Search in sources :

Example 21 with CompilerContext

use of org.kie.dmn.feel.lang.CompilerContext in project drools by kiegroup.

the class FEELErrorMessagesTest method ifWithoutElse2.

@Test
public void ifWithoutElse2() {
    final FEEL feel = FEEL.newInstance();
    final FEELEventListener fel = Mockito.mock(FEELEventListener.class);
    feel.addListener(fel);
    final CompilerContext ctx = feel.newCompilerContext();
    feel.compile("if true then 123 456", ctx);
    final ArgumentCaptor<FEELEvent> captor = ArgumentCaptor.forClass(FEELEvent.class);
    verify(fel, times(1)).onEvent(captor.capture());
    Assert.assertThat(captor.getAllValues().size(), is(1));
    Assert.assertThat(captor.getAllValues().get(0), is(instanceOf(SyntaxErrorEvent.class)));
    Assert.assertThat(((SyntaxErrorEvent) captor.getAllValues().get(0)).getMessage(), is("missing 'else' at '456'"));
}
Also used : FEEL(org.kie.dmn.feel.FEEL) CompilerContext(org.kie.dmn.feel.lang.CompilerContext) FEELEventListener(org.kie.dmn.api.feel.runtime.events.FEELEventListener) FEELEvent(org.kie.dmn.api.feel.runtime.events.FEELEvent) Test(org.junit.Test)

Aggregations

CompilerContext (org.kie.dmn.feel.lang.CompilerContext)21 Test (org.junit.Test)13 CompiledExpression (org.kie.dmn.feel.lang.CompiledExpression)12 HashMap (java.util.HashMap)10 FEELEvent (org.kie.dmn.api.feel.runtime.events.FEELEvent)6 FEELEventListener (org.kie.dmn.api.feel.runtime.events.FEELEventListener)6 FEEL (org.kie.dmn.feel.FEEL)5 MapBackedType (org.kie.dmn.feel.lang.impl.MapBackedType)5 Map (java.util.Map)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 DMNType (org.kie.dmn.api.core.DMNType)2 Type (org.kie.dmn.feel.lang.Type)2 ASTNode (org.kie.dmn.feel.lang.ast.ASTNode)2 FunctionInvocationNode (org.kie.dmn.feel.lang.ast.FunctionInvocationNode)2 GenListType (org.kie.dmn.feel.lang.types.GenListType)2 CompiledNetwork (org.drools.ancompiler.CompiledNetwork)1 CompiledNetworkSources (org.drools.ancompiler.CompiledNetworkSources)1 ObjectTypeNodeCompiler (org.drools.ancompiler.ObjectTypeNodeCompiler)1 ObjectTypeNode (org.drools.core.reteoo.ObjectTypeNode)1