use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.
the class DumperTestHelper method dump.
public static String dump(String filename) throws Exception {
DrlParser parser = new DrlParser(LanguageLevelOption.DRL6);
final PackageDescr pkgOriginal = parser.parse(new InputStreamReader(DumperTestHelper.class.getResourceAsStream(filename)));
final DrlDumper dumper = new DrlDumper();
return dumper.dump(pkgOriginal);
}
use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.
the class DumperTest method testRoundTripDRLAccumulate.
@Test
public void testRoundTripDRLAccumulate() throws Exception {
// RHDM-254
String drl = "package org.test\n" + "\n" + "rule \"last flown date\"\n" + "when\n" + " $customer : Profile( $ceid : id )\n" + " accumulate(\n" + " Flight( status == \"Flown\", $dptDate: departureDate.time ) from $customer.flights,\n" + " $cnt : count( $dptDate );\n" + " $cnt > 0 )\n" + "then\n" + "end";
DrlParser parser = new DrlParser(LanguageLevelOption.DRL6);
final PackageDescr pkgOriginal = parser.parse(false, drl);
final DrlDumper dumper = new DrlDumper();
String out = dumper.dump(pkgOriginal);
Assertions.assertThat(drl).isEqualToIgnoringWhitespace(out);
}
use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.
the class FromTest method testFromWithNewConstructor.
@Test
public void testFromWithNewConstructor() throws Exception {
final DrlParser parser = new DrlParser(LanguageLevelOption.DRL5);
final PackageDescr descr = parser.parse(new InputStreamReader(getClass().getResourceAsStream("test_FromWithNewConstructor.drl")));
final Collection<KiePackage> pkgs = loadKnowledgePackages(descr);
SerializationHelper.serializeObject(pkgs);
}
use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode4.
@Test
public void testIncompleteCode4() throws DroolsParserException, RecognitionException {
String input = "package a.b.c import a.b.c.*" + " rule MyRule when Class ( property == collection ) then end " + " query MyQuery Class ( property == 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());
assertNotNull(descr);
assertEquals("MyRule", descr.getRules().get(0).getName());
assertNotNull(descr);
assertEquals("MyQuery", descr.getRules().get(1).getName());
}
use of org.drools.compiler.compiler.DrlParser in project drools by kiegroup.
the class DRLIncompleteCodeTest method testIncompleteCode9.
@Test
@Ignore
public void testIncompleteCode9() throws DroolsParserException, RecognitionException {
String input = "package a.b.c import a.b.c.*" + " rule MyRule xxxxx 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);
assertEquals("a.b.c", descr.getNamespace());
assertEquals("a.b.c.*", descr.getImports().get(0).getTarget());
assertEquals(1, descr.getRules().size());
assertEquals("MyQuery", descr.getRules().get(0).getName());
}
Aggregations