use of org.kie.api.task.TaskService in project jbpm by kiegroup.
the class AdminAPIsWithListenerTest method automaticCleanUpWitCallActivityTest.
@Test
public void automaticCleanUpWitCallActivityTest() throws Exception {
createRuntimeManager("org/jbpm/test/functional/task/CallActivity.bpmn2", "org/jbpm/test/functional/task/CallActivity2.bpmn2", "org/jbpm/test/functional/task/CallActivitySubProcess.bpmn2");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
ksession.addEventListener(new TaskCleanUpProcessEventListener(taskService));
ProcessInstance processInstance = ksession.startProcess("ParentProcessCA");
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
assertEquals(1, tasks.size());
long taskId = tasks.get(0).getId();
taskService.start(taskId, "john");
taskService.complete(taskId, "john", null);
assertProcessInstanceCompleted(processInstance.getId());
final EntityManager em = emfTasks.createEntityManager();
assertEquals(0, em.createQuery("select t from TaskImpl t").getResultList().size());
assertEquals(0, em.createQuery("select i from I18NTextImpl i").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_BAs").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_ExclOwners").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_PotOwners").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_Recipients").getResultList().size());
assertEquals(0, em.createNativeQuery("select * from PeopleAssignments_Stakeholders").getResultList().size());
assertEquals(0, em.createQuery("select c from ContentImpl c").getResultList().size());
em.close();
}
use of org.kie.api.task.TaskService in project jbpm by kiegroup.
the class InclusiveGatewayWithHumanTasksProcessTest method testInclusiveGatewayWithLoopAndUserTasks.
@Test
public void testInclusiveGatewayWithLoopAndUserTasks() {
createRuntimeManager("org/jbpm/test/functional/gateway/InclusiveGatewayWithHumanTasksProcess.bpmn");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
String userId = "john";
// start a new process instance
Map<String, Object> params = new HashMap<String, Object>();
params.put("firstXor", true);
params.put("secondXor", true);
params.put("thirdXor", true);
ProcessInstance pi = ksession.startProcess("InclusiveWithAdvancedLoop", params);
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner(userId, "en-UK");
assertNotNull(tasks);
assertEquals(1, tasks.size());
// completing first task
taskService.start(tasks.get(0).getId(), userId);
taskService.complete(tasks.get(0).getId(), userId, new HashMap<String, Object>());
// completing second task
tasks = taskService.getTasksAssignedAsPotentialOwner(userId, "en-UK");
assertNotNull(tasks);
assertEquals(2, tasks.size());
for (TaskSummary task : tasks) {
if (task.getName().equals("HT Form2")) {
taskService.start(task.getId(), userId);
taskService.complete(task.getId(), userId, new HashMap<String, Object>());
break;
}
}
List<TaskSummary> johntasks = taskService.getTasksAssignedAsPotentialOwner(userId, "en-UK");
assertNotNull(johntasks);
assertEquals(1, johntasks.size());
taskService.start(johntasks.get(0).getId(), userId);
taskService.complete(johntasks.get(0).getId(), userId, new HashMap<String, Object>());
johntasks = taskService.getTasksAssignedAsPotentialOwner(userId, "en-UK");
assertNotNull(johntasks);
assertEquals(1, johntasks.size());
taskService.start(johntasks.get(0).getId(), userId);
taskService.complete(johntasks.get(0).getId(), userId, new HashMap<String, Object>());
assertProcessInstanceCompleted(pi.getId());
}
use of org.kie.api.task.TaskService in project jbpm by kiegroup.
the class AbstractStartProcessWithCorrelationKeyTest method testProcessesWithSameBusinessKeyNotInParallel.
@Test
public void testProcessesWithSameBusinessKeyNotInParallel() {
createRuntimeManager("org/jbpm/test/functional/correlation/humantask.bpmn");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
ProcessInstance processInstance = ((CorrelationAwareProcessRuntime) ksession).startProcess("com.sample.bpmn.hello", getCorrelationKey(), null);
assertProcessInstanceActive(processInstance.getId(), ksession);
assertNodeTriggered(processInstance.getId(), "Start", "Task 1");
// let john execute Task 1
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
TaskSummary task = list.get(0);
logger.info("John is executing task {}", task.getName());
taskService.start(task.getId(), "john");
taskService.complete(task.getId(), "john", null);
assertNodeTriggered(processInstance.getId(), "Task 2");
ProcessInstance processInstanceCopy = ((CorrelationAwareProcessRuntime) ksession).getProcessInstance(getCorrelationKey());
assertNotNull(processInstanceCopy);
assertEquals(processInstance.getId(), processInstanceCopy.getId());
// let mary execute Task 2
list = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");
task = list.get(0);
logger.info("Mary is executing task {}", task.getName());
taskService.start(task.getId(), "mary");
taskService.complete(task.getId(), "mary", null);
assertNodeTriggered(processInstance.getId(), "End");
assertProcessInstanceNotActive(processInstance.getId(), ksession);
processInstance = ((CorrelationAwareProcessRuntime) ksession).startProcess("com.sample.bpmn.hello", getCorrelationKey(), null);
assertProcessInstanceActive(processInstance.getId(), ksession);
assertNodeTriggered(processInstance.getId(), "Start", "Task 1");
// let john execute Task 1
list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
task = list.get(0);
logger.info("John is executing task {}", task.getName());
taskService.start(task.getId(), "john");
taskService.complete(task.getId(), "john", null);
assertNodeTriggered(processInstance.getId(), "Task 2");
processInstanceCopy = ((CorrelationAwareProcessRuntime) ksession).getProcessInstance(getCorrelationKey());
assertNotNull(processInstanceCopy);
assertEquals(processInstance.getId(), processInstanceCopy.getId());
// let mary execute Task 2
list = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");
task = list.get(0);
logger.info("Mary is executing task {}", task.getName());
taskService.start(task.getId(), "mary");
taskService.complete(task.getId(), "mary", null);
assertNodeTriggered(processInstance.getId(), "End");
assertProcessInstanceNotActive(processInstance.getId(), ksession);
}
use of org.kie.api.task.TaskService in project jbpm by kiegroup.
the class AbstractStartProcessWithCorrelationKeyTest method testCreateAndStartProcessWithBusinessKey.
@Test
public void testCreateAndStartProcessWithBusinessKey() {
createRuntimeManager("org/jbpm/test/functional/correlation/humantask.bpmn");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
ProcessInstance processInstance = ((CorrelationAwareProcessRuntime) ksession).createProcessInstance("com.sample.bpmn.hello", getCorrelationKey(), null);
ksession.startProcessInstance(processInstance.getId());
assertProcessInstanceActive(processInstance.getId(), ksession);
assertNodeTriggered(processInstance.getId(), "Start", "Task 1");
// let john execute Task 1
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
TaskSummary task = list.get(0);
logger.info("John is executing task {}", task.getName());
taskService.start(task.getId(), "john");
taskService.complete(task.getId(), "john", null);
assertNodeTriggered(processInstance.getId(), "Task 2");
ProcessInstance processInstanceCopy = ((CorrelationAwareProcessRuntime) ksession).getProcessInstance(getCorrelationKey());
assertNotNull(processInstanceCopy);
assertEquals(processInstance.getId(), processInstanceCopy.getId());
// let mary execute Task 2
list = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");
task = list.get(0);
logger.info("Mary is executing task {}", task.getName());
taskService.start(task.getId(), "mary");
taskService.complete(task.getId(), "mary", null);
assertNodeTriggered(processInstance.getId(), "End");
assertProcessInstanceNotActive(processInstance.getId(), ksession);
}
use of org.kie.api.task.TaskService in project jbpm by kiegroup.
the class AbstractStartProcessWithCorrelationKeyTest method testProcessWithBusinessKey.
@Test
public void testProcessWithBusinessKey() {
createRuntimeManager("org/jbpm/test/functional/correlation/humantask.bpmn");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
ProcessInstance processInstance = ((CorrelationAwareProcessRuntime) ksession).startProcess("com.sample.bpmn.hello", getCorrelationKey(), null);
assertProcessInstanceActive(processInstance.getId(), ksession);
assertNodeTriggered(processInstance.getId(), "Start", "Task 1");
// let john execute Task 1
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
TaskSummary task = list.get(0);
logger.info("John is executing task {}", task.getName());
taskService.start(task.getId(), "john");
taskService.complete(task.getId(), "john", null);
assertNodeTriggered(processInstance.getId(), "Task 2");
ProcessInstance processInstanceCopy = ((CorrelationAwareProcessRuntime) ksession).getProcessInstance(getCorrelationKey());
assertNotNull(processInstanceCopy);
assertEquals(processInstance.getId(), processInstanceCopy.getId());
// let mary execute Task 2
list = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");
task = list.get(0);
logger.info("Mary is executing task {}", task.getName());
taskService.start(task.getId(), "mary");
taskService.complete(task.getId(), "mary", null);
assertNodeTriggered(processInstance.getId(), "End");
assertProcessInstanceNotActive(processInstance.getId(), ksession);
}
Aggregations