use of com.thinkbiganalytics.alerts.api.AlertResponder in project kylo by Teradata.
the class AggregatingAlertProvider method accept.
/* (non-Javadoc)
* @see reactor.fn.Consumer#accept(java.lang.Object)
*/
@Override
public void accept(Event<Alert> event) {
final Alert alert = unwrapAlert(event.getData());
final AlertManager mgr = (AlertManager) alert.getSource();
final List<AlertResponder> responders = snapshotResponderts();
responders.forEach(responder -> {
AlertResponse resp = mgr.getResponse(alert);
AlertResponseWrapper wrapper = new AlertResponseWrapper(resp);
responder.alertChange(alert, wrapper);
});
}
use of com.thinkbiganalytics.alerts.api.AlertResponder in project kylo by Teradata.
the class AggregatingAlertProviderTest method testRespondToChange.
@Test
public void testRespondToChange() throws InterruptedException {
TestAlert initMgrAlert = new TestAlert(this.manager, true);
CountDownLatch latch = new CountDownLatch(1);
this.provider.addAlertManager(this.manager);
when(this.manager.getAlert(any(Alert.ID.class))).thenReturn(Optional.of(initMgrAlert));
when(this.manager.getAlertAsServiceAccount(any(Alert.ID.class))).thenReturn(Optional.of(initMgrAlert));
when(this.manager.getResponse(any(Alert.class))).thenReturn(this.response);
when(this.response.handle(any(String.class), any(Serializable.class))).thenReturn(initMgrAlert);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
latch.countDown();
return null;
}
}).when(this.listener).alertChange(any(Alert.class));
this.provider.respondTo(new SourceAlertID(initMgrAlert.getId(), this.manager), new AlertResponder() {
@Override
public void alertChange(Alert alert, AlertResponse response) {
response.handle(null, "handled");
}
});
latch.await(10, TimeUnit.SECONDS);
verify(this.response).handle(eq(null), eq("handled"));
verify(this.listener, atLeastOnce()).alertChange(any(Alert.class));
}
Aggregations