SyncClientPayloadsPresenter extends BasePresenter<SyncClientPayloadsMvpView> { public void loadDatabaseClientPayload() { checkViewAttached(); getMvpView().showProgressbar(true); mSubscriptions.add(mDataManagerClient.getAllDatabaseClientPayload() .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Subscriber<List<ClientPayload>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getMvpView().showProgressbar(false); getMvpView().showError(R.string.failed_to_load_clientpayload); } @Override public void onNext(List<ClientPayload> clientPayloads) { getMvpView().showProgressbar(false); getMvpView().showPayloads(clientPayloads); } })); } @Inject  SyncClientPayloadsPresenter(DataManagerClient dataManagerClient); @Override void attachView(SyncClientPayloadsMvpView mvpView); @Override void detachView(); void loadDatabaseClientPayload(); void syncClientPayload(ClientPayload clientPayload); void deleteAndUpdateClientPayload(int id, long clientCreationTIme); void updateClientPayload(ClientPayload clientPayload);  }
@Test public void testLoadDatabaseClientPayload() { when(mDataManagerClient.getAllDatabaseClientPayload()).thenReturn(Observable.just (clientPayloads)); syncClientPayloadsPresenter.loadDatabaseClientPayload(); verify(mSyncClientPayloadsMvpView).showPayloads(clientPayloads); verify(mSyncClientPayloadsMvpView, never()) .showError(R.string.failed_to_load_clientpayload); }
@Test public void testLoadDatabaseClientPayloadFails() { when(mDataManagerClient.getAllDatabaseClientPayload()) .thenReturn(Observable.<List<ClientPayload>>error(new RuntimeException())); syncClientPayloadsPresenter.loadDatabaseClientPayload(); verify(mSyncClientPayloadsMvpView).showError(R.string.failed_to_load_clientpayload); verify(mSyncClientPayloadsMvpView, never()).showPayloads(clientPayloads); }