FlashcardsPresenter extends AbstractPresenter<IFlashcardsView> { @Override public void onCreate() { onLoadFlashcards(); } @Inject  FlashcardsPresenter(FlashcardsModule module, @Named(VIEW_EXECUTOR) Executor executor); @Override void onCreate(); @Override void onDestroy(); void onLoadFlashcards(); void onWordRight(FlashcardWord word); void onWordWrong(FlashcardWord word); void onCardsDepleted();  }
@Test public void onCreateWouldStartLoadingFlashcards() { when(module.getFlashcards()).thenReturn(Call.empty()); presenter.onCreate(); presenter.onBind(view); verify(module).getFlashcards(); verify(view).showProgress(); }
@Test public void onCreateWouldShowList() { List<FlashcardWord> list = Collections.singletonList(mock(FlashcardWord.class)); prepareTestData(list); presenter.onCreate(); presenter.onBind(view); verify(view).showWords(list); }
@Test public void onFlashcardsLoadErrorWouldShowError() { when(module.getFlashcards()).thenReturn(Call.error(new ServerException())); presenter.onCreate(); presenter.onBind(view); verify(view).showError(); }
@Test public void emptyWordsListIsTreatedAsError() { prepareTestData(Collections.emptyList()); presenter.onCreate(); presenter.onBind(view); verify(view).showError(); }