Search in sources :

Example 96 with TaskSummary

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);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) CorrelationAwareProcessRuntime(org.kie.internal.process.CorrelationAwareProcessRuntime) TaskService(org.kie.api.task.TaskService) TaskSummary(org.kie.api.task.model.TaskSummary) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test)

Example 97 with TaskSummary

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);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) CorrelationAwareProcessRuntime(org.kie.internal.process.CorrelationAwareProcessRuntime) TaskService(org.kie.api.task.TaskService) TaskSummary(org.kie.api.task.model.TaskSummary) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test)

Example 98 with TaskSummary

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());
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) HashMap(java.util.HashMap) TaskService(org.kie.api.task.TaskService) TaskSummary(org.kie.api.task.model.TaskSummary) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test)

Example 99 with TaskSummary

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");
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) VariableDesc(org.jbpm.services.api.model.VariableDesc) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest) Test(org.junit.Test)

Example 100 with TaskSummary

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);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary) MigrationReport(org.jbpm.services.api.admin.MigrationReport) Test(org.junit.Test) AbstractRuntimeEJBServicesTest(org.jbpm.test.container.AbstractRuntimeEJBServicesTest)

Aggregations

TaskSummary (org.kie.api.task.model.TaskSummary)371 Test (org.junit.Test)327 HashMap (java.util.HashMap)132 QueryFilter (org.kie.internal.query.QueryFilter)126 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)100 Task (org.kie.api.task.model.Task)91 ArrayList (java.util.ArrayList)87 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)86 KieSession (org.kie.api.runtime.KieSession)84 TaskService (org.kie.api.task.TaskService)66 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)58 StringReader (java.io.StringReader)55 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)49 QueryContext (org.kie.api.runtime.query.QueryContext)49 Status (org.kie.api.task.model.Status)47 InternalTask (org.kie.internal.task.api.model.InternalTask)47 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)41 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)38 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)36 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)28