Skip to content

Commit bc16ba3

Browse files
committed
chore: improve tests for Spring
1 parent e90121f commit bc16ba3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

spring-integration/spring-boot-integration-test/src/main/java/ai/timefold/solver/spring/boot/it/domain/IntegrationTestEntity.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import ai.timefold.solver.core.api.domain.lookup.PlanningId;
77
import ai.timefold.solver.core.api.domain.valuerange.ValueRangeProvider;
88
import ai.timefold.solver.core.api.domain.variable.PlanningVariable;
9+
import ai.timefold.solver.core.api.domain.variable.ShadowSources;
10+
import ai.timefold.solver.core.api.domain.variable.ShadowVariable;
911

1012
@PlanningEntity
1113
public class IntegrationTestEntity {
@@ -17,6 +19,12 @@ public class IntegrationTestEntity {
1719

1820
private List<IntegrationTestValue> valueList;
1921

22+
@ShadowVariable(supplierName = "processShadowVarWithParam")
23+
private Integer shadowVarWithParam;
24+
25+
@ShadowVariable(supplierName = "processShadowVarWithoutParam")
26+
private Integer shadowVarWithoutParam;
27+
2028
public IntegrationTestEntity() {
2129
}
2230

@@ -53,4 +61,17 @@ public void setValueList(List<IntegrationTestValue> valueList) {
5361
public List<IntegrationTestValue> getValueRangeWithParameter(IntegrationTestSolution solution) {
5462
return solution.getValueList();
5563
}
64+
65+
@ShadowSources("value")
66+
public int processShadowVarWithParam(IntegrationTestSolution solution) {
67+
if (solution == null) {
68+
throw new NullPointerException("solution is null");
69+
}
70+
return solution.getDummyShadowValue();
71+
}
72+
73+
@ShadowSources("value")
74+
public int processShadowVarWithoutParam() {
75+
return -1;
76+
}
5677
}

spring-integration/spring-boot-integration-test/src/main/java/ai/timefold/solver/spring/boot/it/domain/IntegrationTestSolution.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public void setValueList(List<IntegrationTestValue> valueList) {
4141
this.valueList = valueList;
4242
}
4343

44+
public int getDummyShadowValue() {
45+
return 10;
46+
}
47+
4448
public SimpleScore getScore() {
4549
return score;
4650
}

0 commit comments

Comments
 (0)