Let's say I have a method that takes List<List<MyObject>>
as an argument:
public void myFunction(List<List<MyObject>> listOfList) {}
I know I can use anyList()
as a matcher e.g.
verify(myClass).myFunction(anyList());
However, I get an unchecked assignment warning. I cannot use either of these matchers as they produce compile errors:
// Fails - Expects just a single-layered List<MyObject>
verify(myClass).myFunction(anyListOf(MyObject.class));
// Fails - "no instance(s) of type variable(s) T exist so that List<T> conforms to Class<T>"
verify(myClass).myFunction(anyListOf(anyListOf(MyObject.class)));
So how would I create a type-safe matcher for an argument of type List<List<T>>
?
Aucun commentaire:
Enregistrer un commentaire