title: Java - How to Mock impl via using Mockito
body: <p>I have this repository created in my class as such:</p>
  <pre><code>    private static ModuleRepository repository = new ModuleRepository();
  </code></pre>
  <p>its called via:</p>
  <pre><code>  repository.isModuleCached(moduleType,taxModuleInfo.getModuleYear(), taxModuleInfo.getModuleVersion()
  </code></pre>
  <p>However when I try to mock it in my test class, I cannot actually return the mocked result I want, instead it calls the actual repository, as if my mockito call is ignored.</p>
  <p>My Test case setup includes:</p>
  <pre><code>@Mock
  private ModuleRepository repository;
  </code></pre>
  <p>my Test classs:</p>
  <pre><code>when(repository.isModuleCached(anyString(), anyString(), anyString())).thenReturn(resp);
  </code></pre>
  <p>The actualy repository in the class isn't autowired, it's instantiated, maybe that could be it?</p>