### Question:
CachedRuleManager implements RuleManager { @Override public RuleViolations evaluate(final RuleSet ruleSet, final RuleEvaluationContext context) { return ruleManager.evaluate(ruleSet, context); } @Inject  CachedRuleManager(final RuleManagerImpl ruleManager); @PostConstruct void init(); @Override RuleHandlerRegistry registry(); @Override RuleViolations evaluate(final RuleSet ruleSet,
                                   final RuleEvaluationContext context); @PreDestroy void destroy();  }### Answer:
@Test public void testEvaluateContainmentContextOnce() { tested.evaluate(ruleSet, containmentContext); tested.evaluate(ruleSet, containmentContext); verify(ruleSet, times(1)).getRules(); verify(containmentHandler, times(2)).evaluate(eq(containmentRule), eq(containmentContext)); verify(connectionHandler, never()).evaluate(any(CanConnect.class), any(ConnectionContext.class)); }
@Test public void testEvaluateConnectionContextOnce() { tested.evaluate(ruleSet, connectionContext); tested.evaluate(ruleSet, connectionContext); verify(ruleSet, times(1)).getRules(); verify(connectionHandler, times(2)).evaluate(eq(connectionRule), eq(connectionContext)); verify(containmentHandler, never()).evaluate(any(CanContain.class), any(ContainmentContext.class)); }