AssertionEvaluation implements Evaluation { @Override public boolean validate() throws EvaluationException { try { final ExpressionParser parser = new SpelExpressionParser(); final Expression expr = parser.parseExpression(assertion); final StandardEvaluationContext context = new StandardEvaluationContext(); context.registerFunction("jsonPath", BeanUtils.resolveSignature("evaluate", JsonPathFunction.class)); context.setVariables(variables); return expr.getValue(context, boolean.class); } catch (SpelEvaluationException spelex) { throw new EvaluationException("Assertion can not be verified : " + assertion, spelex); } } AssertionEvaluation(final String assertion); @Override boolean validate(); void setVariable(String variable, Object value); String getAssertion();  }
@Test public void shouldNotValidate_singleCondition() throws EvaluationException { String assertion = "'toto' == 'tata'"; AssertionEvaluation evaluation = new AssertionEvaluation(assertion); boolean result = evaluation.validate(); Assert.assertFalse(result); }
@Test public void shouldNotValidate_multipleCondition() throws EvaluationException { String assertion = "'toto' == 'toto' && 1 == 2"; AssertionEvaluation evaluation = new AssertionEvaluation(assertion); boolean result = evaluation.validate(); Assert.assertFalse(result); }