@Before
  public void setUp() {
    MockitoAnnotations.initMocks(this);
    mBitmapMemoryCacheProducer =
        new BitmapMemoryCacheProducer(mMemoryCache, mCacheKeyFactory, mInputProducer);
    mBitmapMemoryCacheKey = mock(BitmapMemoryCacheKey.class);
    mCloseableImage1 = mock(CloseableImage.class);
    when(mCloseableImage1.getQualityInfo()).thenReturn(ImmutableQualityInfo.FULL_QUALITY);
    mCloseableImage2 = mock(CloseableImage.class);
    when(mCloseableImage2.getQualityInfo())
        .thenReturn(ImmutableQualityInfo.of(INTERMEDIATE_SCAN_2, true, false));
    mFinalImageReference = CloseableReference.of(mCloseableImage1);
    mIntermediateImageReference = CloseableReference.of(mCloseableImage2);
    mFinalImageReferenceClone = mFinalImageReference.clone();
    mIntermediateImageReferenceClone = mIntermediateImageReference.clone();

    when(mMemoryCache.cache(mBitmapMemoryCacheKey, mIntermediateImageReference))
        .thenReturn(mIntermediateImageReferenceClone);
    when(mMemoryCache.cache(mBitmapMemoryCacheKey, mFinalImageReference))
        .thenReturn(mFinalImageReferenceClone);
    when(mProducerContext.getImageRequest()).thenReturn(mImageRequest);
    when(mProducerContext.getProducerListener()).thenReturn(mProducerListener);
    when(mProducerContext.getLowestPermittedRequestLevel())
        .thenReturn(ImageRequest.RequestLevel.FULL_FETCH);
    when(mProducerContext.getCallerContext()).thenReturn(PRODUCER_NAME);
    when(mProducerListener.requiresExtraMap(mProducerContext, PRODUCER_NAME)).thenReturn(true);
    when(mCacheKeyFactory.getBitmapCacheKey(mImageRequest, PRODUCER_NAME))
        .thenReturn(mBitmapMemoryCacheKey);

    when(mImageRequest.isMemoryCacheEnabled()).thenReturn(true);
    setUpCacheEnabled(true);
  }
Checks basic properties of bitmap memory cache producer operation, that is: - it delegates to the
{@link MemoryCache#get(Object)} - if {@link MemoryCache#get(Object)} is unsuccessful, then it
passes the request to the next producer in the sequence. - if the next producer returns the value
of higher quality, then it is put into the bitmap cache. - responses from the next producer are
passed back down to the consumer.
imagepipeline/src/test/java/com/facebook/imagepipeline/producers/BitmapMemoryCacheProducerTest.java