use of org.kie.dmn.feel.lang.CompiledExpression in project drools by kiegroup.
the class CompileEvaluateTest method test2OK.
@Test
public void test2OK() {
CompilerContext ctx = feel.newCompilerContext();
ctx.addInputVariableType("MyPerson", new MapBackedType().addField("FullName", BuiltInType.STRING));
CompiledExpression compiledExpression = feel.compile("MyPerson.FullName", ctx);
Map<String, Object> inputs = new HashMap<>();
inputs.put("MyPerson", prototype(entry("FullName", "John Doe")));
Object result = feel.evaluate(compiledExpression, inputs);
assertThat(result, is("John Doe"));
}
use of org.kie.dmn.feel.lang.CompiledExpression in project drools by kiegroup.
the class CompileEvaluateTest method testExternalFnMissingMethodString.
@Test
public void testExternalFnMissingMethodString() {
CompiledExpression compiledExpression = feel.compile("{ fn : function( p1 ) external { java : { class : \"" + SomeTestUtilClass.class.getCanonicalName() + "\", method signature: \"greet(String)\" } }, r : fn( \"John Doe\" ) }.r", feel.newCompilerContext());
Object result = feel.evaluate(compiledExpression, new HashMap<>());
assertThat(errors).anyMatch(fe -> fe.getMessage().contains("greet(java.lang.String)"));
}
use of org.kie.dmn.feel.lang.CompiledExpression in project drools by kiegroup.
the class CompileEvaluateTest method testHyphenInProperty.
@Test
public void testHyphenInProperty() {
CompilerContext ctx = feel.newCompilerContext();
ctx.addInputVariableType("input", new MapBackedType().addField("Primary-Key", BuiltInType.STRING).addField("Value", BuiltInType.STRING));
CompiledExpression compiledExpression = feel.compile("input.Primary-Key", ctx);
assertTrue(errors.isEmpty());
Map<String, Object> inputs = new HashMap<>();
inputs.put("input", prototype(entry("Primary-Key", "k987")));
Object result = feel.evaluate(compiledExpression, inputs);
assertThat(result, is("k987"));
assertTrue(errors.isEmpty());
}
Aggregations