DATACMNS-323 - PageImpl returns correct number of pages for use with content only.

So far, the PageImpl class returned 0 as total number of pages if set up from a plain List. This returns 1 now (as it should be). We've also adapted the hasNextPage() implementation to correctly calculate whether a next page is available.
This commit is contained in:
Oliver Gierke
2013-05-14 16:40:45 +02:00
parent 602834f86a
commit 70ce9a0908
2 changed files with 16 additions and 3 deletions

View File

@@ -106,11 +106,24 @@ public class PageImplUnitTests {
assertThat(page.getSize(), is(0));
assertThat(page.getSort(), is((Sort) null));
assertThat(page.getTotalElements(), is(0L));
assertThat(page.getTotalPages(), is(0));
assertThat(page.getTotalPages(), is(1));
assertThat(page.hasNextPage(), is(false));
assertThat(page.hasPreviousPage(), is(false));
assertThat(page.isFirstPage(), is(true));
assertThat(page.isLastPage(), is(true));
assertThat(page.hasContent(), is(false));
}
/**
* @see DATACMNS-323
*/
@Test
public void returnsCorrectTotalPages() {
Page<String> page = new PageImpl<String>(Arrays.asList("a"));
assertThat(page.getTotalPages(), is(1));
assertThat(page.hasNextPage(), is(false));
assertThat(page.hasPreviousPage(), is(false));
}
}