PTVProgramToPTVViewModelMapper { public List<PTVViewModel> buildPlaceholderRows(PTVProgram ptvProgram) throws LMISException { ptvViewModels = new ArrayList<>(); List<HealthFacilityService> healthFacilities = healthFacilityServiceRepository.getAll(); List<PTVProgramStockInformation> ptvProgramStocksInformation = new ArrayList<>(ptvProgram.getPtvProgramStocksInformation()); createRowsForFacilities(ptvViewModels, healthFacilities); ptvViewModelEntry = new PTVViewModel(ENTRIES); ptvViewModelLossesAndAdjustments = new PTVViewModel(LOSSES_AND_ADJUSTMENTS); ptvViewModelRequisition = new PTVViewModel(REQUISITIONS); ptvFinalStock = new PTVViewModel(FINAL_STOCK); for (PTVProgramStockInformation ptvProgramStockInformation : ptvProgramStocksInformation) { List<ServiceDispensation> serviceDispensations = new ArrayList<>(ptvProgramStockInformation.getServiceDispensations()); setQuantitiesForModels(healthFacilities, ptvProgramStockInformation, serviceDispensations); } addPTVInformation(); return ptvViewModels; } @Inject  PTVProgramToPTVViewModelMapper(); List<PTVViewModel> buildPlaceholderRows(PTVProgram ptvProgram);  }
@Test public void shouldReturnAListOfPTVViewModelsWithTheCorrectValues() throws LMISException { int numberOfTotalRows = 5; when(healthFacilityServiceRepository.getAll()).thenReturn(PTVUtil.createDummyHealthFacilityServices()); Period period = new Period(DateTime.now()); PTVProgram ptvProgram = PTVUtil.createDummyPTVProgram(period); List<PTVProgramStockInformation> ptvProgramStocksInformation = PTVUtil.createDummyPTVProgramStocksInformation(); ptvProgram.setPtvProgramStocksInformation(ptvProgramStocksInformation); List<PTVViewModel> ptvViewModels = ptvProgramToPTVViewModelMapper.buildPlaceholderRows(ptvProgram); assertThat(ptvViewModels.size(), is(PTVUtil.createDummyHealthFacilityServices().size()+ numberOfTotalRows)); assertQuantitiesOfFirstPTVProgramStockInformationAreTheQuantitesForTheQuantity1OfEachViewModel(ptvProgramStocksInformation, ptvViewModels); }