use of org.drools.compiler.lang.descr.PackageDescr in project drools by kiegroup.
the class RuleParserTest method testEvalMultiple.
@Test
public void testEvalMultiple() throws Exception {
final PackageDescr pkg = (PackageDescr) parseResource("compilationUnit", "eval_multiple.drl");
assertEquals(1, pkg.getRules().size());
final RuleDescr rule = (RuleDescr) pkg.getRules().get(0);
assertEquals(4, rule.getLhs().getDescrs().size());
final EvalDescr eval = (EvalDescr) rule.getLhs().getDescrs().get(0);
assertEqualsIgnoreWhitespace("abc(\"foo\") + 5", (String) eval.getContent());
final PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(1);
assertEquals("Foo", pattern.getObjectType());
}
use of org.drools.compiler.lang.descr.PackageDescr in project drools by kiegroup.
the class RuleParserTest method testEntryPointDeclaration.
@Test
public void testEntryPointDeclaration() throws Exception {
final String text = "package org.drools\n" + "declare entry-point eventStream\n" + " @source(\"jndi://queues/events\")\n" + " @foo( true )\n" + "end";
PackageDescr pkg = (PackageDescr) parse("compilationUnit", text);
assertEquals("org.drools", pkg.getName());
assertEquals(1, pkg.getEntryPointDeclarations().size());
EntryPointDeclarationDescr epd = pkg.getEntryPointDeclarations().iterator().next();
assertEquals("eventStream", epd.getEntryPointId());
assertEquals(2, epd.getAnnotations().size());
assertEquals("\"jndi://queues/events\"", epd.getAnnotation("source").getValue());
assertEquals("true", epd.getAnnotation("foo").getValue());
}
use of org.drools.compiler.lang.descr.PackageDescr in project drools by kiegroup.
the class RuleParserTest method testEval.
@Test
public void testEval() throws Exception {
final PackageDescr pkg = (PackageDescr) parseResource("compilationUnit", "eval_parsing.drl");
assertEquals("org.drools.compiler", pkg.getName());
assertEquals(1, pkg.getRules().size());
final RuleDescr rule1 = (RuleDescr) pkg.getRules().get(0);
assertEquals(1, rule1.getLhs().getDescrs().size());
}
use of org.drools.compiler.lang.descr.PackageDescr in project drools by kiegroup.
the class RuleParserTest method testDialect.
@Test
public void testDialect() throws Exception {
final String source = "dialect 'mvel'";
PackageDescr pkg = (PackageDescr) parse("compilationUnit", source);
AttributeDescr attr = (AttributeDescr) pkg.getAttributes().get(0);
assertEquals("dialect", attr.getName());
assertEquals("mvel", attr.getValue());
}
use of org.drools.compiler.lang.descr.PackageDescr in project drools by kiegroup.
the class RuleParserTest method testAccumulate.
@Test
public void testAccumulate() throws Exception {
final PackageDescr pkg = (PackageDescr) parseResource("compilationUnit", "accumulate.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 AccumulateDescr accum = (AccumulateDescr) outPattern.getSource();
assertEqualsIgnoreWhitespace("int x = 0 ;", accum.getInitCode());
assertEqualsIgnoreWhitespace("x++;", accum.getActionCode());
assertNull(accum.getReverseCode());
assertEqualsIgnoreWhitespace("new Integer(x)", accum.getResultCode());
assertFalse(accum.isExternalFunction());
final PatternDescr pattern = (PatternDescr) accum.getInputPattern();
assertEquals("Person", pattern.getObjectType());
}
Aggregations