Skip to content

Commit

Permalink
PLANNER-421 Avoid undoMove.toString()
Browse files Browse the repository at this point in the history
(cherry picked from commit b1b2ba6)
  • Loading branch information
ge0ffrey committed Aug 31, 2015
1 parent 4bed2e1 commit 34d7f4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Expand Up @@ -135,18 +135,19 @@ public void assertWorkingScoreFromScratch(Score workingScore, Object completedAc
public void assertExpectedUndoMoveScore(Move move, Move undoMove, Score beforeMoveScore) {
Score undoScore = calculateScore();
if (!undoScore.equals(beforeMoveScore)) {
// TODO PLANNER-421 Avoid undoMove.toString() because it's stale (because the move is already done)
String undoMoveString = "Undo(" + move + ")";
// Precondition: assert that are probably no corrupted score rules.
getScoreDirector().assertWorkingScoreFromScratch(undoScore, undoMove);
getScoreDirector().assertWorkingScoreFromScratch(undoScore, undoMoveString);
// Precondition: assert that shadow variable after the undoMove aren't stale
getScoreDirector().assertShadowVariablesAreNotStale(undoScore, undoMove);
// TODO PLANNER-421 undoMove.toString() not included because it's stale (because the move is already done)
getScoreDirector().assertShadowVariablesAreNotStale(undoScore, undoMoveString);
throw new IllegalStateException("UndoMove corruption: the beforeMoveScore (" + beforeMoveScore
+ ") is not the undoScore (" + undoScore
+ ") which is the uncorruptedScore (" + undoScore + ") of the workingSolution.\n"
+ " 1) Enable EnvironmentMode " + EnvironmentMode.FULL_ASSERT
+ " (if you haven't already) to fail-faster in case there's a score corruption.\n"
+ " 2) Check the Move.createUndoMove(...) method of the moveClass (" + move.getClass() + ")."
+ " The move (" + move + ") might have a corrupted undoMove.\n"
+ " The move (" + move + ") might have a corrupted undoMove (" + undoMoveString + ").\n"
+ " 3) Check your custom " + VariableListener.class.getSimpleName() + "s (if you have any)"
+ " for shadow variables that are used by the score constraints with a different score weight"
+ " between the beforeMoveScore (" + beforeMoveScore + ") and the undoScore (" + undoScore + ").");
Expand Down
Expand Up @@ -353,7 +353,8 @@ public void assertShadowVariablesAreNotStale(Score expectedWorkingScore, Object
+ ") after all " + VariableListener.class.getSimpleName() + "s were triggered without changes to the genuine variables.\n"
+ "Probably the " + VariableListener.class.getSimpleName()
+ " class for that shadow variable (" + shadowVariableDescriptor.getSimpleEntityAndVariableName()
+ ") forgot to update it when one of its sources changed.");
+ ") forgot to update it when one of its sources changed"
+ " after completedAction (" + completedAction + ").");
}
}
}
Expand Down

0 comments on commit 34d7f4f

Please sign in to comment.