@Test
  public void testRemoveAllMatchingPredicate() {
    // Cache has 4 entries; 2 for LFU and 2 for MFU
    // key is considered as MFU, if its accessCount > 1
    mCache =
        createDummyAdaptiveCountingMemoryCache(
            mParamsSupplier,
            mCacheTrimStrategy,
            mValueDescriptor,
            100,
            1,
            2,
            initialLFUCacheFractionPromil);

    // insert item1 to MFU
    CloseableReference<Integer> originalRef1 = newReference(10);
    CloseableReference<Integer> valueRef1 = mCache.cache(KEYS[1], originalRef1);
    CloseableReference<Integer> valueRef1a = mCache.get(KEYS[1]);
    originalRef1.close();
    valueRef1.close();
    valueRef1a.close();

    // insert item2 to LFU
    CloseableReference<Integer> originalRef2 = newReference(20);
    CloseableReference<Integer> valueRef2 = mCache.cache(KEYS[2], originalRef2);
    originalRef2.close();
    valueRef2.close();

    // insert item3 to the cache
    CloseableReference<Integer> originalRef3 = newReference(30);
    CloseableReference<Integer> valueRef3 = mCache.cache(KEYS[3], originalRef3);
    originalRef3.close();
    AbstractAdaptiveCountingMemoryCache.Entry<String, Integer> entry3 =
        mCache.mCachedEntries.get(KEYS[3]);

    int numEvictedEntries =
        mCache.removeAll(
            new Predicate<String>() {
              @Override
              public boolean apply(String key) {
                return key.equals(KEYS[2]) || key.equals(KEYS[3]);
              }
            });

    assertEquals(2, numEvictedEntries);
    assertNotCached(KEYS[2], 20);
    assertNotCached(KEYS[3], 30);

    assertTotalSize(1, 10);
    assertExclusivelyOwnedSize(1, 10);
    assertOrphanWithCount(entry3, 1);

    verify(mReleaser).release(20);
    verify(mReleaser, never()).release(30);

    valueRef3.close();
    verify(mReleaser).release(30);
  }
test: pass illegal adaptive rate and illegal initial LFU cache fraction. expected result: fall
back and use the default adaptive rate and initial LFU fraction values.
imagepipeline-base/src/test/java/com/facebook/imagepipeline/cache/AbstractAdaptiveCountingMemoryCacheTest.java