variables.put("var1", "test");
variables.put("var2", "test");
Task task = taskService.newTask();
taskService.saveTask(task);
taskService.setVariablesLocal(task.getId(), variables);
VariableInstance result = runtimeService.createVariableInstanceQuery().variableName("var1").singleResult();
assertNotNull(result);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().variableId(result.getId());
// then
assertNotNull(query);
VariableInstance resultById = query.singleResult();
assertEquals(result.getId(), resultById.getId());
// delete task
taskService.deleteTask(task.getId(), true);
}