Error in task3 service complete test Command ‘COMPLETE’ rejected with code ‘NOT_FOUND’: Expected to complete job with key ‘2251799813685286’, but no such job was found
@Test
public void task3ServiceCompleteTest() throws Exception {
try {
task3ServiceConfiguration.TASK3_DELEGATE_SERVICE_API = "/example/callback";
Map<String, Object> variables = new HashMap<>();
Task3DelegateServiceResponseModel expectedResponse = new Task3DelegateServiceResponseModel(Constant.SUCCESS,
"Task3 Delegate Service is completed");
mockTask3DelegateServiceApi(expectedResponse);
// Variables for the testing failure of task2 service
variables.put("name", "HappyProcess");
variables.put("taskToFail", "Task4");
// start a process instance
ProcessInstanceEvent processInstance = startProcessInstance(variables);
assertThat(processInstance).isActive();
Thread.sleep(5000);
BpmnAssert.assertThat(processInstance).hasNoIncidents();
BpmnAssert.assertThat(processInstance).hasNotPassedElement(TASK3_ELEMENT_ID);
ActivateJobsResponse response = zeebeClient.newActivateJobsCommand().jobType("task3-service-worker")
.maxJobsToActivate(1).send().join();
Thread.sleep(5000);
ActivatedJob activatedJob = response.getJobs().get(0);
task3Service.task3Service(activatedJob, zeebeClient);
Thread.sleep(10000);
//BpmnAssert.getRecordStream().jobRecords().forEach(obj->System.out.println(obj.getKey()) );
//BpmnAssert.assertThat(processInstance).hasPassedElement(TASK3_ELEMENT_ID);
//zeebeTestEngine.waitForBusyState(java.time.Duration.ofMillis(1000));
assertThat(processInstance).isActive();
zeebeClient.newCompleteCommand(activatedJob).send().join();
assertThat(processInstance).isCompleted();
cancelProcessInstance(processInstance);
} catch (Exception e) {
log.error("Error in task3 service complete test {}",e.getMessage());
throw e;
}
}
Its not get completed which is it should be?
After starting process instance does that automatically call task service method in unit test or explicitly need to call as I made here?
Please Explain.