Class RandomObjects


  • public final class RandomObjects
    extends java.lang.Object
    • Method Detail

      • randomStoredFieldValues

        public static Tuple<java.util.List<java.lang.Object>,​java.util.List<java.lang.Object>> randomStoredFieldValues​(java.util.Random random,
                                                                                                                             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.
      • randomSource

        public static 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 BytesReference randomSource​(java.util.Random random,
                                                  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​(java.util.Random random,
                                                  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