use of org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager in project jbpm by kiegroup.
the class SingleRuntimeManagerWithListenersTest method testProcessStartOnManager.
private void testProcessStartOnManager(RuntimeEngine runtime) {
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
Collection<ProcessEventListener> pListeners = ksession.getProcessEventListeners();
assertNotNull(pListeners);
// prepare listeners class names for assertion
List<String> listenerCLassNames = new ArrayList<String>();
for (Object o : pListeners) {
listenerCLassNames.add(o.getClass().getName());
}
// DebugProcessEventListener was added by custom producer
assertTrue(listenerCLassNames.contains(DebugProcessEventListener.class.getName()));
// JPAWorkingMemoryDbLogger one is always added to deal with user tasks
assertTrue(listenerCLassNames.contains(JPAWorkingMemoryDbLogger.class.getName()));
if (((RuntimeEngineImpl) runtime).getManager() instanceof PerProcessInstanceRuntimeManager) {
assertEquals(3, pListeners.size());
} else {
assertEquals(2, pListeners.size());
}
TaskService taskService = runtime.getTaskService();
assertNotNull(taskService);
List<?> listeners = ((EventService<?>) taskService).getTaskEventListeners();
assertNotNull(listeners);
assertEquals(3, listeners.size());
// prepare listeners class names for assertion
listenerCLassNames = new ArrayList<String>();
for (Object o : listeners) {
System.out.println("###### " + o.getClass().getName());
listenerCLassNames.add(o.getClass().getName());
}
assertEquals(3, listenerCLassNames.size());
// JPATaskLifeCycleEventListener was added by custom producer
assertTrue(listenerCLassNames.contains(JPATaskLifeCycleEventListener.class.getName()));
// external one is always added to deal with user tasks
assertTrue(listenerCLassNames.contains(ExternalTaskEventListener.class.getName()));
// BAMTaskEventListener was added by custom producer
assertTrue(listenerCLassNames.contains(BAMTaskEventListener.class.getName()));
ProcessInstance processInstance = ksession.startProcess("UserTask");
assertNotNull(processInstance);
List<Status> statuses = new ArrayList<Status>();
statuses.add(Status.Reserved);
List<TaskSummary> tasks = taskService.getTasksOwnedByStatus("john", statuses, "en-UK");
assertNotNull(tasks);
assertEquals(1, tasks.size());
taskService.start(tasks.get(0).getId(), "john");
taskService.complete(tasks.get(0).getId(), "john", null);
processInstance = ksession.getProcessInstance(processInstance.getId());
assertNull(processInstance);
}
Aggregations