@Test public void shouldSave() throws Exception { List<ProductDoseDTO> protocols = new ArrayList<>(); ProductDoseDTO dto = new ProductDoseDTO(); dto.setDoses(new ArrayList<VaccineProductDose>()); VaccineProductDose dose = new VaccineProductDose(); dose.setProgramId(1L); dto.getDoses().add(dose); protocols.add(dto); doNothing().when(repository).deleteAllByProgram(1L); service.save(protocols); verify(repository).deleteAllByProgram(1L); verify(repository).insert(any(VaccineProductDose.class)); }
public void save(List<ProductDoseDTO> productDoseDTOs) { repository.deleteAllByProgram(productDoseDTOs.get(0).getDoses().get(0).getProgramId()); for (ProductDoseDTO productDose : productDoseDTOs) { for (VaccineProductDose dose : productDose.getDoses()) { repository.insert(dose); } } }
VaccineProductDoseService { public void save(List<ProductDoseDTO> productDoseDTOs) { repository.deleteAllByProgram(productDoseDTOs.get(0).getDoses().get(0).getProgramId()); for (ProductDoseDTO productDose : productDoseDTOs) { for (VaccineProductDose dose : productDose.getDoses()) { repository.insert(dose); } } } }
VaccineProductDoseService { public void save(List<ProductDoseDTO> productDoseDTOs) { repository.deleteAllByProgram(productDoseDTOs.get(0).getDoses().get(0).getProgramId()); for (ProductDoseDTO productDose : productDoseDTOs) { for (VaccineProductDose dose : productDose.getDoses()) { repository.insert(dose); } } }  }
VaccineProductDoseService { public void save(List<ProductDoseDTO> productDoseDTOs) { repository.deleteAllByProgram(productDoseDTOs.get(0).getDoses().get(0).getProgramId()); for (ProductDoseDTO productDose : productDoseDTOs) { for (VaccineProductDose dose : productDose.getDoses()) { repository.insert(dose); } } }  VaccineServiceConfigDTO getProductDoseForProgram(Long programId); List<VaccineProductDose> getForProgram(Long programId); void save(List<ProductDoseDTO> productDoseDTOs); }
VaccineProductDoseService { public void save(List<ProductDoseDTO> productDoseDTOs) { repository.deleteAllByProgram(productDoseDTOs.get(0).getDoses().get(0).getProgramId()); for (ProductDoseDTO productDose : productDoseDTOs) { for (VaccineProductDose dose : productDose.getDoses()) { repository.insert(dose); } } }  VaccineServiceConfigDTO getProductDoseForProgram(Long programId); List<VaccineProductDose> getForProgram(Long programId); void save(List<ProductDoseDTO> productDoseDTOs);  }