### Question:
PaginationFilter implements Function<ListResult<T>, ListResult<T>> { @Override public ListResult<T> apply(ListResult<T> result) { List<T> list = result.getItems(); if (startIndex >= list.size()) { list = Collections.emptyList(); } else { list = list.subList(startIndex, Math.min(list.size(), endIndex)); } return new ListResult.Builder<T>().createFrom(result).items(list).build(); } PaginationFilter(PaginationOptions options); @Override ListResult<T> apply(ListResult<T> result);  }### Answer:
@Test public void apply() throws Exception { try { ListResult<Integer> filtered = new PaginationFilter<Integer>(new PaginationOptions() { @Override public int getPage() { return PaginationFilterTest.this.parameter.page; } @Override public int getPerPage() { return PaginationFilterTest.this.parameter.perPage; } }).apply(new ListResult.Builder<Integer>().items(parameter.inputList).totalCount(parameter.inputList.size()).build()); assertEquals(parameter.outputList, filtered.getItems()); assertEquals(parameter.inputList.size(), filtered.getTotalCount()); } catch (Exception e) { if (parameter.expectedException == null) { throw e; } assertEquals(parameter.expectedException, e.getClass()); return; } if (parameter.expectedException != null) { fail("Expected exception " + parameter.expectedException); } }