// when
VariableInstanceQuery taskVariablesQuery = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(execution.getActivityInstanceId());
VariableInstanceQuery processVariablesQuery = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(execution.getProcessInstanceId());
// then
VariableInstance taskVar = taskVariablesQuery.singleResult();
assertNotNull(taskVar);
assertEquals(1, taskVariablesQuery.count());
assertEquals("string", taskVar.getTypeName());
assertEquals("taskVariable", taskVar.getName());
assertEquals("aCustomValue", taskVar.getValue());
VariableInstance processVar = processVariablesQuery.singleResult();
assertEquals(1, processVariablesQuery.count());
assertEquals("string", processVar.getTypeName());
assertEquals("stringVar", processVar.getName());
assertEquals("test", processVar.getValue());
}