Search in sources :

Example 6 with PageRequest

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);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) City(sample.data.jpa.domain.City) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 7 with PageRequest

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);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) RatingCount(sample.data.jpa.domain.RatingCount) HotelSummary(sample.data.jpa.domain.HotelSummary) City(sample.data.jpa.domain.City) Hotel(sample.data.jpa.domain.Hotel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with PageRequest

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);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) City(sample.data.rest.domain.City) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 9 with PageRequest

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);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) City(sample.data.rest.domain.City) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 10 with PageRequest

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;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) TextQuery(org.springframework.data.mongodb.core.query.TextQuery) Query(org.springframework.data.mongodb.core.query.Query) TextCriteria(org.springframework.data.mongodb.core.query.TextCriteria)

Aggregations

PageRequest (org.springframework.data.domain.PageRequest)106 Sort (org.springframework.data.domain.Sort)29 Pageable (org.springframework.data.domain.Pageable)25 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)14 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)9 Transactional (org.springframework.transaction.annotation.Transactional)9 UUID (java.util.UUID)8 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)7 ApiOperation (io.swagger.annotations.ApiOperation)7 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)6 IdmTreeNode (eu.bcvsolutions.idm.core.model.entity.IdmTreeNode)6 List (java.util.List)6 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)5 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)5 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)5 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)5 PageImpl (org.springframework.data.domain.PageImpl)5