### Question:
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();  }### Answer:
@Test public void fetchUsers_sucess(){ mPresenter.fetchUsers(); verify(mRepository, times(1)).fetchUsers(2); }
@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); }
@Test public void fetchUsers_returningSuccess_forView() { mPresenter.fetchUsers(); mTestScheduler.triggerActions(); verify(mView, times(1)).onUserResponse(mUserResponse); verify(mView, never()).onError(null); }
@Test public void fetchUsers_returningFailing_forView() { Throwable throwable = new Throwable(); when(mRepository.fetchUsers(2)).thenReturn(Single.error(throwable)); mPresenter.fetchUsers(); mTestScheduler.triggerActions(); verify(mView).onError(throwable); verify(mView, times(1)).onLoading(false); verify(mView, never()).onUserResponse(mUserResponse); }