JUNIT Delegate call fails to call a subprocess programatically

Hi,

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.

ProcessEngine processEngine = BpmPlatform.getDefaultProcessEngine();
processEngine.getRuntimeService().startProcessInstanceByKey(“Test-Invoke”, variables);

Please let me know if you have any idea on this.

Thanks,Vishnu

Can you post the full unit test

@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.

Can you make sure you read the style guide when posting code?
Also - can you upload your models