### Question:
ConfigGetParameterHandler { public double getDouble(String key) { Double activatedDouble = getDoubleFromCache(activatedConfigsCache, key); if (activatedDouble != null) { return activatedDouble; } Double defaultsDouble = getDoubleFromCache(defaultConfigsCache, key); if (defaultsDouble != null) { return defaultsDouble; } logParameterValueDoesNotExist(key, "Double"); return DEFAULT_VALUE_FOR_DOUBLE; } ConfigGetParameterHandler(
      ConfigCacheClient activatedConfigsCache, ConfigCacheClient defaultConfigsCache); String getString(String key); boolean getBoolean(String key); byte[] getByteArray(String key); double getDouble(String key); long getLong(String key); FirebaseRemoteConfigValue getValue(String key); Set<String> getKeysByPrefix(String prefix); Map<String, FirebaseRemoteConfigValue> getAll(); @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
  static final Charset FRC_BYTE_ARRAY_ENCODING; }### Answer:
@Test public void getDouble_activatedAndDefaultsKeysExist_returnsActivatedValue() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of(DOUBLE_KEY, ACTIVATED_DOUBLE_VALUE)); loadDefaultsCacheWithMap(ImmutableMap.of(DOUBLE_KEY, DEFAULTS_DOUBLE_VALUE)); double doubleValue = getHandler.getDouble(DOUBLE_KEY); assertThat(doubleValue).isEqualTo(ACTIVATED_DOUBLE_VALUE); }
@Test public void getDouble_noActivatedKeyButDefaultsKeyExists_returnsDefaultsValue() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of()); loadDefaultsCacheWithMap(ImmutableMap.of(DOUBLE_KEY, DEFAULTS_DOUBLE_VALUE)); double doubleValue = getHandler.getDouble(DOUBLE_KEY); assertThat(doubleValue).isEqualTo(DEFAULTS_DOUBLE_VALUE); }
@Test public void getDouble_activatedAndDefaultsKeysDoNotExist_returnsStaticDefault() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of()); loadDefaultsCacheWithMap(ImmutableMap.of()); double doubleValue = getHandler.getDouble(DOUBLE_KEY); assertThat(doubleValue).isEqualTo(DEFAULT_VALUE_FOR_DOUBLE); }
@Test public void getDouble_activatedKeyExistsAndNoDefaultsConfigs_returnsActivatedValue() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of(DOUBLE_KEY, ACTIVATED_DOUBLE_VALUE)); loadCacheWithConfig(mockDefaultsCache, null); double doubleValue = getHandler.getDouble(DOUBLE_KEY); assertThat(doubleValue).isEqualTo(ACTIVATED_DOUBLE_VALUE); }
@Test public void getDouble_noActivatedConfigsButDefaultsKeyExists_returnsDefaultsValue() throws Exception { loadCacheWithConfig(mockActivatedCache, null); loadDefaultsCacheWithMap(ImmutableMap.of(DOUBLE_KEY, DEFAULTS_DOUBLE_VALUE)); double doubleValue = getHandler.getDouble(DOUBLE_KEY); assertThat(doubleValue).isEqualTo(DEFAULTS_DOUBLE_VALUE); }
@Test public void getDouble_activatedAndDefaultsConfigsDoNotExist_returnsStaticDefault() { loadCacheWithConfig(mockActivatedCache, null); loadCacheWithConfig(mockDefaultsCache, null); double doubleValue = getHandler.getDouble(DOUBLE_KEY); assertThat(doubleValue).isEqualTo(DEFAULT_VALUE_FOR_DOUBLE); }
@Test public void getDouble_activatedStillLoadingFromDisk_blocksAndReturnsActivatedValue() throws Exception { loadActivatedAsyncCacheWithIncompleteTask(); loadActivatedBlockingCacheWith(ImmutableMap.of(DOUBLE_KEY, ACTIVATED_DOUBLE_VALUE)); double doubleValue = getHandler.getDouble(DOUBLE_KEY); assertThat(doubleValue).isEqualTo(ACTIVATED_DOUBLE_VALUE); }