@Test
public void testDefaultCacheKeyFactory_buildCacheKey() {

  Uri testUri = Uri.parse("test");
  String key = "key";
  // If DataSpec.key is present, returns it.
  assertThat(
          CacheUtil.DEFAULT_CACHE_KEY_FACTORY.buildCacheKey(
              new DataSpec(testUri, 0, LENGTH_UNSET, key)))
      .isEqualTo(key);
  // If not generates a new one using DataSpec.uri.
  assertThat(
          CacheUtil.DEFAULT_CACHE_KEY_FACTORY.buildCacheKey(
              new DataSpec(testUri, 0, LENGTH_UNSET, null)))
      .isEqualTo(testUri.toString());
}