Search in sources :

Example 6 with DoNothingWorkItemHandler

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

the class IntermediateEventTest method testIntermediateCatchEventTimerCycle2.

@Test(timeout = 10000)
public void testIntermediateCatchEventTimerCycle2() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3);
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycle2.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();
    assertProcessInstanceActive(processInstance);
    ksession.abortProcessInstance(processInstance.getId());
}
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 7 with DoNothingWorkItemHandler

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

the class IntermediateEventTest method testIntermediateCatchEventTimerDateISO.

@Test(timeout = 10000)
public void testIntermediateCatchEventTimerDateISO() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntermediateCatchEventTimerDateISO.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);
    HashMap<String, Object> params = new HashMap<String, Object>();
    OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2);
    params.put("date", plusTwoSeconds.toString());
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent", params);
    assertProcessInstanceActive(processInstance);
    // now wait for 1 second for timer to trigger
    countDownListener.waitTillCompleted();
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) HashMap(java.util.HashMap) OffsetDateTime(java.time.OffsetDateTime) 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 8 with DoNothingWorkItemHandler

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

the class IntermediateEventTest method testTimerBoundaryEventCycleISOWithPersistence.

@Test(timeout = 10000)
@RequirePersistence
public void testTimerBoundaryEventCycleISOWithPersistence() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 2);
    // load up the knowledge base
    KieBase kbase = createKnowledgeBase("BPMN2-TimerBoundaryEventCycleISO.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(countDownListener);
    long sessionId = ksession.getIdentifier();
    Environment env = ksession.getEnvironment();
    ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
    ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent");
    assertProcessInstanceActive(processInstance);
    countDownListener.waitTillCompleted();
    assertProcessInstanceActive(processInstance);
    logger.info("dispose");
    ksession.dispose();
    ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env);
    ksession.addEventListener(countDownListener);
    assertProcessInstanceActive(processInstance);
    ksession.abortProcessInstance(processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) KieBase(org.kie.api.KieBase) CommandBasedStatefulKnowledgeSession(org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) DoNothingWorkItemHandler(org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler) Environment(org.kie.api.runtime.Environment) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence)

Example 9 with DoNothingWorkItemHandler

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

the class IntermediateEventTest method testTimerBoundaryEventDateISO.

@Test(timeout = 10000)
public void testTimerBoundaryEventDateISO() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1);
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-TimerBoundaryEventDateISO.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(countDownListener);
    ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
    HashMap<String, Object> params = new HashMap<String, Object>();
    OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2);
    params.put("date", plusTwoSeconds.toString());
    ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent", params);
    assertProcessInstanceActive(processInstance);
    countDownListener.waitTillCompleted();
    ksession = restoreSession(ksession, true);
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) HashMap(java.util.HashMap) OffsetDateTime(java.time.OffsetDateTime) 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 10 with DoNothingWorkItemHandler

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

the class IntermediateEventTest method testIntermediateCatchEventTimerDurationISO.

@Test(timeout = 10000)
public void testIntermediateCatchEventTimerDurationISO() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDurationISO.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.5 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)

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