Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify the class of a generic interface to mock

I'm trying to capture an argument using Mockito. This argument is of type List< MyClass >. But I can't find the proper syntax to specify it.

I can do this:

ArgumentCaptor< MyClass > captor = 
   ArgumentCaptor.forClass( MyClass.class );

But I don't get this to compile:

ArgumentCaptor< List<MyClass> > captor = 
   ArgumentCaptor.forClass( List<MyClass>.class );

Is there a way?

like image 824
xtofl Avatar asked Aug 25 '11 15:08

xtofl


1 Answers

It should work using the @Captor annotation:

@Captor
    private ArgumentCaptor<ArrayList<SomeType>> captor;
like image 125
Andreas Köberle Avatar answered Sep 22 '22 19:09

Andreas Köberle