### Question:
MatchingServiceHealthCheckClient { public MatchingServiceHealthCheckResponseDto sendHealthCheckRequest( final Element matchingServiceHealthCheckRequest, final URI matchingServiceUri) { final String scope = matchingServiceUri.toString().replace(':','_').replace('/', '_'); final Timer timer = metricsRegistry.timer(MetricRegistry.name(MatchingServiceHealthCheckClient.class, "sendHealthCheckRequest", scope)); final Timer.Context context = timer.time(); HealthCheckResponse healthCheckResponse; try { healthCheckResponse = client.makeSoapRequestForHealthCheck(matchingServiceHealthCheckRequest, matchingServiceUri); } catch(ApplicationException ex) { final String errorMessage = MessageFormat.format("Failed to complete matching service health check to {0}.", matchingServiceUri); LOG.warn(errorMessage, ex); return new MatchingServiceHealthCheckResponseDto(Optional.empty()); } finally { context.stop(); } return new MatchingServiceHealthCheckResponseDto( Optional.of(XmlUtils.writeToString(healthCheckResponse.getResponseElement()))); } @Inject  MatchingServiceHealthCheckClient(HealthCheckSoapRequestClient soapRequestClient, MetricRegistry metricsRegistry); MatchingServiceHealthCheckResponseDto sendHealthCheckRequest(
            final Element matchingServiceHealthCheckRequest,
            final URI matchingServiceUri);  }### Answer:
@Test public void sendHealthCheckRequest_shouldReturnTrueIfResponseReceived() { HealthCheckResponse healthCheckResponse = aHealthCheckResponse() .withElement(healthCheckResponseElement) .build(); when(soapRequestClient.makeSoapRequestForHealthCheck(healthCheckRequest, healthCheckUri)).thenReturn(healthCheckResponse); final MatchingServiceHealthCheckResponseDto matchingServiceHealthCheckResponseDto = matchingServiceHealthCheckClient.sendHealthCheckRequest(healthCheckRequest, healthCheckUri); assertThat(matchingServiceHealthCheckResponseDto.getResponse()).isEqualTo(Optional.of(XmlUtils.writeToString(healthCheckResponseElement))); }
@Test public void sendHealthCheckRequest_shouldReturnOptionalAbsentIfNoResponseReceived() { when(soapRequestClient.makeSoapRequestForHealthCheck(healthCheckRequest, healthCheckUri)).thenThrow(ApplicationException.createUnauditedException(ExceptionType.NETWORK_ERROR, UUID.randomUUID())); final MatchingServiceHealthCheckResponseDto matchingServiceHealthCheckResponseDto = matchingServiceHealthCheckClient.sendHealthCheckRequest(healthCheckRequest, healthCheckUri); assertThat(matchingServiceHealthCheckResponseDto.getResponse()).isEqualTo(Optional.empty()); }