use of org.drools.core.process.instance.WorkItemHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testThrowIntermediateSignalWithExternalScope.
@Test
public void testThrowIntermediateSignalWithExternalScope() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-IntermediateThrowEventExternalScope.bpmn2");
ksession = createKnowledgeSession(kbase);
TestWorkItemHandler handler = new TestWorkItemHandler();
WorkItemHandler externalHandler = new WorkItemHandler() {
@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
String signal = (String) workItem.getParameter("Signal");
ksession.signalEvent(signal, null);
manager.completeWorkItem(workItem.getId(), null);
}
@Override
public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
}
};
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
ksession.getWorkItemManager().registerWorkItemHandler("External Send Task", externalHandler);
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance processInstance = ksession.startProcess("intermediate-event-scope", params);
assertProcessInstanceActive(processInstance);
assertNodeActive(processInstance.getId(), ksession, "Complete work", "Wait");
List<WorkItem> items = handler.getWorkItems();
assertThat(items.size()).isEqualTo(1);
WorkItem wi = items.get(0);
Map<String, Object> result = new HashMap<String, Object>();
result.put("_output", "sending event");
ksession.getWorkItemManager().completeWorkItem(wi.getId(), result);
assertProcessInstanceCompleted(processInstance);
}
Aggregations