Bajji
Bajji

Reputation: 2383

Mockito - Stubbing generic Class parameter

I have a method which takes a Class parameter like this :

public void check(Class<? extends A<? extends B>>);}}

I am trying to verify that the call to the method check has been performed by the caller :

Mockito.verify(object).check(any(Class<? extends A<? extends B>>));

But it doesn't seem to match the parameters that "check" is expecting.

What's the right way to express this expectation using Mockito ?

Upvotes: 0

Views: 593

Answers (2)

sunysen
sunysen

Reputation: 2351

Mockito.verify(object).check((Class)any(Class<? extends A<? extends B>>));

Upvotes: 0

Jeff Bowman
Jeff Bowman

Reputation: 95614

You're welcome to ignore the generics if they're causing you problems. Use raw types instead.

verify(object).check((Class) any());

Upvotes: 2

Related Questions