@Test public void shouldReturnPTVProgramStocksInformationWhenStockCardInformationDoesNotExist() throws LMISException { stockOnHand = DEFAULT_QUANTITY; movementQuantity = DEFAULT_QUANTITY; List<PTVProgramStockInformation> expectedPtvProgramStocksInformation = new ArrayList<>(); when(healthFacilityServiceRepository.getAll()).thenReturn(expectedHealthFacilityServices); List<Product> products = PTVUtil.getProductsWithPTVProductCodes(); when(productRepository.getProductsByCodes(PTVUtil.ptvProductCodes)).thenReturn(products); for (Product product : products) { StockCard stockCard = null; PTVProgramStockInformation ptvProgramStockInformation = createPtvProgramStockInformation(product); List<ServiceDispensation> serviceDispensations = PTVUtil.createDummyServiceDispensations(ptvProgramStockInformation); when(serviceDispensationBuilder.buildInitialServiceDispensations(ptvProgramStockInformation)).thenReturn(serviceDispensations); when(stockRepository.queryStockCardByProductCode(product.getCode())).thenReturn(stockCard); expectedPtvProgramStocksInformation.add(ptvProgramStockInformation); } List<PTVProgramStockInformation> actualPtvProgramStocksInformation = ptvProgramStockInformationBuilder.buildPTVProgramStockInformation(ptvProgram); assertThat(actualPtvProgramStocksInformation, is(expectedPtvProgramStocksInformation)); }
public List<PTVProgramStockInformation> buildPTVProgramStockInformation(PTVProgram ptvProgram) throws LMISException { List<PTVProgramStockInformation> ptvProgramStocksInformation = new ArrayList<>(); List<Product> products = productRepository.getProductsByCodes(getProductCodes()); for (Product product : products) { PTVProgramStockInformation ptvProgramStockInformation = new PTVProgramStockInformation(); ptvProgramStockInformation.setProduct(product); ptvProgramStockInformation.setPtvProgram(ptvProgram); List<ServiceDispensation> serviceDispensations = serviceDispensationBuilder.buildInitialServiceDispensations(ptvProgramStockInformation); ptvProgramStockInformation.setServiceDispensations(serviceDispensations); setStockCardInformation(product, ptvProgramStockInformation); ptvProgramStocksInformation.add(ptvProgramStockInformation); } return ptvProgramStocksInformation; }
PTVProgramStockInformationBuilder { public List<PTVProgramStockInformation> buildPTVProgramStockInformation(PTVProgram ptvProgram) throws LMISException { List<PTVProgramStockInformation> ptvProgramStocksInformation = new ArrayList<>(); List<Product> products = productRepository.getProductsByCodes(getProductCodes()); for (Product product : products) { PTVProgramStockInformation ptvProgramStockInformation = new PTVProgramStockInformation(); ptvProgramStockInformation.setProduct(product); ptvProgramStockInformation.setPtvProgram(ptvProgram); List<ServiceDispensation> serviceDispensations = serviceDispensationBuilder.buildInitialServiceDispensations(ptvProgramStockInformation); ptvProgramStockInformation.setServiceDispensations(serviceDispensations); setStockCardInformation(product, ptvProgramStockInformation); ptvProgramStocksInformation.add(ptvProgramStockInformation); } return ptvProgramStocksInformation; } }
PTVProgramStockInformationBuilder { public List<PTVProgramStockInformation> buildPTVProgramStockInformation(PTVProgram ptvProgram) throws LMISException { List<PTVProgramStockInformation> ptvProgramStocksInformation = new ArrayList<>(); List<Product> products = productRepository.getProductsByCodes(getProductCodes()); for (Product product : products) { PTVProgramStockInformation ptvProgramStockInformation = new PTVProgramStockInformation(); ptvProgramStockInformation.setProduct(product); ptvProgramStockInformation.setPtvProgram(ptvProgram); List<ServiceDispensation> serviceDispensations = serviceDispensationBuilder.buildInitialServiceDispensations(ptvProgramStockInformation); ptvProgramStockInformation.setServiceDispensations(serviceDispensations); setStockCardInformation(product, ptvProgramStockInformation); ptvProgramStocksInformation.add(ptvProgramStockInformation); } return ptvProgramStocksInformation; }  }
PTVProgramStockInformationBuilder { public List<PTVProgramStockInformation> buildPTVProgramStockInformation(PTVProgram ptvProgram) throws LMISException { List<PTVProgramStockInformation> ptvProgramStocksInformation = new ArrayList<>(); List<Product> products = productRepository.getProductsByCodes(getProductCodes()); for (Product product : products) { PTVProgramStockInformation ptvProgramStockInformation = new PTVProgramStockInformation(); ptvProgramStockInformation.setProduct(product); ptvProgramStockInformation.setPtvProgram(ptvProgram); List<ServiceDispensation> serviceDispensations = serviceDispensationBuilder.buildInitialServiceDispensations(ptvProgramStockInformation); ptvProgramStockInformation.setServiceDispensations(serviceDispensations); setStockCardInformation(product, ptvProgramStockInformation); ptvProgramStocksInformation.add(ptvProgramStockInformation); } return ptvProgramStocksInformation; }  List<PTVProgramStockInformation> buildPTVProgramStockInformation(PTVProgram ptvProgram); List<PTVProgramStockInformation> buildExistentPTVProgramStockInformation(PTVProgram ptvProgram); }
PTVProgramStockInformationBuilder { public List<PTVProgramStockInformation> buildPTVProgramStockInformation(PTVProgram ptvProgram) throws LMISException { List<PTVProgramStockInformation> ptvProgramStocksInformation = new ArrayList<>(); List<Product> products = productRepository.getProductsByCodes(getProductCodes()); for (Product product : products) { PTVProgramStockInformation ptvProgramStockInformation = new PTVProgramStockInformation(); ptvProgramStockInformation.setProduct(product); ptvProgramStockInformation.setPtvProgram(ptvProgram); List<ServiceDispensation> serviceDispensations = serviceDispensationBuilder.buildInitialServiceDispensations(ptvProgramStockInformation); ptvProgramStockInformation.setServiceDispensations(serviceDispensations); setStockCardInformation(product, ptvProgramStockInformation); ptvProgramStocksInformation.add(ptvProgramStockInformation); } return ptvProgramStocksInformation; }  List<PTVProgramStockInformation> buildPTVProgramStockInformation(PTVProgram ptvProgram); List<PTVProgramStockInformation> buildExistentPTVProgramStockInformation(PTVProgram ptvProgram); static final long DEFAULT_QUANTITY; }