use of org.kie.api.task.model.TaskSummary 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.model.TaskSummary 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);
}
use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.
the class BoundaryErrorMultiInstanceProcessTest method simpleSupportProcessTest.
@Test
public void simpleSupportProcessTest() {
createRuntimeManager("org/jbpm/test/functional/event/BoundaryErrorMultiInstanceProcess.bpmn2");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
TaskService taskService = runtimeEngine.getTaskService();
Map<String, Object> params = new HashMap<String, Object>();
params.put("approvers", new String[] { "salaboy", "mary" });
ProcessInstance processInstance = ksession.startProcess("boundary-catch-error-event", params);
assertProcessInstanceActive(processInstance.getId());
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
assertEquals(1, tasks.size());
TaskSummary dataEntryTask = tasks.get(0);
taskService.start(dataEntryTask.getId(), "john");
taskService.complete(dataEntryTask.getId(), "john", null);
tasks = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");
assertEquals(1, tasks.size());
tasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
assertEquals(1, tasks.size());
// signal to terminate subprocess
ksession.signalEvent("Terminate", null, processInstance.getId());
tasks = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");
assertEquals(0, tasks.size());
tasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
assertEquals(0, tasks.size());
// second round ...
tasks = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
assertEquals(1, tasks.size());
dataEntryTask = tasks.get(0);
taskService.start(dataEntryTask.getId(), "john");
taskService.complete(dataEntryTask.getId(), "john", null);
tasks = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");
assertEquals(1, tasks.size());
TaskSummary maryTask = tasks.get(0);
taskService.start(maryTask.getId(), "mary");
taskService.complete(maryTask.getId(), "mary", null);
tasks = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
assertEquals(1, tasks.size());
TaskSummary salaboyTask = tasks.get(0);
taskService.start(salaboyTask.getId(), "salaboy");
taskService.complete(salaboyTask.getId(), "salaboy", null);
assertProcessInstanceCompleted(processInstance.getId());
}
use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.
the class EThreadInfoTest method testHumanTaskThreadInfo.
@Test
public void testHumanTaskThreadInfo() throws Exception {
Long pid = startProcessInstance(THREAD_INFO_PROCESS_ID);
processService.signalProcessInstance(pid, "start", "usertask");
listener.waitTillCompleted();
List<TaskSummary> taskSummaries = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
Assertions.assertThat(taskSummaries).isNotNull().hasSize(1);
userTaskService.start(taskSummaries.get(0).getId(), "john");
userTaskService.complete(taskSummaries.get(0).getId(), "john", new HashMap<String, Object>());
Assertions.assertThat(hasNodeLeft(pid, "usertask")).isTrue();
Assertions.assertThat(hasNodeLeft(pid, "User Task")).isTrue();
Collection<VariableDesc> stackTraceHistory = getStackTrace(pid);
Collection<VariableDesc> threadNameHistory = getThreadName(pid);
System.out.println("====stackTraceHistory====");
System.out.println(stackTraceHistory);
System.out.println("====stackTraceHistoryLast====");
System.out.println(stackTraceHistory.iterator().next().getNewValue());
System.out.println("====stackTraceHistorySize====");
System.out.println(stackTraceHistory.size());
System.out.println("====threadNameHistory====");
System.out.println(threadNameHistory);
System.out.println("====threadNameHistoryLast====");
System.out.println(threadNameHistory.iterator().next().getNewValue());
// in this scenario we have to check the middle value, so it is the old one in the last history entry
Assertions.assertThat(threadNameHistory.iterator().next().getOldValue()).startsWith("EE");
}
use of org.kie.api.task.model.TaskSummary in project jbpm by kiegroup.
the class EMigrateProcessTest method testUpgradeProcessInstanceWithNodeMapping.
@Test
public void testUpgradeProcessInstanceWithNodeMapping() throws Exception {
Long processInstanceId = processService.startProcess(kieJar, EVALUATION_PROCESS_ID_V1);
if (processInstanceId != null) {
archive.getPids().add(processInstanceId);
}
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
Assertions.assertThat(tasks.size()).isEqualTo(1);
TaskSummary task = tasks.get(0);
Assertions.assertThat(tasks.get(0).getName()).isEqualTo("Evaluate items");
Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar);
Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V1);
Assertions.assertThat(task.getProcessInstanceId()).isEqualTo(processInstanceId);
Map<String, String> nodeMapping = new HashMap<String, String>();
nodeMapping.put("_4E8E7545-FB70-494E-9136-2B9ABE655889", "_56FB3E50-DEDD-415B-94DD-0357C91836B9");
// migrate process instance to evaluation 2 in container 2
MigrationReport report = migrationService.migrate(kieJar, processInstanceId, kieJar2, EVALUATION_PROCESS_ID_V2, nodeMapping);
Assertions.assertThat(report).isNotNull();
Assertions.assertThat(report.isSuccessful()).isTrue();
// migrated to Approve user task
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(USER_YODA, new QueryFilter(0, 10));
Assertions.assertThat(tasks.size()).isEqualTo(1);
task = tasks.get(0);
Assertions.assertThat(task.getName()).isEqualTo("Approve");
Assertions.assertThat(task.getDeploymentId()).isEqualTo(kieJar2);
Assertions.assertThat(task.getProcessId()).isEqualTo(EVALUATION_PROCESS_ID_V2);
Assertions.assertThat(task.getProcessInstanceId()).isEqualTo(processInstanceId);
}
Aggregations