PreferenceStoreImpl implements PreferenceStore { @Override public boolean save(SharedPreferences.Editor editor) { editor.apply(); return true; } PreferenceStoreImpl(Context context, String name); @Override SharedPreferences get(); @Override SharedPreferences.Editor edit(); @Override boolean save(SharedPreferences.Editor editor);  }
@Test @SuppressLint("CommitPrefEdits") public void testSave() { final String key = "Test Key"; final String value = "Test Value"; final SharedPreferences.Editor editor = preferenceStore.edit(); editor.putString(key, value); assertTrue(preferenceStore.save(editor)); final String result = preferenceStore.get().getString(key, null); assertNotNull(result); assertEquals(value, result); }