### Question:
InferenceRulesEngine extends AbstractRulesEngine { @Override public void fire(Rules rules, Facts facts) { Set<Rule> selectedRules; do { LOGGER.debug("Selecting candidate rules based on the following facts: {}", facts); selectedRules = selectCandidates(rules, facts); if (!selectedRules.isEmpty()) { delegate.fire(new Rules(selectedRules), facts); } else { LOGGER.debug("No candidate rules found for facts: {}", facts); } } while (!selectedRules.isEmpty()); } InferenceRulesEngine();  InferenceRulesEngine(RulesEngineParameters parameters); @Override void fire(Rules rules, Facts facts); @Override Map<Rule, Boolean> check(Rules rules, Facts facts); void registerRuleListener(RuleListener ruleListener); void registerRuleListeners(List<RuleListener> ruleListeners); void registerRulesEngineListener(RulesEngineListener rulesEngineListener); void registerRulesEngineListeners(List<RulesEngineListener> rulesEngineListeners);  }### Answer:
@Test public void testCandidateSelection() { Facts facts = new Facts(); facts.put("foo", true); DummyRule dummyRule = new DummyRule(); AnotherDummyRule anotherDummyRule = new AnotherDummyRule(); Rules rules = new Rules(dummyRule, anotherDummyRule); RulesEngine rulesEngine = new InferenceRulesEngine(); rulesEngine.fire(rules, facts); assertThat(dummyRule.isExecuted()).isTrue(); assertThat(anotherDummyRule.isExecuted()).isFalse(); }
@Test public void testCandidateOrdering() { Facts facts = new Facts(); facts.put("foo", true); facts.put("bar", true); DummyRule dummyRule = new DummyRule(); AnotherDummyRule anotherDummyRule = new AnotherDummyRule(); Rules rules = new Rules(dummyRule, anotherDummyRule); RulesEngine rulesEngine = new InferenceRulesEngine(); rulesEngine.fire(rules, facts); assertThat(dummyRule.isExecuted()).isTrue(); assertThat(anotherDummyRule.isExecuted()).isTrue(); assertThat(dummyRule.getTimestamp()).isLessThanOrEqualTo(anotherDummyRule.getTimestamp()); }