AdapterPatientDiscoveryDeferredReqQueueProcessImpl { public PatientDiscoveryDeferredReqQueueProcessResponseType processPatientDiscoveryDeferredReqQueue( PatientDiscoveryDeferredReqQueueProcessRequestType request, WebServiceContext context) { PatientDiscoveryDeferredReqQueueProcessResponseType response = new PatientDiscoveryDeferredReqQueueProcessResponseType(); SuccessOrFailType sof = new SuccessOrFailType(); sof.setSuccess(Boolean.FALSE); response.setSuccessOrFail(sof); AdapterPatientDiscoveryDeferredReqQueueProcessOrchImpl entityPatientDiscoveryDeferredReqQueueProcessOrchImpl = getAdapterPatientDiscoveryDeferredReqQueueProcessOrchImpl(); MCCIIN000002UV01 mCCIIN000002UV01 = entityPatientDiscoveryDeferredReqQueueProcessOrchImpl .processPatientDiscoveryDeferredReqQueue(request.getMessageId()); if (mCCIIN000002UV01 != null && CollectionUtils.isNotEmpty(mCCIIN000002UV01.getAcknowledgement()) && mCCIIN000002UV01.getAcknowledgement().get(0) != null && mCCIIN000002UV01.getAcknowledgement().get(0).getTypeCode() != null && mCCIIN000002UV01.getAcknowledgement().get(0).getTypeCode().getCode() != null && mCCIIN000002UV01.getAcknowledgement().get(0).getTypeCode().getCode() .equals(HL7AckTransforms.ACK_TYPE_CODE_ACCEPT)) { sof.setSuccess(Boolean.TRUE); } return response; }  PatientDiscoveryDeferredReqQueueProcessResponseType processPatientDiscoveryDeferredReqQueue(
        PatientDiscoveryDeferredReqQueueProcessRequestType request, WebServiceContext context);  }
@Test public void testProcessPatientDiscoveryDeferredReqQueueHappy() { try { final int NUM_CALLS = 7; PatientDiscoveryDeferredReqQueueProcessRequestType request = new PatientDiscoveryDeferredReqQueueProcessRequestType(); request.setMessageId(""); AdapterPatientDiscoveryDeferredReqQueueProcessImpl deferredProcessImpl = new AdapterPatientDiscoveryDeferredReqQueueProcessImpl() { @Override protected AdapterPatientDiscoveryDeferredReqQueueProcessOrchImpl getAdapterPatientDiscoveryDeferredReqQueueProcessOrchImpl() { return mockServiceImpl; } }; context.checking(new Expectations() { { exactly(NUM_CALLS).of(mockServiceImpl).processPatientDiscoveryDeferredReqQueue( with(any(String.class))); will(onConsecutiveCalls(returnValue(createMCCIIN000002UV01()), returnValue(createMCCIIN000002UV01_2()), returnValue(createMCCIIN000002UV01_3()), returnValue(createMCCIIN000002UV01_4()), returnValue(createMCCIIN000002UV01_5()), returnValue(new MCCIIN000002UV01()), returnValue(null))); } }); PatientDiscoveryDeferredReqQueueProcessResponseType response; for (int i = 0; i < NUM_CALLS; i++) { response = deferredProcessImpl.processPatientDiscoveryDeferredReqQueue(request, null); assertNotNull(response); } } catch (Throwable t) { System.out.println("Error running testProcessPatientDiscoveryDeferredReqQueueHappy: " + t.getMessage()); t.printStackTrace(); fail("Error running testProcessPatientDiscoveryDeferredReqQueueHappy: " + t.getMessage()); } }