Package org.elasticsearch.test
Class RandomObjects
java.lang.Object
org.elasticsearch.test.RandomObjects
public final class RandomObjects
extends java.lang.Object
-
Method Summary
Modifier and Type Method Description static java.lang.Object
getExpectedParsedValue(org.elasticsearch.common.xcontent.XContentType xContentType, java.lang.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.common.collect.Tuple<org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo,org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo>
randomShardInfo(java.util.Random random)
Returns a tuple that contains a randomizedReplicationResponse.ShardInfo
value (left side) and its corresponding value (right side) after it has been printed out as aToXContent
and parsed back using a parsing method likeReplicationResponse.ShardInfo.fromXContent(XContentParser)
.static org.elasticsearch.common.collect.Tuple<org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo,org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo>
randomShardInfo(java.util.Random random, boolean withShardFailures)
Returns a tuple that contains a randomizedReplicationResponse.ShardInfo
value (left side) and its corresponding value (right side) after it has been printed out as aToXContent
and parsed back using a parsing method likeReplicationResponse.ShardInfo.fromXContent(XContentParser)
.static org.elasticsearch.common.bytes.BytesReference
randomSource(java.util.Random random)
Returns a random source containing a random number of fields, objects and array, with maximum depth 5.static org.elasticsearch.common.bytes.BytesReference
randomSource(java.util.Random random, org.elasticsearch.common.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 org.elasticsearch.common.bytes.BytesReference
randomSource(java.util.Random random, org.elasticsearch.common.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.static org.elasticsearch.common.collect.Tuple<java.util.List<java.lang.Object>,java.util.List<java.lang.Object>>
randomStoredFieldValues(java.util.Random random, org.elasticsearch.common.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 org.elasticsearch.action.admin.indices.analyze.AnalyzeAction.AnalyzeToken
randomToken(java.util.Random random)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
randomStoredFieldValues
public static org.elasticsearch.common.collect.Tuple<java.util.List<java.lang.Object>,java.util.List<java.lang.Object>> randomStoredFieldValues(java.util.Random random, org.elasticsearch.common.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 java.lang.Object getExpectedParsedValue(org.elasticsearch.common.xcontent.XContentType xContentType, java.lang.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
public static org.elasticsearch.common.bytes.BytesReference randomSource(java.util.Random random)Returns a random source containing a random number of fields, objects and array, with maximum depth 5.- Parameters:
random
- Random generator
-
randomSource
public static org.elasticsearch.common.bytes.BytesReference randomSource(java.util.Random random, org.elasticsearch.common.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 org.elasticsearch.common.bytes.BytesReference randomSource(java.util.Random random, org.elasticsearch.common.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.common.collect.Tuple<org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo,org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo> randomShardInfo(java.util.Random random)Returns a tuple that contains a randomizedReplicationResponse.ShardInfo
value (left side) and its corresponding value (right side) after it has been printed out as aToXContent
and 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.common.collect.Tuple<org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo,org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo> randomShardInfo(java.util.Random random, boolean withShardFailures)Returns a tuple that contains a randomizedReplicationResponse.ShardInfo
value (left side) and its corresponding value (right side) after it has been printed out as aToXContent
and 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
public static org.elasticsearch.action.admin.indices.analyze.AnalyzeAction.AnalyzeToken randomToken(java.util.Random random)
-