Package org.elasticsearch.test
Class RandomObjects
java.lang.Object
org.elasticsearch.test.RandomObjects
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetExpectedParsedValue(org.elasticsearch.xcontent.XContentType xContentType, Object value) Converts the provided field value to its corresponding expected value once printed out viaToXContent.toXContent(XContentBuilder, ToXContent.Params)and parsed back viaXContentParser.objectText().static org.elasticsearch.core.Tuple<ReplicationResponse.ShardInfo, ReplicationResponse.ShardInfo> randomShardInfo(Random random) Returns a tuple that contains a randomizedReplicationResponse.ShardInfovalue (left side) and its corresponding value (right side) after it has been printed out as aToXContentand parsed back using a parsing method likeReplicationResponse.ShardInfo.fromXContent(XContentParser).static org.elasticsearch.core.Tuple<ReplicationResponse.ShardInfo, ReplicationResponse.ShardInfo> randomShardInfo(Random random, boolean withShardFailures) Returns a tuple that contains a randomizedReplicationResponse.ShardInfovalue (left side) and its corresponding value (right side) after it has been printed out as aToXContentand parsed back using a parsing method likeReplicationResponse.ShardInfo.fromXContent(XContentParser).static BytesReferencerandomSource(Random random) Returns a random source containing a random number of fields, objects and array, with maximum depth 5.static BytesReferencerandomSource(Random random, org.elasticsearch.xcontent.XContentType xContentType) Returns a random source in a given XContentType containing a random number of fields, objects and array, with maximum depth 5.static BytesReferencerandomSource(Random random, org.elasticsearch.xcontent.XContentType xContentType, int minNumFields) Returns a random source in a given XContentType containing a random number of fields, objects and array, with maximum depth 5.randomStoredFieldValues(Random random, org.elasticsearch.xcontent.XContentType xContentType) Returns a tuple containing random stored field values and their corresponding expected values once printed out viaToXContent.toXContent(XContentBuilder, ToXContent.Params)and parsed back viaXContentParser.objectText().static AnalyzeAction.AnalyzeTokenrandomToken(Random random)
-
Method Details
-
randomStoredFieldValues
public static org.elasticsearch.core.Tuple<List<Object>,List<Object>> randomStoredFieldValues(Random random, org.elasticsearch.xcontent.XContentType xContentType) Returns a tuple containing random stored field values and their corresponding expected values once printed out viaToXContent.toXContent(XContentBuilder, ToXContent.Params)and parsed back viaXContentParser.objectText(). Generates values based on what can get printed out. Stored fields values are retrieved from lucene and converted viaMappedFieldType.valueForDisplay(Object)to either strings, numbers or booleans.- Parameters:
random- Random generatorxContentType- the content type, used to determine what the expected values are for float numbers.
-
getExpectedParsedValue
public static Object getExpectedParsedValue(org.elasticsearch.xcontent.XContentType xContentType, Object value) Converts the provided field value to its corresponding expected value once printed out viaToXContent.toXContent(XContentBuilder, ToXContent.Params)and parsed back viaXContentParser.objectText(). Generates values based on what can get printed out. Stored fields values are retrieved from lucene and converted viaMappedFieldType.valueForDisplay(Object)to either strings, numbers or booleans. -
randomSource
Returns a random source containing a random number of fields, objects and array, with maximum depth 5.- Parameters:
random- Random generator
-
randomSource
public static BytesReference randomSource(Random random, org.elasticsearch.xcontent.XContentType xContentType) Returns a random source in a given XContentType containing a random number of fields, objects and array, with maximum depth 5. The minimum number of fields per object is 1.- Parameters:
random- Random generator
-
randomSource
public static BytesReference randomSource(Random random, org.elasticsearch.xcontent.XContentType xContentType, int minNumFields) Returns a random source in a given XContentType containing a random number of fields, objects and array, with maximum depth 5. The minimum number of fields per object is provided as an argument.- Parameters:
random- Random generator
-
randomShardInfo
public static org.elasticsearch.core.Tuple<ReplicationResponse.ShardInfo,ReplicationResponse.ShardInfo> randomShardInfo(Random random) Returns a tuple that contains a randomizedReplicationResponse.ShardInfovalue (left side) and its corresponding value (right side) after it has been printed out as aToXContentand parsed back using a parsing method likeReplicationResponse.ShardInfo.fromXContent(XContentParser). The ShardInfo randomly contains shard failures.- Parameters:
random- Random generator
-
randomShardInfo
public static org.elasticsearch.core.Tuple<ReplicationResponse.ShardInfo,ReplicationResponse.ShardInfo> randomShardInfo(Random random, boolean withShardFailures) Returns a tuple that contains a randomizedReplicationResponse.ShardInfovalue (left side) and its corresponding value (right side) after it has been printed out as aToXContentand parsed back using a parsing method likeReplicationResponse.ShardInfo.fromXContent(XContentParser). A `withShardFailures` parameter indicates if the randomized ShardInfo must or must not contain shard failures.- Parameters:
random- Random generatorwithShardFailures- indicates if the generated ShardInfo must contain shard failures
-
randomToken
-