Skip to content

Commit 8e86ed0

Browse files
committed
Move AbstractNotifier-tests to MailNotifierTests
Tests in Abstract*.class are not executed during the maven build, so I moved the tests for code in AbstractNotifierTest to MailNotifierTest
1 parent 1c5abd5 commit 8e86ed0

File tree

2 files changed

+44
-90
lines changed

2 files changed

+44
-90
lines changed

spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/notify/AbstractNotifierTest.java

-90
This file was deleted.

spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/notify/MailNotifierTest.java

+44
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static org.mockito.Matchers.eq;
1919
import static org.mockito.Mockito.mock;
2020
import static org.mockito.Mockito.verify;
21+
import static org.mockito.Mockito.verifyNoMoreInteractions;
2122

2223
import org.junit.Before;
2324
import org.junit.Test;
@@ -60,4 +61,47 @@ public void test_onApplicationEvent() {
6061
verify(sender).send(eq(expected));
6162
}
6263

64+
// The following tests are rather for AbstractNotifier
65+
66+
@Test
67+
public void test_onApplicationEvent_disbaled() {
68+
notifier.setEnabled(false);
69+
notifier.onClientApplicationStatusChanged(new ClientApplicationStatusChangedEvent(
70+
Application.create("App").withId("-id-").withHealthUrl("http://health").build(),
71+
StatusInfo.ofDown(), StatusInfo.ofUp()));
72+
73+
verifyNoMoreInteractions(sender);
74+
}
75+
76+
@Test
77+
public void test_onApplicationEvent_noSend() {
78+
notifier.onClientApplicationStatusChanged(new ClientApplicationStatusChangedEvent(
79+
Application.create("App").withId("-id-").withHealthUrl("http://health").build(),
80+
StatusInfo.ofUnknown(), StatusInfo.ofUp()));
81+
82+
verifyNoMoreInteractions(sender);
83+
}
84+
85+
@Test
86+
public void test_onApplicationEvent_noSend_wildcard() {
87+
notifier.setIgnoreChanges(new String[] { "*:UP" });
88+
notifier.onClientApplicationStatusChanged(new ClientApplicationStatusChangedEvent(
89+
Application.create("App").withId("-id-").withHealthUrl("http://health").build(),
90+
StatusInfo.ofOffline(), StatusInfo.ofUp()));
91+
92+
verifyNoMoreInteractions(sender);
93+
}
94+
95+
@Test
96+
public void test_onApplicationEvent_throw_doesnt_propagate() {
97+
AbstractNotifier notifier = new AbstractNotifier() {
98+
@Override
99+
protected void notify(ClientApplicationStatusChangedEvent event) throws Exception {
100+
throw new RuntimeException();
101+
}
102+
};
103+
notifier.onClientApplicationStatusChanged(new ClientApplicationStatusChangedEvent(
104+
Application.create("App").withId("-id-").withHealthUrl("http://health").build(),
105+
StatusInfo.ofOffline(), StatusInfo.ofUp()));
106+
}
63107
}

0 commit comments

Comments
 (0)