コード例 #1
0
  @Override
  public ReviewsSummary getReviewSummary(Hotel hotel) {
    Collection<RatingCount> ratingCounts =
        ratingCountListCacheRedisRepository.get(
            "ratingcounts:hotel:" + hotel.getId(), RatingCount.class);

    if (ratingCounts == null || ratingCounts.isEmpty()) {
      ratingCounts = this.hotelRepository.findRatingCounts(hotel);
      if (ratingCounts != null) {
        ratingCountListCacheRedisRepository.multiAdd(
            "ratingcounts:hotel:" + hotel.getId(), ratingCounts, true);
        ratingCountListCacheRedisRepository.expire(
            "ratingcounts:hotel:" + hotel.getId(), 60, TimeUnit.SECONDS);
      }
    }

    return new ReviewsSummaryImpl(new ArrayList<>(ratingCounts));
  }
コード例 #2
0
 @org.junit.Before
 public void setUp() throws Exception {
   hcontroller = new HotelController();
   hotel = hcontroller.getHotel("Hilton");
   book = new Booking();
   book.setEmail("*****@*****.**");
   book.setHotelId(hotel.getId());
   book.setRoomId(20);
   book.setPhoneNr("894-7896");
   book.setCreditCardNr("4567894512345698");
   book.setCustomerName("palli");
   book.setStartDate("2016-05-19");
   book.setEndDate("2016-05-20");
   book = bcontroller.saveBooking(book);
 }