@@ -262,32 +262,26 @@ public void celEnvironment_runtime_disabledFeatures_throwsException() throws Exc
262262 // String concatenation fails at runtime evaluation (missing overload)
263263 CelAbstractSyntaxTree stringConcatAst = compileLenientAst ("'a' + 'b'" );
264264 CelRuntime .Program stringConcatProgram = CelCommon .RUNTIME .createProgram (stringConcatAst );
265- try {
266- stringConcatProgram .eval (resolver );
267- Assert .fail ("String concatenation evaluation should fail" );
268- } catch (CelEvaluationException e ) {
269- assertThat (e ).hasMessageThat ().contains ("No matching overload" );
270- }
265+ Assert .assertThrows (
266+ "String concatenation evaluation should fail" ,
267+ CelEvaluationException .class ,
268+ () -> stringConcatProgram .eval (resolver ));
271269
272- // List concatenation fails at runtime evaluation (missing overload)
270+ // List concatenation fails at runtime evaluation
273271 CelAbstractSyntaxTree listConcatAst = compileLenientAst ("[1] + [2]" );
274272 CelRuntime .Program listConcatProgram = CelCommon .RUNTIME .createProgram (listConcatAst );
275- try {
276- listConcatProgram .eval (resolver );
277- Assert .fail ("List concatenation evaluation should fail" );
278- } catch (CelEvaluationException e ) {
279- assertThat (e ).hasMessageThat ().contains ("No matching overload" );
280- }
273+ Assert .assertThrows (
274+ "List concatenation evaluation should fail" ,
275+ CelEvaluationException .class ,
276+ () -> listConcatProgram .eval (resolver ));
281277
282- // String conversion fails at runtime evaluation (missing overload/function)
278+ // String conversion fails at runtime evaluation
283279 CelAbstractSyntaxTree stringConvAst = compileLenientAst ("string(1)" );
284280 CelRuntime .Program stringConvProgram = CelCommon .RUNTIME .createProgram (stringConvAst );
285- try {
286- stringConvProgram .eval (resolver );
287- Assert .fail ("String conversion evaluation should fail" );
288- } catch (CelEvaluationException e ) {
289- assertThat (e ).hasMessageThat ().contains ("No matching overload" );
290- }
281+ Assert .assertThrows (
282+ "String conversion evaluation should fail" ,
283+ CelEvaluationException .class ,
284+ () -> stringConvProgram .eval (resolver ));
291285 }
292286
293287 @ Test
0 commit comments