use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class StartEventTest method testConditionalStartEvent.
@Test(timeout = 30000)
public void testConditionalStartEvent() {
KieSession ksession = createKSession(CONDITIONAL);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
List<Command<?>> cmds = new ArrayList<Command<?>>();
cmds.add(getCommands().newInsert("condition"));
cmds.add(getCommands().newFireAllRules());
ksession.execute(getCommands().newBatchExecution(cmds, null));
Assertions.assertThat(process.wasProcessStarted(CONDITIONAL_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(CONDITIONAL_ID)).isTrue();
assertProcessStarted(events, CONDITIONAL_ID);
assertNextNode(events, "start");
assertNextNode(events, "script");
assertNextNode(events, "end");
assertProcessCompleted(events, CONDITIONAL_ID);
Assertions.assertThat(events.hasNext()).isFalse();
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class StartEventTest method testNoneStartEvent.
@Test(timeout = 30000)
public void testNoneStartEvent() {
KieSession ksession = createKSession(NONE);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
Command<?> cmd = getCommands().newStartProcess(NONE_ID);
ksession.execute(cmd);
Assertions.assertThat(process.wasProcessStarted(NONE_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(NONE_ID)).isTrue();
assertProcessStarted(events, NONE_ID);
assertNextNode(events, "start");
assertNextNode(events, "script");
assertNextNode(events, "end");
assertProcessCompleted(events, NONE_ID);
Assertions.assertThat(events.hasNext()).isFalse();
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class StartEventTest method testMessageStartEvent.
@Test(timeout = 30000)
public void testMessageStartEvent() {
KieSession ksession = createKSession(MESSAGE);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
Command<?> cmd = getCommands().newSignalEvent("Message-type", null);
ksession.execute(cmd);
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();
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class StartEventTest method testRecurringTimerStartEvent.
@Test(timeout = 30000)
public void testRecurringTimerStartEvent() throws Exception {
KieSession ksession = createKSession(TIMER_CYCLE);
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));
Assertions.assertThat(process.wasProcessStarted(TIMER_CYCLE_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(TIMER_CYCLE_ID)).isTrue();
process.clear();
for (int i = 0; i < 10; i++) {
assertTrue("The process was not triggered on time!", process.waitForProcessToStart(1000));
assertTrue("The process did not complete on time!", process.waitForProcessToComplete(1000));
Assertions.assertThat(process.wasProcessStarted(TIMER_CYCLE_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(TIMER_CYCLE_ID)).isTrue();
process.clear();
}
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EventBasedGatewayTest method testMessage.
@Test(timeout = 30000)
public void testMessage() {
TrackingProcessEventListener tpel = new TrackingProcessEventListener();
ksession.addEventListener(tpel);
ProcessInstance pi = (ProcessInstance) ksession.execute((Command<?>) CommandFactory.newStartProcess(EVENT_BASED_GATEWAY_ID));
TrackingListenerAssert.assertProcessStarted(tpel, EVENT_BASED_GATEWAY_ID);
TrackingListenerAssert.assertTriggeredAndLeft(tpel, "start");
TrackingListenerAssert.assertTriggeredAndLeft(tpel, "fork");
TrackingListenerAssert.assertTriggered(tpel, "msg");
ksession.execute((Command<?>) CommandFactory.newSignalEvent(pi.getId(), "Message-message1", null));
TrackingListenerAssert.assertLeft(tpel, "msg");
TrackingListenerAssert.assertTriggeredAndLeft(tpel, "join");
TrackingListenerAssert.assertTriggered(tpel, "end");
TrackingListenerAssert.assertProcessCompleted(tpel, EVENT_BASED_GATEWAY_ID);
}
Aggregations