use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class ActivityTest method testAdHocSubProcessAutoCompleteDynamicSubProcess.
@Test
public void testAdHocSubProcessAutoCompleteDynamicSubProcess() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-AdHocSubProcessAutoComplete.bpmn2", "BPMN2-AdHocSubProcess.drl", "BPMN2-MinimalProcess.bpmn2");
ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
TestWorkItemHandler workItemHandler2 = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("OtherTask", workItemHandler2);
ProcessInstance processInstance = ksession.startProcess("AdHocSubProcess");
assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
ksession.fireAllRules();
DynamicNodeInstance dynamicContext = (DynamicNodeInstance) ((WorkflowProcessInstance) processInstance).getNodeInstances().iterator().next();
DynamicUtils.addDynamicSubProcess(dynamicContext, ksession, "Minimal", new HashMap<String, Object>());
ksession = restoreSession(ksession, true);
WorkItem workItem = workItemHandler.getWorkItem();
assertNotNull(workItem);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
// assertProcessInstanceActive(processInstance.getId(), ksession);
// workItem = workItemHandler2.getWorkItem();
// ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class ActivityTest method testAdHocSubProcessAutoComplete.
@Test
public void testAdHocSubProcessAutoComplete() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-AdHocSubProcessAutoComplete.bpmn2", "BPMN2-AdHocSubProcess.drl");
ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ProcessInstance processInstance = ksession.startProcess("AdHocSubProcess");
assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
WorkItem workItem = workItemHandler.getWorkItem();
assertNull(workItem);
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ksession.fireAllRules();
workItem = workItemHandler.getWorkItem();
assertNotNull(workItem);
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertEquals("Exit", getProcessVarValue(processInstance, "y"));
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class ActivityTest method testProcesWithHumanTaskWithTimer.
@Test(timeout = 10000)
@RequirePersistence
public void testProcesWithHumanTaskWithTimer() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer", 1);
KieBase kbase = createKnowledgeBase("BPMN2-SubProcessWithTimer.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance processInstance = ksession.startProcess("subproc", params);
ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), null);
long sessionId = ksession.getIdentifier();
Environment env = ksession.getEnvironment();
ksession.dispose();
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env);
ksession.addEventListener(countDownListener);
countDownListener.waitTillCompleted();
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class ActivityTest method testAdHocSubProcessAutoCompleteDynamicTask.
@Test
public void testAdHocSubProcessAutoCompleteDynamicTask() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-AdHocSubProcessAutoComplete.bpmn2", "BPMN2-AdHocSubProcess.drl");
ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
TestWorkItemHandler workItemHandler2 = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("OtherTask", workItemHandler2);
ProcessInstance processInstance = ksession.startProcess("AdHocSubProcess");
assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
DynamicNodeInstance dynamicContext = (DynamicNodeInstance) ((WorkflowProcessInstance) processInstance).getNodeInstances().iterator().next();
DynamicUtils.addDynamicWorkItem(dynamicContext, ksession, "OtherTask", new HashMap<String, Object>());
WorkItem workItem = workItemHandler.getWorkItem();
assertNull(workItem);
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ksession.fireAllRules();
workItem = workItemHandler.getWorkItem();
assertNotNull(workItem);
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceActive(processInstance);
workItem = workItemHandler2.getWorkItem();
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceFinished(processInstance, ksession);
ksession.dispose();
}
use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.
the class ActivityTest method testUserTaskWithBooleanOutput.
@Test
public void testUserTaskWithBooleanOutput() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-UserTaskWithBooleanOutput.bpmn2");
ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ProcessInstance processInstance = ksession.startProcess("com.sample.boolean");
assertProcessInstanceActive(processInstance);
ksession = restoreSession(ksession, true);
WorkItem workItem = workItemHandler.getWorkItem();
assertNotNull(workItem);
assertEquals("john", workItem.getParameter("ActorId"));
HashMap<String, Object> output = new HashMap<String, Object>();
output.put("isCheckedCheckbox", "true");
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), output);
assertProcessInstanceFinished(processInstance, ksession);
}
Aggregations