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);
}
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());
}
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();
}
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();
}
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();
}
Aggregations