PassthroughOutboundDocRetrieve extends AbstractOutboundDocRetrieve implements OutboundDocRetrieve { @Override public RetrieveDocumentSetResponseType respondingGatewayCrossGatewayRetrieve( RetrieveDocumentSetRequestType request, AssertionType assertion, NhinTargetCommunitiesType targets, ADAPTER_API_LEVEL entityAPILevel) { logInfoServiceProcess(this.getClass()); RetrieveDocumentSetResponseType response; assertion = MessageGeneratorUtils.getInstance().generateMessageId(assertion); if (validateGuidance(targets, entityAPILevel)) { NhinTargetSystemType targetSystem = MessageGeneratorUtils.getInstance().convertFirstToNhinTargetSystemType( targets); auditRequest(request, assertion, targetSystem); OutboundDocRetrieveDelegate delegate = new OutboundDocRetrieveDelegate(); OutboundDocRetrieveOrchestratable orchestratable = new OutboundPassthroughDocRetrieveOrchestratable(null, delegate, null, request, assertion, targetSystem); OutboundDocRetrieveOrchestratable orchResponse = (OutboundDocRetrieveOrchestratable) orchestrator .process(orchestratable); response = orchResponse.getResponse(); try { DocRetrieveFileUtils.getInstance().streamDocumentsToFileSystemIfEnabled(response); } catch (IOException ioe) { LOG.error("Failed to save documents to file system.", ioe); response = MessageGenerator.getInstance().createRegistryResponseError( "Adapter Document Retrieve Processing: " + ioe.getLocalizedMessage()); } } else { NhinTargetSystemType target = MessageGeneratorUtils.getInstance().convertFirstToNhinTargetSystemType( targets); auditRequest(request, assertion, target); response = createGuidanceErrorResponse(entityAPILevel); } return response; } PassthroughOutboundDocRetrieve();  PassthroughOutboundDocRetrieve(CONNECTOutboundOrchestrator orchestrator, DocRetrieveAuditLogger auditLogger); @Override RetrieveDocumentSetResponseType respondingGatewayCrossGatewayRetrieve(
        RetrieveDocumentSetRequestType request, AssertionType assertion, NhinTargetCommunitiesType targets,
        ADAPTER_API_LEVEL entityAPILevel); @Override DocRetrieveAuditLogger getAuditLogger();  }
@Test public void invoke() { targets.setUseSpecVersion("2.0"); RetrieveDocumentSetResponseType expectedResponse = new RetrieveDocumentSetResponseType(); when(orchestrator.process(any(OutboundDocRetrieveOrchestratable.class))).thenReturn(orchResponse); when(orchResponse.getResponse()).thenReturn(expectedResponse); PassthroughOutboundDocRetrieve outboundDocRetrieve = (PassthroughOutboundDocRetrieve) getOutboundDocRetrieve( orchestrator, true); RetrieveDocumentSetResponseType actualResponse = outboundDocRetrieve.respondingGatewayCrossGatewayRetrieve( request, assertion, targets, ADAPTER_API_LEVEL.LEVEL_a0); assertSame(expectedResponse, actualResponse); assertNotNull("Assertion MessageId is null", assertion.getMessageId()); verify(mockEJBLogger).auditRequestMessage(eq(request), eq(assertion), any(NhinTargetSystemType.class), eq(NhincConstants.AUDIT_LOG_OUTBOUND_DIRECTION), eq(NhincConstants.AUDIT_LOG_NHIN_INTERFACE), eq(Boolean.TRUE), isNull(Properties.class), eq(NhincConstants.DOC_RETRIEVE_SERVICE_NAME), any(DocRetrieveAuditTransforms.class)); }
@Test public void auditLoggingOffForOutboundDR() { targets.setUseSpecVersion("2.0"); RetrieveDocumentSetResponseType expectedResponse = new RetrieveDocumentSetResponseType(); when(orchestrator.process(any(OutboundDocRetrieveOrchestratable.class))).thenReturn(orchResponse); when(orchResponse.getResponse()).thenReturn(expectedResponse); PassthroughOutboundDocRetrieve outboundDocRetrieve = (PassthroughOutboundDocRetrieve) getOutboundDocRetrieve( orchestrator, false); RetrieveDocumentSetResponseType actualResponse = outboundDocRetrieve.respondingGatewayCrossGatewayRetrieve( request, assertion, targets, ADAPTER_API_LEVEL.LEVEL_a0); assertSame(expectedResponse, actualResponse); assertNotNull("Assertion MessageId is null", assertion.getMessageId()); verify(mockEJBLogger, never()).auditRequestMessage(eq(request), eq(assertion), any(NhinTargetSystemType.class), eq(NhincConstants.AUDIT_LOG_OUTBOUND_DIRECTION), eq(NhincConstants.AUDIT_LOG_NHIN_INTERFACE), eq(Boolean.TRUE), isNull(Properties.class), eq(NhincConstants.DOC_RETRIEVE_SERVICE_NAME), any(DocRetrieveAuditTransforms.class)); }