[jboss-svn-commits] JBL Code SVN: r32223 - in labs/jbossrules/trunk/drools-factconstraint/src: main/java/org/drools/guvnor/client/factcontraints and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Mar 25 17:58:57 EDT 2010


Author: baunax
Date: 2010-03-25 17:58:57 -0400 (Thu, 25 Mar 2010)
New Revision: 32223

Modified:
   labs/jbossrules/trunk/drools-factconstraint/src/main/java/org/drools/guvnor/client/factconstraints/predefined/RangeConstraint.java
   labs/jbossrules/trunk/drools-factconstraint/src/main/java/org/drools/guvnor/client/factcontraints/DefaultConstraintImpl.java
   labs/jbossrules/trunk/drools-factconstraint/src/test/java/org/drools/factconstraint/RangeConstraintTest.java
Log:
changes verifier rules constrains to use the new drools-verifier changes (guids for paths)

Modified: labs/jbossrules/trunk/drools-factconstraint/src/main/java/org/drools/guvnor/client/factconstraints/predefined/RangeConstraint.java
===================================================================
--- labs/jbossrules/trunk/drools-factconstraint/src/main/java/org/drools/guvnor/client/factconstraints/predefined/RangeConstraint.java	2010-03-25 20:16:24 UTC (rev 32222)
+++ labs/jbossrules/trunk/drools-factconstraint/src/main/java/org/drools/guvnor/client/factconstraints/predefined/RangeConstraint.java	2010-03-25 21:58:57 UTC (rev 32223)
@@ -74,12 +74,12 @@
         StringBuilder restrictionPattern = new StringBuilder();
 
         restrictionPattern.append("      ($restriction :LiteralRestriction(\n");
-        restrictionPattern.append("            fieldGuid == $field.guid,\n");
+        restrictionPattern.append("            fieldPath == $field.path,\n");
         restrictionPattern.append("            valueType == Field.INT,\n");
         restrictionPattern.append("            intValue < " + getMin() + " || > " + getMax() + "\n");
         restrictionPattern.append("      ) OR\n");
         restrictionPattern.append("      $restriction :LiteralRestriction(\n");
-        restrictionPattern.append("            fieldGuid == $field.guid,\n");
+        restrictionPattern.append("            fieldPath == $field.path,\n");
         restrictionPattern.append("            valueType == Field.DOUBLE,\n");
         restrictionPattern.append("            doubleValue < " + getMin() + " || > " + getMax() + "\n");
         restrictionPattern.append("      ))\n");

Modified: labs/jbossrules/trunk/drools-factconstraint/src/main/java/org/drools/guvnor/client/factcontraints/DefaultConstraintImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-factconstraint/src/main/java/org/drools/guvnor/client/factcontraints/DefaultConstraintImpl.java	2010-03-25 20:16:24 UTC (rev 32222)
+++ labs/jbossrules/trunk/drools-factconstraint/src/main/java/org/drools/guvnor/client/factcontraints/DefaultConstraintImpl.java	2010-03-25 21:58:57 UTC (rev 32223)
@@ -56,16 +56,27 @@
         this.verifierFieldPatternTemplate += "      )\n";
 
         this.verifierRestrictionPatternTemplate += "      $restriction :LiteralRestriction(\n";
-        this.verifierRestrictionPatternTemplate += "            fieldGuid == $field.guid,\n";
+        this.verifierRestrictionPatternTemplate += "            fieldPath == $field.path,\n";
         this.verifierRestrictionPatternTemplate += "            ${constraints}\n";
         this.verifierRestrictionPatternTemplate += "      )\n";
 
         this.verifierRuleThenTemplate += "  then\n";
 
+        /*
+         result.add( new VerifierMessage(
+								impactedRules,
+								Severity.ERROR,
+								MessageType.ALWAYS_FALSE,
+								$p,
+								$p + " in " + $r + " can never be satisfied." ) );
+         */
+        
+        
         this.verifierActionTemplate += "      Map<String,String> impactedRules = new HashMap<String,String>();\n";
-        this.verifierActionTemplate += "      impactedRules.put( $restriction.getRuleGuid(), $restriction.getRuleName());\n";
+//        this.verifierActionTemplate += "      impactedRules.put( $restriction.getPath(), $restriction.getRuleName());\n";
+//        this.verifierActionTemplate += "      impactedRules.put( $r.getPath(), $r.getName());\n";
         this.verifierActionTemplate += "      result.add(new VerifierMessage(\n";
