[jboss-svn-commits] JBL Code SVN: r18750 - in labs/jbossrules/trunk/drools-compiler/src: main/java/org/drools/brms/server/util and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Mar 7 00:20:10 EST 2008
Author: michael.neale at jboss.com
Date: 2008-03-07 00:20:10 -0500 (Fri, 07 Mar 2008)
New Revision: 18750
Added:
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionInsertFactCol.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionRetractFactCol.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionSetFieldCol.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/AttributeCol.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/server/util/GuidedDTBRLPersistence.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/brms/server/util/GuidedDTBRLPersistenceTest.java
Modified:
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionCol.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ConditionCol.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/GuidedDecisionTable.java
Log:
JBRULES-1494 Decision table model
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionCol.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionCol.java 2008-03-07 05:16:40 UTC (rev 18749)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionCol.java 2008-03-07 05:20:10 UTC (rev 18750)
@@ -2,7 +2,17 @@
import org.drools.brms.client.modeldriven.brl.PortableObject;
-public class ActionCol implements PortableObject {
+/**
+ * This is the config for an action column.
+ * @author Michael Neale
+ *
+ */
+public abstract class ActionCol implements PortableObject {
+ /**
+ * The header to be displayed.
+ */
public String header;
+
+
}
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionInsertFactCol.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionInsertFactCol.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionInsertFactCol.java 2008-03-07 05:20:10 UTC (rev 18750)
@@ -0,0 +1,30 @@
+package org.drools.brms.client.modeldriven.dt;
+
+public class ActionInsertFactCol extends ActionCol {
+
+ /**
+ * The fact type (class) that is to be created.
+ * eg Driver, Person, Cheese.
+ */
+ public String factType;
+
+ /**
+ * The bound name of the variable to be effected.
+ * If the same name appears twice, is it merged into the same action.
+ */
+ public String boundName;
+
+ /**
+ * The field on the fact being effected.
+ */
+ public String factField;
+
+ /**
+ * Same as the type in ActionFieldValue - eg, either a String, or Numeric.
+ * Refers to the data type of the literal value in the cell.
+ * Refer to the types in SuggestionCompletionEngine.
+ */
+ public String type;
+
+
+}
Property changes on: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionInsertFactCol.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionRetractFactCol.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionRetractFactCol.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionRetractFactCol.java 2008-03-07 05:20:10 UTC (rev 18750)
@@ -0,0 +1,12 @@
+package org.drools.brms.client.modeldriven.dt;
+
+public class ActionRetractFactCol extends ActionCol {
+
+ /**
+ * The name of the fact to be retracted.
+ */
+ public String boundName;
+
+
+
+}
Property changes on: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionRetractFactCol.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionSetFieldCol.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionSetFieldCol.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionSetFieldCol.java 2008-03-07 05:20:10 UTC (rev 18750)
@@ -0,0 +1,22 @@
+package org.drools.brms.client.modeldriven.dt;
+
+public class ActionSetFieldCol extends ActionCol {
+
+ /**
+ * The bound name of the variable to be effected.
+ * If the same name appears twice, is it merged into the same action.
+ */
+ public String boundName;
+
+ /**
+ * The field on the fact being effected.
+ */
+ public String factField;
+
+ /**
+ * Same as the type in ActionFieldValue - eg, either a String, or Numeric.
+ * Refers to the data type of the literal value in the cell.
+ * These values come from SuggestionCompletionEngine.
+ */
+ public String type;
+}
Property changes on: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ActionSetFieldCol.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/AttributeCol.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/AttributeCol.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/AttributeCol.java 2008-03-07 05:20:10 UTC (rev 18750)
@@ -0,0 +1,14 @@
+package org.drools.brms.client.modeldriven.dt;
+
+import org.drools.brms.client.modeldriven.brl.PortableObject;
+
+/**
+ * This is a rule attribute - eg salience, no-loop etc.
+ * @author Michael Neale
+ *
+ */
+public class AttributeCol implements PortableObject {
+
+ public String attr;
+
+}
Property changes on: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/AttributeCol.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ConditionCol.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ConditionCol.java 2008-03-07 05:16:40 UTC (rev 18749)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/ConditionCol.java 2008-03-07 05:20:10 UTC (rev 18750)
@@ -2,8 +2,50 @@
import org.drools.brms.client.modeldriven.brl.PortableObject;
+/**
+ * This is the config for a condition column. Typically many of them have their constraints added.
+ *
+ * @author Michael Neale
+ *
+ */
public class ConditionCol implements PortableObject {
+ /**
+ * What is displayed at the top
+ */
public String header;
+ /**
+ * The type of the fact - class - eg Driver, Person, Cheese etc.
+ */
+ public String factType;
+
+ /**
+ * The name that this gets referenced as. Multiple columns with the same name mean their constraints will be combined.
+ */
+ public String boundName;
+
+ /**
+ * The type of the value that is in the cell, eg if it is a formula, or literal value etc.
+ * The valid types are from ISingleFieldConstraint:
+ * TYPE_LITERAL
+ * TYPE_RET_VALUE
+ * TYPE_PREDICATE (in this case, the field and operator are ignored).
+ */
+ public int constraintValueType;
+
+
+ /**
+ * The field of the fact that this pertains to (if its a predicate, ignore it).
+ */
+ public String factField;
+
+
+ /**
+ * The operator to use to compare the field with the value (unless its a predicate, in which case this is ignored).
+ */
+ public String operator;
+
+
+
}
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/GuidedDecisionTable.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/GuidedDecisionTable.java 2008-03-07 05:16:40 UTC (rev 18749)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/client/modeldriven/dt/GuidedDecisionTable.java 2008-03-07 05:20:10 UTC (rev 18750)
@@ -5,15 +5,42 @@
import org.drools.brms.client.modeldriven.brl.PortableObject;
+/**
+ * This is a decision table model for a guided editor. It is not template or XLS based.
+ * (template could be done relatively easily by taking a template, as a String, and then String[][] data and driving the SheetListener
+ * interface in the decision tables module).
+ *
+ * This works by taking the column definitions, and combining them with the table of data to produce rule models.
+ *
+ * @author Michael Neale
+ */
public class GuidedDecisionTable implements PortableObject {
+ /**
+ * The name - obviously.
+ */
+ public String tableName;
+
+ /**
+ * @gwt.typeArgs <org.drools.brms.client.modeldriven.dt.AttributeCol>
+ */
+ public List attributeCols = new ArrayList();
+
+ /**
+ * @gwt.typeArgs <org.drools.brms.client.modeldriven.dt.ConditionCol>
+ */
public List conditionCols = new ArrayList();
+
+ /**
+ * @gwt.typeArgs <org.drools.brms.client.modeldriven.dt.ActionCol>
+ */
public List actionCols = new ArrayList();
/**
* First column is always row number.
* Second column is description.
- * Subsequent ones follow the above column definitions.
+ * Subsequent ones follow the above column definitions:
+ * attributeCols, then conditionCols, then actionCols, in that order, left to right.
*/
public String[][] data;
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/server/util/GuidedDTBRLPersistence.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/server/util/GuidedDTBRLPersistence.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/server/util/GuidedDTBRLPersistence.java 2008-03-07 05:20:10 UTC (rev 18750)
@@ -0,0 +1,125 @@
+package org.drools.brms.server.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.brms.client.modeldriven.brl.FactPattern;
+import org.drools.brms.client.modeldriven.brl.IPattern;
+import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
+import org.drools.brms.client.modeldriven.brl.RuleAttribute;
+import org.drools.brms.client.modeldriven.brl.RuleModel;
+import org.drools.brms.client.modeldriven.brl.SingleFieldConstraint;
+import org.drools.brms.client.modeldriven.dt.AttributeCol;
+import org.drools.brms.client.modeldriven.dt.ConditionCol;
+import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
+
+/**
+ * This takes care of converting GuidedDT object to DRL (via the RuleModel).
+ * @author Michael Neale
+ *
+ */
+public class GuidedDTBRLPersistence {
+
+
+ public String marshal(GuidedDecisionTable dt) {
+
+ StringBuilder sb = new StringBuilder();
+
+ for (int i = 0; i < dt.data.length; i++) {
+ String[] row = dt.data[i];
+ String num = row[0];
+ String desc = row[1];
+
+ RuleModel rm = new RuleModel();
+ rm.name = getName(dt.tableName, num, desc);
+
+ doAttribs(dt.attributeCols, row, rm);
+ doConditions(dt.attributeCols.size(), dt.conditionCols, row, rm);
+ doActions(dt.attributeCols.size() + dt.conditionCols.size(), dt.actionCols, row, rm);
+ }
+
+
+ return sb.toString();
+
+ }
+
+ void doActions(int condAndAttrs, List actionCols, String[] row, RuleModel rm) {
+
+
+ }
+
+ void doConditions(int numOfAttributes, List<ConditionCol> conditionCols, String[] row, RuleModel rm) {
+
+ List<FactPattern> patterns = new ArrayList<FactPattern>();
+
+ for (int i = 0; i < conditionCols.size(); i++) {
+ ConditionCol c = (ConditionCol) conditionCols.get(i);
+ String cell = row[i + 2 + numOfAttributes];
+ if (validCell(cell)) {
+
+ //get or create the pattern it belongs too
+ FactPattern fp = find(patterns, c.boundName);
+ if (fp == null) {
+ fp = new FactPattern(c.factType);
+ fp.boundName = c.boundName;
+ patterns.add(fp);
+ }
+
+ //now add the constraint from this cell
+ switch (c.constraintValueType) {
+ case ISingleFieldConstraint.TYPE_LITERAL:
+ case ISingleFieldConstraint.TYPE_RET_VALUE:
+ SingleFieldConstraint sfc = new SingleFieldConstraint(c.factField);
+ sfc.operator = c.operator;
+ sfc.constraintValueType = c.constraintValueType;
+ sfc.value = cell;
+ fp.addConstraint(sfc);
+ break;
+ case ISingleFieldConstraint.TYPE_PREDICATE:
+ SingleFieldConstraint pred = new SingleFieldConstraint();
+ pred.constraintValueType = c.constraintValueType;
+ pred.value = cell;
+ fp.addConstraint(pred);
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown constraintValueType: " + c.constraintValueType);
+ }
+ }
+ }
+ rm.lhs = patterns.toArray(new IPattern[patterns.size()]);
+ }
+
+ private FactPattern find(List<FactPattern> patterns, String boundName) {
+ for (FactPattern factPattern : patterns) {
+ if (factPattern.boundName.equals(boundName)) {
+ return factPattern;
+ }
+ }
+ return null;
+ }
+
+ void doAttribs(List attributeCols, String[] row, RuleModel rm) {
+ List<RuleAttribute> attribs = new ArrayList<RuleAttribute>();
+ for (int j = 0; j < attributeCols.size(); j++) {
+ AttributeCol at = (AttributeCol) attributeCols.get(j);
+ String cell = row[j + 2];
+ if (validCell(cell)) {
+ attribs.add(new RuleAttribute(at.attr, cell));
+ }
+ }
+ if (attribs.size() > 0) {
+ rm.attributes = attribs.toArray(new RuleAttribute[attribs.size()]);
+ }
+ }
+
+ String getName(String tableName, String num, String desc) {
+ return (validCell(desc)) ? num + "_" + desc : num + "_" + tableName;
+ }
+
+ boolean validCell(String c) {
+ return c !=null && !c.trim().equals("");
+ }
+
+}
Property changes on: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/brms/server/util/GuidedDTBRLPersistence.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/brms/server/util/GuidedDTBRLPersistenceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/brms/server/util/GuidedDTBRLPersistenceTest.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/brms/server/util/GuidedDTBRLPersistenceTest.java 2008-03-07 05:20:10 UTC (rev 18750)
@@ -0,0 +1,231 @@
+package org.drools.brms.server.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.FactPattern;
+import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
+import org.drools.brms.client.modeldriven.brl.RuleAttribute;
+import org.drools.brms.client.modeldriven.brl.RuleModel;
+import org.drools.brms.client.modeldriven.brl.SingleFieldConstraint;
+import org.drools.brms.client.modeldriven.dt.ActionInsertFactCol;
+import org.drools.brms.client.modeldriven.dt.ActionRetractFactCol;
+import org.drools.brms.client.modeldriven.dt.ActionSetFieldCol;
+import org.drools.brms.client.modeldriven.dt.AttributeCol;
+import org.drools.brms.client.modeldriven.dt.ConditionCol;
+import org.drools.brms.client.modeldriven.dt.GuidedDecisionTable;
+
+public class GuidedDTBRLPersistenceTest extends TestCase {
+
+
+ public void testOneRule() throws Exception {
+ GuidedDecisionTable dt = new GuidedDecisionTable();
+ dt.tableName = "michael";
+
+ AttributeCol attr = new AttributeCol();
+ attr.attr = "salience";
+ dt.attributeCols.add(attr);
+
+ ConditionCol con = new ConditionCol();
+ con.boundName = "f1";
+ con.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+ con.factField = "age";
+ con.factType = "Driver";
+ con.header = "Driver f1 age";
+ con.operator = "==";
+ dt.conditionCols.add(con);
+
+ ConditionCol con2 = new ConditionCol();
+ con2.boundName = "f1";
+ con2.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+ con2.factField = "name";
+ con2.factType = "Driver";
+ con2.header = "Driver f1 name";
+ con2.operator = "==";
+ dt.conditionCols.add(con2);
+
+ ConditionCol con3 = new ConditionCol();
+ con3.boundName = "f1";
+ con3.constraintValueType = ISingleFieldConstraint.TYPE_RET_VALUE;
+ con3.factField = "rating";
+ con3.factType = "Driver";
+ con3.header = "Driver rating";
+ con3.operator = "==";
+ dt.conditionCols.add(con3);
+
+
+ ConditionCol con4 = new ConditionCol();
+ con4.boundName = "f2";
+ con4.constraintValueType = ISingleFieldConstraint.TYPE_PREDICATE;
+ con4.factType = "Driver";
+ con4.header = "Driver 2 pimp";
+ dt.conditionCols.add(con4);
+
+
+ ActionInsertFactCol ins = new ActionInsertFactCol();
+ ins.boundName = "ins";
+ ins.type = "Cheese";
+ ins.factField = "price";
+ ins.type = SuggestionCompletionEngine.TYPE_NUMERIC;
+ dt.actionCols.add(ins);
+
+ ActionRetractFactCol ret = new ActionRetractFactCol();
+ ret.boundName = "f2";
+ dt.actionCols.add(ret);
+
+ ActionSetFieldCol set = new ActionSetFieldCol();
+ set.boundName = "f1";
+ set.factField = "goo1";
+ set.type = SuggestionCompletionEngine.TYPE_STRING;
+ dt.actionCols.add(set);
+
+ ActionSetFieldCol set2 = new ActionSetFieldCol();
+ set2.boundName = "f1";
+ set2.factField = "goo2";
+ set2.type = SuggestionCompletionEngine.TYPE_STRING;
+ dt.actionCols.add(set2);
+
+
+ dt.data = new String[][] {
+ new String[] {"1", "desc", "42", "33", "michael", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", "gooVal2"},
+ new String[] {"2", "desc", "", "39", "bob", "age * 0.3", "age > 7", "6.60", "", "gooVal1", "gooVal2"}
+ };
+
+
+
+
+
+
+
+
+ }
+
+ public void testCellVal() {
+ GuidedDTBRLPersistence p = new GuidedDTBRLPersistence();
+ assertFalse(p.validCell(null));
+ assertFalse(p.validCell(""));
+ assertFalse(p.validCell(" "));
+
+ }
+
+ public void testName() {
+ GuidedDTBRLPersistence p = new GuidedDTBRLPersistence();
+ assertEquals("42_hey", p.getName("XXX", "42", "hey"));
+ assertEquals("42_XXX", p.getName("XXX", "42", ""));
+ }
+
+ public void testAttribs() {
+ GuidedDTBRLPersistence p = new GuidedDTBRLPersistence();
+ String[] row = new String[] {"1", "desc", "a", ""};
+
+ List<AttributeCol> attributeCols = new ArrayList<AttributeCol>();
+ RuleModel rm = new RuleModel();
+ RuleAttribute[] orig = rm.attributes;
+ p.doAttribs(attributeCols, row, rm);
+
+ assertSame(orig, rm.attributes);
+
+ AttributeCol col1 = new AttributeCol();
+ col1.attr = "salience";
+ AttributeCol col2 = new AttributeCol();
+ col2.attr = "agenda-group";
+ attributeCols.add(col1);
+ attributeCols.add(col2);
+
+ p.doAttribs(attributeCols, row, rm);
+
+ assertEquals(1, rm.attributes.length);
+ assertEquals("salience", rm.attributes[0].attributeName);
+ assertEquals("a", rm.attributes[0].value);
+
+ row = new String[] {"1", "desc", "a", "b"};
+ p.doAttribs(attributeCols, row, rm);
+ assertEquals(2, rm.attributes.length);
+ assertEquals("salience", rm.attributes[0].attributeName);
+ assertEquals("a", rm.attributes[0].value);
+ assertEquals("agenda-group", rm.attributes[1].attributeName);
+ assertEquals("b", rm.attributes[1].value);
+
+ }
+
+ public void testLHS() {
+ GuidedDTBRLPersistence p = new GuidedDTBRLPersistence();
+ String[] row = new String[] {"1", "desc", "a", "mike", "33 + 1", "age > 6", "stilton"};
+
+ List<ConditionCol> cols = new ArrayList<ConditionCol>();
+ ConditionCol col = new ConditionCol();
+ col.boundName = "p1";
+ col.factType = "Person";
+ col.factField = "name";
+ col.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+ col.operator = "==";
+ cols.add(col);
+
+ ConditionCol col2 = new ConditionCol();
+ col2.boundName = "p1";
+ col2.factType = "Person";
+ col2.factField = "age";
+ col2.constraintValueType = ISingleFieldConstraint.TYPE_RET_VALUE;
+ col2.operator = "<";
+ cols.add(col2);
+
+ ConditionCol col3 = new ConditionCol();
+ col3.boundName = "p1";
+ col3.factType = "Person";
+ col3.constraintValueType = ISingleFieldConstraint.TYPE_PREDICATE;
+ cols.add(col3);
+
+ ConditionCol col4 = new ConditionCol();
+ col4.boundName = "c";
+ col4.factType = "Cheese";
+ col4.factField = "type";
+ col4.operator = "==";
+ col4.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+ cols.add(col4);
+
+ RuleModel rm = new RuleModel();
+
+ p.doConditions(1, cols, row, rm);
+ assertEquals(2, rm.lhs.length);
+
+ assertEquals("Person", ((FactPattern)rm.lhs[0]).factType);
+ assertEquals("p1", ((FactPattern)rm.lhs[0]).boundName);
+
+ assertEquals("Cheese", ((FactPattern)rm.lhs[1]).factType);
+ assertEquals("c", ((FactPattern)rm.lhs[1]).boundName);
+
+ //examine the first pattern
+ FactPattern person = (FactPattern) rm.lhs[0];
+ assertEquals(3, person.constraintList.constraints.length);
+ SingleFieldConstraint cons = (SingleFieldConstraint) person.constraintList.constraints[0];
+ assertEquals(ISingleFieldConstraint.TYPE_LITERAL, cons.constraintValueType);
+ assertEquals("name", cons.fieldName);
+ assertEquals("==", cons.operator);
+ assertEquals("mike", cons.value);
+
+ cons = (SingleFieldConstraint) person.constraintList.constraints[1];
+ assertEquals(ISingleFieldConstraint.TYPE_RET_VALUE, cons.constraintValueType);
+ assertEquals("age", cons.fieldName);
+ assertEquals("<", cons.operator);
+ assertEquals("33 + 1", cons.value);
+
+ cons = (SingleFieldConstraint) person.constraintList.constraints[2];
+ assertEquals(ISingleFieldConstraint.TYPE_PREDICATE, cons.constraintValueType);
+ assertEquals("age > 6", cons.value);
+
+
+ //examine the second pattern
+ FactPattern cheese = (FactPattern) rm.lhs[1];
+ assertEquals(1, cheese.constraintList.constraints.length);
+ cons = (SingleFieldConstraint) cheese.constraintList.constraints[0];
+ assertEquals("type", cons.fieldName);
+ assertEquals("==", cons.operator);
+ assertEquals("stilton", cons.value);
+ assertEquals(ISingleFieldConstraint.TYPE_LITERAL, cons.constraintValueType);
+ }
+
+
+}
Property changes on: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/brms/server/util/GuidedDTBRLPersistenceTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list