@Test public void testInvalid() { Set<Holiday> result = new HashSet<>(); Holidays config = new Holidays(); RelativeToWeekdayInMonth rule = new RelativeToWeekdayInMonth(); rule.setWeekday(Weekday.TUESDAY); rule.setWhen(When.AFTER); FixedWeekdayInMonth date = new FixedWeekdayInMonth(); date.setWhich(Which.SECOND); date.setWeekday(Weekday.MONDAY); date.setMonth(Month.JULY); rule.setFixedWeekday(date); config.getRelativeToWeekdayInMonth().add(rule); rule.setValidFrom(2012); rtwim.parse(2011, result, config); Assert.assertTrue("Result is not empty.", result.isEmpty()); }
@Test public void testTueAfter2ndMondayJuly() { Set<Holiday> result = new HashSet<>(); Holidays config = new Holidays(); RelativeToWeekdayInMonth rule = new RelativeToWeekdayInMonth(); rule.setWeekday(Weekday.TUESDAY); rule.setWhen(When.AFTER); FixedWeekdayInMonth date = new FixedWeekdayInMonth(); date.setWhich(Which.SECOND); date.setWeekday(Weekday.MONDAY); date.setMonth(Month.JULY); rule.setFixedWeekday(date); config.getRelativeToWeekdayInMonth().add(rule); rtwim.parse(2011, result, config); Assert.assertEquals("Wrong number of dates.", 1, result.size()); Assert.assertEquals( "Wrong date.", calendarUtil.create(2011, 7, 12), result.iterator().next().getDate()); }