title: Is it possible to mock all fields of second level mocked object using mockito
body: <p>I am using mockito framework in junit test class.</p>
  
  <p>Here is the dependency graph of classes:</p>
  
  <p>First is dependent on Second, Second is dependent on Third and Fourth.</p>
  
  <p>I want to test First class. In my test class, I have mocked instance of Second. Now I want, for a mocked instance of Second class, all fields of Second class should also get mocked i.e. mocked instance of Second class should have mocked instance of Third and Fourth class (Second class has two fields Third and Fourth).</p>
  
  <p>In the below test class, I want mocked instance of Second should have mocked instance of Third and Fourth in it.</p>
  
  <pre><code>public class FirstTest {
  
     @Mock
      private Second second;
  
      @Mock
      private Third third;
  
      @Mock
      private Fourth fourth;
  
      @InjectMocks
      private First first = new First();
  
      @BeforeClass
      public void setUp() throws Exception {
          initMocks(this);
      }
  
  
      @Test
      public void testCallSecond() throws Exception {
          first.callSecond();
      }
  
  }
  
  
  
  public class First {
  
      @Autowired
      private Second second;
  
      public void callSecond() {
          second.call();
      }
  }
  
  
  
  public class Second {
  
      @Autowired 
      Third third;
  
  
      @Autowired 
      Fourth fourth;
  
  
      public void call() {
  
          System.out.println("third instance ======="+third);
          third.call();
      }
  
  
  }
  </code></pre>
  
  <p>is it possible to mock all fields of second level mocked object? If yes then please suggest. I want to do it using Mockito framework only.</p>