Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (10.2k points)

is it possible to pass the type of an interface with generics?

The interface:

public interface AsyncCallback<T>

In my test method:

Mockito.any(AsyncCallback.class)

Putting <ResponseX> behind or for .class didnt work.

1 Answer

0 votes
by (46k points)

There is a type-safe way: use ArgumentMatchers.any() and qualify it with the type:

ArgumentMatchers.<AsyncCallback<ResponseX>>any()

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Nov 4, 2019 in Java by Anvi (10.2k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...