use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class ActivityTest method testNullVariableInScriptTaskProcess.
@RequirePersistence
@Test(timeout = 10000)
public void testNullVariableInScriptTaskProcess() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer", 1, true);
KieBase kbase = createKnowledgeBase("BPMN2-NullVariableInScriptTaskProcess.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
ProcessInstance processInstance = ksession.startProcess("nullVariableInScriptAfterTimer");
assertProcessInstanceActive(processInstance);
countDownListener.waitTillCompleted();
ProcessInstance pi = ksession.getProcessInstance(processInstance.getId());
assertNotNull(pi);
assertProcessInstanceActive(processInstance);
ksession.abortProcessInstance(processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class ActivityTest method testCallActivityWithTimer.
@Test(timeout = 10000)
@RequirePersistence
public void testCallActivityWithTimer() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer", 1);
KieBase kbase = createKnowledgeBase("BPMN2-ParentProcess.bpmn2", "BPMN2-SubProcessWithTimer.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance processInstance = ksession.startProcess("ParentProcess", params);
ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), null);
Map<String, Object> res = new HashMap<String, Object>();
res.put("sleep", "2s");
ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), res);
long sessionId = ksession.getIdentifier();
Environment env = ksession.getEnvironment();
logger.info("dispose");
ksession.dispose();
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env);
ksession.addEventListener(countDownListener);
countDownListener.waitTillCompleted();
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class StartEventTest method testMultipleEventBasedStartEventsStartOnTimer.
@Test(timeout = 10000)
public void testMultipleEventBasedStartEventsStartOnTimer() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartTimer", 2);
KieBase kbase = createKnowledgeBase("BPMN2-MultipleEventBasedStartEventProcess.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
final List<Long> list = new ArrayList<Long>();
ksession.addEventListener(new DefaultProcessEventListener() {
public void beforeProcessStarted(ProcessStartedEvent event) {
list.add(event.getProcessInstance().getId());
}
});
assertThat(list.size()).isEqualTo(0);
// Timer in the process takes 500ms, so after 1 second, there should be 2 process IDs in the list.
countDownListener.waitTillCompleted();
assertThat(getNumberOfProcessInstances("MultipleStartEvents")).isEqualTo(2);
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class StartEventTest method testMultipleStartEventsStartOnTimer.
@Test(timeout = 10000)
public void testMultipleStartEventsStartOnTimer() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartTimer", 2);
KieBase kbase = createKnowledgeBase("BPMN2-MultipleStartEventProcess.bpmn2");
ksession = createKnowledgeSession(kbase);
try {
ksession.addEventListener(countDownListener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
final List<Long> list = new ArrayList<Long>();
ksession.addEventListener(new DefaultProcessEventListener() {
public void beforeProcessStarted(ProcessStartedEvent event) {
list.add(event.getProcessInstance().getId());
}
});
assertThat(list.size()).isEqualTo(0);
// Timer in the process takes 500ms, so after 1 second, there should be 2 process IDs in the list.
countDownListener.waitTillCompleted();
assertThat(getNumberOfProcessInstances("MultipleStartEvents")).isEqualTo(2);
} finally {
abortProcessInstances(ksession);
}
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class StartEventTest method testTimerStartCycleISO.
@Test(timeout = 10000)
public void testTimerStartCycleISO() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 6);
KieBase kbase = createKnowledgeBase("BPMN2-TimerStartISO.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
final List<Long> list = new ArrayList<Long>();
ksession.addEventListener(new DefaultProcessEventListener() {
public void beforeProcessStarted(ProcessStartedEvent event) {
list.add(event.getProcessInstance().getId());
}
});
assertThat(list.size()).isEqualTo(0);
countDownListener.waitTillCompleted();
assertThat(getNumberOfProcessInstances("Minimal")).isEqualTo(6);
}
Aggregations