@Test public void loadPostUserAndPostTestForPostsError() throws InterruptedException { postsPresenter.attachView(postsViewMock); when(internetAvailabilityDetectorMock.isAvailable()).thenReturn(true); when(retrofitServiceMock.users()).thenReturn(Observable.just(users)); when(postsModelMock.saveUsers(users)).thenReturn(true); when(retrofitServiceMock.posts()).thenReturn(Observable.error(observableErrorThrowable)); postsPresenter.loadPosts(PULL_TO_REFRESH); Thread.sleep(100); verify(postsViewMock, times(1)).showLoading(PULL_TO_REFRESH); verify(internetAvailabilityDetectorMock, times(1)).isAvailable(); verifyNoMoreInteractions(internetAvailabilityDetectorMock); verify(retrofitServiceMock, times(1)).users(); verify(postsModelMock, times(1)).saveUsers(users); verifyNoMoreInteractions(postsModelMock); verify(retrofitServiceMock, times(1)).posts(); verifyNoMoreInteractions(retrofitServiceMock); verify(postsViewMock, times(1)).showError(observableErrorThrowable, false); verifyNoMoreInteractions(postsViewMock); }
@Override public void loadPosts(final boolean pullToRefresh) { if (internetAvailabilityDetector.isAvailable()) { getView().showLoading(pullToRefresh); loadPosts(); } else { getView().notifyUserAboutInternetUnavailability(); } }
PostsPresenterImpl extends MvpNullObjectBasePresenter<PostsView> implements PostsPresenter { @Override public void loadPosts(final boolean pullToRefresh) { if (internetAvailabilityDetector.isAvailable()) { getView().showLoading(pullToRefresh); loadPosts(); } else { getView().notifyUserAboutInternetUnavailability(); } } }
PostsPresenterImpl extends MvpNullObjectBasePresenter<PostsView> implements PostsPresenter { @Override public void loadPosts(final boolean pullToRefresh) { if (internetAvailabilityDetector.isAvailable()) { getView().showLoading(pullToRefresh); loadPosts(); } else { getView().notifyUserAboutInternetUnavailability(); } } PostsPresenterImpl(final PostsModel postsModel, final RetrofitService retrofitService, final RxSchedulers rxSchedulers,
                              final InternetAvailabilityDetector internetAvailabilityDetector); }
PostsPresenterImpl extends MvpNullObjectBasePresenter<PostsView> implements PostsPresenter { @Override public void loadPosts(final boolean pullToRefresh) { if (internetAvailabilityDetector.isAvailable()) { getView().showLoading(pullToRefresh); loadPosts(); } else { getView().notifyUserAboutInternetUnavailability(); } } PostsPresenterImpl(final PostsModel postsModel, final RetrofitService retrofitService, final RxSchedulers rxSchedulers,
                              final InternetAvailabilityDetector internetAvailabilityDetector); @Override void loadPosts(final boolean pullToRefresh); @Override void detachView(boolean retainInstance); }
PostsPresenterImpl extends MvpNullObjectBasePresenter<PostsView> implements PostsPresenter { @Override public void loadPosts(final boolean pullToRefresh) { if (internetAvailabilityDetector.isAvailable()) { getView().showLoading(pullToRefresh); loadPosts(); } else { getView().notifyUserAboutInternetUnavailability(); } } PostsPresenterImpl(final PostsModel postsModel, final RetrofitService retrofitService, final RxSchedulers rxSchedulers,
                              final InternetAvailabilityDetector internetAvailabilityDetector); @Override void loadPosts(final boolean pullToRefresh); @Override void detachView(boolean retainInstance);  }