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:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user