Search in sources :

Example 1 with DroolsToken

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

the class DRLContextTest method testCheckRuleHeaderLocationDetermination_dialect4.

@Test(timeout = 10 * 1000)
public void testCheckRuleHeaderLocationDetermination_dialect4() {
    String input = "rule MyRule \n" + "	dialect \"";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    DroolsToken token = getLastTokenOnList(parser.getEditorInterface().get(0).getContent());
    assertEquals("dialect", token.getText().toLowerCase());
    assertEquals(DroolsEditorType.KEYWORD, token.getEditorType());
    assertEquals(Location.LOCATION_RULE_HEADER_KEYWORD, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
Also used : DroolsToken(org.drools.drl.parser.lang.DroolsToken) DRLParser(org.drools.drl.parser.lang.DRLParser) DroolsParserException(org.drools.drl.parser.DroolsParserException) RecognitionException(org.antlr.runtime.RecognitionException) Test(org.junit.Test)

Example 2 with DroolsToken

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

the class DRLContextTest method testCheckRuleHeaderLocationDetermination2.

@Test(timeout = 10 * 1000)
public void testCheckRuleHeaderLocationDetermination2() {
    String input = "rule MyRule \n" + "	salience 12 activation-group \"my";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    DroolsToken token = getLastTokenOnList(parser.getEditorInterface().get(0).getContent());
    assertEquals("group", token.getText().toLowerCase());
    assertEquals(DroolsEditorType.KEYWORD, token.getEditorType());
    assertEquals(Location.LOCATION_RULE_HEADER_KEYWORD, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
Also used : DroolsToken(org.drools.drl.parser.lang.DroolsToken) DRLParser(org.drools.drl.parser.lang.DRLParser) DroolsParserException(org.drools.drl.parser.DroolsParserException) RecognitionException(org.antlr.runtime.RecognitionException) Test(org.junit.Test)

Example 3 with DroolsToken

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

the class DRLContextTest method testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR4.

@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR4() {
    String input = "rule MyRule \n" + "	when \n" + "		name : Class ( name: property ) and ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
    DroolsToken token = (DroolsToken) parser.getEditorInterface().get(0).getContent().get(12);
    assertEquals(DroolsEditorType.IDENTIFIER_VARIABLE, token.getEditorType());
}
Also used : DroolsToken(org.drools.drl.parser.lang.DroolsToken) DRLParser(org.drools.drl.parser.lang.DRLParser) DroolsParserException(org.drools.drl.parser.DroolsParserException) RecognitionException(org.antlr.runtime.RecognitionException) Test(org.junit.Test)

Example 4 with DroolsToken

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

the class DRLContextTest method testCheckLHSLocationDetermination_INSIDE_CONDITION_START8.

@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START8() {
    String input = "rule MyRule \n" + "	when \n" + "		Class ( c: condition, \n" + "			";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    DroolsToken token = (DroolsToken) parser.getEditorInterface().get(0).getContent().get(11);
    assertEquals("c", token.getText());
    assertEquals(DroolsEditorType.IDENTIFIER_VARIABLE, token.getEditorType());
    assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
Also used : DroolsToken(org.drools.drl.parser.lang.DroolsToken) DRLParser(org.drools.drl.parser.lang.DRLParser) DroolsParserException(org.drools.drl.parser.DroolsParserException) RecognitionException(org.antlr.runtime.RecognitionException) Test(org.junit.Test)

Example 5 with DroolsToken

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

the class DRLContextTest method testCheckRuleHeaderLocationDetermination_dialect3.

@Test(timeout = 10 * 1000)
public void testCheckRuleHeaderLocationDetermination_dialect3() {
    String input = "rule MyRule \n" + "	dialect ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    DroolsToken token = getLastTokenOnList(parser.getEditorInterface().get(0).getContent());
    assertEquals("dialect", token.getText().toLowerCase());
    assertEquals(DroolsEditorType.KEYWORD, token.getEditorType());
    assertEquals(Location.LOCATION_RULE_HEADER_KEYWORD, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
Also used : DroolsToken(org.drools.drl.parser.lang.DroolsToken) DRLParser(org.drools.drl.parser.lang.DRLParser) DroolsParserException(org.drools.drl.parser.DroolsParserException) RecognitionException(org.antlr.runtime.RecognitionException) Test(org.junit.Test)

Aggregations

RecognitionException (org.antlr.runtime.RecognitionException)5 DroolsParserException (org.drools.drl.parser.DroolsParserException)5 DRLParser (org.drools.drl.parser.lang.DRLParser)5 DroolsToken (org.drools.drl.parser.lang.DroolsToken)5 Test (org.junit.Test)5