### Question:
BimonthlyExpiryDayValidator extends ExpiryDayValidator { protected int plusMonths() { return 2; } BimonthlyExpiryDayValidator(int expiryDays, String period);   }### Answer:
@Test public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferenceExpiryDays() { LocalDate periodDate = new LocalDate(); String previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear(monthStart(previousPeriodStart)).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(2), new LocalDate()).getDays(); BimonthlyExpiryDayValidator monthlyExpiryDayValidator = new BimonthlyExpiryDayValidator( expiryDays, String.format(periodDate.toString(PATTERN), previousPeriodStart)); assertFalse(monthlyExpiryDayValidator.canEdit()); }
@Test public void testCanEditPreviousPeriodEndsSameTodayMinusDifferencePlusTwoExpiryDays() { LocalDate periodDate = new LocalDate(); String previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear(monthStart(previousPeriodStart)).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(2), new LocalDate()).getDays() + 2; BimonthlyExpiryDayValidator monthlyExpiryDayValidator = new BimonthlyExpiryDayValidator( expiryDays, String.format(periodDate.toString(PATTERN), previousPeriodStart)); assertTrue(monthlyExpiryDayValidator.canEdit()); }
@Test public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferencePlusOneExpiryDays() { LocalDate periodDate = new LocalDate(); String previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear(monthStart(previousPeriodStart)).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(2), new LocalDate()).getDays() + 1; BimonthlyExpiryDayValidator monthlyExpiryDayValidator = new BimonthlyExpiryDayValidator( expiryDays, String.format(periodDate.toString(PATTERN), previousPeriodStart)); assertFalse(monthlyExpiryDayValidator.canEdit()); }
@Test public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferenceMinusOneExpiryDays() { LocalDate periodDate = new LocalDate(); String previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear(monthStart(previousPeriodStart)).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(2), new LocalDate()).getDays() - 1; BimonthlyExpiryDayValidator monthlyExpiryDayValidator = new BimonthlyExpiryDayValidator( expiryDays, String.format(periodDate.toString(PATTERN), previousPeriodStart)); assertFalse(monthlyExpiryDayValidator.canEdit()); }