@Test @SuppressWarnings("unchecked") public void decisionBooksShouldRunDecisionsAndRules() { Decision<String, Boolean> decision1 = (Decision<String, Boolean>) mock(Decision.class); Rule<String> rule = (Rule<String>) mock(Rule.class); Decision<String, Boolean> decision2 = (Decision<String, Boolean>) spy(Decision.class); DecisionBook<String, Boolean> decisionBook = spy(new DecisionBook<String, Boolean>() { @Override protected void defineRules() { } }); decisionBook.given("hello", "world").addRule(decision1); decisionBook.addRule(rule); decisionBook.addRule(decision2); decisionBook.run(); verify(decision1, times(1)).setNextRule(rule); verify(rule, times(1)).setNextRule(decision2); verify(decision1, times(1)).run(); verify(decision1, times(1)).given(anyList()); verify(decisionBook, times(0)).defineRules(); }
public void addRule(Decision<T, U> rule) { if (rule == null) { return; } super.addRule(rule); rule.setResult(_result); }
DecisionBook extends RuleBook<T> { public void addRule(Decision<T, U> rule) { if (rule == null) { return; } super.addRule(rule); rule.setResult(_result); } }
DecisionBook extends RuleBook<T> { public void addRule(Decision<T, U> rule) { if (rule == null) { return; } super.addRule(rule); rule.setResult(_result); }  }
DecisionBook extends RuleBook<T> { public void addRule(Decision<T, U> rule) { if (rule == null) { return; } super.addRule(rule); rule.setResult(_result); }  final DecisionBook<T, U> withDefaultResult(U result); void addRule(Decision<T, U> rule); U getResult(); }
DecisionBook extends RuleBook<T> { public void addRule(Decision<T, U> rule) { if (rule == null) { return; } super.addRule(rule); rule.setResult(_result); }  final DecisionBook<T, U> withDefaultResult(U result); void addRule(Decision<T, U> rule); U getResult();  }