Search in sources :

Example 21 with IterableProcessEventListener

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

the class SubprocessesTest method testParameterMapping.

@Test(timeout = 30000)
public void testParameterMapping() {
    IterableProcessEventListener process = new IterableProcessEventListener();
    ksession.addEventListener(process);
    // start the process and track the progress
    ProcessInstance pi = ksession.startProcess(PROCESS_ID_2, createBranchDefiningMap("parameters"));
    assertChangedVariable(process, "node", null, "parameters");
    assertProcessStarted(process, PROCESS_ID_2);
    assertNextNode(process, P2_START);
    assertNextNode(process, P2_GATEWAY_START);
    assertTriggered(process, "parameter mapping");
    // subprocess is started
    if (JAVA8_9) {
        assertChangedVariable(process, "variable", null, "parameters");
        assertChangedVariable(process, "undefined", null, "parameters");
    } else {
        assertChangedVariable(process, "undefined", null, "parameters");
        assertChangedVariable(process, "variable", null, "parameters");
    }
    assertProcessStarted(process, PROCESS_ID_3);
    assertNextNode(process, P3_START);
    assertTriggered(process, P3_SIGNAL);
    // signal the subprocess to continue
    ksession.signalEvent("continue", null);
    assertLeft(process, P3_SIGNAL);
    assertTriggered(process, P3_SCRIPT);
    assertChangedVariable(process, "variable", "parameters", "new value");
    assertLeft(process, P3_SCRIPT);
    assertNextNode(process, P3_END);
    assertProcessCompleted(process, PROCESS_ID_3);
    // track the progress after subprocess completion
    assertChangedVariable(process, "node", "parameters", "new value");
    assertLeft(process, "parameter mapping");
    assertNextNode(process, "Gateway");
    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 22 with IterableProcessEventListener

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

the class SubprocessesTest method testVariableScope.

@Test(timeout = 30000)
public void testVariableScope() {
    IterableProcessEventListener process = new IterableProcessEventListener();
    ksession.addEventListener(process);
    ProcessInstance pi = ksession.startProcess(PROCESS_ID_2, createBranchDefiningMap("variables"));
    assertChangedVariable(process, "node", null, "variables");
    assertProcessStarted(process, PROCESS_ID_2);
    assertNextNode(process, P2_START);
    assertNextNode(process, P2_GATEWAY_START);
    assertTriggered(process, "variables scope");
    // subprocess
    assertNextNode(process, "Start");
    assertNextNode(process, "Script");
    assertTriggered(process, "Script");
    assertChangedVariable(process, "9:variable", null, "variables");
    assertChangedVariable(process, "node", "variables", "new value");
    assertLeft(process, "Script");
    assertNextNode(process, "Script");
    assertNextNode(process, "End");
    assertLeft(process, "variables scope");
    assertNextNode(process, "Gateway");
    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 23 with IterableProcessEventListener

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

the class SubprocessesTest method testIndependentNoWaitForCompletionSubprocessFirst.

@Test(timeout = 30000)
public void testIndependentNoWaitForCompletionSubprocessFirst() {
    IterableProcessEventListener process = new IterableProcessEventListener();
    ksession.addEventListener(process);
    ProcessInstance pi = ksession.startProcess(PROCESS_ID_2, createBranchDefiningMap("nowait"));
    assertChangedVariable(process, "node", null, "nowait");
    assertProcessStarted(process, PROCESS_ID_2);
    assertNextNode(process, P2_START);
    assertNextNode(process, P2_GATEWAY_START);
    assertTriggered(process, "don't wait for completion");
    // subprocess
    assertProcessStarted(process, PROCESS_ID_3);
    long id = process.current().<CachedProcessStartedEvent>getEvent().getProcessInstanceId();
    assertNextNode(process, P3_START);
    assertTriggered(process, P3_SIGNAL);
    assertLeft(process, "don't wait for completion");
    assertNextNode(process, P2_GATEWAY_END);
    assertTriggered(process, P2_SIGNAL_END);
    // 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);
    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 24 with IterableProcessEventListener

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

the class SubprocessesTest method testDependentNoWaitForCompletion.

@Test(timeout = 30000)
public void testDependentNoWaitForCompletion() {
    TrackingProcessEventListener listener = new TrackingProcessEventListener();
    ksession.addEventListener(listener);
    IterableProcessEventListener process = new IterableProcessEventListener();
    ksession.addEventListener(process);
    ProcessInstance pi = ksession.startProcess(PROCESS_ID_2, createBranchDefiningMap("dependent-nowait"));
    assertChangedVariable(process, "node", null, "dependent-nowait");
    assertProcessStarted(process, PROCESS_ID_2);
    assertNextNode(process, P2_START);
    assertNextNode(process, P2_GATEWAY_START);
    assertTriggered(process, "dependent process that doesn't have to be completed");
    // subprocess
    assertProcessStarted(process, PROCESS_ID_3);
    long id = process.current().<CachedProcessStartedEvent>getEvent().getProcessInstanceId();
    assertNextNode(process, P3_START);
    assertTriggered(process, P3_SIGNAL);
    assertLeft(process, "dependent process that doesn't have to be completed");
    assertNextNode(process, P2_GATEWAY_END);
    assertTriggered(process, P2_SIGNAL_END);
    Assertions.assertThat(listener.wasProcessStarted(PROCESS_ID_2)).isTrue();
    Assertions.assertThat(listener.wasProcessStarted(PROCESS_ID_3)).isTrue();
    // 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);
    Assertions.assertThat(listener.wasProcessCompleted(PROCESS_ID_2)).isTrue();
    Assertions.assertThat(listener.wasProcessCompleted(PROCESS_ID_3)).isFalse();
    // 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);
    Assertions.assertThat(listener.wasProcessCompleted(PROCESS_ID_2)).isTrue();
    Assertions.assertThat(listener.wasProcessCompleted(PROCESS_ID_3)).isTrue();
}
Also used : IterableProcessEventListener(org.jbpm.test.listener.IterableProcessEventListener) TrackingProcessEventListener(org.jbpm.test.listener.TrackingProcessEventListener) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test)

Example 25 with IterableProcessEventListener

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

the class SubprocessesTest method testIndependentNoWaitForCompletionParentFirst.

@Test(timeout = 30000)
public void testIndependentNoWaitForCompletionParentFirst() {
    IterableProcessEventListener process = new IterableProcessEventListener();
    ksession.addEventListener(process);
    ProcessInstance pi = ksession.startProcess(PROCESS_ID_2, createBranchDefiningMap("nowait"));
    assertChangedVariable(process, "node", null, "nowait");
    assertProcessStarted(process, PROCESS_ID_2);
    assertNextNode(process, P2_START);
    assertNextNode(process, P2_GATEWAY_START);
    assertTriggered(process, "don't wait for completion");
    // subprocess
    assertProcessStarted(process, PROCESS_ID_3);
    long id = process.current().<CachedProcessStartedEvent>getEvent().getProcessInstanceId();
    assertNextNode(process, P3_START);
    assertTriggered(process, P3_SIGNAL);
    assertLeft(process, "don't wait for completion");
    assertNextNode(process, P2_GATEWAY_END);
    assertTriggered(process, P2_SIGNAL_END);
    ksession.signalEvent("finish", null, pi.getId());
    assertLeft(process, P2_SIGNAL_END);
    assertNextNode(process, P2_END);
    assertProcessCompleted(process, PROCESS_ID_2);
    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);
}
Also used : IterableProcessEventListener(org.jbpm.test.listener.IterableProcessEventListener) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) 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