### Question:
SixMonthlyAprilExpiryDayValidator extends SixMonthlyExpiryDayValidator { @Override protected int plusMonths() { return 6; } SixMonthlyAprilExpiryDayValidator(int expiryDays, String period); @Override String getDateFormat();  }### Answer:
@Test public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferencePlusOneExpiryDays() { LocalDate periodDate = new LocalDate(); int previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear( previousPeriodStart == PREVIOUS_PERIOD_START_APRIL ? DateTimeConstants.APRIL : DateTimeConstants.OCTOBER).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(6), new LocalDate()).getDays() + 1; SixMonthlyAprilExpiryDayValidator monthlyExpiryDayValidator = new SixMonthlyAprilExpiryDayValidator( expiryDays, periodDate.toString(PATTERN) + previousPeriodStart); assertFalse(monthlyExpiryDayValidator.canEdit()); }
@Test public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferenceMinusOneExpiryDays() { LocalDate periodDate = new LocalDate(); int previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear( previousPeriodStart == PREVIOUS_PERIOD_START_APRIL ? DateTimeConstants.APRIL : DateTimeConstants.OCTOBER).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(6), new LocalDate()).getDays() - 1; SixMonthlyAprilExpiryDayValidator monthlyExpiryDayValidator = new SixMonthlyAprilExpiryDayValidator( expiryDays, periodDate.toString(PATTERN) + previousPeriodStart); assertFalse(monthlyExpiryDayValidator.canEdit()); }
@Test public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferenceExpiryDays() { LocalDate periodDate = new LocalDate(); int previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear( previousPeriodStart == PREVIOUS_PERIOD_START_APRIL ? DateTimeConstants.APRIL : DateTimeConstants.OCTOBER).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(6), new LocalDate()).getDays(); SixMonthlyAprilExpiryDayValidator monthlyExpiryDayValidator = new SixMonthlyAprilExpiryDayValidator( expiryDays, periodDate.toString(PATTERN) + previousPeriodStart); assertFalse(monthlyExpiryDayValidator.canEdit()); }
@Test public void testCanEditWithPeriodPreviousMonthWithTwoMoreDaysAtExpiryDays() { LocalDate periodDate = new LocalDate(); int previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear( previousPeriodStart == PREVIOUS_PERIOD_START_APRIL ? DateTimeConstants.APRIL : DateTimeConstants.OCTOBER).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(6), new LocalDate()).getDays() + 2; SixMonthlyAprilExpiryDayValidator monthlyExpiryDayValidator = new SixMonthlyAprilExpiryDayValidator( expiryDays, periodDate.toString(PATTERN) + previousPeriodStart); assertTrue(monthlyExpiryDayValidator.canEdit()); }