Source:
<code>public void failedPolicyCheck() throws PropertyAccessException { String localHCID = "1.1"; String senderHCID = "2.2"; RegistryResponseType regResponse = new RegistryResponseType(); AssertionType assertion = new AssertionType(); assertion.setHomeCommunity(new HomeCommunityType()); assertion.getHomeCommunity().setHomeCommunityId(senderHCID); AdapterDocSubmissionDeferredResponseProxyObjectFactory adapterFactory = mock(AdapterDocSubmissionDeferredResponseProxyObjectFactory.class); PropertyAccessor propertyAccessor = mock(PropertyAccessor.class); XDRPolicyChecker policyChecker = mock(XDRPolicyChecker.class); when( propertyAccessor.getProperty(NhincConstants.GATEWAY_PROPERTY_FILE, NhincConstants.HOME_COMMUNITY_ID_PROPERTY)).thenReturn(localHCID); when( policyChecker.checkXDRResponsePolicy(regResponse, assertion, senderHCID, localHCID, NhincConstants.POLICYENGINE_INBOUND_DIRECTION)).thenReturn(false); StandardInboundDocSubmissionDeferredResponse standardDocSubmission = new StandardInboundDocSubmissionDeferredResponse(adapterFactory, policyChecker, propertyAccessor, auditLogger); XDRAcknowledgementType actualResponse = standardDocSubmission.provideAndRegisterDocumentSetBResponse( regResponse, assertion, webContextProperties); <START> <END> assertEquals("CONNECTPolicyCheckFailed", actualResponse.getMessage().getRegistryErrorList().getRegistryError() .get(0).getErrorCode()); assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure", actualResponse.getMessage() .getStatus()); assertEquals("urn:oasis:names:tc:ebxml-regrep:ErrorSeverityType:Error", actualResponse.getMessage() .getRegistryErrorList().getRegistryError().get(0).getSeverity()); verify(auditLogger).auditResponseMessage(eq(regResponse), eq(actualResponse), eq(assertion), isNull(NhinTargetSystemType.class), eq(NhincConstants.AUDIT_LOG_OUTBOUND_DIRECTION), eq(NhincConstants.AUDIT_LOG_NHIN_INTERFACE), eq(Boolean.FALSE), eq(webContextProperties), eq(NhincConstants.NHINC_XDR_RESPONSE_SERVICE_NAME)); }</code><technical_language>already-defined constants for strings</technical_language>

Target:
public void failedPolicyCheck() throws PropertyAccessException { String localHCID = "1.1"; String senderHCID = "2.2"; assertion.setHomeCommunity(new HomeCommunityType()); assertion.getHomeCommunity().setHomeCommunityId(senderHCID); when( propertyAccessor.getProperty(NhincConstants.GATEWAY_PROPERTY_FILE, NhincConstants.HOME_COMMUNITY_ID_PROPERTY)).thenReturn(localHCID); when( policyChecker.checkXDRResponsePolicy(regResponse, assertion, senderHCID, localHCID, NhincConstants.POLICYENGINE_INBOUND_DIRECTION)).thenReturn(false); StandardInboundDocSubmissionDeferredResponse standardDocSubmission = new StandardInboundDocSubmissionDeferredResponse(adapterFactory, policyChecker, propertyAccessor, auditLogger); XDRAcknowledgementType actualResponse = standardDocSubmission.provideAndRegisterDocumentSetBResponse( regResponse, assertion, webContextProperties); assertEquals("CONNECTPolicyCheckFailed", actualResponse.getMessage().getRegistryErrorList().getRegistryError() .get(0).getErrorCode()); assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure", actualResponse.getMessage() .getStatus()); assertEquals("urn:oasis:names:tc:ebxml-regrep:ErrorSeverityType:Error", actualResponse.getMessage() .getRegistryErrorList().getRegistryError().get(0).getSeverity()); verify(auditLogger).auditResponseMessage(eq(regResponse), eq(actualResponse), eq(assertion), isNull(NhinTargetSystemType.class), eq(NhincConstants.AUDIT_LOG_OUTBOUND_DIRECTION), eq(NhincConstants.AUDIT_LOG_NHIN_INTERFACE), eq(Boolean.FALSE), eq(webContextProperties), eq(NhincConstants.NHINC_XDR_RESPONSE_SERVICE_NAME)); }