@Test public void shouldSavePTVProgramWhenThereIsNotPTVProgramStored() throws LMISException, SQLException { PTVProgram expectedPtvProgram = createInitialPTVProgram(); when(ptvProgramRepository.save(expectedPtvProgram)).thenReturn(expectedPtvProgram); Observable<PTVProgram> observableSave = ptvProgramPresenter.savePTVProgram(false); observableSave.subscribe(subscriber); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); PTVProgram actualPTVProgram = subscriber.getOnNextEvents().get(0); assertThat(actualPTVProgram, is(expectedPtvProgram)); }
public Observable<PTVProgram> savePTVProgram(final boolean isCompleted) { return Observable.create(new Observable.OnSubscribe<PTVProgram>() { @Override public void call(Subscriber<? super PTVProgram> subscriber) { try { if (ptvProgram == null) { LMISException e = new LMISException("PTV Program cannot be null"); e.reportToFabric(); throw e; } setPTVProgramStatus(isCompleted); PTVProgram ptvProgramSaved = ptvProgramRepository.save(ptvProgram); subscriber.onNext(ptvProgramSaved); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } catch (SQLException e) { subscriber.onError(e); } } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); }
PtvProgramPresenter extends Presenter { public Observable<PTVProgram> savePTVProgram(final boolean isCompleted) { return Observable.create(new Observable.OnSubscribe<PTVProgram>() { @Override public void call(Subscriber<? super PTVProgram> subscriber) { try { if (ptvProgram == null) { LMISException e = new LMISException("PTV Program cannot be null"); e.reportToFabric(); throw e; } setPTVProgramStatus(isCompleted); PTVProgram ptvProgramSaved = ptvProgramRepository.save(ptvProgram); subscriber.onNext(ptvProgramSaved); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } catch (SQLException e) { subscriber.onError(e); } } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } }
PtvProgramPresenter extends Presenter { public Observable<PTVProgram> savePTVProgram(final boolean isCompleted) { return Observable.create(new Observable.OnSubscribe<PTVProgram>() { @Override public void call(Subscriber<? super PTVProgram> subscriber) { try { if (ptvProgram == null) { LMISException e = new LMISException("PTV Program cannot be null"); e.reportToFabric(); throw e; } setPTVProgramStatus(isCompleted); PTVProgram ptvProgramSaved = ptvProgramRepository.save(ptvProgram); subscriber.onNext(ptvProgramSaved); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } catch (SQLException e) { subscriber.onError(e); } } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } PtvProgramPresenter(); }
PtvProgramPresenter extends Presenter { public Observable<PTVProgram> savePTVProgram(final boolean isCompleted) { return Observable.create(new Observable.OnSubscribe<PTVProgram>() { @Override public void call(Subscriber<? super PTVProgram> subscriber) { try { if (ptvProgram == null) { LMISException e = new LMISException("PTV Program cannot be null"); e.reportToFabric(); throw e; } setPTVProgramStatus(isCompleted); PTVProgram ptvProgramSaved = ptvProgramRepository.save(ptvProgram); subscriber.onNext(ptvProgramSaved); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } catch (SQLException e) { subscriber.onError(e); } } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } PtvProgramPresenter(); @Override void attachView(BaseView v); Observable<PTVProgram> buildInitialPtvProgram(); Observable<PTVProgram> savePTVProgram(final boolean isCompleted); PTVProgram updatePTVProgram(String totalWoman, String totalChild); void buildPlaceholderRows(); boolean isNotSubmittedForApproval(); Observable<PTVProgram> signReport(String signature, boolean isComplete); }
PtvProgramPresenter extends Presenter { public Observable<PTVProgram> savePTVProgram(final boolean isCompleted) { return Observable.create(new Observable.OnSubscribe<PTVProgram>() { @Override public void call(Subscriber<? super PTVProgram> subscriber) { try { if (ptvProgram == null) { LMISException e = new LMISException("PTV Program cannot be null"); e.reportToFabric(); throw e; } setPTVProgramStatus(isCompleted); PTVProgram ptvProgramSaved = ptvProgramRepository.save(ptvProgram); subscriber.onNext(ptvProgramSaved); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } catch (SQLException e) { subscriber.onError(e); } } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } PtvProgramPresenter(); @Override void attachView(BaseView v); Observable<PTVProgram> buildInitialPtvProgram(); Observable<PTVProgram> savePTVProgram(final boolean isCompleted); PTVProgram updatePTVProgram(String totalWoman, String totalChild); void buildPlaceholderRows(); boolean isNotSubmittedForApproval(); Observable<PTVProgram> signReport(String signature, boolean isComplete);  }