private void verifyListenerOnEviction(
      String[] resourceIds,
      long[] itemSizes,
      CacheEventListener.EvictionReason reason,
      long cacheSizeBeforeEviction) {
    int numberItems = resourceIds.length;
    ArgumentCaptor<CacheEvent> cacheEventCaptor = ArgumentCaptor.forClass(CacheEvent.class);
    mCacheEventListenerInOrder
        .verify(mCacheEventListener, times(numberItems))
        .onEviction(cacheEventCaptor.capture());

    boolean[] found = new boolean[numberItems];
    long runningCacheSize = cacheSizeBeforeEviction;

    // The eviction order is unknown so make allowances for them coming in different orders
    for (CacheEvent event : cacheEventCaptor.getAllValues()) {
      CacheEventAssert.assertThat(event).isNotNull();

      for (int i = 0; i < numberItems; i++) {
        if (!found[i] && resourceIds[i].equals(event.getResourceId())) {
          found[i] = true;
          CacheEventAssert.assertThat(event).hasItemSize(itemSizes[i]).hasEvictionReason(reason);
        }
      }

      runningCacheSize -= event.getItemSize();
      CacheEventAssert.assertThat(event).hasCacheSize(runningCacheSize);
    }

    // Ensure all resources were found
    for (int i = 0; i < numberItems; i++) {
      assertTrue(
          String.format("Expected eviction of resource %s but wasn't evicted", resourceIds[i]),
          found[i]);
    }
  }
Verify that multiple threads can write to the cache at the same time.
imagepipeline-base/src/test/java/com/facebook/cache/disk/DiskStorageCacheTest.java