@Test
  public void testDiskCacheGetCancelled() {
    setUpDiskCacheProducerEnabled(true);
    setupDiskCacheGetWait(mDefaultBufferedDiskCache);
    mDiskCacheReadProducer.produceResults(mConsumer, mProducerContext);
    verify(mConsumer, never()).onCancellation();
    assertFalse(mIsCancelled.getValue().get());
    mProducerContext.cancel();
    assertTrue(mIsCancelled.getValue().get());
    mTaskCompletionSource.trySetCancelled();
    verify(mConsumer).onCancellation();
    verify(mInputProducer, never()).produceResults(any(Consumer.class), eq(mProducerContext));
    verify(mProducerListener).onProducerStart(mProducerContext, PRODUCER_NAME);
    verify(mProducerListener)
        .onProducerFinishWithCancellation(mProducerContext, PRODUCER_NAME, null);
    verify(mProducerListener, never())
        .onProducerFinishWithFailure(
            eq(mProducerContext), any(String.class), any(Exception.class), any(Map.class));
    verify(mProducerListener, never())
        .onProducerFinishWithSuccess(eq(mProducerContext), any(String.class), any(Map.class));
    verify(mProducerListener, never())
        .onUltimateProducerReached(eq(mProducerContext), anyString(), anyBoolean());
  }
Checks basic properties of disk cache producer operation, that is: - it delegates to the {@link
BufferedDiskCache#get(CacheKey key, AtomicBoolean isCancelled)} - it returns a 'copy' of the
cached value - if {@link BufferedDiskCache#get(CacheKey key, AtomicBoolean isCancelled)} is
unsuccessful, then it passes the request to the next producer in the sequence. - if the next
producer returns the value, then it is put into the disk cache.
imagepipeline/src/test/java/com/facebook/imagepipeline/producers/DiskCacheReadProducerTest.java