Mockito Matchers not working
<p>I have these two lines at different points of my code:</p>

<pre><code>Message&lt;T1&gt; reply = (Message&lt;T1&gt;) template.sendAndReceive(channel1, message);

Message&lt;T2&gt; reply = (Message&lt;T2&gt;) template.sendAndReceive(channel2, message);
</code></pre>

<p>I am doing some unit testing and the test covers both statements. When I try to mock the behaviour, I define some behaviour like this:</p>

<pre><code>Mockito.when(template.sendAndReceive(Mockito.any(MessageChannel.class), Matchers.&lt;GenericMessage&lt;T1&gt;&gt;any() )).thenReturn(instance1);

Mockito.when(template.sendAndReceive(Mockito.any(MessageChannel.class), Matchers.&lt;GenericMessage&lt;T2&gt;&gt;any()   )).thenReturn(null);
</code></pre>

<p>When I execute the unit tests and do some debugging , the first statement returns null</p>

<p>Do you have any idea what the matchers seem not to work ? and it always takes the last definition of the mock . I am using Mockito 1.1.10</p>