use of org.springframework.data.domain.PageRequest in project spring-boot by spring-projects.
the class CityRepositoryIntegrationTests method findsFirstPageOfCities.
@Test
public void findsFirstPageOfCities() {
Page<City> cities = this.repository.findAll(new PageRequest(0, 10));
assertThat(cities.getTotalElements()).isGreaterThan(20L);
}
use of org.springframework.data.domain.PageRequest in project spring-boot by spring-projects.
the class HotelRepositoryIntegrationTests method executesQueryMethodsCorrectly.
@Test
public void executesQueryMethodsCorrectly() {
City city = this.cityRepository.findAll(new PageRequest(0, 1, Direction.ASC, "name")).getContent().get(0);
assertThat(city.getName()).isEqualTo("Atlanta");
Page<HotelSummary> hotels = this.repository.findByCity(city, new PageRequest(0, 10, Direction.ASC, "name"));
Hotel hotel = this.repository.findByCityAndName(city, hotels.getContent().get(0).getName());
assertThat(hotel.getName()).isEqualTo("Doubletree");
List<RatingCount> counts = this.repository.findRatingCounts(hotel);
assertThat(counts).hasSize(1);
assertThat(counts.get(0).getRating()).isEqualTo(Rating.AVERAGE);
assertThat(counts.get(0).getCount()).isGreaterThan(1L);
}
use of org.springframework.data.domain.PageRequest in project spring-boot by spring-projects.
the class CityRepositoryIntegrationTests method findContaining.
@Test
public void findContaining() {
Page<City> cities = this.repository.findByNameContainingAndCountryContainingAllIgnoringCase("", "UK", new PageRequest(0, 10));
assertThat(cities.getTotalElements()).isEqualTo(3L);
}
use of org.springframework.data.domain.PageRequest in project spring-boot by spring-projects.
the class CityRepositoryIntegrationTests method findsFirstPageOfCities.
@Test
public void findsFirstPageOfCities() {
Page<City> cities = this.repository.findAll(new PageRequest(0, 10));
assertThat(cities.getTotalElements()).isGreaterThan(20L);
}
use of org.springframework.data.domain.PageRequest in project ocvn by devgateway.
the class GenericOCDSController method textSearchQuery.
/**
* Creates a mongodb query for searching based on text index, sorts the results by score
*
* @param request
* @return
*/
protected Query textSearchQuery(final TextSearchRequest request) {
PageRequest pageRequest = new PageRequest(request.getPageNumber(), request.getPageSize());
Query query = null;
if (request.getText() == null) {
query = new Query();
} else {
query = TextQuery.queryText(new TextCriteria().matching(request.getText())).sortByScore();
}
query.with(pageRequest);
return query;
}
Aggregations