@Test public void fetchUsers_returning_loadingSuccess_forView() { mPresenter.fetchUsers(); verify(mView, times(1)).getPage(); verify(mView, times(1)).onLoading(true); mTestScheduler.triggerActions(); verify(mView, times(1)).onLoading(false); }
@Override public void fetchUsers() { if (this.getView() != null) { this.getView().onLoading(true); this.addDisposable(mRepository.fetchUsers(this.getView().getPage()). subscribeOn(this.getScheduler().io()) .observeOn(this.getScheduler().ui()) .subscribe( userResponse -> { this.getView().onLoading(false); this.getView().onUserResponse(userResponse); }, error -> { this.getView().onLoading(false); this.getView().onError(error); } )); } }
HomePresenter extends BasePresenter<HomeContract.View> implements HomeContract.Presenter { @Override public void fetchUsers() { if (this.getView() != null) { this.getView().onLoading(true); this.addDisposable(mRepository.fetchUsers(this.getView().getPage()). subscribeOn(this.getScheduler().io()) .observeOn(this.getScheduler().ui()) .subscribe( userResponse -> { this.getView().onLoading(false); this.getView().onUserResponse(userResponse); }, error -> { this.getView().onLoading(false); this.getView().onError(error); } )); } } }
HomePresenter extends BasePresenter<HomeContract.View> implements HomeContract.Presenter { @Override public void fetchUsers() { if (this.getView() != null) { this.getView().onLoading(true); this.addDisposable(mRepository.fetchUsers(this.getView().getPage()). subscribeOn(this.getScheduler().io()) .observeOn(this.getScheduler().ui()) .subscribe( userResponse -> { this.getView().onLoading(false); this.getView().onUserResponse(userResponse); }, error -> { this.getView().onLoading(false); this.getView().onError(error); } )); } } @Inject  HomePresenter(@NonNull HomeContract.Repository repository,
                         @NonNull BaseScheduler scheduler); }
HomePresenter extends BasePresenter<HomeContract.View> implements HomeContract.Presenter { @Override public void fetchUsers() { if (this.getView() != null) { this.getView().onLoading(true); this.addDisposable(mRepository.fetchUsers(this.getView().getPage()). subscribeOn(this.getScheduler().io()) .observeOn(this.getScheduler().ui()) .subscribe( userResponse -> { this.getView().onLoading(false); this.getView().onUserResponse(userResponse); }, error -> { this.getView().onLoading(false); this.getView().onError(error); } )); } } @Inject  HomePresenter(@NonNull HomeContract.Repository repository,
                         @NonNull BaseScheduler scheduler); @Override void fetchUsers(); @Override HomeContract.View getView(); }
HomePresenter extends BasePresenter<HomeContract.View> implements HomeContract.Presenter { @Override public void fetchUsers() { if (this.getView() != null) { this.getView().onLoading(true); this.addDisposable(mRepository.fetchUsers(this.getView().getPage()). subscribeOn(this.getScheduler().io()) .observeOn(this.getScheduler().ui()) .subscribe( userResponse -> { this.getView().onLoading(false); this.getView().onUserResponse(userResponse); }, error -> { this.getView().onLoading(false); this.getView().onError(error); } )); } } @Inject  HomePresenter(@NonNull HomeContract.Repository repository,
                         @NonNull BaseScheduler scheduler); @Override void fetchUsers(); @Override HomeContract.View getView();  }