Hello everyone (I’m new in this forum so please don’t judge me ),
To my question: Is it possible to return Java Objects (or at least Json) from the Process Engine?
I’m doing some testing on processes with Spring Boot Camunda. I need to start a process with a process variable which I set as Java Object. I want to modify this object within a Java Delegate and test afterwards that the changes were done right. I have tried it with HistoricVariableInstance but i just get the name of process variables. I don’t know how to modify this object via DelegateExecution, but HistoricVariableInstance still returns empty values. Can someone help?
@SpringBootTest(classes = ProcessApplication.class)
@TestPropertySource(locations = { "classpath:test.properties" })
public class TestJsonThroughProcessTestNG extends AbstractTestNGSpringContextTests {
@Autowired
RuntimeService runtimeService;
@Autowired
ProcessEngine processEngine;
private Record cr;
@BeforeMethod
public void setUp() {
this.mapper = new ObjectMapper();
cr = new Record();
cr.setId(Integer.valueOf(1234));
cr.setFirstName("Max");
cr.setLastName("Mustermann");
cr.setComplaintDate(Instant.now());
cr.setListOfThings(new ArrayList<String>(Arrays.asList("here", "there", "everywhere")));
}
@Test
public void testGetObject() {
ProcessInstance pi = this.runtimeService.startProcessInstanceByKey("sendResponseTest",
Variables.createVariables().putValue("Record", cr));
List<HistoricVariableInstance> variables = this.processEngine.getHistoryService()
.createHistoricVariableInstanceQuery().processInstanceId(pi.getId()).list();
}
Greetings
Alex