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);
}
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);
}
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);
}
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());
}
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);
}
Aggregations