I was trying to find out if I can use something like the any
argument matcher for a method with type parameters:
when(store.getItems[Product](any[FilterParams]))
.thenReturn(allProducts)
When running the code with the above snippet, I get this error:
Invalid use of argument matchers!
2 matchers expected, 1 recorded
I guessed this would be because I passed an exact type parameter Product
to the getItems
method.
This does work when I pass in an actual FilterParams
object:
when(store.getItems[Product](FilterParams()))
.thenReturn(allProducts)
Is there any argument matcher that I can use for the type parameter? Or is it counter-intuitive, because whenever we're calling a function with a type parameter, we have to pass the type parameter?
Edit:
Product
here isn't Scala's built-in Product
trait.
The function signature of the getItems
method:
def getItems[T <: ItemType : universe.TypeTag](filterParams: FilterParams): List[T]