### Question:
SpELCondition implements Condition { @Override public boolean evaluate(Facts facts) { StandardEvaluationContext context = new StandardEvaluationContext(); context.setRootObject(facts.asMap()); context.setVariables(facts.asMap()); if (beanResolver != null) { context.setBeanResolver(beanResolver); } return compiledExpression.getValue(context, Boolean.class); } SpELCondition(String expression);  SpELCondition(String expression, BeanResolver beanResolver);  SpELCondition(String expression, ParserContext parserContext);  SpELCondition(String expression, ParserContext parserContext, BeanResolver beanResolver); @Override boolean evaluate(Facts facts);  }### Answer:
@Test public void testSpELExpressionEvaluation() { Condition isAdult = new SpELCondition("#{ ['person'].age > 18 }"); Facts facts = new Facts(); facts.put("person", new Person("foo", 20)); boolean evaluationResult = isAdult.evaluate(facts); assertThat(evaluationResult).isTrue(); }
@Test public void whenDeclaredFactIsNotPresent_thenShouldReturnFalse() { Condition isHot = new SpELCondition("#{ ['temperature'] > 30 }"); Facts facts = new Facts(); boolean evaluationResult = isHot.evaluate(facts); assertThat(evaluationResult).isFalse(); }
@Test public void testSpELConditionWithExpressionAndParserContext() { ParserContext context = new TemplateParserContext("%{", "}"); Condition condition = new SpELCondition("%{ T(java.lang.Integer).MAX_VALUE > 1 }", context); Facts facts = new Facts(); boolean evaluationResult = condition.evaluate(facts); assertThat(evaluationResult).isTrue(); }
@Test public void testSpELConditionWithExpressionAndParserContextAndBeanResolver() throws Exception { ApplicationContext applicationContext = new AnnotationConfigApplicationContext(MySpringAppConfig.class); BeanResolver beanResolver = new SimpleBeanResolver(applicationContext); SpELRule spELRule = new SpELRule(beanResolver); spELRule.when("#{ ['person'].age >= 18 }"); spELRule.then("#{ @myGreeter.greeting(#person.name) }"); Facts facts = new Facts(); facts.put("person", new Person("jack", 19)); boolean evaluationResult = spELRule.evaluate(facts); Assertions.assertThat(evaluationResult).isTrue(); spELRule.execute(facts); Assertions.assertThat(systemOutRule.getLog()).contains("Bonjour jack!"); }