ValidatingResponseHandler implements ResponseHandler<T, E> { public static <T, E extends Exception> ValidatingResponseHandler<T, E> validate(ResponseHandler<T, E> handler) { return new ValidatingResponseHandler<>(handler); } private  ValidatingResponseHandler(ResponseHandler<T, E> handler); static ValidatingResponseHandler<T, E> validate(ResponseHandler<T, E> handler); @Override T handleException(Request request, Exception exception); @Override T handle(Request request, Response response);  }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*agentId=may not be null.*") public void testValidate() { JsonCodec<AgentStatusRepresentation> agentCodec = JsonCodec.jsonCodec(AgentStatusRepresentation.class); Request request = prepareGet().setUri(URI.create("http: Response response = fakeJsonResponse("{}"); validate(createJsonResponseHandler(agentCodec)).handle(request, response); }