Search in sources :

Example 1 with RatingCount

use of sample.data.jpa.domain.RatingCount 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)

Aggregations

Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 PageRequest (org.springframework.data.domain.PageRequest)1 City (sample.data.jpa.domain.City)1 Hotel (sample.data.jpa.domain.Hotel)1 HotelSummary (sample.data.jpa.domain.HotelSummary)1 RatingCount (sample.data.jpa.domain.RatingCount)1