use of org.drools.drl.ast.descr.PackageDescr in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode2.
@Test
public void testIncompleteCode2() throws DroolsParserException, RecognitionException {
String input = "rule MyRule when Class ( property memberOf collection ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
assertNotNull(descr);
assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, getLastIntegerValue(parser.getEditorSentences().get(0).getContent()));
}
use of org.drools.drl.ast.descr.PackageDescr in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode5.
@Test
public void testIncompleteCode5() throws DroolsParserException, RecognitionException {
String input = "package a.b.c import a.b.c.*" + " rule MyRule when Class ( property memberOf collection ) then end " + " query MyQuery Class ( property memberOf collection ) end ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
assertNotNull(descr);
}
use of org.drools.drl.ast.descr.PackageDescr in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode6.
@Test
public void testIncompleteCode6() throws DroolsParserException, RecognitionException {
String input = "packe 1111.111 import a.b.c.*" + " rule MyRule when Class ( property memberOf collection ) then end " + " query MyQuery Class ( property memberOf collection ) end ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
assertNotNull(descr);
}
use of org.drools.drl.ast.descr.PackageDescr in project drools by kiegroup.
the class RuleParserTest method testAccumulateMultiPattern.
@Test
public void testAccumulateMultiPattern() throws Exception {
final PackageDescr pkg = (PackageDescr) parseResource("compilationUnit", "accumulate_multi_pattern.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("$counter", outPattern.getIdentifier());
assertEqualsIgnoreWhitespace("int x = 0 ;", accum.getInitCode());
assertEqualsIgnoreWhitespace("x++;", accum.getActionCode());
assertEqualsIgnoreWhitespace("new Integer(x)", accum.getResultCode());
final AndDescr and = (AndDescr) accum.getInput();
assertEquals(2, and.getDescrs().size());
final PatternDescr person = (PatternDescr) and.getDescrs().get(0);
final PatternDescr cheese = (PatternDescr) and.getDescrs().get(1);
assertEquals("Person", person.getObjectType());
assertEquals("Cheese", cheese.getObjectType());
}
use of org.drools.drl.ast.descr.PackageDescr in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode1.
@Test
@Ignore
public void testIncompleteCode1() throws DroolsParserException, RecognitionException {
String input = "package a.b.c import a.b.c.* rule MyRule when Class ( property memberOf collexction ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
System.out.println(parser.getErrors());
assertNotNull(descr);
assertEquals("a.b.c", descr.getNamespace());
assertEquals("a.b.c.*", descr.getImports().get(0).getTarget());
assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, getLastIntegerValue(parser.getEditorSentences().get(2).getContent()));
}
Aggregations