@Test public void shouldFinalize() throws Exception { AnnualDistrictEstimateEntry districtEstimateEntry = make(a(AnnualDistrictEstimateBuilder.defaultAnnualDistrictEstimateEntry, with(AnnualDistrictEstimateBuilder.id, 3L), with(AnnualDistrictEstimateBuilder.isFinal, false))); EstimateForm form = getDemographicEstimateFormForOneDistrict(districtEstimateEntry); service.finalizeEstimate(form, 2L); verify(repository, never()).insert(districtEstimateEntry); verify(repository, times(1)).update(any(AnnualDistrictEstimateEntry.class)); verify(repository, times(1)).finalizeEstimate(any(AnnualDistrictEstimateEntry.class)); }
public void finalizeEstimate(EstimateForm form, Long userId) { this.save(form, userId); for (EstimateFormLineItem dto : ListUtil.emptyIfNull(form.getEstimateLineItems())) { for (AnnualDistrictEstimateEntry est : ListUtil.emptyIfNull(dto.getDistrictEstimates())) { est.setDistrictId(dto.getId()); if (est.getId() != null) { est.setModifiedBy(userId); est.setModifiedDate(new Date()); est.setIsFinal(true); repository.finalizeEstimate(est); } } } }
AnnualDistrictDemographicEstimateService { public void finalizeEstimate(EstimateForm form, Long userId) { this.save(form, userId); for (EstimateFormLineItem dto : ListUtil.emptyIfNull(form.getEstimateLineItems())) { for (AnnualDistrictEstimateEntry est : ListUtil.emptyIfNull(dto.getDistrictEstimates())) { est.setDistrictId(dto.getId()); if (est.getId() != null) { est.setModifiedBy(userId); est.setModifiedDate(new Date()); est.setIsFinal(true); repository.finalizeEstimate(est); } } } } }
AnnualDistrictDemographicEstimateService { public void finalizeEstimate(EstimateForm form, Long userId) { this.save(form, userId); for (EstimateFormLineItem dto : ListUtil.emptyIfNull(form.getEstimateLineItems())) { for (AnnualDistrictEstimateEntry est : ListUtil.emptyIfNull(dto.getDistrictEstimates())) { est.setDistrictId(dto.getId()); if (est.getId() != null) { est.setModifiedBy(userId); est.setModifiedDate(new Date()); est.setIsFinal(true); repository.finalizeEstimate(est); } } } }  }
AnnualDistrictDemographicEstimateService { public void finalizeEstimate(EstimateForm form, Long userId) { this.save(form, userId); for (EstimateFormLineItem dto : ListUtil.emptyIfNull(form.getEstimateLineItems())) { for (AnnualDistrictEstimateEntry est : ListUtil.emptyIfNull(dto.getDistrictEstimates())) { est.setDistrictId(dto.getId()); if (est.getId() != null) { 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(Integer year, Long programId, Long userId); }
AnnualDistrictDemographicEstimateService { public void finalizeEstimate(EstimateForm form, Long userId) { this.save(form, userId); for (EstimateFormLineItem dto : ListUtil.emptyIfNull(form.getEstimateLineItems())) { for (AnnualDistrictEstimateEntry est : ListUtil.emptyIfNull(dto.getDistrictEstimates())) { est.setDistrictId(dto.getId()); if (est.getId() != null) { 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(Integer year, Long programId, Long userId);  }