Search in sources :

Example 71 with QueryFilter

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

the class HumanTaskQueryFilterTest method testDescendingOrder.

@Test
public void testDescendingOrder() {
    startHumanTaskProcess(3, "john's task", "john");
    List<TaskSummary> taskList = taskService.getTasksAssignedAsPotentialOwner("john", null, null, new QueryFilter(0, 0, "t.name", false));
    logger.debug("### Potential owner task list: " + taskList);
    Assertions.assertThat(taskList).hasSize(3);
    for (int i = 0; i < taskList.size(); i++) {
        logger.debug("### Task Name: " + taskList.get(i).getName());
        Assertions.assertThat(taskList.get(i).getName()).isEqualTo("john's task " + (3 - i));
    }
    abortHumanTaskProcess(3);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) Test(org.junit.Test)

Example 72 with QueryFilter

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

the class HumanTaskQueryFilterTest method testSingleResult.

@Test
@BZ("1132145")
public void testSingleResult() {
    startHumanTaskProcess(4, "john's task", "john");
    List<TaskSummary> taskList = taskService.getTasksAssignedAsPotentialOwner("john", null, null, new QueryFilter(0, 0));
    logger.debug("### Potential owner task list: " + taskList);
    Assertions.assertThat(taskList).hasSize(1);
    abortHumanTaskProcess(4);
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 73 with QueryFilter

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

the class RuntimeDataServiceEJBIntegrationTest method testGetTaskAssignedAsBusinessAdmin.

@Test
public void testGetTaskAssignedAsBusinessAdmin() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    processService.getProcessInstance(processInstanceId);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsBusinessAdministrator("Administrator", new QueryFilter(0, 5));
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    TaskSummary userTask = tasks.get(0);
    assertNotNull(userTask);
    assertEquals(processInstanceId, userTask.getProcessInstanceId());
    assertEquals("Write a Document", userTask.getName());
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) Test(org.junit.Test)

Example 74 with QueryFilter

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

the class RuntimeDataServiceEJBIntegrationTest method testGetTasksAssignedAsPotentialOwnerByStatusPagingAndFiltering.

@Test
public void testGetTasksAssignedAsPotentialOwnerByStatusPagingAndFiltering() {
    List<Long> processInstanceIds = new ArrayList<Long>();
    for (int i = 0; i < 10; i++) {
        processInstanceIds.add(processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument"));
    }
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("processInstanceId", processInstanceIds);
    QueryFilter qf = new QueryFilter("t.taskData.processInstanceId in (:processInstanceId)", params, "t.id", false);
    qf.setOffset(0);
    qf.setCount(5);
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Ready);
    statuses.add(Status.Reserved);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", statuses, qf);
    assertNotNull(tasks);
    assertEquals(5, tasks.size());
    TaskSummary userTask = tasks.get(0);
    assertNotNull(userTask);
    assertEquals("Write a Document", userTask.getName());
    Collection<ProcessInstanceDesc> activeProcesses = runtimeDataService.getProcessInstances(new QueryContext(0, 20));
    for (ProcessInstanceDesc pi : activeProcesses) {
        processService.abortProcessInstance(pi.getId());
    }
}
Also used : Status(org.kie.api.task.model.Status) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) Test(org.junit.Test)

Example 75 with QueryFilter

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

the class ClientProcessServiceWithCustomDataEJBTest method testStartProcessWithCustomData.

@Test
public void testStartProcessWithCustomData() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    Map<String, Object> parameters = new RemoteMap();
    Object person = getInstance("org.jbpm.test.Person", new Object[] { "john", 25, true });
    parameters.put("person", person);
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "custom-data-project.work-on-custom-data", parameters);
    assertNotNull(processInstanceId);
    List<TaskSummary> taskSummaries = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter(0, 10));
    assertNotNull(taskSummaries);
    assertEquals(1, taskSummaries.size());
    List<Long> tasks = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    Long taskId = tasks.get(0);
    userTaskService.start(taskId, "john");
    Map<String, Object> data = userTaskService.getTaskInputContentByTaskId(taskId);
    assertNotNull(data);
    Object fromTaskPerson = data.get("_person");
    assertNotNull(fromTaskPerson);
    assertEquals("john", getFieldValue(fromTaskPerson, "name"));
    setFieldValue(fromTaskPerson, "name", "John Doe");
    RemoteMap outcome = new RemoteMap();
    outcome.put("person_", fromTaskPerson);
    userTaskService.complete(taskId, "john", outcome);
    ProcessInstanceDesc desc = runtimeDataService.getProcessInstanceById(processInstanceId);
    assertNotNull(desc);
    assertEquals(2, (int) desc.getState());
    processInstanceId = null;
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) RemoteMap(org.jbpm.services.ejb.remote.api.RemoteMap) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) 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