Package uk.org.woodcraft.bookings.utils

Examples of uk.org.woodcraft.bookings.utils.TestClock


    Event event1 = CannedQueries.eventByName(TestConstants.EVENT1_NAME);
   
    List<Unit> testUnits = new ArrayList<Unit>(50);
    List<Booking> testBookings = new ArrayList<Booking>(50);
    List<String> testNames = new ArrayList<String>(52);
    TestClock clock = new TestClock(TestConstants.DATE_BEFORE_DEADLINE);
   
    for (int i = 0; i < 50; i++) {
      Unit testUnit = new Unit("Test Unit "+i, org, true);
      testUnits.add(testUnit);
    }
View Full Code Here


    Event event1 = CannedQueries.eventByName(TestConstants.EVENT1_NAME);
   
    List<Unit> testUnits = new ArrayList<Unit>(50);
    List<Transaction> testTransactions = new ArrayList<Transaction>(100);
    List<String> testTransNames = new ArrayList<String>(103);
    TestClock clock = new TestClock(TestConstants.DATE_BEFORE_DEADLINE);
   
    for (int i = 0; i < 50; i++) {
      Unit testUnit = new Unit("Test Unit "+i, org, true);
      testUnits.add(testUnit);
    }
    CannedQueries.save(testUnits);
   
    int transNumber = 0;
    for(Unit unit : testUnits)
    {
      String transName = "Test Trans "+transNumber++;
      testTransactions.add(new Transaction(unit.getKeyCheckNotNull(), event1.getKeyCheckNotNull(), clock.getTime(),
                        TransactionType.Payment,  transName, null, 1.0d));
      testTransNames.add(transName);
    }
    CannedQueries.save(testTransactions);
   
View Full Code Here

   
    Event vcamp = CannedQueries.eventByName(TestConstants.EVENT1_NAME);
    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);

View Full Code Here

   
    Event vcamp = CannedQueries.eventByName(TestConstants.EVENT1_NAME);
    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);
