SyncClientPayloadsPresenter extends BasePresenter<SyncClientPayloadsMvpView> { public void syncClientPayload(ClientPayload clientPayload) { checkViewAttached(); getMvpView().showProgressbar(true); mSubscriptions.add(mDataManagerClient.createClient(clientPayload) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Observer<Client>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getMvpView().showProgressbar(false); getMvpView().showClientSyncFailed(MFErrorParser.errorMessage(e)); } @Override public void onNext(Client client) { getMvpView().showProgressbar(false); getMvpView().showSyncResponse(); } })); } @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 testSyncClientPayload() { when(mDataManagerClient.createClient(clientPayloads.get(0))).thenReturn(Observable.just (new Client())); syncClientPayloadsPresenter.syncClientPayload(clientPayloads.get(0)); verify(mSyncClientPayloadsMvpView).showSyncResponse(); verify(mSyncClientPayloadsMvpView, never()) .showClientSyncFailed(errorSyncServerMessage); }
@Test public void testSyncClientPayloadFails() { when(mDataManagerClient.createClient(clientPayloads.get(0))) .thenReturn(Observable.<Client>error(new RuntimeException())); syncClientPayloadsPresenter.syncClientPayload(clientPayloads.get(0)); verify(mSyncClientPayloadsMvpView, never()).showSyncResponse(); }