@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())); }