Skip to content

Commit

Permalink
issue #121 : rename methods in RulesEngineListener to be consistent w…
Browse files Browse the repository at this point in the history
…ith RuleListener
  • Loading branch information
fmbenhassine committed Dec 11, 2017
1 parent 4d2dad6 commit 14fe227
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@
public interface RulesEngineListener {

/**
* Triggered before firing the rule set.
* <strong>When this listener is used with a {@link InferenceRulesEngine}, this method will be triggered before each candidate rule set in each iteration.</strong>
* Triggered before evaluating the rule set.
* <strong>When this listener is used with a {@link InferenceRulesEngine}, this method will be triggered before the evaluation of each candidate rule set in each iteration.</strong>
*
* @param rules to fire
* @param facts present before firing rules
*/
void beforeFiringRules(Rules rules, Facts facts);
void beforeEvaluate(Rules rules, Facts facts);

/**
* Triggered after firing the rule set
* <strong>When this listener is used with a {@link InferenceRulesEngine}, this method will be triggered after each candidate rule set in each iteration.</strong>
* Triggered after executing the rule set
* <strong>When this listener is used with a {@link InferenceRulesEngine}, this method will be triggered after the execution of each candidate rule set in each iteration.</strong>
*
* @param rules fired
* @param facts present after firing rules
*/
void afterFiringRules(Rules rules, Facts facts);
void afterExecute(Rules rules, Facts facts);
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ private void triggerListenersAfterEvaluate(Rule rule, Facts facts, boolean evalu

private void triggerListenersBeforeRules(Rules rule, Facts facts) {
for (RulesEngineListener rulesEngineListener : rulesEngineListeners) {
rulesEngineListener.beforeFiringRules(rule, facts);
rulesEngineListener.beforeEvaluate(rule, facts);
}
}

private void triggerListenersAfterRules(Rules rule, Facts facts) {
for (RulesEngineListener rulesEngineListener : rulesEngineListeners) {
rulesEngineListener.afterFiringRules(rule, facts);
rulesEngineListener.afterExecute(rule, facts);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void setup() throws Exception {
}

@Test
public void rulesEngineListenersShouldBeCalledInOrder() throws Exception {
public void rulesEngineListenersShouldBeCalledInOrderWhenFiringRules() throws Exception {
// Given
when(rule1.evaluate(facts)).thenReturn(true);
rules.register(rule1);
Expand All @@ -61,12 +61,12 @@ public void rulesEngineListenersShouldBeCalledInOrder() throws Exception {

// Then
InOrder inOrder = inOrder(rule1, fact1, fact2, rulesEngineListener1, rulesEngineListener2);
inOrder.verify(rulesEngineListener1).beforeFiringRules(rules, facts);
inOrder.verify(rulesEngineListener2).beforeFiringRules(rules, facts);
inOrder.verify(rulesEngineListener1).beforeEvaluate(rules, facts);
inOrder.verify(rulesEngineListener2).beforeEvaluate(rules, facts);
inOrder.verify(rule1).evaluate(facts);
inOrder.verify(rule1).execute(facts);
inOrder.verify(rulesEngineListener1).afterFiringRules(rules, facts);
inOrder.verify(rulesEngineListener2).afterFiringRules(rules, facts);
inOrder.verify(rulesEngineListener1).afterExecute(rules, facts);
inOrder.verify(rulesEngineListener2).afterExecute(rules, facts);
}

}

0 comments on commit 14fe227

Please sign in to comment.