@Test public void shouldPassProductValidationIfNoneExist() throws Exception { Report report = new Report(); Rnr savedRequisition = new Rnr(); restRequisitionCalculator.validateProducts(report.getProducts(), savedRequisition); }
public void validateProducts(List<RnrLineItem> products, Rnr savedRequisition) { if (products == null) { return; } List<String> invalidProductCodes = new ArrayList<>(); for (final RnrLineItem product : products) { RnrLineItem correspondingLineItem = savedRequisition.findCorrespondingLineItem(product); if (correspondingLineItem == null) { invalidProductCodes.add(product.getProductCode()); } } if (!invalidProductCodes.isEmpty()) { throw new DataException("invalid.product.codes", invalidProductCodes.toString()); } }
RestRequisitionCalculator { public void validateProducts(List<RnrLineItem> products, Rnr savedRequisition) { if (products == null) { return; } List<String> invalidProductCodes = new ArrayList<>(); for (final RnrLineItem product : products) { RnrLineItem correspondingLineItem = savedRequisition.findCorrespondingLineItem(product); if (correspondingLineItem == null) { invalidProductCodes.add(product.getProductCode()); } } if (!invalidProductCodes.isEmpty()) { throw new DataException("invalid.product.codes", invalidProductCodes.toString()); } } }
RestRequisitionCalculator { public void validateProducts(List<RnrLineItem> products, Rnr savedRequisition) { if (products == null) { return; } List<String> invalidProductCodes = new ArrayList<>(); for (final RnrLineItem product : products) { RnrLineItem correspondingLineItem = savedRequisition.findCorrespondingLineItem(product); if (correspondingLineItem == null) { invalidProductCodes.add(product.getProductCode()); } } if (!invalidProductCodes.isEmpty()) { throw new DataException("invalid.product.codes", invalidProductCodes.toString()); } }  }
RestRequisitionCalculator { public void validateProducts(List<RnrLineItem> products, Rnr savedRequisition) { if (products == null) { return; } List<String> invalidProductCodes = new ArrayList<>(); for (final RnrLineItem product : products) { RnrLineItem correspondingLineItem = savedRequisition.findCorrespondingLineItem(product); if (correspondingLineItem == null) { invalidProductCodes.add(product.getProductCode()); } } if (!invalidProductCodes.isEmpty()) { throw new DataException("invalid.product.codes", invalidProductCodes.toString()); } }  void validatePeriod(Facility reportingFacility, Program reportingProgram); void validateCustomPeriod(Facility reportingFacility, Program reportingProgram, ProcessingPeriod period, Long userId); void validateProducts(List<RnrLineItem> products, Rnr savedRequisition); Rnr setDefaultValues(Rnr requisition); }
RestRequisitionCalculator { public void validateProducts(List<RnrLineItem> products, Rnr savedRequisition) { if (products == null) { return; } List<String> invalidProductCodes = new ArrayList<>(); for (final RnrLineItem product : products) { RnrLineItem correspondingLineItem = savedRequisition.findCorrespondingLineItem(product); if (correspondingLineItem == null) { invalidProductCodes.add(product.getProductCode()); } } if (!invalidProductCodes.isEmpty()) { throw new DataException("invalid.product.codes", invalidProductCodes.toString()); } }  void validatePeriod(Facility reportingFacility, Program reportingProgram); void validateCustomPeriod(Facility reportingFacility, Program reportingProgram, ProcessingPeriod period, Long userId); void validateProducts(List<RnrLineItem> products, Rnr savedRequisition); Rnr setDefaultValues(Rnr requisition);  }