With Mockito I can do the following:
verify(someService).process(any(Person.class));
But how do I write this if process
takes a Collection<Person>
instead? Can't figure out how to write it correctly. Just getting syntax errors...
With Mockito I can do the following:
verify(someService).process(any(Person.class));
But how do I write this if process
takes a Collection<Person>
instead? Can't figure out how to write it correctly. Just getting syntax errors...
Try :
Since version 1.8 Mockito introduces
You can't express this because of type erasure. Even if you could express it in code, Mockito had no chance to check it at runtime. You could create an interface like
instead and use this throughout your code.
Edit: I was wrong, Mockito has anyCollectionOf(..) which is what you want.
if you use a own method, you can even use static import:
Then you can use
Try:
Actually, IntelliJ automatically suggested this fix when I typed
any()
... Unfortunately you cannot use static import in this case.