StandardOutboundDocSubmission implements OutboundDocSubmission { @Override @OutboundProcessingEvent(beforeBuilder = DocSubmissionBaseEventDescriptionBuilder.class, afterReturningBuilder = DocSubmissionBaseEventDescriptionBuilder.class, serviceType = "Document Submission", version = "") public RegistryResponseType provideAndRegisterDocumentSetB(ProvideAndRegisterDocumentSetRequestType body, AssertionType assertion, NhinTargetCommunitiesType targets, UrlInfoType urlInfo) { logInfoServiceProcess(this.getClass()); RegistryResponseType response; assertion = MessageGeneratorUtils.getInstance().generateMessageId(assertion); RespondingGatewayProvideAndRegisterDocumentSetSecuredRequestType request = createRequestForInternalProcessing( body, targets, urlInfo); NhinTargetSystemType target = getMessageGeneratorUtils().convertFirstToNhinTargetSystemType(targets); auditRequest(request.getProvideAndRegisterDocumentSetRequest(), assertion, target); if (isPolicyValid(request, assertion)) { LOG.info("Policy check successful"); response = getResponseFromTarget(request, assertion); } else { LOG.error("Failed policy check. Sending error response."); response = MessageGeneratorUtils.getInstance().createFailedPolicyCheckResponse(); } return response; } StandardOutboundDocSubmission(); @Override @OutboundProcessingEvent(beforeBuilder = DocSubmissionBaseEventDescriptionBuilder.class, afterReturningBuilder = DocSubmissionBaseEventDescriptionBuilder.class, serviceType = "Document Submission", version = "") RegistryResponseType provideAndRegisterDocumentSetB(ProvideAndRegisterDocumentSetRequestType body,
        AssertionType assertion, NhinTargetCommunitiesType targets, UrlInfoType urlInfo);  }
