@Test public void shouldCreatePTVProgramForCurrentPeriodWhenPTVProgramIsNotSaved() throws LMISException { Period period = new Period(DateTime.now()); PTVProgram expectedPTVProgram = PTVUtil.createDummyPTVProgram(period); expectedPTVProgram.setPatientDispensations(PTVUtil.createDummyPatientDispensations()); expectedPTVProgram.setPtvProgramStocksInformation(PTVUtil.createDummyPTVProgramStocksInformation()); when(ptvProgramBuilder.buildInitialPTVProgram(period)).thenReturn(expectedPTVProgram); ptvProgramPresenter.setPeriod(period); Observable<PTVProgram> observable = ptvProgramPresenter.buildInitialPtvProgram(); observable.subscribe(subscriber); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); PTVProgram actualPTVProgram = subscriber.getOnNextEvents().get(0); assertThat(expectedPTVProgram, is(actualPTVProgram)); }
public Observable<PTVProgram> buildInitialPtvProgram() { return Observable.create(new Observable.OnSubscribe<PTVProgram>() { @Override public void call(Subscriber<? super PTVProgram> subscriber) { try { if (period == null) { LMISException e = new LMISException("Period cannot be null"); e.reportToFabric(); throw e; } createPTVProgram(); buildPlaceholderRows(); subscriber.onNext(ptvProgram); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); }
PtvProgramPresenter extends Presenter { public Observable<PTVProgram> buildInitialPtvProgram() { return Observable.create(new Observable.OnSubscribe<PTVProgram>() { @Override public void call(Subscriber<? super PTVProgram> subscriber) { try { if (period == null) { LMISException e = new LMISException("Period cannot be null"); e.reportToFabric(); throw e; } createPTVProgram(); buildPlaceholderRows(); subscriber.onNext(ptvProgram); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } }
PtvProgramPresenter extends Presenter { public Observable<PTVProgram> buildInitialPtvProgram() { return Observable.create(new Observable.OnSubscribe<PTVProgram>() { @Override public void call(Subscriber<? super PTVProgram> subscriber) { try { if (period == null) { LMISException e = new LMISException("Period cannot be null"); e.reportToFabric(); throw e; } createPTVProgram(); buildPlaceholderRows(); subscriber.onNext(ptvProgram); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } PtvProgramPresenter(); }
PtvProgramPresenter extends Presenter { public Observable<PTVProgram> buildInitialPtvProgram() { return Observable.create(new Observable.OnSubscribe<PTVProgram>() { @Override public void call(Subscriber<? super PTVProgram> subscriber) { try { if (period == null) { LMISException e = new LMISException("Period cannot be null"); e.reportToFabric(); throw e; } createPTVProgram(); buildPlaceholderRows(); subscriber.onNext(ptvProgram); subscriber.onCompleted(); } catch (LMISException 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> buildInitialPtvProgram() { return Observable.create(new Observable.OnSubscribe<PTVProgram>() { @Override public void call(Subscriber<? super PTVProgram> subscriber) { try { if (period == null) { LMISException e = new LMISException("Period cannot be null"); e.reportToFabric(); throw e; } createPTVProgram(); buildPlaceholderRows(); subscriber.onNext(ptvProgram); subscriber.onCompleted(); } catch (LMISException 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);  }