TourInfoRepositoryImpl implements TourInfoRepositoryCustom { @Override @Transactional public Page<TourInfo> findPageBySearchCriteria( TourInfoSearchCriteria criteria, Pageable pageable) { List<TourInfo> content = findTourInfo(criteria, pageable); long total = countSearchTourInfo(criteria); Page<TourInfo> page = new PageImpl<TourInfo>(content, pageable, total); return page; }  @Override @Transactional Page<TourInfo> findPageBySearchCriteria(
            TourInfoSearchCriteria criteria, Pageable pageable);  }
@Test public void testSearchTourInfo01() { criteria.setDepDate(depDay.toDate()); criteria.setAdultCount(1); criteria.setArrCode("01"); criteria.setBasePrice(0); criteria.setChildCount(1); criteria.setDepCode("01"); criteria.setTourDays(0); Pageable pageable = PageRequest.of(0, 10); Page<TourInfo> page = tourInfoRepository.findPageBySearchCriteria( criteria, pageable); assertThat(page.getTotalPages(), is(1)); assertThat(page.getNumber(), is(0)); TourInfo tour = page.getContent().get(0); assertThat(tour.getAvaRecMax(), is(2147483647)); assertThat(tour.getBasePrice(), is(basePrice)); assertThat(tour.getConductor(), is("1")); assertThat(tour.getDepDay().getTime(), is(depDay.getMillis())); assertThat(tour.getPlannedDay().getTime(), is(plannedDay.getMillis())); assertThat(tour.getTourAbs(), is(tourAbs)); assertThat(tour.getTourCode(), is(tourCode)); assertThat(tour.getTourDays(), is(1)); assertThat(tour.getTourName(), is(tourName)); assertThat(tour.getAccommodation().getAccomCode(), is("0001")); assertThat(tour.getAccommodation().getAccomName(), is( "TERASOLUNAホテル第一荘")); assertThat(tour.getAccommodation().getAccomTel(), is("018-123-4567")); assertThat(tour.getDeparture().getDepCode(), is("01")); assertThat(tour.getDeparture().getDepName(), is("北海道")); }
@Test public void testSearchTourInfo02() { criteria.setDepDate(new LocalDate(2012, 7, 10).toDate()); criteria.setAdultCount(1); criteria.setArrCode("01"); criteria.setBasePrice(10); criteria.setChildCount(1); criteria.setDepCode("01"); criteria.setTourDays(2); Pageable pageable = PageRequest.of(0, 10); Page<TourInfo> page = tourInfoRepository.findPageBySearchCriteria( criteria, pageable); assertThat(page.getTotalPages(), is(0)); assertThat(page.getNumber(), is(0)); }