### Question:
PreferencesBasedRepository implements Repository { @Override public void update(Collection<MiniHabit> list) { Set<MiniHabit> currentList = findAll(); currentList.removeAll(list); currentList.addAll(list); prefs.putString("mini_habits", asString(currentList)); prefs.flush(); } 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 update() { context.checking(new Expectations() {{ oneOf(preferences).getString("mini_habits"); will(returnValue("One Pushup:1,Cooking:3")); oneOf(preferences).putString("mini_habits", "Cooking:3,One Pushup:2"); oneOf(preferences).flush(); }}); repo.update(asSet(new MiniHabit("Cooking", 3), new MiniHabit("One Pushup", 2))); }