Skip to content

Commit a92799e

Browse files
Christopher-Chianellitriceo
authored andcommitted
test: add testing support for legacy moves in MoveAsserter
1 parent 0f59213 commit a92799e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

core/src/test/java/ai/timefold/solver/core/impl/solver/MoveAsserter.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import ai.timefold.solver.core.api.score.Score;
66
import ai.timefold.solver.core.impl.domain.solution.descriptor.SolutionDescriptor;
7+
import ai.timefold.solver.core.impl.heuristic.move.LegacyMoveAdapter;
78
import ai.timefold.solver.core.impl.score.director.InnerScore;
89
import ai.timefold.solver.core.preview.api.move.Move;
910

@@ -36,6 +37,32 @@ public void assertMoveAndApply(Solution_ solution, Move<Solution_> move, Consume
3637
assertMove(solution, move, moveSolutionConsumer, true);
3738
}
3839

40+
public void assertMoveAndUndo(Solution_ solution, ai.timefold.solver.core.impl.heuristic.move.Move<Solution_> move) {
41+
assertMoveAndUndo(solution, move, (ignored) -> {
42+
});
43+
}
44+
45+
public void assertMoveAndUndo(Solution_ solution, ai.timefold.solver.core.impl.heuristic.move.Move<Solution_> move,
46+
Consumer<Solution_> moveSolutionConsumer) {
47+
assertMove(solution, move, moveSolutionConsumer, false);
48+
}
49+
50+
public void assertMoveAndApply(Solution_ solution, ai.timefold.solver.core.impl.heuristic.move.Move<Solution_> move) {
51+
assertMoveAndApply(solution, move, (ignored) -> {
52+
});
53+
}
54+
55+
public void assertMoveAndApply(Solution_ solution, ai.timefold.solver.core.impl.heuristic.move.Move<Solution_> move,
56+
Consumer<Solution_> moveSolutionConsumer) {
57+
assertMove(solution, move, moveSolutionConsumer, true);
58+
}
59+
60+
private void assertMove(Solution_ solution, ai.timefold.solver.core.impl.heuristic.move.Move<Solution_> move,
61+
Consumer<Solution_> moveSolutionConsumer,
62+
boolean applyMove) {
63+
assertMove(solution, new LegacyMoveAdapter<>(move), moveSolutionConsumer, applyMove);
64+
}
65+
3966
private void assertMove(Solution_ solution, Move<Solution_> move, Consumer<Solution_> moveSolutionConsumer,
4067
boolean applyMove) {
4168
var scoreDirectorFactory = new MoveAssertScoreDirectorFactory<>(solutionDescriptor, moveSolutionConsumer);

0 commit comments

Comments
 (0)