@Test public void shouldFinalize() throws Exception { AnnualFacilityEstimateEntry facilityEstimateEntry = make(a(AnnualFacilityEstimateBuilder.defaultAnnualFacilityEstimateEntry, with(AnnualFacilityEstimateBuilder.id, 3L), with(AnnualFacilityEstimateBuilder.isFinal,false))); EstimateForm form = getDemographicEstimateFormForOneFacility(facilityEstimateEntry); service.finalizeEstimate(form, 2L); verify(repository, never()).insert(facilityEstimateEntry); verify(repository, times(1)).update(any(AnnualFacilityEstimateEntry.class)); verify(repository, times(1)).finalizeEstimate(any(AnnualFacilityEstimateEntry.class)); }
public void finalizeEstimate(EstimateForm form, Long userId) { this.save(form, userId); for (EstimateFormLineItem dto : ListUtil.emptyIfNull(form.getEstimateLineItems())) { for (AnnualFacilityEstimateEntry est : ListUtil.emptyIfNull(dto.getFacilityEstimates())) { est.setFacilityId(dto.getId()); if (est.hasId()) { est.setModifiedBy(userId); est.setModifiedDate(new Date()); est.setIsFinal(true); repository.finalizeEstimate(est); } } } }
AnnualFacilityDemographicEstimateService { public void finalizeEstimate(EstimateForm form, Long userId) { this.save(form, userId); for (EstimateFormLineItem dto : ListUtil.emptyIfNull(form.getEstimateLineItems())) { for (AnnualFacilityEstimateEntry est : ListUtil.emptyIfNull(dto.getFacilityEstimates())) { est.setFacilityId(dto.getId()); if (est.hasId()) { est.setModifiedBy(userId); est.setModifiedDate(new Date()); est.setIsFinal(true); repository.finalizeEstimate(est); } } } } }
AnnualFacilityDemographicEstimateService { public void finalizeEstimate(EstimateForm form, Long userId) { this.save(form, userId); for (EstimateFormLineItem dto : ListUtil.emptyIfNull(form.getEstimateLineItems())) { for (AnnualFacilityEstimateEntry est : ListUtil.emptyIfNull(dto.getFacilityEstimates())) { est.setFacilityId(dto.getId()); if (est.hasId()) { est.setModifiedBy(userId); est.setModifiedDate(new Date()); est.setIsFinal(true); repository.finalizeEstimate(est); } } } }  }
AnnualFacilityDemographicEstimateService { public void finalizeEstimate(EstimateForm form, Long userId) { this.save(form, userId); for (EstimateFormLineItem dto : ListUtil.emptyIfNull(form.getEstimateLineItems())) { for (AnnualFacilityEstimateEntry est : ListUtil.emptyIfNull(dto.getFacilityEstimates())) { est.setFacilityId(dto.getId()); if (est.hasId()) { est.setModifiedBy(userId); est.setModifiedDate(new Date()); est.setIsFinal(true); repository.finalizeEstimate(est); } } } }  void save(EstimateForm estimateForm, Long userId); void finalizeEstimate(EstimateForm form, Long userId); void undoFinalize(EstimateForm form, Long userId); EstimateForm getEstimateForm(Long userId, Long programId, Integer year); List<AnnualFacilityEstimateEntry> getEstimateValuesForFacility(Long facilityId, Long programId, Integer year); }
AnnualFacilityDemographicEstimateService { public void finalizeEstimate(EstimateForm form, Long userId) { this.save(form, userId); for (EstimateFormLineItem dto : ListUtil.emptyIfNull(form.getEstimateLineItems())) { for (AnnualFacilityEstimateEntry est : ListUtil.emptyIfNull(dto.getFacilityEstimates())) { est.setFacilityId(dto.getId()); if (est.hasId()) { est.setModifiedBy(userId); est.setModifiedDate(new Date()); est.setIsFinal(true); repository.finalizeEstimate(est); } } } }  void save(EstimateForm estimateForm, Long userId); void finalizeEstimate(EstimateForm form, Long userId); void undoFinalize(EstimateForm form, Long userId); EstimateForm getEstimateForm(Long userId, Long programId, Integer year); List<AnnualFacilityEstimateEntry> getEstimateValuesForFacility(Long facilityId, Long programId, Integer year);  }