@Test
 public void testEmpty() {
   final HolidayMap aHolidays = new HolidayMap();
   final Holidays config = new Holidays();
   s_aParser.parse(2011, aHolidays, config);
   assertTrue("Result is not empty.", aHolidays.isEmpty());
 }
Пример #2
0
 @Test
 public void testLevel2() throws Exception {
   final IHolidayManager m = HolidayManagerFactory.getHolidayManager("test");
   final HolidayMap holidays = m.getHolidays(2010, "level1", "level2");
   assertNotNull(holidays);
   assertEquals("Wrong number of dates.", test_days_l2.size(), holidays.size());
   assertDates(test_days_l2, holidays);
 }
Пример #3
0
 @Test
 public void testChronology() throws Exception {
   final IHolidayManager aMgr = HolidayManagerFactory.getHolidayManager("test");
   final HolidayMap aHolidays = aMgr.getHolidays(2010);
   for (final LocalDate aDate : aHolidays.getMap().keySet()) {
     assertEquals(
         "Wrong chronology for date " + aDate,
         PDTConfig.getDefaultChronologyUTC(),
         aDate.getChronology());
   }
 }
Пример #4
0
 private void assertDates(final Set<LocalDate> dates, final HolidayMap holidays) {
   for (final LocalDate d : dates) {
     if (!holidays.containsHolidayForDate(d)) {
       fail("Missing " + d + " in " + holidays);
     }
   }
 }
 @Test
 public void testInvalid() {
   final HolidayMap aHolidays = new HolidayMap();
   final Holidays config = new Holidays();
   final FixedWeekdayRelativeToFixed rule = new FixedWeekdayRelativeToFixed();
   rule.setWhich(Which.FIRST);
   rule.setWeekday(Weekday.MONDAY);
   rule.setWhen(When.BEFORE);
   final Fixed fixed = new Fixed();
   fixed.setDay(Integer.valueOf(29));
   fixed.setMonth(Month.JANUARY);
   rule.setDay(fixed);
   config.getFixedWeekdayRelativeToFixed().add(rule);
   rule.setValidTo(Integer.valueOf(2010));
   s_aParser.parse(2011, aHolidays, config);
   assertTrue("Result is not empty.", aHolidays.isEmpty());
 }
 @Test
 public void testParserSecondBefore() {
   final HolidayMap aHolidays = new HolidayMap();
   final Holidays config = new Holidays();
   final FixedWeekdayRelativeToFixed rule = new FixedWeekdayRelativeToFixed();
   rule.setWhich(Which.SECOND);
   rule.setWeekday(Weekday.MONDAY);
   rule.setWhen(When.BEFORE);
   final Fixed fixed = new Fixed();
   fixed.setDay(Integer.valueOf(29));
   fixed.setMonth(Month.JANUARY);
   rule.setDay(fixed);
   config.getFixedWeekdayRelativeToFixed().add(rule);
   s_aParser.parse(2011, aHolidays, config);
   assertEquals("Wrong number of dates.", 1, aHolidays.size());
   assertEquals(
       "Wrong date.",
       PDTFactory.createLocalDate(2011, 1, 17),
       ContainerHelper.getFirstElement(aHolidays.getAllDates()));
 }
 @Test
 public void testParserFourthAfter() {
   final HolidayMap aHolidays = new HolidayMap();
   final Holidays config = new Holidays();
   final FixedWeekdayRelativeToFixed rule = new FixedWeekdayRelativeToFixed();
   rule.setWhich(Which.FOURTH);
   rule.setWeekday(Weekday.TUESDAY);
   rule.setWhen(When.AFTER);
   final Fixed fixed = new Fixed();
   fixed.setDay(Integer.valueOf(15));
   fixed.setMonth(Month.MARCH);
   rule.setDay(fixed);
   config.getFixedWeekdayRelativeToFixed().add(rule);
   s_aParser.parse(2011, aHolidays, config);
   assertEquals("Wrong number of dates.", 1, aHolidays.size());
   assertEquals(
       "Wrong date.",
       PDTFactory.createLocalDate(2011, 4, 12),
       ContainerHelper.getFirstElement(aHolidays.getAllDates()));
 }