### Question:
TmsConverter { public Date rollForward(Date d, PeriodType periodType) { calendar.setTime(d); if (periodType == PeriodType.MONTH) { calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 1); } if (periodType == PeriodType.DAY) { calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1); } if (periodType == PeriodType.HOUR) { calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) + 1); } if (periodType == PeriodType.MINUTE) { calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 1); } if (periodType == PeriodType.SECOND) { calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + 1); } return calendar.getTime(); } TmsConverter();  TmsConverter(Calendar calendar); Date convert(Date d, PeriodType periodType); Date rollForward(Date d, PeriodType periodType); int minute(Date d); int hour(Date d); int day(Date d); int month(Date d);  }### Answer:
@Test public void rollForwardMonth() { final Date date = new Date(2018 - 1900, 10, 1); final PeriodType periodType = PeriodType.MONTH; converter.rollForward(date, periodType); verify(calendar).setTime(date); verify(calendar).set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 1); verify(calendar).getTime(); }
@Test public void rollForwardDay() { final Date date = new Date(2018 - 1900, 10, 1); final PeriodType periodType = PeriodType.DAY; converter.rollForward(date, periodType); verify(calendar).setTime(date); verify(calendar).set(Calendar.MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1); verify(calendar).getTime(); }
@Test public void rollForwardHour() { final Date date = new Date(2018 - 1900, 10, 1); final PeriodType periodType = PeriodType.HOUR; converter.rollForward(date, periodType); verify(calendar).setTime(date); verify(calendar).set(Calendar.MONTH, calendar.get(Calendar.HOUR_OF_DAY) + 1); verify(calendar).getTime(); }
@Test public void rollForwardMinute() { final Date date = new Date(2018 - 1900, 10, 1); final PeriodType periodType = PeriodType.MINUTE; converter.rollForward(date, periodType); verify(calendar).setTime(date); verify(calendar).set(Calendar.MONTH, calendar.get(Calendar.MINUTE) + 1); verify(calendar).getTime(); }
@Test public void rollForwardSecond() { final Date date = new Date(2018 - 1900, 10, 1); final PeriodType periodType = PeriodType.SECOND; converter.rollForward(date, periodType); verify(calendar).setTime(date); verify(calendar).set(Calendar.MONTH, calendar.get(Calendar.SECOND) + 1); verify(calendar).getTime(); }