1
1
package ai .timefold .solver .core .impl .constructionheuristic ;
2
2
3
- import static ai .timefold .solver .core .config .solver .PreviewFeature .DECLARATIVE_SHADOW_VARIABLES ;
4
- import static ai .timefold .solver .core .testutil .PlannerAssert .assertCode ;
5
- import static org .assertj .core .api .Assertions .assertThat ;
6
- import static org .assertj .core .api .Assertions .assertThatCode ;
7
- import static org .assertj .core .api .Assertions .assertThatThrownBy ;
8
- import static org .assertj .core .api .SoftAssertions .assertSoftly ;
9
-
10
- import java .util .ArrayList ;
11
- import java .util .Arrays ;
12
- import java .util .Collections ;
13
- import java .util .List ;
14
- import java .util .concurrent .atomic .AtomicLong ;
15
-
16
3
import ai .timefold .solver .core .api .score .buildin .simple .SimpleScore ;
17
4
import ai .timefold .solver .core .api .solver .Solver ;
18
5
import ai .timefold .solver .core .api .solver .SolverFactory ;
53
40
import ai .timefold .solver .core .testdomain .valuerange .entityproviding .unassignedvar .TestdataAllowsUnassignedEntityProvidingSolution ;
54
41
import ai .timefold .solver .core .testutil .AbstractMeterTest ;
55
42
import ai .timefold .solver .core .testutil .PlannerTestUtils ;
56
-
43
+ import io . micrometer . core . instrument . Metrics ;
57
44
import org .junit .jupiter .api .Test ;
58
45
59
- import io .micrometer .core .instrument .Metrics ;
46
+ import java .util .ArrayList ;
47
+ import java .util .Arrays ;
48
+ import java .util .Collections ;
49
+ import java .util .List ;
50
+ import java .util .concurrent .atomic .AtomicLong ;
51
+
52
+ import static ai .timefold .solver .core .config .solver .PreviewFeature .DECLARATIVE_SHADOW_VARIABLES ;
53
+ import static ai .timefold .solver .core .testutil .PlannerAssert .assertCode ;
54
+ import static org .assertj .core .api .Assertions .assertThat ;
55
+ import static org .assertj .core .api .Assertions .assertThatCode ;
56
+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
57
+ import static org .assertj .core .api .SoftAssertions .assertSoftly ;
60
58
61
59
class DefaultConstructionHeuristicPhaseTest extends AbstractMeterTest {
62
60
@@ -365,7 +363,8 @@ void solveWithEntityValueRangeBasicVariable() {
365
363
@ Test
366
364
void solveWithEntityValueRangeListVariable () {
367
365
var solverConfig = PlannerTestUtils
368
- .buildSolverConfig (TestdataListEntityProvidingSolution .class , TestdataListEntityProvidingEntity .class )
366
+ .buildSolverConfig (TestdataListEntityProvidingSolution .class , TestdataListEntityProvidingEntity .class ,
367
+ TestdataListEntityProvidingValue .class )
369
368
.withEasyScoreCalculatorClass (TestdataListEntityProvidingScoreCalculator .class )
370
369
.withPhases (new ConstructionHeuristicPhaseConfig ());
371
370
@@ -381,8 +380,10 @@ void solveWithEntityValueRangeListVariable() {
381
380
var bestSolution = PlannerTestUtils .solve (solverConfig , solution , true );
382
381
assertThat (bestSolution ).isNotNull ();
383
382
// Only one entity should provide the value list and assign the values.
384
- assertThat (bestSolution .getEntityList ().get (0 ).getValueList ()).hasSameElementsAs (List .of (value1 , value2 ));
385
- assertThat (bestSolution .getEntityList ().get (1 ).getValueList ()).hasSameElementsAs (List .of (value3 ));
383
+ assertThat (bestSolution .getEntityList ().get (0 ).getValueList ().stream ().map (TestdataListEntityProvidingValue ::getCode ))
384
+ .hasSameElementsAs (List .of ("v1" , "v2" ));
385
+ assertThat (bestSolution .getEntityList ().get (1 ).getValueList ().stream ().map (TestdataListEntityProvidingValue ::getCode ))
386
+ .hasSameElementsAs (List .of ("v3" ));
386
387
}
387
388
388
389
@ Test
0 commit comments