### Question:
SixMonthlyExpiryDayValidator extends ExpiryDayValidator { protected int plusMonths() { return 6; } SixMonthlyExpiryDayValidator(int expiryDays, String period); String getDateFormat();  }### Answer:
@Test public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferenceExpiryDays() { LocalDate periodDate = new LocalDate(); int previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear( previousPeriodStart == PREVIOUS_PERIOD_START_JANUARY ? DateTimeConstants.JANUARY : DateTimeConstants.JULY).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(6), new LocalDate()).getDays(); SixMonthlyExpiryDayValidator monthlyExpiryDayValidator = new SixMonthlyExpiryDayValidator( expiryDays, periodDate.toString(PATTERN) + previousPeriodStart); assertFalse(monthlyExpiryDayValidator.canEdit()); }
@Test public void testCanEditPreviousPeriodEndsSameTodayMinusDifferencePlusTwoExpiryDays() { LocalDate periodDate = new LocalDate(); int previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear( previousPeriodStart == PREVIOUS_PERIOD_START_JANUARY ? DateTimeConstants.JANUARY : DateTimeConstants.JULY).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(6), new LocalDate()).getDays() + 2; SixMonthlyExpiryDayValidator monthlyExpiryDayValidator = new SixMonthlyExpiryDayValidator( expiryDays, periodDate.toString(PATTERN) + previousPeriodStart); assertTrue(monthlyExpiryDayValidator.canEdit()); }
@Test public void testCanNotEditPreviousPeriodEndsSameTodayMinusDifferencePlusOneExpiryDays() { LocalDate periodDate = new LocalDate(); int previousPeriodStart = getPreviousPeriodStart(); periodDate = periodDate.withMonthOfYear( previousPeriodStart == PREVIOUS_PERIOD_START_JANUARY ? DateTimeConstants.JANUARY : DateTimeConstants.JULY).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(6), new LocalDate()).getDays() + 1; SixMonthlyExpiryDayValidator monthlyExpiryDayValidator = new SixMonthlyExpiryDayValidator( 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_JANUARY ? DateTimeConstants.JANUARY : DateTimeConstants.JULY).withDayOfMonth(1); int expiryDays = Days.daysBetween(periodDate.plusMonths(6), new LocalDate()).getDays() - 1; SixMonthlyExpiryDayValidator monthlyExpiryDayValidator = new SixMonthlyExpiryDayValidator( expiryDays, periodDate.toString(PATTERN) + previousPeriodStart); assertFalse(monthlyExpiryDayValidator.canEdit()); }