Assert.assertNotNull(executions);
Assert.assertEquals(2, executions.size());
// Query on two short variables, should result in single value
query = runtimeService.createExecutionQuery().variableValueEquals("shortVar", shortVar).variableValueEquals("shortVar2", shortVar2);
Execution execution = query.singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance2.getId(), execution.getId());
// Query with unexisting variable value
short unexistingValue = (short)9999;
execution = runtimeService.createExecutionQuery().variableValueEquals("shortVar", unexistingValue).singleResult();
Assert.assertNull(execution);
// Test NOT_EQUALS
execution = runtimeService.createExecutionQuery().variableValueNotEquals("shortVar", (short)1234).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
// Test GREATER_THAN
execution = runtimeService.createExecutionQuery().variableValueGreaterThan("shortVar", (short)4444).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueGreaterThan("shortVar", (short)5555).count());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThan("shortVar",(short)1).count());
// Test GREATER_THAN_OR_EQUAL
execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("shortVar", (short)4444).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
execution = runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("shortVar", (short)5555).singleResult();
Assert.assertNotNull(execution);
Assert.assertEquals(processInstance3.getId(), execution.getId());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("shortVar",(short)1).count());
// Test LESS_THAN
executions = runtimeService.createExecutionQuery().variableValueLessThan("shortVar", (short)5555).list();
Assert.assertEquals(2, executions.size());
List<String> expecedIds = Arrays.asList(processInstance1.getId(), processInstance2.getId());
List<String> ids = new ArrayList<String>(Arrays.asList(executions.get(0).getId(), executions.get(1).getId()));
ids.removeAll(expecedIds);
assertTrue(ids.isEmpty());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThan("shortVar", (short)1234).count());
Assert.assertEquals(3, runtimeService.createExecutionQuery().variableValueLessThan("shortVar",(short)6666).count());
// Test LESS_THAN_OR_EQUAL
executions = runtimeService.createExecutionQuery().variableValueLessThanOrEqual("shortVar", (short)5555).list();
Assert.assertEquals(3, executions.size());
Assert.assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThanOrEqual("shortVar", (short)1233).count());
// Test value-only matching
execution = runtimeService.createExecutionQuery().variableValueEquals((short)5555).singleResult();
assertNotNull(execution);
assertEquals(processInstance3.getId(), execution.getId());
executions = runtimeService.createExecutionQuery().variableValueEquals((short)1234).list();
Assert.assertEquals(2, executions.size());
expecedIds = Arrays.asList(processInstance1.getId(), processInstance2.getId());
ids = new ArrayList<String>(Arrays.asList(executions.get(0).getId(), executions.get(1).getId()));