|
18 | 18 | import static org.mockito.Matchers.eq;
|
19 | 19 | import static org.mockito.Mockito.mock;
|
20 | 20 | import static org.mockito.Mockito.verify;
|
| 21 | +import static org.mockito.Mockito.verifyNoMoreInteractions; |
21 | 22 |
|
22 | 23 | import org.junit.Before;
|
23 | 24 | import org.junit.Test;
|
@@ -60,4 +61,47 @@ public void test_onApplicationEvent() {
|
60 | 61 | verify(sender).send(eq(expected));
|
61 | 62 | }
|
62 | 63 |
|
| 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 | + } |
63 | 107 | }
|
0 commit comments