@Test public void testProvideAndRegisterDocumentSetB1() { NhinTargetCommunitiesType targets = createNhinTargetCommunitiesType(receiverHcid); NhinTargetSystemType target = createNhinTargetSystemType(receiverHcid); ProvideAndRegisterDocumentSetRequestType request = createProvideAndRegisterDocumentSetRequestType(); AssertionType assertion = getAssertion(senderHcid); StandardOutboundDocSubmission outbound = getStandardOutboundDocSubmission(getAuditLogger(true), mockChecker, mockDelegate, mockOrchestratable, mockUtils, target); when(mockUtils.convertFirstToNhinTargetSystemType(targets)).thenReturn(target); when(mockChecker.checkXDRRequestPolicy(request, assertion, senderHcid, receiverHcid, NhincConstants.POLICYENGINE_OUTBOUND_DIRECTION)).thenReturn(Boolean.TRUE); when(mockDelegate.process(mockOrchestratable)).thenReturn(mockOrchestratable); when(mockOrchestratable.getResponse()).thenReturn(successResponse); RegistryResponseType actualResponse = outbound.provideAndRegisterDocumentSetB(request, assertion, targets, new UrlInfoType()); assertNotNull("Assertion MessageId is null", assertion.getMessageId()); verify(mockEJBLogger).auditRequestMessage(eq(request), eq(assertion), eq(target), eq(NhincConstants.AUDIT_LOG_OUTBOUND_DIRECTION), eq(NhincConstants.AUDIT_LOG_NHIN_INTERFACE), eq(Boolean.TRUE), isNull(Properties.class), eq(NhincConstants.NHINC_XDR_SERVICE_NAME), any(DocSubmissionAuditTransforms.class)); assertNotNull(actualResponse); assertEquals(actualResponse.getStatus(), successResponse.getStatus()); }
@Test public void testProvideAndRegisterDocumentSetB_policyFailure() { NhinTargetCommunitiesType targets = createNhinTargetCommunitiesType(receiverHcid); NhinTargetSystemType target = createNhinTargetSystemType(receiverHcid); ProvideAndRegisterDocumentSetRequestType request = createProvideAndRegisterDocumentSetRequestType(); AssertionType assertion = getAssertion(senderHcid); StandardOutboundDocSubmission outbound = getStandardOutboundDocSubmission(getAuditLogger(true), mockChecker, mockDelegate, mockOrchestratable, mockUtils, target); when(mockUtils.convertFirstToNhinTargetSystemType(targets)).thenReturn(target); when(mockChecker.checkXDRRequestPolicy(request, assertion, senderHcid, receiverHcid, NhincConstants.POLICYENGINE_OUTBOUND_DIRECTION)).thenReturn(Boolean.FALSE); RegistryResponseType response = outbound.provideAndRegisterDocumentSetB(request, assertion, targets, new UrlInfoType()); assertNotNull("Assertion MessageId is null", assertion.getMessageId()); verify(mockEJBLogger).auditRequestMessage(eq(request), eq(assertion), eq(target), eq(NhincConstants.AUDIT_LOG_OUTBOUND_DIRECTION), eq(NhincConstants.AUDIT_LOG_NHIN_INTERFACE), eq(Boolean.TRUE), isNull(Properties.class), eq(NhincConstants.NHINC_XDR_SERVICE_NAME), any(DocSubmissionAuditTransforms.class)); assertNotNull(response); assertTrue(response.getRegistryErrorList().getRegistryError().size() > 0); assertEquals(DocumentConstants.XDS_SUBMISSION_RESPONSE_STATUS_FAILURE, response.getStatus()); }
@Test public void testProvideAndRegisterDocumentSetB_emptyTargets() { AssertionType assertion = getAssertion(senderHcid); ProvideAndRegisterDocumentSetRequestType request = createProvideAndRegisterDocumentSetRequestType(); StandardOutboundDocSubmission outbound = getStandardOutboundDocSubmission(getAuditLogger(true), mockChecker, mockDelegate, mockOrchestratable, mockUtils, null); RegistryResponseType response = outbound.provideAndRegisterDocumentSetB(request, assertion, null, new UrlInfoType()); assertNotNull("Assertion MessageId is null", assertion.getMessageId()); verify(mockEJBLogger).auditRequestMessage(eq(request), eq(assertion), isNull(NhinTargetSystemType.class), eq(NhincConstants.AUDIT_LOG_OUTBOUND_DIRECTION), eq(NhincConstants.AUDIT_LOG_NHIN_INTERFACE), eq(Boolean.TRUE), isNull(Properties.class), eq(NhincConstants.NHINC_XDR_SERVICE_NAME), any(DocSubmissionAuditTransforms.class)); assertNotNull(response); assertTrue(response.getRegistryErrorList().getRegistryError().size() > 0); assertEquals(DocumentConstants.XDS_SUBMISSION_RESPONSE_STATUS_FAILURE, response.getStatus()); }
@Test public void testAuditLoggingOffForOutboundDS() { NhinTargetCommunitiesType targets = createNhinTargetCommunitiesType(receiverHcid); NhinTargetSystemType target = createNhinTargetSystemType(receiverHcid); ProvideAndRegisterDocumentSetRequestType request = createProvideAndRegisterDocumentSetRequestType(); AssertionType assertion = getAssertion(senderHcid); StandardOutboundDocSubmission outbound = getStandardOutboundDocSubmission(getAuditLogger(false), mockChecker, mockDelegate, mockOrchestratable, mockUtils, target); when(mockUtils.convertFirstToNhinTargetSystemType(targets)).thenReturn(target); when(mockChecker.checkXDRRequestPolicy(request, assertion, senderHcid, receiverHcid, NhincConstants.POLICYENGINE_OUTBOUND_DIRECTION)).thenReturn(Boolean.TRUE); when(mockDelegate.process(mockOrchestratable)).thenReturn(mockOrchestratable); when(mockOrchestratable.getResponse()).thenReturn(successResponse); RegistryResponseType actualResponse = outbound.provideAndRegisterDocumentSetB(request, assertion, targets, new UrlInfoType()); assertNotNull("Assertion MessageId is null", assertion.getMessageId()); verify(mockEJBLogger, never()).auditRequestMessage(eq(request), eq(assertion), eq(target), eq(NhincConstants.AUDIT_LOG_OUTBOUND_DIRECTION), eq(NhincConstants.AUDIT_LOG_NHIN_INTERFACE), eq(Boolean.TRUE), isNull(Properties.class), eq(NhincConstants.NHINC_XDR_SERVICE_NAME), any(DocSubmissionAuditTransforms.class)); assertNotNull(actualResponse); assertEquals(actualResponse.getStatus(), successResponse.getStatus()); }