@@ -398,8 +398,11 @@ public void testStatsWithoutGroupKeyMixedAggAndFilter() {
398398 public void testInlineStatsWithGroups () {
399399 var query = "inlinestats b = min(a) by c, d.e" ;
400400 if (Build .current ().isSnapshot () == false ) {
401- var e = expectThrows (ParsingException .class , () -> processingCommand (query ));
402- assertThat (e .getMessage (), containsString ("line 1:13: mismatched input 'inlinestats' expecting {" ));
401+ expectThrows (
402+ ParsingException .class ,
403+ containsString ("line 1:13: mismatched input 'inlinestats' expecting {" ),
404+ () -> processingCommand (query )
405+ );
403406 return ;
404407 }
405408 assertEquals (
@@ -424,8 +427,11 @@ public void testInlineStatsWithGroups() {
424427 public void testInlineStatsWithoutGroups () {
425428 var query = "inlinestats min(a), c = 1" ;
426429 if (Build .current ().isSnapshot () == false ) {
427- var e = expectThrows (ParsingException .class , () -> processingCommand (query ));
428- assertThat (e .getMessage (), containsString ("line 1:13: mismatched input 'inlinestats' expecting {" ));
430+ expectThrows (
431+ ParsingException .class ,
432+ containsString ("line 1:13: mismatched input 'inlinestats' expecting {" ),
433+ () -> processingCommand (query )
434+ );
429435 return ;
430436 }
431437 assertEquals (
@@ -858,16 +864,17 @@ public void testSuggestAvailableSourceCommandsOnParsingError() {
858864 Tuple .tuple ("a/*hi*/" , "a" ),
859865 Tuple .tuple ("explain [ frm a ]" , "frm" )
860866 )) {
861- ParsingException pe = expectThrows (ParsingException .class , () -> statement (queryWithUnexpectedCmd .v1 ()));
862- assertThat (
863- pe .getMessage (),
867+ expectThrows (
868+ ParsingException .class ,
864869 allOf (
865870 containsString ("mismatched input '" + queryWithUnexpectedCmd .v2 () + "'" ),
866871 containsString ("'explain'" ),
867872 containsString ("'from'" ),
868873 containsString ("'row'" )
869- )
874+ ),
875+ () -> statement (queryWithUnexpectedCmd .v1 ())
870876 );
877+
871878 }
872879 }
873880
@@ -882,15 +889,15 @@ public void testSuggestAvailableProcessingCommandsOnParsingError() {
882889 Tuple .tuple ("from a | a/*hi*/" , "a" ),
883890 Tuple .tuple ("explain [ from a | evl b = c ]" , "evl" )
884891 )) {
885- ParsingException pe = expectThrows (ParsingException .class , () -> statement (queryWithUnexpectedCmd .v1 ()));
886- assertThat (
887- pe .getMessage (),
892+ expectThrows (
893+ ParsingException .class ,
888894 allOf (
889895 containsString ("mismatched input '" + queryWithUnexpectedCmd .v2 () + "'" ),
890896 containsString ("'eval'" ),
891897 containsString ("'stats'" ),
892898 containsString ("'where'" )
893- )
899+ ),
900+ () -> statement (queryWithUnexpectedCmd .v1 ())
894901 );
895902 }
896903 }
@@ -981,10 +988,10 @@ public void testGrokPattern() {
981988 assertEquals ("%{WORD:foo}" , grok .parser ().pattern ());
982989 assertEquals (List .of (referenceAttribute ("foo" , KEYWORD )), grok .extractedFields ());
983990
984- ParsingException pe = expectThrows (ParsingException . class , () -> statement ( "row a = \" foo bar \" | grok a \" %{_invalid_:x} \" " ));
985- assertThat (
986- pe . getMessage ( ),
987- containsString ( "Invalid pattern [%{_invalid_:x}] for grok: Unable to find pattern [_invalid_] in Grok's pattern dictionary " )
991+ expectThrows (
992+ ParsingException . class ,
993+ containsString ( "Invalid pattern [%{_invalid_:x}] for grok: Unable to find pattern [_invalid_] in Grok's pattern dictionary" ),
994+ () -> statement ( "row a = \" foo bar \" | grok a \" %{_invalid_:x} \" " )
988995 );
989996
990997 cmd = processingCommand ("grok a \" %{WORD:foo} %{WORD:foo}\" " );
@@ -1110,8 +1117,7 @@ public void testKeepStarMvExpand() {
11101117
11111118 public void testUsageOfProject () {
11121119 String query = "from test | project foo, bar" ;
1113- ParsingException e = expectThrows (ParsingException .class , "Expected syntax error for " + query , () -> statement (query ));
1114- assertThat (e .getMessage (), containsString ("mismatched input 'project' expecting" ));
1120+ expectThrows (ParsingException .class , containsString ("mismatched input 'project' expecting" ), () -> statement (query ));
11151121 }
11161122
11171123 public void testInputParams () {
@@ -2046,8 +2052,7 @@ public void testQuotedName() {
20462052
20472053 private void assertStringAsIndexPattern (String string , String statement ) {
20482054 if (Build .current ().isSnapshot () == false && statement .contains ("METRIC" )) {
2049- var e = expectThrows (ParsingException .class , () -> statement (statement ));
2050- assertThat (e .getMessage (), containsString ("mismatched input 'METRICS' expecting {" ));
2055+ expectThrows (ParsingException .class , containsString ("mismatched input 'METRICS' expecting {" ), () -> statement (statement ));
20512056 return ;
20522057 }
20532058 LogicalPlan from = statement (statement );
@@ -2058,8 +2063,11 @@ private void assertStringAsIndexPattern(String string, String statement) {
20582063
20592064 private void assertStringAsLookupIndexPattern (String string , String statement ) {
20602065 if (Build .current ().isSnapshot () == false ) {
2061- var e = expectThrows (ParsingException .class , () -> statement (statement ));
2062- assertThat (e .getMessage (), containsString ("line 1:14: LOOKUP_🐔 is in preview and only available in SNAPSHOT build" ));
2066+ expectThrows (
2067+ ParsingException .class ,
2068+ containsString ("line 1:14: LOOKUP_🐔 is in preview and only available in SNAPSHOT build" ),
2069+ () -> statement (statement )
2070+ );
20632071 return ;
20642072 }
20652073 var plan = statement (statement );
@@ -2126,8 +2134,11 @@ public void testInlineConvertWithNonexistentType() {
21262134 public void testLookup () {
21272135 String query = "ROW a = 1 | LOOKUP_🐔 t ON j" ;
21282136 if (Build .current ().isSnapshot () == false ) {
2129- var e = expectThrows (ParsingException .class , () -> statement (query ));
2130- assertThat (e .getMessage (), containsString ("line 1:13: mismatched input 'LOOKUP_🐔' expecting {" ));
2137+ expectThrows (
2138+ ParsingException .class ,
2139+ containsString ("line 1:13: mismatched input 'LOOKUP_🐔' expecting {" ),
2140+ () -> statement (query )
2141+ );
21312142 return ;
21322143 }
21332144 var plan = statement (query );
0 commit comments