use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class TransactionsTest method testRuleflowGroup.
@Test(timeout = 60000)
public void testRuleflowGroup() throws Exception {
TrackingProcessEventListener process = new TrackingProcessEventListener(false);
TrackingAgendaEventListener agenda = new TrackingAgendaEventListener();
ksession.addEventListener(process);
ksession.addEventListener(agenda);
long processId = startProcess(ksession);
UserTransaction ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "rfg", processId);
Assertions.assertThat(process.wasNodeLeft("rfg")).isTrue();
} finally {
ut.rollback();
}
Thread.sleep(600);
process.clear();
agenda.clear();
ksession = restoreKSession(resources);
ksession.addEventListener(process);
ksession.addEventListener(agenda);
ksession.fireAllRules();
Assertions.assertThat(agenda.isRuleFired("dummyRule")).isFalse();
agenda.clear();
process.clear();
String ruleFlowGroupNodeName = "rfg";
ut = getUserTransaction();
try {
ut.begin();
ksession.signalEvent("start", "rfg", processId);
assertTrue("Node '" + ruleFlowGroupNodeName + "' was not left on time!", process.waitForNodeToBeLeft(ruleFlowGroupNodeName, 1000));
ut.commit();
} catch (Exception ex) {
ut.rollback();
throw ex;
}
Assertions.assertThat(process.wasNodeLeft(ruleFlowGroupNodeName)).isTrue();
ksession.signalEvent("finish", null, processId);
ksession.fireAllRules();
assertTrue("Process did not complete on time!", process.waitForProcessToComplete(1000));
Assertions.assertThat(agenda.isRuleFired("dummyRule")).isTrue();
assertProcessInstanceCompleted(processId);
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EndEventTest method testEscalationEndEvent.
@BZ("1015221")
@Test(timeout = 30000)
public void testEscalationEndEvent() {
KieSession ksession = createKSession(ESCALATION);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
Command<?> cmd = getCommands().newStartProcess(ESCALATION_ID);
ksession.execute(cmd);
Assertions.assertThat(process.wasProcessStarted(ESCALATION_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(ESCALATION_ID)).isFalse();
Assertions.assertThat(process.wasProcessAborted(ESCALATION_ID)).isTrue();
assertProcessStarted(events, ESCALATION_ID);
assertNextNode(events, "start");
assertNextNode(events, "script");
assertTriggered(events, "end");
assertProcessCompleted(events, ESCALATION_ID);
assertFalse(events.hasNext());
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EndEventTest method testErrorEndEvent.
@Test(timeout = 30000)
public void testErrorEndEvent() {
KieSession ksession = createKSession(ERROR);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
Command<?> cmd = getCommands().newStartProcess(ERROR_ID);
ksession.execute(cmd);
Assertions.assertThat(process.wasProcessStarted(ERROR_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(ERROR_ID)).isFalse();
Assertions.assertThat(process.wasProcessAborted(ERROR_ID)).isTrue();
assertProcessStarted(events, ERROR_ID);
assertNextNode(events, "start");
assertNextNode(events, "script");
assertTriggered(events, "end");
assertProcessCompleted(events, ERROR_ID);
Assertions.assertThat(events.hasNext()).isFalse();
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EndEventTest method testTerminatingEndEvent.
@Test(timeout = 30000)
public void testTerminatingEndEvent() {
KieSession ksession = createKSession(TERMINATING);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
Command<?> cmd = getCommands().newStartProcess(TERMINATING_ID);
ksession.execute(cmd);
Assertions.assertThat(process.wasProcessStarted(TERMINATING_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(TERMINATING_ID)).isTrue();
assertProcessStarted(events, TERMINATING_ID);
assertNextNode(events, "start");
assertNextNode(events, "script");
assertNextNode(events, "end");
assertProcessCompleted(events, TERMINATING_ID);
Assertions.assertThat(events.hasNext()).isFalse();
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EndEventTest method testMessageEndEvent.
@Test(timeout = 30000)
public void testMessageEndEvent() {
KieSession ksession = createKSession(MESSAGE);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
RecordingHandler handler = new RecordingHandler();
List<Command<?>> cmds = new ArrayList<Command<?>>();
cmds.add(new RegisterWorkItemHandlerCommand("Send Task", handler));
cmds.add(getCommands().newStartProcess(MESSAGE_ID));
ksession.execute(getCommands().newBatchExecution(cmds, null));
Assertions.assertThat(process.wasProcessStarted(MESSAGE_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(MESSAGE_ID)).isTrue();
assertProcessStarted(events, MESSAGE_ID);
assertNextNode(events, "start");
assertNextNode(events, "script");
assertNextNode(events, "end");
assertProcessCompleted(events, MESSAGE_ID);
Assertions.assertThat(events.hasNext()).isFalse();
Assertions.assertThat(handler.item).isNotNull();
}
Aggregations