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