@Before
  public void setUp() {
    MockitoAnnotations.initMocks(this);
    mEncodedMemoryCacheProducer =
        new EncodedMemoryCacheProducer(mMemoryCache, mCacheKeyFactory, mInputProducer);
    mPooledByteBuffer1 = mock(PooledByteBuffer.class);
    mPooledByteBuffer2 = mock(PooledByteBuffer.class);
    mFinalImageReference = CloseableReference.of(mPooledByteBuffer1);
    mIntermediateImageReference = CloseableReference.of(mPooledByteBuffer2);
    mFinalImageReferenceClone = mFinalImageReference.clone();
    mFinalEncodedImage = new EncodedImage(mFinalImageReference);
    mFinalEncodedImage.setImageFormat(new ImageFormat("jpeg", null));
    mFinalEncodedImage.setWidth(100);
    mFinalEncodedImage.setHeight(100);
    mImagePipelineConfig = mock(ImagePipelineConfig.class);
    mImagePipelineExperiments = mock(ImagePipelineExperiments.class);

    mFinalEncodedImageFormatUnknown = new EncodedImage(mFinalImageReference);
    mIntermediateEncodedImage = new EncodedImage(mIntermediateImageReference);
    mFinalEncodedImageClone = new EncodedImage(mFinalImageReferenceClone);
    List<CacheKey> list = new ArrayList<>();
    list.add(new SimpleCacheKey("http://dummy.uri"));
    mCacheKey = new MultiCacheKey(list);
    when(mCacheKeyFactory.getEncodedCacheKey(mImageRequest, mCallerContext)).thenReturn(mCacheKey);

    when(mMemoryCache.cache(mCacheKey, mFinalImageReference)).thenReturn(mFinalImageReferenceClone);
    when(mProducerContext.getImageRequest()).thenReturn(mImageRequest);
    when(mProducerContext.getCallerContext()).thenReturn(mCallerContext);
    when(mProducerContext.getProducerListener()).thenReturn(mProducerListener);
    when(mProducerListener.requiresExtraMap(mProducerContext, PRODUCER_NAME)).thenReturn(true);
    when(mProducerContext.getLowestPermittedRequestLevel())
        .thenReturn(ImageRequest.RequestLevel.FULL_FETCH);
    when(mProducerContext.getImagePipelineConfig()).thenReturn(mImagePipelineConfig);
    when(mImagePipelineConfig.getExperiments()).thenReturn(mImagePipelineExperiments);
    when(mImagePipelineExperiments.isEncodedCacheEnabled()).thenReturn(true);

    setUpCacheEnabled(true);
  }
Checks basic properties of encoded 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, then it is put into the disk cache. - responses from the next producer are passed back
down to the consumer.
imagepipeline/src/test/java/com/facebook/imagepipeline/producers/EncodedMemoryCacheProducerTest.java