Search in sources :

Example 1 with DRLParser

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

the class DRLContextTest method testCheckRHSLocationDetermination_firstLineOfLHS.

@Test(timeout = 10 * 1000)
public void testCheckRHSLocationDetermination_firstLineOfLHS() {
    String input = "rule MyRule \n" + "	when\n" + "		Class ( )\n" + "   then\n" + "       ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_RHS, 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 2 with DRLParser

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

the class DRLContextTest method testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT1.

/**
 * Inside of condition: argument
 */
@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT1() {
    String input = "rule MyRule \n" + "	when \n" + "		Class ( property == ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, 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 3 with DRLParser

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

the class DRLContextTest method testCheckLHSLocationDetermination_INSIDE_CONDITION_END2.

@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END2() {
    String input = "rule MyRule \n" + "	when \n" + "		Class ( property not in ('1', '2') ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, 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 4 with DRLParser

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

the class DRLContextTest method testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT9b.

@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT9b() {
    String input = "rule MyRule \n" + "	when \n" + "		Class ( property not contains ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, 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 5 with DRLParser

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

the class DRLContextTest method testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT.

@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT() {
    String input = "rule MyRule \n" + "	when \n" + "		exists Class ( ) and not ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT, 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