Skip to content

Commit adef44a

Browse files
committed
Adding test comment
1 parent 2c302cf commit adef44a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/src/test/java/org/elasticsearch/search/aggregations/AggregationsTests.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.common.bytes.BytesReference;
2424
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
2525
import org.elasticsearch.common.xcontent.ToXContent;
26+
import org.elasticsearch.common.xcontent.XContent;
2627
import org.elasticsearch.common.xcontent.XContentBuilder;
2728
import org.elasticsearch.common.xcontent.XContentFactory;
2829
import 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"));

0 commit comments

Comments
 (0)