@Test public void testFirstNotifyFails() { String alertType = "phideaux"; String id = "foobar"; String message = "it burns... it burns..."; RuntimeException e = new RuntimeException(); Mockito.doThrow(e).when(notifier1).notify(alertType, id, message); alertService.raiseAlert(alertType, id, message); Mockito.verify(notifier1, Mockito.times(1)).notify(Mockito.eq(alertType), Mockito.eq(id), Mockito.eq(message)); Mockito.verify(notifier2, Mockito.times(1)).notify(Mockito.eq(alertType), Mockito.eq(id), Mockito.eq(message)); Mockito.verify(log, Mockito.times(1)).error(Mockito.anyString(), Mockito.eq(e)); }
@Override public void raiseAlert(String alertType, String id, String message) { getSpaceEnvironment().getLog().error("Alert being raised."); for (AlertNotifier notifier : alertNotifiers) { try { notifier.notify(alertType, id, message); } catch (Exception e) { getSpaceEnvironment().getLog().error("Error notifying about alert", e); } } }
BasicAlertService extends BaseSupportedService implements AlertService { @Override public void raiseAlert(String alertType, String id, String message) { getSpaceEnvironment().getLog().error("Alert being raised."); for (AlertNotifier notifier : alertNotifiers) { try { notifier.notify(alertType, id, message); } catch (Exception e) { getSpaceEnvironment().getLog().error("Error notifying about alert", e); } } } }
BasicAlertService extends BaseSupportedService implements AlertService { @Override public void raiseAlert(String alertType, String id, String message) { getSpaceEnvironment().getLog().error("Alert being raised."); for (AlertNotifier notifier : alertNotifiers) { try { notifier.notify(alertType, id, message); } catch (Exception e) { getSpaceEnvironment().getLog().error("Error notifying about alert", e); } } }  }
BasicAlertService extends BaseSupportedService implements AlertService { @Override public void raiseAlert(String alertType, String id, String message) { getSpaceEnvironment().getLog().error("Alert being raised."); for (AlertNotifier notifier : alertNotifiers) { try { notifier.notify(alertType, id, message); } catch (Exception e) { getSpaceEnvironment().getLog().error("Error notifying about alert", e); } } }  @Override String getName(); @Override void startup(); @Override void raiseAlert(String alertType, String id, String message); @Override void registerAlertNotifier(AlertNotifier notifier); @Override void unregisterAlertNotifier(AlertNotifier notifier); }
BasicAlertService extends BaseSupportedService implements AlertService { @Override public void raiseAlert(String alertType, String id, String message) { getSpaceEnvironment().getLog().error("Alert being raised."); for (AlertNotifier notifier : alertNotifiers) { try { notifier.notify(alertType, id, message); } catch (Exception e) { getSpaceEnvironment().getLog().error("Error notifying about alert", e); } } }  @Override String getName(); @Override void startup(); @Override void raiseAlert(String alertType, String id, String message); @Override void registerAlertNotifier(AlertNotifier notifier); @Override void unregisterAlertNotifier(AlertNotifier notifier);  }