use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testExtendingVariableQuery.
public void testExtendingVariableQuery() {
TaskQuery taskQuery = taskService.createTaskQuery().processVariableValueEquals("hello", "world");
saveQuery(taskQuery);
// variables won't overridden variables with same name in different scopes
TaskQuery extendingQuery = taskService.createTaskQuery().taskVariableValueEquals("hello", "world").caseInstanceVariableValueEquals("hello", "world");
Filter extendedFilter = filter.extend(extendingQuery);
TaskQueryImpl extendedQuery = extendedFilter.getQuery();
List<TaskQueryVariableValue> variables = extendedQuery.getVariables();
assertEquals(3, variables.size());
// assert variables (ordering: extending variables are inserted first)
assertEquals("hello", variables.get(0).getName());
assertEquals("world", variables.get(0).getValue());
assertEquals(QueryOperator.EQUALS, variables.get(0).getOperator());
assertFalse(variables.get(0).isProcessInstanceVariable());
assertTrue(variables.get(0).isLocal());
assertEquals("hello", variables.get(1).getName());
assertEquals("world", variables.get(1).getValue());
assertEquals(QueryOperator.EQUALS, variables.get(1).getOperator());
assertFalse(variables.get(1).isProcessInstanceVariable());
assertFalse(variables.get(1).isLocal());
assertEquals("hello", variables.get(2).getName());
assertEquals("world", variables.get(2).getValue());
assertEquals(QueryOperator.EQUALS, variables.get(2).getOperator());
assertTrue(variables.get(2).isProcessInstanceVariable());
assertFalse(variables.get(2).isLocal());
// variables will override variables with same name in same scope
extendingQuery = taskService.createTaskQuery().processVariableValueLessThan("hello", 42).taskVariableValueLessThan("hello", 42).caseInstanceVariableValueLessThan("hello", 42);
extendedFilter = filter.extend(extendingQuery);
extendedQuery = extendedFilter.getQuery();
variables = extendedQuery.getVariables();
assertEquals(3, variables.size());
// assert variables (ordering: extending variables are inserted first)
assertEquals("hello", variables.get(0).getName());
assertEquals(42, variables.get(0).getValue());
assertEquals(QueryOperator.LESS_THAN, variables.get(0).getOperator());
assertTrue(variables.get(0).isProcessInstanceVariable());
assertFalse(variables.get(0).isLocal());
assertEquals("hello", variables.get(1).getName());
assertEquals(42, variables.get(1).getValue());
assertEquals(QueryOperator.LESS_THAN, variables.get(1).getOperator());
assertFalse(variables.get(1).isProcessInstanceVariable());
assertTrue(variables.get(1).isLocal());
assertEquals("hello", variables.get(2).getName());
assertEquals(42, variables.get(2).getValue());
assertEquals(QueryOperator.LESS_THAN, variables.get(2).getOperator());
assertFalse(variables.get(2).isProcessInstanceVariable());
assertFalse(variables.get(2).isLocal());
}
use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testExtendTaskQueryWithCandidateUserExpressionAndIncludeAssignedTasks.
public void testExtendTaskQueryWithCandidateUserExpressionAndIncludeAssignedTasks() {
// 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 user expression and include assigned tasks
// and save it as filter
TaskQuery query = taskService.createTaskQuery();
query.taskCandidateUserExpression("${'test'}").includeAssignedTasks();
Filter filter = filterService.newTaskFilter("filter");
filter.setQuery(query);
// extend empty query by query with candidate user expression and include assigned tasks
Filter extendedFilter = emptyFilter.extend(query);
TaskQueryImpl extendedQuery = extendedFilter.getQuery();
assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateUser"));
assertTrue(extendedQuery.isIncludeAssignedTasks());
// extend query with candidate user expression and include assigned tasks with empty query
extendedFilter = filter.extend(emptyQuery);
extendedQuery = extendedFilter.getQuery();
assertEquals("${'test'}", extendedQuery.getExpressions().get("taskCandidateUser"));
assertTrue(extendedQuery.isIncludeAssignedTasks());
}
use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.
the class FilterTaskQueryTest method testDeprecatedOrderingFormatDeserializationFunctionOrdering.
/**
* Tests compatibility with serialization format that was used in 7.2
*/
@SuppressWarnings("deprecation")
public void testDeprecatedOrderingFormatDeserializationFunctionOrdering() {
String orderingWithFunction = "LOWER(RES." + TaskQueryProperty.NAME.getName() + ") asc";
JsonTaskQueryConverter converter = (JsonTaskQueryConverter) FilterEntity.queryConverter.get(EntityTypes.TASK);
JSONObject queryJson = converter.toJsonObject(filter.<TaskQuery>getQuery());
// when I apply an ordering with a function
queryJson.put(JsonTaskQueryConverter.ORDER_BY, orderingWithFunction);
TaskQueryImpl deserializedTaskQuery = (TaskQueryImpl) converter.toObject(queryJson);
assertEquals(1, deserializedTaskQuery.getOrderingProperties().size());
// then the ordering is applied accordingly
QueryOrderingProperty orderingProperty = deserializedTaskQuery.getOrderingProperties().get(0);
assertNull(orderingProperty.getRelation());
assertEquals("asc", orderingProperty.getDirection().getName());
assertNull(orderingProperty.getRelationConditions());
assertFalse(orderingProperty.isContainedProperty());
assertEquals(TaskQueryProperty.NAME_CASE_INSENSITIVE.getName(), orderingProperty.getQueryProperty().getName());
assertEquals(TaskQueryProperty.NAME_CASE_INSENSITIVE.getFunction(), orderingProperty.getQueryProperty().getFunction());
}
use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.
the class TaskQueryTest method testExtendingTaskQueryList_ProcessDefinitionKeyIn.
public void testExtendingTaskQueryList_ProcessDefinitionKeyIn() {
// given
String processDefinitionKey = "invoice";
TaskQuery query = taskService.createTaskQuery();
TaskQuery extendingQuery = taskService.createTaskQuery().processDefinitionKeyIn(processDefinitionKey);
// when
TaskQuery result = ((TaskQueryImpl) query).extend(extendingQuery);
// then
String[] processDefinitionKeys = ((TaskQueryImpl) result).getProcessDefinitionKeys();
assertEquals(1, processDefinitionKeys.length);
assertEquals(processDefinitionKey, processDefinitionKeys[0]);
}
use of org.camunda.bpm.engine.impl.TaskQueryImpl in project camunda-bpm-platform by camunda.
the class TaskQueryTest method testExtendTaskQueryList_TaskDefinitionKeyIn.
public void testExtendTaskQueryList_TaskDefinitionKeyIn() {
// given
String taskDefinitionKey = "assigneApprover";
TaskQuery query = taskService.createTaskQuery().taskDefinitionKeyIn(taskDefinitionKey);
TaskQuery extendingQuery = taskService.createTaskQuery();
// when
TaskQuery result = ((TaskQueryImpl) query).extend(extendingQuery);
// then
String[] key = ((TaskQueryImpl) result).getKeys();
assertEquals(1, key.length);
assertEquals(taskDefinitionKey, key[0]);
}
Aggregations