title: Mockito: mock object in call hierarchy - chained call
body: <p>Is it possible to mock an object with Mockito which is called somewhere in the object hierarchy?</p>
  
  <p>Let's assume following classes:</p>
  
  <pre><code>@Component
  Class A
      @Autowired B b
  
      method obtainSalaryA()
          calls b.calculateSalary() 
  
  @Component
  Class B
      @Autowired C c
  
      method calculateSalary()
          calls c.getDatabaseSalary()
  
  @Component
  Class C
  
      getDatabaseSalary()
  </code></pre>
  
  <p>In the unit test, I would like to unit test the method <code>obtainSalary</code> from <code>class A</code>, but mock C at the same time, so that I replace the return value of <code>getDatabaseSalary()</code> when this method is called in the hierarchy.</p>