### Question:
DefaultRulesEngine extends AbstractRulesEngine { @Override public void fire(Rules rules, Facts facts) { triggerListenersBeforeRules(rules, facts); doFire(rules, facts); triggerListenersAfterRules(rules, facts); } DefaultRulesEngine();  DefaultRulesEngine(final RulesEngineParameters parameters); @Override void fire(Rules rules, Facts facts); @Override Map<Rule, Boolean> check(Rules rules, Facts facts);  }### Answer:
@Test public void whenConditionIsTrue_thenActionShouldBeExecuted() throws Exception { when(rule1.evaluate(facts)).thenReturn(true); rules.register(rule1); rulesEngine.fire(rules, facts); verify(rule1).execute(facts); }
@Test public void whenConditionIsFalse_thenActionShouldNotBeExecuted() throws Exception { when(rule1.evaluate(facts)).thenReturn(false); rules.register(rule1); rulesEngine.fire(rules, facts); verify(rule1, never()).execute(facts); }
@Test public void rulesMustBeTriggeredInTheirNaturalOrder() throws Exception { when(rule1.evaluate(facts)).thenReturn(true); when(rule2.evaluate(facts)).thenReturn(true); when(rule2.compareTo(rule1)).thenReturn(1); rules.register(rule1); rules.register(rule2); rulesEngine.fire(rules, facts); InOrder inOrder = inOrder(rule1, rule2); inOrder.verify(rule1).execute(facts); inOrder.verify(rule2).execute(facts); }
@Test public void actionsMustBeExecutedInTheDefinedOrder() { rules.register(annotatedRule); rulesEngine.fire(rules, facts); assertEquals("012", annotatedRule.getActionSequence()); }
@Test public void annotatedRulesAndNonAnnotatedRulesShouldBeUsableTogether() throws Exception { when(rule1.evaluate(facts)).thenReturn(true); rules.register(rule1); rules.register(annotatedRule); rulesEngine.fire(rules, facts); verify(rule1).execute(facts); assertThat(annotatedRule.isExecuted()).isTrue(); }