Search in sources :

Example 11 with WorkflowProcessInstance

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"));
}
Also used : HashMap(java.util.HashMap) CXFWebServiceWorkItemHandler(com.salaboy.jbpm5.dev.guide.workitems.CXFWebServiceWorkItemHandler) WorkflowProcessInstance(org.drools.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 12 with WorkflowProcessInstance

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());
}
Also used : HashMap(java.util.HashMap) Patient(com.salaboy.jbpm5.dev.guide.model.Patient) WorkflowProcessInstance(org.drools.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)12 WorkflowProcessInstance (org.drools.runtime.process.WorkflowProcessInstance)12 Test (org.junit.Test)12 Patient (com.salaboy.jbpm5.dev.guide.model.Patient)4 AsyncGenericWorkItemHandler (com.salaboy.jbpm5.dev.guide.workitems.AsyncGenericWorkItemHandler)4 CXFWebServiceWorkItemHandler (com.salaboy.jbpm5.dev.guide.workitems.CXFWebServiceWorkItemHandler)2 ServiceTaskHandler (org.jbpm.bpmn2.handler.ServiceTaskHandler)2 RequestInfo (org.jbpm.executor.entities.RequestInfo)2