Search in sources :

Example 31 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class AbstractTaskSerializationTest method statusInCommandSerialization.

@Test
public void statusInCommandSerialization() throws Exception {
    Assume.assumeTrue(getType().equals(TestType.JAXB));
    addClassesToSerializationContext(GetTaskAssignedAsPotentialOwnerCommand.class);
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Completed);
    statuses.add(Status.Exited);
    List<String> groupIds = new ArrayList<String>();
    groupIds.add("team");
    groupIds.add("region");
    QueryFilter filter = new QueryFilter(0, 0, "order", false);
    GetTaskAssignedAsPotentialOwnerCommand cmd = new GetTaskAssignedAsPotentialOwnerCommand("user", groupIds, statuses, filter);
    GetTaskAssignedAsPotentialOwnerCommand copyCmd = testRoundTrip(cmd);
    Assertions.assertThat(cmd).isEqualToComparingFieldByFieldRecursively(copyCmd);
}
Also used : Status(org.kie.api.task.model.Status) QueryFilter(org.kie.internal.query.QueryFilter) ArrayList(java.util.ArrayList) GetTaskAssignedAsPotentialOwnerCommand(org.jbpm.services.task.commands.GetTaskAssignedAsPotentialOwnerCommand) Test(org.junit.Test)

Example 32 with QueryFilter

use of org.kie.internal.query.QueryFilter 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 33 with QueryFilter

use of org.kie.internal.query.QueryFilter 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)

Example 34 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class EGetTaskTest method testFormName.

@Test
public void testFormName() {
    Map<String, Object> params = new HashMap<>();
    params.put("userName", "johndoe");
    Long pid = ejb.startProcess(ProcessDefinitions.HUMAN_TASK_WITH_FORM, params);
    List<Status> statusList = new ArrayList<>();
    statusList.add(Status.Reserved);
    List<TaskSummary> summaryList = ejb.getTasksByStatusByProcessInstanceId(pid, statusList, new QueryFilter(0, 1));
    Assertions.assertThat(summaryList).isNotNull().isNotEmpty();
    TaskSummary summary = summaryList.get(0);
    Task task = ejb.getTask(summary.getId());
    String formName = ((InternalTask) task).getFormName();
    Assertions.assertThat(formName).as("Expected different form name.").isEqualTo("UserNameInputTask");
}
Also used : Status(org.kie.api.task.model.Status) Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) HashMap(java.util.HashMap) InternalTask(org.kie.internal.task.api.model.InternalTask) ArrayList(java.util.ArrayList) QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Example 35 with QueryFilter

use of org.kie.internal.query.QueryFilter in project jbpm by kiegroup.

the class EGetTaskTest method testTaskQuery.

@Test
public void testTaskQuery() {
    Long pid = ejb.startProcess(ProcessDefinitions.HUMAN_TASK);
    List<TaskSummary> taskList = ejb.getTasksOwned(userId, new QueryFilter(0, 5));
    Assertions.assertThat(taskList.size()).isLessThanOrEqualTo(5);
    TaskSummary task = null;
    for (TaskSummary potentialTask : taskList) {
        System.out.println("id=" + potentialTask.getProcessInstanceId());
        if (potentialTask.getProcessInstanceId() == pid) {
            task = potentialTask;
        }
    }
    Assertions.assertThat(task).isNotNull();
    Assertions.assertThat(task.getName()).isEqualTo("Hello");
    Assertions.assertThat(task.getStatus()).isEqualTo(Status.Reserved);
    Assertions.assertThat(task.getActualOwnerId()).isEqualTo(userId);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) RemoteEjbTest(org.jbpm.remote.ejb.test.RemoteEjbTest) Test(org.junit.Test)

Aggregations

QueryFilter (org.kie.internal.query.QueryFilter)149 Test (org.junit.Test)127 TaskSummary (org.kie.api.task.model.TaskSummary)122 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)52 HashMap (java.util.HashMap)47 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)31 KModuleDeploymentServiceTest (org.jbpm.kie.services.test.KModuleDeploymentServiceTest)26 AuditTask (org.kie.internal.task.api.AuditTask)25 ArrayList (java.util.ArrayList)24 QueryContext (org.kie.api.runtime.query.QueryContext)24 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)23 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)21 Task (org.kie.api.task.model.Task)19 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)18 TaskFluent (org.jbpm.services.task.utils.TaskFluent)17 TaskEvent (org.kie.internal.task.api.model.TaskEvent)17 HumanTaskServicesBaseTest (org.jbpm.services.task.HumanTaskServicesBaseTest)14 Status (org.kie.api.task.model.Status)13 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)11 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)10