@Test public void shouldUpdateAdultCoverageLineItemsAndOpenedVialLineItemsIfAlreadyExists() throws Exception { AdultCoverageLineItem adultCoverageLineItem = new AdultCoverageLineItem(); adultCoverageLineItem.setId(1L); VaccinationAdultCoverage adultCoverage = new VaccinationAdultCoverage(asList(adultCoverageLineItem)); OpenedVialLineItem openedVialLineItem = new OpenedVialLineItem(); openedVialLineItem.setId(2L); adultCoverage.setOpenedVialLineItems(asList(openedVialLineItem)); repository.saveAdultCoverage(adultCoverage); verify(mapper).updateAdultCoverageLineItem(adultCoverageLineItem); verify(mapper).updateAdultCoverageOpenedVialLineItem(openedVialLineItem); }
public void saveAdultCoverage(VaccinationAdultCoverage adultCoverage) { for (AdultCoverageLineItem adultCoverageLineItem : adultCoverage.getAdultCoverageLineItems()) { if (adultCoverageLineItem.getId() == null) { mapper.insertAdultCoverageLineItem(adultCoverageLineItem); } else { mapper.updateAdultCoverageLineItem(adultCoverageLineItem); } } for (OpenedVialLineItem openedVialLineItem : adultCoverage.getOpenedVialLineItems()) { if (openedVialLineItem.getId() == null) { mapper.insertAdultCoverageOpenedVialLineItem(openedVialLineItem); } else { mapper.updateAdultCoverageOpenedVialLineItem(openedVialLineItem); } } }
VaccinationCoverageRepository { public void saveAdultCoverage(VaccinationAdultCoverage adultCoverage) { for (AdultCoverageLineItem adultCoverageLineItem : adultCoverage.getAdultCoverageLineItems()) { if (adultCoverageLineItem.getId() == null) { mapper.insertAdultCoverageLineItem(adultCoverageLineItem); } else { mapper.updateAdultCoverageLineItem(adultCoverageLineItem); } } for (OpenedVialLineItem openedVialLineItem : adultCoverage.getOpenedVialLineItems()) { if (openedVialLineItem.getId() == null) { mapper.insertAdultCoverageOpenedVialLineItem(openedVialLineItem); } else { mapper.updateAdultCoverageOpenedVialLineItem(openedVialLineItem); } } } }
VaccinationCoverageRepository { public void saveAdultCoverage(VaccinationAdultCoverage adultCoverage) { for (AdultCoverageLineItem adultCoverageLineItem : adultCoverage.getAdultCoverageLineItems()) { if (adultCoverageLineItem.getId() == null) { mapper.insertAdultCoverageLineItem(adultCoverageLineItem); } else { mapper.updateAdultCoverageLineItem(adultCoverageLineItem); } } for (OpenedVialLineItem openedVialLineItem : adultCoverage.getOpenedVialLineItems()) { if (openedVialLineItem.getId() == null) { mapper.insertAdultCoverageOpenedVialLineItem(openedVialLineItem); } else { mapper.updateAdultCoverageOpenedVialLineItem(openedVialLineItem); } } }  }
VaccinationCoverageRepository { public void saveAdultCoverage(VaccinationAdultCoverage adultCoverage) { for (AdultCoverageLineItem adultCoverageLineItem : adultCoverage.getAdultCoverageLineItems()) { if (adultCoverageLineItem.getId() == null) { mapper.insertAdultCoverageLineItem(adultCoverageLineItem); } else { mapper.updateAdultCoverageLineItem(adultCoverageLineItem); } } for (OpenedVialLineItem openedVialLineItem : adultCoverage.getOpenedVialLineItems()) { if (openedVialLineItem.getId() == null) { mapper.insertAdultCoverageOpenedVialLineItem(openedVialLineItem); } else { mapper.updateAdultCoverageOpenedVialLineItem(openedVialLineItem); } } }  void saveFullCoverage(VaccinationFullCoverage vaccinationFullCoverage); VaccinationFullCoverage getFullCoverageBy(Long facilityVisitId); List<TargetGroupProduct> getVaccinationProducts(); void saveChildCoverage(VaccinationChildCoverage childCoverage); VaccinationChildCoverage getChildCoverageBy(Long facilityVisitId); List<ProductVial> getProductVials(); void saveAdultCoverage(VaccinationAdultCoverage adultCoverage); VaccinationAdultCoverage getAdultCoverageBy(Long facilityVisitId); }
VaccinationCoverageRepository { public void saveAdultCoverage(VaccinationAdultCoverage adultCoverage) { for (AdultCoverageLineItem adultCoverageLineItem : adultCoverage.getAdultCoverageLineItems()) { if (adultCoverageLineItem.getId() == null) { mapper.insertAdultCoverageLineItem(adultCoverageLineItem); } else { mapper.updateAdultCoverageLineItem(adultCoverageLineItem); } } for (OpenedVialLineItem openedVialLineItem : adultCoverage.getOpenedVialLineItems()) { if (openedVialLineItem.getId() == null) { mapper.insertAdultCoverageOpenedVialLineItem(openedVialLineItem); } else { mapper.updateAdultCoverageOpenedVialLineItem(openedVialLineItem); } } }  void saveFullCoverage(VaccinationFullCoverage vaccinationFullCoverage); VaccinationFullCoverage getFullCoverageBy(Long facilityVisitId); List<TargetGroupProduct> getVaccinationProducts(); void saveChildCoverage(VaccinationChildCoverage childCoverage); VaccinationChildCoverage getChildCoverageBy(Long facilityVisitId); List<ProductVial> getProductVials(); void saveAdultCoverage(VaccinationAdultCoverage adultCoverage); VaccinationAdultCoverage getAdultCoverageBy(Long facilityVisitId);  }