I have a JUNIT code which executes a Delegate class which I am trying to run and failing because of the below:
The below code is written within a delegate Java Class to start an instance of another Process.I am getting a NPE in my JUNIT because the ProcessEngine is not getting instantiated. I could see that Actual Use case is working(while running the actual code in tomcat) but failing with the Test Case alone.
@Test @Deployment(resources={“MainProcess.bpmn”, “Test-Subproces.bpmn”,“Test-Another-Invoke.bpmn”})
public void testHappyPath(){
// Create a HashMap to put in variables for the process instance
//Mock RestAPIDelegateTest
RestAPISuccessDelegateTest mockSubProcess = new RestAPISuccessDelegateTest();
Mocks.register("RestAPIDelegateTest",mockSubProcess);
Map<String, Object> variables = new HashMap<String, Object>();
// Start process with Java API and variables
ProcessInstance processInstance = runtimeService().startProcessInstanceByKey("Main-Process-Start", variables);
assertThat(processInstance).isWaitingAt("Timer_Activity");
//runtimeService().
Job job = rule.getManagementService().createJobQuery().processInstanceId(processInstance.getId()).singleResult();
rule.getManagementService().executeJob(job.getId());
assertThat(processInstance).isEnded();
}
Main Process waits for a time then calls the SubProcess(subprocess.bpmn) using a CallActivity. After the Call Activity I have a Service Task with in which initiates the third workflow(invoke.bpmn) with the above pasted code in my actual question where I get a NPE.