use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class IntermediateEventTest method testEventSubprocessTimerCycle.
@Test(timeout = 10000)
@RequirePersistence
public void testEventSubprocessTimerCycle() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Script Task 1", 4);
KieBase kbase = createKnowledgeBase("BPMN2-EventSubprocessTimerCycle.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", "start-sub", "Script Task 1", "end-sub");
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class IntermediateEventTest method testTimerBoundaryEventCronCycleVariable.
@Test(timeout = 10000)
public void testTimerBoundaryEventCronCycleVariable() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Send Update Timer", 3);
KieBase kbase = createKnowledgeBase("BPMN2-BoundaryTimerCycleCronVariable.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
TestWorkItemHandler handler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("cronStr", "0/1 * * * * ?");
ProcessInstance processInstance = ksession.startProcess("boundaryTimerCycleCron", parameters);
assertProcessInstanceActive(processInstance);
List<WorkItem> workItems = handler.getWorkItems();
assertThat(workItems).isNotNull();
assertThat(workItems.size()).isEqualTo(1);
countDownListener.waitTillCompleted();
assertProcessInstanceActive(processInstance);
workItems = handler.getWorkItems();
assertThat(workItems).isNotNull();
assertThat(workItems.size()).isEqualTo(3);
ksession.abortProcessInstance(processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class IntermediateEventTest method testEventSubprocessMessageWithLocalVars.
@Test(timeout = 10000)
public void testEventSubprocessMessageWithLocalVars() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);
KieBase kbase = createKnowledgeBase("subprocess/BPMN2-EventSubProcessWithLocalVariables.bpmn2");
final Set<String> variablevalues = new HashSet<String>();
ProcessEventListener listener = new DefaultProcessEventListener() {
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
@SuppressWarnings("unchecked") Map<String, String> variable = (Map<String, String>) event.getNodeInstance().getVariable("richiesta");
if (variable != null) {
variablevalues.addAll(variable.keySet());
}
}
};
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(listener);
ksession.addEventListener(countDownListener);
ProcessInstance processInstance = ksession.startProcess("EventSPWithVars");
assertProcessInstanceActive(processInstance);
Map<String, String> data = new HashMap<String, String>();
ksession.signalEvent("Message-MAIL", data, processInstance.getId());
countDownListener.waitTillCompleted();
processInstance = ksession.getProcessInstance(processInstance.getId());
assertThat(processInstance).isNull();
assertThat(variablevalues.size()).isEqualTo(2);
assertThat(variablevalues.contains("SCRIPT1")).isTrue();
assertThat(variablevalues.contains("SCRIPT2")).isTrue();
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class IntermediateEventTest method testMultipleTimerBoundaryEventCronCycleVariable.
@Test(timeout = 10000)
public void testMultipleTimerBoundaryEventCronCycleVariable() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Send Update Timer", 2);
KieBase kbase = createKnowledgeBase("BPMN2-MultipleBoundaryTimerCycleCronVariable.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
TestWorkItemHandler handler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("cronStr", "0/1 * * * * ?");
ProcessInstance processInstance = ksession.startProcess("boundaryTimerCycleCron", parameters);
assertProcessInstanceActive(processInstance);
List<WorkItem> workItems = handler.getWorkItems();
assertThat(workItems).isNotNull();
assertThat(workItems.size()).isEqualTo(1);
countDownListener.waitTillCompleted();
assertProcessInstanceActive(processInstance);
workItems = handler.getWorkItems();
assertThat(workItems).isNotNull();
assertThat(workItems.size()).isEqualTo(2);
ksession.abortProcessInstance(processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.test.listener.NodeLeftCountDownProcessEventListener in project jbpm by kiegroup.
the class IntermediateEventTest method testTimerBoundaryEventCycle1.
@Test(timeout = 10000)
public void testTimerBoundaryEventCycle1() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);
KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventCycle1.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);
}
Aggregations