A small tip about Java generics
Use ArgumentCaptor to capture the parameters in the mock method as shown below
ArgumentCaptor<List<Foo>> fooCaptor = ArgumentCaptor.forClass(List.class);
Error reporting
Error:(89, 86) java: incompatible types: org.mockito.ArgumentCaptor<java.util.List> cannot be converted to org.mockito.ArgumentCaptor<java.util.List<com.myapp.model.Foo>>
Solution
Using a higher version of Mockito--mockito-core-2.0.36-beta
Code comparison
mockito-core-1.0.19
public static <T> ArgumentCaptor<T> forClass(Class<T> clazz) { return new ArgumentCaptor<T>(clazz); }
mockito-core-2.0.36-beta
public static <U,S extends U> ArgumentCaptor<U> forClass(Class<S> clazz) { return new ArgumentCaptor<U>(clazz); }