@Test public void whenADateFallsOnNonWorkingDayItShouldBeAdjustedToTheNearestWorkingDay() { DateTime firstOfNextMonth = new DateTime().plusMonths(1).withDayOfMonth(1).toDateMidnight().toDateTime(); DateTime firstSaturdayOfNextMonth = firstOfNextMonth.withDayOfWeek(DayOfWeek.saturday()); // exercise test DateTime adjustedDate = workingDayStrategy.adjust(firstSaturdayOfNextMonth); assertThat(adjustedDate, is(firstSaturdayOfNextMonth.plusDays(2))); }
@Test public void whenADateFallsOnAWorkingDayItShouldNotBeAdjusted() { DateTime firstOfNextMonth = new DateTime().plusMonths(1).withDayOfMonth(1).toDateMidnight().toDateTime(); DateTime firstTuesdayOfNextMonth = firstOfNextMonth.withDayOfWeek(DayOfWeek.tuesday()); // exercise test DateTime adjustedDate = workingDayStrategy.adjust(firstTuesdayOfNextMonth); assertThat(adjustedDate, is(firstTuesdayOfNextMonth)); }