Hi, I can’t find an answer neither in camunda docs, nor on github.
I have integration test with autowired services, repositories, embedded db. Tasks are “mock registered”.
Somehow when I try to ger vars from processInstance in certain moments of workflow, e.g. it is waiting in one of the task, I don’t get this way the values of delegate execution variables:
VariableMap variableMap = ((ProcessInstanceWithVariablesImpl) processInstance).getVariables();
It contains everytime same two veriables like variableMap is always in one state in any moment of workflow, but I am 100% sure there should be more cause they were set.
So what is correct way to get actual variables from delegate execution in test? I think I do something wrong
@RunWith(JUnitParamsRunner.class)
@DataJpaTest
@Import(CommonTestConfig.class)
@TestPropertySource("classpath:application-test.properties")
public class CategorizedForNameMismatchTest extends BaseIntegrationTest {
@Autowired
private ReverifyDataService reverifyDataService;
//other autowired components
@Test
@Parameters({
TEMPLATE_CHARLIE_CONTACT_DATA1,
TEMPLATE_CHARLIE_CONTACT_DATA2,
})
public void testExecute(String templatePath) throws Exception {
PreLaunchCheckTask preLaunchCheckTask = new PreLaunchCheckTask();
Mocks.register("preLaunchCheckTask", preLaunchCheckTask);
ReflectionTestUtils.setField(preLaunchCheckTask, "processRepositoryService", processRepositoryService);
ReflectionTestUtils.setField(preLaunchCheckTask, "reverifyDataService", reverifyDataService);
ReflectionTestUtils.setField(preLaunchCheckTask, "preLaunchCheckService", preLaunchCheckService);
//other tasks reigstering with same approach
ProcessInstance processInstance = runtimeService().startProcessInstanceByKey("ReverifyContact", "mainProcessUUID",
Map.of(BPMProcessConfigNames.assigneeSubJobUUID.configName(), "subProcessUUID"));
assertThat(processInstance)
.isStarted()
.hasPassed("RV_STR")
.hasPassed("PROCESS_INITIATED")
.hasPassed("RV_CHK_GW")
.hasPassed("RV_CHA_1")
.isWaitingAt("RV_CHA_2");
VariableMap variableMap = ((ProcessInstanceWithVariablesImpl) processInstance).getVariables();
assertNull(variableMap.get(ProcessVariables.CharlieResponse.CHARLIE_DATA));
assertEquals(false, variableMap.get(ProcessVariables.REQUIRES_TITLE_REVIEW));
assertEquals("subProcessUUID", variableMap.get(BPMProcessConfigNames.assigneeSubJobUUID.configName()));