use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class StructureRefTest method testNotExistingVarBooleanStructureRefOnStart.
@Test(expected = IllegalArgumentException.class)
public void testNotExistingVarBooleanStructureRefOnStart() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-BooleanStructureRef.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
Map<String, Object> params = new HashMap<String, Object>();
params.put("not existing", "invalid boolean");
ksession.startProcess("StructureRef", params);
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testEventSubprocessSignalWithStateNode.
@Test
public void testEventSubprocessSignalWithStateNode() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-EventSubprocessSignalWithStateNode.bpmn2");
final List<Long> executednodes = new ArrayList<Long>();
ProcessEventListener listener = new DefaultProcessEventListener() {
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
if (event.getNodeInstance().getNodeName().equals("User Task 2")) {
executednodes.add(event.getNodeInstance().getId());
}
}
};
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(listener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ProcessInstance processInstance = ksession.startProcess("BPMN2-EventSubprocessSignal");
assertProcessInstanceActive(processInstance);
ksession = restoreSession(ksession, true);
ksession.addEventListener(listener);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
WorkItem workItemTopProcess = workItemHandler.getWorkItem();
ksession.signalEvent("MySignal", null, processInstance.getId());
assertProcessInstanceActive(processInstance);
WorkItem workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
ksession.signalEvent("MySignal", null);
assertProcessInstanceActive(processInstance);
workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
ksession.signalEvent("MySignal", null);
assertProcessInstanceActive(processInstance);
workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
ksession.signalEvent("MySignal", null);
assertProcessInstanceActive(processInstance);
workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertThat(workItemTopProcess).isNotNull();
ksession.getWorkItemManager().completeWorkItem(workItemTopProcess.getId(), null);
assertProcessInstanceFinished(processInstance, ksession);
assertNodeTriggered(processInstance.getId(), "start", "User Task 1", "end", "Sub Process 1", "start-sub", "User Task 2", "end-sub");
assertThat(executednodes.size()).isEqualTo(4);
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testConditionalBoundaryEventOnTaskActiveOnStartup.
@Test
public void testConditionalBoundaryEventOnTaskActiveOnStartup() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-BoundaryConditionalEventOnTask.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new TestWorkItemHandler());
ProcessInstance processInstance = ksession.startProcess("BoundarySignalOnTask");
Person person = new Person();
person.setName("john");
ksession.insert(person);
assertProcessInstanceCompleted(processInstance);
assertNodeTriggered(processInstance.getId(), "StartProcess", "User Task", "Boundary event", "Condition met", "End2");
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testIntermediateTimerParallelGateway.
@Test(timeout = 10000)
public void testIntermediateTimerParallelGateway() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer1", 1);
NodeLeftCountDownProcessEventListener countDownListener2 = new NodeLeftCountDownProcessEventListener("Timer2", 1);
NodeLeftCountDownProcessEventListener countDownListener3 = new NodeLeftCountDownProcessEventListener("Timer3", 1);
KieBase kbase = createKnowledgeBase("timer/BPMN2-IntermediateTimerParallelGateway.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
ksession.addEventListener(countDownListener2);
ksession.addEventListener(countDownListener3);
TestWorkItemHandler handler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
ProcessInstance processInstance = ksession.startProcess("Evaluation.timer-parallel");
assertProcessInstanceActive(processInstance);
countDownListener.waitTillCompleted();
countDownListener2.waitTillCompleted();
countDownListener3.waitTillCompleted();
assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testErrorBoundaryEventOnMultiInstanceSubprocess.
@Test
public void testErrorBoundaryEventOnMultiInstanceSubprocess() throws Exception {
KieBase kbase = createKnowledgeBase("subprocess/BPMN2-MultiInstanceSubprocessWithBoundaryError.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
TestWorkItemHandler handler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
Map<String, Object> params = new HashMap<String, Object>();
List<String> approvers = new ArrayList<String>();
approvers.add("john");
approvers.add("john");
params.put("approvers", approvers);
ProcessInstance processInstance = ksession.startProcess("boundary-catch-error-event", params);
assertProcessInstanceActive(processInstance);
List<WorkItem> workItems = handler.getWorkItems();
assertThat(workItems).isNotNull();
assertThat(workItems.size()).isEqualTo(2);
ksession.signalEvent("Inside", null, processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
ksession.dispose();
}
Aggregations