use of org.jboss.pnc.bpm.model.BpmStringMapNotificationRest in project pnc by project-ncl.
the class BpmSchedulerSmokeTest method notificationTest.
@Test
public void notificationTest() throws CoreException {
successNotification = false;
errorNotification = false;
BpmTask task = new BpmTask("") {
@Override
public String getProcessId() {
return "colors";
}
@Override
protected Serializable getProcessParameters() throws CoreException {
return new SimpleParameters();
}
};
task.<BpmStringMapNotificationRest>addListener(RC_REPO_CREATION_SUCCESS, t -> {
assertEquals("green", t.getData().get("color"));
successNotification = true;
});
task.<BpmStringMapNotificationRest>addListener(RC_REPO_CREATION_ERROR, t -> {
assertEquals("red", t.getData().get("color"));
errorNotification = true;
});
bpmManager.startTask(task);
// notify
assertEquals(new Integer(1), task.getTaskId());
BpmStringMapNotificationRest notification = mock(BpmStringMapNotificationRest.class);
when(notification.getEventType()).thenReturn(RC_REPO_CREATION_SUCCESS.name());
Map<String, String> data = new HashMap<>();
data.put("color", "green");
when(notification.getData()).thenReturn(data);
bpmManager.notify(1, notification);
assertTrue(successNotification);
assertFalse(errorNotification);
}
Aggregations