Search in sources :

Example 36 with DrlParser

use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.

the class DRLIncompleteCodeTest method testIncompleteCode6.

@Test
public void testIncompleteCode6() throws DroolsParserException, RecognitionException {
    String input = "packe 1111.111 import a.b.c.*" + " rule MyRule when Class ( property memberOf collection ) then end " + " query MyQuery Class ( property memberOf collection ) end ";
    DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
    PackageDescr descr = parser.parse(true, input);
    assertNotNull(descr);
}
Also used : DrlParser(org.drools.compiler.compiler.DrlParser) PackageDescr(org.drools.compiler.lang.descr.PackageDescr) Test(org.junit.Test)

Example 37 with DrlParser

use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.

the class DRLIncompleteCodeTest method testIncompleteCode1.

@Test
@Ignore
public void testIncompleteCode1() throws DroolsParserException, RecognitionException {
    String input = "package a.b.c import a.b.c.* rule MyRule when Class ( property memberOf collexction ";
    DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
    PackageDescr descr = parser.parse(true, input);
    System.out.println(parser.getErrors());
    assertNotNull(descr);
    assertEquals("a.b.c", descr.getNamespace());
    assertEquals("a.b.c.*", descr.getImports().get(0).getTarget());
    assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, getLastIntegerValue(parser.getEditorSentences().get(2).getContent()));
}
Also used : DrlParser(org.drools.compiler.compiler.DrlParser) PackageDescr(org.drools.compiler.lang.descr.PackageDescr) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 38 with DrlParser

use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.

the class DRLIncompleteCodeTest method testIncompleteCode11.

@Test
public void testIncompleteCode11() throws DroolsParserException, RecognitionException {
    String input = "package a.b.c import a.b.c.*" + " rule MyRule when Class ( property memberOf collection ) then end " + " qzzzzuery MyQuery Class ( property ";
    DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
    PackageDescr descr = parser.parse(true, input);
    assertEquals("a.b.c", descr.getNamespace());
    assertEquals("a.b.c.*", descr.getImports().get(0).getTarget());
    assertNotNull(descr);
    assertEquals("MyRule", descr.getRules().get(0).getName());
}
Also used : DrlParser(org.drools.compiler.compiler.DrlParser) PackageDescr(org.drools.compiler.lang.descr.PackageDescr) Test(org.junit.Test)

Example 39 with DrlParser

use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.

the class DRLIncompleteCodeTest method testIncompleteCode3.

@Test
public void testIncompleteCode3() throws DroolsParserException, RecognitionException {
    String input = "rule MyRule when Class ( property > somevalue ) then end query MyQuery Class ( property == collection ) end ";
    DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
    PackageDescr descr = parser.parse(true, input);
    assertNotNull(descr);
    assertEquals("MyRule", descr.getRules().get(0).getName());
    assertNotNull(descr);
    assertEquals("MyQuery", descr.getRules().get(1).getName());
    assertEquals(Location.LOCATION_RHS, getLastIntegerValue(parser.getEditorSentences().get(0).getContent()));
}
Also used : DrlParser(org.drools.compiler.compiler.DrlParser) PackageDescr(org.drools.compiler.lang.descr.PackageDescr) Test(org.junit.Test)

Example 40 with DrlParser

use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.

the class DRLIncompleteCodeTest method testIncompleteCode12.

@Test
public void testIncompleteCode12() throws DroolsParserException, RecognitionException {
    String input = "package a.b.c " + "import a.b.c.* " + "rule MyRule" + "  when " + "    m: Message(  ) " + "    " + "  then" + "end ";
    DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
    PackageDescr descr = parser.parse(true, input);
    assertNotNull(descr);
    assertEquals("a.b.c", descr.getNamespace());
    assertEquals("a.b.c.*", descr.getImports().get(0).getTarget());
}
Also used : DrlParser(org.drools.compiler.compiler.DrlParser) PackageDescr(org.drools.compiler.lang.descr.PackageDescr) Test(org.junit.Test)

Aggregations

DrlParser (org.drools.compiler.compiler.DrlParser)44 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)43 Test (org.junit.Test)32 InputStreamReader (java.io.InputStreamReader)10 RuleDescr (org.drools.compiler.lang.descr.RuleDescr)9 StringReader (java.io.StringReader)8 CompositePackageDescr (org.drools.compiler.lang.descr.CompositePackageDescr)6 ArrayList (java.util.ArrayList)5 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)5 ParserError (org.drools.compiler.compiler.ParserError)5 DrlDumper (org.drools.compiler.lang.DrlDumper)4 Reader (java.io.Reader)3 List (java.util.List)3 DroolsParserException (org.drools.compiler.compiler.DroolsParserException)3 PatternDescr (org.drools.compiler.lang.descr.PatternDescr)3 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)3 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)3 Ignore (org.junit.Ignore)3 AttributeDescr (org.drools.compiler.lang.descr.AttributeDescr)2 MVELConsequence (org.drools.core.base.mvel.MVELConsequence)2