Search in sources :

Example 41 with QueryFilter

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

the class RuntimeDataServiceImplTest method testGetTasksAssignedAsPotentialOwnerSortedByAlias.

@Test
public void testGetTasksAssignedAsPotentialOwnerSortedByAlias() {
    List<Long> processInstanceIds = new ArrayList<Long>();
    for (int i = 0; i < 10; i++) {
        processInstanceIds.add(processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument"));
    }
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Ready);
    statuses.add(Status.Reserved);
    QueryFilter ctx = new QueryFilter(0, 5, "Status", true);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", statuses, ctx);
    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) QueryFilter(org.kie.internal.query.QueryFilter) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 42 with QueryFilter

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

the class RuntimeDataServiceImplTest method testGetTaskAssignedAsBusinessAdmin.

@Test
public void testGetTaskAssignedAsBusinessAdmin() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(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());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) TaskSummary(org.kie.api.task.model.TaskSummary) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 43 with QueryFilter

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

the class RuntimeDataServiceImplTest method testGetAuditTaskByStatus.

@Test
public void testGetAuditTaskByStatus() throws Exception {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance instance = processService.getProcessInstance(processInstanceId);
    assertNotNull(instance);
    Collection<NodeInstance> activeNodes = ((WorkflowProcessInstanceImpl) instance).getNodeInstances();
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    NodeInstance node = activeNodes.iterator().next();
    assertNotNull(node);
    assertTrue(node instanceof WorkItemNodeInstance);
    Long workItemId = ((WorkItemNodeInstance) node).getWorkItemId();
    assertNotNull(workItemId);
    List<String> statuses = new ArrayList();
    statuses.add(Status.Reserved.toString());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("statuses", statuses);
    QueryFilter queryFilter = new QueryFilter();
    queryFilter.setParams(params);
    List<AuditTask> auditTasks = runtimeDataService.getAllAuditTaskByStatus("salaboy", queryFilter);
    assertNotNull(auditTasks);
    assertEquals(1, auditTasks.size());
    assertEquals("Write a Document", auditTasks.get(0).getName());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
}
Also used : HashMap(java.util.HashMap) WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) ArrayList(java.util.ArrayList) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) NodeInstance(org.kie.api.runtime.process.NodeInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 44 with QueryFilter

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

the class RuntimeDataServiceImplTest method testTasksByStatusByProcessInstanceIdPagingAndFiltering.

@Test
public void testTasksByStatusByProcessInstanceIdPagingAndFiltering() {
    Long pid = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Ready);
    statuses.add(Status.Reserved);
    List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus("salaboy", statuses, new QueryFilter(0, 5));
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    long taskId = tasks.get(0).getId();
    userTaskService.start(taskId, "salaboy");
    userTaskService.complete(taskId, "salaboy", null);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("name", "Review Document");
    QueryFilter qf = new QueryFilter("t.name = :name", params, "t.id", false);
    qf.setOffset(0);
    qf.setCount(5);
    tasks = runtimeDataService.getTasksByStatusByProcessInstanceId(pid, statuses, qf);
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    TaskSummary userTask = tasks.get(0);
    assertNotNull(userTask);
    assertEquals("Review Document", userTask.getName());
    tasks = runtimeDataService.getTasksByStatusByProcessInstanceId(pid, statuses, new QueryFilter(0, 5));
    assertNotNull(tasks);
    assertEquals(2, tasks.size());
    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) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 45 with QueryFilter

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

the class RuntimeDataServiceImplTest method testGetTaskAudit.

@Test
public void testGetTaskAudit() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance instance = processService.getProcessInstance(processInstanceId);
    assertNotNull(instance);
    Collection<NodeInstance> activeNodes = ((WorkflowProcessInstanceImpl) instance).getNodeInstances();
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    NodeInstance node = activeNodes.iterator().next();
    assertNotNull(node);
    assertTrue(node instanceof WorkItemNodeInstance);
    Long workItemId = ((WorkItemNodeInstance) node).getWorkItemId();
    assertNotNull(workItemId);
    List<AuditTask> auditTasks = runtimeDataService.getAllAuditTask("salaboy", new QueryFilter(0, 10));
    assertNotNull(auditTasks);
    assertEquals(1, auditTasks.size());
    assertEquals("Write a Document", auditTasks.get(0).getName());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) NodeInstance(org.kie.api.runtime.process.NodeInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) AuditTask(org.kie.internal.task.api.AuditTask) 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