PreferenceManager { public void save(String userId, Map<String, String> preferences) throws ServerException { requireNonNull(userId, "Required non-null user id"); requireNonNull(preferences, "Required non-null preferences"); preferenceDao.setPreferences(userId, preferences); }  void save(String userId, Map<String, String> preferences); Map<String, String> update(String userId, Map<String, String> preferences); Map<String, String> find(String userId); Map<String, String> find(String userId, String keyFilter); void remove(String userId); void remove(String userId, List<String> names);  }
@Test(expectedExceptions = NullPointerException.class) public void shouldThrowNpeWhenSavePreferencesWithNullUser() throws Exception { preferenceManager.save(null, Collections.emptyMap()); }
@Test(expectedExceptions = NullPointerException.class) public void shouldThrowNpeWhenSavePreferencesWithNullPreferences() throws Exception { preferenceManager.save("user123", null); }
@Test public void shouldSavePreferences() throws Exception { preferenceManager.save("user123", Collections.emptyMap()); verify(preferenceDao).setPreferences("user123", Collections.emptyMap()); }