@Test public void shouldCopyApproverEditableFields() throws Exception { long userId = 5L; Rnr newRnr = make(a(defaultRequisition, with(modifiedBy, userId))); ProgramRnrTemplate template = new ProgramRnrTemplate(new ArrayList<RnrColumn>()); RnrLineItem lineItem1 = make(a(defaultRnrLineItem, with(beginningBalance, 24), with(RnrLineItemBuilder.productCode, "P1"))); RnrLineItem lineItem2 = make(a(defaultRnrLineItem, with(beginningBalance, 25), with(RnrLineItemBuilder.productCode, "P2"))); RnrLineItem lineItem3 = make(a(defaultRnrLineItem, with(beginningBalance, 27), with(RnrLineItemBuilder.productCode, "P3"))); RnrLineItem lineItem4 = make(a(defaultRnrLineItem, with(RnrLineItemBuilder.productCode, "P4"))); RnrLineItem spyLineItem1 = spy(lineItem1); RnrLineItem spyLineItem2 = spy(lineItem2); RnrLineItem spyLineItem3 = spy(lineItem3); RnrLineItem spyLineItem4 = spy(lineItem4); newRnr.setFullSupplyLineItems(asList(lineItem1, lineItem2)); newRnr.setNonFullSupplyLineItems(asList(lineItem3, lineItem4)); rnr.setFullSupplyLineItems(asList(spyLineItem1, spyLineItem2)); rnr.setNonFullSupplyLineItems(asList(spyLineItem3, spyLineItem4)); rnr.copyApproverEditableFields(newRnr, template); verify(spyLineItem1).copyApproverEditableFields(lineItem1, template); verify(spyLineItem2).copyApproverEditableFields(lineItem2, template); verify(spyLineItem3).copyApproverEditableFields(lineItem3, template); verify(spyLineItem4).copyApproverEditableFields(lineItem4, template); assertThat(rnr.getModifiedBy(), is(newRnr.getModifiedBy())); assertModifiedBy(userId); }
public void copyApproverEditableFields(Rnr rnr, ProgramRnrTemplate template) { this.modifiedBy = rnr.modifiedBy; copyApproverEditableFieldsToLineItems(rnr, template, rnr.fullSupplyLineItems); copyApproverEditableFieldsToLineItems(rnr, template, rnr.nonFullSupplyLineItems); }
Rnr extends BaseModel { public void copyApproverEditableFields(Rnr rnr, ProgramRnrTemplate template) { this.modifiedBy = rnr.modifiedBy; copyApproverEditableFieldsToLineItems(rnr, template, rnr.fullSupplyLineItems); copyApproverEditableFieldsToLineItems(rnr, template, rnr.nonFullSupplyLineItems); } }
Rnr extends BaseModel { public void copyApproverEditableFields(Rnr rnr, ProgramRnrTemplate template) { this.modifiedBy = rnr.modifiedBy; copyApproverEditableFieldsToLineItems(rnr, template, rnr.fullSupplyLineItems); copyApproverEditableFieldsToLineItems(rnr, template, rnr.nonFullSupplyLineItems); } Rnr(Facility facility, Program program, ProcessingPeriod period, Boolean emergency, Long modifiedBy, Long createdBy);  Rnr(Facility facility, Program program, ProcessingPeriod period, Boolean emergency, List<FacilityTypeApprovedProduct> facilityTypeApprovedProducts,
             List<Regimen> regimens, Long modifiedBy);  Rnr(Facility facility, Program program, ProcessingPeriod period);  Rnr(Long id); }
