@Deployment public void testHistoricTaskInstanceQueryTaskVariableValueEquals() throws Exception {
  ProcessInstance processInstance=runtimeService.startProcessInstanceByKey("HistoricTaskInstanceTest");
  Task task=taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
  Map<String,Object> variables=new HashMap<String,Object>();
  variables.put("longVar",12345L);
  variables.put("shortVar",(short)123);
  variables.put("integerVar",1234);
  variables.put("stringVar","stringValue");
  variables.put("booleanVar",true);
  Date date=Calendar.getInstance().getTime();
  variables.put("dateVar",date);
  variables.put("nullVar",null);
  taskService.setVariablesLocal(task.getId(),variables);
  assertEquals(7,historyService.createHistoricDetailQuery().variableUpdates().taskId(task.getId()).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("longVar",12345L).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("shortVar",(short)123).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("integerVar",1234).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("stringVar","stringValue").count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("booleanVar",true).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("dateVar",date).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("nullVar",null).count());
  variables.put("longVar",67890L);
  variables.put("shortVar",(short)456);
  variables.put("integerVar",5678);
  variables.put("stringVar","updatedStringValue");
  variables.put("booleanVar",false);
  Calendar otherCal=Calendar.getInstance();
  otherCal.add(Calendar.DAY_OF_MONTH,1);
  Date otherDate=otherCal.getTime();
  variables.put("dateVar",otherDate);
  variables.put("nullVar",null);
  taskService.setVariablesLocal(task.getId(),variables);
  assertEquals(14,historyService.createHistoricDetailQuery().variableUpdates().taskId(task.getId()).count());
  assertEquals(0,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("longVar",12345L).count());
  assertEquals(0,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("shortVar",(short)123).count());
  assertEquals(0,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("integerVar",1234).count());
  assertEquals(0,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("stringVar","stringValue").count());
  assertEquals(0,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("booleanVar",true).count());
  assertEquals(0,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("dateVar",date).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("longVar",67890L).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("shortVar",(short)456).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("integerVar",5678).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("stringVar","updatedStringValue").count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("booleanVar",false).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("dateVar",otherDate).count());
  assertEquals(1,historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("nullVar",null).count());
}
