### Question:
MainController { public DateAtMidnight nextFeedbackDate(DateAtMidnight currentDate) throws LastFeedbackDateUnavailableException { DateAtMidnight lastFeedbackDate = repository.lastFeedbackDate(); if (lastFeedbackDate == null) throw new LastFeedbackDateUnavailableException("Unable to find last feedback date"); List<DateAtMidnight> dates = DateAtMidnight.datesBetween(lastFeedbackDate, currentDate); return (! dates.isEmpty()) ? dates.get(0) : null; } MainController(Repository repository); void updateHabitsProgress(Set<MiniHabit> doneHabits, DateAtMidnight feedbackDate); DateAtMidnight nextFeedbackDate(DateAtMidnight currentDate); void addHabit(MiniHabit miniHabit); Collection<MiniHabit> allHabits();  }### Answer:
@Test(expected = LastFeedbackDateUnavailableException.class) public void no_next_feedback_date() throws LastFeedbackDateUnavailableException { context.checking(new Expectations() {{ oneOf(repository).lastFeedbackDate(); will(returnValue(null)); }}); assertNull(controller.nextFeedbackDate(from(date("20 May 2017")))); }
@Test public void returns_current_date_as_next_feedback_date() throws LastFeedbackDateUnavailableException { context.checking(new Expectations() {{ oneOf(repository).lastFeedbackDate(); will(returnValue(from(date("19 May 2017")))); }}); DateAtMidnight currentDate = from(date("20 May 2017")); assertEquals(currentDate, controller.nextFeedbackDate(currentDate)); }
@Test public void returns_the_day_before() throws LastFeedbackDateUnavailableException { context.checking(new Expectations() {{ oneOf(repository).lastFeedbackDate(); will(returnValue(from(date("19 May 2017")))); }}); assertEquals(from(date("20 May 2017")), controller.nextFeedbackDate(from(date("21 May 2017")))); }