The following test sends a value object (Person) to a process that simply adds some tracking data for demonstration.
I had the same problem to get a value object after executing the service in order to do some validation in my test.
The following code snippet shows the execution and collection of a varaible task after completion of execution.
@Test public void justATest() { Map<String, Object> inVariables = new HashMap<String, Object>(); Person person = new Person(); person.setName("Jens"); inVariables.put("person", person); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("event01", inVariables); String processDefinitionId = processInstance.getProcessDefinitionId(); String id = processInstance.getId(); System.out.println("id " + id + " " + processDefinitionId); List<HistoricVariableInstance> outVariables = historyService.createHistoricVariableInstanceQuery().processInstanceId(id).list(); for (HistoricVariableInstance historicVariableInstance : outVariables) { String variableName = historicVariableInstance.getVariableName(); System.out.println(variableName); Person person1 = (Person) historicVariableInstance.getValue(); System.out.println(person1.toString()); } }
source share