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