use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class MultipleInstancesSubProcessTest method testMultipleInstances.
@BZ("802721")
@Test(timeout = 30000)
public void testMultipleInstances() {
KieSession kieSession = createKSession(MULTIPLE_INSTANCES);
IterableProcessEventListener eventListener = new IterableProcessEventListener();
kieSession.addEventListener(eventListener);
kieSession.addEventListener(new DebugProcessEventListener());
List<String> items = new ArrayList<String>();
items.add("breakfast");
items.add("lunch");
items.add("dinner");
Map<String, Object> params = new HashMap<String, Object>();
params.put("list", items);
kieSession.execute((Command<?>) getCommands().newStartProcess(MULTIPLE_INSTANCES_ID, params));
assertChangedVariable(eventListener, "list", null, items);
assertProcessStarted(eventListener, MULTIPLE_INSTANCES_ID);
assertNextNode(eventListener, "start");
assertNextNode(eventListener, "script");
assertTriggered(eventListener, "multipleInstances");
// collection is passed to multiple-instances node
for (String str : items) {
assertChangedMultipleInstancesVariable(eventListener, "listItem", null, str);
}
// multiple-instances node is processed for every collection item
for (String str : items) {
assertNextNode(eventListener, "innerStart");
assertTriggered(eventListener, "innerScript");
assertChangedMultipleInstancesVariable(eventListener, "listItem", str, str + "-eaten");
assertLeft(eventListener, "innerScript");
assertNextNode(eventListener, "innerEnd");
}
assertLeft(eventListener, "multipleInstances");
assertNextNode(eventListener, "end");
assertProcessCompleted(eventListener, MULTIPLE_INSTANCES_ID);
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class ReusableSubProcessTest method testCallActivity.
@Test(timeout = 30000)
public void testCallActivity() {
KieSession ksession = createKSession(CALL_ACTIVITY_CHILD, CALL_ACTIVITY_PARENT);
IterableProcessEventListener eventListener = new IterableProcessEventListener();
ksession.addEventListener(eventListener);
ksession.execute((Command<?>) getCommands().newStartProcess(CALL_ACTIVITY_PARENT_ID));
assertProcessStarted(eventListener, CALL_ACTIVITY_PARENT_ID);
assertNextNode(eventListener, "start");
assertTriggered(eventListener, "script");
assertChangedVariable(eventListener, "var", null, 1);
assertLeft(eventListener, "script");
assertTriggered(eventListener, "reusable");
assertChangedVariable(eventListener, "inSubVar", null, 1);
assertProcessStarted(eventListener, CALL_ACTIVITY_CHILD_ID);
assertNextNode(eventListener, "rs-start");
assertTriggered(eventListener, "rs-script");
assertChangedVariable(eventListener, "outSubVar", null, "one");
assertLeft(eventListener, "rs-script");
assertNextNode(eventListener, "rs-end");
assertProcessCompleted(eventListener, CALL_ACTIVITY_CHILD_ID);
assertChangedVariable(eventListener, "var", 1, "one");
assertLeft(eventListener, "reusable");
assertNextNode(eventListener, "end");
assertProcessCompleted(eventListener, CALL_ACTIVITY_PARENT_ID);
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class SubprocessesTest method testDependentNoWaitForCompletionAbortParent.
@Test(timeout = 30000)
public void testDependentNoWaitForCompletionAbortParent() {
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);
ksession.abortProcessInstance(pi.getId());
assertProcessCompleted(process, PROCESS_ID_2);
Assertions.assertThat(listener.wasProcessAborted(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.wasProcessAborted(PROCESS_ID_2)).isTrue();
Assertions.assertThat(listener.wasProcessCompleted(PROCESS_ID_3)).isTrue();
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class SubprocessesTest method testIndependentNoWaitForCompletionAbortSubprocess.
@Test(timeout = 30000)
public void testIndependentNoWaitForCompletionAbortSubprocess() {
TrackingProcessEventListener listener = new TrackingProcessEventListener();
ksession.addEventListener(listener);
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);
Assertions.assertThat(listener.wasProcessStarted(PROCESS_ID_2)).isTrue();
Assertions.assertThat(listener.wasProcessStarted(PROCESS_ID_3)).isTrue();
ksession.abortProcessInstance(id);
assertProcessCompleted(process, PROCESS_ID_3);
Assertions.assertThat(listener.wasProcessCompleted(PROCESS_ID_2)).isFalse();
Assertions.assertThat(listener.wasProcessAborted(PROCESS_ID_3)).isTrue();
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.wasProcessAborted(PROCESS_ID_3)).isTrue();
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class SubprocessesTest method testIndependentNoWaitForCompletionAbortParent.
@Test(timeout = 30000)
public void testIndependentNoWaitForCompletionAbortParent() {
TrackingProcessEventListener listener = new TrackingProcessEventListener();
ksession.addEventListener(listener);
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);
Assertions.assertThat(listener.wasProcessStarted(PROCESS_ID_2)).isTrue();
Assertions.assertThat(listener.wasProcessStarted(PROCESS_ID_3)).isTrue();
ksession.abortProcessInstance(pi.getId());
assertProcessCompleted(process, PROCESS_ID_2);
Assertions.assertThat(listener.wasProcessAborted(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.wasProcessAborted(PROCESS_ID_2)).isTrue();
Assertions.assertThat(listener.wasProcessCompleted(PROCESS_ID_3)).isTrue();
}
Aggregations