Interface MapGeneratorSpec<K,V>

Type Parameters:
K - key type
V - value type
All Superinterfaces:
GeneratorSpec<Map<K,V>>, NullableGeneratorSpec<Map<K,V>>, SizeGeneratorSpec<Map<K,V>>, SubtypeGeneratorSpec<Map<K,V>>

public interface MapGeneratorSpec<K,V> extends SizeGeneratorSpec<Map<K,V>>, NullableGeneratorSpec<Map<K,V>>, SubtypeGeneratorSpec<Map<K,V>>
Generator spec for maps.
  • Method Details

    • size

      MapGeneratorSpec<K,V> size(int size)
      Size of map to generate.
      Specified by:
      size in interface SizeGeneratorSpec<K>
      Parameters:
      size - of map
      Returns:
      spec builder
    • minSize

      MapGeneratorSpec<K,V> minSize(int size)
      Minimum size of map to generate.
      Specified by:
      minSize in interface SizeGeneratorSpec<K>
      Parameters:
      size - minimum size (inclusive)
      Returns:
      spec builder
    • maxSize

      MapGeneratorSpec<K,V> maxSize(int size)
      Maximum size of map to generate.
      Specified by:
      maxSize in interface SizeGeneratorSpec<K>
      Parameters:
      size - maximum size (inclusive)
      Returns:
      spec builder
    • nullable

      MapGeneratorSpec<K,V> nullable()
      Indicates that null value can be generated for the map.
      Specified by:
      nullable in interface NullableGeneratorSpec<K>
      Returns:
      spec builder
    • nullableKeys

      MapGeneratorSpec<K,V> nullableKeys()
      Indicates that null values can be generated for map keys.
      Returns:
      spec builder
    • nullableValues

      MapGeneratorSpec<K,V> nullableValues()
      Indicates that null values can be generated for map values.
      Returns:
      spec builder
    • subtype

      MapGeneratorSpec<K,V> subtype(Class<?> type)
      Specifies the type of map that should be generated.
      Specified by:
      subtype in interface SubtypeGeneratorSpec<K>
      Parameters:
      type - of collection to generate
      Returns:
      spec builder
      Since:
      1.4.0
    • with

      MapGeneratorSpec<K,V> with(K key, V value)
      Adds given key/value pair to the generated map. Note that the entry is added after the map has been generated.

      Example:

      
        // will generate a map of size 5 (3 random + 2 custom entries)
        generate(field("someMap"), gen -> gen.map()
                .size(3)
                .with("key1", "value1")
                .with("key2", "value2")
       
      Parameters:
      key - to add
      value - to add
      Returns:
      spec builder
      Since:
      2.0.0
      See Also:
    • withKeys

      MapGeneratorSpec<K,V> withKeys(K... keys)
      Adds given keys to the map in the order they are provided.

      If the resulting map size is equal to the number of specified keys, then the map will contain only the specified keys and no randomly generated keys.

      Examples:

      
        // will generate a map of size 1 containing only "key1"
        generate(field("someMap"), gen -> gen.map().size(1).withKeys("key1", "key2")
      
        // will generate a map of size 2 containing "key1" and "key2"
        generate(field("someMap"), gen -> gen.map().size(2).withKeys("key1", "key2")
      
        // will generate a map of size 5 containing "key1", "key2", and 3 randomly generated keys
        generate(field("someMap"), gen -> gen.map().size(5).withKeys("key1", "key2")
       
      Parameters:
      keys - to add
      Returns:
      spec builder
      Since:
      2.0.0
      See Also: