@@ -165,8 +165,8 @@ public void indexDocuments() throws IOException {
165165 }
166166 }
167167
168- protected MapMatcher responseMatcher () {
169- return matchesMap ( );
168+ protected MapMatcher responseMatcher (Map < String , Object > result ) {
169+ return getResultMatcher ( result );
170170 }
171171
172172 public void testAllowedIndices () throws Exception {
@@ -182,10 +182,7 @@ public void testAllowedIndices() throws Exception {
182182 Response resp = runESQLCommand (user , "from index-user1 | stats sum=sum(value)" );
183183 assertOK (resp );
184184 Map <String , Object > responseMap = entityAsMap (resp );
185- MapMatcher mapMatcher = responseMatcher ();
186- if (responseMap .get ("took" ) != null ) {
187- mapMatcher = mapMatcher .entry ("took" , ((Integer ) responseMap .get ("took" )).intValue ());
188- }
185+ MapMatcher mapMatcher = responseMatcher (responseMap );
189186 MapMatcher matcher = mapMatcher .entry ("columns" , List .of (Map .of ("name" , "sum" , "type" , "double" )))
190187 .entry ("values" , List .of (List .of (43.0d )));
191188 assertMap (responseMap , matcher );
@@ -195,10 +192,7 @@ public void testAllowedIndices() throws Exception {
195192 Response resp = runESQLCommand (user , "from index-user2 | stats sum=sum(value)" );
196193 assertOK (resp );
197194 Map <String , Object > responseMap = entityAsMap (resp );
198- MapMatcher mapMatcher = responseMatcher ();
199- if (responseMap .get ("took" ) != null ) {
200- mapMatcher = mapMatcher .entry ("took" , ((Integer ) responseMap .get ("took" )).intValue ());
201- }
195+ MapMatcher mapMatcher = responseMatcher (responseMap );
202196 MapMatcher matcher = mapMatcher .entry ("columns" , List .of (Map .of ("name" , "sum" , "type" , "double" )))
203197 .entry ("values" , List .of (List .of (72.0d )));
204198 assertMap (responseMap , matcher );
@@ -208,10 +202,7 @@ public void testAllowedIndices() throws Exception {
208202 Response resp = runESQLCommand ("metadata1_read2" , "from " + index + " | stats sum=sum(value)" );
209203 assertOK (resp );
210204 Map <String , Object > responseMap = entityAsMap (resp );
211- MapMatcher mapMatcher = responseMatcher ();
212- if (responseMap .get ("took" ) != null ) {
213- mapMatcher = mapMatcher .entry ("took" , ((Integer ) responseMap .get ("took" )).intValue ());
214- }
205+ MapMatcher mapMatcher = responseMatcher (responseMap );
215206 MapMatcher matcher = mapMatcher .entry ("columns" , List .of (Map .of ("name" , "sum" , "type" , "double" )))
216207 .entry ("values" , List .of (List .of (72.0d )));
217208 assertMap (responseMap , matcher );
@@ -226,9 +217,10 @@ public void testAliases() throws Exception {
226217 );
227218 assertOK (resp );
228219 Map <String , Object > responseMap = entityAsMap (resp );
229- MapMatcher matcher = responseMatcher ().entry ("took" , ((Integer ) responseMap .get ("took" )).intValue ())
230- .entry ("columns" , List .of (Map .of ("name" , "sum" , "type" , "double" ), Map .of ("name" , "index" , "type" , "keyword" )))
231- .entry ("values" , List .of (List .of (72.0d , "index-user2" )));
220+ MapMatcher matcher = responseMatcher (responseMap ).entry (
221+ "columns" ,
222+ List .of (Map .of ("name" , "sum" , "type" , "double" ), Map .of ("name" , "index" , "type" , "keyword" ))
223+ ).entry ("values" , List .of (List .of (72.0d , "index-user2" )));
232224 assertMap (responseMap , matcher );
233225 }
234226 }
@@ -238,16 +230,14 @@ public void testAliasFilter() throws Exception {
238230 Response resp = runESQLCommand ("alias_user1" , "from " + index + " METADATA _index" + "| KEEP _index, org, value | LIMIT 10" );
239231 assertOK (resp );
240232 Map <String , Object > responseMap = entityAsMap (resp );
241- MapMatcher matcher = responseMatcher ().entry ("took" , ((Integer ) responseMap .get ("took" )).intValue ())
242- .entry (
243- "columns" ,
244- List .of (
245- Map .of ("name" , "_index" , "type" , "keyword" ),
246- Map .of ("name" , "org" , "type" , "keyword" ),
247- Map .of ("name" , "value" , "type" , "double" )
248- )
233+ MapMatcher matcher = responseMatcher (responseMap ).entry (
234+ "columns" ,
235+ List .of (
236+ Map .of ("name" , "_index" , "type" , "keyword" ),
237+ Map .of ("name" , "org" , "type" , "keyword" ),
238+ Map .of ("name" , "value" , "type" , "double" )
249239 )
250- .entry ("values" , List .of (List .of ("index-user1" , "sales" , 31.0d )));
240+ ) .entry ("values" , List .of (List .of ("index-user1" , "sales" , 31.0d )));
251241 assertMap (responseMap , matcher );
252242 }
253243 }
0 commit comments