Use Mockito to match a null list of a specific type
<p>I have a method that takes a few parameters. One of them is a List of some class, and null is an acceptable value for this parameter.</p>

<pre><code>public void doStuff(String string, @Nullable List&lt;SomeClass&gt; list) {
    ...
}
</code></pre>

<p>I want to write a test that uses Mockito to verify the method was called with null as a parameter. I tried using <code>isNull(List.class)</code>:</p>

<pre><code>MyClass myClass = ...
verify(myClass).doStuff(any(String.class), isNull(List.class));
</code></pre>

<p>but this generates a warning:</p>

<blockquote>
  <p>unchecked conversion<br/>  required: java.util.List&lt;
  com.package.SomeClass><br/>  found:    java.util.List</p>
</blockquote>

<p>I can see how to fix this warning in the event that the list is not null:</p>

<pre><code>// this generates the same warning
verify(myClass).doStuff(any(String.class), any(List.class));

// this does not generate the warning
verify(myClass).doStuff(any(String.class), Matchers.anyListOf(SomeClass.class)));
</code></pre>

<p>However, I can't seem to find a way to combine these two approaches together. Or find an alternate approach that accomplishes what I am trying to do. (Other than suppressing the warning with an annotation)</p>