DefaultPagingAndSortingRepository extends PagingAndSortingSupport implements DataStoreAware { public List findAll(Sort sort) { return PagingAndSortingUtils.sort(retrieveAll(), sort); }  List findAll(Sort sort); Page findAll(Pageable pageable); @Override void setDataStore(DataStore dataStore);  }
@Test public void testFindAllWithPagingAndNoSorting() { final Page page = repository.findAll(PageRequest.of(2, 3)); assertThat(page.getTotalElements(), is(8L)); assertThat(page.getTotalPages(), is(3)); assertThat(page.getNumber(), is(2)); assertThat(page.getSize(), is(3)); assertThat(page.getNumberOfElements(), is(2)); }
@Test public void testFindAllWithPagingAndSorting() { final Page page = repository.findAll(PageRequest.of(2, 3, Sort.by(new Sort.Order(Sort.Direction.ASC, "address.city"), new Sort.Order(Sort.Direction.DESC, "address.zip.area")))); assertThat(page.getTotalElements(), is(8L)); assertThat(page.getTotalPages(), is(3)); assertThat(page.getNumber(), is(2)); assertThat(page.getSize(), is(3)); assertThat(page.getNumberOfElements(), is(2)); final List<?> found = page.getContent(); assertThat(found.get(0), Matchers.is(dataStore.retrieve("1"))); assertThat(found.get(1), Matchers.is(dataStore.retrieve("7"))); }