use of org.jbpm.bpmn2.handler.ReceiveTaskHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testEventBasedSplit5.
@Test
public void testEventBasedSplit5() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-EventBasedSplit5.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
ReceiveTaskHandler receiveTaskHandler = new ReceiveTaskHandler(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
// Yes
ProcessInstance processInstance = ksession.startProcess("com.sample.test");
assertProcessInstanceActive(processInstance);
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
receiveTaskHandler.setKnowledgeRuntime(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
receiveTaskHandler.messageReceived("YesMessage", "YesValue");
assertProcessInstanceFinished(processInstance, ksession);
receiveTaskHandler.messageReceived("NoMessage", "NoValue");
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
receiveTaskHandler.setKnowledgeRuntime(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
// No
processInstance = ksession.startProcess("com.sample.test");
receiveTaskHandler.messageReceived("NoMessage", "NoValue");
assertProcessInstanceFinished(processInstance, ksession);
receiveTaskHandler.messageReceived("YesMessage", "YesValue");
}
use of org.jbpm.bpmn2.handler.ReceiveTaskHandler in project jbpm by kiegroup.
the class ActivityTest method testReceiveTask.
@Test
public void testReceiveTask() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-ReceiveTask.bpmn2");
ksession = createKnowledgeSession(kbase);
ReceiveTaskHandler receiveTaskHandler = new ReceiveTaskHandler(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess("ReceiveTask");
assertProcessInstanceActive(processInstance);
ksession = restoreSession(ksession, true);
receiveTaskHandler.setKnowledgeRuntime(ksession);
receiveTaskHandler.messageReceived("HelloMessage", "Hello john!");
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.bpmn2.handler.ReceiveTaskHandler in project jbpm by kiegroup.
the class StandaloneBPMNProcessTest method testReceiveTask.
@Test
public void testReceiveTask() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-ReceiveTask.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
ReceiveTaskHandler receiveTaskHandler = new ReceiveTaskHandler(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess("ReceiveTask");
assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
ksession = restoreSession(ksession);
receiveTaskHandler.messageReceived("HelloMessage", "Hello john!");
assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
use of org.jbpm.bpmn2.handler.ReceiveTaskHandler in project jbpm by kiegroup.
the class StandaloneBPMNProcessTest method testEventBasedSplit5.
@Test
public void testEventBasedSplit5() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-EventBasedSplit5.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
ReceiveTaskHandler receiveTaskHandler = new ReceiveTaskHandler(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
// Yes
ProcessInstance processInstance = ksession.startProcess("com.sample.test");
assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
receiveTaskHandler.setKnowledgeRuntime(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
receiveTaskHandler.messageReceived("YesMessage", "YesValue");
assertProcessInstanceCompleted(processInstance.getId(), ksession);
receiveTaskHandler.messageReceived("NoMessage", "NoValue");
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
receiveTaskHandler.setKnowledgeRuntime(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
// No
processInstance = ksession.startProcess("com.sample.test");
receiveTaskHandler.messageReceived("NoMessage", "NoValue");
assertProcessInstanceCompleted(processInstance.getId(), ksession);
receiveTaskHandler.messageReceived("YesMessage", "YesValue");
}
Aggregations