Search in sources :

Example 11 with TaskQuery

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());
}
Also used : Filter(org.camunda.bpm.engine.filter.Filter) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) TaskQuery(org.camunda.bpm.engine.task.TaskQuery)

Example 12 with TaskQuery

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());
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery)

Example 13 with TaskQuery

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
    }
}
Also used : TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 14 with TaskQuery

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);
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with TaskQuery

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);
}
Also used : TaskQuery(org.camunda.bpm.engine.task.TaskQuery)

Aggregations

TaskQuery (org.camunda.bpm.engine.task.TaskQuery)517 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)230 Task (org.camunda.bpm.engine.task.Task)227 Test (org.junit.Test)224 Deployment (org.camunda.bpm.engine.test.Deployment)195 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)124 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)86 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)55 Filter (org.camunda.bpm.engine.filter.Filter)26 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)24 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)23 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)22 Execution (org.camunda.bpm.engine.runtime.Execution)22 Job (org.camunda.bpm.engine.runtime.Job)20 ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)17 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)15 Date (java.util.Date)12 HashMap (java.util.HashMap)12 SequenceFlow (org.camunda.bpm.model.bpmn.instance.SequenceFlow)12 CamundaExecutionListener (org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener)12