use of org.jeasy.rules.api.Facts in project easy-rules by j-easy.
the class MVELActionTest method testMVELActionExecution.
@Test
public void testMVELActionExecution() throws Exception {
// given
Action markAsAdult = new MVELAction("person.setAdult(true);");
Facts facts = new Facts();
Person foo = new Person("foo", 20);
facts.put("person", foo);
// when
markAsAdult.execute(facts);
// then
assertThat(foo.isAdult()).isTrue();
}
use of org.jeasy.rules.api.Facts in project easy-rules by j-easy.
the class MVELConditionTest method testMVELExpressionEvaluation.
@Test
public void testMVELExpressionEvaluation() throws Exception {
// given
Condition isAdult = new MVELCondition("person.age > 18");
Facts facts = new Facts();
facts.put("person", new Person("foo", 20));
// when
boolean evaluationResult = isAdult.evaluate(facts);
// then
assertThat(evaluationResult).isTrue();
}
use of org.jeasy.rules.api.Facts in project tutorials by eugenp.
the class Launcher method main.
public static void main(String... args) {
// create facts
Facts facts = new Facts();
// create rules
Rules rules = new Rules();
rules.register(new HelloWorldRule());
// create a rules engine and fire rules on known facts
RulesEngine rulesEngine = new DefaultRulesEngine();
rulesEngine.fire(rules, facts);
}
Aggregations