public final class XContentTestUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.util.Map<java.lang.String,java.lang.Object> |
convertToMap(ToXContent part) |
static java.lang.String |
differenceBetweenMapsIgnoringArrayOrder(java.util.Map<java.lang.String,java.lang.Object> first,
java.util.Map<java.lang.String,java.lang.Object> second)
Compares to maps generated from XContentObjects.
|
static BytesReference |
insertRandomFields(XContentType contentType,
BytesReference xContent,
java.util.function.Predicate<java.lang.String> excludeFilter,
java.util.Random random)
This method takes the input xContent data and adds a random field value, inner object or array into each
json object.
|
public static java.util.Map<java.lang.String,java.lang.Object> convertToMap(ToXContent part) throws java.io.IOException
java.io.IOException
public static java.lang.String differenceBetweenMapsIgnoringArrayOrder(java.util.Map<java.lang.String,java.lang.Object> first, java.util.Map<java.lang.String,java.lang.Object> second)
public static BytesReference insertRandomFields(XContentType contentType, BytesReference xContent, java.util.function.Predicate<java.lang.String> excludeFilter, java.util.Random random) throws java.io.IOException
Predicate
can be supplied that checks xContent paths that should be excluded from this treatment.
This predicate should check the xContent path that we want to insert to and return true if the
path should be excluded. Paths are string concatenating field names and array indices, so e.g. in:
{ "foo1 : { "bar" : [ { ... }, { ... }, { "baz" : { // insert here } } ] } }"foo1.bar.2.baz" would point to the desired insert location. To exclude inserting into the "foo1" object we would user a
Predicate
like
(path) -> path.endsWith("foo1")
or if we don't want any random insertions in the "foo1" tree we could use
(path) -> path.contains("foo1")
java.io.IOException