HttpCallImplWithConnectionPooling implements HttpCall<T> { @Override public T doGet(final String url, final Class<T> toMap, final Map<String, String> headers, final Map<String, String> queryParams, final String accept, final int expectedStatus) { return makeRequest(GET, url, null, toMap, headers, queryParams, accept, null, expectedStatus); } @Inject  HttpCallImplWithConnectionPooling(); @Override T makeRequest(final String httpMethod, final String url, final Object data, final Class<T> toMap,
                         final Map<String, String> headers, final Map<String, String> queryParams,
                         final String accept, final String type, final int expectedStatus); @Override T makeRequest(final String httpMethod, final HttpCallConfig<T> config); @Override WebResource.Builder addHeaders(final WebResource webResource, final Map<String, String> headers,
                                          final String accept, final String type); @Override WebResource addQueryParams(final WebResource webResource, Map<String, String> queryParams); @Override T doGet(final String url, final Class<T> toMap, final Map<String, String> headers,
                   final Map<String, String> queryParams, final String accept, final int expectedStatus); @Override T doPost(final String url, final Object data, final Class<T> toMap, final Map<String, String> headers,
                    final Map<String, String> queryParams, final String accept, final String type,
                    final int expectedStatus); @Override T doPost(final HttpCallConfig<T> httpCallConfig); @Override T doGet(final HttpCallConfig<T> httpCallConfig); @Override T doPut(final HttpCallConfig<T> httpCallConfig); @Override T doDelete(final HttpCallConfig<T> httpCallConfig); @Override T doPut(final String url, final Object data, final Class<T> toMap, final Map<String, String> headers,
                   final Map<String, String> queryParams, final String accept, final String type,
                   final int expectedStatus); @Override T doDelete(final String url, final Class<T> toMap, final Map<String, String> headers,
                      final Map<String, String> queryParams, final String accept, final int expectedStatus);  }
@Test public void testDoGet() throws Exception { stubFor(get(urlEqualTo("/test")) .withHeader(ACCEPT, equalTo(accept)) .withHeader("foo", equalTo(map.get("foo"))) .withHeader("dead", equalTo(map.get("dead"))) .willReturn(aResponse().withStatus(ORDINAL_200_OK))); ClientResponse response = httpCallsImpl.doGet(url, ClientResponse.class, map, null, accept, ORDINAL_200_OK); assertThat(response.getStatus(), is(ORDINAL_200_OK)); response = httpCallsImpl.doGet(url, ClientResponse.class, null, null, accept, ORDINAL_404_Not_Found); assertThat(response.getStatus(), is(ORDINAL_404_Not_Found)); }
@Test public void testDoGetWithHttpConfig() throws Exception { stubFor(get(urlEqualTo("/test")) .withHeader(ACCEPT, equalTo(accept)) .withHeader("foo", equalTo(map.get("foo"))) .withHeader("dead", equalTo(map.get("dead"))) .willReturn(aResponse().withStatus(ORDINAL_200_OK))); HttpCallConfig httpCallConfig = HttpCallConfig.Builder.aHttpCallConfig() .withUrl(url) .withToMap(ClientResponse.class) .withHeaders(map) .withAccept(accept) .withExpectedStatus(ORDINAL_200_OK).build(); ClientResponse response = httpCallsImpl.doGet(httpCallConfig); assertThat(response.getStatus(), is(ORDINAL_200_OK)); }