@Test public void shouldNotAddAdjustItemsWhenKitIsNotFound() throws LMISException { RnRForm rnRForm = new RnRForm(); presenter.rnRForm = rnRForm; List<RnrFormItem> rnrFormItemListWrapper = new ArrayList<>(); RnrFormItem rnrFormItem = createRnrFormItem(1); rnrFormItem.setInitialAmount((long) 1000); rnrFormItem.setCalculatedOrderQuantity(500L); rnrFormItemListWrapper.add(rnrFormItem); rnRForm.setRnrFormItemListWrapper(rnrFormItemListWrapper); ArrayList<KitProduct> kitProducts = new ArrayList<>(); KitProduct kitProduct = new KitProduct(); kitProduct.setQuantity(2); kitProduct.setKitCode("kit"); kitProducts.add(kitProduct); when(mockProductRepository.queryKitProductByProductCode("code")).thenReturn(kitProducts); Product product = new Product(); product.setPrimaryName("KitName"); when(mockProductRepository.getByCode("kit")).thenReturn(product); when(mockStockRepository.queryStockCardByProductId(product.getId())).thenReturn(null); List<RequisitionFormItemViewModel> viewModelsFromRnrForm = presenter.getViewModelsFromRnrForm(rnRForm); assertThat(viewModelsFromRnrForm.size(), is(1)); assertThat(viewModelsFromRnrForm.get(0).getAdjustmentViewModels().size(), is(0)); }
protected List<RequisitionFormItemViewModel> getViewModelsFromRnrForm(RnRForm form) throws LMISException { if (requisitionFormItemViewModels.size() > 0) { return requisitionFormItemViewModels; } return from(form.getRnrItems(IsKit.No)).transform(item -> { RequisitionFormItemViewModel requisitionFormItemViewModel = new RequisitionFormItemViewModel(item); if (!isHistoryForm()) { adjustTheoretical(requisitionFormItemViewModel); } return requisitionFormItemViewModel; }).toList(); }
VIARequisitionPresenter extends BaseRequisitionPresenter { protected List<RequisitionFormItemViewModel> getViewModelsFromRnrForm(RnRForm form) throws LMISException { if (requisitionFormItemViewModels.size() > 0) { return requisitionFormItemViewModels; } return from(form.getRnrItems(IsKit.No)).transform(item -> { RequisitionFormItemViewModel requisitionFormItemViewModel = new RequisitionFormItemViewModel(item); if (!isHistoryForm()) { adjustTheoretical(requisitionFormItemViewModel); } return requisitionFormItemViewModel; }).toList(); } }
VIARequisitionPresenter extends BaseRequisitionPresenter { protected List<RequisitionFormItemViewModel> getViewModelsFromRnrForm(RnRForm form) throws LMISException { if (requisitionFormItemViewModels.size() > 0) { return requisitionFormItemViewModels; } return from(form.getRnrItems(IsKit.No)).transform(item -> { RequisitionFormItemViewModel requisitionFormItemViewModel = new RequisitionFormItemViewModel(item); if (!isHistoryForm()) { adjustTheoretical(requisitionFormItemViewModel); } return requisitionFormItemViewModel; }).toList(); } VIARequisitionPresenter(); }
VIARequisitionPresenter extends BaseRequisitionPresenter { protected List<RequisitionFormItemViewModel> getViewModelsFromRnrForm(RnRForm form) throws LMISException { if (requisitionFormItemViewModels.size() > 0) { return requisitionFormItemViewModels; } return from(form.getRnrItems(IsKit.No)).transform(item -> { RequisitionFormItemViewModel requisitionFormItemViewModel = new RequisitionFormItemViewModel(item); if (!isHistoryForm()) { adjustTheoretical(requisitionFormItemViewModel); } return requisitionFormItemViewModel; }).toList(); } 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 { protected List<RequisitionFormItemViewModel> getViewModelsFromRnrForm(RnRForm form) throws LMISException { if (requisitionFormItemViewModels.size() > 0) { return requisitionFormItemViewModels; } return from(form.getRnrItems(IsKit.No)).transform(item -> { RequisitionFormItemViewModel requisitionFormItemViewModel = new RequisitionFormItemViewModel(item); if (!isHistoryForm()) { adjustTheoretical(requisitionFormItemViewModel); } return requisitionFormItemViewModel; }).toList(); } 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);  }