Search in sources :

Example 91 with PackageDescr

use of org.drools.drl.ast.descr.PackageDescr in project drools by kiegroup.

the class RuleParserTest method testSoundsLike.

@Test
public void testSoundsLike() throws Exception {
    final PackageDescr pkg = (PackageDescr) parseResource("compilationUnit", "soundslike_operator.drl");
    RuleDescr rule = (RuleDescr) pkg.getRules().get(0);
    PatternDescr pat = (PatternDescr) rule.getLhs().getDescrs().get(0);
    pat.getConstraint();
}
Also used : PatternDescr(org.drools.drl.ast.descr.PatternDescr) RuleDescr(org.drools.drl.ast.descr.RuleDescr) PackageDescr(org.drools.drl.ast.descr.PackageDescr) Test(org.junit.Test)

Example 92 with PackageDescr

use of org.drools.drl.ast.descr.PackageDescr 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.drl.parser.DrlParser) PackageDescr(org.drools.drl.ast.descr.PackageDescr) Test(org.junit.Test)

Example 93 with PackageDescr

use of org.drools.drl.ast.descr.PackageDescr 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 94 with PackageDescr

use of org.drools.drl.ast.descr.PackageDescr 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 95 with PackageDescr

use of org.drools.drl.ast.descr.PackageDescr 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)

Aggregations

PackageDescr (org.drools.drl.ast.descr.PackageDescr)262 Test (org.junit.Test)210 RuleDescr (org.drools.drl.ast.descr.RuleDescr)104 PatternDescr (org.drools.drl.ast.descr.PatternDescr)85 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)52 AndDescr (org.drools.drl.ast.descr.AndDescr)39 DrlParser (org.drools.drl.parser.DrlParser)39 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)25 InputStreamReader (java.io.InputStreamReader)23 CompositePackageDescr (org.drools.compiler.lang.descr.CompositePackageDescr)23 ExprConstraintDescr (org.drools.drl.ast.descr.ExprConstraintDescr)23 KieSession (org.kie.api.runtime.KieSession)19 List (java.util.List)18 InternalKnowledgeBase (org.drools.kiesession.rulebase.InternalKnowledgeBase)18 XmlPackageReader (org.drools.compiler.compiler.xml.XmlPackageReader)17 GlobalDescr (org.drools.drl.ast.descr.GlobalDescr)17 KiePackage (org.kie.api.definition.KiePackage)17 DrlDumper (org.drools.mvel.DrlDumper)16 Cheese (org.drools.mvel.compiler.Cheese)16 AccumulateDescr (org.drools.drl.ast.descr.AccumulateDescr)15