use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class SubprocessesTest method testReusable.
@Test(timeout = 30000)
public void testReusable() {
TrackingProcessEventListener process = runProcess(ksession, "external");
Assertions.assertThat(process.wasProcessCompleted(PROCESS_ID_1)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(HELLO_WORLD_PROCESS_ID)).isTrue();
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EventListenersTest method testBadSignal.
@Test(timeout = 60000L)
public void testBadSignal() {
TrackingProcessEventListener listener = new TrackingProcessEventListener();
ksession.addEventListener(listener);
List<Command<?>> commands = new ArrayList<Command<?>>();
commands.add(getCommands().newStartProcess(PROCESS_ID));
commands.add(getCommands().newSignalEvent("bad-signal", "bad signal!"));
ksession.execute(getCommands().newBatchExecution(commands, null));
assertTrue(listener.wasNodeTriggered("introduction"));
assertFalse(listener.wasNodeTriggered("info"));
assertTrue(listener.wasNodeLeft("introduction"));
assertFalse(listener.wasNodeLeft("info"));
assertFalse(listener.wasVariableChanged("signalData"));
assertFalse(listener.wasVariableChanged("stringVariable"));
assertTrue(listener.wasNodeLeft("script-warning"));
assertTrue(listener.wasProcessStarted(PROCESS_ID));
assertTrue(listener.wasProcessCompleted(PROCESS_ID));
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class EventListenersTest method testUnfinishedProcess.
@Test(timeout = 60000L)
public void testUnfinishedProcess() {
TrackingProcessEventListener listener = new TrackingProcessEventListener();
ksession.addEventListener(listener);
List<Command<?>> commands = new ArrayList<Command<?>>();
commands.add(getCommands().newStartProcess(PROCESS_ID));
ksession.execute(getCommands().newBatchExecution(commands, null));
assertTrue(listener.wasNodeTriggered("introduction"));
assertTrue(listener.wasNodeTriggered("split"));
assertTrue(listener.wasNodeLeft("introduction"));
assertFalse(listener.wasNodeLeft("xor-gateway"));
assertTrue(listener.wasProcessStarted(PROCESS_ID));
assertFalse(listener.wasProcessCompleted(PROCESS_ID));
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class FlexibleProcessTest method testFlexibleProcess.
/**
* Flexible process with four fragments. -default - with start node, without
* end event -two fragments which will be signaled -one fragment which won't
* be signaled - it should not be executed
*/
@Ignore
@Test(timeout = 30000)
public void testFlexibleProcess() throws Exception {
KieSession ksession = createKSession(PROCESS);
TrackingProcessEventListener tpel = new TrackingProcessEventListener();
ksession.addEventListener(tpel);
TestWorkItemHandler handler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
ProcessInstance pi = ksession.startProcess(PROCESS_ID);
assertProcessStarted(tpel, PROCESS_ID);
assertTriggeredAndLeft(tpel, "start");
assertTriggered(tpel, "task1");
ksession.signalEvent("userTask", null, pi.getId());
assertTriggered(tpel, "userTask");
ksession = restoreKSession(PROCESS);
Assertions.assertThat(ksession.getProcessEventListeners()).isNotEmpty();
WorkItem item = handler.getWorkItem();
ksession.getWorkItemManager().completeWorkItem(item.getId(), null);
assertTriggered(tpel, "userTask2");
ksession.signalEvent("task21", null, pi.getId());
assertTriggeredAndLeft(tpel, "task21");
assertTriggeredAndLeft(tpel, "task22");
assertTriggeredAndLeft(tpel, "end1");
assertProcessCompleted(tpel, PROCESS_ID);
assertFalse(tpel.wasNodeTriggered("task3"));
assertFalse(tpel.wasNodeTriggered("end2"));
}
use of org.jbpm.test.listener.TrackingProcessEventListener in project jbpm by kiegroup.
the class FlexibleProcessTest method testFlexibleProcessAddWorkItem.
/**
* Tests dynamic insertion of work item node into adhoc top-level process.
* DynamicUtils does not support adhoc processes yet, but there is improved
* version on jbpm master branch.
*/
@Test(timeout = 30000)
public void testFlexibleProcessAddWorkItem() {
KieSession ksession = createKSession(PROCESS);
TrackingProcessEventListener tpel = new TrackingProcessEventListener();
ksession.addEventListener(tpel);
TestWorkItemHandler handler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("addedWorkItem", handler);
ProcessInstance pi = ksession.startProcess(PROCESS_ID);
assertProcessStarted(tpel, PROCESS_ID);
DynamicUtils.addDynamicWorkItem(pi, ksession, "addedWorkItem", Collections.<String, Object>emptyMap());
WorkItem wi = handler.getWorkItem();
ksession.getWorkItemManager().completeWorkItem(wi.getId(), new java.util.HashMap<String, Object>());
assertEquals(wi.getName(), "addedWorkItem");
}
Aggregations