use of org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler in project jbpm by kiegroup.
the class StandaloneBPMNProcessTest method testIntermediateCatchEventTimer.
@Test(timeout = 10000)
public void testIntermediateCatchEventTimer() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);
KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDuration.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
// now wait for 1 second for timer to trigger
countDownListener.waitTillCompleted();
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
use of org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler in project jbpm by kiegroup.
the class StandaloneBPMNProcessTest method testErrorBoundaryEvent.
@Test
public void testErrorBoundaryEvent() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-ErrorBoundaryEventInterrupting.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
ProcessInstance processInstance = ksession.startProcess("ErrorBoundaryEvent");
assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
use of org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler in project jbpm by kiegroup.
the class ProcessTimerTest method testOnEntryTimerWorkItemExecuted.
@Test
public void testOnEntryTimerWorkItemExecuted() throws Exception {
Reader source = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" + " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" + " type=\"RuleFlow\" name=\"flow\" id=\"org.drools.timer\" package-name=\"org.drools\" version=\"1\" >\n" + "\n" + " <header>\n" + " <globals>\n" + " <global identifier=\"myList\" type=\"java.util.List\" />\n" + " </globals>\n" + " </header>\n" + "\n" + " <nodes>\n" + " <start id=\"1\" name=\"Start\" />\n" + " <workItem id=\"2\" name=\"Work\" >\n" + " <timers>\n" + " <timer id=\"1\" delay=\"300\" >\n" + " <action type=\"expression\" dialect=\"java\" >myList.add(\"Executing timer\");</action>\n" + " </timer>\n" + " </timers>\n" + " <work name=\"Human Task\" >\n" + " </work>\n" + " </workItem>\n" + " <end id=\"3\" name=\"End\" />\n" + " </nodes>\n" + "\n" + " <connections>\n" + " <connection from=\"1\" to=\"2\" />\n" + " <connection from=\"2\" to=\"3\" />\n" + " </connections>\n" + "\n" + "</process>");
builder.addRuleFlow(source);
KieSession session = createKieSession(builder.getPackages());
List<String> myList = new ArrayList<String>();
session.setGlobal("myList", myList);
session.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
ProcessInstance processInstance = (ProcessInstance) session.startProcess("org.drools.timer");
assertEquals(0, myList.size());
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
assertEquals(1, ((InternalProcessRuntime) ((InternalWorkingMemory) session).getProcessRuntime()).getTimerManager().getTimers().size());
try {
Thread.sleep(400);
} catch (InterruptedException e) {
// do nothing
}
assertEquals(1, myList.size());
session.dispose();
}
use of org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler in project jbpm by kiegroup.
the class WorkItemTest method testCancelNonRegisteredWorkItemHandler.
@Test
public void testCancelNonRegisteredWorkItemHandler() {
String processId = "org.drools.actions";
String workName = "Unnexistent Task";
RuleFlowProcess process = getWorkItemProcess(processId, workName);
KieSession ksession = createKieSession(process);
ksession.getWorkItemManager().registerWorkItemHandler(workName, new DoNothingWorkItemHandler());
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("UserName", "John Doe");
parameters.put("Person", new Person("John Doe"));
ProcessInstance processInstance = ksession.startProcess("org.drools.actions", parameters);
long processInstanceId = processInstance.getId();
Assert.assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
ksession.getWorkItemManager().registerWorkItemHandler(workName, null);
try {
ksession.abortProcessInstance(processInstanceId);
Assert.fail("should fail if WorkItemHandler for" + workName + "is not registered");
} catch (WorkItemHandlerNotFoundException wihnfe) {
}
Assert.assertEquals(ProcessInstance.STATE_ABORTED, processInstance.getState());
}
use of org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler in project jbpm by kiegroup.
the class IntermediateEventTest method testIntermediateCatchEventTimerDuration.
@Test(timeout = 10000)
public void testIntermediateCatchEventTimerDuration() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1);
KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerDuration.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());
ksession.addEventListener(countDownListener);
assertProcessInstanceFinished(processInstance, ksession);
}
Aggregations