### Question:
CdsImmDateLogic { static LocalDate getPreviousImmDate(LocalDate date) { int day = date.getDayOfMonth(); int month = date.getMonthValue(); int year = date.getYear(); if (month % 3 == 0) { if (day > IMM_DAY) { return LocalDate.of(year, month, IMM_DAY); } else { if (month != 3) { return LocalDate.of(year, month - 3, IMM_DAY); } else { return LocalDate.of(year - 1, IMM_MONTHS.get(3), IMM_DAY); } } } else { int i = month / 3; if (i == 0) { return LocalDate.of(year - 1, IMM_MONTHS.get(3), IMM_DAY); } else { return LocalDate.of(year, IMM_MONTHS.get(i - 1), IMM_DAY); } } } private  CdsImmDateLogic();   }### Answer:
@Test public void onImmDateTest() { LocalDate today = LocalDate.of(2013, Month.MARCH, 20); LocalDate prevIMM = CdsImmDateLogic.getPreviousImmDate(today); assertThat(prevIMM).isEqualTo(LocalDate.of(2012, Month.DECEMBER, 20)); today = LocalDate.of(2017, Month.JUNE, 20); prevIMM = CdsImmDateLogic.getPreviousImmDate(today); assertThat(LocalDate.of(2017, Month.MARCH, 20)).isEqualTo(prevIMM); today = LocalDate.of(2011, Month.SEPTEMBER, 20); prevIMM = CdsImmDateLogic.getPreviousImmDate(today); assertThat(LocalDate.of(2011, Month.JUNE, 20)).isEqualTo(prevIMM); today = LocalDate.of(2015, Month.DECEMBER, 20); prevIMM = CdsImmDateLogic.getPreviousImmDate(today); assertThat(LocalDate.of(2015, Month.SEPTEMBER, 20)).isEqualTo(prevIMM); }
@Test public void previousImmTest() { LocalDate today = LocalDate.of(2011, Month.JUNE, 21); LocalDate prevIMM = CdsImmDateLogic.getPreviousImmDate(today); assertThat(LocalDate.of(2011, Month.JUNE, 20)).isEqualTo(prevIMM); prevIMM = CdsImmDateLogic.getPreviousImmDate(CdsImmDateLogic.getPreviousImmDate(prevIMM)); assertThat(LocalDate.of(2010, Month.DECEMBER, 20)).isEqualTo(prevIMM); today = LocalDate.of(2011, Month.JUNE, 18); prevIMM = CdsImmDateLogic.getPreviousImmDate(today); assertThat(LocalDate.of(2011, Month.MARCH, 20)).isEqualTo(prevIMM); today = LocalDate.of(1976, Month.JULY, 30); prevIMM = CdsImmDateLogic.getPreviousImmDate(today); assertThat(LocalDate.of(1976, Month.JUNE, 20)).isEqualTo(prevIMM); today = LocalDate.of(1977, Month.FEBRUARY, 13); prevIMM = CdsImmDateLogic.getPreviousImmDate(today); assertThat(LocalDate.of(1976, Month.DECEMBER, 20)).isEqualTo(prevIMM); today = LocalDate.of(2013, Month.MARCH, 1); prevIMM = CdsImmDateLogic.getPreviousImmDate(today); assertThat(LocalDate.of(2012, Month.DECEMBER, 20)).isEqualTo(prevIMM); }