public class PactDslJsonArray extends DslPart
DSL to define a JSON array
public static au.com.dius.pact.consumer.dsl.PactDslJsonArray.Companion Companion
public PactDslJsonArray(@NotNull
java.lang.String rootPath,
@NotNull
java.lang.String rootName,
@Nullable
DslPart parent,
@NotNull
PactDslJsonArray array)
Construct an array as a child copied from an existing array
rootPath - Path to the child arrayrootName - Name to associate the child asparent - Parent to attach the child toarray - Array to copy@JvmOverloads
public PactDslJsonArray(@NotNull
java.lang.String rootPath,
@NotNull
java.lang.String rootName,
@Nullable
DslPart parent,
boolean wildCard)
Construct a array as a child
rootPath - Path to the child arrayrootName - Name to associate the child asparent - Parent to attach the child towildCard - If it should be matched as a wild card@JvmOverloads
public PactDslJsonArray(@NotNull
java.lang.String rootPath,
@NotNull
java.lang.String rootName,
@Nullable
DslPart parent)
Construct a array as a child
rootPath - Path to the child arrayrootName - Name to associate the child asparent - Parent to attach the child to@JvmOverloads
public PactDslJsonArray(@NotNull
java.lang.String rootPath,
@NotNull
java.lang.String rootName)
Construct a array as a child
rootPath - Path to the child arrayrootName - Name to associate the child as@JvmOverloads
public PactDslJsonArray(@NotNull
java.lang.String rootPath)
Construct a array as a child
rootPath - Path to the child array@JvmOverloads public PactDslJsonArray()
Construct a array as a child
@NotNull public au.com.dius.pact.core.support.json.JsonValue getBody()
public void setBody(@NotNull
au.com.dius.pact.core.support.json.JsonValue p)
public int getNumberExamples()
Sets the number of example elements to generate for sample bodies
public void setNumberExamples(int p)
Sets the number of example elements to generate for sample bodies
@Nullable public DslPart closeArray()
Closes the current array
@NotNull public PactDslJsonBody eachLike(@NotNull java.lang.String name)
Array field where each element must match the following object
name - field name@NotNull public PactDslJsonBody eachLike(@NotNull java.lang.String name, @NotNull DslPart obj)
Array field where each element must match the following object
name - field name@NotNull public PactDslJsonBody eachLike(@NotNull java.lang.String name, int numberExamples)
Array field where each element must match the following object
name - field namenumberExamples - number of examples to generate@NotNull public PactDslJsonBody eachLike()
Element that is an array where each item must match the following example
@NotNull public PactDslJsonArray eachLike(@NotNull DslPart obj)
Array element where each element of the array must match the provided object
@NotNull public PactDslJsonBody eachLike(int numberExamples)
Element that is an array where each item must match the following example
numberExamples - Number of examples to generate@NotNull public PactDslJsonBody minArrayLike(@NotNull java.lang.String name, int size)
Array field with a minimum size and each element must match the following object
name - field namesize - minimum size@NotNull public PactDslJsonBody minArrayLike(int size)
Element that is an array with a minimum size where each item must match the following example
size - minimum size of the array@NotNull public PactDslJsonBody minArrayLike(@NotNull java.lang.String name, int size, @NotNull DslPart obj)
Array field with a minimum size and each element must match the provided object
name - field namesize - minimum size@NotNull public PactDslJsonArray minArrayLike(int size, @NotNull DslPart obj)
Array element with a minumum size and each element of the array must match the provided object
size - minimum size@NotNull public PactDslJsonBody minArrayLike(@NotNull java.lang.String name, int size, int numberExamples)
Array field with a minumum size and each element must match the following object
name - field namesize - minimum sizenumberExamples - number of examples to generate@NotNull public PactDslJsonBody minArrayLike(int size, int numberExamples)
Element that is an array with a minimum size where each item must match the following example
size - minimum size of the arraynumberExamples - number of examples to generate@NotNull public PactDslJsonBody maxArrayLike(@NotNull java.lang.String name, int size)
Array field with a maximum size and each element must match the following object
name - field namesize - maximum size@NotNull public PactDslJsonBody maxArrayLike(int size)
Element that is an array with a maximum size where each item must match the following example
size - maximum size of the array@NotNull public PactDslJsonBody maxArrayLike(@NotNull java.lang.String name, int size, @NotNull DslPart obj)
Array field with a maximum size and each element must match the provided object
name - field namesize - maximum size@NotNull public PactDslJsonArray maxArrayLike(int size, @NotNull DslPart obj)
Array element with a maximum size and each element of the array must match the provided object
size - minimum size@NotNull public PactDslJsonBody maxArrayLike(@NotNull java.lang.String name, int size, int numberExamples)
Array field with a maximum size and each element must match the following object
name - field namesize - maximum sizenumberExamples - number of examples to generate@NotNull public PactDslJsonBody maxArrayLike(int size, int numberExamples)
Element that is an array with a maximum size where each item must match the following example
size - maximum size of the arraynumberExamples - number of examples to generatepublic void putObjectPrivate(@NotNull
DslPart obj)
public void putArrayPrivate(@NotNull
DslPart obj)
@NotNull public PactDslJsonArray stringValue(@Nullable java.lang.String value)
Element that must be the specified value
value - string value@NotNull public PactDslJsonArray string(@Nullable java.lang.String value)
Element that must be the specified value
value - string value@NotNull public PactDslJsonArray numberValue(@NotNull java.lang.Number value)
@NotNull public PactDslJsonArray number(@NotNull java.lang.Number value)
Element that must be the specified value
value - number value@NotNull public PactDslJsonArray booleanValue(boolean value)
Element that must be the specified value
value - boolean value@NotNull public PactDslJsonArray like(@Nullable java.lang.Object example)
Element that must be the same type as the example
@NotNull public PactDslJsonArray stringType()
Element that can be any string
@NotNull public PactDslJsonArray stringType(@NotNull java.lang.String example)
Element that can be any string
example - example value to use for generated bodies@NotNull public PactDslJsonArray numberType()
Element that can be any number
@NotNull public PactDslJsonArray numberType(@NotNull java.lang.Number number)
Element that can be any number
number - example number to use for generated bodies@NotNull public PactDslJsonArray integerType()
Element that must be an integer
@NotNull public PactDslJsonArray integerType(long number)
Element that must be an integer
number - example integer value to use for generated bodies@NotNull public PactDslJsonArray decimalType()
Element that must be a decimal value
@NotNull public PactDslJsonArray decimalType(@NotNull java.math.BigDecimal number)
Element that must be a decimalType value
number - example decimalType value@NotNull public PactDslJsonArray decimalType(double number)
Attribute that must be a decimalType value
number - example decimalType value@NotNull public PactDslJsonArray booleanType()
Element that must be a boolean
@NotNull public PactDslJsonArray booleanType(boolean example)
Element that must be a boolean
example - example boolean to use for generated bodies@NotNull public PactDslJsonArray stringMatcher(@NotNull java.lang.String regex, @NotNull java.lang.String value)
Element that must match the regular expression
regex - regular expressionvalue - example value to use for generated bodies@Deprecated @NotNull public PactDslJsonArray timestamp()
Element that must be an ISO formatted timestamp
@Deprecated @NotNull public PactDslJsonArray timestamp(@NotNull java.lang.String format)
Element that must match the given timestamp format
format - timestamp format@Deprecated @NotNull public PactDslJsonArray timestamp(@NotNull java.lang.String format, @NotNull java.util.Date example)
Element that must match the given timestamp format
format - timestamp formatexample - example date and time to use for generated bodies@Deprecated @NotNull public PactDslJsonArray timestamp(@NotNull java.lang.String format, @NotNull java.time.Instant example)
Element that must match the given timestamp format
format - timestamp formatexample - example date and time to use for generated bodies@NotNull public PactDslJsonArray datetime()
Element that must be an ISO formatted timestamp
@NotNull public PactDslJsonArray datetime(@NotNull java.lang.String format)
Element that must match the given timestamp format
format - timestamp format@NotNull public PactDslJsonArray datetime(@NotNull java.lang.String format, @NotNull java.util.Date example)
Element that must match the given timestamp format
format - timestamp formatexample - example date and time to use for generated bodies@NotNull public PactDslJsonArray datetime(@NotNull java.lang.String format, @NotNull java.time.Instant example)
Element that must match the given timestamp format
format - timestamp formatexample - example date and time to use for generated bodies@NotNull public PactDslJsonArray date()
Element that must be formatted as an ISO date
@NotNull public PactDslJsonArray date(@NotNull java.lang.String format)
Element that must match the provided date format
format - date format to match@NotNull public PactDslJsonArray date(@NotNull java.lang.String format, @NotNull java.util.Date example)
Element that must match the provided date format
format - date format to matchexample - example date to use for generated values@NotNull public PactDslJsonArray time()
Element that must be an ISO formatted time
@NotNull public PactDslJsonArray time(@NotNull java.lang.String format)
Element that must match the given time format
format - time format to match@NotNull public PactDslJsonArray time(@NotNull java.lang.String format, @NotNull java.util.Date example)
Element that must match the given time format
format - time format to matchexample - example time to use for generated bodies@NotNull public PactDslJsonArray ipAddress()
Element that must be an IP4 address
@NotNull public PactDslJsonBody object(@NotNull java.lang.String name)
Object field
name - field name@NotNull public PactDslJsonBody object()
Element that is a JSON object
@Nullable public DslPart closeObject()
Close off the previous object
@Nullable public DslPart close()
This closes off the object graph build from the DSL in case any closeObject|Array methods have not been called.
@NotNull public PactDslJsonArray array(@NotNull java.lang.String name)
Field which is an array
name - field name@NotNull public PactDslJsonArray array()
Element that is a JSON array
@NotNull public PactDslJsonArray wildcardArrayMatcher(@NotNull au.com.dius.pact.core.model.matchingrules.MatchingRule rule)
Matches rule for all elements in array
rule - Matching rule to apply across array@NotNull public PactDslJsonArray id()
Element that must be a numeric identifier
@NotNull public PactDslJsonArray id(long id)
Element that must be a numeric identifier
id - example id to use for generated bodies@NotNull public PactDslJsonArray hexValue()
Element that must be encoded as a hexadecimal value
@NotNull public PactDslJsonArray hexValue(@NotNull java.lang.String hexValue)
Element that must be encoded as a hexadecimal value
hexValue - example value to use for generated bodies@NotNull public PactDslJsonArray uuid()
Element that must be encoded as an UUID
@NotNull public PactDslJsonArray uuid(@NotNull java.lang.String uuid)
Element that must be encoded as an UUID
uuid - example UUID to use for generated bodies@NotNull public PactDslJsonArray template(@NotNull DslPart template)
Adds the template object to the array
template - template object@NotNull public PactDslJsonArray template(@NotNull DslPart template, int occurrences)
Adds a number of template objects to the array
template - template objectoccurrences - number to add@NotNull public java.lang.String toString()
@NotNull public PactDslJsonArray nullValue()
Adds a null value to the list
@NotNull public PactDslJsonArray eachArrayLike(@NotNull java.lang.String name)
Array field where each element is an array and must match the following object
name - field name@NotNull public PactDslJsonArray eachArrayLike(@NotNull java.lang.String name, int numberExamples)
Array field where each element is an array and must match the following object
name - field namenumberExamples - number of examples to generate@NotNull public PactDslJsonArray eachArrayLike()
Array element where each element of the array is an array and must match the following object
@NotNull public PactDslJsonArray eachArrayLike(int numberExamples)
Array element where each element of the array is an array and must match the following object
numberExamples - number of examples to generate@NotNull public PactDslJsonArray eachArrayWithMaxLike(@NotNull java.lang.String name, int size)
Array field where each element is an array and must match the following object
name - field namesize - Maximum size of the outer array@NotNull public PactDslJsonArray eachArrayWithMaxLike(@NotNull java.lang.String name, int numberExamples, int size)
Array field where each element is an array and must match the following object
name - field namenumberExamples - number of examples to generatesize - Maximum size of the outer array@NotNull public PactDslJsonArray eachArrayWithMaxLike(int size)
Array element where each element of the array is an array and must match the following object
size - Maximum size of the outer array@NotNull public PactDslJsonArray eachArrayWithMaxLike(int numberExamples, int size)
Array element where each element of the array is an array and must match the following object
numberExamples - number of examples to generatesize - Maximum size of the outer array@NotNull public PactDslJsonArray eachArrayWithMinLike(@NotNull java.lang.String name, int size)
Array field where each element is an array and must match the following object
name - field namesize - Minimum size of the outer array@NotNull public PactDslJsonArray eachArrayWithMinLike(@NotNull java.lang.String name, int numberExamples, int size)
Array field where each element is an array and must match the following object
name - field namenumberExamples - number of examples to generatesize - Minimum size of the outer array@NotNull public PactDslJsonArray eachArrayWithMinLike(int size)
Array element where each element of the array is an array and must match the following object
size - Minimum size of the outer array@NotNull public PactDslJsonArray eachArrayWithMinLike(int numberExamples, int size)
Array element where each element of the array is an array and must match the following object
numberExamples - number of examples to generatesize - Minimum size of the outer array@JvmOverloads @NotNull public PactDslJsonArray eachLike(@Nullable PactDslJsonRootValue value, int numberExamples)
Array of values that are not objects where each item must match the provided example
value - Value to use to match each item@JvmOverloads @NotNull public PactDslJsonArray eachLike(@Nullable PactDslJsonRootValue value)
Array of values that are not objects where each item must match the provided example
value - Value to use to match each item@JvmOverloads @NotNull public PactDslJsonArray minArrayLike(int size, @Nullable PactDslJsonRootValue value, int numberExamples)
Array of values with a minimum size that are not objects where each item must match the provided example
size - minimum size of the arrayvalue - Value to use to match each itemnumberExamples - number of examples to generate@JvmOverloads @NotNull public PactDslJsonArray minArrayLike(int size, @Nullable PactDslJsonRootValue value)
Array of values with a minimum size that are not objects where each item must match the provided example
size - minimum size of the arrayvalue - Value to use to match each item@JvmOverloads @NotNull public PactDslJsonArray maxArrayLike(int size, @Nullable PactDslJsonRootValue value, int numberExamples)
Array of values with a maximum size that are not objects where each item must match the provided example
size - maximum size of the arrayvalue - Value to use to match each itemnumberExamples - number of examples to generate@JvmOverloads @NotNull public PactDslJsonArray maxArrayLike(int size, @Nullable PactDslJsonRootValue value)
Array of values with a maximum size that are not objects where each item must match the provided example
size - maximum size of the arrayvalue - Value to use to match each item@NotNull public PactDslJsonArray includesStr(@NotNull java.lang.String value)
List item that must include the provided string
value - Value that must be included@NotNull public PactDslJsonArray equalsTo(@Nullable java.lang.Object value)
Attribute that must be equal to the provided value.
value - Value that will be used for comparisons@NotNull public PactDslJsonArray and(@Nullable java.lang.Object value, @NotNull au.com.dius.pact.core.model.matchingrules.MatchingRule... rules)
Combine all the matchers using AND
value - Attribute example valuerules - Matching rules to apply@NotNull public PactDslJsonArray or(@Nullable java.lang.Object value, @NotNull au.com.dius.pact.core.model.matchingrules.MatchingRule... rules)
Combine all the matchers using OR
value - Attribute example valuerules - Matching rules to apply@NotNull public PactDslJsonArray matchUrl(@Nullable java.lang.String basePath, @NotNull java.lang.Object... pathFragments)
Matches a URL that is composed of a base path and a sequence of path expressions
basePath - The base path for the URL (like "http://localhost:8080/") which will beexcluded from the matchingpathFragments - Series of path fragments to match on. These can be strings or regular expressions.@NotNull public DslPart matchUrl(@NotNull java.lang.String name, @Nullable java.lang.String basePath, @NotNull java.lang.Object... pathFragments)
Matches a URL that is composed of a base path and a sequence of path expressions
name - Attribute namebasePath - The base path for the URL (like "http://localhost:8080/") which will be excluded from the matchingpathFragments - Series of path fragments to match on. These can be strings or regular expressions.@NotNull public PactDslJsonBody matchUrl2(@NotNull java.lang.String name, @NotNull java.lang.Object... pathFragments)
Matches a URL that is composed of a base path and a sequence of path expressions. Base path from the mock server will be used.
name - Attribute namepathFragments - Series of path fragments to match on. These can be strings or regular expressions.@NotNull public DslPart matchUrl2(@NotNull java.lang.Object... pathFragments)
Matches a URL that is composed of a base path and a sequence of path expressions. Base path from the mock server will be used.
pathFragments - Series of path fragments to match on. These can be strings or regular expressions.@NotNull public PactDslJsonBody minMaxArrayLike(@NotNull java.lang.String name, int minSize, int maxSize)
Array field with a minimum and maximum size and each element must match the following object
name - field nameminSize - minimum sizemaxSize - maximum size@NotNull public PactDslJsonBody minMaxArrayLike(@NotNull java.lang.String name, int minSize, int maxSize, @NotNull DslPart obj)
Array field with a minimum and maximum size and each element must match the provided object
name - field nameminSize - minimum sizemaxSize - maximum size@NotNull public PactDslJsonBody minMaxArrayLike(int minSize, int maxSize)
Array element with a minimum and maximum size and each element of the array must match the following object
minSize - minimum sizemaxSize - maximum size@NotNull public PactDslJsonArray minMaxArrayLike(int minSize, int maxSize, @NotNull DslPart obj)
Array element with a minimum and maximum size and each element of the array must match the provided object
minSize - minimum sizemaxSize - maximum size@NotNull public PactDslJsonBody minMaxArrayLike(@NotNull java.lang.String name, int minSize, int maxSize, int numberExamples)
Array field with a minimum and maximum size and each element must match the following object
name - field nameminSize - minimum sizemaxSize - maximum sizenumberExamples - number of examples to generate@NotNull public PactDslJsonBody minMaxArrayLike(int minSize, int maxSize, int numberExamples)
Array element with a minimum and maximum size and each element of the array must match the following object
minSize - minimum sizemaxSize - maximum sizenumberExamples - number of examples to generate@NotNull public PactDslJsonArray eachArrayWithMinMaxLike(@NotNull java.lang.String name, int minSize, int maxSize)
Array field where each element is an array and must match the following object
name - field nameminSize - minimum sizemaxSize - maximum size@NotNull public PactDslJsonArray eachArrayWithMinMaxLike(int minSize, int maxSize)
Array element where each element of the array is an array and must match the following object
minSize - minimum sizemaxSize - maximum size@NotNull public PactDslJsonArray eachArrayWithMinMaxLike(@NotNull java.lang.String name, int numberExamples, int minSize, int maxSize)
Array field where each element is an array and must match the following object
name - field namenumberExamples - number of examples to generateminSize - minimum sizemaxSize - maximum size@NotNull public PactDslJsonArray eachArrayWithMinMaxLike(int numberExamples, int minSize, int maxSize)
Array element where each element of the array is an array and must match the following object
numberExamples - number of examples to generateminSize - minimum sizemaxSize - maximum size@NotNull public PactDslJsonArray valueFromProviderState(@Nullable java.lang.String expression, @Nullable java.lang.Object example)
Adds an element that will have it's value injected from the provider state
expression - Expression to be evaluated from the provider stateexample - Example value to be used in the consumer test@JvmOverloads @NotNull public PactDslJsonArray dateExpression(@NotNull java.lang.String expression, @NotNull java.lang.String format)
Adds a date value with the value generated by the date expression
expression - Date expression to use to generate the valuesformat - Date format to use@JvmOverloads @NotNull public PactDslJsonArray dateExpression(@NotNull java.lang.String expression)
Adds a date value with the value generated by the date expression
expression - Date expression to use to generate the values@JvmOverloads @NotNull public PactDslJsonArray timeExpression(@NotNull java.lang.String expression, @NotNull java.lang.String format)
Adds a time value with the value generated by the time expression
expression - Time expression to use to generate the valuesformat - Time format to use@JvmOverloads @NotNull public PactDslJsonArray timeExpression(@NotNull java.lang.String expression)
Adds a time value with the value generated by the time expression
expression - Time expression to use to generate the values@JvmOverloads @NotNull public PactDslJsonArray datetimeExpression(@NotNull java.lang.String expression, @NotNull java.lang.String format)
Adds a datetime value with the value generated by the expression
expression - Datetime expression to use to generate the valuesformat - Datetime format to use@JvmOverloads @NotNull public PactDslJsonArray datetimeExpression(@NotNull java.lang.String expression)
Adds a datetime value with the value generated by the expression
expression - Datetime expression to use to generate the values@JvmOverloads @JvmStatic @NotNull public static PactDslJsonBody arrayEachLike(int numberExamples)
Array where each item must match the following example
numberExamples - Number of examples to generate@JvmOverloads @JvmStatic @NotNull public static PactDslJsonBody arrayEachLike()
Array where each item must match the following example
@JvmStatic @NotNull public static PactDslJsonArray arrayEachLike(@NotNull PactDslJsonRootValue rootValue)
Root level array where each item must match the provided matcher
@JvmStatic @NotNull public static PactDslJsonArray arrayEachLike(int numberExamples, @NotNull PactDslJsonRootValue value)
Root level array where each item must match the provided matcher
numberExamples - Number of examples to generate@JvmOverloads @JvmStatic @NotNull public static PactDslJsonBody arrayMinLike(int minSize, int numberExamples)
Array with a minimum size where each item must match the following example
minSize - minimum sizenumberExamples - Number of examples to generate@JvmOverloads @JvmStatic @NotNull public static PactDslJsonBody arrayMinLike(int minSize)
Array with a minimum size where each item must match the following example
minSize - minimum size@JvmStatic @NotNull public static PactDslJsonArray arrayMinLike(int minSize, @NotNull PactDslJsonRootValue value)
Root level array with minimum size where each item must match the provided matcher
minSize - minimum size@JvmStatic @NotNull public static PactDslJsonArray arrayMinLike(int minSize, int numberExamples, @NotNull PactDslJsonRootValue value)
Root level array with minimum size where each item must match the provided matcher
minSize - minimum sizenumberExamples - Number of examples to generate@JvmOverloads @JvmStatic @NotNull public static PactDslJsonBody arrayMaxLike(int maxSize, int numberExamples)
Array with a maximum size where each item must match the following example
maxSize - maximum sizenumberExamples - Number of examples to generate@JvmOverloads @JvmStatic @NotNull public static PactDslJsonBody arrayMaxLike(int maxSize)
Array with a maximum size where each item must match the following example
maxSize - maximum size@JvmStatic @NotNull public static PactDslJsonArray arrayMaxLike(int maxSize, @NotNull PactDslJsonRootValue value)
Root level array with maximum size where each item must match the provided matcher
maxSize - maximum size@JvmStatic @NotNull public static PactDslJsonArray arrayMaxLike(int maxSize, int numberExamples, @NotNull PactDslJsonRootValue value)
Root level array with maximum size where each item must match the provided matcher
maxSize - maximum sizenumberExamples - Number of examples to generate@JvmOverloads @JvmStatic @NotNull public static PactDslJsonBody arrayMinMaxLike(int minSize, int maxSize, int numberExamples)
Array with a minimum and maximum size where each item must match the following example
minSize - minimum sizemaxSize - maximum sizenumberExamples - Number of examples to generate@JvmOverloads @JvmStatic @NotNull public static PactDslJsonBody arrayMinMaxLike(int minSize, int maxSize)
Array with a minimum and maximum size where each item must match the following example
minSize - minimum sizemaxSize - maximum size@JvmStatic @NotNull public static PactDslJsonArray arrayMinMaxLike(int minSize, int maxSize, @NotNull PactDslJsonRootValue value)
Root level array with minimum and maximum size where each item must match the provided matcher
minSize - minimum sizemaxSize - maximum size@JvmStatic @NotNull public static PactDslJsonArray arrayMinMaxLike(int minSize, int maxSize, int numberExamples, @NotNull PactDslJsonRootValue value)
Root level array with minimum and maximum size where each item must match the provided matcher
minSize - minimum sizemaxSize - maximum sizenumberExamples - Number of examples to generate