Search in sources :

Example 6 with ForallDescr

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

the class RuleParserTest method testForall.

@Test
public void testForall() throws Exception {
    final PackageDescr pkg = (PackageDescr) parseResource("compilationUnit", "forall.drl");
    assertEquals(1, pkg.getRules().size());
    final RuleDescr rule = (RuleDescr) pkg.getRules().get(0);
    assertEquals(1, rule.getLhs().getDescrs().size());
    final ForallDescr forall = (ForallDescr) rule.getLhs().getDescrs().get(0);
    assertEquals(2, forall.getDescrs().size());
    final PatternDescr pattern = forall.getBasePattern();
    assertEquals("Person", pattern.getObjectType());
    final List<BaseDescr> remaining = forall.getRemainingPatterns();
    assertEquals(1, remaining.size());
    final PatternDescr cheese = (PatternDescr) remaining.get(0);
    assertEquals("Cheese", cheese.getObjectType());
}
Also used : PatternDescr(org.drools.drl.ast.descr.PatternDescr) RuleDescr(org.drools.drl.ast.descr.RuleDescr) BaseDescr(org.drools.drl.ast.descr.BaseDescr) PackageDescr(org.drools.drl.ast.descr.PackageDescr) ForallDescr(org.drools.drl.ast.descr.ForallDescr) Test(org.junit.Test)

Aggregations

ForallDescr (org.drools.drl.ast.descr.ForallDescr)6 PatternDescr (org.drools.drl.ast.descr.PatternDescr)4 BaseDescr (org.drools.drl.ast.descr.BaseDescr)3 PackageDescr (org.drools.drl.ast.descr.PackageDescr)3 RuleDescr (org.drools.drl.ast.descr.RuleDescr)3 Test (org.junit.Test)3 InputStreamReader (java.io.InputStreamReader)1 List (java.util.List)1 XmlPackageReader (org.drools.compiler.compiler.xml.XmlPackageReader)1 Forall (org.drools.core.rule.Forall)1 GroupElement (org.drools.core.rule.GroupElement)1 Pattern (org.drools.core.rule.Pattern)1 ConditionalElementDescr (org.drools.drl.ast.descr.ConditionalElementDescr)1 ExistsDescr (org.drools.drl.ast.descr.ExistsDescr)1 FromDescr (org.drools.drl.ast.descr.FromDescr)1 NotDescr (org.drools.drl.ast.descr.NotDescr)1 Element (org.w3c.dom.Element)1