issue #121 : rename methods in RulesEngineListener to be consistent with RuleListener

pull/130/merge
Mahmoud Ben Hassine 7 years ago
parent 4d2dad6147
commit 14fe227c82

@ -33,20 +33,20 @@ import org.jeasy.rules.core.InferenceRulesEngine;
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);
}

@ -213,13 +213,13 @@ public final class DefaultRulesEngine implements RulesEngine {
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);
}
}

@ -51,7 +51,7 @@ public class RulesEngineListenerTest extends AbstractTest {
}
@Test
public void rulesEngineListenersShouldBeCalledInOrder() throws Exception {
public void rulesEngineListenersShouldBeCalledInOrderWhenFiringRules() throws Exception {
// Given
when(rule1.evaluate(facts)).thenReturn(true);
rules.register(rule1);
@ -61,12 +61,12 @@ public class RulesEngineListenerTest extends AbstractTest {
// 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);
}
}

Loading…
Cancel
Save