@Test public void shouldCallValidateOnEachLineItem() throws Exception { final RnrLineItem rnrLineItem1 = mock(RnrLineItem.class); final RnrLineItem rnrLineItem2 = mock(RnrLineItem.class); when(rnrLineItem1.calculateCost()).thenReturn(new Money("10")); when(rnrLineItem2.calculateCost()).thenReturn(new Money("10")); rnr.setFullSupplyLineItems(asList(rnrLineItem1)); rnr.setNonFullSupplyLineItems(asList(rnrLineItem2)); List<RnrColumn> programRnrColumns = new ArrayList<>(); ProgramRnrTemplate template = new ProgramRnrTemplate(programRnrColumns); calculationService.perform(rnr, template); verify(rnrLineItem1).validateMandatoryFields(template); verify(rnrLineItem1).validateCalculatedFields(template); verify(rnrLineItem2).validateNonFullSupply(); }
public void perform(Rnr requisition, ProgramRnrTemplate template) { requisition.setFullSupplyItemsSubmittedCost(new Money("0")); requisition.setNonFullSupplyItemsSubmittedCost(new Money("0")); calculateForFullSupply(requisition, template); calculateForNonFullSupply(requisition); }
CalculationService { public void perform(Rnr requisition, ProgramRnrTemplate template) { requisition.setFullSupplyItemsSubmittedCost(new Money("0")); requisition.setNonFullSupplyItemsSubmittedCost(new Money("0")); calculateForFullSupply(requisition, template); calculateForNonFullSupply(requisition); } }
CalculationService { public void perform(Rnr requisition, ProgramRnrTemplate template) { requisition.setFullSupplyItemsSubmittedCost(new Money("0")); requisition.setNonFullSupplyItemsSubmittedCost(new Money("0")); calculateForFullSupply(requisition, template); calculateForNonFullSupply(requisition); }  }
CalculationService { public void perform(Rnr requisition, ProgramRnrTemplate template) { requisition.setFullSupplyItemsSubmittedCost(new Money("0")); requisition.setNonFullSupplyItemsSubmittedCost(new Money("0")); calculateForFullSupply(requisition, template); calculateForNonFullSupply(requisition); }  void perform(Rnr requisition, ProgramRnrTemplate template); void fillReportingDays(Rnr requisition); void fillFieldsForInitiatedRequisition(Rnr requisition, ProgramRnrTemplate rnrTemplate, RegimenTemplate regimenTemplate); void copySkippedFieldFromPreviousPeriod(Rnr requisition); }
CalculationService { public void perform(Rnr requisition, ProgramRnrTemplate template) { requisition.setFullSupplyItemsSubmittedCost(new Money("0")); requisition.setNonFullSupplyItemsSubmittedCost(new Money("0")); calculateForFullSupply(requisition, template); calculateForNonFullSupply(requisition); }  void perform(Rnr requisition, ProgramRnrTemplate template); void fillReportingDays(Rnr requisition); void fillFieldsForInitiatedRequisition(Rnr requisition, ProgramRnrTemplate rnrTemplate, RegimenTemplate regimenTemplate); void copySkippedFieldFromPreviousPeriod(Rnr requisition); static final int MILLI_SECONDS_IN_ONE_DAY; static final int MAX_NUMBER_OF_PERIODS_TO_TRACK; }