use of org.drools.template.model.DRLOutput in project drools by kiegroup.
the class RuleWorksheetParseTest method testQuoteEscapingDisabled.
@Test
public void testQuoteEscapingDisabled() throws Exception {
final InputStream stream = RuleWorksheetParseTest.class.getResourceAsStream("/data/QuoteEscapeDisabledWorkbook.xls");
final RuleSheetListener listener = getRuleSheetListener(stream);
final Package ruleset = listener.getRuleSet();
assertNotNull(ruleset);
DRLOutput dout = new DRLOutput();
ruleset.renderDRL(dout);
String drl = dout.getDRL();
System.out.println(drl);
// check rules
Rule rule = (Rule) ruleset.getRules().get(0);
Condition cond = (Condition) rule.getConditions().get(0);
assertEquals("Foo(myObject.getColour().equals(red), myObject.size () > \"12\")", cond.getSnippet());
rule = ruleset.getRules().get(1);
cond = rule.getConditions().get(0);
assertEquals("Foo(myObject.getColour().equals(blue), myObject.size () > 12\")", cond.getSnippet());
}
use of org.drools.template.model.DRLOutput in project drools by kiegroup.
the class RuleWorksheetParseTest method testSalienceRange.
@Test
public void testSalienceRange() throws Exception {
// DROOLS-1225
final InputStream stream = RuleWorksheetParseTest.class.getResourceAsStream("/data/SalienceRangeWorkbook.xls");
final RuleSheetListener listener = getRuleSheetListener(stream);
final Package ruleset = listener.getRuleSet();
assertNotNull(ruleset);
DRLOutput dout = new DRLOutput();
ruleset.renderDRL(dout);
String drl = dout.getDRL();
System.out.println(drl);
// check rules
List<Rule> rules = ruleset.getRules();
assertEquals("10000", rules.get(0).getSalience());
assertEquals("9999", rules.get(1).getSalience());
}
use of org.drools.template.model.DRLOutput in project drools by kiegroup.
the class RuleWorksheetParseTest method testQuoteEscapingEnabled.
@Test
public void testQuoteEscapingEnabled() throws Exception {
final InputStream stream = RuleWorksheetParseTest.class.getResourceAsStream("/data/QuoteEscapeEnabledWorkbook.xls");
final RuleSheetListener listener = getRuleSheetListener(stream);
final Package ruleset = listener.getRuleSet();
assertNotNull(ruleset);
DRLOutput dout = new DRLOutput();
ruleset.renderDRL(dout);
String drl = dout.getDRL();
System.out.println(drl);
// check rules
Rule rule = ruleset.getRules().get(0);
Condition cond = rule.getConditions().get(0);
assertEquals("Foo(myObject.getColour().equals(red), myObject.size () > 12\\\")", cond.getSnippet());
}
use of org.drools.template.model.DRLOutput in project drools by kiegroup.
the class RuleWorksheetParseTest method testRuleAttributeRendering.
/**
* Check correct rendering of string-valued attribute
*/
@Test
public void testRuleAttributeRendering() {
makeRuleSet();
makeRuleTable();
makeRow(11, "C", "A", "G");
makeRow(12, "Foo", "Foo");
makeRow(13, "attr == $param", "x");
makeRow(15, "1", "show()", "foo bar");
makeRow(16, "2", "list()", "\"10\" group\"");
listener.finishSheet();
Package p = listener.getRuleSet();
DRLOutput dout = new DRLOutput();
p.renderDRL(dout);
String drl = dout.getDRL();
// System.out.println( drl );
assertTrue(drl.contains("agenda-group \"foo bar\""));
assertTrue(drl.contains("agenda-group \"10\\\" group\""));
}
use of org.drools.template.model.DRLOutput in project drools by kiegroup.
the class TemplateDataListener method renderDRL.
public String renderDRL() {
DRLOutput out = new DRLOutput();
out.writeLine(templateContainer.getHeader());
out.writeLine(generator.getDrl());
// System.err.println(out.getDRL());
return out.getDRL();
}
Aggregations