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());
}
}
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;
}
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;
}
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());
}
}
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;
}
Aggregations