### Question:
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();  }### Answer:
@Test public void retrievingPreparedStatementPreparations() throws Exception { stubFor(get(urlEqualTo(preparedStatementPreparationUrl)) .willReturn(aResponse().withStatus(200).withBody( "[{\n" + " \"preparedStatementText\": \"select * from people where name = ?\"\n" + "}]" ))); List<PreparedStatementPreparation> preparations = underTest.retrievePreparedStatementPreparations(); assertEquals(1, preparations.size()); PreparedStatementPreparation singlePreparation = preparations.get(0); assertEquals("select * from people where name = ?", singlePreparation.getPreparedStatementText()); }
@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(); }
@Test(expected = ActivityRequestFailed.class) public void retrievingPreparedStatementPreparationsNot200() throws Exception { stubFor(get(urlEqualTo(preparedStatementPreparationUrl)) .willReturn(aResponse().withStatus(500))); underTest.retrievePreparedStatementPreparations(); }