@@ -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 (
@@ -861,16 +867,17 @@ public void testSuggestAvailableSourceCommandsOnParsingError() {
861867 Tuple .tuple ("a/*hi*/" , "a" ),
862868 Tuple .tuple ("explain [ frm a ]" , "frm" )
863869 )) {
864- ParsingException pe = expectThrows (ParsingException .class , () -> statement (queryWithUnexpectedCmd .v1 ()));
865- assertThat (
866- pe .getMessage (),
870+ expectThrows (
871+ ParsingException .class ,
867872 allOf (
868873 containsString ("mismatched input '" + queryWithUnexpectedCmd .v2 () + "'" ),
869874 containsString ("'explain'" ),
870875 containsString ("'from'" ),
871876 containsString ("'row'" )
872- )
877+ ),
878+ () -> statement (queryWithUnexpectedCmd .v1 ())
873879 );
880+
874881 }
875882 }
876883
@@ -885,15 +892,15 @@ public void testSuggestAvailableProcessingCommandsOnParsingError() {
885892 Tuple .tuple ("from a | a/*hi*/" , "a" ),
886893 Tuple .tuple ("explain [ from a | evl b = c ]" , "evl" )
887894 )) {
888- ParsingException pe = expectThrows (ParsingException .class , () -> statement (queryWithUnexpectedCmd .v1 ()));
889- assertThat (
890- pe .getMessage (),
895+ expectThrows (
896+ ParsingException .class ,
891897 allOf (
892898 containsString ("mismatched input '" + queryWithUnexpectedCmd .v2 () + "'" ),
893899 containsString ("'eval'" ),
894900 containsString ("'stats'" ),
895901 containsString ("'where'" )
896- )
902+ ),
903+ () -> statement (queryWithUnexpectedCmd .v1 ())
897904 );
898905 }
899906 }
@@ -987,10 +994,10 @@ public void testGrokPattern() {
987994 assertEquals ("%{WORD:foo}" , grok .parser ().pattern ());
988995 assertEquals (List .of (referenceAttribute ("foo" , KEYWORD )), grok .extractedFields ());
989996
990- ParsingException pe = expectThrows (ParsingException . class , () -> statement ( "row a = \" foo bar \" | grok a \" %{_invalid_:x} \" " ));
991- assertThat (
992- pe . getMessage ( ),
993- containsString ( "Invalid pattern [%{_invalid_:x}] for grok: Unable to find pattern [_invalid_] in Grok's pattern dictionary " )
997+ expectThrows (
998+ ParsingException . class ,
999+ containsString ( "Invalid pattern [%{_invalid_:x}] for grok: Unable to find pattern [_invalid_] in Grok's pattern dictionary" ),
1000+ () -> statement ( "row a = \" foo bar \" | grok a \" %{_invalid_:x} \" " )
9941001 );
9951002
9961003 cmd = processingCommand ("grok a \" %{WORD:foo} %{WORD:foo}\" " );
@@ -1116,8 +1123,7 @@ public void testKeepStarMvExpand() {
11161123
11171124 public void testUsageOfProject () {
11181125 String query = "from test | project foo, bar" ;
1119- ParsingException e = expectThrows (ParsingException .class , "Expected syntax error for " + query , () -> statement (query ));
1120- assertThat (e .getMessage (), containsString ("mismatched input 'project' expecting" ));
1126+ expectThrows (ParsingException .class , containsString ("mismatched input 'project' expecting" ), () -> statement (query ));
11211127 }
11221128
11231129 public void testInputParams () {
@@ -2052,8 +2058,7 @@ public void testQuotedName() {
20522058
20532059 private void assertStringAsIndexPattern (String string , String statement ) {
20542060 if (Build .current ().isSnapshot () == false && statement .contains ("METRIC" )) {
2055- var e = expectThrows (ParsingException .class , () -> statement (statement ));
2056- assertThat (e .getMessage (), containsString ("mismatched input 'METRICS' expecting {" ));
2061+ expectThrows (ParsingException .class , containsString ("mismatched input 'METRICS' expecting {" ), () -> statement (statement ));
20572062 return ;
20582063 }
20592064 LogicalPlan from = statement (statement );
@@ -2064,8 +2069,11 @@ private void assertStringAsIndexPattern(String string, String statement) {
20642069
20652070 private void assertStringAsLookupIndexPattern (String string , String statement ) {
20662071 if (Build .current ().isSnapshot () == false ) {
2067- var e = expectThrows (ParsingException .class , () -> statement (statement ));
2068- assertThat (e .getMessage (), containsString ("line 1:14: LOOKUP_π is in preview and only available in SNAPSHOT build" ));
2072+ expectThrows (
2073+ ParsingException .class ,
2074+ containsString ("line 1:14: LOOKUP_π is in preview and only available in SNAPSHOT build" ),
2075+ () -> statement (statement )
2076+ );
20692077 return ;
20702078 }
20712079 var plan = statement (statement );
@@ -2132,8 +2140,11 @@ public void testInlineConvertWithNonexistentType() {
21322140 public void testLookup () {
21332141 String query = "ROW a = 1 | LOOKUP_π t ON j" ;
21342142 if (Build .current ().isSnapshot () == false ) {
2135- var e = expectThrows (ParsingException .class , () -> statement (query ));
2136- assertThat (e .getMessage (), containsString ("line 1:13: mismatched input 'LOOKUP_π' expecting {" ));
2143+ expectThrows (
2144+ ParsingException .class ,
2145+ containsString ("line 1:13: mismatched input 'LOOKUP_π' expecting {" ),
2146+ () -> statement (query )
2147+ );
21372148 return ;
21382149 }
21392150 var plan = statement (query );
0 commit comments