2020import de .codecentric .boot .admin .server .domain .events .InstanceStatusChangedEvent ;
2121import de .codecentric .boot .admin .server .domain .values .InstanceId ;
2222import de .codecentric .boot .admin .server .domain .values .StatusInfo ;
23+ import reactor .core .publisher .Mono ;
2324import reactor .test .StepVerifier ;
2425
2526import java .util .Arrays ;
2829import static org .assertj .core .api .Assertions .assertThat ;
2930
3031public class CompositeNotifierTest {
31- private static final InstanceEvent APP_DOWN = new InstanceStatusChangedEvent (InstanceId .of ("-" ), 0L ,
32- StatusInfo .ofDown ());
32+ private static final InstanceEvent APP_DOWN = new InstanceStatusChangedEvent (InstanceId .of ("-" ),
33+ 0L ,
34+ StatusInfo .ofDown ()
35+ );
3336
3437 @ Test (expected = IllegalArgumentException .class )
35- public void test_ctor_assert () {
38+ public void should_throw_for_invariants () {
3639 new CompositeNotifier (null );
3740 }
3841
3942 @ Test
40- public void test_all_notifiers_get_notified () {
43+ public void should_trigger_all_notifiers () {
4144 TestNotifier notifier1 = new TestNotifier ();
4245 TestNotifier notifier2 = new TestNotifier ();
4346 CompositeNotifier compositeNotifier = new CompositeNotifier (Arrays .asList (notifier1 , notifier2 ));
@@ -47,4 +50,15 @@ public void test_all_notifiers_get_notified() {
4750 assertThat (notifier1 .getEvents ()).containsOnly (APP_DOWN );
4851 assertThat (notifier2 .getEvents ()).containsOnly (APP_DOWN );
4952 }
53+
54+ @ Test
55+ public void should_continue_on_exception () {
56+ Notifier notifier1 = ev -> Mono .error (new IllegalStateException ("Test" ));
57+ TestNotifier notifier2 = new TestNotifier ();
58+ CompositeNotifier compositeNotifier = new CompositeNotifier (Arrays .asList (notifier1 , notifier2 ));
59+
60+ StepVerifier .create (compositeNotifier .notify (APP_DOWN )).verifyComplete ();
61+
62+ assertThat (notifier2 .getEvents ()).containsOnly (APP_DOWN );
63+ }
5064}
0 commit comments