use of com.thinkbiganalytics.alerts.api.AlertResponse in project kylo by Teradata.
the class DefaultAlertManagerTest method testAlertResponding.
@Test(dependsOnGroups = "create", groups = "update1")
public void testAlertResponding() {
Alert alert = this.manager.getAlertAsServiceAccount(id1).get();
AlertResponse resp = this.manager.getResponse(alert);
alert = resp.inProgress(LONG_DESCR);
Assertions.assertThat(alert.getEvents()).hasSize(2).extracting("state", "description", "content").contains(Assertions.tuple(State.UNHANDLED, null, null), Assertions.tuple(State.IN_PROGRESS, TRUNK_DESCR, null));
alert = resp.handle("Change handled", new Integer(42));
Assertions.assertThat(alert.getEvents()).hasSize(3).extracting("state", "description", "content").contains(Assertions.tuple(State.UNHANDLED, null, null), Assertions.tuple(State.IN_PROGRESS, TRUNK_DESCR, null), Assertions.tuple(State.HANDLED, "Change handled", 42));
Mockito.verify(this.alertReceiver, Mockito.times(2)).alertsAvailable(Matchers.anyInt());
}
use of com.thinkbiganalytics.alerts.api.AlertResponse 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.AlertResponse 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));
}
use of com.thinkbiganalytics.alerts.api.AlertResponse in project kylo by Teradata.
the class DefaultAlertManagerTest method testClear.
@Test(dependsOnGroups = "read2", groups = "update2")
public void testClear() {
Alert alert = this.manager.getAlertAsServiceAccount(id1).get();
AlertResponse resp = this.manager.getResponse(alert);
resp.clear();
alert = this.manager.getAlertAsServiceAccount(id1).get();
Assertions.assertThat(alert).isNotNull();
Assertions.assertThat(alert.isCleared()).isTrue();
Mockito.verify(this.alertReceiver, Mockito.times(0)).alertsAvailable(Matchers.anyInt());
}
Aggregations