[jboss-svn-commits] JBL Code SVN: r26792 - labs/jbossrules/trunk/drools-solver/drools-solver-core/src/test/java/org/drools/solver/core/localsearch/decider/forager.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun May 31 07:32:26 EDT 2009


Author: ge0ffrey
Date: 2009-05-31 07:32:25 -0400 (Sun, 31 May 2009)
New Revision: 26792

Modified:
   labs/jbossrules/trunk/drools-solver/drools-solver-core/src/test/java/org/drools/solver/core/localsearch/decider/forager/AcceptedForagerTest.java
Log:
fix broken testcases due to shifting penalty support

Modified: labs/jbossrules/trunk/drools-solver/drools-solver-core/src/test/java/org/drools/solver/core/localsearch/decider/forager/AcceptedForagerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-solver/drools-solver-core/src/test/java/org/drools/solver/core/localsearch/decider/forager/AcceptedForagerTest.java	2009-05-31 06:09:50 UTC (rev 26791)
+++ labs/jbossrules/trunk/drools-solver/drools-solver-core/src/test/java/org/drools/solver/core/localsearch/decider/forager/AcceptedForagerTest.java	2009-05-31 11:32:25 UTC (rev 26792)
@@ -11,6 +11,7 @@
 import org.drools.solver.core.move.Move;
 import org.drools.solver.core.score.DefaultSimpleScore;
 import org.drools.solver.core.score.Score;
+import org.drools.solver.core.score.comparator.NaturalScoreComparator;
 import org.drools.solver.core.score.definition.SimpleScoreDefinition;
 
 /**
@@ -22,12 +23,12 @@
         
     }
     
-    public void FIXME_testPickMoveMaxScoreOfAll() {
+    public void testPickMoveMaxScoreOfAll() {
         // Setup
         Forager forager = new AcceptedForager(PickEarlyByScore.NONE, false);
         LocalSearchSolverScope localSearchSolverScope = createLocalSearchSolverScope();
         forager.solvingStarted(localSearchSolverScope);
-        StepScope stepScope = new StepScope(localSearchSolverScope);
+        StepScope stepScope = createStepScope(localSearchSolverScope);
         forager.beforeDeciding(stepScope);
         // Pre conditions
         MoveScope a = createMoveScope(stepScope, DefaultSimpleScore.valueOf(-20), 30.0);
@@ -58,12 +59,12 @@
         forager.solvingEnded(localSearchSolverScope);
     }
 
-    public void FIXME_testPickMoveFirstBestScoreImproving() {
+    public void testPickMoveFirstBestScoreImproving() {
         // Setup
         Forager forager = new AcceptedForager(PickEarlyByScore.FIRST_BEST_SCORE_IMPROVING, false);
         LocalSearchSolverScope localSearchSolverScope = createLocalSearchSolverScope();
         forager.solvingStarted(localSearchSolverScope);
-        StepScope stepScope = new StepScope(localSearchSolverScope);
+        StepScope stepScope = createStepScope(localSearchSolverScope);
         forager.beforeDeciding(stepScope);
         // Pre conditions
         MoveScope a = createMoveScope(stepScope, DefaultSimpleScore.valueOf(-1), 0.0);
@@ -88,12 +89,12 @@
         forager.solvingEnded(localSearchSolverScope);
     }
 
-    public void FIXME_testPickMoveFirstLastStepScoreImproving() {
+    public void testPickMoveFirstLastStepScoreImproving() {
         // Setup
         Forager forager = new AcceptedForager(PickEarlyByScore.FIRST_LAST_STEP_SCORE_IMPROVING, false);
         LocalSearchSolverScope localSearchSolverScope = createLocalSearchSolverScope();
         forager.solvingStarted(localSearchSolverScope);
-        StepScope stepScope = new StepScope(localSearchSolverScope);
+        StepScope stepScope = createStepScope(localSearchSolverScope);
         forager.beforeDeciding(stepScope);
         // Pre conditions
         MoveScope a = createMoveScope(stepScope, DefaultSimpleScore.valueOf(-1), 0.0);
@@ -118,12 +119,12 @@
         forager.solvingEnded(localSearchSolverScope);
     }
 
-    public void FIXME_testPickMoveRandomly() {
+    public void testPickMoveRandomly() {
         // Setup
         Forager forager = new AcceptedForager(PickEarlyByScore.NONE, true);
         LocalSearchSolverScope localSearchSolverScope = createLocalSearchSolverScope();
         forager.solvingStarted(localSearchSolverScope);
-        StepScope stepScope = new StepScope(localSearchSolverScope);
+        StepScope stepScope = createStepScope(localSearchSolverScope);
         forager.beforeDeciding(stepScope);
         // Pre conditions
         MoveScope a = createMoveScope(stepScope, DefaultSimpleScore.valueOf(-20), 0.0);
@@ -163,6 +164,12 @@
         return localSearchSolverScope;
     }
 
+    private StepScope createStepScope(LocalSearchSolverScope localSearchSolverScope) {
+        StepScope stepScope = new StepScope(localSearchSolverScope);
+        stepScope.setDeciderScoreComparator(new NaturalScoreComparator());
+        return stepScope;
+    }
+
     public MoveScope createMoveScope(StepScope stepScope, Score score, double acceptChance) {
         MoveScope moveScope = new MoveScope(stepScope);
         moveScope.setMove(new DummyMove());




More information about the jboss-svn-commits mailing list