Expression { public Object compile(String expression, ExpressionContext pctx) { return expressionCache.computeIfAbsent(expression, s -> MVEL.compileExpression(expression, pctx.getContext())); } Expression(ExpressionContext context); Object eval(String expression); Object eval(String expression, Map<String, Object> vars); Object compile(String expression, ExpressionContext pctx); Set<String> analysisInputs(String expression);  }
@Test public void testCompile() { String expr = " a && b "; ExpressionContext context = new ExpressionContext(); Object compiledExpression = expression.compile(expr, context); assertNotNull(compiledExpression); Object sameExpression = expression.compile(expr, context); assertThat(compiledExpression, is(sameExpression)); }
@Test(expected = CompileException.class) public void testCompileWithException() { String expr = " a && * b "; ExpressionContext context = new ExpressionContext(); expression.compile(expr, context); }