17
17
18
18
import ai .timefold .solver .core .api .function .QuadConsumer ;
19
19
import ai .timefold .solver .core .api .score .buildin .hardsoft .HardSoftScore ;
20
- import ai .timefold .solver .core .api .score .buildin .simple .SimpleScore ;
21
- import ai .timefold .solver .core .impl .domain .entity .descriptor .EntityDescriptor ;
22
- import ai .timefold .solver .core .impl .domain .solution .descriptor .SolutionDescriptor ;
23
20
import ai .timefold .solver .core .impl .domain .variable .declarative .DefaultTopologicalOrderGraph ;
24
21
import ai .timefold .solver .core .impl .domain .variable .declarative .EntityVariablePair ;
25
22
import ai .timefold .solver .core .impl .domain .variable .declarative .TopologicalOrderGraph ;
26
23
import ai .timefold .solver .core .impl .domain .variable .descriptor .VariableDescriptor ;
27
24
import ai .timefold .solver .core .impl .domain .variable .inverserelation .ExternalizedSingletonInverseVariableSupply ;
28
25
import ai .timefold .solver .core .impl .domain .variable .inverserelation .SingletonInverseVariableDemand ;
29
26
import ai .timefold .solver .core .impl .domain .variable .inverserelation .SingletonInverseVariableListener ;
30
- import ai .timefold .solver .core .impl .domain .variable .inverserelation .SingletonInverseVariableSupply ;
31
27
import ai .timefold .solver .core .impl .domain .variable .supply .SupplyManager ;
32
28
import ai .timefold .solver .core .impl .score .director .InnerScoreDirector ;
33
29
import ai .timefold .solver .core .impl .testdata .domain .TestdataEntity ;
40
36
import ai .timefold .solver .core .impl .testdata .domain .declarative .concurrent .TestdataConcurrentSolution ;
41
37
import ai .timefold .solver .core .impl .testdata .domain .declarative .concurrent .TestdataConcurrentValue ;
42
38
import ai .timefold .solver .core .impl .testdata .domain .shadow .order .TestdataShadowVariableOrderEntity ;
43
- import ai .timefold .solver .core .impl .testdata .domain .shadow .order .TestdataShadowVariableOrderSolution ;
44
39
import ai .timefold .solver .core .preview .api .domain .metamodel .VariableMetaModel ;
45
40
46
41
import org .junit .jupiter .api .Test ;
@@ -49,33 +44,32 @@ class VariableListenerSupportTest {
49
44
50
45
@ Test
51
46
void demandBasic () {
52
- SolutionDescriptor < TestdataSolution > solutionDescriptor = TestdataSolution .buildSolutionDescriptor ();
53
- InnerScoreDirector < TestdataSolution , SimpleScore > scoreDirector = mock (InnerScoreDirector .class );
47
+ var solutionDescriptor = TestdataSolution .buildSolutionDescriptor ();
48
+ var scoreDirector = mock (InnerScoreDirector .class );
54
49
when (scoreDirector .getSolutionDescriptor ()).thenReturn (solutionDescriptor );
55
- TestdataSolution solution = new TestdataSolution ();
50
+ var solution = new TestdataSolution ();
56
51
solution .setEntityList (Collections .emptyList ());
57
52
when (scoreDirector .getWorkingSolution ()).thenReturn (solution );
58
53
when (scoreDirector .getSupplyManager ()).thenReturn (mock (SupplyManager .class ));
59
54
VariableListenerSupport <TestdataSolution > variableListenerSupport = VariableListenerSupport .create (scoreDirector );
60
55
variableListenerSupport .linkVariableListeners ();
61
56
62
- VariableDescriptor <TestdataSolution > variableDescriptor =
63
- solutionDescriptor .getEntityDescriptorStrict (TestdataEntity .class )
64
- .getVariableDescriptor ("value" );
57
+ var variableDescriptor = solutionDescriptor .getEntityDescriptorStrict (TestdataEntity .class )
58
+ .getVariableDescriptor ("value" );
65
59
66
- SingletonInverseVariableSupply supply1 = variableListenerSupport
60
+ var supply1 = variableListenerSupport
67
61
.demand (new SingletonInverseVariableDemand <>(variableDescriptor ));
68
- SingletonInverseVariableSupply supply2 = variableListenerSupport
62
+ var supply2 = variableListenerSupport
69
63
.demand (new SingletonInverseVariableDemand <>(variableDescriptor ));
70
64
assertThat (supply2 ).isSameAs (supply1 );
71
65
}
72
66
73
67
@ Test
74
68
void demandChained () {
75
- SolutionDescriptor < TestdataChainedSolution > solutionDescriptor = TestdataChainedSolution .buildSolutionDescriptor ();
76
- InnerScoreDirector < TestdataChainedSolution , SimpleScore > scoreDirector = mock (InnerScoreDirector .class );
69
+ var solutionDescriptor = TestdataChainedSolution .buildSolutionDescriptor ();
70
+ var scoreDirector = mock (InnerScoreDirector .class );
77
71
when (scoreDirector .getSolutionDescriptor ()).thenReturn (solutionDescriptor );
78
- TestdataChainedSolution solution = new TestdataChainedSolution ();
72
+ var solution = new TestdataChainedSolution ();
79
73
solution .setChainedEntityList (Collections .emptyList ());
80
74
when (scoreDirector .getWorkingSolution ()).thenReturn (solution );
81
75
when (scoreDirector .getSupplyManager ()).thenReturn (mock (SupplyManager .class ));
@@ -87,55 +81,48 @@ void demandChained() {
87
81
solutionDescriptor .getEntityDescriptorStrict (TestdataChainedEntity .class )
88
82
.getVariableDescriptor ("chainedObject" );
89
83
90
- SingletonInverseVariableSupply supply1 = variableListenerSupport
84
+ var supply1 = variableListenerSupport
91
85
.demand (new SingletonInverseVariableDemand <>(variableDescriptor ));
92
86
assertThat (supply1 )
93
87
.isInstanceOf (ExternalizedSingletonInverseVariableSupply .class );
94
- SingletonInverseVariableSupply supply2 = variableListenerSupport
88
+ var supply2 = variableListenerSupport
95
89
.demand (new SingletonInverseVariableDemand <>(variableDescriptor ));
96
90
assertThat (supply2 ).isSameAs (supply1 );
97
91
}
98
92
99
93
@ Test
100
94
void demandRichChained () {
101
- SolutionDescriptor <TestdataShadowingChainedSolution > solutionDescriptor =
102
- TestdataShadowingChainedSolution .buildSolutionDescriptor ();
103
- InnerScoreDirector <TestdataShadowingChainedSolution , SimpleScore > scoreDirector =
104
- mock (InnerScoreDirector .class );
95
+ var solutionDescriptor = TestdataShadowingChainedSolution .buildSolutionDescriptor ();
96
+ var scoreDirector = mock (InnerScoreDirector .class );
105
97
when (scoreDirector .getSolutionDescriptor ()).thenReturn (solutionDescriptor );
106
- TestdataShadowingChainedSolution solution = new TestdataShadowingChainedSolution ();
98
+ var solution = new TestdataShadowingChainedSolution ();
107
99
solution .setChainedEntityList (Collections .emptyList ());
108
100
when (scoreDirector .getWorkingSolution ()).thenReturn (solution );
109
101
when (scoreDirector .getSupplyManager ()).thenReturn (mock (SupplyManager .class ));
110
- VariableListenerSupport <TestdataShadowingChainedSolution > variableListenerSupport =
111
- VariableListenerSupport .create (scoreDirector );
102
+ var variableListenerSupport = VariableListenerSupport .create (scoreDirector );
112
103
variableListenerSupport .linkVariableListeners ();
113
104
114
- VariableDescriptor < TestdataShadowingChainedSolution > variableDescriptor = solutionDescriptor
105
+ var variableDescriptor = solutionDescriptor
115
106
.getEntityDescriptorStrict (TestdataShadowingChainedEntity .class )
116
107
.getVariableDescriptor ("chainedObject" );
117
108
118
- SingletonInverseVariableSupply supply1 = variableListenerSupport
119
- .demand (new SingletonInverseVariableDemand <>(variableDescriptor ));
109
+ var supply1 = variableListenerSupport .demand (new SingletonInverseVariableDemand <>(variableDescriptor ));
120
110
assertThat (supply1 )
121
111
.isInstanceOf (SingletonInverseVariableListener .class );
122
- SingletonInverseVariableSupply supply2 = variableListenerSupport
123
- .demand (new SingletonInverseVariableDemand <>(variableDescriptor ));
112
+ var supply2 = variableListenerSupport .demand (new SingletonInverseVariableDemand <>(variableDescriptor ));
124
113
assertThat (supply2 ).isSameAs (supply1 );
125
114
}
126
115
127
116
@ Test
128
117
void shadowVariableListenerOrder () {
129
- EntityDescriptor <TestdataShadowVariableOrderSolution > entityDescriptor =
130
- TestdataShadowVariableOrderEntity .buildEntityDescriptor ();
131
- SolutionDescriptor <TestdataShadowVariableOrderSolution > solutionDescriptor = entityDescriptor .getSolutionDescriptor ();
132
- InnerScoreDirector <TestdataShadowVariableOrderSolution , SimpleScore > scoreDirector = mock (InnerScoreDirector .class );
118
+ var entityDescriptor = TestdataShadowVariableOrderEntity .buildEntityDescriptor ();
119
+ var solutionDescriptor = entityDescriptor .getSolutionDescriptor ();
120
+ var scoreDirector = mock (InnerScoreDirector .class );
133
121
when (scoreDirector .getSolutionDescriptor ()).thenReturn (solutionDescriptor );
134
122
when (scoreDirector .getSolutionDescriptor ()).thenReturn (solutionDescriptor );
135
123
136
- NotifiableRegistry <TestdataShadowVariableOrderSolution > registry = new NotifiableRegistry <>(solutionDescriptor );
137
- VariableListenerSupport <TestdataShadowVariableOrderSolution > variableListenerSupport =
138
- new VariableListenerSupport <>(scoreDirector , registry , DefaultTopologicalOrderGraph ::new );
124
+ var registry = new NotifiableRegistry <>(solutionDescriptor );
125
+ var variableListenerSupport = new VariableListenerSupport <>(scoreDirector , registry , DefaultTopologicalOrderGraph ::new );
139
126
140
127
variableListenerSupport .linkVariableListeners ();
141
128
0 commit comments