@Test(expected = ActivityRequestFailed.class) public void retrievingPreparedStatementPreparationsFailure() throws Exception { stubFor(get(urlEqualTo(preparedStatementPreparationUrl)) .willReturn(aResponse().withStatus(200).withFault(Fault.RANDOM_DATA_THEN_CLOSE))); underTest.retrievePreparedStatementPreparations(); }
public List<PreparedStatementPreparation> retrievePreparedStatementPreparations() { HttpGet get = new HttpGet(preparedStatementPreparationUrl); try { CloseableHttpResponse response = httpClient.execute(get); String body = EntityUtils.toString(response.getEntity()); LOGGER.debug("Received response {}", body); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != 200) { String errorMessage = String.format("Non 200 status code when retrieving prepared statement preparations %s", statusCode); LOGGER.info(errorMessage); throw new ActivityRequestFailed(errorMessage); } PreparedStatementPreparation[] preparations = (PreparedStatementPreparation[]) gson.fromJson(body, (Class) PreparedStatementPreparation[].class); LOGGER.debug("Parsed prepared statement preparations {}", Arrays.toString(preparations)); return Arrays.asList(preparations); } catch (IOException e) { LOGGER.info(REQUEST_FAILED, e); throw new ActivityRequestFailed(REQUEST_FAILED, e); } }
ActivityClient { public List<PreparedStatementPreparation> retrievePreparedStatementPreparations() { HttpGet get = new HttpGet(preparedStatementPreparationUrl); try { CloseableHttpResponse response = httpClient.execute(get); String body = EntityUtils.toString(response.getEntity()); LOGGER.debug("Received response {}", body); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != 200) { String errorMessage = String.format("Non 200 status code when retrieving prepared statement preparations %s", statusCode); LOGGER.info(errorMessage); throw new ActivityRequestFailed(errorMessage); } PreparedStatementPreparation[] preparations = (PreparedStatementPreparation[]) gson.fromJson(body, (Class) PreparedStatementPreparation[].class); LOGGER.debug("Parsed prepared statement preparations {}", Arrays.toString(preparations)); return Arrays.asList(preparations); } catch (IOException e) { LOGGER.info(REQUEST_FAILED, e); throw new ActivityRequestFailed(REQUEST_FAILED, e); } } }
ActivityClient { public List<PreparedStatementPreparation> retrievePreparedStatementPreparations() { HttpGet get = new HttpGet(preparedStatementPreparationUrl); try { CloseableHttpResponse response = httpClient.execute(get); String body = EntityUtils.toString(response.getEntity()); LOGGER.debug("Received response {}", body); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != 200) { String errorMessage = String.format("Non 200 status code when retrieving prepared statement preparations %s", statusCode); LOGGER.info(errorMessage); throw new ActivityRequestFailed(errorMessage); } PreparedStatementPreparation[] preparations = (PreparedStatementPreparation[]) gson.fromJson(body, (Class) PreparedStatementPreparation[].class); LOGGER.debug("Parsed prepared statement preparations {}", Arrays.toString(preparations)); return Arrays.asList(preparations); } catch (IOException e) { LOGGER.info(REQUEST_FAILED, e); throw new ActivityRequestFailed(REQUEST_FAILED, e); } } private  ActivityClient(String host, int port, int socketTimeout); }
ActivityClient { public List<PreparedStatementPreparation> retrievePreparedStatementPreparations() { HttpGet get = new HttpGet(preparedStatementPreparationUrl); try { CloseableHttpResponse response = httpClient.execute(get); String body = EntityUtils.toString(response.getEntity()); LOGGER.debug("Received response {}", body); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != 200) { String errorMessage = String.format("Non 200 status code when retrieving prepared statement preparations %s", statusCode); LOGGER.info(errorMessage); throw new ActivityRequestFailed(errorMessage); } PreparedStatementPreparation[] preparations = (PreparedStatementPreparation[]) gson.fromJson(body, (Class) PreparedStatementPreparation[].class); LOGGER.debug("Parsed prepared statement preparations {}", Arrays.toString(preparations)); return Arrays.asList(preparations); } catch (IOException e) { LOGGER.info(REQUEST_FAILED, e); throw new ActivityRequestFailed(REQUEST_FAILED, e); } } private  ActivityClient(String host, int port, int socketTimeout); static ActivityClientBuilder builder(); List<Query> retrieveQueries(); List<Connection> retrieveConnections(); void clearConnections(); void clearQueries(); void clearPreparedStatementPreparations(); List<PreparedStatementPreparation> retrievePreparedStatementPreparations(); void clearPreparedStatementExecutions(); void clearAllRecordedActivity(); List<PreparedStatementExecution> retrievePreparedStatementExecutions(); List<BatchExecution> retrieveBatches(); void clearBatchExecutions(); }
ActivityClient { public List<PreparedStatementPreparation> retrievePreparedStatementPreparations() { HttpGet get = new HttpGet(preparedStatementPreparationUrl); try { CloseableHttpResponse response = httpClient.execute(get); String body = EntityUtils.toString(response.getEntity()); LOGGER.debug("Received response {}", body); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != 200) { String errorMessage = String.format("Non 200 status code when retrieving prepared statement preparations %s", statusCode); LOGGER.info(errorMessage); throw new ActivityRequestFailed(errorMessage); } PreparedStatementPreparation[] preparations = (PreparedStatementPreparation[]) gson.fromJson(body, (Class) PreparedStatementPreparation[].class); LOGGER.debug("Parsed prepared statement preparations {}", Arrays.toString(preparations)); return Arrays.asList(preparations); } catch (IOException e) { LOGGER.info(REQUEST_FAILED, e); throw new ActivityRequestFailed(REQUEST_FAILED, e); } } private  ActivityClient(String host, int port, int socketTimeout); static ActivityClientBuilder builder(); List<Query> retrieveQueries(); List<Connection> retrieveConnections(); void clearConnections(); void clearQueries(); void clearPreparedStatementPreparations(); List<PreparedStatementPreparation> retrievePreparedStatementPreparations(); void clearPreparedStatementExecutions(); void clearAllRecordedActivity(); List<PreparedStatementExecution> retrievePreparedStatementExecutions(); List<BatchExecution> retrieveBatches(); void clearBatchExecutions();  }