use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class LaneTest method testLane.
@Test(timeout = 30000)
public void testLane() {
KieSession ksession = createKSession(PROCESS);
TrackingProcessEventListener tpel = new TrackingProcessEventListener();
ksession.addEventListener(tpel);
ksession.execute((Command<?>) getCommands().newStartProcess(PROCESS_ID));
assertProcessStarted(tpel, PROCESS_ID);
assertTriggeredAndLeft(tpel, "start");
assertTriggered(tpel, "fork");
assertLeft(tpel, "fork", 2);
assertTriggeredAndLeft(tpel, "scriptTask1");
assertTriggeredAndLeft(tpel, "scriptTask2");
assertTriggered(tpel, "end1");
assertTriggered(tpel, "end2");
assertProcessCompleted(tpel, PROCESS_ID);
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class TransactionsTest method testUsertask.
@Test(timeout = 60000)
public void testUsertask() throws Exception {
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(process);
ListWorkItemHandler handler = new ListWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
long processId = startProcess(ksession);
UserTransaction ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "usertask", processId);
Assertions.assertThat(process.wasNodeLeft("usertask")).isTrue();
Assertions.assertThat(handler.getWorkItems()).hasSize(1);
} finally {
ut.rollback();
}
// human tasks are not aborted (as that would not cause the task to be cancelled
process.clear();
ksession = restoreKSession(resources);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
ksession.addEventListener(process);
ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "usertask", processId);
ut.commit();
} catch (Exception ex) {
ut.rollback();
throw ex;
}
String lastUserTaskNodeName = "User Task";
assertTrue("Node '" + lastUserTaskNodeName + "' was not left on time!", process.waitForNodeTobeTriggered(lastUserTaskNodeName, 1000));
Assertions.assertThat(handler.getWorkItems()).hasSize(2);
Assertions.assertThat(process.wasNodeLeft("usertask")).isTrue();
Assertions.assertThat(process.wasNodeTriggered(lastUserTaskNodeName)).isTrue();
Assertions.assertThat(process.wasNodeLeft(lastUserTaskNodeName)).isFalse();
Assertions.assertThat(process.wasProcessCompleted("transactions")).isFalse();
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class TransactionsTest method testForLoop.
@Test(timeout = 60000)
public void testForLoop() throws Exception {
TrackingProcessEventListener process = new TrackingProcessEventListener(false);
ksession.addEventListener(process);
Map<String, Object> params = new HashMap<String, Object>();
params.put("collection", Arrays.asList("hello world", "25", "false", "1234567891011121314151617181920", ""));
long processId = ksession.startProcess(TRANSACTIONS_ID, params).getId();
String forLoopNodeName = "forloop";
UserTransaction ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", forLoopNodeName, processId);
assertTrue("Node '" + forLoopNodeName + "' was not left on time!", process.waitForNodeToBeLeft(forLoopNodeName, 1000));
Assertions.assertThat(process.wasNodeLeft(forLoopNodeName)).isTrue();
} finally {
ut.rollback();
}
process.clear();
ksession = restoreKSession(resources);
ksession.addEventListener(process);
ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "forloop", processId);
ut.commit();
} catch (Exception ex) {
ut.rollback();
throw ex;
}
String multipleInstancesNode = "Multiple Instances";
assertTrue("Process did not complete on time!", process.waitForNodeToBeLeft(multipleInstancesNode, 1000));
Assertions.assertThat(process.wasNodeLeft(forLoopNodeName)).isTrue();
Assertions.assertThat(process.wasNodeLeft(multipleInstancesNode)).isTrue();
Assertions.assertThat(process.wasProcessCompleted("transactions")).isFalse();
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class TransactionsTest method testScript.
@Test(timeout = 60000)
public void testScript() throws Exception {
TrackingProcessEventListener process = new TrackingProcessEventListener(false);
ksession.addEventListener(process);
long processId = startProcess(ksession);
UserTransaction ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "script", processId);
Assertions.assertThat(process.wasNodeLeft("script")).isTrue();
} finally {
ut.rollback();
}
process.clear();
ksession = restoreKSession(resources);
ksession.addEventListener(process);
String scriptNodeName = "script";
ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "script", processId);
assertTrue("Node '" + scriptNodeName + "' was not left on time!", process.waitForNodeToBeLeft(scriptNodeName, 1000));
Assertions.assertThat(ut.getStatus()).isEqualTo(Status.STATUS_ACTIVE);
ut.commit();
} catch (Exception ex) {
ut.rollback();
throw ex;
}
Assertions.assertThat(process.wasNodeLeft(scriptNodeName)).isTrue();
ksession.signalEvent("finish", null, processId);
assertTrue("Process was not completed on time!", process.waitForProcessToComplete(1000));
assertProcessInstanceCompleted(processId);
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class StartEventTest method testDelayingTimerStartEvent.
@Test(timeout = 30000)
public void testDelayingTimerStartEvent() throws Exception {
KieSession ksession = createKSession(TIMER_DURATION);
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(process);
ksession.fireAllRules();
assertTrue("The process did not start on time!", process.waitForProcessToStart(1000));
assertTrue("The process did not complete on time!", process.waitForProcessToComplete(1000));
ksession.fireAllRules();
Assertions.assertThat(process.wasProcessStarted(TIMER_DURATION_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(TIMER_DURATION_ID)).isTrue();
process.clear();
}
Aggregations