use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode7.
@Test
public void testIncompleteCode7() throws DroolsParserException, RecognitionException {
String input = "package a.b.c imrt 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.compiler.compiler.DrlParser in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode10.
@Test
@Ignore
public void testIncompleteCode10() throws DroolsParserException, RecognitionException {
String input = "package a.b.c import a.b.c.*" + " rule MyRule xxxxx Class ( property memberOf " + " query MyQuery Class ( property memberOf collection ) end ";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
PackageDescr descr = parser.parse(true, input);
assertEquals("a.b.c", descr.getNamespace());
assertEquals("a.b.c.*", descr.getImports().get(0).getTarget());
assertEquals(0, descr.getRules().size());
}
use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.
the class RuleParserTest method testExpanderLineSpread.
@Test
public void testExpanderLineSpread() throws Exception {
final DrlParser parser = new DrlParser(LanguageLevelOption.DRL6);
final PackageDescr pkg = parser.parse(this.getReader("expander_spread_lines.dslr"), this.getReader("complex.dsl"));
assertFalse(parser.getErrors().toString(), parser.hasErrors());
final RuleDescr rule = (RuleDescr) pkg.getRules().get(0);
assertEquals(1, rule.getLhs().getDescrs().size());
final OrDescr or = (OrDescr) rule.getLhs().getDescrs().get(0);
assertEquals(2, or.getDescrs().size());
assertNotNull((String) rule.getConsequence());
}
use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.
the class RuleParserTest method testPackageWithError.
@Test
public void testPackageWithError() throws Exception {
final String source = "package 12 foo.bar.baz";
final DrlParser parser = new DrlParser(LanguageLevelOption.DRL6);
final PackageDescr pkg = parser.parse(true, new StringReader(source));
assertTrue(parser.hasErrors());
assertEquals("foo.bar.baz", pkg.getName());
}
Aggregations