### Question:
ProtectiveMonitoringLogFormatter { public String formatAuthnResponse(Response samlResponse, Direction direction, SignatureStatus signatureStatus) { Issuer issuer = samlResponse.getIssuer(); String issuerString = issuer != null ? issuer.getValue() : ""; Status status = samlResponse.getStatus(); StatusCode subStatusCode = status.getStatusCode().getStatusCode(); String subStatus = subStatusCode != null ? subStatusCode.getValue() : ""; return String.format(AUTHN_RESPONSE, samlResponse.getID(), samlResponse.getInResponseTo(), direction, samlResponse.getDestination(), issuerString, signatureStatus.valid(), status.getStatusCode().getValue(), subStatus, getStatusDetailValues(status)); }  String formatAuthnRequest(AuthnRequest authnRequest, Direction direction, SignatureStatus signatureStatus); String formatAuthnResponse(Response samlResponse, Direction direction, SignatureStatus signatureStatus);  }### Answer:
@Test public void shouldFormatAuthnCancelResponse() throws IOException, URISyntaxException { String cancelXml = readXmlFile("status-cancel.xml"); Response cancelResponse = stringtoOpenSamlObjectTransformer.apply(cancelXml); String logString = new ProtectiveMonitoringLogFormatter().formatAuthnResponse(cancelResponse, Direction.INBOUND, SignatureStatus.VALID_SIGNATURE); String expectedLogMessage = "Protective Monitoring – Authn Response Event – " + "{responseId: _ccb1eabc4827928c9cbb3db34fdbe9df186dfcb8, " + "inResponseTo: _7081cbd6-a811-440a-949a-12a9521ed7cc, " + "direction: INBOUND, " + "destination: https: "issuerId: http: "validSignature: true, " + "status: urn:oasis:names:tc:SAML:2.0:status:Responder, " + "subStatus: urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext, " + "statusDetails: [authn-cancel]}"; assertThat(logString).isEqualTo(expectedLogMessage); }
@Test public void shouldFormatAuthnSuccessResponse() throws MarshallingException, SignatureException { Response response = aResponse().build(); String logString = new ProtectiveMonitoringLogFormatter().formatAuthnResponse(response, Direction.INBOUND, SignatureStatus.VALID_SIGNATURE); String expectedLogMessage = "Protective Monitoring – Authn Response Event – " + "{responseId: " + DEFAULT_RESPONSE_ID + ", " + "inResponseTo: " + DEFAULT_REQUEST_ID + ", " + "direction: INBOUND, " + "destination: http: "issuerId: a-test-entity, " + "validSignature: true, " + "status: urn:oasis:names:tc:SAML:2.0:status:Success, " + "subStatus: , " + "statusDetails: []}"; assertThat(logString).isEqualTo(expectedLogMessage); }
@Test public void shouldFormatResponseWithNoIssuer() throws MarshallingException, SignatureException { Response response = aResponse().withIssuer(null).build(); String logString = new ProtectiveMonitoringLogFormatter().formatAuthnResponse(response, Direction.INBOUND, SignatureStatus.VALID_SIGNATURE); assertThat(logString).contains("issuerId: ,"); }