### Question:
ConfigGetParameterHandler { public long getLong(String key) { Long activatedLong = getLongFromCache(activatedConfigsCache, key); if (activatedLong != null) { return activatedLong; } Long defaultsLong = getLongFromCache(defaultConfigsCache, key); if (defaultsLong != null) { return defaultsLong; } logParameterValueDoesNotExist(key, "Long"); return DEFAULT_VALUE_FOR_LONG; } 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 getLong_activatedAndDefaultsKeysExist_returnsActivatedValue() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of(LONG_KEY, ACTIVATED_LONG_VALUE)); loadDefaultsCacheWithMap(ImmutableMap.of(LONG_KEY, DEFAULTS_LONG_VALUE)); long longValue = getHandler.getLong(LONG_KEY); assertThat(longValue).isEqualTo(ACTIVATED_LONG_VALUE); }
@Test public void getLong_noActivatedKeyButDefaultsKeyExists_returnsDefaultsValue() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of()); loadDefaultsCacheWithMap(ImmutableMap.of(LONG_KEY, DEFAULTS_LONG_VALUE)); long longValue = getHandler.getLong(LONG_KEY); assertThat(longValue).isEqualTo(DEFAULTS_LONG_VALUE); }
@Test public void getLong_activatedAndDefaultsKeysDoNotExist_returnsStaticDefault() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of()); loadDefaultsCacheWithMap(ImmutableMap.of()); long longValue = getHandler.getLong(LONG_KEY); assertThat(longValue).isEqualTo(DEFAULT_VALUE_FOR_LONG); }
@Test public void getLong_activatedKeyExistsAndNoDefaultsConfigs_returnsActivatedValue() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of(LONG_KEY, ACTIVATED_LONG_VALUE)); loadCacheWithConfig(mockDefaultsCache, null); long longValue = getHandler.getLong(LONG_KEY); assertThat(longValue).isEqualTo(ACTIVATED_LONG_VALUE); }
@Test public void getLong_noActivatedConfigsButDefaultsKeyExists_returnsDefaultsValue() throws Exception { loadCacheWithConfig(mockActivatedCache, null); loadDefaultsCacheWithMap(ImmutableMap.of(LONG_KEY, DEFAULTS_LONG_VALUE)); long longValue = getHandler.getLong(LONG_KEY); assertThat(longValue).isEqualTo(DEFAULTS_LONG_VALUE); }
@Test public void getLong_activatedAndDefaultsConfigsDoNotExist_returnsStaticDefault() { loadCacheWithConfig(mockActivatedCache, null); loadCacheWithConfig(mockDefaultsCache, null); long longValue = getHandler.getLong(LONG_KEY); assertThat(longValue).isEqualTo(DEFAULT_VALUE_FOR_LONG); }
@Test public void getLong_activatedStillLoadingFromDisk_blocksAndReturnsActivatedValue() throws Exception { loadActivatedAsyncCacheWithIncompleteTask(); loadActivatedBlockingCacheWith(ImmutableMap.of(LONG_KEY, ACTIVATED_LONG_VALUE)); long longValue = getHandler.getLong(LONG_KEY); assertThat(longValue).isEqualTo(ACTIVATED_LONG_VALUE); }