Mockito: Mocking AnnotationType

I would like to make fun of the annotationType () method that returns Class<? extends Annotation>.

But the next line gives me a compilation error.

when(annotation.annotationType()).thenReturn(notNullClass.getClass());

I am using java 1.7.0_45. I get a compilation error that I need to pass Class<? extends Annotation>as a parameter.

Any idea what I should put as an argument thenReturnto compile?

+4
source share
1 answer

annotation.annotationType()returns Class<? extends Annotation>.

Thus, you must return a class object of some type of annotation .

+2
source

All Articles