Search in sources :

Example 31 with IterableProcessEventListener

use of org.jbpm.test.listener.IterableProcessEventListener 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 32 with IterableProcessEventListener

use of org.jbpm.test.listener.IterableProcessEventListener 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 33 with IterableProcessEventListener

use of org.jbpm.test.listener.IterableProcessEventListener 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 34 with IterableProcessEventListener

use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.

the class InclusiveGatewayTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    kieSession = createKSession(INCLUSIVE_GATEWAY);
    iterableListener = new IterableProcessEventListener();
}
Also used : IterableProcessEventListener(org.jbpm.test.listener.IterableProcessEventListener) Before(org.junit.Before)

Aggregations

IterableProcessEventListener (org.jbpm.test.listener.IterableProcessEventListener)34 Test (org.junit.Test)32 KieSession (org.kie.api.runtime.KieSession)18 TrackingProcessEventListener (org.jbpm.test.listener.TrackingProcessEventListener)17 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)15 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 Command (org.kie.api.command.Command)4 BZ (qa.tools.ikeeper.annotation.BZ)3 Person (org.jbpm.test.domain.Person)2 Before (org.junit.Before)2 ResourceType (org.kie.api.io.ResourceType)2 RegisterWorkItemHandlerCommand (org.drools.core.command.runtime.process.RegisterWorkItemHandlerCommand)1 StartProcessCommand (org.drools.core.command.runtime.process.StartProcessCommand)1 JbpmJUnitBaseTestCase (org.jbpm.test.JbpmJUnitBaseTestCase)1 DebugProcessEventListener (org.jbpm.test.listener.DebugProcessEventListener)1 Ignore (org.junit.Ignore)1 WorkItem (org.kie.api.runtime.process.WorkItem)1