@Test public void search_MakeupRepositoryError_ErrorMsg() { String errorMessage = "No internet"; when(makeUpRepository.searchMakeUp(anyString(), anyString())).thenReturn(Observable.error (new IOException(errorMessage))); makeUpSearchPresenter.search("test", "test"); verify(view).showLoading(); verify(view).hideLoading(); verify(view, never()).showSearchResults(anyList()); verify(view).showError(errorMessage); }
@Override public void search(String brand, String product) { checkViewAttached(); getView().showLoading(); addSubscription(makeUpRepository.searchMakeUp(brand, product).subscribeOn(ioScheduler) .observeOn(mainScheduler).subscribe(new Subscriber<List<MakeUp>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getView().hideLoading(); getView().showError(e.getMessage()); } @Override public void onNext(List<MakeUp> makeUps) { getView().hideLoading(); if (makeUps.isEmpty()) { getView().showEmptyState(); } else { getView().showSearchResults(makeUps); } } })); }
MakeUpSearchPresenter extends BasePresenter<MakeUpSearchContract.View> implements
        MakeUpSearchContract.Presenter { @Override public void search(String brand, String product) { checkViewAttached(); getView().showLoading(); addSubscription(makeUpRepository.searchMakeUp(brand, product).subscribeOn(ioScheduler) .observeOn(mainScheduler).subscribe(new Subscriber<List<MakeUp>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getView().hideLoading(); getView().showError(e.getMessage()); } @Override public void onNext(List<MakeUp> makeUps) { getView().hideLoading(); if (makeUps.isEmpty()) { getView().showEmptyState(); } else { getView().showSearchResults(makeUps); } } })); } }
MakeUpSearchPresenter extends BasePresenter<MakeUpSearchContract.View> implements
        MakeUpSearchContract.Presenter { @Override public void search(String brand, String product) { checkViewAttached(); getView().showLoading(); addSubscription(makeUpRepository.searchMakeUp(brand, product).subscribeOn(ioScheduler) .observeOn(mainScheduler).subscribe(new Subscriber<List<MakeUp>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getView().hideLoading(); getView().showError(e.getMessage()); } @Override public void onNext(List<MakeUp> makeUps) { getView().hideLoading(); if (makeUps.isEmpty()) { getView().showEmptyState(); } else { getView().showSearchResults(makeUps); } } })); } MakeUpSearchPresenter(MakeUpRepository makeUpRepository, Scheduler ioScheduler, Scheduler
            mainScheduler); }
MakeUpSearchPresenter extends BasePresenter<MakeUpSearchContract.View> implements
        MakeUpSearchContract.Presenter { @Override public void search(String brand, String product) { checkViewAttached(); getView().showLoading(); addSubscription(makeUpRepository.searchMakeUp(brand, product).subscribeOn(ioScheduler) .observeOn(mainScheduler).subscribe(new Subscriber<List<MakeUp>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getView().hideLoading(); getView().showError(e.getMessage()); } @Override public void onNext(List<MakeUp> makeUps) { getView().hideLoading(); if (makeUps.isEmpty()) { getView().showEmptyState(); } else { getView().showSearchResults(makeUps); } } })); } MakeUpSearchPresenter(MakeUpRepository makeUpRepository, Scheduler ioScheduler, Scheduler
            mainScheduler); @Override void search(String brand, String product); }
MakeUpSearchPresenter extends BasePresenter<MakeUpSearchContract.View> implements
        MakeUpSearchContract.Presenter { @Override public void search(String brand, String product) { checkViewAttached(); getView().showLoading(); addSubscription(makeUpRepository.searchMakeUp(brand, product).subscribeOn(ioScheduler) .observeOn(mainScheduler).subscribe(new Subscriber<List<MakeUp>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getView().hideLoading(); getView().showError(e.getMessage()); } @Override public void onNext(List<MakeUp> makeUps) { getView().hideLoading(); if (makeUps.isEmpty()) { getView().showEmptyState(); } else { getView().showSearchResults(makeUps); } } })); } MakeUpSearchPresenter(MakeUpRepository makeUpRepository, Scheduler ioScheduler, Scheduler
            mainScheduler); @Override void search(String brand, String product);  }