public static void stubGetAndSetHierarchy(DraweeController controller) {
    final DraweeHierarchy[] dhHolder = new DraweeHierarchy[1];
    doAnswer(
            new Answer<Object>() {
              @Override
              public Object answer(InvocationOnMock invocation) throws Throwable {
                return dhHolder[0];
              }
            })
        .when(controller)
        .getHierarchy();
    doAnswer(
            new Answer() {
              @Override
              public Object answer(InvocationOnMock invocation) throws Throwable {
                return dhHolder[0] = (DraweeHierarchy) invocation.getArguments()[0];
              }
            })
        .when(controller)
        .setHierarchy((DraweeHierarchy) any());
  }
Stubs setHierarchy and getHierarchy methods.

@param controller controller to stub methods of
drawee/src/test/java/com/facebook/drawee/testing/DraweeMocks.java