List of usage examples for org.springframework.data.domain Slice nextPageable
Pageable nextPageable();
From source file:com.afmobi.mongodb.repository.PersonRepositoryIntegrationTests.java
@Test public void sliceShouldTraverseElementsWithoutSkippingOnes() { repository.deleteAll();/*from ww w . j a va 2 s .c o m*/ List<Person> persons = new ArrayList<Person>(100); for (int i = 0; i < 100; i++) { // format firstname to assert sorting retains proper order persons.add(new Person(String.format("%03d", i), "ln" + 1, 100)); } repository.save(persons); Slice<Person> slice = repository.findByAgeGreaterThan(50, new PageRequest(0, 20, Direction.ASC, "firstname")); assertThat(slice, contains(persons.subList(0, 20).toArray())); slice = repository.findByAgeGreaterThan(50, slice.nextPageable()); assertThat(slice, contains(persons.subList(20, 40).toArray())); }