Search in sources :

Example 6 with SendTaskHandler

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

the class StandaloneBPMNProcessTest method testMessageEnd.

@Test
public void testMessageEnd() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-MessageEndEvent.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("MessageEndEvent", 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 7 with SendTaskHandler

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

the class EndEventTest method testMessageEnd.

@Test
public void testMessageEnd() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-MessageEndEvent.bpmn2");
    StatefulKnowledgeSession 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("MessageEndEvent", params);
    assertProcessInstanceCompleted(processInstance);
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) SendTaskHandler(org.jbpm.bpmn2.handler.SendTaskHandler) Test(org.junit.Test)

Example 8 with SendTaskHandler

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

the class PerProcessInstanceRuntimeManagerTest method testEndMessageEventProcess.

@Test
public void testEndMessageEventProcess() {
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("events/EndMessageEvent.bpmn2"), ResourceType.BPMN2).registerableItemsFactory(new DefaultRegisterableItemsFactory() {

        @Override
        public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) {
            Map<String, WorkItemHandler> handlers = new HashMap<String, WorkItemHandler>();
            handlers.putAll(super.getWorkItemHandlers(runtime));
            handlers.put("Send Task", new SendTaskHandler());
            return handlers;
        }
    }).get();
    manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
    assertNotNull(manager);
    // since there is no process instance yet we need to get new session
    RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    KieSession ksession = runtime.getKieSession();
    ProcessInstance pi1 = ksession.startProcess("test-process");
    assertEquals(ProcessInstance.STATE_COMPLETED, pi1.getState());
    manager.close();
}
Also used : WorkItemHandler(org.kie.api.runtime.process.WorkItemHandler) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) HashMap(java.util.HashMap) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) SendTaskHandler(org.jbpm.bpmn2.handler.SendTaskHandler) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) 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