@@ -80,12 +80,10 @@ public void testBasicEsql() throws IOException {
8080 builder .pragmas (Settings .builder ().put ("data_partitioning" , "shard" ).build ());
8181 }
8282 Map <String , Object > result = runEsql (builder );
83- assertEquals ( 3 , result . size ());
83+
8484 Map <String , String > colA = Map .of ("name" , "avg(value)" , "type" , "double" );
85- assertEquals (List .of (colA ), result .get ("columns" ));
86- assertEquals (List .of (List .of (499.5d )), result .get ("values" ));
85+ assertResultMap (result , colA , List .of (List .of (499.5d )));
8786 assertTrue (result .containsKey ("took" ));
88- assertThat (((Number ) result .get ("took" )).longValue (), greaterThanOrEqualTo (0L ));
8987 }
9088
9189 public void testInvalidPragma () throws IOException {
@@ -118,11 +116,8 @@ public void testDoNotLogWithInfo() throws IOException {
118116 setLoggingLevel ("INFO" );
119117 RequestObjectBuilder builder = requestObjectBuilder ().query ("ROW DO_NOT_LOG_ME = 1" );
120118 Map <String , Object > result = runEsql (builder );
121- assertEquals (3 , result .size ());
122- assertThat (((Integer ) result .get ("took" )).intValue (), greaterThanOrEqualTo (0 ));
123119 Map <String , String > colA = Map .of ("name" , "DO_NOT_LOG_ME" , "type" , "integer" );
124- assertEquals (List .of (colA ), result .get ("columns" ));
125- assertEquals (List .of (List .of (1 )), result .get ("values" ));
120+ assertResultMap (result , colA , List .of (List .of (1 )));
126121 for (int i = 0 ; i < cluster .getNumNodes (); i ++) {
127122 try (InputStream log = cluster .getNodeLog (i , LogType .SERVER )) {
128123 Streams .readAllLines (log , line -> assertThat (line , not (containsString ("DO_NOT_LOG_ME" ))));
@@ -138,11 +133,8 @@ public void testDoLogWithDebug() throws IOException {
138133 setLoggingLevel ("DEBUG" );
139134 RequestObjectBuilder builder = requestObjectBuilder ().query ("ROW DO_LOG_ME = 1" );
140135 Map <String , Object > result = runEsql (builder );
141- assertEquals (3 , result .size ());
142- assertThat (((Integer ) result .get ("took" )).intValue (), greaterThanOrEqualTo (0 ));
143136 Map <String , String > colA = Map .of ("name" , "DO_LOG_ME" , "type" , "integer" );
144- assertEquals (List .of (colA ), result .get ("columns" ));
145- assertEquals (List .of (List .of (1 )), result .get ("values" ));
137+ assertResultMap (result , colA , List .of (List .of (1 )));
146138 boolean [] found = new boolean [] { false };
147139 for (int i = 0 ; i < cluster .getNumNodes (); i ++) {
148140 try (InputStream log = cluster .getNodeLog (i , LogType .SERVER )) {
@@ -289,13 +281,11 @@ public void testProfile() throws IOException {
289281 builder .pragmas (Settings .builder ().put ("data_partitioning" , "shard" ).build ());
290282 }
291283 Map <String , Object > result = runEsql (builder );
292- MapMatcher mapMatcher = matchesMap ();
293- assertMap (
284+ assertResultMap (
294285 result ,
295- mapMatcher .entry ("columns" , matchesList ().item (matchesMap ().entry ("name" , "AVG(value)" ).entry ("type" , "double" )))
296- .entry ("values" , List .of (List .of (499.5d )))
297- .entry ("profile" , matchesMap ().entry ("drivers" , instanceOf (List .class )))
298- .entry ("took" , greaterThanOrEqualTo (0 ))
286+ getResultMatcher (result ).entry ("profile" , matchesMap ().entry ("drivers" , instanceOf (List .class ))),
287+ matchesList ().item (matchesMap ().entry ("name" , "AVG(value)" ).entry ("type" , "double" )),
288+ equalTo (List .of (List .of (499.5d )))
299289 );
300290
301291 List <List <String >> signatures = new ArrayList <>();
@@ -373,24 +363,19 @@ public void testInlineStatsProfile() throws IOException {
373363 }
374364
375365 Map <String , Object > result = runEsql (builder );
376- MapMatcher mapMatcher = matchesMap ();
377366 ListMatcher values = matchesList ();
378367 for (int i = 0 ; i < 1000 ; i ++) {
379368 values = values .item (matchesList ().item ("2020-12-12T00:00:00.000Z" ).item ("value" + i ).item ("value" + i ).item (i ).item (499.5 ));
380369 }
381- assertMap (
370+ assertResultMap (
382371 result ,
383- mapMatcher .entry (
384- "columns" ,
385- matchesList ().item (matchesMap ().entry ("name" , "@timestamp" ).entry ("type" , "date" ))
386- .item (matchesMap ().entry ("name" , "test" ).entry ("type" , "text" ))
387- .item (matchesMap ().entry ("name" , "test.keyword" ).entry ("type" , "keyword" ))
388- .item (matchesMap ().entry ("name" , "value" ).entry ("type" , "long" ))
389- .item (matchesMap ().entry ("name" , "AVG(value)" ).entry ("type" , "double" ))
390- )
391- .entry ("values" , values )
392- .entry ("profile" , matchesMap ().entry ("drivers" , instanceOf (List .class )))
393- .entry ("took" , greaterThanOrEqualTo (0 ))
372+ getResultMatcher (result ).entry ("profile" , matchesMap ().entry ("drivers" , instanceOf (List .class ))),
373+ matchesList ().item (matchesMap ().entry ("name" , "@timestamp" ).entry ("type" , "date" ))
374+ .item (matchesMap ().entry ("name" , "test" ).entry ("type" , "text" ))
375+ .item (matchesMap ().entry ("name" , "test.keyword" ).entry ("type" , "keyword" ))
376+ .item (matchesMap ().entry ("name" , "value" ).entry ("type" , "long" ))
377+ .item (matchesMap ().entry ("name" , "AVG(value)" ).entry ("type" , "double" )),
378+ values
394379 );
395380
396381 List <List <String >> signatures = new ArrayList <>();
@@ -484,20 +469,15 @@ public void testForceSleepsProfile() throws IOException {
484469 for (int group2 = 0 ; group2 < 10 ; group2 ++) {
485470 expectedValues .add (List .of (1.0 , 1 , 1 , 0 , group2 ));
486471 }
487- MapMatcher mapMatcher = matchesMap ();
488- assertMap (
472+ assertResultMap (
489473 result ,
490- mapMatcher .entry (
491- "columns" ,
492- matchesList ().item (matchesMap ().entry ("name" , "AVG(value)" ).entry ("type" , "double" ))
493- .item (matchesMap ().entry ("name" , "MAX(value)" ).entry ("type" , "long" ))
494- .item (matchesMap ().entry ("name" , "MIN(value)" ).entry ("type" , "long" ))
495- .item (matchesMap ().entry ("name" , "group1" ).entry ("type" , "long" ))
496- .item (matchesMap ().entry ("name" , "group2" ).entry ("type" , "long" ))
497- )
498- .entry ("values" , expectedValues )
499- .entry ("profile" , matchesMap ().entry ("drivers" , instanceOf (List .class )))
500- .entry ("took" , greaterThanOrEqualTo (0 ))
474+ getResultMatcher (result ).entry ("profile" , matchesMap ().entry ("drivers" , instanceOf (List .class ))),
475+ matchesList ().item (matchesMap ().entry ("name" , "AVG(value)" ).entry ("type" , "double" ))
476+ .item (matchesMap ().entry ("name" , "MAX(value)" ).entry ("type" , "long" ))
477+ .item (matchesMap ().entry ("name" , "MIN(value)" ).entry ("type" , "long" ))
478+ .item (matchesMap ().entry ("name" , "group1" ).entry ("type" , "long" ))
479+ .item (matchesMap ().entry ("name" , "group2" ).entry ("type" , "long" )),
480+ equalTo (expectedValues )
501481 );
502482
503483 @ SuppressWarnings ("unchecked" )
0 commit comments