BPMS bpms = muleContext.getRegistry().lookupObject(BPMS.class);
assertNotNull(bpms);
// Create a new process.
MuleMessage response = muleContext.getClient().send("vm://fork", "data", null);
ProcessInstance process = (ProcessInstance) response.getPayload();
// The process should be waiting for asynchronous responses from both services
String state = (String) bpms.getState(process);
assertTrue(state.contains("waitForResponseA"));
assertTrue(state.contains("waitForResponseB"));
Thread.sleep(2000);
// ServiceA is initially stopped, so we're still waiting for a response from ServiceA
process = (ProcessInstance) bpms.lookupProcess(process.getId());
assertEquals("waitForResponseA", bpms.getState(process));
// Start ServiceA
muleContext.getRegistry().lookupService("ServiceA").resume();
Thread.sleep(2000);
// The process should have ended.
process = (ProcessInstance) bpms.lookupProcess(process.getId());
assertTrue("Process should have ended, but is in state " + bpms.getState(process),
bpms.hasEnded(process));
}