### Question:
Scenario { @POST @Produces("application/json") public CheckResult run( @QueryParam("serviceUrl") String serviceUrl, Credentials credentials) { try { credentialsService.validate(credentials); try (OPClient client = opushClientFactory.create(chooseHttpClient(credentials, serviceUrl), credentials.getLoginAtDomain(), credentials.getPassword(), DEVICE_ID, DEV_TYPE, USER_AGENT, serviceUrl)) { return scenarii(client); } } catch (Exception e) { return handleException(e); } }  @POST @Produces("application/json") CheckResult run(
			@QueryParam("serviceUrl") String serviceUrl,
			Credentials credentials); final static DeviceId DEVICE_ID; final static String DEV_TYPE; final static String USER_AGENT; }### Answer:
@Test public void runShouldCloseHttpClientAndReturnOKWhenSuccess() { opushClient.close(); expectLastCall(); mocks.replay(); CheckResult result = testee.run(serverUrl, noCertificateCredentials); mocks.verify(); assertThat(result).isEqualTo(CheckResult.builder().checkStatus(CheckStatus.OK).build()); }
@Test public void runShouldCloseHttpClientAndReturnERRORWhenException() { opushClient.close(); expectLastCall(); mocks.replay(); CheckResult result = testeeThrowingException.run(serverUrl, noCertificateCredentials); mocks.verify(); assertThat(result.getStatus()).isEqualTo(CheckStatus.ERROR.asSpecificationValue()); assertThat(result.getMessages()).hasSize(1); assertThat(Iterables.getLast(result.getMessages())).startsWith(IllegalStateException.class.getName() + ": expected message"); }