Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
#10 Notify of Revivival
Browse files Browse the repository at this point in the history
  • Loading branch information
baardl committed Aug 18, 2020
1 parent fc86f52 commit d1dee75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,15 @@ synchronized void notifyAlerters(Status status) {
if (alerter.isAlertingEnabled()) {
String serviceName = getProperty("service_name");
String environment = getProperty("environment");
String message = "Integration Failed on" + serviceName + " in " + environment + ". Status is " + status.toString();
log.trace("Sending alert: {}", message);
alerter.notifyFailure(message);
if (status == Status.OK) {
String message = "Integration OK on" + serviceName + " in " + environment + ". Status is " + status.toString();
log.trace("Sending alert: {}", message);
alerter.notifyRevival(message);
} else {
String message = "Integration Failed on" + serviceName + " in " + environment + ". Status is " + status.toString();
log.trace("Sending alert: {}", message);
alerter.notifyFailure(message);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,25 @@ public void notifyAlertersFromUnknownToFailure() {
manager.notifyAlerters(Status.FAILED);

verify(alerter, times(1)).isAlertingEnabled();
verify(alerter, times(1)).notifyFailure(anyString());
}

@Test
public void multipleFailedStatuses() {

when(alerter.isAlertingEnabled()).thenReturn(true);
manager.notifyAlerters(Status.FAILED);
manager.notifyAlerters(Status.FAILED);
verify(alerter, times(2)).isAlertingEnabled();
}

@Test
public void notifyAlertersFromOkToFailedToOk() {
when(alerter.isAlertingEnabled()).thenReturn(true);
manager.notifyAlerters(Status.FAILED);
verify(alerter, times(1)).isAlertingEnabled();
verify(alerter, times(1)).notifyFailure(anyString());
manager.notifyAlerters(Status.OK);
verify(alerter, times(2)).isAlertingEnabled();
verify(alerter, times(1)).notifyRevival(anyString());
}
}

0 comments on commit d1dee75

Please sign in to comment.