[jboss-svn-commits] JBL Code SVN: r9527 - in labs/jbossrules/trunk/drools-decisiontables/src/test: resources/templates and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Feb 15 08:13:44 EST 2007
Author: stevearoonie
Date: 2007-02-15 08:13:44 -0500 (Thu, 15 Feb 2007)
New Revision: 9527
Modified:
labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/ExternalSpreadsheetCompilerUnitTest.java
labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template1.drl
Log:
Add example of line conditionally displaying based on a
column even though the line itself doesn't use the column.
Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/ExternalSpreadsheetCompilerUnitTest.java
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/ExternalSpreadsheetCompilerUnitTest.java 2007-02-15 12:36:39 UTC (rev 9526)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/ExternalSpreadsheetCompilerUnitTest.java 2007-02-15 13:13:44 UTC (rev 9527)
@@ -29,38 +29,6 @@
* itself is correct).
*/
public class ExternalSpreadsheetCompilerUnitTest extends TestCase {
- // public void testRE() throws Exception
- // {
- // String test = "Something(test == \"yes\" OPTIONAL[, $something$ ==
- // \"$else$\"]) OPTIONAL[Hope(it == \"$works$\")]";
- // Pattern pattern = Pattern.compile("OPTIONAL\\[(.[^\\]]*)\\]");
- // Pattern pattern2 = Pattern.compile("\\$(.[^\\$]*)\\$");
- // Matcher matcher = pattern.matcher(test);
- // StringBuffer newTest = new StringBuffer();
- // while (matcher.find()) {
- // String expression = matcher.group(1);
- // Matcher matcher2 = pattern2.matcher(expression);
- // int j = 0;
- // StringBuffer newExpression = new StringBuffer();
- // StringBuffer newEndExpression = new StringBuffer();
- // while (matcher2.find(j)) {
- // newExpression.append("\\$if(").append(matcher2.group(1)).append(")\\$");
- // newEndExpression.append("\\$endif\\$");
- // j = matcher2.end();
- // }
- // newExpression.append(escape(expression)).append(newEndExpression);
- // System.out.println(newExpression);
- // matcher.appendReplacement(newTest, newExpression.toString());
- // }
- // System.out.println(newTest);
- // }
- //
- // private String escape(String expression) {
- // System.out.println("expression: " + expression);
- // String newExp = expression.replaceAll("\\$", "\\\\\\$");
- // System.out.println("newExp: " + newExp);
- // return newExp;
- // }
public void testLoadFromClassPath() {
final ExternalSpreadsheetCompiler converter = new ExternalSpreadsheetCompiler();
final String drl = converter.compile("/data/MultiSheetDST.xls",
@@ -78,7 +46,8 @@
public void testLoadSpecificWorksheet() {
final ExternalSpreadsheetCompiler converter = new ExternalSpreadsheetCompiler();
final String drl = converter.compile("/data/MultiSheetDST.xls",
- "Another Sheet", "/templates/test_template1.drl", 11, 2);
+ "Another Sheet", "/templates/test_template1.drl", 21, 2);
+// System.out.println(drl);
assertNotNull(drl);
}
Modified: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template1.drl
===================================================================
--- labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template1.drl 2007-02-15 12:36:39 UTC (rev 9526)
+++ labs/jbossrules/trunk/drools-decisiontables/src/test/resources/templates/test_template1.drl 2007-02-15 13:13:44 UTC (rev 9527)
@@ -23,4 +23,17 @@
user.setCoolness("$coolness$");
end
end template
+template "uncoolness"
+name
+age
+log
+rule "How uncool is $name$ $row.rowNumber$"
+ when
+ user.getName().equals("$name$")
+ user.getAge() >= $age1$ && user.getAge() <= $age2$
+ then
+ System.out.println( "$log$" );
+ user.setCoolness("Not so cool"); //$coolness$ putting the column in the comments makes the line conditionally display
+end
+end template
More information about the jboss-svn-commits
mailing list