FavoritasMainPresenter implements Presenter<FavoritasMainPresenter.View> { @Override public void initialize(View view) { this.view = view; view.showLoading(); loadFavoritas(); } FavoritasMainPresenter(ObtainFavoritasAction obtainFavoritasAction); @Override void initialize(View view); @Override void update(); @Override void pause();  }
@Test public void shows_loading_when_initialized() throws Exception { presenter.initialize(view); verify(view).showLoading(); }
@Test public void hides_loading_when_received_empty_list() throws Exception { when(obtainFavoritasAction.getFavoritas()).thenReturn(Observable.just(emptyList())); presenter.initialize(view); verify(view).hideLoading(); }
@Test public void hides_loading_when_received_any_list() throws Exception { when(obtainFavoritasAction.getFavoritas()).thenReturn(Observable.just(favoritasListOf(4))); presenter.initialize(view); verify(view).hideLoading(); }
@Test public void shows_empty_when_received_empty_list() throws Exception { when(obtainFavoritasAction.getFavoritas()).thenReturn(Observable.just(emptyList())); presenter.initialize(view); verify(view).showEmpty(); }
@Test public void hides_empty_when_received_some_favoritas() throws Exception { when(obtainFavoritasAction.getFavoritas()).thenReturn(Observable.just(favoritasListOf(4))); presenter.initialize(view); verify(view).hideEmpty(); }
@Test public void shows_favoritas_when_received_some_favoritas() throws Exception { List<Favorita> favoritas = favoritasListOf(4); when(obtainFavoritasAction.getFavoritas()).thenReturn(Observable.just(favoritas)); presenter.initialize(view); verify(view).showFavoritas(favoritas); }
@Test public void shows_error_when_received_an_error() throws Exception { when(obtainFavoritasAction.getFavoritas()).thenReturn(Observable.error(new Exception())); presenter.initialize(view); verify(view).showError(); }