### Question:
CdsImmDateLogic { static LocalDate getNextSemiAnnualRollDate(LocalDate date) { int day = date.getDayOfMonth(); int month = date.getMonthValue(); int year = date.getYear(); if (isSemiAnnualRollDate(date)) { if (month == INDEX_ROLL_MONTHS.get(0)) { return LocalDate.of(year, INDEX_ROLL_MONTHS.get(1), IMM_DAY); } else { return LocalDate.of(year + 1, INDEX_ROLL_MONTHS.get(0), IMM_DAY); } } else { if (month < INDEX_ROLL_MONTHS.get(0)) { return LocalDate.of(year, INDEX_ROLL_MONTHS.get(0), IMM_DAY); } else if (month == INDEX_ROLL_MONTHS.get(0)) { if (day < IMM_DAY) { return LocalDate.of(year, month, IMM_DAY); } else { return LocalDate.of(year, INDEX_ROLL_MONTHS.get(1), IMM_DAY); } } else if (month < INDEX_ROLL_MONTHS.get(1)) { return LocalDate.of(year, INDEX_ROLL_MONTHS.get(1), IMM_DAY); } else if (month == INDEX_ROLL_MONTHS.get(1)) { if (day < IMM_DAY) { return LocalDate.of(year, month, IMM_DAY); } else { return LocalDate.of(year + 1, INDEX_ROLL_MONTHS.get(0), IMM_DAY); } } else { return LocalDate.of(year + 1, INDEX_ROLL_MONTHS.get(0), IMM_DAY); } } } private  CdsImmDateLogic();   }### Answer:
@Test public void getNextSemiAnnualRollDateTest() { LocalDate[] dates = new LocalDate[] {LocalDate.of(2013, 3, 14), LocalDate.of(2013, 6, 20), LocalDate.of(2013, 3, 20), LocalDate.of(2013, 9, 20), LocalDate.of(2013, 1, 21), LocalDate.of(2013, 3, 21), LocalDate.of(2013, 9, 19), LocalDate.of(2013, 9, 21), LocalDate.of(2013, 11, 21)}; LocalDate[] datesExp = new LocalDate[] {LocalDate.of(2013, 3, 20), LocalDate.of(2013, 9, 20), LocalDate.of(2013, 9, 20), LocalDate.of(2014, 3, 20), LocalDate.of(2013, 3, 20), LocalDate.of(2013, 9, 20), LocalDate.of(2013, 9, 20), LocalDate.of(2014, 3, 20), LocalDate.of(2014, 3, 20)}; for (int i = 0; i < dates.length; ++i) { assertThat(CdsImmDateLogic.getNextSemiAnnualRollDate(dates[i])).isEqualTo(datesExp[i]); } }