PagedList extends ArrayList<HttpResponse<T>> { public List<T> getBodies() { return stream() .filter(HttpResponse::isSuccess) .map(HttpResponse::getBody) .collect(Collectors.toList()); }  List<T> getBodies(); PagedList<T> ifSuccess(Consumer<HttpResponse<T>> consumer); PagedList<T> ifFailure(Consumer<HttpResponse<T>> consumer);  }
@Test public void canGetAllTheBodies() { PagedList<String> list = new PagedList<>(); list.addAll(asList( mkRequest("foo"), mkRequest("bar"), mkRequest("baz") )); List<String> bodies = list.getBodies(); assertEquals(Arrays.asList("foo","bar","baz"), bodies); }
@Test public void bodiesMustBeSucessful() { PagedList<String> list = new PagedList<>(); list.addAll(asList( mkRequest("foo"), mkRequest(null), mkRequest("baz") )); List<String> bodies = list.getBodies(); assertEquals(Arrays.asList("foo","baz"), bodies); }