Search in sources :

Example 6 with MVELExprDescr

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

the class RuleParserTest method testComplexChainedAcessor.

@Test
public void testComplexChainedAcessor() throws Exception {
    final RuleDescr rule = (RuleDescr) parseResource("rule", "test_ComplexChainedCallWithFrom.drl");
    assertFalse(parser.getErrors().toString(), parser.hasErrors());
    final PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
    final FromDescr from = (FromDescr) pattern.getSource();
    final MVELExprDescr accessor = (MVELExprDescr) from.getDataSource();
    assertEquals("doIt1( foo,bar,42,\"hello\",[ a : \"b\"], [a, \"b\", 42] ).doIt2(bar, [a, \"b\", 42]).field[\"key\"]", accessor.getExpression());
}
Also used : PatternDescr(org.drools.compiler.lang.descr.PatternDescr) RuleDescr(org.drools.compiler.lang.descr.RuleDescr) FromDescr(org.drools.compiler.lang.descr.FromDescr) MVELExprDescr(org.drools.compiler.lang.descr.MVELExprDescr) Test(org.junit.Test)

Example 7 with MVELExprDescr

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

the class RuleParserTest method testSimpleFunctionCallWithFrom.

@Test
public void testSimpleFunctionCallWithFrom() throws Exception {
    final RuleDescr rule = (RuleDescr) parseResource("rule", "test_SimpleFunctionCallWithFrom.drl");
    assertFalse(parser.getErrors().toString(), parser.hasErrors());
    final PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
    final FromDescr from = (FromDescr) pattern.getSource();
    final MVELExprDescr func = (MVELExprDescr) from.getDataSource();
    assertEquals("doIt( foo,bar,42,\"hello\",[ a : \"b\", \"something\" : 42, \"a\" : foo, x : [x:y]],\"end\", [a, \"b\", 42] )", func.getExpression());
}
Also used : PatternDescr(org.drools.compiler.lang.descr.PatternDescr) RuleDescr(org.drools.compiler.lang.descr.RuleDescr) FromDescr(org.drools.compiler.lang.descr.FromDescr) MVELExprDescr(org.drools.compiler.lang.descr.MVELExprDescr) Test(org.junit.Test)

Example 8 with MVELExprDescr

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

the class RuleParserTest method testSimpleAccessorAndArgWithFrom.

@Test
public void testSimpleAccessorAndArgWithFrom() throws Exception {
    final RuleDescr rule = (RuleDescr) parseResource("rule", "test_SimpleAccessorArgWithFrom.drl");
    assertFalse(parser.getErrors().toString(), parser.hasErrors());
    final PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
    final FromDescr from = (FromDescr) pattern.getSource();
    final MVELExprDescr accessor = (MVELExprDescr) from.getDataSource();
    assertEquals("something.doIt[\"key\"]", accessor.getExpression());
}
Also used : PatternDescr(org.drools.compiler.lang.descr.PatternDescr) RuleDescr(org.drools.compiler.lang.descr.RuleDescr) FromDescr(org.drools.compiler.lang.descr.FromDescr) MVELExprDescr(org.drools.compiler.lang.descr.MVELExprDescr) Test(org.junit.Test)

Example 9 with MVELExprDescr

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

the class RuleParserTest method testSimpleAccessorWithFrom.

@Test
public void testSimpleAccessorWithFrom() throws Exception {
    final RuleDescr rule = (RuleDescr) parseResource("rule", "test_SimpleAccessorWithFrom.drl");
    assertFalse(parser.getErrors().toString(), parser.hasErrors());
    final PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
    final FromDescr from = (FromDescr) pattern.getSource();
    final MVELExprDescr accessor = (MVELExprDescr) from.getDataSource();
    assertEquals("something.doIt", accessor.getExpression());
}
Also used : PatternDescr(org.drools.compiler.lang.descr.PatternDescr) RuleDescr(org.drools.compiler.lang.descr.RuleDescr) FromDescr(org.drools.compiler.lang.descr.FromDescr) MVELExprDescr(org.drools.compiler.lang.descr.MVELExprDescr) Test(org.junit.Test)

Aggregations

FromDescr (org.drools.compiler.lang.descr.FromDescr)9 MVELExprDescr (org.drools.compiler.lang.descr.MVELExprDescr)9 PatternDescr (org.drools.compiler.lang.descr.PatternDescr)6 RuleDescr (org.drools.compiler.lang.descr.RuleDescr)6 Test (org.junit.Test)6 InputStreamReader (java.io.InputStreamReader)1 XmlPackageReader (org.drools.compiler.compiler.xml.XmlPackageReader)1 ExprConstraintDescr (org.drools.compiler.lang.descr.ExprConstraintDescr)1 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)1 XpathPart (org.drools.compiler.rule.builder.XpathAnalysis.XpathPart)1 Declaration (org.drools.core.rule.Declaration)1 TypeDeclaration (org.drools.core.rule.TypeDeclaration)1 DeclarationScopeResolver (org.drools.core.spi.DeclarationScopeResolver)1 Element (org.w3c.dom.Element)1