use of org.drools.mvel.DrlDumper in project drools by kiegroup.
the class DumperTest method testAccumulateWithoutConstraint.
@Test
public void testAccumulateWithoutConstraint() throws Exception {
// DROOLS-5872
String expectedDrl = "package example \n" + "\n" + "import java.math.BigDecimal\n" + "\n" + "rule \"Test Rule\"\n" + "when\n" + " accumulate( \n" + " $target : example.RuleTest.Fact( ) ,\n" + " $cnt : count( ) \n" + " ) \n" + "then\n" + "System.out.println($cnt);\n" + "\n" + "end";
PackageDescr packageDescr = DescrFactory.newPackage().name("example").newImport().target("java.math.BigDecimal").end().newRule().name("Test Rule").lhs().accumulate().source().pattern().type("example.RuleTest.Fact").id("$target", false).end().end().function("count", "$cnt", false).end().end().rhs("System.out.println($cnt);").end().end().getDescr();
String drl = new DrlDumper().dump(packageDescr);
Assertions.assertThat(drl).isEqualToIgnoringWhitespace(expectedDrl);
}
use of org.drools.mvel.DrlDumper in project drools by kiegroup.
the class XmlPackageReaderTest method testParseCollect.
@Test
public void testParseCollect() throws Exception {
final XmlPackageReader xmlPackageReader = getXmReader();
xmlPackageReader.read(new InputStreamReader(getClass().getResourceAsStream("test_ParseCollect.xml")));
final PackageDescr packageDescr = xmlPackageReader.getPackageDescr();
String expected = StringUtils.readFileAsString(new InputStreamReader(getClass().getResourceAsStream("test_ParseCollect.drl")));
String expectedWithoutHeader = removeLicenseHeader(expected);
String actual = new DrlDumper().dump(packageDescr);
Assertions.assertThat(expectedWithoutHeader).isEqualToIgnoringWhitespace(actual);
}
use of org.drools.mvel.DrlDumper in project drools by kiegroup.
the class DescrBuilderTest method testDumperTimer.
@Test
public void testDumperTimer() {
PackageDescr pkg = DescrFactory.newPackage().name("org.test").newRule().name("org.test").attribute("timer").value("cron:0/5 * * * * ?").end().lhs().end().rhs("").end().end().getDescr();
String drl = new DrlDumper().dump(pkg);
assertTrue(drl.contains("timer (cron:0/5 * * * * ?)"));
}
use of org.drools.mvel.DrlDumper in project drools by kiegroup.
the class DescrBuilderTest method testDumperPositional.
@Test
public void testDumperPositional() {
PackageDescr pkg = DescrFactory.newPackage().name("org.test").newRule().name("org.test").lhs().pattern().type("Integer").constraint("this > 10", true).constraint("this > 11", true).constraint("this > 12", false).constraint("this > 13", false).end().end().rhs("").end().end().getDescr();
String drl = new DrlDumper().dump(pkg);
assertTrue(drl.contains("Integer( this > 10, this > 11; this > 12, this > 13 )"));
}
use of org.drools.mvel.DrlDumper in project drools by kiegroup.
the class DescrBuilderTest method testDumperDuration.
@Test
public void testDumperDuration() {
PackageDescr pkg = DescrFactory.newPackage().name("org.test").newRule().name("org.test").attribute("duration").value("int: 0 3600000; repeat-limit = 6").end().lhs().end().rhs("").end().end().getDescr();
String drl = new DrlDumper().dump(pkg);
assertTrue(drl.contains("duration (int: 0 3600000; repeat-limit = 6)"));
}
Aggregations