### Question:
CustomerInventoryBuilder { public CustomerInventory build() { Map<String, ProductCategoryInventory> inventories = Maps.newHashMap(); for(ProductCategory productCategory : productCategories) { if(parameters.countPetsBySpecies(productCategory.getApplicableSpecies()) > 0) { ProductCategoryInventory inventory = new ProductCategoryInventory(productCategory, parameters, seedFactory); inventories.put(productCategory.getCategoryLabel(), inventory); } } return new CustomerInventory(inventories); } CustomerInventoryBuilder(CustomerTransactionParameters parameters,
			SeedFactory seedFactory); void addProductCategory(ProductCategory productCategory); void addAllProductCategories(Collection<ProductCategory> productCategories); CustomerInventory build();  }### Answer:
@Test public void testBuild() throws Exception { SeedFactory seedFactory = new SeedFactory(1234); CustomerTransactionParametersSamplerBuilder transParamsBuilder = new CustomerTransactionParametersSamplerBuilder(seedFactory); Sampler<CustomerTransactionParameters> sampler = transParamsBuilder.build(); CustomerTransactionParameters parameters = sampler.sample(); ProductCategoryBuilder builder = new ProductCategoryBuilder(); builder.addApplicableSpecies(PetSpecies.DOG); builder.setAmountUsedPetPetAverage(1.0); builder.setAmountUsedPetPetVariance(1.0); builder.setDailyUsageRate(2.0); builder.setCategory("dog food"); ProductCategory category = builder.build(); CustomerInventoryBuilder inventoryBuilder = new CustomerInventoryBuilder(parameters, seedFactory); inventoryBuilder.addProductCategory(category); CustomerInventory inventory = inventoryBuilder.build(); for(Map.Entry<String, Double> entry : inventory.getExhaustionTimes().entrySet()) { assertEquals(entry.getValue(), 0.0, 0.0001); } for(Map.Entry<String, Double> entry : inventory.getInventoryAmounts(0.0).entrySet()) { assertEquals(entry.getValue(), 0.0, 0.0001); } Map<String, Object> fields = Maps.newHashMap(); fields.put(Constants.PRODUCT_CATEGORY, "dog food"); fields.put(Constants.PRODUCT_QUANTITY, 30.0); Product product = new Product(fields); inventory.simulatePurchase(1.0, product); Map<String, Double> exhaustionTimes = inventory.getExhaustionTimes(); assertTrue(exhaustionTimes.containsKey("dog food")); assertTrue(exhaustionTimes.get("dog food") > 0.0); Map<String, Double> amounts = inventory.getInventoryAmounts(2.0); assertTrue(amounts.containsKey("dog food")); assertTrue(amounts.get("dog food") > 0.0); }