Search in sources :

Example 41 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.

the class FilterTaskQueryTest method testExtendingSorting.

public void testExtendingSorting() {
    // create empty query
    TaskQueryImpl query = (TaskQueryImpl) taskService.createTaskQuery();
    saveQuery(query);
    // assert default sorting
    query = filter.getQuery();
    assertTrue(query.getOrderingProperties().isEmpty());
    // extend query by new task query with sorting
    TaskQueryImpl sortQuery = (TaskQueryImpl) taskService.createTaskQuery().orderByTaskName().asc();
    Filter extendedFilter = filter.extend(sortQuery);
    query = extendedFilter.getQuery();
    List<QueryOrderingProperty> expectedOrderingProperties = new ArrayList<QueryOrderingProperty>(sortQuery.getOrderingProperties());
    verifyOrderingProperties(expectedOrderingProperties, query.getOrderingProperties());
    // extend query by new task query with additional sorting
    TaskQueryImpl extendingQuery = (TaskQueryImpl) taskService.createTaskQuery().orderByTaskAssignee().desc();
    extendedFilter = extendedFilter.extend(extendingQuery);
    query = extendedFilter.getQuery();
    expectedOrderingProperties.addAll(extendingQuery.getOrderingProperties());
    verifyOrderingProperties(expectedOrderingProperties, query.getOrderingProperties());
    // extend query by incomplete sorting query (should add sorting anyway)
    sortQuery = (TaskQueryImpl) taskService.createTaskQuery().orderByCaseExecutionId();
    extendedFilter = extendedFilter.extend(sortQuery);
    query = extendedFilter.getQuery();
    expectedOrderingProperties.addAll(sortQuery.getOrderingProperties());
    verifyOrderingProperties(expectedOrderingProperties, query.getOrderingProperties());
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter) ArrayList(java.util.ArrayList) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty)

Example 42 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.

the class FilterTaskQueryTest method testTaskQueryWithCandidateGroupInAndCandidateGroupExpression.

public void testTaskQueryWithCandidateGroupInAndCandidateGroupExpression() {
    // create an query with candidate group in and candidate group expression
    TaskQueryImpl candidateGroupInQuery = (TaskQueryImpl) taskService.createTaskQuery().taskCandidateGroupIn(Arrays.asList("testGroup", "testGroup2")).taskCandidateGroupExpression("${'test'}");
    assertEquals("${'test'}", candidateGroupInQuery.getExpressions().get("taskCandidateGroup"));
    assertEquals(2, candidateGroupInQuery.getCandidateGroups().size());
    assertEquals("testGroup", candidateGroupInQuery.getCandidateGroups().get(0));
    assertEquals("testGroup2", candidateGroupInQuery.getCandidateGroups().get(1));
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl)

Example 43 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.

the class FilterTaskQueryTest method testExtendTaskQueryWithCandidateGroupInExpressionAndIncludeAssignedTasks.

public void testExtendTaskQueryWithCandidateGroupInExpressionAndIncludeAssignedTasks() {
    // 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 in expression and include assigned tasks
    // and save it as filter
    TaskQuery query = taskService.createTaskQuery();
    query.taskCandidateGroupInExpression("${'test'}").includeAssignedTasks();
    Filter filter = filterService.newTaskFilter("filter");
    filter.setQuery(query);
    // extend empty query by query with candidate group in expression and include assigned tasks
    Filter extendedFilter = emptyFilter.extend(query);
    TaskQueryImpl extendedQuery = extendedFilter.getQuery();
    assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateGroupIn"));
    assertTrue(extendedQuery.isIncludeAssignedTasks());
    // extend query with candidate group in expression and include assigned tasks with empty query
    extendedFilter = filter.extend(emptyQuery);
    extendedQuery = extendedFilter.getQuery();
    assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateGroupIn"));
    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 44 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.

the class FilterTaskQueryTest method testTaskQueryCandidateUserIncludeAssignedTasks.

public void testTaskQueryCandidateUserIncludeAssignedTasks() {
    TaskQueryImpl query = new TaskQueryImpl();
    query.taskCandidateUser(testUser.getId());
    query.includeAssignedTasks();
    saveQuery(query);
    query = filterService.getFilter(filter.getId()).getQuery();
    assertEquals(testUser.getId(), query.getCandidateUser());
    assertTrue(query.isIncludeAssignedTasks());
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl)

Example 45 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.

the class FilterTaskQueryTest method testTaskQueryCandidateGroupExpressionIncludeAssignedTasks.

public void testTaskQueryCandidateGroupExpressionIncludeAssignedTasks() {
    TaskQueryImpl query = new TaskQueryImpl();
    query.taskCandidateGroupExpression(testString);
    query.includeAssignedTasks();
    saveQuery(query);
    query = filterService.getFilter(filter.getId()).getQuery();
    assertEquals(testString, query.getExpressions().get("taskCandidateGroup"));
    assertTrue(query.isIncludeAssignedTasks());
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl)

Aggregations

TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)60 Filter (org.camunda.bpm.engine.filter.Filter)26 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)25 Test (org.junit.Test)17 FilterEntity (org.camunda.bpm.engine.impl.persistence.entity.FilterEntity)12 MockProvider.mockFilter (org.camunda.bpm.engine.rest.helper.MockProvider.mockFilter)12 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)8 Map (java.util.Map)7 Response (com.jayway.restassured.response.Response)6 HashMap (java.util.HashMap)6 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)6 Matchers.anyString (org.mockito.Matchers.anyString)6 JSONObject (org.camunda.bpm.engine.impl.util.json.JSONObject)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Date (java.util.Date)3 TaskQueryVariableValue (org.camunda.bpm.engine.impl.TaskQueryVariableValue)3 JsonTaskQueryConverter (org.camunda.bpm.engine.impl.json.JsonTaskQueryConverter)3 ArrayList (java.util.ArrayList)2 JSONArray (org.camunda.bpm.engine.impl.util.json.JSONArray)2 VariableQueryParameterDto (org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)2