### Question:
HealthCheckSoapRequestClient extends SoapRequestClient { public HealthCheckResponse makeSoapRequestForHealthCheck(Element requestElement, URI uri) { LOG.info(MessageFormat.format("Making SOAP request to: {0}", uri)); try { SoapResponse response = makePost(uri, requestElement); return new HealthCheckResponse(response.getBody()); } catch(ProcessingException e) { throw ApplicationException.createUnauditedException(ExceptionType.NETWORK_ERROR, UUID.randomUUID(), e); } catch (SOAPRequestError e) { throw ApplicationException.createUnauditedException(ExceptionType.REMOTE_SERVER_ERROR, UUID.randomUUID(), e); } } @Inject  HealthCheckSoapRequestClient(SoapMessageManager soapMessageManager, @Named("HealthCheckClient") Client client); HealthCheckResponse makeSoapRequestForHealthCheck(Element requestElement, URI uri);  }### Answer:
@Test(expected = ApplicationException.class) public void makeSoapRequestForHealthCheck_shouldThrowWhenResponseNot200() throws URISyntaxException { when(response.getStatus()).thenReturn(502); URI matchingServiceUri = new URI("http: healthCheckSoapRequestClient.makeSoapRequestForHealthCheck(null, matchingServiceUri); }
@Test public void makePost_shouldEnsureResponseInputStreamIsClosedWhenResponseCodeIsNot200() throws URISyntaxException { when(response.getStatus()).thenReturn(502); URI matchingServiceUri = new URI("http: try { healthCheckSoapRequestClient.makeSoapRequestForHealthCheck(null, matchingServiceUri); fail("Exception should have been thrown"); } catch (ApplicationException e) { verify(response).close(); } }