Por exemplo:
public void shouldUpdateAuctionsList_whenGetsAuctionsFromAPI() {
AuctionsListActivity activity = new AuctionsListActivity();
final ArrayList<Auction> auctions = new ArrayList<>(Arrays.asList(
new Auction("Computer"),
new Auction("Car")
));
Mockito.doNothing().when(adapter).refreshList();
Mockito.doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) {
ResponseListener<List<Auction>> argument = invocation.getArgument(0);
argument.success(auctions);
return null;
}
}).when(client).all(ArgumentMatchers.any(ResponseListener.class));
activity.getAuctions(adapter, client);
Mockito.verify(client).all(ArgumentMatchers.any(ResponseListener.class));
Mockito.verify(adapter).update(auctions);
}
Obrigado
PS.: ignorem o fato de eu estar fazendo o curso em Inglês... Fora isso, ele é todo igual