Issue
Class A--Has a method 'doSomething' which accepts a list of Pair
Class B--Has a method which internally calls Class A's method.
I am trying to write Junit for Class B , where I need to verify Mocked Class A's mentod is called with Pair type.
verify(a,times(1)).doSomething(Mockito.anyListOf(Pair.class))
I need a way to specify something like
verify(a,times(1)).doSomething(Mockito.anyListOf(Pair<CustomClass1,CustomClass2>.class))
Solution
Not really an answer to the question but an alternative (Probably a better option). I ended up using Argument Captor to capture the argument and then I can assert the captured values to verify they match against expected values.
@Captor
private ArgumentCaptor<List<Pair<CustomClass1, CustomClass2>>> pairListArgCaptor;
//Capture Values
verify(a,times(1)).doSomething(pairListArgCaptor.capture());
assertEquals(expectedCustomObject1,pairListArgCaptor.get().get(0).getFirst());
assertEquals(expectedCustomObject2,pairListArgCaptor.get().get(0).getSecond());
Answered By - Sandeep Lakdawala