use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class SubprocessesTest method testIndependent.
@Test(timeout = 30000)
public void testIndependent() {
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);
long id = process.current().<IterableProcessEventListener.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", "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);
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class SubprocessesTest method testDependentAbort.
@Test(timeout = 30000)
public void testDependentAbort() {
TrackingProcessEventListener listener = new TrackingProcessEventListener();
IterableProcessEventListener process = new IterableProcessEventListener();
ksession.addEventListener(process);
ksession.addEventListener(listener);
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);
assertNextNode(process, P3_START);
assertTriggered(process, P3_SIGNAL);
ksession.abortProcessInstance(pi.getId());
assertProcessCompleted(process, PROCESS_ID_2);
assertProcessCompleted(process, PROCESS_ID_3);
Assertions.assertThat(listener.wasProcessCompleted(PROCESS_ID_2)).isFalse();
Assertions.assertThat(listener.wasProcessCompleted(PROCESS_ID_3)).isFalse();
Assertions.assertThat(listener.wasProcessAborted(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 testIndependentAbort.
@Ignore
@Test(timeout = 30000)
public void testIndependentAbort() {
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);
long id = process.current().<CachedProcessStartedEvent>getEvent().getProcessInstanceId();
assertNextNode(process, P3_START);
assertTriggered(process, P3_SIGNAL);
ksession.abortProcessInstance(id);
assertProcessCompleted(process, PROCESS_ID_3);
process.printRemainingEvents();
// track the progress after subprocess completion
assertLeft(process, "parameter mapping");
assertNextNode(process, "Gateway");
// variable value was not changed -> error
assertTriggered(process, "Error");
assertProcessCompleted(process, PROCESS_ID_2);
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class SubprocessesTest method testDependentNoWaitForCompletionAbortSubprocess.
@Test(timeout = 30000)
public void testDependentNoWaitForCompletionAbortSubprocess() {
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(id);
assertProcessCompleted(process, PROCESS_ID_3);
Assertions.assertThat(listener.wasProcessCompleted(PROCESS_ID_2)).isFalse();
Assertions.assertThat(listener.wasProcessAborted(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.wasProcessAborted(PROCESS_ID_3)).isTrue();
}
use of org.jbpm.test.listener.IterableProcessEventListener in project jbpm by kiegroup.
the class SubprocessesTest method testDependentAbort2.
@Test(timeout = 30000)
public void testDependentAbort2() {
TrackingProcessEventListener listener = new TrackingProcessEventListener();
IterableProcessEventListener process = new IterableProcessEventListener();
ksession.addEventListener(process);
ksession.addEventListener(listener);
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");
// subprocess started
assertProcessStarted(process, PROCESS_ID_3);
assertNextNode(process, P3_START);
assertTriggered(process, P3_SIGNAL);
long subprocessId = process.current().getProcessInstanceId();
Assertions.assertThat(pi.getId()).isNotEqualTo(subprocessId);
// abort subprocess
ksession.abortProcessInstance(subprocessId);
// carry on with execution of superprocess
assertProcessCompleted(process, PROCESS_ID_3);
assertProcessCompleted(process, PROCESS_ID_2);
Assertions.assertThat(listener.wasProcessAborted(PROCESS_ID_2)).isTrue();
Assertions.assertThat(listener.wasProcessAborted(PROCESS_ID_3)).isTrue();
}
Aggregations