use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testExtendTaskQueryWithCandidateGroupExpressionAndIncludeAssignedTasks.
public void testExtendTaskQueryWithCandidateGroupExpressionAndIncludeAssignedTasks() {
// create an empty query and save it as a filter
TaskQuery emptyQuery = taskService.createTaskQuery();
Filter emptyFilter = filterService.newTaskFilter("empty");
emptyFilter.setQuery(emptyQuery);
// create a query with candidate group expression and include assigned tasks
// and save it as filter
TaskQuery query = taskService.createTaskQuery();
query.taskCandidateGroupExpression("${'test'}").includeAssignedTasks();
Filter filter = filterService.newTaskFilter("filter");
filter.setQuery(query);
// extend empty query by query with candidate group expression and include assigned tasks
Filter extendedFilter = emptyFilter.extend(query);
TaskQueryImpl extendedQuery = extendedFilter.getQuery();
assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateGroup"));
assertTrue(extendedQuery.isIncludeAssignedTasks());
// extend query with candidate group expression and include assigned tasks with empty query
extendedFilter = filter.extend(emptyQuery);
extendedQuery = extendedFilter.getQuery();
assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateGroup"));
assertTrue(extendedQuery.isIncludeAssignedTasks());
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testExecuteTaskQueryListPage.
public void testExecuteTaskQueryListPage() {
TaskQuery query = taskService.createTaskQuery();
query.taskNameLike("Task%");
saveQuery(query);
List<Task> tasks = filterService.listPage(filter.getId(), 1, 2);
assertEquals(2, tasks.size());
for (Task task : tasks) {
assertEquals(testUser.getId(), task.getOwner());
}
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testFailTaskQuerySingleResult.
public void testFailTaskQuerySingleResult() {
TaskQuery query = taskService.createTaskQuery();
saveQuery(query);
try {
filterService.singleResult(filter.getId());
fail("Exception expected");
} catch (ProcessEngineException e) {
// expected
}
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testExtendTaskQueryByOrderByProcessVariable.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testExtendTaskQueryByOrderByProcessVariable() {
ProcessInstance instance500 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", 500));
ProcessInstance instance1000 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", 1000));
ProcessInstance instance250 = runtimeService.startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValue("var", 250));
TaskQuery query = taskService.createTaskQuery().processDefinitionKey("oneTaskProcess");
saveQuery(query);
// asc
TaskQuery extendingQuery = taskService.createTaskQuery().orderByProcessVariable("var", ValueType.INTEGER).asc();
List<Task> tasks = filterService.list(filter.getId(), extendingQuery);
assertEquals(3, tasks.size());
assertEquals(instance250.getId(), tasks.get(0).getProcessInstanceId());
assertEquals(instance500.getId(), tasks.get(1).getProcessInstanceId());
assertEquals(instance1000.getId(), tasks.get(2).getProcessInstanceId());
// desc
extendingQuery = taskService.createTaskQuery().orderByProcessVariable("var", ValueType.INTEGER).desc();
tasks = filterService.list(filter.getId(), extendingQuery);
assertEquals(3, tasks.size());
assertEquals(instance1000.getId(), tasks.get(0).getProcessInstanceId());
assertEquals(instance500.getId(), tasks.get(1).getProcessInstanceId());
assertEquals(instance250.getId(), tasks.get(2).getProcessInstanceId());
runtimeService.deleteProcessInstance(instance250.getId(), null);
runtimeService.deleteProcessInstance(instance500.getId(), null);
runtimeService.deleteProcessInstance(instance1000.getId(), null);
}
use of org.camunda.bpm.engine.task.TaskQuery in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testExecuteTaskQueryCount.
public void testExecuteTaskQueryCount() {
TaskQuery query = taskService.createTaskQuery();
saveQuery(query);
long count = filterService.count(filter.getId());
assertEquals(3, count);
query.taskDelegationState(DelegationState.RESOLVED);
saveQuery(query);
count = filterService.count(filter.getId());
assertEquals(2, count);
}
Aggregations