PagingResult { public List<T> getResult() { return result; } PagingResult(Collection<? extends T> result, Paging paging, PagingLinkObjects pagingLinkObjects); List<T> getResult(); Paging getPaging(); PagingLinkObjects getPagingLinkObjects(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testDefensiveCopyOfResultList() { List<Object> data = new ArrayList<>(); data.add("entry1"); PagingResult<Object> result = new PagingResult<>(data, null, null); data.add("entry2"); assertThat(result.getResult()).containsOnly("entry1"); }
@Test(expected = UnsupportedOperationException.class) public void testGetResultUnmodifiable() { PagingResult<Object> result = new PagingResult<>(Arrays.asList("a", "b", "c"), null, null); result.getResult().add("d"); }