### Question:
ConfigGetParameterHandler { public byte[] getByteArray(String key) { String activatedString = getStringFromCache(activatedConfigsCache, key); if (activatedString != null) { return activatedString.getBytes(FRC_BYTE_ARRAY_ENCODING); } String defaultsString = getStringFromCache(defaultConfigsCache, key); if (defaultsString != null) { return defaultsString.getBytes(FRC_BYTE_ARRAY_ENCODING); } logParameterValueDoesNotExist(key, "ByteArray"); return DEFAULT_VALUE_FOR_BYTE_ARRAY; } 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 getByteArray_activatedAndDefaultsKeysExist_returnsActivatedValue() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of(BYTE_ARRAY_KEY, ACTIVATED_BYTE_ARRAY_STRING_VALUE)); loadDefaultsCacheWithMap(ImmutableMap.of(BYTE_ARRAY_KEY, DEFAULTS_BYTE_ARRAY_STRING_VALUE)); byte[] byteArrayValue = getHandler.getByteArray(BYTE_ARRAY_KEY); assertThat(byteArrayValue).isEqualTo(ACTIVATED_BYTE_ARRAY_VALUE); }
@Test public void getByteArray_noActivatedKeyButDefaultsKeyExists_returnsDefaultsValue() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of()); loadDefaultsCacheWithMap(ImmutableMap.of(BYTE_ARRAY_KEY, DEFAULTS_BYTE_ARRAY_STRING_VALUE)); byte[] byteArrayValue = getHandler.getByteArray(BYTE_ARRAY_KEY); assertThat(byteArrayValue).isEqualTo(DEFAULTS_BYTE_ARRAY_VALUE); }
@Test public void getByteArray_activatedAndDefaultsKeysDoNotExist_returnsStaticDefault() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of()); loadDefaultsCacheWithMap(ImmutableMap.of()); byte[] byteArrayValue = getHandler.getByteArray(BYTE_ARRAY_KEY); assertThat(byteArrayValue).isEqualTo(DEFAULT_VALUE_FOR_BYTE_ARRAY); }
@Test public void getByteArray_activatedKeyExistsAndNoDefaultsConfigs_returnsActivatedValue() throws Exception { loadActivatedCacheWithMap(ImmutableMap.of(BYTE_ARRAY_KEY, ACTIVATED_BYTE_ARRAY_STRING_VALUE)); loadCacheWithConfig(mockDefaultsCache, null); byte[] byteArrayValue = getHandler.getByteArray(BYTE_ARRAY_KEY); assertThat(byteArrayValue).isEqualTo(ACTIVATED_BYTE_ARRAY_VALUE); }
@Test public void getByteArray_noActivatedConfigsButDefaultsKeyExists_returnsDefaultsValue() throws Exception { loadCacheWithConfig(mockActivatedCache, null); loadDefaultsCacheWithMap(ImmutableMap.of(BYTE_ARRAY_KEY, DEFAULTS_BYTE_ARRAY_STRING_VALUE)); byte[] byteArrayValue = getHandler.getByteArray(BYTE_ARRAY_KEY); assertThat(byteArrayValue).isEqualTo(DEFAULTS_BYTE_ARRAY_VALUE); }
@Test public void getByteArray_activatedAndDefaultsConfigsDoNotExist_returnsStaticDefault() { loadCacheWithConfig(mockActivatedCache, null); loadCacheWithConfig(mockDefaultsCache, null); byte[] byteArrayValue = getHandler.getByteArray(BYTE_ARRAY_KEY); assertThat(byteArrayValue).isEqualTo(DEFAULT_VALUE_FOR_BYTE_ARRAY); }
@Test public void getByteArray_activatedStillLoadingFromDisk_blocksAndReturnsActivatedValue() throws Exception { loadActivatedAsyncCacheWithIncompleteTask(); loadActivatedBlockingCacheWith( ImmutableMap.of(BYTE_ARRAY_KEY, ACTIVATED_BYTE_ARRAY_STRING_VALUE)); byte[] byteArrayValue = getHandler.getByteArray(BYTE_ARRAY_KEY); assertThat(byteArrayValue).isEqualTo(ACTIVATED_BYTE_ARRAY_VALUE); }