### Question:
MatchingServiceHealthCheckResource { @GET public Response performMatchingServiceHealthCheck() { final AggregatedMatchingServicesHealthCheckResult result = matchingServiceHealthCheckHandler.handle(); final Response.ResponseBuilder response = result.isHealthy() ? Response.ok() : Response.serverError(); response.entity(result); return response.build(); } @Inject  MatchingServiceHealthCheckResource(MatchingServiceHealthCheckHandler matchingServiceHealthCheckHandler); @GET Response performMatchingServiceHealthCheck();  }### Answer:
@Test public void performMatchingServiceHealthCheck_shouldReturn500WhenThereAreNoMSAResults() { AggregatedMatchingServicesHealthCheckResult result = new AggregatedMatchingServicesHealthCheckResult(); when(handler.handle()).thenReturn(result); final Response response = matchingServiceHealthCheckResource.performMatchingServiceHealthCheck(); assertThat(response.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); }
@Test public void performMatchingServiceHealthCheck_shouldReturn500WhenHealthCheckIsUnhealthy() { AggregatedMatchingServicesHealthCheckResult result = new AggregatedMatchingServicesHealthCheckResult(); result.addResult(unhealthy(aMatchingServiceHealthCheckDetails().build())); when(handler.handle()).thenReturn(result); final Response response = matchingServiceHealthCheckResource.performMatchingServiceHealthCheck(); assertThat(response.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); }
@Test public void performMatchingServiceHealthCheck_shouldReturnResultFromHandler() { final String failureDescription = "some-error-description"; AggregatedMatchingServicesHealthCheckResult result = new AggregatedMatchingServicesHealthCheckResult(); result.addResult(unhealthy(aMatchingServiceHealthCheckDetails().withDetails(failureDescription).build())); when(handler.handle()).thenReturn(result); final Response response = matchingServiceHealthCheckResource.performMatchingServiceHealthCheck(); AggregatedMatchingServicesHealthCheckResult returnedResult = (AggregatedMatchingServicesHealthCheckResult)response.getEntity(); assertThat(returnedResult).isEqualTo(result); }