title: Mock a method call from another class
body: <p>My code structure :</p>
  
  <pre><code>class A {
      void methodA() {
          //some code
          B b = new B();
          response = b.methodB(arg1, arg2);
          //some code using "response"
      }
  }
  </code></pre>
  
  <p>I am UNIT testing class A and don't want to actually call methodB(). Is there any way to mock this method call by a custom response. 
  I tried Mockito to mock this method call as below:</p>
  
  <pre><code>B classBMock = Mockito.mock(B.class);
  Mockito.when(classBMock.methodB(arg1, arg2)).thenReturn(customResponse);
  A objA = new A();
  objA.methodA();
  </code></pre>
  
  <p>On calling methodA() the above way I don't get customResponse when methodB() is called within A. But when I call methodB() with classBMock, I get the customResponse.
  Is there anyway I can get customResponse from methodB() while calling methodA().</p>