use of org.jbpm.process.workitem.wsht.GenericHTWorkItemHandler in project jBPM5-Developer-Guide by Salaboy.
the class ProcessAndHumanTasksTest method testProcessWithHumanTasks.
@Test
public void testProcessWithHumanTasks() throws InterruptedException {
StatefulKnowledgeSession ksession = this.initializeSession();
KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
GenericHTWorkItemHandler htHandler = this.createTaskHandler(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", htHandler);
Map<String, Object> initialParams = new HashMap<String, Object>();
initialParams.put("user_self_evaluation", "calcacuervo");
ProcessInstance processInstance = ksession.startProcess("chapter_07_simple_review", initialParams);
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
// first, calcacuervo will make its own review..
List<TaskSummary> tasks = this.service.getTasksAssignedAsPotentialOwner("calcacuervo", "en-UK");
assertEquals(1, tasks.size());
this.service.start(tasks.get(0).getId(), "calcacuervo");
this.service.complete(tasks.get(0).getId(), "calcacuervo", null);
// now, a user with role TL will see the task.. esteban is one of them
List<TaskSummary> estebanTasks = this.service.getTasksAssignedAsPotentialOwner("esteban", "en-UK");
Assert.assertEquals(1, estebanTasks.size());
this.service.claim(estebanTasks.get(0).getId(), "esteban");
this.service.start(estebanTasks.get(0).getId(), "esteban");
this.service.complete(estebanTasks.get(0).getId(), "esteban", null);
// now, a user with role HR will see the task.. mariano is one of them
List<TaskSummary> marianoTasks = this.service.getTasksAssignedAsPotentialOwner("mariano", "en-UK");
Assert.assertEquals(1, marianoTasks.size());
this.service.claim(marianoTasks.get(0).getId(), "mariano");
this.service.start(marianoTasks.get(0).getId(), "mariano");
this.service.complete(marianoTasks.get(0).getId(), "mariano", null);
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
Aggregations