Search in sources :

Example 11 with DRLParser

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

the class ErrorsParserTest method testErrorMessageForMisplacedParenthesis.

@Test
public void testErrorMessageForMisplacedParenthesis() throws Exception {
    final DRLParser parser = parseResource("misplaced_parenthesis.drl");
    parser.compilationUnit();
    assertTrue("Parser should have raised errors", parser.hasErrors());
    assertEquals(1, parser.getErrors().size());
    assertEquals("ERR 102", parser.getErrors().get(0).getErrorCode());
}
Also used : DRLParser(org.drools.drl.parser.lang.DRLParser) Test(org.junit.Test)

Example 12 with DRLParser

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

the class ErrorsParserTest method testTempleteError.

@Test
public void testTempleteError() throws Exception {
    DRLParser parser = parseResource("template_test_error.drl");
    parser.compilationUnit();
    assertTrue(parser.hasErrors());
}
Also used : DRLParser(org.drools.drl.parser.lang.DRLParser) Test(org.junit.Test)

Example 13 with DRLParser

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

the class DRLContextTest method testCheckLHSLocationDetermination_FROM_ACCUMULATE_INIT_INSIDE.

@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_INIT_INSIDE() {
    String input = "rule MyRule \n" + "	when \n" + "		Class ( property > 0 ) from accumulate( \n" + "			$cheese : Cheese( type == $likes ), \n" + "			init( ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE_INIT_INSIDE, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
Also used : DRLParser(org.drools.drl.parser.lang.DRLParser) DroolsParserException(org.drools.drl.parser.DroolsParserException) RecognitionException(org.antlr.runtime.RecognitionException) Test(org.junit.Test)

Example 14 with DRLParser

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

the class DRLContextTest method testCheckLHSLocationDetermination_FROM_COLLECT1.

/**
 * FROM COLLECT
 */
@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_FROM_COLLECT1() {
    String input = "rule MyRule \n" + "	when \n" + "		Class ( property > 0 ) from collect ( ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_LHS_FROM_COLLECT, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
Also used : DRLParser(org.drools.drl.parser.lang.DRLParser) DroolsParserException(org.drools.drl.parser.DroolsParserException) RecognitionException(org.antlr.runtime.RecognitionException) Test(org.junit.Test)

Example 15 with DRLParser

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

the class DRLContextTest method testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS1.

/**
 * EXISTS
 */
@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS1() {
    String input = "rule MyRule \n" + "	when \n" + "		exists ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
Also used : DRLParser(org.drools.drl.parser.lang.DRLParser) DroolsParserException(org.drools.drl.parser.DroolsParserException) RecognitionException(org.antlr.runtime.RecognitionException) Test(org.junit.Test)

Aggregations

DRLParser (org.drools.drl.parser.lang.DRLParser)200 Test (org.junit.Test)197 DroolsParserException (org.drools.drl.parser.DroolsParserException)187 RecognitionException (org.antlr.runtime.RecognitionException)186 DroolsToken (org.drools.drl.parser.lang.DroolsToken)6 Ignore (org.junit.Ignore)2 LinkedList (java.util.LinkedList)1 Token (org.antlr.runtime.Token)1 InternalResource (org.drools.core.io.internal.InternalResource)1 Expander (org.drools.drl.parser.lang.Expander)1 DefaultExpander (org.drools.drl.parser.lang.dsl.DefaultExpander)1