You can use the anyList()
matcher if you don't care about exactly what list your method is being called with. For example, if you want to verify the save()
method was called exactly thrice:
verify(dao, times(3)).save(anyList())
If you want to make further assertions about what list save()
was called with, use ArgumentCaptor
An example usage of ArgumentCaptor
:
ArgumentCaptor<List> argument = ArgumentCaptor.forClass(List.class);
verify(dao, times(3)).save(argument.capture());
List secondValue = argument.getAllValues().get(1); // captured value when the method was called the second time