@Test public void shouldSaveForm() throws Exception { RnRForm rnRForm = new RnRForm(); rnRForm.setBaseInfoItemListWrapper(newArrayList(new BaseInfoItem())); presenter.rnRForm = rnRForm; List<RequisitionFormItemViewModel> list = new ArrayList<>(); for (int i = 0; i < 3; i++) { list.add(new RequisitionFormItemViewModel(createRnrFormItem(i))); list.get(i).setRequestAmount(""); } ViaKitsViewModel viaKitsViewModel = buildDefaultViaKit(); presenter.setViaKitsViewModel(viaKitsViewModel); presenter.requisitionFormItemViewModels = list; TestSubscriber<RnRForm> subscriber = new TestSubscriber<>(); presenter.getSaveFormObservable("100").subscribe(subscriber); subscriber.awaitTerminalEvent(); verify(mockRnrFormRepository).createOrUpdateWithItems(rnRForm); subscriber.assertNoErrors(); assertEquals(5, presenter.getRnRForm().getRnrFormItemListWrapper().size()); }
public Observable<RnRForm> getSaveFormObservable(final String consultationNumbers) { return Observable.create((Observable.OnSubscribe<RnRForm>) subscriber -> { try { dataViewToModel(consultationNumbers); rnrFormRepository.createOrUpdateWithItems(rnRForm); subscriber.onNext(rnRForm); subscriber.onCompleted(); } catch (LMISException e) { new LMISException(e, "VIARequisitionPresenter.getSaveFormObservable").reportToFabric(); subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); }
VIARequisitionPresenter extends BaseRequisitionPresenter { public Observable<RnRForm> getSaveFormObservable(final String consultationNumbers) { return Observable.create((Observable.OnSubscribe<RnRForm>) subscriber -> { try { dataViewToModel(consultationNumbers); rnrFormRepository.createOrUpdateWithItems(rnRForm); subscriber.onNext(rnRForm); subscriber.onCompleted(); } catch (LMISException e) { new LMISException(e, "VIARequisitionPresenter.getSaveFormObservable").reportToFabric(); subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } }
VIARequisitionPresenter extends BaseRequisitionPresenter { public Observable<RnRForm> getSaveFormObservable(final String consultationNumbers) { return Observable.create((Observable.OnSubscribe<RnRForm>) subscriber -> { try { dataViewToModel(consultationNumbers); rnrFormRepository.createOrUpdateWithItems(rnRForm); subscriber.onNext(rnRForm); subscriber.onCompleted(); } catch (LMISException e) { new LMISException(e, "VIARequisitionPresenter.getSaveFormObservable").reportToFabric(); subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } VIARequisitionPresenter(); }
VIARequisitionPresenter extends BaseRequisitionPresenter { public Observable<RnRForm> getSaveFormObservable(final String consultationNumbers) { return Observable.create((Observable.OnSubscribe<RnRForm>) subscriber -> { try { dataViewToModel(consultationNumbers); rnrFormRepository.createOrUpdateWithItems(rnRForm); subscriber.onNext(rnRForm); subscriber.onCompleted(); } catch (LMISException e) { new LMISException(e, "VIARequisitionPresenter.getSaveFormObservable").reportToFabric(); subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } VIARequisitionPresenter(); @Override void loadData(long formId, Date periodEndDate); void loadEmergencyData(final List<StockCard> stockCards, final Date periodEndDate); @Override void attachView(BaseView baseView); void populateAdditionalDrugsViewModels(List<RnrFormItem> addedDrugInVIAs, Date periodBegin); void deleteRnRItemFromViewModel(final RnrFormItem rnrFormItem); @Override void updateUIAfterSubmit(); @Override void updateFormUI(); @Override void submitRequisition(); boolean processRequisition(String consultationNumbers); Observable<RnRForm> getSaveFormObservable(final String consultationNumbers); String getConsultationNumbers(); void setConsultationNumbers(String consultationNumbers); void createStockCardsOrUnarchiveAndAddToFormForAdditionalRnrItems(); Observable<Void> removeRnrItem(final RnrFormItem rnrFormItem); }
VIARequisitionPresenter extends BaseRequisitionPresenter { public Observable<RnRForm> getSaveFormObservable(final String consultationNumbers) { return Observable.create((Observable.OnSubscribe<RnRForm>) subscriber -> { try { dataViewToModel(consultationNumbers); rnrFormRepository.createOrUpdateWithItems(rnRForm); subscriber.onNext(rnRForm); subscriber.onCompleted(); } catch (LMISException e) { new LMISException(e, "VIARequisitionPresenter.getSaveFormObservable").reportToFabric(); subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } VIARequisitionPresenter(); @Override void loadData(long formId, Date periodEndDate); void loadEmergencyData(final List<StockCard> stockCards, final Date periodEndDate); @Override void attachView(BaseView baseView); void populateAdditionalDrugsViewModels(List<RnrFormItem> addedDrugInVIAs, Date periodBegin); void deleteRnRItemFromViewModel(final RnrFormItem rnrFormItem); @Override void updateUIAfterSubmit(); @Override void updateFormUI(); @Override void submitRequisition(); boolean processRequisition(String consultationNumbers); Observable<RnRForm> getSaveFormObservable(final String consultationNumbers); String getConsultationNumbers(); void setConsultationNumbers(String consultationNumbers); void createStockCardsOrUnarchiveAndAddToFormForAdditionalRnrItems(); Observable<Void> removeRnrItem(final RnrFormItem rnrFormItem);  }