### Question:
TransactionPurchasesHiddenMarkovModel implements ConditionalSampler<List<Product>, Double> { protected String chooseCategory(double transactionTime, int numPurchases) throws Exception { ImmutableMap<String, Double> exhaustionTimes = this.inventory.getExhaustionTimes(); Map<String, Double> weights = Maps.newHashMap(); for(Map.Entry<String, Double> entry : exhaustionTimes.entrySet()) { String category = entry.getKey(); double weight = this.categoryWF.weight(entry.getValue(), transactionTime); weights.put(category, weight); } if(numPurchases > 0) { weights.put(STOP_STATE, Constants.STOP_CATEGORY_WEIGHT); } Sampler<String> sampler = RouletteWheelSampler.create(weights, seedFactory); return sampler.sample(); } TransactionPurchasesHiddenMarkovModel(ConditionalSampler<Product, String> purchasingProcesses,
			ConditionalWeightFunction<Double, Double> categoryWF, CustomerInventory inventory,
				SeedFactory seedFactory); List<Product> sample(Double transactionTime);  }### Answer:
@Test public void testChooseCategory() throws Exception { TransactionPurchasesHiddenMarkovModel hmm = createHMM(); String category = hmm.chooseCategory(1.0, 0); assertNotNull(category); assertTrue(category.equals(TransactionPurchasesHiddenMarkovModel.STOP_STATE) || category.equals("dog food") || category.equals("cat food")); }