Hello Everyone!
I have a problem with writing integration tests in Spring Boot application with Camunda Spring boot Starter.
I have a test, which is testing rest endpoint, the logic of this endpoint also use Process Engine
.
Next block of code had NullPointerException:
1. RuntimeService runtimeService = processEngine.getRuntimeService();
2. ProcessInstance pi = runtimeService.createProcessInstanceQuery()
3. .processInstanceBusinessKey(String.valueOf(requestId)).singleResult();
4. Execution execution = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).activityId(CONFIRM_REQUEST_CREATION).singleResult();
In this case pi
variable is NULL. So I have NPE.
My test is looks like:
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
public class RequestControllerIT extends BaseIT {
private String REQUEST_CONTROLLER_URL = "my/path/to/endpoint";
@Test
public void testMyEndpoint() {
MockHttpServletRequestBuilder request = put(REQUEST_CONTROLLER_URL)
.accept(APPLICATION_JSON_VALUE);
mockMvc.perform(request)
.andExpect(MockMvcResultMatchers.status().isOk());
}
Any ideas?