Search in sources :

Example 26 with IterableProcessEventListener

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

the class SubprocessesTest method testDependent.

@Test(timeout = 30000)
public void testDependent() {
    IterableProcessEventListener process = new IterableProcessEventListener();
    ksession.addEventListener(process);
    ProcessInstance pi = ksession.startProcess(PROCESS_ID_2, createBranchDefiningMap("dependent"));
    assertChangedVariable(process, "node", null, "dependent");
    assertProcessStarted(process, PROCESS_ID_2);
    assertNextNode(process, P2_START);
    assertNextNode(process, P2_GATEWAY_START);
    assertTriggered(process, "dependent process");
    assertProcessStarted(process, PROCESS_ID_3);
    long id = process.current().<CachedProcessStartedEvent>getEvent().getProcessInstanceId();
    assertNextNode(process, P3_START);
    assertTriggered(process, P3_SIGNAL);
    // signal the subprocess to continue
    ksession.signalEvent("continue", null, id);
    assertLeft(process, P3_SIGNAL);
    assertTriggered(process, P3_SCRIPT);
    assertChangedVariable(process, "variable", null, "new value");
    assertLeft(process, P3_SCRIPT);
    assertNextNode(process, P3_END);
    assertProcessCompleted(process, PROCESS_ID_3);
    // track the progress after subprocess completion
    assertLeft(process, "dependent process");
    assertNextNode(process, P2_GATEWAY_END);
    assertTriggered(process, P2_SIGNAL_END);
    // signal the parent process to finish
    ksession.signalEvent("finish", null, pi.getId());
    assertLeft(process, P2_SIGNAL_END);
    assertNextNode(process, P2_END);
    assertProcessCompleted(process, PROCESS_ID_2);
}
Also used : IterableProcessEventListener(org.jbpm.test.listener.IterableProcessEventListener) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test)

Example 27 with IterableProcessEventListener

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

the class EndEventTest method testEscalationEndEvent.

@BZ("1015221")
@Test(timeout = 30000)
public void testEscalationEndEvent() {
    KieSession ksession = createKSession(ESCALATION);
    IterableProcessEventListener events = new IterableProcessEventListener();
    TrackingProcessEventListener process = new TrackingProcessEventListener();
    ksession.addEventListener(events);
    ksession.addEventListener(process);
    Command<?> cmd = getCommands().newStartProcess(ESCALATION_ID);
    ksession.execute(cmd);
    Assertions.assertThat(process.wasProcessStarted(ESCALATION_ID)).isTrue();
    Assertions.assertThat(process.wasProcessCompleted(ESCALATION_ID)).isFalse();
    Assertions.assertThat(process.wasProcessAborted(ESCALATION_ID)).isTrue();
    assertProcessStarted(events, ESCALATION_ID);
    assertNextNode(events, "start");
    assertNextNode(events, "script");
    assertTriggered(events, "end");
    assertProcessCompleted(events, ESCALATION_ID);
    assertFalse(events.hasNext());
}
Also used : IterableProcessEventListener(org.jbpm.test.listener.IterableProcessEventListener) TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 28 with IterableProcessEventListener

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

the class EndEventTest method testErrorEndEvent.

@Test(timeout = 30000)
public void testErrorEndEvent() {
    KieSession ksession = createKSession(ERROR);
    IterableProcessEventListener events = new IterableProcessEventListener();
    TrackingProcessEventListener process = new TrackingProcessEventListener();
    ksession.addEventListener(events);
    ksession.addEventListener(process);
    Command<?> cmd = getCommands().newStartProcess(ERROR_ID);
    ksession.execute(cmd);
    Assertions.assertThat(process.wasProcessStarted(ERROR_ID)).isTrue();
    Assertions.assertThat(process.wasProcessCompleted(ERROR_ID)).isFalse();
    Assertions.assertThat(process.wasProcessAborted(ERROR_ID)).isTrue();
    assertProcessStarted(events, ERROR_ID);
    assertNextNode(events, "start");
    assertNextNode(events, "script");
    assertTriggered(events, "end");
    assertProcessCompleted(events, ERROR_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 29 with IterableProcessEventListener

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

the class EndEventTest method testTerminatingEndEvent.

@Test(timeout = 30000)
public void testTerminatingEndEvent() {
    KieSession ksession = createKSession(TERMINATING);
    IterableProcessEventListener events = new IterableProcessEventListener();
    TrackingProcessEventListener process = new TrackingProcessEventListener();
    ksession.addEventListener(events);
    ksession.addEventListener(process);
    Command<?> cmd = getCommands().newStartProcess(TERMINATING_ID);
    ksession.execute(cmd);
    Assertions.assertThat(process.wasProcessStarted(TERMINATING_ID)).isTrue();
    Assertions.assertThat(process.wasProcessCompleted(TERMINATING_ID)).isTrue();
    assertProcessStarted(events, TERMINATING_ID);
    assertNextNode(events, "start");
    assertNextNode(events, "script");
    assertNextNode(events, "end");
    assertProcessCompleted(events, TERMINATING_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 30 with IterableProcessEventListener

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

the class EndEventTest method testMessageEndEvent.

@Test(timeout = 30000)
public void testMessageEndEvent() {
    KieSession ksession = createKSession(MESSAGE);
    IterableProcessEventListener events = new IterableProcessEventListener();
    TrackingProcessEventListener process = new TrackingProcessEventListener();
    ksession.addEventListener(events);
    ksession.addEventListener(process);
    RecordingHandler handler = new RecordingHandler();
    List<Command<?>> cmds = new ArrayList<Command<?>>();
    cmds.add(new RegisterWorkItemHandlerCommand("Send Task", handler));
    cmds.add(getCommands().newStartProcess(MESSAGE_ID));
    ksession.execute(getCommands().newBatchExecution(cmds, null));
    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();
    Assertions.assertThat(handler.item).isNotNull();
}
Also used : Command(org.kie.api.command.Command) RegisterWorkItemHandlerCommand(org.drools.core.command.runtime.process.RegisterWorkItemHandlerCommand) RegisterWorkItemHandlerCommand(org.drools.core.command.runtime.process.RegisterWorkItemHandlerCommand) 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)

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