38
38
import org .springframework .expression .spel .support .StandardEvaluationContext ;
39
39
40
40
import static org .assertj .core .api .Assertions .assertThat ;
41
- import static org .assertj .core .api .InstanceOfAssertFactories .INTEGER ;
42
41
import static org .assertj .core .api .InstanceOfAssertFactories .LIST ;
43
42
import static org .assertj .core .api .InstanceOfAssertFactories .array ;
44
43
import static org .springframework .expression .spel .SpelMessage .INVALID_TYPE_FOR_SELECTION ;
@@ -95,21 +94,21 @@ void selectionAST() {
95
94
void selectionWithList () {
96
95
Expression expression = new SpelExpressionParser ().parseRaw ("integers.?[#this < 5]" );
97
96
EvaluationContext context = new StandardEvaluationContext (new ListTestBean ());
98
- assertThat (expression .getValue (context )). asInstanceOf ( LIST ).containsExactly (0 , 1 , 2 , 3 , 4 );
97
+ assertThat (expression .getValue (context , List . class ) ).containsExactly (0 , 1 , 2 , 3 , 4 );
99
98
}
100
99
101
100
@ Test
102
101
void selectFirstItemInList () {
103
102
Expression expression = new SpelExpressionParser ().parseRaw ("integers.^[#this < 5]" );
104
103
EvaluationContext context = new StandardEvaluationContext (new ListTestBean ());
105
- assertThat (expression .getValue (context )). asInstanceOf ( INTEGER ).isZero ();
104
+ assertThat (expression .getValue (context , Integer . class ) ).isZero ();
106
105
}
107
106
108
107
@ Test
109
108
void selectLastItemInList () {
110
109
Expression expression = new SpelExpressionParser ().parseRaw ("integers.$[#this < 5]" );
111
110
EvaluationContext context = new StandardEvaluationContext (new ListTestBean ());
112
- assertThat (expression .getValue (context )). asInstanceOf ( INTEGER ).isEqualTo (4 );
111
+ assertThat (expression .getValue (context , Integer . class ) ).isEqualTo (4 );
113
112
}
114
113
115
114
@ Test
@@ -124,21 +123,21 @@ void selectionWithSetAndRegex() {
124
123
void selectionWithSet () {
125
124
Expression expression = new SpelExpressionParser ().parseRaw ("integers.?[#this < 5]" );
126
125
EvaluationContext context = new StandardEvaluationContext (new SetTestBean ());
127
- assertThat (expression .getValue (context )). asInstanceOf ( LIST ).containsExactly (0 , 1 , 2 , 3 , 4 );
126
+ assertThat (expression .getValue (context , List . class ) ).containsExactly (0 , 1 , 2 , 3 , 4 );
128
127
}
129
128
130
129
@ Test
131
130
void selectFirstItemInSet () {
132
131
Expression expression = new SpelExpressionParser ().parseRaw ("integers.^[#this < 5]" );
133
132
EvaluationContext context = new StandardEvaluationContext (new SetTestBean ());
134
- assertThat (expression .getValue (context )). asInstanceOf ( INTEGER ).isZero ();
133
+ assertThat (expression .getValue (context , Integer . class ) ).isZero ();
135
134
}
136
135
137
136
@ Test
138
137
void selectLastItemInSet () {
139
138
Expression expression = new SpelExpressionParser ().parseRaw ("integers.$[#this < 5]" );
140
139
EvaluationContext context = new StandardEvaluationContext (new SetTestBean ());
141
- assertThat (expression .getValue (context )). asInstanceOf ( INTEGER ).isEqualTo (4 );
140
+ assertThat (expression .getValue (context , Integer . class ) ).isEqualTo (4 );
142
141
}
143
142
144
143
@ ParameterizedTest
@@ -161,14 +160,14 @@ void selectionWithArray() {
161
160
void selectFirstItemInArray () {
162
161
Expression expression = new SpelExpressionParser ().parseRaw ("integers.^[#this < 5]" );
163
162
EvaluationContext context = new StandardEvaluationContext (new ArrayTestBean ());
164
- assertThat (expression .getValue (context )). asInstanceOf ( INTEGER ).isZero ();
163
+ assertThat (expression .getValue (context , Integer . class ) ).isZero ();
165
164
}
166
165
167
166
@ Test
168
167
void selectLastItemInArray () {
169
168
Expression expression = new SpelExpressionParser ().parseRaw ("integers.$[#this < 5]" );
170
169
EvaluationContext context = new StandardEvaluationContext (new ArrayTestBean ());
171
- assertThat (expression .getValue (context )). asInstanceOf ( INTEGER ).isEqualTo (4 );
170
+ assertThat (expression .getValue (context , Integer . class ) ).isEqualTo (4 );
172
171
}
173
172
174
173
@ Test
@@ -183,14 +182,14 @@ void selectionWithPrimitiveArray() {
183
182
void selectFirstItemInPrimitiveArray () {
184
183
Expression expression = new SpelExpressionParser ().parseRaw ("ints.^[#this < 5]" );
185
184
EvaluationContext context = new StandardEvaluationContext (new ArrayTestBean ());
186
- assertThat (expression .getValue (context )). asInstanceOf ( INTEGER ).isZero ();
185
+ assertThat (expression .getValue (context , Integer . class ) ).isZero ();
187
186
}
188
187
189
188
@ Test
190
189
void selectLastItemInPrimitiveArray () {
191
190
Expression expression = new SpelExpressionParser ().parseRaw ("ints.$[#this < 5]" );
192
191
EvaluationContext context = new StandardEvaluationContext (new ArrayTestBean ());
193
- assertThat (expression .getValue (context )). asInstanceOf ( INTEGER ).isEqualTo (4 );
192
+ assertThat (expression .getValue (context , Integer . class ) ).isEqualTo (4 );
194
193
}
195
194
196
195
@ Test
@@ -254,7 +253,7 @@ void projectionWithList() {
254
253
Expression expression = new SpelExpressionParser ().parseRaw ("#testList.![wrapper.value]" );
255
254
EvaluationContext context = new StandardEvaluationContext ();
256
255
context .setVariable ("testList" , IntegerTestBean .createList ());
257
- assertThat (expression .getValue (context )). asInstanceOf ( LIST ).containsExactly (5 , 6 , 7 );
256
+ assertThat (expression .getValue (context , List . class ) ).containsExactly (5 , 6 , 7 );
258
257
}
259
258
260
259
@ Test
@@ -269,7 +268,7 @@ void projectionWithSet() {
269
268
Expression expression = new SpelExpressionParser ().parseRaw ("#testSet.![wrapper.value]" );
270
269
EvaluationContext context = new StandardEvaluationContext ();
271
270
context .setVariable ("testSet" , IntegerTestBean .createSet ());
272
- assertThat (expression .getValue (context )). asInstanceOf ( LIST ).containsExactly (5 , 6 , 7 );
271
+ assertThat (expression .getValue (context , List . class ) ).containsExactly (5 , 6 , 7 );
273
272
}
274
273
275
274
@ ParameterizedTest
0 commit comments