Search in sources :

Example 1 with ServiceTaskHandler

use of org.jbpm.bpmn2.handler.ServiceTaskHandler in project jBPM5-Developer-Guide by Salaboy.

the class ServiceTaskTest 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.
    //This work item handler is provided by jBPM5.
    session.getWorkItemManager().registerWorkItemHandler("Service Task", new ServiceTaskHandler());
    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 : ServiceTaskHandler(org.jbpm.bpmn2.handler.ServiceTaskHandler) HashMap(java.util.HashMap) WorkflowProcessInstance(org.drools.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 2 with ServiceTaskHandler

use of org.jbpm.bpmn2.handler.ServiceTaskHandler in project jBPM5-Developer-Guide by Salaboy.

the class ServiceTaskTest method testPatientInsuranceCheckProcessFalse.

/**
     * 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 testPatientInsuranceCheckProcessFalse() {
    HashMap<String, Object> input = new HashMap<String, Object>();
    input.put("bedrequest_patientname", testPatients.get("brotha").getId());
    //Register a synchronous work item handler that will invoke a web service.
    //This work item handler is provided by jBPM5.
    session.getWorkItemManager().registerWorkItemHandler("Service Task", new ServiceTaskHandler());
    WorkflowProcessInstance pI = (WorkflowProcessInstance) session.startProcess("NewPatientInsuranceCheck", input);
    //'brotha' is not inssured according to the web service we have configured.
    //The response should be invalid.
    assertEquals(ProcessInstance.STATE_COMPLETED, pI.getState());
    assertEquals(Boolean.FALSE, pI.getVariable("checkinresults_patientInsured"));
    System.out.println("-> Insurance Valid = " + pI.getVariable("checkinresults_patientInsured"));
}
Also used : ServiceTaskHandler(org.jbpm.bpmn2.handler.ServiceTaskHandler) HashMap(java.util.HashMap) WorkflowProcessInstance(org.drools.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)2 WorkflowProcessInstance (org.drools.runtime.process.WorkflowProcessInstance)2 ServiceTaskHandler (org.jbpm.bpmn2.handler.ServiceTaskHandler)2 Test (org.junit.Test)2