use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testSignalBoundaryEventOnTaskWithSignalName.
@Test
public void testSignalBoundaryEventOnTaskWithSignalName() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-BoundarySignalWithNameEventOnTaskbpmn2.bpmn");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new TestWorkItemHandler());
ksession.addEventListener(LOGGING_EVENT_LISTENER);
ProcessInstance processInstance = ksession.startProcess("BoundarySignalOnTask");
ksession.signalEvent("MySignal", "value");
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testMessageIntermediateThrowVerifyWorkItemData.
@Test
public void testMessageIntermediateThrowVerifyWorkItemData() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-IntermediateThrowEventMessage.bpmn2");
ksession = createKnowledgeSession(kbase);
TestWorkItemHandler handler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Send Task", handler);
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "MyValue");
ProcessInstance processInstance = ksession.startProcess("MessageIntermediateEvent", params);
assertProcessInstanceCompleted(processInstance);
WorkItem workItem = handler.getWorkItem();
assertThat(workItem).isNotNull();
assertThat(workItem instanceof org.drools.core.process.instance.WorkItem).isTrue();
long nodeInstanceId = ((org.drools.core.process.instance.WorkItem) workItem).getNodeInstanceId();
long nodeId = ((org.drools.core.process.instance.WorkItem) workItem).getNodeId();
assertThat(nodeId).isNotNull();
assertThat(nodeId > 0).isTrue();
assertThat(nodeInstanceId).isNotNull();
assertThat(nodeInstanceId > 0).isTrue();
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testSignalBoundaryEventOnMultiInstanceSubprocess.
@Test
public void testSignalBoundaryEventOnMultiInstanceSubprocess() throws Exception {
KieBase kbase = createKnowledgeBase("subprocess/BPMN2-MultiInstanceSubprocessWithBoundarySignal.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("Outside", null, processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
ksession.dispose();
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testConditionalBoundaryEventOnTask.
@Test
public void testConditionalBoundaryEventOnTask() 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);
assertProcessInstanceFinished(processInstance, ksession);
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 testSignalIntermediateThrowEventWithTransformation.
@Test
public void testSignalIntermediateThrowEventWithTransformation() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-BoundarySignalEventOnTaskbpmn2.bpmn", "BPMN2-IntermediateThrowEventSignalWithTransformation.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
TestWorkItemHandler handler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "john");
ProcessInstance processInstance = ksession.startProcess("BoundarySignalOnTask");
ProcessInstance processInstance2 = ksession.startProcess("SignalIntermediateEvent", params);
assertProcessInstanceFinished(processInstance2, ksession);
assertProcessInstanceFinished(processInstance, ksession);
String var = getProcessVarValue(processInstance, "x");
assertThat(var).isEqualTo("JOHN");
}
Aggregations