@Test public void test_paginated_view_page_navigation() { List<String> strings = Lists.newArrayList("one", "two", "three", "four", "five"); Page page = new Page(0, 5); Result<String> result = new Result<>(strings, 0, 100); PaginatedView<String> paginatedView = new PaginatedView<>(result, page); Assertions.assertThat(paginatedView.hasPrev()).isFalse(); Assertions.assertThat(paginatedView.hasNext()).isTrue(); Assertions.assertThat(paginatedView.prev()).isNull(); Assertions.assertThat(paginatedView.next()).isNotNull(); Assertions.assertThat(paginatedView.next().getIndex()).isEqualTo(1); paginatedView = new PaginatedView<>(result, paginatedView.next()); Assertions.assertThat(paginatedView.hasPrev()).isTrue(); Assertions.assertThat(paginatedView.hasNext()).isTrue(); Assertions.assertThat(paginatedView.prev()).isNotNull(); Assertions.assertThat(paginatedView.prev().getIndex()).isEqualTo(0); paginatedView = new PaginatedView<>(result, new Page(19, 5)); Assertions.assertThat(paginatedView.hasPrev()).isTrue(); Assertions.assertThat(paginatedView.hasNext()).isFalse(); Assertions.assertThat(paginatedView.prev()).isNotNull(); Assertions.assertThat(paginatedView.next()).isNull(); }
public long getIndex() { return index; }
Page { public long getIndex() { return index; } }
Page { public long getIndex() { return index; } Page(long pageIndex, long capacity); }
Page { public long getIndex() { return index; } Page(long pageIndex, long capacity); long getIndex(); long getCapacity(); @Override String toString(); }
Page { public long getIndex() { return index; } Page(long pageIndex, long capacity); long getIndex(); long getCapacity(); @Override String toString();  }