use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.
the class ActivityTest method testUserTaskWithSimData.
@Test
public void testUserTaskWithSimData() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-UserTaskWithSimulationMetaData.bpmn2");
ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ProcessInstance processInstance = ksession.startProcess("UserTask");
assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
ksession = restoreSession(ksession, true);
WorkItem workItem = workItemHandler.getWorkItem();
assertNotNull(workItem);
assertEquals("john", workItem.getParameter("ActorId"));
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.
the class ActivityTest method testSubProcessInAdHocProcess.
@Test
public void testSubProcessInAdHocProcess() throws Exception {
// JBPM-5374
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-SubProcessInAdHocProcess.bpmn2");
ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
Map<String, Object> parameters = new HashMap<String, Object>();
ProcessInstance processInstance = ksession.startProcess("SubProcessInAdHocProcess", parameters);
assertProcessInstanceActive(processInstance);
ksession = restoreSession(ksession, true);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
WorkItem workItem = workItemHandler.getWorkItem();
assertNotNull(workItem);
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.
the class ActivityTest method testCallActivityWithContantsAssignment.
@Test
public void testCallActivityWithContantsAssignment() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("subprocess/SingleTaskWithVarDef.bpmn2", "subprocess/InputMappingUsingValue.bpmn2");
ksession = createKnowledgeSession(kbase);
TestWorkItemHandler handler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("CustomTask", handler);
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance processInstance = ksession.startProcess("defaultPackage.InputMappingUsingValue", params);
WorkItem workItem = handler.getWorkItem();
assertNotNull(workItem);
Object value = workItem.getParameter("TaskName");
assertNotNull(value);
assertEquals("test string", value);
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceCompleted(processInstance);
}
use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.
the class ActivityTest method testUserTaskParametrizedInput.
@Test
public void testUserTaskParametrizedInput() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-UserTaskWithParametrizedInput.bpmn2");
KieSession ksession = createKnowledgeSession(kbase);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
ProcessInstance processInstance = ksession.startProcess("UserTask");
assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
ksession = restoreSession(ksession, true);
WorkItem workItem = workItemHandler.getWorkItem();
assertNotNull(workItem);
assertEquals("Executing task of process instance " + processInstance.getId() + " as work item with Hello", workItem.getParameter("Description").toString().trim());
ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
assertProcessInstanceFinished(processInstance, ksession);
ksession.dispose();
}
use of org.kie.api.runtime.process.WorkItem 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