title: Mockito match specific Class argument
body: <p>I am trying to mock some resources that are generated dynamically. In order to generate these resources, we must pass in a class argument. So for example: </p>
  
  <pre><code>FirstResourceClass firstResource = ResourceFactory.create(FirstResourceClass.class);
  
  SecondResourceClass secondResource = ResourceFactory.create(SecondResource.class);
  </code></pre>
  
  <p>This is well and good until I tried to mock. I am doing something like this: </p>
  
  <pre><code>PowerMockito.mockStatic(ResourceFactory.class);
  FirstResourceClass mockFirstResource = Mockito.mock(FirstResourceClass.class);
  SecondResourceClass mockSecondResource = Mockito.mock(SecondResourceClass.class);
  
  PowerMockito.when(ResourceFactory.create(Matchers.&lt;Class&lt;FirstResourceClass&gt;&gt;any()).thenReturn(mockFirstResource);
  PowerMockito.when(ResourceFactory.create(Matchers.&lt;Class&lt;SecondResourceClass&gt;&gt;any()).thenReturn(mockSecondResource);
  </code></pre>
  
  <p>It seems like the mock is being injected into the calling class, but <code>FirstResourceClass</code> is being send <code>mockSecondResource</code>, which throws a compile error. </p>
  
  <p>The issue is (I think) with the use of any() (which I got from <a href="https://stackoverflow.com/questions/7500312/mockito-match-any-class-argument">this question</a>). I believe I have to use <code>isA()</code>, but I'm not sure how to make that method call, as it requires a <code>Class</code> argument. I have tried <code>FirstResourceClass.class</code>, and that gives a compile error. </p>