Search in sources :

Example 11 with DoNothingWorkItemHandler

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

the class IntermediateEventTest method testTimerBoundaryEventDuration.

@Test(timeout = 10000)
public void testTimerBoundaryEventDuration() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);
    KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventDuration.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);
    ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent");
    assertProcessInstanceActive(processInstance);
    countDownListener.waitTillCompleted();
    ksession = restoreSession(ksession, true);
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) KieBase(org.kie.api.KieBase) 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 12 with DoNothingWorkItemHandler

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

the class IntermediateEventTest method testIntermediateCatchEventTimerDurationWithError.

@Test(timeout = 10000)
@RequirePersistence
public void testIntermediateCatchEventTimerDurationWithError() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDurationWithError.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("x", 0);
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent", params);
    long waitTime = 2;
    assertProcessInstanceActive(processInstance);
    // now wait for 1 second for timer to trigger
    countDownListener.waitTillCompleted(waitTime * 1000);
    assertProcessInstanceActive(processInstance);
    processInstance = ksession.getProcessInstance(processInstance.getId());
    // reschedule it to allow to move on
    ksession.setGlobal("TestOK", Boolean.TRUE);
    ksession.execute(new UpdateTimerCommand(processInstance.getId(), "timer", waitTime + 1));
    countDownListener.reset(1);
    countDownListener.waitTillCompleted();
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) DoNothingWorkItemHandler(org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) UpdateTimerCommand(org.jbpm.process.instance.command.UpdateTimerCommand) Test(org.junit.Test) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence)

Example 13 with DoNothingWorkItemHandler

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

the class IntermediateEventTest method testIntermediateCatchEventTimerCycle1.

@Test(timeout = 10000)
public void testIntermediateCatchEventTimerCycle1() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycle1.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    assertProcessInstanceActive(processInstance);
    // now wait for 1 second for timer to trigger
    countDownListener.waitTillCompleted();
    ksession = restoreSession(ksession, true);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) KieBase(org.kie.api.KieBase) 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 DoNothingWorkItemHandler

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

the class StandaloneBPMNProcessTest 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");
    KieSession ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Email1", new SystemOutWorkItemHandler());
    ksession.getWorkItemManager().registerWorkItemHandler("Email2", new DoNothingWorkItemHandler());
    // 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 DoNothingWorkItemHandler());
    ksession.signalEvent("Yes", "YesValue", processInstance.getId());
    assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    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) 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 15 with DoNothingWorkItemHandler

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

the class ActivityTest method testAdHocProcessDynamicTask.

@Test
public void testAdHocProcessDynamicTask() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-AdHocProcess.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ProcessInstance processInstance = ksession.startProcess("AdHocProcess");
    assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
    ksession = restoreSession(ksession, true);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    logger.debug("Triggering node");
    ksession.signalEvent("Task1", null, processInstance.getId());
    assertProcessInstanceActive(processInstance);
    TestWorkItemHandler workItemHandler2 = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("OtherTask", workItemHandler2);
    DynamicUtils.addDynamicWorkItem(processInstance, ksession, "OtherTask", new HashMap<String, Object>());
    WorkItem workItem = workItemHandler2.getWorkItem();
    assertNotNull(workItem);
    ksession = restoreSession(ksession, true);
    ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
    ksession.signalEvent("User1", null, processInstance.getId());
    assertProcessInstanceActive(processInstance);
    ksession.insert(new Person());
    ksession.signalEvent("Task3", null, processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) KieBase(org.kie.api.KieBase) DoNothingWorkItemHandler(org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) WorkItem(org.kie.api.runtime.process.WorkItem) Person(org.jbpm.bpmn2.objects.Person) Test(org.junit.Test)

Aggregations

DoNothingWorkItemHandler (org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler)40 Test (org.junit.Test)39 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)36 KieBase (org.kie.api.KieBase)34 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)30 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)21 KieSession (org.kie.api.runtime.KieSession)12 HashMap (java.util.HashMap)6 RequirePersistence (org.jbpm.bpmn2.test.RequirePersistence)6 CommandBasedStatefulKnowledgeSession (org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession)4 Person (org.jbpm.bpmn2.objects.Person)4 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)4 ArrayList (java.util.ArrayList)3 DefaultRegisterableItemsFactory (org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory)3 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)3 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)3 WorkItemHandler (org.kie.api.runtime.process.WorkItemHandler)3 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)3 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2