PreferenceStoreImpl implements PreferenceStore { @Override public <T> void putIfAbsent(final PreferenceScope scope, final String key, final T value) { if (!storage.exists(scope, key)) { put(scope, key, value); } } protected  PreferenceStoreImpl();   PreferenceStoreImpl(final PreferenceStorage storage,
                        final PreferenceScopeFactory scopeFactory,
                        final PreferenceScopeResolutionStrategy defaultScopeResolutionStrategy); @Inject  PreferenceStoreImpl(final PreferenceStorage storage,
                               final PreferenceScopeFactory scopeFactory,
                               @Customizable final PreferenceScopeResolutionStrategy defaultScopeResolutionStrategy,
                               final Instance<PreferenceScopeResolutionStrategy> preferenceScopeResolutionStrategy,
                               final InjectionPoint ip); @Override PreferenceScopeResolutionStrategyInfo getDefaultScopeResolutionStrategyInfo(); @Override PreferenceScopeResolver getDefaultScopeResolver(); @Override void put(final PreferenceScope scope,
                        final String key,
                        final T value); @Override void put(final PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo,
                        final String key,
                        final T value); @Override void put(final String key,
                        final T value); @Override void put(final PreferenceScope scope,
                        final Map<String, T> valueByKey); @Override void put(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo,
                        final Map<String, T> valueByKey); @Override void put(final Map<String, T> valueByKey); @Override void putIfAbsent(final PreferenceScope scope,
                                final String key,
                                final T value); @Override void putIfAbsent(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo,
                                final String key,
                                final T value); @Override void putIfAbsent(final String key,
                                final T value); @Override void putIfAbsent(final PreferenceScope scope,
                                final Map<String, T> valueByKey); @Override void putIfAbsent(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo,
                                final Map<String, T> valueByKey); @Override void putIfAbsent(final Map<String, T> valueByKey); @Override T get(final PreferenceScope scope,
                     final String key); @Override T get(final PreferenceScope scope,
                     final String key,
                     final T defaultValue); @Override T get(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo,
                     final String key); @Override T get(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo,
                     final String key,
                     final T defaultValue); @Override T get(final String key); @Override T get(final String key,
                     final T defaultValue); @Override PreferenceScopedValue<T> getScoped(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo,
                                                  final String key); @Override PreferenceScopedValue<T> getScoped(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo,
                                                  final String key,
                                                  final T defaultValue); @Override PreferenceScopedValue<T> getScoped(final String key); @Override PreferenceScopedValue<T> getScoped(final String key,
                                                  final T defaultValue); @Override Map<String, Object> search(final PreferenceScope scope,
                                      final Collection<String> keys); @Override Map<String, Object> search(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo,
                                      final Collection<String> keys); @Override Map<String, Object> search(final Collection<String> keys); @Override Map<String, PreferenceScopedValue<Object>> searchScoped(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo,
                                                                   final Collection<String> keys); @Override Map<String, PreferenceScopedValue<Object>> searchScoped(final Collection<String> keys); @Override Map<String, Object> all(final PreferenceScope scope); @Override Map<String, Object> all(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo); @Override Map<String, Object> all(); @Override Map<String, PreferenceScopedValue<Object>> allScoped(PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo); @Override Map<String, PreferenceScopedValue<Object>> allScoped(); @Override void remove(final PreferenceScope scope,
                       final String key); @Override void remove(final List<PreferenceScope> scopes,
                       final String key);  }
@Test public void putIfAbsentInScopeTest() { preferenceStore.putIfAbsent(allUsersEntireApplication, KEY, VALUE); preferenceStore.putIfAbsent(allUsersEntireApplication, KEY, VALUE); verify(storage, times(1)).write(allUsersEntireApplication, KEY, VALUE); }
@Test public void putIfAbsentInDefaultScopeOfAScopeResolutionStrategyTest() { preferenceStore.putIfAbsent(preferenceScopeResolutionStrategyInfo, KEY, VALUE); preferenceStore.putIfAbsent(preferenceScopeResolutionStrategyInfo, KEY, VALUE); verify(storage, times(1)).write(preferenceScopeResolutionStrategyInfo.defaultScope(), KEY, VALUE); }
@Test public void putIfAbsentInDefaultScopeTest() { preferenceStore.putIfAbsent(KEY, VALUE); preferenceStore.putIfAbsent(KEY, VALUE); verify(storage, times(1)).write(preferenceScopeResolutionStrategyInfo.defaultScope(), KEY, VALUE); }