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 via ToXContent.toXContent(XContentBuilder, ToXContent.Params) and parsed back via XContentParser.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 randomized ReplicationResponse.ShardInfo value (left side) and its corresponding value (right side) after it has been printed out as a ToXContent and parsed back using a parsing method like ReplicationResponse.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 randomized ReplicationResponse.ShardInfo value (left side) and its corresponding value (right side) after it has been printed out as a ToXContent and parsed back using a parsing method like ReplicationResponse.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 via ToXContent.toXContent(XContentBuilder, ToXContent.Params) and parsed back via XContentParser.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 via ToXContent.toXContent(XContentBuilder, ToXContent.Params) and parsed back via XContentParser.objectText(). Generates values based on what can get printed out. Stored fields values are retrieved from lucene and converted via MappedFieldType.valueForDisplay(Object) to either strings, numbers or booleans.
      Parameters:
      random - Random generator
      xContentType - 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 via ToXContent.toXContent(XContentBuilder, ToXContent.Params) and parsed back via XContentParser.objectText(). Generates values based on what can get printed out. Stored fields values are retrieved from lucene and converted via MappedFieldType.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 randomized ReplicationResponse.ShardInfo value (left side) and its corresponding value (right side) after it has been printed out as a ToXContent and parsed back using a parsing method like ReplicationResponse.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 randomized ReplicationResponse.ShardInfo value (left side) and its corresponding value (right side) after it has been printed out as a ToXContent and parsed back using a parsing method like ReplicationResponse.ShardInfo.fromXContent(XContentParser). A `withShardFailures` parameter indicates if the randomized ShardInfo must or must not contain shard failures.
      Parameters:
      random - Random generator
      withShardFailures - 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)