### Question:
PreferencesBasedRepository implements Repository { @Override public DateAtMidnight lastFeedbackDate() { long timestamp = prefs.getLong("last_feedback_timestamp"); if (timestamp == 0L) return null; return DateAtMidnight.from(timestamp); } PreferencesBasedRepository(Preferences prefs); @Override Set<MiniHabit> findAll(); @Override void add(MiniHabit miniHabit); @Override void update(Collection<MiniHabit> list); @Override void updateProgressDate(DateAtMidnight aDate); @Override DateAtMidnight lastFeedbackDate();  }### Answer:
@Test public void no_lastFeedbackDate() { context.checking(new Expectations() {{ oneOf(preferences).getLong("last_feedback_timestamp"); will(returnValue(0L)); }}); assertNull(repo.lastFeedbackDate()); }
@Test public void lastFeedbackDate() { context.checking(new Expectations() {{ oneOf(preferences).getLong("last_feedback_timestamp"); will(returnValue(1495144800000L)); }}); assertEquals(DateAtMidnight.from(DateFactory.date("19 May 2017")), repo.lastFeedbackDate()); }