### Question:
PrimingClient { public List<PrimingRequest> retrieveQueryPrimes() { return httpGetSinglePrimingRequests(primeQueryUrl); } private  PrimingClient(String host, int port); static PrimingClientBuilder builder(); void prime(PrimingRequest prime); void prime(PrimingRequest.PrimingRequestBuilder prime); void primeBatch(BatchPrimingRequest batchPrimingRequest); void primeBatch(BatchPrimingRequest.BatchPrimingRequestBuilder batchPrimingRequest); void multiPrime(MultiPrimeRequest primeRequest); @Deprecated void primeQuery(PrimingRequest primeRequest); @Deprecated void primePreparedStatement(PrimingRequest primeRequest); List<PrimingRequest> retrievePreparedPrimes(); List<MultiPrimeRequest> retrievePreparedMultiPrimes(); List<PrimingRequest> retrieveQueryPrimes(); void clearAllPrimes(); void clearQueryPrimes(); void clearPreparedPrimes(); void clearPreparedMultiPrimes(); void clearBatchPrimes(); static final String DELETING_OF_PRIMES_FAILED; static final String PRIMING_FAILED; }### Answer:
@Test public void testRetrieveOfPreviousQueryPrimes() { Map<String, Object> rows = new HashMap<String, Object>(); rows.put("name", "Chris"); PrimingRequest pr = PrimingRequest.queryBuilder() .withQuery("select * from people") .withRows(rows) .build(); stubFor(get(urlEqualTo(PRIME_QUERY_PATH)).willReturn(aResponse().withStatus(200).withBody( "[{\n" + " \"when\": {\n" + " \"query\": \"select * from people\"\n" + " },\n" + " \"then\": {\n" + " \"rows\": [{\n" + " \"name\": \"Chris\"\n" + " }],\n" + " \"result\":\"success\"" + " }\n" + "}]" ))); List<PrimingRequest> primingRequests = underTest.retrieveQueryPrimes(); assertEquals(1, primingRequests.size()); assertEquals(pr, primingRequests.get(0)); }
@Test(expected = PrimeFailedException.class) public void testRetrievingOfQueryPrimesFailedDueToStatusCode() { stubFor(get(urlEqualTo(PRIME_QUERY_PATH)).willReturn(aResponse().withStatus(500))); underTest.retrieveQueryPrimes(); }
@Test(expected = PrimeFailedException.class) public void testRetrievingOfQueryPrimesFailed() { stubFor(get(urlEqualTo(PRIME_QUERY_PATH)) .willReturn(aResponse() .withFault(Fault.RANDOM_DATA_THEN_CLOSE))); underTest.retrieveQueryPrimes(); }
@Test(expected = PrimeFailedException.class) public void testRetrievingOfMultiPreparedPrimesFailedDueToStatusCode() { stubFor(get(urlEqualTo(PRIME_PREPARED_MULTI_PATH)).willReturn(aResponse().withStatus(500))); underTest.retrieveQueryPrimes(); }
@Test(expected = PrimeFailedException.class) public void testRetrievingOfMultiPreparedPrimesFailed() { stubFor(get(urlEqualTo(PRIME_PREPARED_MULTI_PATH)) .willReturn(aResponse() .withFault(Fault.RANDOM_DATA_THEN_CLOSE))); underTest.retrieveQueryPrimes(); }