File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
core/src/test/java/org/elasticsearch/search/aggregations Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 2323import org .elasticsearch .common .bytes .BytesReference ;
2424import org .elasticsearch .common .xcontent .NamedXContentRegistry ;
2525import org .elasticsearch .common .xcontent .ToXContent ;
26+ import org .elasticsearch .common .xcontent .XContent ;
2627import org .elasticsearch .common .xcontent .XContentBuilder ;
2728import org .elasticsearch .common .xcontent .XContentFactory ;
2829import org .elasticsearch .common .xcontent .XContentHelper ;
@@ -185,6 +186,18 @@ public void testFromXContentWithRandomFields() throws IOException {
185186 parseAndAssert (true );
186187 }
187188
189+ /**
190+ * Test that parsing works for a randomly created Aggregations object with a
191+ * randomized aggregation tree. The test randomly chooses an
192+ * {@link XContentType}, randomizes the order of the {@link XContent} fields
193+ * and randomly sets the `humanReadable` flag when rendering the
194+ * {@link XContent}.
195+ *
196+ * @param addRandomFields
197+ * if set, this will also add random {@link XContent} fields to
198+ * tests that the parsers are lenient to future additions to rest
199+ * responses
200+ */
188201 private void parseAndAssert (boolean addRandomFields ) throws IOException {
189202 XContentType xContentType = randomFrom (XContentType .values ());
190203 final ToXContent .Params params = new ToXContent .MapParams (singletonMap (RestSearchAction .TYPED_KEYS_PARAM , "true" ));
You can’t perform that action at this time.
0 commit comments