Search in sources :

Example 46 with TrackingProcessEventListener

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

Example 47 with TrackingProcessEventListener

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();
}
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 48 with TrackingProcessEventListener

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();
}
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 49 with TrackingProcessEventListener

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

Example 50 with TrackingProcessEventListener

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);
}
Also used : Command(org.kie.api.command.Command) TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) 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