Search in sources :

Example 11 with DrlParser

use of org.drools.drl.parser.DrlParser in project drools by kiegroup.

the class DRLIncompleteCodeTest method testIncompleteCode10.

@Test
@Ignore
public void testIncompleteCode10() throws DroolsParserException, RecognitionException {
    String input = "package a.b.c import a.b.c.*" + " rule MyRule xxxxx Class ( property memberOf " + " query MyQuery Class ( property memberOf collection ) end ";
    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());
    assertEquals(0, descr.getRules().size());
}
Also used : DrlParser(org.drools.drl.parser.DrlParser) PackageDescr(org.drools.drl.ast.descr.PackageDescr) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with DrlParser

use of org.drools.drl.parser.DrlParser in project drools by kiegroup.

the class DRLIncompleteCodeTest method testIncompleteCode9.

@Test
@Ignore
public void testIncompleteCode9() throws DroolsParserException, RecognitionException {
    String input = "package a.b.c import a.b.c.*" + " rule MyRule xxxxx 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);
    assertEquals("a.b.c", descr.getNamespace());
    assertEquals("a.b.c.*", descr.getImports().get(0).getTarget());
    assertEquals(1, descr.getRules().size());
    assertEquals("MyQuery", descr.getRules().get(0).getName());
}
Also used : DrlParser(org.drools.drl.parser.DrlParser) PackageDescr(org.drools.drl.ast.descr.PackageDescr) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with DrlParser

use of org.drools.drl.parser.DrlParser in project drools by kiegroup.

the class DRLIncompleteCodeTest method testIncompleteCode4.

@Test
public void testIncompleteCode4() throws DroolsParserException, RecognitionException {
    String input = "package a.b.c import a.b.c.*" + " rule MyRule when Class ( property == collection ) then end " + " query MyQuery Class ( property == collection ) end ";
    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());
    assertNotNull(descr);
    assertEquals("MyQuery", descr.getRules().get(1).getName());
}
Also used : DrlParser(org.drools.drl.parser.DrlParser) PackageDescr(org.drools.drl.ast.descr.PackageDescr) Test(org.junit.Test)

Example 14 with DrlParser

use of org.drools.drl.parser.DrlParser in project drools by kiegroup.

the class DRLIncompleteCodeTest method testIncompleteCode2.

@Test
public void testIncompleteCode2() throws DroolsParserException, RecognitionException {
    String input = "rule MyRule when Class ( property memberOf collection ";
    DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
    PackageDescr descr = parser.parse(true, input);
    assertNotNull(descr);
    assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, getLastIntegerValue(parser.getEditorSentences().get(0).getContent()));
}
Also used : DrlParser(org.drools.drl.parser.DrlParser) PackageDescr(org.drools.drl.ast.descr.PackageDescr) Test(org.junit.Test)

Example 15 with DrlParser

use of org.drools.drl.parser.DrlParser in project drools by kiegroup.

the class DRLIncompleteCodeTest method testIncompleteCode5.

@Test
public void testIncompleteCode5() throws DroolsParserException, RecognitionException {
    String input = "package a.b.c 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.drl.parser.DrlParser) PackageDescr(org.drools.drl.ast.descr.PackageDescr) Test(org.junit.Test)

Aggregations

DrlParser (org.drools.drl.parser.DrlParser)41 PackageDescr (org.drools.drl.ast.descr.PackageDescr)38 Test (org.junit.Test)32 RuleDescr (org.drools.drl.ast.descr.RuleDescr)9 InputStreamReader (java.io.InputStreamReader)8 StringReader (java.io.StringReader)8 CompositePackageDescr (org.drools.compiler.lang.descr.CompositePackageDescr)4 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)4 ParserError (org.drools.drl.parser.ParserError)4 DrlDumper (org.drools.mvel.DrlDumper)4 Reader (java.io.Reader)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)3 PatternDescr (org.drools.drl.ast.descr.PatternDescr)3 Ignore (org.junit.Ignore)3 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)2 InputStreamResource (org.drools.core.io.impl.InputStreamResource)2 AttributeDescr (org.drools.drl.ast.descr.AttributeDescr)2 MVELConsequence (org.drools.mvel.expr.MVELConsequence)2