Search in sources :

Example 1 with SendTaskHandler

use of org.jbpm.bpmn2.handler.SendTaskHandler in project jbpm by kiegroup.

the class IntermediateEventTest method testMessageIntermediateThrowWithTransformation.

@Test
public void testMessageIntermediateThrowWithTransformation() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntermediateThrowEventMessageWithTransformation.bpmn2");
    ksession = createKnowledgeSession(kbase);
    final StringBuffer messageContent = new StringBuffer();
    ksession.getWorkItemManager().registerWorkItemHandler("Send Task", new SendTaskHandler() {

        @Override
        public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
            // collect message content for verification
            messageContent.append(workItem.getParameter("Message"));
            super.executeWorkItem(workItem, manager);
        }
    });
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("x", "MyValue");
    ProcessInstance processInstance = ksession.startProcess("MessageIntermediateEvent", params);
    assertProcessInstanceCompleted(processInstance);
    assertThat(messageContent.toString()).isEqualTo("MYVALUE");
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) WorkItem(org.kie.api.runtime.process.WorkItem) WorkItemManager(org.kie.api.runtime.process.WorkItemManager) SendTaskHandler(org.jbpm.bpmn2.handler.SendTaskHandler) Test(org.junit.Test)

Example 2 with SendTaskHandler

use of org.jbpm.bpmn2.handler.SendTaskHandler in project jbpm by kiegroup.

the class StandaloneBPMNProcessTest method testSendTask.

@Test
public void testSendTask() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-SendTask.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Send Task", new SendTaskHandler());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("s", "john");
    WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess("SendTask", params);
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) SendTaskHandler(org.jbpm.bpmn2.handler.SendTaskHandler) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 3 with SendTaskHandler

use of org.jbpm.bpmn2.handler.SendTaskHandler in project jbpm by kiegroup.

the class ActivityTest method testSendTask.

@Test
public void testSendTask() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-SendTask.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Send Task", new SendTaskHandler());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("s", "john");
    WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess("SendTask", params);
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) SendTaskHandler(org.jbpm.bpmn2.handler.SendTaskHandler) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 4 with SendTaskHandler

use of org.jbpm.bpmn2.handler.SendTaskHandler in project jbpm by kiegroup.

the class StandaloneBPMNProcessTest method testMessageIntermediateThrow.

@Test
public void testMessageIntermediateThrow() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateThrowEventMessage.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Send Task", new SendTaskHandler());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("x", "MyValue");
    ProcessInstance processInstance = ksession.startProcess("MessageIntermediateEvent", params);
    assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) SendTaskHandler(org.jbpm.bpmn2.handler.SendTaskHandler) Test(org.junit.Test)

Example 5 with SendTaskHandler

use of org.jbpm.bpmn2.handler.SendTaskHandler in project jbpm by kiegroup.

the class IntermediateEventTest method testMessageIntermediateThrow.

@Test
public void testMessageIntermediateThrow() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateThrowEventMessage.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Send Task", new SendTaskHandler());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("x", "MyValue");
    ProcessInstance processInstance = ksession.startProcess("MessageIntermediateEvent", params);
    assertProcessInstanceCompleted(processInstance);
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) SendTaskHandler(org.jbpm.bpmn2.handler.SendTaskHandler) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)8 SendTaskHandler (org.jbpm.bpmn2.handler.SendTaskHandler)8 Test (org.junit.Test)8 KieBase (org.kie.api.KieBase)7 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)6 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)6 KieSession (org.kie.api.runtime.KieSession)4 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)1 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)1 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)1 WorkItem (org.kie.api.runtime.process.WorkItem)1 WorkItemHandler (org.kie.api.runtime.process.WorkItemHandler)1 WorkItemManager (org.kie.api.runtime.process.WorkItemManager)1 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)1