Search in sources :

Example 46 with TaskQueryImpl

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

Example 47 with TaskQueryImpl

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

Example 48 with TaskQueryImpl

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());
}
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 49 with TaskQueryImpl

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

Example 50 with TaskQueryImpl

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

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