Search in sources :

Example 36 with QueryFilter

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

the class EGetTaskTest method testTaskQueryWithPageSize.

@Test()
public void testTaskQueryWithPageSize() {
    startProcess(ProcessDefinitions.HUMAN_TASK, 5);
    List<TaskSummary> ts = ejb.getTasksAssignedAsPotentialOwner(userId, new QueryFilter(0, 2));
    Assertions.assertThat(ts.size()).isEqualTo(2);
}
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)

Example 37 with QueryFilter

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

the class ETransactionTest method startAndCompleteHumanTask.

private List<TaskSummary> startAndCompleteHumanTask(Long processInstanceId) {
    List<TaskSummary> taskSummaries = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
    Assertions.assertThat(taskSummaries).isNotNull().hasSize(1);
    long taskId = taskSummaries.get(0).getId();
    userTaskService.start(taskId, "john");
    userTaskService.complete(taskId, "john", new HashMap<String, Object>());
    Assertions.assertThat(hasNodeLeft(processInstanceId, "User Task")).isTrue();
    Assertions.assertThat(hasTaskCompleted(taskId));
    return taskSummaries;
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary)

Example 38 with QueryFilter

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

the class ETaskQueryFilterTest method testAscendingOrder.

@Test
public void testAscendingOrder() {
    startHumanTaskProcess(3, "john's task", "john");
    List<TaskSummary> taskList = ejb.getTasksAssignedAsPotentialOwner("john", null, null, new QueryFilter(0, 0, "t.name", true));
    logger.info("### Potential owner task list: " + taskList);
    Assertions.assertThat(taskList).hasSize(3);
    for (int i = 0; i < taskList.size(); i++) {
        logger.info("### Task Name: " + taskList.get(i).getName());
        Assertions.assertThat(taskList.get(i).getName()).isEqualTo("john's task " + (i + 1));
    }
}
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)

Example 39 with QueryFilter

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

the class ETaskQueryFilterTest method testMaxResults.

@Test
public void testMaxResults() {
    startHumanTaskProcess(4, "john's task", "john");
    List<TaskSummary> taskList = ejb.getTasksAssignedAsPotentialOwner("john", null, null, new QueryFilter(0, 2, "t.id", true));
    logger.info("### Potential owner task list: " + taskList);
    Assertions.assertThat(taskList).hasSize(2);
    taskList = ejb.getTasksOwned("john", new QueryFilter(0, 1, null, "en-UK", null));
    logger.info("### Owned task list: " + taskList);
    Assertions.assertThat(taskList.size()).isEqualTo(1);
}
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)

Example 40 with QueryFilter

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

the class RuntimeDataServiceImplTest method testGetTasksByVariable.

@Test
public void testGetTasksByVariable() {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("approval_document", "initial content");
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
    assertNotNull(processInstanceId);
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Ready);
    statuses.add(Status.Reserved);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", statuses, new QueryFilter());
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    String userId = "salaboy";
    String varName = "Comment";
    List<TaskSummary> tasksByVariable = runtimeDataService.getTasksByVariable(userId, varName, statuses, new QueryContext());
    assertNotNull(tasksByVariable);
    assertEquals(1, tasksByVariable.size());
    varName = "ReviewComment";
    tasksByVariable = runtimeDataService.getTasksByVariable(userId, varName, statuses, new QueryContext());
    assertNotNull(tasksByVariable);
    assertEquals(0, tasksByVariable.size());
    long taskId = tasks.get(0).getId();
    Map<String, Object> output = new HashMap<String, Object>();
    output.put("ReviewComment", "document reviewed");
    userTaskService.saveContent(taskId, output);
    tasksByVariable = runtimeDataService.getTasksByVariable(userId, varName, statuses, new QueryContext());
    assertNotNull(tasksByVariable);
    assertEquals(1, tasksByVariable.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
}
Also used : Status(org.kie.api.task.model.Status) QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) 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