Search in sources :

Example 21 with TrackingProcessEventListener

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();
}
Also used : IterableProcessEventListener(org.jbpm.test.listener.IterableProcessEventListener) TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test)

Example 22 with TrackingProcessEventListener

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);
}
Also used : Command(org.kie.api.command.Command) TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 23 with TrackingProcessEventListener

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);
}
Also used : SessionPseudoClock(org.kie.api.time.SessionPseudoClock) TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) Test(org.junit.Test)

Example 24 with TrackingProcessEventListener

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();
}
Also used : TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) Before(org.junit.Before)

Example 25 with 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();
}
Also used : IterableProcessEventListener(org.jbpm.test.listener.IterableProcessEventListener) TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test)

Aggregations

TrackingProcessEventListener (org.jbpm.test.listener.TrackingProcessEventListener)51 Test (org.junit.Test)49 KieSession (org.kie.api.runtime.KieSession)25 IterableProcessEventListener (org.jbpm.test.listener.IterableProcessEventListener)17 Command (org.kie.api.command.Command)16 ArrayList (java.util.ArrayList)13 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)13 BZ (qa.tools.ikeeper.annotation.BZ)9 UserTransaction (javax.transaction.UserTransaction)7 RegisterWorkItemHandlerCommand (org.drools.core.command.runtime.process.RegisterWorkItemHandlerCommand)6 CompleteWorkItemCommand (org.drools.core.command.runtime.process.CompleteWorkItemCommand)5 HashMap (java.util.HashMap)3 TrackingAgendaEventListener (org.jbpm.test.listener.TrackingAgendaEventListener)2 WorkItem (org.kie.api.runtime.process.WorkItem)2 AsyncWorkItemHandler (org.jbpm.executor.impl.wih.AsyncWorkItemHandler)1 JbpmJUnitBaseTestCase (org.jbpm.test.JbpmJUnitBaseTestCase)1 TrackingRuleRuntimeEventListener (org.jbpm.test.listener.TrackingRuleRuntimeEventListener)1 ListWorkItemHandler (org.jbpm.test.wih.ListWorkItemHandler)1 DynamicNodeInstance (org.jbpm.workflow.instance.node.DynamicNodeInstance)1 Before (org.junit.Before)1