@Test public void testOnCompletionWithProvidedMapper() throws Exception { when(mockResponse.getStatusCode()).thenReturn(200); when(mockResponse.hasResponseBody()).thenReturn(true); when(mockResponse.getResponseBody()).thenReturn("true"); when(mockObjectMapper.readValue(anyString(), eq(String.class))).thenReturn("true"); DefaultAsyncCompletionHandler<String> handler = new DefaultAsyncCompletionHandler<>(String.class, mockObjectMapper); Assert.assertEquals(handler.onCompleted(mockResponse), "true"); }
@Override public T onCompleted(Response response) throws Exception { if (expectedStatusCodes.contains(response.getStatusCode())) { if (response.hasResponseBody()) { if (tClass == String.class) { return tClass.cast(response.getResponseBody()); } else { return objectMapper.readValue(response.getResponseBody(), tClass); } } return null; } else { throw new HTTPException(response.getStatusCode()); } }
DefaultAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(Response response) throws Exception { if (expectedStatusCodes.contains(response.getStatusCode())) { if (response.hasResponseBody()) { if (tClass == String.class) { return tClass.cast(response.getResponseBody()); } else { return objectMapper.readValue(response.getResponseBody(), tClass); } } return null; } else { throw new HTTPException(response.getStatusCode()); } } }
DefaultAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(Response response) throws Exception { if (expectedStatusCodes.contains(response.getStatusCode())) { if (response.hasResponseBody()) { if (tClass == String.class) { return tClass.cast(response.getResponseBody()); } else { return objectMapper.readValue(response.getResponseBody(), tClass); } } return null; } else { throw new HTTPException(response.getStatusCode()); } } DefaultAsyncCompletionHandler(Class<T> tClass, Set<Integer> expected, ObjectMapper o);  DefaultAsyncCompletionHandler(Class<T> tClass, Set<Integer> expected);  DefaultAsyncCompletionHandler(Class<T> tClass, ObjectMapper o);  DefaultAsyncCompletionHandler(Class<T> tClass); }
DefaultAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(Response response) throws Exception { if (expectedStatusCodes.contains(response.getStatusCode())) { if (response.hasResponseBody()) { if (tClass == String.class) { return tClass.cast(response.getResponseBody()); } else { return objectMapper.readValue(response.getResponseBody(), tClass); } } return null; } else { throw new HTTPException(response.getStatusCode()); } } DefaultAsyncCompletionHandler(Class<T> tClass, Set<Integer> expected, ObjectMapper o);  DefaultAsyncCompletionHandler(Class<T> tClass, Set<Integer> expected);  DefaultAsyncCompletionHandler(Class<T> tClass, ObjectMapper o);  DefaultAsyncCompletionHandler(Class<T> tClass); @Override T onCompleted(Response response); }
DefaultAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(Response response) throws Exception { if (expectedStatusCodes.contains(response.getStatusCode())) { if (response.hasResponseBody()) { if (tClass == String.class) { return tClass.cast(response.getResponseBody()); } else { return objectMapper.readValue(response.getResponseBody(), tClass); } } return null; } else { throw new HTTPException(response.getStatusCode()); } } DefaultAsyncCompletionHandler(Class<T> tClass, Set<Integer> expected, ObjectMapper o);  DefaultAsyncCompletionHandler(Class<T> tClass, Set<Integer> expected);  DefaultAsyncCompletionHandler(Class<T> tClass, ObjectMapper o);  DefaultAsyncCompletionHandler(Class<T> tClass); @Override T onCompleted(Response response);  }