### Question:
StringSetPreference extends AbsPreference<Set<String>> { @SuppressLint("CommitPrefEdits") @Override public void set(Set<String> value) { getPreferences().edit().putStringSet(getKey(), value).apply(); } StringSetPreference(SharedPreferences preferences, String key);  StringSetPreference(SharedPreferences preferences, String key, Set<String> defaultValue); @Override Set<String> get(); @SuppressLint("CommitPrefEdits") @Override void set(Set<String> value);  }### Answer:
@Test public void saveStringSet() { Set<String> expected = new LinkedHashSet<>(); expected.add("Test1"); expected.add("Test2"); expected.add("Test3"); String key = "testKey"; StringSetPreference preference = new StringSetPreference(preferences, key); preference.set(expected); assertThat(preferences.getStringSet(key, null)).isEqualTo(expected); }
@Test public void setWithNull() { String key = "testKey1"; StringSetPreference preference = new StringSetPreference(preferences, key); preference.set(null); assertThat(preferences.getString(key, null)).isNull(); }