如何测试easy-rules 的spel 表达式

尽管官方文档没有提供,但是测试用例都是包含了,我们可以直接使用

参考示例

@Test
 public  void demo222(){
     ParserContext context = new TemplateParserContext("#{","}");
     Condition condition = new SpELCondition("#{#biz.age>100}",context);
     Facts facts = new Facts();
     User user = new User();
     user.setAge(33);
     facts.put("biz",user);
     Boolean result=  condition.evaluate(facts);
     System.out.println(result);
 }

说明

多看看官方的测试还是很有用的

参考资料

https://github.com/j-easy/easy-rules/blob/master/easy-rules-spel/src/test/java/org/jeasy/rules/spel/SpELConditionTest.java

posted on 2021-08-22 12:13  荣锋亮  阅读(443)  评论(0编辑  收藏  举报

导航