TourInfoSharedServiceImpl implements TourInfoSharedService { @Override public boolean isOverPaymentLimit(TourInfo tour) { Assert.notNull(tour, "tour must not be null"); DateTime today = dateFactory.newDateTime().withTime(0, 0, 0, 0); DateTime paymentLimit = tour.getPaymentLimit(); log.debug("today={}, paymentLimit={}", today, paymentLimit); return today.isAfter(paymentLimit); }  @Override TourInfo findOne(String tourCode); @Override boolean isOverPaymentLimit(TourInfo tour); @Override TourInfo findOneForUpdate(String tourCode);  }
@Test public void testIsOverPaymentLimitTour01() { TourInfo tour = new TourInfo(); DateTime depDay = now.withTime(0, 0, 0, 0).plusDays(7); tour.setDepDay(depDay.toDate()); boolean result = tourInfoSharedService.isOverPaymentLimit(tour); assertThat(result, is(false)); }
@Test public void testIsOverPaymentLimitTour02() { TourInfo tour = new TourInfo(); DateTime depDay = now.withTime(0, 0, 0, 0).plusDays(6); tour.setDepDay(depDay.toDate()); boolean result = tourInfoSharedService.isOverPaymentLimit(tour); assertThat(result, is(true)); }
@Test public void testIsOverPaymentLimitTour03() { TourInfo tour = new TourInfo(); DateTime depDay = now.withTime(0, 0, 0, 0).plusDays(7); tour.setDepDay(depDay.toDate()); when(dateFactory.newDateTime()).thenReturn(now.withTime(0, 0, 0, 0) .plusMillis(1)); boolean result = tourInfoSharedService.isOverPaymentLimit(tour); assertThat(result, is(false)); }
@Test public void testIsOverPaymentLimitTour04() { TourInfo tour = new TourInfo(); DateTime depDay = now.withTime(0, 0, 0, 0).plusDays(7); tour.setDepDay(depDay.toDate()); when(dateFactory.newDateTime()).thenReturn(now.withTime(0, 0, 0, 0) .plusHours(23).plusMinutes(59).plusSeconds(59).plusMillis(999)); boolean result = tourInfoSharedService.isOverPaymentLimit(tour); assertThat(result, is(false)); }