use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class HumanTaskTest method testBoundaryTimer.
@Test
@BZ("958397")
public void testBoundaryTimer() throws Exception {
createRuntimeManager(BOUNDARY_TIMER);
KieSession ksession = getRuntimeEngine().getKieSession();
TaskService taskService = getRuntimeEngine().getTaskService();
TrackingProcessEventListener tpel = new TrackingProcessEventListener();
ksession.addEventListener(tpel);
ProcessInstance pi = ksession.startProcess(BOUNDARY_TIMER_ID);
// wait for timer
String endNodeName = "End1";
assertTrue("Node '" + endNodeName + "' was not triggered on time!", tpel.waitForNodeTobeTriggered(endNodeName, 2000));
assertTriggeredAndLeft(tpel, "Script1");
assertTriggered(tpel, endNodeName);
long taskId = taskService.getTasksByProcessInstanceId(pi.getId()).get(0);
taskService.start(taskId, "john");
taskService.complete(taskId, "john", null);
assertTriggeredAndLeft(tpel, "Script2");
assertTriggered(tpel, "End2");
assertProcessInstanceCompleted(pi.getId());
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EventListenersTest method testClearExecution.
@Test(timeout = 60000L)
public void testClearExecution() {
TrackingProcessEventListener listener = new TrackingProcessEventListener();
ksession.addEventListener(listener);
List<Command<?>> commands = new ArrayList<Command<?>>();
commands.add(getCommands().newStartProcess(PROCESS_ID));
commands.add(getCommands().newSignalEvent("other-branch", "hello world!"));
ksession.execute(getCommands().newBatchExecution(commands, null));
assertTrue(listener.wasNodeTriggered("introduction"));
assertFalse(listener.wasNodeTriggered("script-warning"));
assertTrue(listener.wasNodeLeft("introduction"));
assertFalse(listener.wasNodeLeft("script-warning"));
assertTrue(listener.wasVariableChanged("signalData"));
assertFalse(listener.wasVariableChanged("stringVariable"));
assertTrue(listener.wasProcessStarted(PROCESS_ID));
assertTrue(listener.wasProcessCompleted(PROCESS_ID));
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class TransactionsTest method testAbortProcessCommit.
@Test(timeout = 60000)
public void testAbortProcessCommit() throws Exception {
long processId = startProcess(ksession);
TrackingProcessEventListener listener = new TrackingProcessEventListener();
ksession.addEventListener(listener);
assertProcessInstanceActive(processId);
UserTransaction ut = getUserTransaction();
try {
ut.begin();
ksession.abortProcessInstance(processId);
ut.commit();
} catch (Exception ex) {
ut.rollback();
throw ex;
}
ksession = restoreKSession(resources);
assertProcessInstanceAborted(processId);
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class TransactionsTest method testTimer.
@Test
public void testTimer() throws Exception {
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(process);
long processId = startProcess(ksession);
UserTransaction ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "timer", processId);
Assertions.assertThat(process.wasNodeLeft("timer")).isTrue();
} finally {
ut.rollback();
}
Thread.sleep(600);
process.clear();
ksession = restoreKSession(resources);
ksession.addEventListener(process);
ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "timer", processId);
ut.commit();
} catch (Exception ex) {
ut.rollback();
throw ex;
}
String timerNodeName = "timer";
assertTrue("Node '" + timerNodeName + "' was not left on time!", process.waitForNodeToBeLeft(timerNodeName, 1500));
Assertions.assertThat(process.wasNodeLeft(timerNodeName)).isTrue();
String finishScriptNodeName = "Finish-Script";
assertTrue("Node '" + finishScriptNodeName + "' was not triggered on time!", process.waitForNodeTobeTriggered(finishScriptNodeName, 1500));
ksession.signalEvent("finish", null, processId);
assertTrue("Process did not complete on time!", process.waitForProcessToComplete(1500));
assertProcessInstanceCompleted(processId);
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class TransactionsTest method testEmbedded.
@Test(timeout = 60000)
public void testEmbedded() throws Exception {
TrackingProcessEventListener process = new TrackingProcessEventListener(false);
ksession.addEventListener(process);
long processId = startProcess(ksession);
UserTransaction ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "embedded", processId);
assertTrue("Node 'embedded' was not left on time!", process.waitForNodeToBeLeft("embedded", 1000));
Assertions.assertThat(process.wasNodeLeft("embedded")).isTrue();
} finally {
ut.rollback();
}
process.clear();
ksession = restoreKSession(resources);
ksession.addEventListener(process);
ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "embedded", processId);
ut.commit();
} catch (Exception ex) {
ut.rollback();
throw ex;
}
assertTrue("Node 'embedded' was not left on time!", process.waitForNodeToBeLeft("embedded", 1000));
Assertions.assertThat(process.wasNodeLeft("embedded")).isTrue();
Assertions.assertThat(process.wasProcessCompleted("transactions")).isFalse();
}
Aggregations