I am using JUnit 5 with some extensions, and test is running by calling bpmn, and relevant delegate expression. However, @Value variables in delegate coming as ‘null’.
Below is my code snippet,
Test Class
@SpringBootTest
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(ProcessEngineExtension.class)
@TestPropertySource(locations=“classpath:application-test.yml”)
@ActiveProfiles(“test”)
public class ProcessTest {
@Mock
EntryIDStartListener entryIDStartListener;
@Rule
public ProcessEngineRule rule = new ProcessEngineRule();
@Before
public void setUp() throws IOException {
MessageList.messages = new MessageLoader().getFileContent(new String[]{"classpath*:/requests/*.*", "classpath*:/responses/*.*"});
ReflectionTestUtils.setField(entryIDStartListener, "applicationID", "asdfadsf");
MockitoAnnotations.initMocks(this);
}
@Test
@Deployment(resources = {"bpm/NCTOFulfilment.bpmn", "bpm/PromoteCustomer.bpmn", "bpm/BusinessBC.bpmn"})
public void testFlow() throws Exception {
String message = MessageList.getMessage("flowInputRequest");
Map<String, Object> inputMap = new Gson().fromJson(message, Map.class);
String businessKey = (String) inputMap.get(Enums.KVK_NUMBER.getValue());
ProcessInstance nctoFulfilmentInstance = runtimeService().startProcessInstanceByKey("NCTOFulfilment", businessKey, inputMap);
assertThat(nctoFulfilmentInstance).isActive();
assertThat(nctoFulfilmentInstance).isStarted();
assertThat(nctoFulfilmentInstance).hasNotPassed("NCTOFulfillment_Start");
execute(job());
assertThat(nctoFulfilmentInstance)
.hasPassed("NCTOFulfillment_Start")
.hasPassed("PromoteCustomerGateway");
execute(job());
ProcessInstance promoteCustomerCallActivityInst = calledProcessInstance(nctoFulfilmentInstance);
assertThat(promoteCustomerCallActivityInst)
.isActive()
.hasPassed("PromoteCustemer_Start");
ProcessInstance businessBCCallActivityInst = calledProcessInstance(promoteCustomerCallActivityInst);
assertThat(businessBCCallActivityInst)
.isActive()
.hasPassed("BusinessBC_Start");
assertThat(businessBCCallActivityInst).isWaitingAt("EntryIDActivity");
execute(job());
assertThat(businessBCCallActivityInst).hasPassed("EntryIDActivity");
}
}
Delegate Class
@Component(“entryIDStartListener”)
@Slf4j
public class EntryIDStartListener extends AbstractNctoFulfillment {
@Value("${application.apis.soap.promote_customer.entry_id.url}")
private String url;
@Value("${application.apis.soap.static_header.applicationID}")
private String applicationID;
@Value("${application.apis.soap.static_header.sessionID}")
private String sessionID;
@Value("${application.apis.soap.static_header.userID}")
private String userID;
@Value("${application.task.retryCycle}")
private String retryCycle;
…}
Any idea what I am missing here?