Search in sources :

Example 6 with ExpanderException

use of org.drools.drl.parser.lang.ExpanderException in project drools by kiegroup.

the class DefaultExpanderTest method testANTLRLineNumberError.

@Test
public void testANTLRLineNumberError() throws Exception {
    DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
    String dsl = "[when]foo=Foo()" + NL + "[then]bar {num}=baz({num});";
    file.parseAndLoad(new StringReader(dsl));
    DefaultExpander ex = new DefaultExpander();
    ex.addDSLMapping(file.getMapping());
    String source = "rule 'q'" + NL + "agenda-group 'x'" + NL + "when" + NL + "    __  " + NL + "then" + NL + "    bar 42" + NL + "\tgoober" + NL + "end";
    ex.expand(source);
    assertTrue(ex.hasErrors());
    assertEquals(2, ex.getErrors().size());
    ExpanderException err = (ExpanderException) ex.getErrors().get(0);
    assertEquals(4, err.getLine());
    err = (ExpanderException) ex.getErrors().get(1);
    assertEquals(7, err.getLine());
}
Also used : StringReader(java.io.StringReader) ExpanderException(org.drools.drl.parser.lang.ExpanderException) DSLTokenizedMappingFile(org.drools.drl.parser.lang.dsl.DSLTokenizedMappingFile) DefaultExpander(org.drools.drl.parser.lang.dsl.DefaultExpander) Test(org.junit.Test)

Aggregations

ExpanderException (org.drools.drl.parser.lang.ExpanderException)6 DefaultExpander (org.drools.drl.parser.lang.dsl.DefaultExpander)3 StringReader (java.io.StringReader)2 Matcher (java.util.regex.Matcher)2 DSLTokenizedMappingFile (org.drools.drl.parser.lang.dsl.DSLTokenizedMappingFile)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 HashMap (java.util.HashMap)1 Pattern (java.util.regex.Pattern)1 CompositePackageDescr (org.drools.compiler.lang.descr.CompositePackageDescr)1 PackageDescr (org.drools.drl.ast.descr.PackageDescr)1 DrlParser (org.drools.drl.parser.DrlParser)1 Expander (org.drools.drl.parser.lang.Expander)1 DSLMappingFile (org.drools.drl.parser.lang.dsl.DSLMappingFile)1