Skip to content

Commit b374d38

Browse files
authored
refactor: move testing utilities into their own packages
1 parent 7c92839 commit b374d38

100 files changed

Lines changed: 332 additions & 431 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/bom/pom.xml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,6 @@
150150
<type>test-jar</type>
151151
<version>${version.ai.timefold.solver}</version>
152152
</dependency>
153-
<dependency>
154-
<groupId>ai.timefold.solver</groupId>
155-
<artifactId>timefold-solver-test</artifactId>
156-
<version>${version.ai.timefold.solver}</version>
157-
</dependency>
158-
<dependency>
159-
<groupId>ai.timefold.solver</groupId>
160-
<artifactId>timefold-solver-test</artifactId>
161-
<version>${version.ai.timefold.solver}</version>
162-
<classifier>sources</classifier>
163-
</dependency>
164-
<dependency>
165-
<groupId>ai.timefold.solver</groupId>
166-
<artifactId>timefold-solver-test</artifactId>
167-
<type>test-jar</type>
168-
<version>${version.ai.timefold.solver}</version>
169-
</dependency>
170153
<!-- quarkus-integration -->
171154
<dependency>
172155
<groupId>ai.timefold.solver</groupId>

core/src/main/java/ai/timefold/solver/core/api/score/analysis/MatchAnalysis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public record MatchAnalysis<Score_ extends Score<Score_>>(ConstraintRef constrai
2424
Objects.requireNonNull(constraintRef);
2525
Objects.requireNonNull(score);
2626
// Null justification is impossible;
27-
// if the fetch policy doesn't requre match analysis, the code shouldn't even get here.
27+
// if the fetch policy doesn't require match analysis, the code shouldn't even get here.
2828
Objects.requireNonNull(justification, () -> """
2929
Impossible state: Received a null justification.
3030
Maybe check your %s's justifyWith() implementation for that constraint?"""

tools/test/src/main/java/ai/timefold/solver/test/api/score/stream/ConstraintVerifier.java renamed to core/src/main/java/ai/timefold/solver/core/api/score/stream/test/ConstraintVerifier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.timefold.solver.test.api.score.stream;
1+
package ai.timefold.solver.core.api.score.stream.test;
22

33
import static java.util.Objects.requireNonNull;
44

@@ -13,7 +13,7 @@
1313
import ai.timefold.solver.core.config.solver.SolverConfig;
1414
import ai.timefold.solver.core.config.util.ConfigUtils;
1515
import ai.timefold.solver.core.impl.domain.solution.descriptor.SolutionDescriptor;
16-
import ai.timefold.solver.test.impl.score.stream.DefaultConstraintVerifier;
16+
import ai.timefold.solver.core.impl.score.stream.test.DefaultConstraintVerifier;
1717

1818
import org.jspecify.annotations.NonNull;
1919

tools/test/src/main/java/ai/timefold/solver/test/api/score/stream/MultiConstraintAssertion.java renamed to core/src/main/java/ai/timefold/solver/core/api/score/stream/test/MultiConstraintAssertion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.timefold.solver.test.api.score.stream;
1+
package ai.timefold.solver.core.api.score.stream.test;
22

33
import ai.timefold.solver.core.api.score.Score;
44
import ai.timefold.solver.core.api.score.stream.ConstraintProvider;

tools/test/src/main/java/ai/timefold/solver/test/api/score/stream/MultiConstraintVerification.java renamed to core/src/main/java/ai/timefold/solver/core/api/score/stream/test/MultiConstraintVerification.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.timefold.solver.test.api.score.stream;
1+
package ai.timefold.solver.core.api.score.stream.test;
22

33
import org.jspecify.annotations.NonNull;
44

tools/test/src/main/java/ai/timefold/solver/test/api/score/stream/ShadowVariableAwareMultiConstraintAssertion.java renamed to core/src/main/java/ai/timefold/solver/core/api/score/stream/test/ShadowVariableAwareMultiConstraintAssertion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.timefold.solver.test.api.score.stream;
1+
package ai.timefold.solver.core.api.score.stream.test;
22

33
public interface ShadowVariableAwareMultiConstraintAssertion extends MultiConstraintAssertion {
44

tools/test/src/main/java/ai/timefold/solver/test/api/score/stream/ShadowVariableAwareSingleConstraintAssertion.java renamed to core/src/main/java/ai/timefold/solver/core/api/score/stream/test/ShadowVariableAwareSingleConstraintAssertion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.timefold.solver.test.api.score.stream;
1+
package ai.timefold.solver.core.api.score.stream.test;
22

33
public interface ShadowVariableAwareSingleConstraintAssertion extends SingleConstraintAssertion {
44

tools/test/src/main/java/ai/timefold/solver/test/api/score/stream/SingleConstraintAssertion.java renamed to core/src/main/java/ai/timefold/solver/core/api/score/stream/test/SingleConstraintAssertion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.timefold.solver.test.api.score.stream;
1+
package ai.timefold.solver.core.api.score.stream.test;
22

33
import java.math.BigDecimal;
44

tools/test/src/main/java/ai/timefold/solver/test/api/score/stream/SingleConstraintVerification.java renamed to core/src/main/java/ai/timefold/solver/core/api/score/stream/test/SingleConstraintVerification.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.timefold.solver.test.api.score.stream;
1+
package ai.timefold.solver.core.api.score.stream.test;
22

33
import ai.timefold.solver.core.api.domain.variable.InverseRelationShadowVariable;
44
import ai.timefold.solver.core.api.domain.variable.PlanningListVariable;

tools/test/src/main/java/ai/timefold/solver/test/api/solver/change/MockProblemChangeDirector.java renamed to core/src/main/java/ai/timefold/solver/core/api/solver/change/MockProblemChangeDirector.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
package ai.timefold.solver.test.api.solver.change;
1+
package ai.timefold.solver.core.api.solver.change;
22

33
import java.util.IdentityHashMap;
44
import java.util.Map;
55
import java.util.function.Consumer;
66

7-
import ai.timefold.solver.core.api.solver.change.ProblemChangeDirector;
8-
9-
import org.jspecify.annotations.NonNull;
7+
import org.jspecify.annotations.NullMarked;
108
import org.jspecify.annotations.Nullable;
119

1210
/**
13-
* Use for unit-testing {@link ai.timefold.solver.core.api.solver.change.ProblemChange}s.
14-
*
11+
* Use for unit-testing {@link ProblemChange}s.
1512
* Together with Mockito this class makes it possible to verify that a
16-
* {@link ai.timefold.solver.core.api.solver.change.ProblemChange} implementation correctly calls methods of
13+
* {@link ProblemChange} implementation correctly calls methods of
1714
* the {@link ProblemChangeDirector}.
18-
*
15+
* <p>
1916
* Example of usage:
2017
*
2118
* <pre>
@@ -27,41 +24,39 @@
2724
* }
2825
* </pre>
2926
*/
27+
@NullMarked
3028
public class MockProblemChangeDirector implements ProblemChangeDirector {
3129

3230
private Map<Object, Object> lookUpTable = new IdentityHashMap<>();
3331

3432
@Override
35-
public <Entity> void addEntity(@NonNull Entity entity, @NonNull Consumer<Entity> entityConsumer) {
33+
public <Entity> void addEntity(Entity entity, Consumer<Entity> entityConsumer) {
3634
entityConsumer.accept(this.lookUpWorkingObject(entity));
3735
}
3836

3937
@Override
40-
public <Entity> void removeEntity(@NonNull Entity entity, Consumer<Entity> entityConsumer) {
38+
public <Entity> void removeEntity(Entity entity, Consumer<Entity> entityConsumer) {
4139
entityConsumer.accept(this.lookUpWorkingObject(entity));
4240
}
4341

4442
@Override
45-
public <Entity> void changeVariable(@NonNull Entity entity, @NonNull String variableName,
46-
@NonNull Consumer<Entity> entityConsumer) {
43+
public <Entity> void changeVariable(Entity entity, String variableName, Consumer<Entity> entityConsumer) {
4744
entityConsumer.accept(this.lookUpWorkingObject(entity));
4845
}
4946

5047
@Override
51-
public <ProblemFact> void addProblemFact(@NonNull ProblemFact problemFact,
52-
@NonNull Consumer<ProblemFact> problemFactConsumer) {
48+
public <ProblemFact> void addProblemFact(ProblemFact problemFact, Consumer<ProblemFact> problemFactConsumer) {
5349
problemFactConsumer.accept(this.lookUpWorkingObject(problemFact));
5450
}
5551

5652
@Override
57-
public <ProblemFact> void removeProblemFact(@NonNull ProblemFact problemFact,
58-
@NonNull Consumer<ProblemFact> problemFactConsumer) {
53+
public <ProblemFact> void removeProblemFact(ProblemFact problemFact, Consumer<ProblemFact> problemFactConsumer) {
5954
problemFactConsumer.accept(this.lookUpWorkingObject(problemFact));
6055
}
6156

6257
@Override
63-
public <EntityOrProblemFact> void changeProblemProperty(@NonNull EntityOrProblemFact problemFactOrEntity,
64-
@NonNull Consumer<EntityOrProblemFact> problemFactOrEntityConsumer) {
58+
public <EntityOrProblemFact> void changeProblemProperty(EntityOrProblemFact problemFactOrEntity,
59+
Consumer<EntityOrProblemFact> problemFactOrEntityConsumer) {
6560
problemFactOrEntityConsumer.accept(this.lookUpWorkingObject(problemFactOrEntity));
6661
}
6762

@@ -86,7 +81,7 @@ public void updateShadowVariables() {
8681
/**
8782
* Defines what {@link #lookUpWorkingObject(Object)} returns.
8883
*/
89-
public @NonNull LookUpMockBuilder whenLookingUp(Object forObject) {
84+
public LookUpMockBuilder whenLookingUp(Object forObject) {
9085
return new LookUpMockBuilder(forObject);
9186
}
9287

0 commit comments

Comments
 (0)