use of org.kie.api.task.TaskService in project jbpm by kiegroup.
the class ProcessHumanTaskTest method testProcessProcessInstanceStrategy.
@Test
public void testProcessProcessInstanceStrategy() {
RuntimeManager manager = createRuntimeManager(Strategy.PROCESS_INSTANCE, "manager", "org/jbpm/test/functional/task/humantask.bpmn");
RuntimeEngine runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get());
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
long ksessionID = ksession.getIdentifier();
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");
assertProcessInstanceActive(processInstance.getId(), ksession);
assertNodeTriggered(processInstance.getId(), "Start", "Task 1");
manager.disposeRuntimeEngine(runtimeEngine);
runtimeEngine = getRuntimeEngine(ProcessInstanceIdContext.get(processInstance.getId()));
ksession = runtimeEngine.getKieSession();
taskService = runtimeEngine.getTaskService();
assertEquals(ksessionID, ksession.getIdentifier());
// 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");
// 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);
manager.disposeRuntimeEngine(runtimeEngine);
}
use of org.kie.api.task.TaskService in project jbpm by kiegroup.
the class ProcessHumanTaskTest method testProcess.
@Test
public void testProcess() {
createRuntimeManager("org/jbpm/test/functional/task/humantask.bpmn");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");
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");
// 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 ProcessPersistenceHumanTaskOnLaneTest method testProcess.
@Test
public void testProcess() throws Exception {
createRuntimeManager("org/jbpm/test/functional/task/HumanTaskOnLane.bpmn2");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
ProcessInstance processInstance = ksession.startProcess("UserTask");
assertProcessInstanceActive(processInstance.getId());
// simulating a system restart
logger.debug("Reloading the environemnt to simulate system restart");
disposeRuntimeManager();
createRuntimeManager("org/jbpm/test/functional/task/HumanTaskOnLane.bpmn2");
runtimeEngine = getRuntimeEngine();
ksession = runtimeEngine.getKieSession();
taskService = runtimeEngine.getTaskService();
// let john execute Task 1
String taskUser = "john";
String locale = "en-UK";
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner(taskUser, locale);
assertEquals(1, list.size());
TaskSummary task = list.get(0);
taskService.claim(task.getId(), taskUser);
taskService.start(task.getId(), taskUser);
taskService.complete(task.getId(), taskUser, null);
// simulating a system restart
logger.debug("Reloading the environemnt to simulate system restart once again");
List<Status> reservedOnly = new ArrayList<Status>();
reservedOnly.add(Status.Reserved);
list = taskService.getTasksAssignedAsPotentialOwnerByStatus(taskUser, reservedOnly, locale);
assertEquals(1, list.size());
task = list.get(0);
taskService.start(task.getId(), taskUser);
taskService.complete(task.getId(), taskUser, null);
assertProcessInstanceCompleted(processInstance.getId());
}
use of org.kie.api.task.TaskService in project jbpm by kiegroup.
the class ProcessPersistenceHumanTaskOnLaneTest method testProcessWIthDifferentGroups.
@Test
public void testProcessWIthDifferentGroups() throws Exception {
createRuntimeManager("org/jbpm/test/functional/task/HumanTaskOnLaneDifferentGroups.bpmn2");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
ProcessInstance processInstance = ksession.startProcess("UserTask");
assertProcessInstanceActive(processInstance.getId());
// simulating a system restart
logger.debug("Reloading the environemnt to simulate system restart");
disposeRuntimeManager();
createRuntimeManager("org/jbpm/test/functional/task/HumanTaskOnLaneDifferentGroups.bpmn2");
runtimeEngine = getRuntimeEngine();
ksession = runtimeEngine.getKieSession();
taskService = runtimeEngine.getTaskService();
// let manager execute Task 1
String taskUser = "manager";
String locale = "en-UK";
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner(taskUser, locale);
assertEquals(1, list.size());
TaskSummary task = list.get(0);
taskService.claim(task.getId(), taskUser);
taskService.start(task.getId(), taskUser);
taskService.complete(task.getId(), taskUser, null);
// simulating a system restart
logger.debug("Reloading the environemnt to simulate system restart once again");
disposeRuntimeManager();
createRuntimeManager("org/jbpm/test/functional/task/HumanTaskOnLane.bpmn2");
runtimeEngine = getRuntimeEngine();
ksession = runtimeEngine.getKieSession();
taskService = runtimeEngine.getTaskService();
List<Status> reservedAndRegistered = new ArrayList<Status>();
reservedAndRegistered.add(Status.Reserved);
reservedAndRegistered.add(Status.Ready);
// manager does not have access to the second task
list = taskService.getTasksAssignedAsPotentialOwnerByStatus(taskUser, reservedAndRegistered, locale);
assertEquals(0, list.size());
// now try john
taskUser = "john";
list = taskService.getTasksAssignedAsPotentialOwnerByStatus(taskUser, reservedAndRegistered, locale);
assertEquals(1, list.size());
task = list.get(0);
// task is in ready state so claim is required
assertEquals(Status.Ready, task.getStatus());
taskService.claim(task.getId(), taskUser);
taskService.start(task.getId(), taskUser);
taskService.complete(task.getId(), taskUser, null);
assertProcessInstanceCompleted(processInstance.getId());
}
use of org.kie.api.task.TaskService in project jbpm by kiegroup.
the class ProcessPersistenceHumanTaskTest method testProcess.
@Test
public void testProcess() throws Exception {
createRuntimeManager("org/jbpm/test/functional/task/humantask.bpmn");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");
assertProcessInstanceActive(processInstance.getId());
assertNodeTriggered(processInstance.getId(), "Start", "Task 1");
// simulating a system restart
logger.debug("Reloading the environemnt to simulate system restart");
disposeRuntimeManager();
createRuntimeManager("org/jbpm/test/functional/task/humantask.bpmn");
runtimeEngine = getRuntimeEngine();
ksession = runtimeEngine.getKieSession();
taskService = runtimeEngine.getTaskService();
// let john execute Task 1
String taskGroup = "en-UK";
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", taskGroup);
TaskSummary task = list.get(0);
logger.debug("John is executing task " + task.getName());
taskService.start(task.getId(), "john");
taskService.complete(task.getId(), "john", null);
assertNodeTriggered(processInstance.getId(), "Task 2");
// simulating a system restart
logger.debug("Reloading the environemnt to simulate system restart once again");
disposeRuntimeManager();
createRuntimeManager("org/jbpm/test/functional/task/humantask.bpmn");
runtimeEngine = getRuntimeEngine();
ksession = runtimeEngine.getKieSession();
taskService = runtimeEngine.getTaskService();
// let mary execute Task 2
String taskUser = "mary";
list = taskService.getTasksAssignedAsPotentialOwner(taskUser, taskGroup);
assertTrue("No tasks found for potential owner " + taskUser + "/" + taskGroup, list.size() > 0);
task = list.get(0);
logger.debug("Mary is executing task " + task.getName());
taskService.start(task.getId(), "mary");
taskService.complete(task.getId(), "mary", null);
assertNodeTriggered(processInstance.getId(), "End");
assertProcessInstanceCompleted(processInstance.getId());
}
Aggregations