@Test public void testGetReservationReservationStartTimeOverlap() { // Reservation duration is 10 minutes long reservationStart = Timestamp.valueOf("2050-12-03 10:37:37").getTime(); long reservationEnd = Timestamp.valueOf("2050-12-03 10:47:37").getTime(); // Search interval fits the starting portion of the reservation. long searchStart = Timestamp.valueOf("2050-12-03 11:36:37").getTime(); long searchEnd = Timestamp.valueOf("2050-12-03 11:38:37").getTime(); // 60 minute period in milliseconds. long period = 60 * 60 * 1000; testPositiveGetRecurringReservationsHelper(reservationStart, reservationEnd, searchStart, searchEnd, 100, period, 10); }
@Test public void testGetReservationReservationEndTimeOverlap() { // Reservation duration is 10 minutes long reservationStart = Timestamp.valueOf("2050-12-03 10:37:37").getTime(); long reservationEnd = Timestamp.valueOf("2050-12-03 10:47:37").getTime(); // Search interval fits the ending portion of the reservation. long searchStart = Timestamp.valueOf("2050-12-03 11:46:37").getTime(); long searchEnd = Timestamp.valueOf("2050-12-03 11:48:37").getTime(); // 60 minute period in milliseconds. long period = 60 * 60 * 1000; testPositiveGetRecurringReservationsHelper(reservationStart, reservationEnd, searchStart, searchEnd, 100, period, 10); }
@Test public void testGetReservationReservationFitWithinSearchInterval() { // Reservation duration is 10 minutes long reservationStart = Timestamp.valueOf("2050-12-03 10:37:37").getTime(); long reservationEnd = Timestamp.valueOf("2050-12-03 10:47:37").getTime(); // Search interval fits the entire reservation but is smaller than the // period. long searchStart = Timestamp.valueOf("2050-12-03 10:36:37").getTime(); long searchEnd = Timestamp.valueOf("2050-12-03 10:48:37").getTime(); // 20 minute period in milliseconds. long period = 20 * 60 * 1000; testPositiveGetRecurringReservationsHelper(reservationStart, reservationEnd, searchStart, searchEnd, 100, period, 10); }
@Test public void testGetReservationSearchIntervalFitsInReservation() { // Reservation duration is 10 minutes long reservationStart = Timestamp.valueOf("2050-12-03 10:37:37").getTime(); long reservationEnd = Timestamp.valueOf("2050-12-03 10:47:37").getTime(); // Search interval fits the within the reservation. long searchStart = Timestamp.valueOf("2050-12-03 10:40:37").getTime(); long searchEnd = Timestamp.valueOf("2050-12-03 10:43:37").getTime(); // 60 minute period in milliseconds. long period = 60 * 60 * 1000; testPositiveGetRecurringReservationsHelper(reservationStart, reservationEnd, searchStart, searchEnd, 100, period, 10); }
@Test public void testGetReservationSearchIntervalGreaterThanPeriod() { // Reservation duration is 10 minutes long reservationStart = Timestamp.valueOf("2050-12-03 10:37:37").getTime(); long reservationEnd = Timestamp.valueOf("2050-12-03 10:47:37").getTime(); // 1 Hour search interval will for sure encompass the recurring // reservation with 20 minute recurrence. long searchStart = Timestamp.valueOf("2050-12-03 10:57:37").getTime(); long searchEnd = Timestamp.valueOf("2050-12-03 11:57:37").getTime(); // 20 minute period in milliseconds. long period = 20 * 60 * 1000; testPositiveGetRecurringReservationsHelper(reservationStart, reservationEnd, searchStart, searchEnd, 100, period, 10); }
@Test public void testEnsureReservationEndNotNegativeWhenShifted() { // Reservation duration is 10 minutes long reservationStart = Timestamp.valueOf("2050-12-03 9:57:37").getTime(); long reservationEnd = Timestamp.valueOf("2050-12-03 10:07:37").getTime(); // If the reservation end is made periodic, and then shifted, then it can // end up negative. This test guards against this scenario. long searchStart = Timestamp.valueOf("2050-12-03 9:58:37").getTime(); long searchEnd = Timestamp.valueOf("2050-12-03 10:08:37").getTime(); // 60 minute period in milliseconds. long period = 60 * 60 * 1000; testPositiveGetRecurringReservationsHelper(reservationStart, reservationEnd, searchStart, searchEnd, 100, period, 10); }
@Test public void testReservationIntervalGreaterThanPeriodInOrderWhenShifted() { // Reservation duration is 10 minutes long reservationStart = Timestamp.valueOf("2050-12-03 10:37:37").getTime(); long reservationEnd = Timestamp.valueOf("2050-12-03 10:47:37").getTime(); // Search interval is more than 2 hours, but after shifting, and turning // it into periodic values, we expect 13 minutes and 18 minutes // respectively for the search start and search end. After shifting and // turning into periodic, the reservation interval will be 0 and 10 // minutes respectively for the search start and search end. At first // sight, it would appear that the reservation does not fall within the // search interval, when it does in reality. long searchStart = Timestamp.valueOf("2050-12-03 9:50:37").getTime(); long searchEnd = Timestamp.valueOf("2050-12-03 11:55:37").getTime(); // 60 minute period in milliseconds. long period = 60 * 60 * 1000; testPositiveGetRecurringReservationsHelper(reservationStart, reservationEnd, searchStart, searchEnd, 100, period, 10); }