I have this method, "instance" is @Mock
instance.lookup(
SomeClass.class.getField("field").getAnnotation(MyAnnotation.class),
Annotation... annotations
)
Signature of that method is exactly this:
Object lookup(MyAnnotation resource, Annotation... annotations);
Now, that Annotation... value is put there on that mock in runtime in the code I test.
I am trying to Mock it so when I do
Mockito.when(instance.lookup....).thenReturn(something);
but lookup method always returns null value and exception it thrown (it basically do not return "something" but null)
I was thinking that I have to mock these varargs as well so I modified it to this
Mockito.when(instance.lookup(_instance line_, Mockito.any(Annotation[].class)))
but it fails telling me that I am using it "raw".
When I use anyVarargs() like this
Mockito.when(instance.lookup(_that line_, Mockito.anyVararg()))
Mockito.anyVararg() returns Object but I need Annotation[]
Any hint here?
Thanks a lot!