@Deployment(resources={"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testQueryShortVariable(){
  Map<String,Object> vars=new HashMap<String,Object>();
  short shortVar=1234;
  vars.put("shortVar",shortVar);
  ProcessInstance processInstance1=runtimeService.startProcessInstanceByKey("oneTaskProcess",vars);
  short shortVar2=6789;
  vars=new HashMap<String,Object>();
  vars.put("shortVar",shortVar);
  vars.put("shortVar2",shortVar2);
  ProcessInstance processInstance2=runtimeService.startProcessInstanceByKey("oneTaskProcess",vars);
  vars=new HashMap<String,Object>();
  vars.put("shortVar",(short)5555);
  ProcessInstance processInstance3=runtimeService.startProcessInstanceByKey("oneTaskProcess",vars);
  ExecutionQuery query=runtimeService.createExecutionQuery().variableValueEquals("shortVar",shortVar);
  List<Execution> executions=query.list();
  assertNotNull(executions);
  assertEquals(2,executions.size());
  query=runtimeService.createExecutionQuery().variableValueEquals("shortVar",shortVar).variableValueEquals("shortVar2",shortVar2);
  Execution execution=query.singleResult();
  assertNotNull(execution);
  assertEquals(processInstance2.getId(),execution.getId());
  short unexistingValue=(short)9999;
  execution=runtimeService.createExecutionQuery().variableValueEquals("shortVar",unexistingValue).singleResult();
  assertNull(execution);
  execution=runtimeService.createExecutionQuery().variableValueNotEquals("shortVar",(short)1234).singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(),execution.getId());
  execution=runtimeService.createExecutionQuery().variableValueGreaterThan("shortVar",(short)4444).singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(),execution.getId());
  assertEquals(0,runtimeService.createExecutionQuery().variableValueGreaterThan("shortVar",(short)5555).count());
  assertEquals(3,runtimeService.createExecutionQuery().variableValueGreaterThan("shortVar",(short)1).count());
  execution=runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("shortVar",(short)4444).singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(),execution.getId());
  execution=runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("shortVar",(short)5555).singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(),execution.getId());
  assertEquals(3,runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("shortVar",(short)1).count());
  executions=runtimeService.createExecutionQuery().variableValueLessThan("shortVar",(short)5555).list();
  assertEquals(2,executions.size());
  List<String> expectedIds=Arrays.asList(processInstance1.getId(),processInstance2.getId());
  List<String> ids=new ArrayList<String>(Arrays.asList(executions.get(0).getId(),executions.get(1).getId()));
  ids.removeAll(expectedIds);
  assertTrue(ids.isEmpty());
  assertEquals(0,runtimeService.createExecutionQuery().variableValueLessThan("shortVar",(short)1234).count());
  assertEquals(3,runtimeService.createExecutionQuery().variableValueLessThan("shortVar",(short)6666).count());
  executions=runtimeService.createExecutionQuery().variableValueLessThanOrEqual("shortVar",(short)5555).list();
  assertEquals(3,executions.size());
  assertEquals(0,runtimeService.createExecutionQuery().variableValueLessThanOrEqual("shortVar",(short)1233).count());
  execution=runtimeService.createExecutionQuery().variableValueEquals((short)5555).singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(),execution.getId());
  executions=runtimeService.createExecutionQuery().variableValueEquals((short)1234).list();
  assertEquals(2,executions.size());
  expectedIds=Arrays.asList(processInstance1.getId(),processInstance2.getId());
  ids=new ArrayList<String>(Arrays.asList(executions.get(0).getId(),executions.get(1).getId()));
  ids.removeAll(expectedIds);
  assertTrue(ids.isEmpty());
  execution=runtimeService.createExecutionQuery().variableValueEquals((short)999).singleResult();
  assertNull(execution);
  runtimeService.deleteProcessInstance(processInstance1.getId(),"test");
  runtimeService.deleteProcessInstance(processInstance2.getId(),"test");
  runtimeService.deleteProcessInstance(processInstance3.getId(),"test");
}
