2323import com .google .testing .junit .testparameterinjector .TestParameters ;
2424import dev .cel .bundle .Cel ;
2525import dev .cel .bundle .CelFactory ;
26+ import dev .cel .common .CelContainer ;
2627import dev .cel .common .CelOptions ;
2728import dev .cel .common .CelValidationException ;
2829import dev .cel .common .types .SimpleType ;
@@ -39,18 +40,18 @@ public class CelListsExtensionsTest {
3940 .setStandardMacros (CelStandardMacro .STANDARD_MACROS )
4041 .addCompilerLibraries (CelExtensions .lists ())
4142 .addRuntimeLibraries (CelExtensions .lists ())
42- .setContainer ("cel.expr.conformance.test" )
43+ .setContainer (CelContainer . ofName ( "cel.expr.conformance.test" ) )
4344 .addMessageTypes (SimpleTest .getDescriptor ())
4445 .addVar ("non_list" , SimpleType .DYN )
4546 .build ();
4647
47- private static final Cel CEL_WITH_HETEROGENOUS_NUMERIC_COMPARISONS =
48+ private static final Cel CEL_WITH_HETEROGENEOUS_NUMERIC_COMPARISONS =
4849 CelFactory .standardCelBuilder ()
4950 .setOptions (CelOptions .current ().enableHeterogeneousNumericComparisons (true ).build ())
5051 .setStandardMacros (CelStandardMacro .STANDARD_MACROS )
5152 .addCompilerLibraries (CelExtensions .lists ())
5253 .addRuntimeLibraries (CelExtensions .lists ())
53- .setContainer ("cel.expr.conformance.test" )
54+ .setContainer (CelContainer . ofName ( "cel.expr.conformance.test" ) )
5455 .addMessageTypes (SimpleTest .getDescriptor ())
5556 .build ();
5657
@@ -87,8 +88,9 @@ public void macroList_byVersion() {
8788 @ TestParameters ("{expression: '[1,2,3,4].slice(1, 3)', expected: '[2, 3]'}" )
8889 @ TestParameters ("{expression: 'non_list.slice(1, 3)', expected: '[2, 3]'}" )
8990 public void slice_success (String expression , String expected ) throws Exception {
90- Object result = CEL .createProgram (CEL .compile (expression ).getAst ()).eval (
91- ImmutableMap .of ("non_list" , ImmutableSortedSet .of (4L , 1L , 3L , 2L )));
91+ Object result =
92+ CEL .createProgram (CEL .compile (expression ).getAst ())
93+ .eval (ImmutableMap .of ("non_list" , ImmutableSortedSet .of (4L , 1L , 3L , 2L )));
9294
9395 assertThat (result ).isEqualTo (expectedResult (expected ));
9496 }
@@ -106,9 +108,9 @@ public void slice_success(String expression, String expected) throws Exception {
106108 + "expectedError: 'Negative indexes not supported'}" )
107109 public void slice_throws (String expression , String expectedError ) throws Exception {
108110 assertThat (
109- assertThrows (
110- CelEvaluationException .class ,
111- () -> CEL .createProgram (CEL .compile (expression ).getAst ()).eval ()))
111+ assertThrows (
112+ CelEvaluationException .class ,
113+ () -> CEL .createProgram (CEL .compile (expression ).getAst ()).eval ()))
112114 .hasCauseThat ()
113115 .hasMessageThat ()
114116 .contains (expectedError );
@@ -183,8 +185,7 @@ public void range_success(String expression) throws Exception {
183185 @ TestParameters ("{expression: '[].distinct()', expected: '[]'}" )
184186 @ TestParameters ("{expression: '[].distinct()', expected: '[]'}" )
185187 @ TestParameters ("{expression: '[1].distinct()', expected: '[1]'}" )
186- @ TestParameters (
187- "{expression: '[-2, 5, -2, 1, 1, 5, -2, 1].distinct()', expected: '[-2, 5, 1]'}" )
188+ @ TestParameters ("{expression: '[-2, 5, -2, 1, 1, 5, -2, 1].distinct()', expected: '[-2, 5, 1]'}" )
188189 @ TestParameters (
189190 "{expression: '[-2, 5, -2, 1, 1, 5, -2, 1, 5, -2, -2, 1].distinct()', "
190191 + "expected: '[-2, 5, 1]'}" )
@@ -202,8 +203,11 @@ public void range_success(String expression) throws Exception {
202203 + "expected: '[SimpleTest{name: \" a\" }, SimpleTest{name: \" b\" }]'}" )
203204 @ TestParameters ("{expression: 'non_list.distinct()', expected: '[1, 2, 3, 4]'}" )
204205 public void distinct_success (String expression , String expected ) throws Exception {
205- Object result = CEL .createProgram (CEL .compile (expression ).getAst ()).eval (
206- ImmutableMap .of ("non_list" , ImmutableSortedMultiset .of (1L , 2L , 3L , 4L , 4L , 1L , 3L , 2L )));
206+ Object result =
207+ CEL .createProgram (CEL .compile (expression ).getAst ())
208+ .eval (
209+ ImmutableMap .of (
210+ "non_list" , ImmutableSortedMultiset .of (1L , 2L , 3L , 4L , 4L , 1L , 3L , 2L )));
207211
208212 assertThat (result ).isEqualTo (expectedResult (expected ));
209213 }
@@ -219,8 +223,9 @@ public void distinct_success(String expression, String expected) throws Exceptio
219223 "{expression: '[false, true, true].reverse().reverse()', expected: '[false, true, true]'}" )
220224 @ TestParameters ("{expression: 'non_list.reverse()', expected: '[4, 3, 2, 1]'}" )
221225 public void reverse_success (String expression , String expected ) throws Exception {
222- Object result = CEL .createProgram (CEL .compile (expression ).getAst ()).eval (
223- ImmutableMap .of ("non_list" , ImmutableSortedSet .of (4L , 1L , 3L , 2L )));
226+ Object result =
227+ CEL .createProgram (CEL .compile (expression ).getAst ())
228+ .eval (ImmutableMap .of ("non_list" , ImmutableSortedSet .of (4L , 1L , 3L , 2L )));
224229
225230 assertThat (result ).isEqualTo (expectedResult (expected ));
226231 }
@@ -243,8 +248,10 @@ public void sort_success(String expression, String expected) throws Exception {
243248 @ TestParameters ("{expression: '[4, 3, 2, 1].sort()', expected: '[1, 2, 3, 4]'}" )
244249 public void sort_success_heterogeneousNumbers (String expression , String expected )
245250 throws Exception {
246- Object result = CEL_WITH_HETEROGENOUS_NUMERIC_COMPARISONS .createProgram (
247- CEL_WITH_HETEROGENOUS_NUMERIC_COMPARISONS .compile (expression ).getAst ()).eval ();
251+ Object result =
252+ CEL_WITH_HETEROGENEOUS_NUMERIC_COMPARISONS
253+ .createProgram (CEL_WITH_HETEROGENEOUS_NUMERIC_COMPARISONS .compile (expression ).getAst ())
254+ .eval ();
248255
249256 assertThat (result ).isEqualTo (expectedResult (expected ));
250257 }
@@ -261,9 +268,9 @@ public void sort_success_heterogeneousNumbers(String expression, String expected
261268 + "expectedError: 'List elements must be comparable'}" )
262269 public void sort_throws (String expression , String expectedError ) throws Exception {
263270 assertThat (
264- assertThrows (
265- CelEvaluationException .class ,
266- () -> CEL .createProgram (CEL .compile (expression ).getAst ()).eval ()))
271+ assertThrows (
272+ CelEvaluationException .class ,
273+ () -> CEL .createProgram (CEL .compile (expression ).getAst ()).eval ()))
267274 .hasCauseThat ()
268275 .hasMessageThat ()
269276 .contains (expectedError );
@@ -273,14 +280,11 @@ public void sort_throws(String expression, String expectedError) throws Exceptio
273280 @ TestParameters ("{expression: '[].sortBy(e, e)', expected: '[]'}" )
274281 @ TestParameters ("{expression: '[\" a\" ].sortBy(e, e)', expected: '[\" a\" ]'}" )
275282 @ TestParameters (
276- "{expression: '[-3, 1, -5, -2, 4].sortBy(e, -(e * e))', "
277- + "expected: '[-5, 4, -3, -2, 1]'}" )
283+ "{expression: '[-3, 1, -5, -2, 4].sortBy(e, -(e * e))', " + "expected: '[-5, 4, -3, -2, 1]'}" )
278284 @ TestParameters (
279285 "{expression: '[-3, 1, -5, -2, 4].map(e, e * 2).sortBy(e, -(e * e)) ', "
280286 + "expected: '[-10, 8, -6, -4, 2]'}" )
281- @ TestParameters (
282- "{expression: 'lists.range(3).sortBy(e, -e) ', "
283- + "expected: '[2, 1, 0]'}" )
287+ @ TestParameters ("{expression: 'lists.range(3).sortBy(e, -e) ', " + "expected: '[2, 1, 0]'}" )
284288 @ TestParameters (
285289 "{expression: '[\" a\" , \" c\" , \" b\" , \" first\" ].sortBy(e, e == \" first\" ? \" \" : e)', "
286290 + "expected: '[\" first\" , \" a\" , \" b\" , \" c\" ]'}" )
@@ -307,9 +311,9 @@ public void sortBy_success(String expression, String expected) throws Exception
307311 public void sortBy_throws_validationException (String expression , String expectedError )
308312 throws Exception {
309313 assertThat (
310- assertThrows (
311- CelValidationException .class ,
312- () -> CEL .createProgram (CEL .compile (expression ).getAst ()).eval ()))
314+ assertThrows (
315+ CelValidationException .class ,
316+ () -> CEL .createProgram (CEL .compile (expression ).getAst ()).eval ()))
313317 .hasMessageThat ()
314318 .contains (expectedError );
315319 }
@@ -324,9 +328,9 @@ public void sortBy_throws_validationException(String expression, String expected
324328 public void sortBy_throws_evaluationException (String expression , String expectedError )
325329 throws Exception {
326330 assertThat (
327- assertThrows (
328- CelEvaluationException .class ,
329- () -> CEL .createProgram (CEL .compile (expression ).getAst ()).eval ()))
331+ assertThrows (
332+ CelEvaluationException .class ,
333+ () -> CEL .createProgram (CEL .compile (expression ).getAst ()).eval ()))
330334 .hasCauseThat ()
331335 .hasMessageThat ()
332336 .contains (expectedError );
@@ -336,4 +340,4 @@ private static Object expectedResult(String expression)
336340 throws CelEvaluationException , CelValidationException {
337341 return CEL .createProgram (CEL .compile (expression ).getAst ()).eval ();
338342 }
339- }
343+ }
0 commit comments