BinaryPreferences implements Preferences { @Override public Map<String, Object> getAll() { return fetchStrategy.getAll(); } BinaryPreferences(FileTransaction fileTransaction,
                      EventBridge eventsBridge,
                      CacheCandidateProvider cacheCandidateProvider,
                      CacheProvider cacheProvider,
                      TaskExecutor taskExecutor,
                      SerializerFactory serializerFactory,
                      LockFactory lockFactory,
                      FetchStrategy fetchStrategy); @Override Map<String, Object> getAll(); @Override String getString(String key, String defValue); @Override Set<String> getStringSet(String key, Set<String> defValue); @Override int getInt(String key, int defValue); @Override long getLong(String key, long defValue); @Override float getFloat(String key, float defValue); @Override boolean getBoolean(String key, boolean defValue); @SuppressWarnings("unchecked") @Override T getPersistable(String key, T defValue); @Override byte getByte(String key, byte defValue); @Override short getShort(String key, short defValue); @Override char getChar(String key, char defValue); @Override double getDouble(String key, double defValue); @Override byte[] getByteArray(String key, byte[] defValue); @Override boolean contains(String key); @Override PreferencesEditor edit(); @Override Set<String> keys(); @Override void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener); @Override void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener listener);  }
@Test public void getAllDefaultValue() { Map<String, ?> all = preferences.getAll(); assertTrue(all.isEmpty()); }
@Test public void getAll() { String stringKey = String.class.getSimpleName().toLowerCase() + KEY_SUFFIX; String stringValue = "value"; String booleanKey = boolean.class.getSimpleName().toLowerCase() + KEY_SUFFIX; preferences.edit() .putString(stringKey, stringValue) .putBoolean(booleanKey, true) .apply(); Map<String, ?> all = preferences.getAll(); Object str = all.get(stringKey); Object bool = all.get(booleanKey); assertEquals(str.getClass(), String.class); assertEquals(bool.getClass(), Boolean.class); assertEquals(str, stringValue); assertEquals(true, bool); }