### Question:
RuleExtensionMultiHandler extends RuleExtensionHandler<RuleExtensionHandler, RuleEvaluationContext> { @Override @SuppressWarnings("unchecked") public boolean accepts(final RuleExtension rule, final RuleEvaluationContext context) { return handlers.stream().anyMatch(h -> isHandlerAccepted(h, rule, context)); }  boolean addHandler(final RuleExtensionHandler handler); @Override Class<RuleExtensionHandler> getExtensionType(); @Override Class<RuleEvaluationContext> getContextType(); @Override @SuppressWarnings("unchecked") boolean accepts(final RuleExtension rule,
                           final RuleEvaluationContext context); @Override @SuppressWarnings("unchecked") RuleViolations evaluate(final RuleExtension rule,
                                   final RuleEvaluationContext context);  }### Answer:
@Test @SuppressWarnings("unchecked") public void testAcceptAll() { when(handler1.accepts(eq(rule1), eq(context))).thenReturn(true); when(handler2.accepts(eq(rule1), eq(context))).thenReturn(true); final boolean accepts = tested.accepts(rule1, context); assertTrue(accepts); }
@Test @SuppressWarnings("unchecked") public void testAcceptAllBut1() { when(handler1.accepts(eq(rule1), eq(context))).thenReturn(true); when(handler2.accepts(eq(rule1), eq(context))).thenReturn(false); final boolean accepts = tested.accepts(rule1, context); assertTrue(accepts); }
@Test @SuppressWarnings("unchecked") public void testAcceptAllBut2() { when(handler1.accepts(eq(rule1), eq(context))).thenReturn(false); when(handler2.accepts(eq(rule1), eq(context))).thenReturn(true); final boolean accepts = tested.accepts(rule1, context); assertTrue(accepts); }
@Test @SuppressWarnings("unchecked") public void testNotAccept() { when(handler1.accepts(eq(rule1), eq(context))).thenReturn(false); when(handler2.accepts(eq(rule1), eq(context))).thenReturn(false); final boolean accepts = tested.accepts(rule1, context); assertFalse(accepts); }