Search in sources :

Example 16 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler 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");
}
Also used : KieBase(org.kie.api.KieBase) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) ReceiveTaskHandler(org.jbpm.bpmn2.handler.ReceiveTaskHandler) Test(org.junit.Test)

Example 17 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class IntermediateEventTest method testIntermediateCatchEventSignal.

@Test
public void testIntermediateCatchEventSignal() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventSignal.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    assertProcessInstanceActive(processInstance);
    ksession = restoreSession(ksession, true);
    // now signal process instance
    ksession.signalEvent("MyMessage", "SomeValue", processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
    assertNodeTriggered(processInstance.getId(), "StartProcess", "UserTask", "EndProcess", "event");
}
Also used : KieBase(org.kie.api.KieBase) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 18 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class StandaloneBPMNProcessTest method testIntermediateCatchEventSignal.

@Test
public void testIntermediateCatchEventSignal() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventSignal.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    ksession = restoreSession(ksession, true);
    // now signal process instance
    ksession.signalEvent("MyMessage", "SomeValue", processInstance.getId());
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
Also used : KieBase(org.kie.api.KieBase) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 19 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class StandaloneBPMNProcessTest method testEvaluationProcess3.

@Test
public void testEvaluationProcess3() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-EvaluationProcess3.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("RegisterRequest", new SystemOutWorkItemHandler());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("employee", "john2");
    ProcessInstance processInstance = ksession.startProcess("Evaluation", params);
    assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 20 with SystemOutWorkItemHandler

use of org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler in project jbpm by kiegroup.

the class StandaloneBPMNProcessTest method testIntermediateCatchEventMessage.

@Test
public void testIntermediateCatchEventMessage() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventMessage.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    ksession = restoreSession(ksession, true);
    // now signal process instance
    ksession.signalEvent("Message-HelloMessage", "SomeValue", processInstance.getId());
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
Also used : KieBase(org.kie.api.KieBase) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Aggregations

SystemOutWorkItemHandler (org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler)87 Test (org.junit.Test)77 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)75 KieBase (org.kie.api.KieBase)59 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)45 HashMap (java.util.HashMap)39 KieSession (org.kie.api.runtime.KieSession)38 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)16 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)15 DefaultRegisterableItemsFactory (org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory)14 AbstractExecutorBaseTest (org.jbpm.test.util.AbstractExecutorBaseTest)14 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)14 WorkItemHandler (org.kie.api.runtime.process.WorkItemHandler)14 NodeTriggeredCountDownProcessEventListener (org.jbpm.test.listener.NodeTriggeredCountDownProcessEventListener)13 ProcessEventListener (org.kie.api.event.process.ProcessEventListener)13 ArrayList (java.util.ArrayList)10 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)6 Document (org.w3c.dom.Document)5 Map (java.util.Map)4 PersistenceUtil.createEnvironment (org.jbpm.persistence.util.PersistenceUtil.createEnvironment)4