StandardInboundDocQuery extends AbstractInboundDocQuery { @Override @InboundProcessingEvent(beforeBuilder = AdhocQueryRequestDescriptionBuilder.class, afterReturningBuilder = AdhocQueryResponseDescriptionBuilder.class, serviceType = "Document Query", version = "") public AdhocQueryResponse respondingGatewayCrossGatewayQuery(AdhocQueryRequest msg, AssertionType assertion, Properties webContextProperties) { String senderHcid = null; if (msg != null) { senderHcid = HomeCommunityMap.getCommunityIdFromAssertion(assertion); } AdhocQueryResponse resp = processDocQuery(msg, assertion, getLocalHomeCommunityId(), webContextProperties); auditResponseToNhin(msg, resp, assertion, senderHcid, webContextProperties); return resp; } StandardInboundDocQuery();  StandardInboundDocQuery(DocQueryPolicyChecker policyChecker,
        AdapterDocQueryProxyObjectFactory adapterFactory, DocQueryAuditLogger auditLogger); @Override @InboundProcessingEvent(beforeBuilder = AdhocQueryRequestDescriptionBuilder.class, afterReturningBuilder = AdhocQueryResponseDescriptionBuilder.class, serviceType = "Document Query", version = "") AdhocQueryResponse respondingGatewayCrossGatewayQuery(AdhocQueryRequest msg, AssertionType assertion,
        Properties webContextProperties); @Override AdhocQueryResponse processDocQuery(AdhocQueryRequest msg, AssertionType assertion, String requestCommunityID,
        Properties webContextProperties);  }
@Test public void failedPolicy() { AssertionType assertion = new AssertionType(); Properties webContextProperties = new Properties(); AdapterDocQueryProxyObjectFactory mockAdapterFactory = mock(AdapterDocQueryProxyObjectFactory.class); AdapterDocQueryProxy mockAdapterProxy = mock(AdapterDocQueryProxy.class); when(mockAdapterFactory.getAdapterDocQueryProxy()).thenReturn(mockAdapterProxy); when(policyChecker.checkIncomingPolicy(request, assertion)).thenReturn(false); StandardInboundDocQuery standardDocQuery = new StandardInboundDocQuery(policyChecker, mockAdapterFactory, getAuditLogger(true)) { @Override protected String getLocalHomeCommunityId() { return RESPONDING_HCID_FORMATTED; } }; AdhocQueryResponse actualResponse = standardDocQuery.respondingGatewayCrossGatewayQuery(request, assertion, webContextProperties); assertEquals(DocumentConstants.XDS_QUERY_RESPONSE_STATUS_FAILURE, actualResponse.getStatus()); assertEquals(DocumentConstants.XDS_ERRORCODE_REPOSITORY_ERROR, actualResponse.getRegistryErrorList() .getRegistryError().get(0).getErrorCode()); assertEquals(NhincConstants.XDS_REGISTRY_ERROR_SEVERITY_ERROR, actualResponse.getRegistryErrorList() .getRegistryError().get(0).getSeverity()); verify(mockEJBLogger).auditResponseMessage(eq(request), eq(actualResponse), eq(assertion), isNull( NhinTargetSystemType.class), eq(NhincConstants.AUDIT_LOG_INBOUND_DIRECTION), eq(NhincConstants.AUDIT_LOG_NHIN_INTERFACE), eq(Boolean.FALSE), eq(webContextProperties), eq(NhincConstants.DOC_QUERY_SERVICE_NAME), any(DocQueryAuditTransforms.class)); }