Search in sources :

Example 1 with RulesEngineParameters

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);
}
Also used : RulesEngineParameters(org.jeasy.rules.api.RulesEngineParameters) Before(org.junit.Before)

Example 2 with RulesEngineParameters

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);
}
Also used : RulesEngineParameters(org.jeasy.rules.api.RulesEngineParameters) Before(org.junit.Before)

Example 3 with RulesEngineParameters

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);
}
Also used : RulesEngineParameters(org.jeasy.rules.api.RulesEngineParameters) Before(org.junit.Before)

Example 4 with RulesEngineParameters

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);
}
Also used : RulesEngineParameters(org.jeasy.rules.api.RulesEngineParameters) Test(org.junit.Test)

Example 5 with RulesEngineParameters

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();
    }
}
Also used : DefaultRulesEngine(org.jeasy.rules.core.DefaultRulesEngine) DefaultRulesEngine(org.jeasy.rules.core.DefaultRulesEngine) RulesEngine(org.jeasy.rules.api.RulesEngine) RulesEngineParameters(org.jeasy.rules.api.RulesEngineParameters) Rules(org.jeasy.rules.api.Rules) Facts(org.jeasy.rules.api.Facts)

Aggregations

RulesEngineParameters (org.jeasy.rules.api.RulesEngineParameters)6 Before (org.junit.Before)4 Facts (org.jeasy.rules.api.Facts)1 Rules (org.jeasy.rules.api.Rules)1 RulesEngine (org.jeasy.rules.api.RulesEngine)1 DefaultRulesEngine (org.jeasy.rules.core.DefaultRulesEngine)1 Test (org.junit.Test)1