use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class IntermediateEventTest method testTimerBoundaryEventDateISO.
@Test(timeout = 10000)
public void testTimerBoundaryEventDateISO() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-TimerBoundaryEventDateISO.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
HashMap<String, Object> params = new HashMap<String, Object>();
OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2);
params.put("date", plusTwoSeconds.toString());
ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent", params);
assertProcessInstanceActive(processInstance);
countDownListener.waitTillCompleted();
ksession = restoreSession(ksession, true);
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class IntermediateEventTest method testIntermediateCatchEventTimerDurationISO.
@Test(timeout = 10000)
public void testIntermediateCatchEventTimerDurationISO() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);
KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDurationISO.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
ksession.addEventListener(countDownListener);
ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
assertProcessInstanceActive(processInstance);
// now wait for 1.5 second for timer to trigger
countDownListener.waitTillCompleted();
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class IntermediateEventTest method testTimerBoundaryEventDuration.
@Test(timeout = 10000)
public void testTimerBoundaryEventDuration() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);
KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventDuration.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
ksession.addEventListener(countDownListener);
ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent");
assertProcessInstanceActive(processInstance);
countDownListener.waitTillCompleted();
ksession = restoreSession(ksession, true);
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class IntermediateEventTest method testIntermediateCatchEventTimerDurationWithError.
@Test(timeout = 10000)
@RequirePersistence
public void testIntermediateCatchEventTimerDurationWithError() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);
KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDurationWithError.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
ksession.addEventListener(countDownListener);
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", 0);
ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent", params);
long waitTime = 2;
assertProcessInstanceActive(processInstance);
// now wait for 1 second for timer to trigger
countDownListener.waitTillCompleted(waitTime * 1000);
assertProcessInstanceActive(processInstance);
processInstance = ksession.getProcessInstance(processInstance.getId());
// reschedule it to allow to move on
ksession.setGlobal("TestOK", Boolean.TRUE);
ksession.execute(new UpdateTimerCommand(processInstance.getId(), "timer", waitTime + 1));
countDownListener.reset(1);
countDownListener.waitTillCompleted();
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class IntermediateEventTest method testEventSubprocessTimer.
@Test(timeout = 10000)
public void testEventSubprocessTimer() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Script Task 1", 1);
KieBase kbase = createKnowledgeBase("BPMN2-EventSubprocessTimer.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ProcessInstance processInstance = ksession.startProcess("BPMN2-EventSubprocessTimer");
assertProcessInstanceActive(processInstance);
countDownListener.waitTillCompleted();
WorkItem workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceFinished(processInstance, ksession);
assertNodeTriggered(processInstance.getId(), "start", "User Task 1", "end", "Sub Process 1", "start-sub", "Script Task 1", "end-sub");
}
Aggregations