### Question:
RuleBasedExecutor { public void executeIfPermitted(QualityClosure closure, Quality quality) { Quality copy = quality.copy(); closure.execute(copy); for (Rule rule : rules) { if (rule.permits(copy) == Denied) { return; } } closure.execute(quality); } RuleBasedExecutor(Iterable<Rule> rules); void executeIfPermitted(QualityClosure closure, Quality quality);  }### Answer:
@Test public void checksRulesWithAModifiedCopy() throws Exception { Quality copy = mock(Quality.class); when(quality.copy()).thenReturn(copy); Iterable<Rule> rules = Collections.singletonList(rule); new RuleBasedExecutor(rules).executeIfPermitted(closure, quality); InOrder inOrder = inOrder(closure, rule); inOrder.verify(closure).execute(copy); inOrder.verify(rule).permits(copy); }