### Question:
NotRule implements Rule { @Override public boolean ruleMatches(Product product) throws IllegalArgumentException { return ! rule.ruleMatches(product); } NotRule(Rule rule); @Override boolean ruleMatches(Product product);  }### Answer:
@Test public void testRuleMatches() { Rule rule = new NotRule( new AlwaysTrueRule()); Assert.assertFalse(rule.ruleMatches(null)); rule = new NotRule( new NotRule( new AlwaysTrueRule())); Assert.assertTrue(rule.ruleMatches(null)); }