use of org.drools.runtime.process.WorkflowProcessInstance in project jBPM5-Developer-Guide by Salaboy.
the class GenericWebServiceTaskTest method testPatientInsuranceCheckProcessTrue.
/**
* Simple test showing the interaction between a process and a web service.
* This method tests the case of an invalid response from the web-service.
*/
@Test
public void testPatientInsuranceCheckProcessTrue() {
HashMap<String, Object> input = new HashMap<String, Object>();
input.put("bedrequest_patientname", testPatients.get("salaboy").getId());
//Register a synchronous work item handler that will invoke a web service
CXFWebServiceWorkItemHandler webServiceHandler = new CXFWebServiceWorkItemHandler();
session.getWorkItemManager().registerWorkItemHandler("Web Service", webServiceHandler);
WorkflowProcessInstance pI = (WorkflowProcessInstance) session.startProcess("NewPatientInsuranceCheck", input);
//'salaboy' is correctly inssured according to the web service we have configured.
//The response should be valid.
assertEquals(ProcessInstance.STATE_COMPLETED, pI.getState());
assertEquals(Boolean.TRUE, pI.getVariable("checkinresults_patientInsured"));
System.out.println("-> Insurance Valid = " + pI.getVariable("checkinresults_patientInsured"));
}
use of org.drools.runtime.process.WorkflowProcessInstance in project jBPM5-Developer-Guide by Salaboy.
the class HospitalInsuranceProcessExecutorTest method testPatientInsuredProcessWithExecutor.
/**
* Tests the execution path for a patient having a valid insurance.
*/
@Test
public void testPatientInsuredProcessWithExecutor() throws InterruptedException {
HashMap<String, Object> input = new HashMap<String, Object>();
Patient salaboy = testPatients.get("salaboy");
input.put("patientName", salaboy.getId());
SessionStoreUtil.sessionCache.put("sessionId=" + session.getId(), session);
WorkflowProcessInstance pI = (WorkflowProcessInstance) session.startProcess("NewPatientInsuranceCheck", input);
//Our application can continue doing other things, the executor will do the rest
Thread.sleep(25000);
assertEquals(ProcessInstance.STATE_COMPLETED, pI.getState());
assertEquals(Boolean.TRUE, pI.getVariable("patientNotified"));
assertEquals(50, ((BigDecimal) pI.getVariable("finalAmount")).intValue());
}
Aggregations