### Question:
AttributeQueryRequestClient { public Element sendQuery(Element matchingServiceRequest, String messageId, SessionId sessionId, URI matchingServiceUri) { LOG.info("Sending attribute query to {}", matchingServiceUri); totalQueries.labels(matchingServiceUri.toString()).inc(); Optional<Element> response = sendSingleQuery( matchingServiceRequest, messageId, sessionId, matchingServiceUri ); if (response.isPresent()) { successfulQueries.labels(matchingServiceUri.toString()).inc(); return response.get(); } throw new MatchingServiceException(format("Attribute query failed")); } @Inject  AttributeQueryRequestClient(
            SoapRequestClient soapRequestClient,
            ExternalCommunicationEventLogger externalCommunicationEventLogger, MetricRegistry metricsRegistry); Element sendQuery(Element matchingServiceRequest, String messageId, SessionId sessionId, URI matchingServiceUri);  }### Answer:
@Test public void sendQuery_expectingSuccessWithStatusCode200() throws IOException, SAXException, ParserConfigurationException { Element matchingServiceRequest = XmlUtils.convertToElement("<someElement/>"); Response response = mock(Response.class); when(response.getStatus()).thenReturn(200); when(builder.post(any(Entity.class))).thenReturn(response); final Element element = attributeQueryRequestClientWithRealSoapRequestClient.sendQuery(matchingServiceRequest, SOME_MESSAGE_ID, SOME_SESSION_ID, matchingServiceUri); assertThat(element).isNotNull(); }
@Test public void sendQuery_shouldSendAuditHubEvent() throws Exception { Element matchingServiceRequest = XmlUtils.convertToElement("<someElement/>"); when(mockSoapRequestClient.makeSoapRequest(eq(matchingServiceRequest), any(URI.class))) .thenReturn(mock(Element.class)); attributeQueryRequestClientWithMockSoapRequestClient.sendQuery(matchingServiceRequest, SOME_MESSAGE_ID, SOME_SESSION_ID, matchingServiceUri); verify(externalCommunicationEventLogger).logMatchingServiceRequest(SOME_MESSAGE_ID, SOME_SESSION_ID, matchingServiceUri); }