View Full Code Here

    try {
      //tx.begin();
     
      CoreData.createCoreData();
     
      Clock testClock = new TestClock(TestConstants.DATE_BEFORE_EARLY_DEADLINE);
     
      // Events
      List<Event> events = new ArrayList<Event>();
      Event event1 = getTestEvent();
     
      events.add(event1);
       Event event2 = new Event("Other event", null, null, true, RegisteredPricingStrategy.COCAMP);
      events.add(event2);   
     
      events.add(new Event("Closed event", null, null, false, RegisteredPricingStrategy.COCAMP))
      pm.makePersistentAll(events);
     
      // Villages
      List<Village> villages = new ArrayList<Village>();
      Village village1 = new Village(TestConstants.VILLAGE1_NAME, event1);
      villages.add(village1);
      villages.add(new Village("Village 2", event1));
      villages.add(new Village("Empty village", event1));
      villages.add(new Village("Village on other event", events.get(1)));
      pm.makePersistentAll(villages);
     
      // Organisations
      List<Organisation> organisations = new ArrayList<Organisation>();
      Organisation orgWcf = new Organisation(TestConstants.ORG1_NAME, true);
      organisations.add(orgWcf);
     
      Organisation otherOrg = new Organisation("Unapproved organisation", false);
      organisations.add(otherOrg);
      pm.makePersistentAll(organisations);
     
      // Units
      List<Unit> units = new ArrayList<Unit>();
      Unit unit1 = new Unit(TestConstants.UNIT1_NAME, organisations.get(0), true);
      unit1.setVillageKey(village1.getKeyCheckNotNull());
     
      // FIXME: Note, all units are in all events for now...
     
      //unit1.addEventRegistration(event1);
      //unit1.addEventRegistration(event2); 
      units.add(unit1);
     
      Unit unit2 = new Unit(TestConstants.UNIT2_NAME, organisations.get(0), true);
     
      // FIXME: Note, all units are in all events for now...
      //unit2.addEventRegistration(event1);
      units.add(unit2);
     
      Unit unapprovedWcfUnit = new Unit("Unapproved unit for wcf", organisations.get(0), false);
      units.add(unapprovedWcfUnit);
      Unit otherOrgUnit = new Unit("Unapproved unit", organisations.get(1), false);
      units.add(otherOrgUnit);
      Unit otherOrgUnit2 = new Unit("Approved unit in other org", organisations.get(1), true);
      units.add(otherOrgUnit2);
      pm.makePersistentAll(units);
     
      // Bookings
      List<Booking> bookings = getBookings(event1, event2, unit1, unit2, unapprovedWcfUnit, otherOrgUnit2);
      pm.makePersistentAll(bookings);
     
     
      // Transactions
      List<Transaction> transactions = new ArrayList<Transaction>();
      transactions.add(new Transaction(unit1.getKeyCheckNotNull(), event1.getKeyCheckNotNull(), testClock.getTime(), TransactionType.Payment, "Payment 1", "Comment 1", 23.32d));
      transactions.add(new Transaction(unit1.getKeyCheckNotNull(), event1.getKeyCheckNotNull(), testClock.getTime(), TransactionType.Payment, "Payment 2", "", 12.00d));
      transactions.add(new Transaction(unit1.getKeyCheckNotNull(), event1.getKeyCheckNotNull(), testClock.getTime(), TransactionType.Payment, "Payment 3", "", 130.00d));
     
      transactions.add(new Transaction(unit1.getKeyCheckNotNull(), event1.getKeyCheckNotNull(), testClock.getTime(), TransactionType.Adjustment, "Refund 1", "Refund test", -23.32d));
     
      transactions.add(new Transaction(unit2.getKeyCheckNotNull(), event1.getKeyCheckNotNull(), testClock.getTime(), TransactionType.Payment, "Unit 2 payment", "", 70.00d));
     
      // after earlybird deadline
      transactions.add(new Transaction(unit1.getKeyCheckNotNull(), event1.getKeyCheckNotNull(), afterEarlyBird.getTime(), TransactionType.Payment, "Payment after earlybird", "", 10.00d));
      transactions.add(new Transaction(unit1.getKeyCheckNotNull(), event1.getKeyCheckNotNull(), afterEarlyBird.getTime(), TransactionType.Discount, "Discount for early payment", "", 5.00d));
      pm.makePersistentAll(transactions);
View Full Code Here

 
  protected List<Booking> getBookings(Event event1, Event event2,
      Unit unit1, Unit unit2, Unit unapprovedWcfUnit, Unit otherOrgUnit2) {
   
    List<Booking> bookings = new ArrayList<Booking>();
    Clock testClock = new TestClock(TestConstants.DATE_BEFORE_EARLY_DEADLINE);
   
    // Before earlybird deadline
    Booking b = Booking.create("Test person", unit1, event1, testClock);
    b.setEmail("email@example.com");
    bookings.add(b);
View Full Code Here

   
    Event cocamp = CannedQueries.eventByName(TestConstants.EVENT1_NAME);
    Organisation testOrg = CannedQueries.orgByName(TestConstants.ORG1_NAME);
    Unit testUnit = CannedQueries.unitByName(TestConstants.UNIT1_NAME, testOrg);
   
    TestClock testClock = new TestClock(TestConstants.DATE_BEFORE_DEADLINE);
   
    Booking regularBooking = Booking.create(testUnit, cocamp, testClock);
    regularBooking.setArrivalDate(DateUtils.getDate(2011, 6, 30));
    regularBooking.setDepartureDate(DateUtils.getDate(2011, 7, 9));
    assertEquals("Regular bookings are 150", 150d, pricer.priceOf(regularBooking), 0);
   
    Booking bookingWithPreAndPostCamp = Booking.create(testUnit, cocamp, testClock);
    bookingWithPreAndPostCamp.setArrivalDate(DateUtils.getDate(2011, 6, 20));
    bookingWithPreAndPostCamp.setDepartureDate(DateUtils.getDate(2011, 7, 15));
    assertEquals("Bookings capped at 150 including pre and post camp", 150d, pricer.priceOf(bookingWithPreAndPostCamp), 0);
   
    Booking booking = Booking.create(testUnit, cocamp, testClock);
    booking.setArrivalDate(DateUtils.getDate(2011, 6, 30));
    booking.setDepartureDate(DateUtils.getDate(2011, 6, 31));
    assertEquals("1 night", 35 + 15d, pricer.priceOf(booking), 0);
   
    booking.setArrivalDate(DateUtils.getDate(2011, 6, 30));
    booking.setDepartureDate(DateUtils.getDate(2011, 7, 1));
    assertEquals("2 nights", 35 + 30d, pricer.priceOf(booking), 0);

    booking.setArrivalDate(DateUtils.getDate(2011, 6, 30));
    booking.setDepartureDate(DateUtils.getDate(2011, 7, 8));
    assertEquals("9 nights", 150d, pricer.priceOf(booking), 0);
   
   
    Clock clockAfterDeadline = new TestClock(TestConstants.DATE_AFTER_DEADLINE_BEFORE_AMMENDMENT)
    Booking lateBooking = Booking.create(testUnit,cocamp, clockAfterDeadline);
    lateBooking.setArrivalDate(DateUtils.getDate(2011, 6, 30));
    lateBooking.setDepartureDate(DateUtils.getDate(2011, 7, 9));
   
    assertEquals("Bookings after the deadline cost more", 175d, pricer.priceOf(lateBooking), 0);
View Full Code Here

   
    Event cocamp = CannedQueries.eventByName(TestConstants.EVENT1_NAME);
    Organisation testOrg = CannedQueries.orgByName(TestConstants.ORG1_NAME);
    Unit testUnit = CannedQueries.unitByName(TestConstants.UNIT1_NAME, testOrg);
   
    TestClock testClock = new TestClock(TestConstants.DATE_BEFORE_DEADLINE);
   
    Booking regularBooking = Booking.create(testUnit, cocamp, testClock);
    regularBooking.setArrivalDate(DateUtils.getDate(2011, 6, 30));
    regularBooking.setDepartureDate(DateUtils.getDate(2011, 7, 9));
    assertEquals("Regular bookings are 150", 150d, pricer.priceOf(regularBooking), 0);
View Full Code Here


  @Test
  public void testRelevantBookings()
  {
    TestClock clock = new TestClock(TestConstants.DATE_BEFORE_DEADLINE);
    Event event = CannedQueries.eventByName( TestConstants.EVENT1_NAME);
    Map<String, Object> session = new HashMap<String, Object>();
    ApplyCoCampDiscountsAction action = createNewAction(clock, event, session);
   
    Organisation testOrg = CannedQueries.orgByName(TestConstants.ORG1_NAME);
View Full Code Here

  }

  @Test
  public void testRelevantTransactions()
  {
    TestClock clock = new TestClock(TestConstants.DATE_BEFORE_DEADLINE);
    Event event = CannedQueries.eventByName( TestConstants.EVENT1_NAME);
    Map<String, Object> session = new HashMap<String, Object>();
    ApplyCoCampDiscountsAction action = createNewAction(clock, event, session);
   
    Organisation testOrg = CannedQueries.orgByName(TestConstants.ORG1_NAME);
View Full Code Here

TOP

Related Classes of uk.org.woodcraft.bookings.utils.TestClock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.