Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mockito: Verifying with generic parameters

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...

like image 883
Svish Avatar asked May 30 '11 11:05

Svish


1 Answers

Try:

verify(someService).process(Matchers.<Collection<Person>>any()); 

Actually, IntelliJ automatically suggested this fix when I typed any()... Unfortunately you cannot use static import in this case.

like image 82
Tomasz Nurkiewicz Avatar answered Sep 19 '22 23:09

Tomasz Nurkiewicz