-        //this.verifierActionTemplate += "                        impactedRules,\n";
+        this.verifierActionTemplate += "                        impactedRules,\n";
         this.verifierActionTemplate += "                        Severity.ERROR,\n";
         this.verifierActionTemplate += "                        MessageType.NOT_SPECIFIED,\n";
         this.verifierActionTemplate += "                        $restriction,\n";

Modified: labs/jbossrules/trunk/drools-factconstraint/src/test/java/org/drools/factconstraint/RangeConstraintTest.java
===================================================================
--- labs/jbossrules/trunk/drools-factconstraint/src/test/java/org/drools/factconstraint/RangeConstraintTest.java	2010-03-25 20:16:24 UTC (rev 32222)
+++ labs/jbossrules/trunk/drools-factconstraint/src/test/java/org/drools/factconstraint/RangeConstraintTest.java	2010-03-25 21:58:57 UTC (rev 32223)
@@ -119,6 +119,7 @@
 
 
         String ruleToVerify = "";
+        int fail = 0;
 
         //OK
         ruleToVerify += "package org.drools.factconstraint.test\n\n";
@@ -137,6 +138,7 @@
         ruleToVerify += "   then\n";
         ruleToVerify += "       System.out.println(\"Rule fired\");\n";
         ruleToVerify += "end\n\n";
+        fail++;
 
         //OK
         ruleToVerify += "rule \"rule3\"\n";
@@ -169,19 +171,21 @@
         ruleToVerify += "   then\n";
         ruleToVerify += "       System.out.println(\"Rule fired\");\n";
         ruleToVerify += "end\n";
+        fail++;
 
         //FAIL - 3
         ruleToVerify += "rule \"rule7\"\n";
         ruleToVerify += "   when\n";
-        ruleToVerify += "       Person(salary == 1001)\n";
+        ruleToVerify += "       Person(salary == 1024)\n";
         ruleToVerify += "   then\n";
         ruleToVerify += "       System.out.println(\"Rule fired\");\n";
         ruleToVerify += "end\n";
+        fail++;
 
         //OK
         ruleToVerify += "rule \"rule8\"\n";
         ruleToVerify += "   when\n";
-        ruleToVerify += "       Person(age == 40, salary == 1000)\n";
+        ruleToVerify += "       Person(age == 45, salary == 1000)\n";
         ruleToVerify += "   then\n";
         ruleToVerify += "       System.out.println(\"Rule fired\");\n";
         ruleToVerify += "end\n";
@@ -189,34 +193,38 @@
         //FAIL: age - 4
         ruleToVerify += "rule \"rule9\"\n";
         ruleToVerify += "   when\n";
-        ruleToVerify += "       Person(age == 400, salary == 1000)\n";
+        ruleToVerify += "       Person(age == 40, salary == 1011)\n";
         ruleToVerify += "   then\n";
         ruleToVerify += "       System.out.println(\"Rule fired\");\n";
         ruleToVerify += "end\n";
+        fail++;
 
         //FAIL salary - 5
         ruleToVerify += "rule \"rule10\"\n";
         ruleToVerify += "   when\n";
-        ruleToVerify += "       Person(age == 40, salary == 1003)\n";
+        ruleToVerify += "       Person(age == 43, salary == 1007)\n";
         ruleToVerify += "   then\n";
         ruleToVerify += "       System.out.println(\"Rule fired\");\n";
         ruleToVerify += "end\n";
+        fail++;
 
         //FAIL both (creates 2 warnings) - 6,7
         ruleToVerify += "rule \"rule11\"\n";
         ruleToVerify += "   when\n";
-        ruleToVerify += "       Person(age == 400, salary == 1003)\n";
+        ruleToVerify += "       Person(age == 403, salary == 1008)\n";
         ruleToVerify += "   then\n";
         ruleToVerify += "       System.out.println(\"Rule fired\");\n";
         ruleToVerify += "end\n";
-
+        fail+=2;
+        
         //FAIL both (creates 2 warnings) - 8,9
-        ruleToVerify += "rule \"rule11\"\n";
+        ruleToVerify += "rule \"rule12\"\n";
         ruleToVerify += "   when\n";
-        ruleToVerify += "       Person(age == 400, salary == -0.69)\n";
+        ruleToVerify += "       Person(age == 404, salary == -0.679)\n";
         ruleToVerify += "   then\n";
         ruleToVerify += "       System.out.println(\"Rule fired\");\n";
         ruleToVerify += "end\n";
+        fail+=2;
 
         VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
 
@@ -249,7 +257,7 @@
 
         System.out.println(warnings);
 
-        Assert.assertEquals(9, warnings.size());
+        Assert.assertEquals(fail, warnings.size());
         verifier.dispose();
     }
 



More information about the jboss-svn-commits mailing list