Search in sources :

Example 6 with CollectDescr

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

the class RuleParserTest method testCollect.

@Test
public void testCollect() throws Exception {
    final PackageDescr pkg = (PackageDescr) parseResource("compilationUnit", "collect.drl");
    assertEquals(1, pkg.getRules().size());
    final RuleDescr rule = (RuleDescr) pkg.getRules().get(0);
    assertEquals(1, rule.getLhs().getDescrs().size());
    final PatternDescr outPattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
    final CollectDescr collect = (CollectDescr) outPattern.getSource();
    final PatternDescr pattern = (PatternDescr) collect.getInputPattern();
    assertEquals("Person", pattern.getObjectType());
}
Also used : PatternDescr(org.drools.drl.ast.descr.PatternDescr) CollectDescr(org.drools.drl.ast.descr.CollectDescr) RuleDescr(org.drools.drl.ast.descr.RuleDescr) PackageDescr(org.drools.drl.ast.descr.PackageDescr) Test(org.junit.Test)

Aggregations

CollectDescr (org.drools.drl.ast.descr.CollectDescr)6 PatternDescr (org.drools.drl.ast.descr.PatternDescr)5 PackageDescr (org.drools.drl.ast.descr.PackageDescr)3 RuleDescr (org.drools.drl.ast.descr.RuleDescr)3 Test (org.junit.Test)3 Collect (org.drools.core.rule.Collect)1 Pattern (org.drools.core.rule.Pattern)1 AccumulateDescr (org.drools.drl.ast.descr.AccumulateDescr)1 ConditionalElementDescr (org.drools.drl.ast.descr.ConditionalElementDescr)1 FromDescr (org.drools.drl.ast.descr.FromDescr)1 Element (org.w3c.dom.Element)1