// 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.toString(), 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.toString(), 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.toString(), 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)