Search in sources :

Example 6 with ExpanderException

use of org.drools.compiler.lang.ExpanderException in project drools by kiegroup.

the class DefaultExpanderTest method testLineNumberError.

@Test
public void testLineNumberError() throws Exception {
    DSLMappingFile 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.compiler.lang.ExpanderException) Test(org.junit.Test)

Aggregations

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