Search in sources :

Example 11 with SystemOutWorkItemHandler

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

the class IntermediateEventTest method testEventBasedSplit2.

@Test(timeout = 10000)
public void testEventBasedSplit2() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 2);
    KieBase kbase = createKnowledgeBase("BPMN2-EventBasedSplit2.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
    ksession.addEventListener(countDownListener);
    // Yes
    ProcessInstance processInstance = ksession.startProcess("com.sample.test");
    assertProcessInstanceActive(processInstance);
    ksession = restoreSession(ksession, true);
    ksession.addEventListener(countDownListener);
    ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
    ksession.signalEvent("Yes", "YesValue", processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
    ksession = restoreSession(ksession, true);
    ksession.addEventListener(countDownListener);
    ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
    ksession = restoreSession(ksession, true);
    ksession.addEventListener(countDownListener);
    ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
    // Timer
    processInstance = ksession.startProcess("com.sample.test");
    assertProcessInstanceActive(processInstance);
    countDownListener.waitTillCompleted();
    ksession = restoreSession(ksession, true);
    ksession.addEventListener(countDownListener);
    ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) 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 12 with SystemOutWorkItemHandler

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

the class IntermediateEventTest method testIntermediateCatchEventSignalWithVariable.

@Test
public void testIntermediateCatchEventSignalWithVariable() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventSignalWithVariable.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    String signalVar = "myVarSignal";
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("signalName", signalVar);
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent", parameters);
    assertProcessInstanceActive(processInstance);
    ksession = restoreSession(ksession, true);
    // now signal process instance
    ksession.signalEvent(signalVar, "SomeValue", processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
    assertNodeTriggered(processInstance.getId(), "StartProcess", "UserTask", "EndProcess", "event");
}
Also used : HashMap(java.util.HashMap) 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 13 with SystemOutWorkItemHandler

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

the class IntermediateEventTest method testEventBasedSplitAfter.

@Test
public void testEventBasedSplitAfter() throws Exception {
    // signaling the other alternative after one has been selected should
    // have no effect
    KieBase kbase = createKnowledgeBase("BPMN2-EventBasedSplit.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler());
    // 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 DoNothingWorkItemHandler());
    ksession.signalEvent("Yes", "YesValue", processInstance.getId());
    assertProcessInstanceActive(processInstance);
    ksession = restoreSession(ksession, true);
    ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler());
    // No
    ksession.signalEvent("No", "NoValue", processInstance.getId());
}
Also used : KieBase(org.kie.api.KieBase) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) DoNothingWorkItemHandler(org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 14 with SystemOutWorkItemHandler

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

the class IntermediateEventTest method testEventBasedSplit4.

@Test
public void testEventBasedSplit4() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-EventBasedSplit4.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
    // 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());
    ksession.signalEvent("Message-YesMessage", "YesValue", processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
    ksession = restoreSession(ksession, true);
    ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("Email2", new SystemOutWorkItemHandler());
    // No
    processInstance = ksession.startProcess("com.sample.test");
    ksession.signalEvent("Message-NoMessage", "NoValue", processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
}
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 15 with SystemOutWorkItemHandler

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

the class IntermediateEventTest method testIntermediateCatchEventSameSignalOnTwoKsessions.

@Test
public void testIntermediateCatchEventSameSignalOnTwoKsessions() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventSignal.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    KieBase kbase2 = createKnowledgeBase("BPMN2-IntermediateCatchEventSignal2.bpmn2");
    KieSession ksession2 = createKnowledgeSession(kbase2);
    ksession2.getWorkItemManager().registerWorkItemHandler("Human Task", new SystemOutWorkItemHandler());
    ProcessInstance processInstance2 = ksession2.startProcess("IntermediateCatchEvent2");
    assertProcessInstanceActive(processInstance);
    assertProcessInstanceActive(processInstance2);
    ksession = restoreSession(ksession, true);
    ksession2 = restoreSession(ksession2, true);
    // now signal process instance
    ksession.signalEvent("MyMessage", "SomeValue");
    assertProcessInstanceFinished(processInstance, ksession);
    assertProcessInstanceActive(processInstance2);
    // now signal the other one
    ksession2.signalEvent("MyMessage", "SomeValue");
    assertProcessInstanceFinished(processInstance2, ksession2);
    ksession2.dispose();
}
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) KieSession(org.kie.api.runtime.KieSession) 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