AdapterDocSubmissionDeferredRequestProxyWebServiceSecuredImpl implements
    AdapterDocSubmissionDeferredRequestProxy { @AdapterDelegationEvent(beforeBuilder = DocSubmissionBaseEventDescriptionBuilder.class, afterReturningBuilder = DocSubmissionArgTransformerBuilder.class, serviceType = "Document Submission Deferred Request", version = "LEVEL_a0") @Override public XDRAcknowledgementType provideAndRegisterDocumentSetBRequest( ProvideAndRegisterDocumentSetRequestType request, AssertionType assertion) { LOG.debug("Begin AdapterDocSubmissionDeferredRequestProxyWebServiceSecuredImpl.provideAndRegisterDocumentSetBRequest"); XDRAcknowledgementType response = null; String serviceName = NhincConstants.ADAPTER_XDR_REQUEST_SECURED_SERVICE_NAME; try { LOG.debug("Before target system destination URL look up."); String destURL = oProxyHelper.getAdapterEndPointFromConnectionManager(serviceName); LOG.debug("After target system URL look up. URL for service: {} is: {}",serviceName, destURL); if (NullChecker.isNotNullish(destURL)) { AdapterProvideAndRegisterDocumentSetSecuredRequestType wsRequest = new AdapterProvideAndRegisterDocumentSetSecuredRequestType(); wsRequest.setProvideAndRegisterDocumentSetRequest(request); wsRequest.setUrl(destURL); ServicePortDescriptor<AdapterXDRRequestSecuredPortType> portDescriptor = new AdapterDocSubmissionDeferredRequestSecuredServicePortDescriptor(); CONNECTClient<AdapterXDRRequestSecuredPortType> client = getCONNECTClientSecured(portDescriptor, destURL, assertion); client.enableMtom(); response = (XDRAcknowledgementType) client.invokePort(AdapterXDRRequestSecuredPortType.class, "provideAndRegisterDocumentSetBRequest", wsRequest); } else { throw new WebServiceException("Could not determine URL for Doc Submission Deferred Request Adapter endpoint"); } } catch (Exception ex) { throw new ErrorEventException(ex, "Unable to call Doc Submission Deferred Request Adapter"); } LOG.debug("End AdapterDocSubmissionDeferredRequestProxyWebServiceSecuredImpl.provideAndRegisterDocumentSetBRequest"); return response; } AdapterDocSubmissionDeferredRequestProxyWebServiceSecuredImpl(); @AdapterDelegationEvent(beforeBuilder = DocSubmissionBaseEventDescriptionBuilder.class, afterReturningBuilder = DocSubmissionArgTransformerBuilder.class, serviceType = "Document Submission Deferred Request", version = "LEVEL_a0") @Override XDRAcknowledgementType provideAndRegisterDocumentSetBRequest(
        ProvideAndRegisterDocumentSetRequestType request, AssertionType assertion);  }
@Test public void testProvideAndRegisterDocumentSetBRequest() throws ExchangeManagerException { final CONNECTClient<AdapterXDRRequestSecuredPortType> mockClient = new CONNECTClientMock(); AdapterDocSubmissionDeferredRequestProxyWebServiceSecuredImpl adapterXDRRequestWebServiceProxy = new AdapterDocSubmissionDeferredRequestProxyWebServiceSecuredImpl() { @Override protected CONNECTClient<AdapterXDRRequestSecuredPortType> getCONNECTClientSecured( ServicePortDescriptor<AdapterXDRRequestSecuredPortType> portDescriptor, String url, AssertionType assertion) { return mockClient; } @Override protected WebServiceProxyHelper createWebServiceProxyHelper() { return mockWSProxyHelper; } }; when(mockWSProxyHelper.getAdapterEndPointFromConnectionManager(anyString())).thenReturn( "https: ProvideAndRegisterDocumentSetRequestType iheMsg = new ProvideAndRegisterDocumentSetRequestType(); AssertionType assertion = new AssertionType(); XDRAcknowledgementType result = adapterXDRRequestWebServiceProxy.provideAndRegisterDocumentSetBRequest(iheMsg, assertion); assertEquals(NhincConstants.XDR_ACK_STATUS_MSG, result.getMessage().getStatus()); }
@Test public void testProvideAndRegisterDocumentSetBRequestFailureCase() throws ExchangeManagerException { final CONNECTClient<AdapterXDRRequestSecuredPortType> mockClient = new CONNECTClientMock(); AdapterDocSubmissionDeferredRequestProxyWebServiceSecuredImpl adapterXDRRequestWebServiceProxy = new AdapterDocSubmissionDeferredRequestProxyWebServiceSecuredImpl() { @Override protected CONNECTClient<AdapterXDRRequestSecuredPortType> getCONNECTClientSecured( ServicePortDescriptor<AdapterXDRRequestSecuredPortType> portDescriptor, String url, AssertionType assertion) { return mockClient; } @Override protected WebServiceProxyHelper createWebServiceProxyHelper() { return mockWSProxyHelper; } }; when(mockWSProxyHelper.getAdapterEndPointFromConnectionManager(anyString())).thenReturn( "https: ProvideAndRegisterDocumentSetRequestType iheMsg = new ProvideAndRegisterDocumentSetRequestType(); AssertionType assertion = new AssertionType(); XDRAcknowledgementType result = adapterXDRRequestWebServiceProxy.provideAndRegisterDocumentSetBRequest(iheMsg, assertion); assertEquals(NhincConstants.XDR_ACK_STATUS_MSG, result.getMessage().getStatus()); }