title: how to mock internal method call using mockito/powermockito
body: <p>I am testing a method in class which in turn calls another artifacts' method and consume return value in it.</p>
  
  <pre><code>public void methodToTest()
  {
        Object reply = artifactObj.anotherMethod(object);
        if(reply == null)
              return;
        Object =reply.getData();
  }
  </code></pre>
  
  <p>I have used powermockito and know that if "anotherMethod" existed inside the same class I could have easily spied it over. But I am not sure how can I do same when method is not in same class.</p>
  
  <p>My attempt-:</p>
  
  <pre><code>Object mockObject = mock(Object.class);
  Object mockReply = mock(Object.class);
  Mockito.when(artifactObj.anotherMethod(mockObject)).thenReturn(mockReply);
  
  //Now call original test method 
  
  Class c = new Class(artifactObj);
  c.methodToTest(); 
  </code></pre>
  
  <p>doing above will always return reply = null inside original method that I am trying to test. I need some value of reply to be returned so that I can use it inside my method.</p>