Reputation: 7514
I am trying to use Mockito's argThat API:
verify(mockService).methodA(argThat((List ids, int b) -> ids.get(0).equals("123")));
mockService has methodA
which takes two parameters: a List and a primitive integer.
But this gives me an error:
"Imcompatible parameter types in lambda expression".
The reason is that ArgumentMatcher's matches method takes only one argument.
So how can I do verification for such scenarios?
Upvotes: 6
Views: 9475
Reputation: 26542
You should use an argThat
wildcard for each of the inputs:
verify(mockService).methodA(argThat((List ids) -> ids.get(0).equals("123"))
, argThat((int b) -> b < 1);
I would also suggest you use @ArgumentCaptor
which is an alternative to argThat
and makes that custom matching a bit more clear: javadoc. Especially if you have to use both of the params at the same conditional statement.
Upvotes: 14