@Test(expectedExceptions = HTTPException.class) public void testWrongStatusCodeFail() throws Exception { Set<Integer> expected = new HashSet<>(); expected.add(200); when(mockResponse.getStatusCode()).thenReturn(500); DefaultAsyncCompletionHandler<String> handler = new DefaultAsyncCompletionHandler<>(String.class, expected); handler.onCompleted(mockResponse); }
@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);  }