use of org.jeasy.rules.api.RulesEngineParameters in project easy-rules by j-easy.
the class SkipOnFirstAppliedRuleTest method setup.
@Before
public void setup() throws Exception {
super.setup();
RulesEngineParameters parameters = new RulesEngineParameters().skipOnFirstAppliedRule(true);
rulesEngine = new DefaultRulesEngine(parameters);
}
use of org.jeasy.rules.api.RulesEngineParameters in project easy-rules by j-easy.
the class SkipOnFirstNonTriggeredRuleTest method setup.
@Before
public void setup() throws Exception {
super.setup();
RulesEngineParameters parameters = new RulesEngineParameters().skipOnFirstNonTriggeredRule(true);
rulesEngine = new DefaultRulesEngine(parameters);
}
use of org.jeasy.rules.api.RulesEngineParameters in project easy-rules by j-easy.
the class SkipOnFirstFailedRuleTest method setup.
@Before
public void setup() throws Exception {
super.setup();
RulesEngineParameters parameters = new RulesEngineParameters().skipOnFirstFailedRule(true);
rulesEngine = new DefaultRulesEngine(parameters);
}
use of org.jeasy.rules.api.RulesEngineParameters in project easy-rules by j-easy.
the class DefaultRulesEngineTest method getParametersShouldReturnACopyOfTheParameters.
@Test
public void getParametersShouldReturnACopyOfTheParameters() {
// Given
RulesEngineParameters parameters = new RulesEngineParameters().skipOnFirstAppliedRule(true).skipOnFirstFailedRule(true).skipOnFirstNonTriggeredRule(true).priorityThreshold(42);
DefaultRulesEngine rulesEngine = new DefaultRulesEngine(parameters);
// When
RulesEngineParameters engineParameters = rulesEngine.getParameters();
// Then
Assertions.assertThat(engineParameters).isNotSameAs(parameters);
Assertions.assertThat(engineParameters).usingRecursiveComparison().isEqualTo(parameters);
}
use of org.jeasy.rules.api.RulesEngineParameters in project easy-rules by j-easy.
the class FizzBuzzWithEasyRules method main.
public static void main(String[] args) {
// create rules engine
RulesEngineParameters parameters = new RulesEngineParameters().skipOnFirstAppliedRule(true);
RulesEngine fizzBuzzEngine = new DefaultRulesEngine(parameters);
// create rules
Rules rules = new Rules();
rules.register(new FizzRule());
rules.register(new BuzzRule());
rules.register(new FizzBuzzRule(new FizzRule(), new BuzzRule()));
rules.register(new NonFizzBuzzRule());
// fire rules
Facts facts = new Facts();
for (int i = 1; i <= 100; i++) {
facts.put("number", i);
fizzBuzzEngine.fire(rules, facts);
System.out.println();
}
}
Aggregations