Search in sources :

Example 11 with TaskQueryImpl

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

the class FilterTaskQueryTest method testDeprecatedOrderingFormatDeserializationSecondaryOrdering.

/**
 * Tests compatibility with serialization format that was used in 7.2
 */
@SuppressWarnings("deprecation")
public void testDeprecatedOrderingFormatDeserializationSecondaryOrdering() {
    String sortByNameAsc = "RES." + TaskQueryProperty.NAME.getName() + " " + Direction.ASCENDING.getName();
    String secondaryOrdering = sortByNameAsc + ", RES." + TaskQueryProperty.ASSIGNEE.getName() + " " + Direction.DESCENDING.getName();
    JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK);
    JSONObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery());
    // when I apply a secondary ordering
    queryJson.put(JsonTaskQueryConverter.ORDER_BY, secondaryOrdering);
    TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson);
    // then the ordering is applied accordingly
    assertEquals(2, deserializedTaskQuery.getOrderingProperties().size());
    QueryOrderingProperty orderingProperty1 = deserializedTaskQuery.getOrderingProperties().get(0);
    assertNull(orderingProperty1.getRelation());
    assertEquals("asc", orderingProperty1.getDirection().getName());
    assertNull(orderingProperty1.getRelationConditions());
    assertTrue(orderingProperty1.isContainedProperty());
    assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty1.getQueryProperty().getName());
    assertNull(orderingProperty1.getQueryProperty().getFunction());
    QueryOrderingProperty orderingProperty2 = deserializedTaskQuery.getOrderingProperties().get(1);
    assertNull(orderingProperty2.getRelation());
    assertEquals("desc", orderingProperty2.getDirection().getName());
    assertNull(orderingProperty2.getRelationConditions());
    assertTrue(orderingProperty2.isContainedProperty());
    assertEquals(TaskQueryProperty.ASSIGNEE.getName(), orderingProperty2.getQueryProperty().getName());
    assertNull(orderingProperty2.getQueryProperty().getFunction());
}
Also used : JsonTaskQueryConverter(org.camunda.bpm.engine.impl.json.JsonTaskQueryConverter) JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty)

Example 12 with TaskQueryImpl

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

the class FilterTaskQueryTest method testTaskQueryByBusinessKeyLikeExpression.

public void testTaskQueryByBusinessKeyLikeExpression() {
    // given
    String aBusinessKey = "business key";
    Mocks.register("aBusinessKeyLike", "%" + aBusinessKey.substring(5));
    createDeploymentWithBusinessKey(aBusinessKey);
    // when
    TaskQueryImpl extendedQuery = (TaskQueryImpl) taskService.createTaskQuery().processInstanceBusinessKeyLikeExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }");
    Filter filter = filterService.newTaskFilter("aFilterName");
    filter.setQuery(extendedQuery);
    filterService.saveFilter(filter);
    TaskQueryImpl filterQuery = filterService.getFilter(filter.getId()).getQuery();
    // then
    assertEquals(extendedQuery.getExpressions().get("processInstanceBusinessKeyLike"), filterQuery.getExpressions().get("processInstanceBusinessKeyLike"));
    assertEquals(1, filterService.list(filter.getId()).size());
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) Filter(org.camunda.bpm.engine.filter.Filter)

Example 13 with TaskQueryImpl

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

the class FilterTaskQueryTest method testTaskQueryByFollowUpBeforeOrNotExistentExpression.

public void testTaskQueryByFollowUpBeforeOrNotExistentExpression() {
    // create query
    TaskQueryImpl query = new TaskQueryImpl();
    query.followUpBeforeOrNotExistentExpression(testString);
    // save filter
    filter.setQuery(query);
    filterService.saveFilter(filter);
    // fetch from db
    filter = filterService.createTaskFilterQuery().singleResult();
    // test query
    query = filter.getQuery();
    assertTrue(query.isFollowUpNullAccepted());
    assertEquals(testString, query.getExpressions().get("followUpBeforeOrNotExistent"));
}
Also used : TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl)

Example 14 with TaskQueryImpl

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

the class FilterTaskQueryTest method testDeprecatedOrderingFormatDeserializationSingleOrdering.

/**
 * Tests compatibility with serialization format that was used in 7.2
 */
@SuppressWarnings("deprecation")
public void testDeprecatedOrderingFormatDeserializationSingleOrdering() {
    String sortByNameAsc = "RES." + TaskQueryProperty.NAME.getName() + " " + Direction.ASCENDING.getName();
    JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK);
    JSONObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery());
    // when I apply a specific ordering by one dimension
    queryJson.put(JsonTaskQueryConverter.ORDER_BY, sortByNameAsc);
    TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson);
    // then the ordering is applied accordingly
    assertEquals(1, deserializedTaskQuery.getOrderingProperties().size());
    QueryOrderingProperty orderingProperty = deserializedTaskQuery.getOrderingProperties().get(0);
    assertNull(orderingProperty.getRelation());
    assertEquals("asc", orderingProperty.getDirection().getName());
    assertNull(orderingProperty.getRelationConditions());
    assertTrue(orderingProperty.isContainedProperty());
    assertEquals(TaskQueryProperty.NAME.getName(), orderingProperty.getQueryProperty().getName());
    assertNull(orderingProperty.getQueryProperty().getFunction());
}
Also used : JsonTaskQueryConverter(org.camunda.bpm.engine.impl.json.JsonTaskQueryConverter) JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) QueryOrderingProperty(org.camunda.bpm.engine.impl.QueryOrderingProperty)

Example 15 with TaskQueryImpl

use of org.camunda.bpm.engine.impl.TaskQueryImpl 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)

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