Response { public static <T> Response<T> fail(final Exception error) { assertNotNull(error, "Error must not null"); return new Response<>(null, error); } private  Response(final ValueT value, final Exception error); static Response<T> success(final T value); static Response<T> fail(final Exception error);  }
@Test public void testFail() { final Exception expected = new UnsupportedOperationException(); final Response<String> response = Response.fail(expected); assertNull(response.getValue()); assertEquals(expected, response.getError()); }