Search in sources :

Example 1 with BpmStringMapNotificationRest

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);
}
Also used : BpmTask(org.jboss.pnc.bpm.BpmTask) HashMap(java.util.HashMap) BpmStringMapNotificationRest(org.jboss.pnc.bpm.model.BpmStringMapNotificationRest) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 BpmTask (org.jboss.pnc.bpm.BpmTask)1 BpmStringMapNotificationRest (org.jboss.pnc.bpm.model.BpmStringMapNotificationRest)1 Test (org.junit.Test)1