### Question:
AlertApiClient { public NewRelicNrqlCondition get(String apiKey, int policyId, int conditionId) throws AlertApiException { for (Iterator<NewRelicNrqlCondition> it = listAll(apiKey, policyId); it.hasNext(); ) { NewRelicNrqlCondition condition = it.next(); if (condition.getId().equals(conditionId)) { return condition; } } throw new AlertApiException( String.format("Could not find condition %d in policy %d", conditionId, policyId)); } AlertApiClient(String url, HttpClient httpClient); JSONObject create(
            NewRelicNrqlCondition newRelicNrqlCondition, String apiKey, int policyId); JSONObject update(
            NewRelicNrqlCondition newRelicNrqlCondition, String apiKey, int conditionId); void remove(String apiKey, int conditionId); List<NewRelicNrqlCondition> list(String apiKey, int policyId, @Nullable Integer page); Iterator<NewRelicNrqlCondition> listAll(String apiKey, int policyId); NewRelicNrqlCondition get(String apiKey, int policyId, int conditionId); static final String USER_AGENT; static final String X_API_KEY; static final String CONTENT_TYPE; static final String URL_PREFIX; }### Answer:
@Test void read() throws IOException, AlertApiException { nrqlCondition.setId(1); nrqlCondition2.setId(2); ObjectMapper objectMapper = new ObjectMapper(); String responseString = objectMapper.writeValueAsString( Collections.singletonMap( "nrql_conditions", Lists.newArrayList(nrqlCondition, nrqlCondition2))); BasicHttpResponse okResponse = new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK")); okResponse.setEntity(new StringEntity(responseString, ContentType.APPLICATION_JSON)); when(mockHttpClient.execute(any(HttpGet.class))).thenReturn(okResponse); NewRelicNrqlCondition fetchedCondition = alertApiClient.get(TEST_API_KEY, TEST_POLICY_ID, 2); ArgumentCaptor<HttpGet> requestCaptor = ArgumentCaptor.forClass(HttpGet.class); verify(mockHttpClient).execute(requestCaptor.capture()); HttpGet request = requestCaptor.getValue(); assertEquals("http: assertEquals(nrqlCondition2, fetchedCondition); }