@@ -0,0 +1,2828 @@
+/*%0A * Copyright 2014 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage de.codecentric.boot.admin.config;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.hamcrest.Matchers.empty;%0Aimport static org.junit.Assert.assertThat;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport org.junit.After;%0Aimport org.junit.Test;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.web.context.support.AnnotationConfigWebApplicationContext;%0A%0Aimport de.codecentric.boot.admin.event.ClientApplicationEvent;%0Aimport de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent;%0Aimport de.codecentric.boot.admin.model.Application;%0Aimport de.codecentric.boot.admin.model.StatusInfo;%0Aimport de.codecentric.boot.admin.notify.Notifier;%0A%0Apublic class NotifierConfigurationTest %7B%0A%09private static final ClientApplicationEvent APP_DOWN = new ClientApplicationStatusChangedEvent(%0A%09%09%09Application.create(%22App%22).withId(%22id-1%22).withHealthUrl(%22http://health%22)%0A%09%09%09%09%09.withStatusInfo(StatusInfo.ofDown()).build(),%0A%09%09%09StatusInfo.ofUp(), StatusInfo.ofDown());%0A%0A%09private AnnotationConfigWebApplicationContext context;%0A%0A%09@After%0A%09public void close() %7B%0A%09%09if (this.context != null) %7B%0A%09%09%09this.context.close();%0A%09%09%7D%0A%09%7D%0A%0A%09@Test%0A%09public void test_notifierListener() %7B%0A%09%09load(TestNotifierConfig.class);%0A%09%09context.publishEvent(APP_DOWN);%0A%09%09assertThat(context.getBean(TestNotifier.class).getEvents(), is(Arrays.asList(APP_DOWN)));%0A%09%7D%0A%0A%09@Test%0A%09public void test_no_notifierListener() %7B%0A%09%09load(null);%0A%09%09assertThat(context.getBeansOfType(Notifier.class).values(), empty());%0A%09%7D%0A%0A%09private void load(Class%3C?%3E config) %7B%0A%09%09context = new AnnotationConfigWebApplicationContext();%0A%09%09if (config != null) %7B%0A%09%09%09context.register(config);%0A%09%09%7D%0A%09%09context.register(NotifierConfiguration.class);%0A%09%09context.refresh();%0A%09%7D%0A%0A%09public static class TestNotifierConfig %7B%0A%09%09@Bean%0A%09%09public Notifier testNotifier() %7B%0A%09%09%09return new TestNotifier();%0A%09%09%7D%0A%0A%09%7D%0A%0A%09private static class TestNotifier implements Notifier %7B%0A%09%09private List%3CClientApplicationEvent%3E events = new ArrayList%3CClientApplicationEvent%3E();%0A%0A%09%09@Override%0A%09%09public void notify(ClientApplicationEvent event) %7B%0A%09%09%09this.events.add(event);%0A%09%09%7D%0A%0A%09%09public List%3CClientApplicationEvent%3E getEvents() %7B%0A%09%09%09return events;%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add tests for NotifierConfiguration