Search in sources :

Example 16 with NotDescr

use of org.drools.compiler.lang.descr.NotDescr in project drools by kiegroup.

the class RuleParserTest method testNotNode.

@Test
public void testNotNode() throws Exception {
    final RuleDescr rule = (RuleDescr) parseResource("rule", "rule_not.drl");
    assertFalse(parser.getErrors().toString(), parser.hasErrors());
    assertNotNull(rule);
    assertEquals("simple_rule", rule.getName());
    final AndDescr lhs = rule.getLhs();
    assertEquals(1, lhs.getDescrs().size());
    final NotDescr not = (NotDescr) lhs.getDescrs().get(0);
    assertEquals(1, not.getDescrs().size());
    final PatternDescr pattern = (PatternDescr) not.getDescrs().get(0);
    assertEquals("Cheese", pattern.getObjectType());
    assertEquals(1, pattern.getConstraint().getDescrs().size());
    final AndDescr and = (AndDescr) pattern.getConstraint();
    final ExprConstraintDescr fld = (ExprConstraintDescr) and.getDescrs().get(0);
    assertEquals("type == \"stilton\"", fld.getExpression());
}
Also used : NotDescr(org.drools.compiler.lang.descr.NotDescr) PatternDescr(org.drools.compiler.lang.descr.PatternDescr) AndDescr(org.drools.compiler.lang.descr.AndDescr) RuleDescr(org.drools.compiler.lang.descr.RuleDescr) ExprConstraintDescr(org.drools.compiler.lang.descr.ExprConstraintDescr) Test(org.junit.Test)

Aggregations

NotDescr (org.drools.compiler.lang.descr.NotDescr)16 Test (org.junit.Test)12 PatternDescr (org.drools.compiler.lang.descr.PatternDescr)11 RuleDescr (org.drools.compiler.lang.descr.RuleDescr)10 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)7 AndDescr (org.drools.compiler.lang.descr.AndDescr)6 OrDescr (org.drools.compiler.lang.descr.OrDescr)4 ExistsDescr (org.drools.compiler.lang.descr.ExistsDescr)3 ExprConstraintDescr (org.drools.compiler.lang.descr.ExprConstraintDescr)3 ConditionalElementDescr (org.drools.compiler.lang.descr.ConditionalElementDescr)2 FromDescr (org.drools.compiler.lang.descr.FromDescr)2 InputStreamReader (java.io.InputStreamReader)1 XmlPackageReader (org.drools.compiler.compiler.xml.XmlPackageReader)1 CEDescrBuilder (org.drools.compiler.lang.api.CEDescrBuilder)1 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)1 CompositeObjectSinkAdapterTest (org.drools.core.reteoo.CompositeObjectSinkAdapterTest)1 GroupElement (org.drools.core.rule.GroupElement)1 Pattern (org.drools.core.rule.Pattern)1 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)1 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)1