Organisation testOrg = CannedQueries.orgByName(TestConstants.ORG1_NAME);
Unit testUnit = CannedQueries.unitByName(TestConstants.UNIT1_NAME, testOrg);
TestClock testClock = new TestClock(BasicVCampTestDataFixture.DATE_BEFORE_DEADLINE);
Booking regularBooking = Booking.create(testUnit, vcamp, testClock);
regularBooking.setArrivalDate(DateUtils.getDate(2013, 7, 3));
regularBooking.setDepartureDate(DateUtils.getDate(2013, 7, 11));
assertEquals("Regular bookings are 112", 112d, pricer.priceOf(regularBooking), 0);
Booking bookingWithPreAndPostCamp = Booking.create(testUnit, vcamp, testClock);
bookingWithPreAndPostCamp.setArrivalDate(DateUtils.getDate(2013, 6, 30));
bookingWithPreAndPostCamp.setDepartureDate(DateUtils.getDate(2011, 7, 15));
assertEquals("Bookings capped at 112 including pre and post camp", 112d, pricer.priceOf(bookingWithPreAndPostCamp), 0);
Booking booking = Booking.create(testUnit, vcamp, testClock);
booking.setArrivalDate(DateUtils.getDate(2013, 7, 3));
booking.setDepartureDate(DateUtils.getDate(2013, 7, 4));
assertEquals("1 night", 10 + 13d, pricer.priceOf(booking), 0);
booking.setArrivalDate(DateUtils.getDate(2013, 7, 3));
booking.setDepartureDate(DateUtils.getDate(2013, 7, 5));
assertEquals("2 nights", 10d + (2*13), pricer.priceOf(booking), 0);
booking.setArrivalDate(DateUtils.getDate(2013, 7, 3));
booking.setDepartureDate(DateUtils.getDate(2013, 7, 10));
assertEquals("7 nights", 101d, pricer.priceOf(booking), 0);
Clock clockAfterDeadline = new TestClock(BasicVCampTestDataFixture.DATE_AFTER_DEADLINE_BEFORE_AMMENDMENT);
Booking lateBooking = Booking.create(testUnit,vcamp, clockAfterDeadline);
lateBooking.setArrivalDate(DateUtils.getDate(2013, 7, 3));
lateBooking.setDepartureDate(DateUtils.getDate(2013, 7, 11));
assertEquals("Bookings after the deadline cost more", 122, pricer.priceOf(lateBooking), 0);
Clock clockAfterEventStart = new TestClock(BasicVCampTestDataFixture.VCAMP_START);
Booking atEventBooking = Booking.create(testUnit,vcamp, clockAfterEventStart);
atEventBooking.setArrivalDate(DateUtils.getDate(2013, 7, 3));
atEventBooking.setDepartureDate(DateUtils.getDate(2013, 7, 11));
assertEquals("Bookings made at camp cost even more", 142, pricer.priceOf(atEventBooking), 0);
Booking lateUpdatedBooking = Booking.create(testUnit,vcamp, testClock);
lateUpdatedBooking.setArrivalDate(DateUtils.getDate(2013, 7, 3));
lateUpdatedBooking.setDepartureDate(DateUtils.getDate(2013, 7, 11));
lateUpdatedBooking.setBookingUnlockDate(BasicVCampTestDataFixture.DATE_AFTER_AMMENDMENT_DEADLINE);
assertEquals("Bookings unlocked for updating after the amendment deadline cost more", 117d, pricer.priceOf(lateUpdatedBooking), 0);
Booking woodchipBooking = Booking.create(testUnit, vcamp, testClock);
woodchipBooking.setArrivalDate(DateUtils.getDate(2013, 7, 3));
woodchipBooking.setDepartureDate(DateUtils.getDate(2013, 7, 11));
woodchipBooking.setDob(DateUtils.getDate(2007, 7, 3)); // Earliest possible date to be 5 at start of camp
assertEquals("Elfins are not free", 112d, pricer.priceOf(woodchipBooking), 0);
woodchipBooking.setDob(DateUtils.getDate(2007, 7, 4)); // Latest possible date to be 4 at start of camp
assertEquals("Woodchips are free", 0d, pricer.priceOf(woodchipBooking), 0);
Booking missingDOBBooking = Booking.create(testUnit, vcamp, testClock);
missingDOBBooking.setDob(null);
assertEquals("Those without a DOB are regular price", 112d, pricer.priceOf(missingDOBBooking), 0);
woodchipBooking.setBookingCreationDate(BasicVCampTestDataFixture.DATE_AFTER_DEADLINE_BEFORE_AMMENDMENT);
assertEquals("Late woodchip bookings have an admin fee", 10d, pricer.priceOf(woodchipBooking), 0);