title: Unable to mock in unit test for Configuration in Spring boot
body: <p>I am getting issue while writing unit test for following configuration:</p>
  <pre><code>@Configuration
  public class XYZProvider {
  
      private static Logger logger = LoggerFactory.getLogger(this.class);
  
      private final Operations operations;
  
      public XYZProvider(Operations operations) {
          this.operations = operations;
      }
  
      @PostConstruct
      public void process() {
          try {
              File[] files = operations.process(Constants.DIR); &lt;---HERE I AM GETTING NULL FOR OPERATIONS EVEN AFTER MOCKING
              ...
      }
  </code></pre>
  <p><code>Operations</code> class is as follows:</p>
  <pre><code>@Component
  public class Operations {
      public File[] process(String dir) throws IOException {
          ...
      }
  }
  </code></pre>
  <p>Test file is as follows:</p>
  <pre><code> @RunWith(MockitoJUnitRunner.class)
   public class XYZProviderTest {
  
   @Mock
   Operations operations;
  
   @InjectMocks
   XYZProvider xyzProvider;
  
   @Test
   public void test_Success() throws IOException {
     
      when(operations.process(Constants.DIR))
         .thenReturn(getFiles(&quot;tests/success&quot;));
     
      xyzProvider.process();
  
      ...
  }
  </code></pre>
  <p>While running unit tests, I am getting null for <code>operations</code>. I am not getting idea how to fix this.</p>