### Question:
FieldPredicate implements Rule { @Override public boolean ruleMatches(Product product) { if(! product.getFieldNames().contains(fieldName)) { throw new IllegalArgumentException("Product (" + product.toString() + ") does not contain field name (" + fieldName + ")"); } Object seenValue = product.getFieldValue(fieldName); return allowedValues.contains(seenValue); } FieldPredicate(String fieldName, String ... allowedValues); @Override boolean ruleMatches(Product product);  }### Answer:
@Test public void testRuleMatches() { Map<String, Object> fields = ImmutableMap.of("brand", (Object) "Chef Corgi", "flavor", (Object) "chicken"); Product product = new Product(fields); Rule rule = new FieldPredicate("brand", "Chef Corgi"); Assert.assertTrue(rule.ruleMatches(product)); rule = new FieldPredicate("brand", "Happy Pup"); Assert.assertFalse(rule.ruleMatches(product)); }