Rnr extends BaseModel { public void copyApproverEditableFields(Rnr rnr, ProgramRnrTemplate template) { this.modifiedBy = rnr.modifiedBy; copyApproverEditableFieldsToLineItems(rnr, template, rnr.fullSupplyLineItems); copyApproverEditableFieldsToLineItems(rnr, template, rnr.nonFullSupplyLineItems); } Rnr(Facility facility, Program program, ProcessingPeriod period, Boolean emergency, Long modifiedBy, Long createdBy);  Rnr(Facility facility, Program program, ProcessingPeriod period, Boolean emergency, List<FacilityTypeApprovedProduct> facilityTypeApprovedProducts,
             List<Regimen> regimens, Long modifiedBy);  Rnr(Facility facility, Program program, ProcessingPeriod period);  Rnr(Long id); void add(RnrLineItem rnrLineItem, Boolean fullSupply); void calculateForApproval(); void fillLineItems(List<FacilityTypeApprovedProduct> facilityTypeApprovedProducts); void setFieldsForApproval(); List<RnrLineItem> getAllLineItems(); void fillBasicInformation(Facility facility, Program program, ProcessingPeriod period); RnrLineItem findCorrespondingLineItem(final RnrLineItem item); RegimenLineItem findCorrespondingRegimenLineItem(final RegimenLineItem regimenLineItem); void setFieldsAccordingToTemplateFrom(Rnr previousRequisition, ProgramRnrTemplate template, RegimenTemplate regimenTemplate); void convertToOrder(Long userId); void fillFullSupplyCost(); void fillNonFullSupplyCost(); void validateForApproval(); void copyCreatorEditableFields(Rnr rnr, ProgramRnrTemplate rnrTemplate, RegimenTemplate regimenTemplate, List<ProgramProduct> programProducts); void copyApproverEditableFields(Rnr rnr, ProgramRnrTemplate template); void setAuditFieldsForRequisition(Long modifiedBy, RnrStatus status); void prepareForFinalApproval(); void approveAndAssignToNextSupervisoryNode(SupervisoryNode parent); boolean isApprovable(); boolean preAuthorize(); void addToNonFullSupplyCost(Money cost); void addToFullSupplyCost(Money cost); boolean isForVirtualFacility(); List<RnrLineItem> getNonSkippedLineItems(); void validateRegimenLineItems(RegimenTemplate regimenTemplate); @JsonIgnore boolean isBudgetingApplicable(); }
Rnr extends BaseModel { public void copyApproverEditableFields(Rnr rnr, ProgramRnrTemplate template) { this.modifiedBy = rnr.modifiedBy; copyApproverEditableFieldsToLineItems(rnr, template, rnr.fullSupplyLineItems); copyApproverEditableFieldsToLineItems(rnr, template, rnr.nonFullSupplyLineItems); } Rnr(Facility facility, Program program, ProcessingPeriod period, Boolean emergency, Long modifiedBy, Long createdBy);  Rnr(Facility facility, Program program, ProcessingPeriod period, Boolean emergency, List<FacilityTypeApprovedProduct> facilityTypeApprovedProducts,
             List<Regimen> regimens, Long modifiedBy);  Rnr(Facility facility, Program program, ProcessingPeriod period);  Rnr(Long id); void add(RnrLineItem rnrLineItem, Boolean fullSupply); void calculateForApproval(); void fillLineItems(List<FacilityTypeApprovedProduct> facilityTypeApprovedProducts); void setFieldsForApproval(); List<RnrLineItem> getAllLineItems(); void fillBasicInformation(Facility facility, Program program, ProcessingPeriod period); RnrLineItem findCorrespondingLineItem(final RnrLineItem item); RegimenLineItem findCorrespondingRegimenLineItem(final RegimenLineItem regimenLineItem); void setFieldsAccordingToTemplateFrom(Rnr previousRequisition, ProgramRnrTemplate template, RegimenTemplate regimenTemplate); void convertToOrder(Long userId); void fillFullSupplyCost(); void fillNonFullSupplyCost(); void validateForApproval(); void copyCreatorEditableFields(Rnr rnr, ProgramRnrTemplate rnrTemplate, RegimenTemplate regimenTemplate, List<ProgramProduct> programProducts); void copyApproverEditableFields(Rnr rnr, ProgramRnrTemplate template); void setAuditFieldsForRequisition(Long modifiedBy, RnrStatus status); void prepareForFinalApproval(); void approveAndAssignToNextSupervisoryNode(SupervisoryNode parent); boolean isApprovable(); boolean preAuthorize(); void addToNonFullSupplyCost(Money cost); void addToFullSupplyCost(Money cost); boolean isForVirtualFacility(); List<RnrLineItem> getNonSkippedLineItems(); void validateRegimenLineItems(RegimenTemplate regimenTemplate); @JsonIgnore boolean isBudgetingApplicable(); static final String RNR_VALIDATION_ERROR; }