You could use an ArgumentCaptor
.
@Captor
ArgumentCaptor<List<B>> captor;
// then in test
...
verify(a).foo(captor.capture());
List<B> values = captor.getValue();
assertThat(values, IsIterableContainingInOrder.containingInOrder(new BMatcher(expected));
...
I used the @Captor
as a shortcut and also to that it could be a List<B>
instead of just List
. This requires the use of MockitoAnnotations.init(this)
in an @Before
method.