title: How do I use PowerMock / Mockito / EasyMock to use a mocked object for dependency injection?
body: <p>I have an <code>AuthenticationManager.authenticate(username,password)</code> method that gets called in someMethod of a SomeService under test. The AuthenticationManager is injected into SomeService:</p>
  
  <pre><code>@Component
  public class SomeService {
      @Inject
      private AuthenticationManager authenticationManager;
  
      public void someMethod() {
          authenticationManager.authenticate(username, password);
          // do more stuff that I want to test
      }
  }
  </code></pre>
  
  <p>Now for the unit test I need the authenticate method to just pretend it worked correctly, in my case do nothing, so I can test if the method itself does the expected work (Authentication is tested elsewhere according to the unit testing principles, however authenticate needs to be called inside that method) So I am thinking, I need <code>SomeService</code> to use a mocked <code>AuthenticationManager</code> that will just return and do nothing else when <code>authenticate()</code> gets called by <code>someMethod()</code>.</p>
  
  <p>How do I do that with PowerMock (or EasyMock / Mockito, which are part of PowerMock)? </p>