title: How to inject a mocked object inside mock of another mocked object in Java?
body: <p>I have below classes. DataServices object is used in both ProductImpl and Mapper. But its mock is available in ProductImpl but not in Mapper class. I do not what needs to be done so that mocked of DataServices is Available in Mapper class too.</p>
  
  <pre><code>class ProductImpl{
      @Inject private DataServices ds;
      @Inject private Mapper mapper;
  
      public void call(){
        ds.get(); //ds is not null here
        mapper.map();
       // some code
      }
     }
  
  
  
  abstact class Mapper{
  
          @Inject private DataServices ds;
  
          public void map(){
              ds.get()// ds is null here
              //some code
          }
      }
  </code></pre>
  
  <p>I have test class below</p>
  
  <pre><code>class Test{
  
      @Mock private DataServices ds;
      @Mock private Mapper mapper;
      @InjectMocks private ProductImpl impl;
  
      @Before
      public void setUp(){
      MockitoAnnotations.initMocks(this)
      }
  
      @Test
      public void test(){
         impl.call();
      }
  }
  </code></pre>