use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class StartEventTest method testSignalStartEvent.
@Test(timeout = 30000)
public void testSignalStartEvent() {
KieSession ksession = createKSession(SIGNAL);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
Command<?> cmd = getCommands().newSignalEvent("start", null);
ksession.execute(cmd);
Assertions.assertThat(process.wasProcessStarted(SIGNAL_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(SIGNAL_ID)).isTrue();
assertProcessStarted(events, SIGNAL_ID);
assertNextNode(events, "start");
assertNextNode(events, "script");
assertNextNode(events, "end");
assertProcessCompleted(events, SIGNAL_ID);
Assertions.assertThat(events.hasNext()).isFalse();
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EventBasedGatewayTest method testConditional.
/**
* Conditional event branch
*/
@Test(timeout = 30000)
public void testConditional() {
TrackingProcessEventListener tpel = new TrackingProcessEventListener();
ksession.addEventListener(tpel);
List<Command<?>> commands = new ArrayList<Command<?>>();
commands.add(CommandFactory.newInsert(5));
commands.add(CommandFactory.newStartProcess(EVENT_BASED_GATEWAY_ID));
ksession.execute(CommandFactory.newBatchExecution(commands));
TrackingListenerAssert.assertProcessStarted(tpel, EVENT_BASED_GATEWAY_ID);
TrackingListenerAssert.assertTriggeredAndLeft(tpel, "start");
TrackingListenerAssert.assertTriggeredAndLeft(tpel, "fork");
TrackingListenerAssert.assertTriggeredAndLeft(tpel, "cond");
TrackingListenerAssert.assertTriggeredAndLeft(tpel, "join");
TrackingListenerAssert.assertTriggered(tpel, "end");
TrackingListenerAssert.assertProcessCompleted(tpel, EVENT_BASED_GATEWAY_ID);
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EventBasedGatewayTest method testTimer.
/**
* No branch is selected, timer is triggered after 1 sec
* @throws Exception
*/
@Test(timeout = 30000)
public void testTimer() throws Exception {
Assume.assumeFalse(ksession.getSessionClock() instanceof SessionPseudoClock);
TrackingProcessEventListener tpel = new TrackingProcessEventListener();
ksession.addEventListener(tpel);
ksession.execute((Command<?>) CommandFactory.newStartProcess(EVENT_BASED_GATEWAY_ID));
TrackingListenerAssert.assertProcessStarted(tpel, EVENT_BASED_GATEWAY_ID);
TrackingListenerAssert.assertTriggeredAndLeft(tpel, "start");
TrackingListenerAssert.assertTriggered(tpel, "fork");
TrackingListenerAssert.assertLeft(tpel, "fork", 4);
TrackingListenerAssert.assertTriggered(tpel, "cond");
TrackingListenerAssert.assertTriggered(tpel, "msg");
TrackingListenerAssert.assertTriggered(tpel, "sig");
String timerNodeName = "timer";
TrackingListenerAssert.assertTriggered(tpel, timerNodeName);
assertTrue("Node '" + timerNodeName + "' was not triggered on time!", tpel.waitForNodeToBeLeft(timerNodeName, 2000));
TrackingListenerAssert.assertLeft(tpel, timerNodeName);
assertTrue("Process was not completed on time!", tpel.waitForProcessToComplete(2000));
TrackingListenerAssert.assertTriggeredAndLeft(tpel, "join");
TrackingListenerAssert.assertTriggered(tpel, "end");
TrackingListenerAssert.assertProcessCompleted(tpel, EVENT_BASED_GATEWAY_ID);
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class ParallelGatewayTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
kieSession = createKSession(PARALLEL_GATEWAY);
trackingListener = new TrackingProcessEventListener();
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EndEventTest method testNoneEndEvent.
@Test(timeout = 30000)
public void testNoneEndEvent() {
KieSession ksession = createKSession(NONE);
IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener();
ksession.addEventListener(events);
ksession.addEventListener(process);
Command<?> cmd = CommandFactory.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();
}
Aggregations