public class PactDslJsonArray
extends DslPart
DSL to define a JSON array
public PactDslJsonArray()
Construct a root level array
public PactDslJsonArray(java.lang.String rootPath,
java.lang.String rootName,
DslPart parent)
Construct an array as a child
rootPath - Path to the child arrayrootName - Name to associate the child asparent - Parent to attach the child topublic PactDslJsonArray(java.lang.String rootPath,
java.lang.String rootName,
DslPart parent,
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 copypublic PactDslJsonArray(java.lang.String rootPath,
java.lang.String rootName,
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 cardpublic DslPart closeArray()
Closes the current array
public PactDslJsonBody eachLike(java.lang.String name)
public PactDslJsonBody eachLike(java.lang.String name, int numberExamples)
public PactDslJsonBody eachLike()
Element that is an array where each item must match the following example
public PactDslJsonBody eachLike(int numberExamples)
Element that is an array where each item must match the following example
numberExamples - Number of examples to generatepublic PactDslJsonBody minArrayLike(java.lang.String name, java.lang.Integer size)
public PactDslJsonBody minArrayLike(java.lang.Integer size)
Element that is an array with a minimum size where each item must match the following example
size - minimum size of the arraypublic PactDslJsonBody minArrayLike(java.lang.String name, java.lang.Integer size, int numberExamples)
public PactDslJsonBody minArrayLike(java.lang.Integer 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 generatepublic PactDslJsonBody maxArrayLike(java.lang.String name, java.lang.Integer size)
public PactDslJsonBody maxArrayLike(java.lang.Integer size)
Element that is an array with a maximum size where each item must match the following example
size - maximum size of the arraypublic PactDslJsonBody maxArrayLike(java.lang.String name, java.lang.Integer size, int numberExamples)
public PactDslJsonBody maxArrayLike(java.lang.Integer 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 generateprotected void putObject(DslPart object)
protected void putArray(DslPart object)
public java.lang.Object getBody()
public PactDslJsonArray stringValue(java.lang.String value)
Element that must be the specified value
value - string valuepublic PactDslJsonArray string(java.lang.String value)
Element that must be the specified value
value - string valuepublic PactDslJsonArray numberValue(java.lang.Number value)
public PactDslJsonArray number(java.lang.Number value)
Element that must be the specified value
value - number valuepublic PactDslJsonArray booleanValue(java.lang.Boolean value)
Element that must be the specified value
value - boolean valuepublic PactDslJsonArray stringType()
Element that can be any string
public PactDslJsonArray stringType(java.lang.String example)
Element that can be any string
example - example value to use for generated bodiespublic PactDslJsonArray numberType()
Element that can be any number
public PactDslJsonArray numberType(java.lang.Number number)
Element that can be any number
number - example number to use for generated bodiespublic PactDslJsonArray integerType()
Element that must be an integer
public PactDslJsonArray integerType(java.lang.Long number)
Element that must be an integer
number - example integer value to use for generated bodiespublic PactDslJsonArray decimalType()
Element that must be a decimal value
public PactDslJsonArray decimalType(java.math.BigDecimal number)
Element that must be a decimalType value
number - example decimalType valuepublic PactDslJsonArray decimalType(java.lang.Double number)
Attribute that must be a decimalType value
number - example decimalType valuepublic PactDslJsonArray booleanType()
Element that must be a boolean
public PactDslJsonArray booleanType(java.lang.Boolean example)
Element that must be a boolean
example - example boolean to use for generated bodiespublic PactDslJsonArray stringMatcher(java.lang.String regex, java.lang.String value)
Element that must match the regular expression
regex - regular expressionvalue - example value to use for generated bodiespublic PactDslJsonArray timestamp()
Element that must be an ISO formatted timestamp
public PactDslJsonArray timestamp(java.lang.String format)
Element that must match the given timestamp format
format - timestamp formatpublic PactDslJsonArray timestamp(java.lang.String format, java.util.Date example)
Element that must match the given timestamp format
format - timestamp formatexample - example date and time to use for generated bodiespublic PactDslJsonArray timestamp(java.lang.String format, java.time.Instant example)
Element that must match the given timestamp format
format - timestamp formatexample - example date and time to use for generated bodiespublic PactDslJsonArray date()
Element that must be formatted as an ISO date
public PactDslJsonArray date(java.lang.String format)
Element that must match the provided date format
format - date format to matchpublic PactDslJsonArray date(java.lang.String format, java.util.Date example)
Element that must match the provided date format
format - date format to matchexample - example date to use for generated valuespublic PactDslJsonArray time()
Element that must be an ISO formatted time
public PactDslJsonArray time(java.lang.String format)
Element that must match the given time format
format - time format to matchpublic PactDslJsonArray time(java.lang.String format, java.util.Date example)
Element that must match the given time format
format - time format to matchexample - example time to use for generated bodiespublic PactDslJsonArray ipAddress()
Element that must be an IP4 address
public PactDslJsonBody object(java.lang.String name)
public PactDslJsonBody object()
Element that is a JSON object
public DslPart closeObject()
public DslPart close()
public PactDslJsonArray array(java.lang.String name)
public PactDslJsonArray array()
Element that is a JSON array
public PactDslJsonArray id()
Element that must be a numeric identifier
public PactDslJsonArray id(java.lang.Long id)
Element that must be a numeric identifier
id - example id to use for generated bodiespublic PactDslJsonArray hexValue()
Element that must be encoded as a hexadecimal value
public PactDslJsonArray hexValue(java.lang.String hexValue)
Element that must be encoded as a hexadecimal value
hexValue - example value to use for generated bodiespublic PactDslJsonArray uuid()
Element that must be encoded as an UUID
public PactDslJsonArray uuid(java.lang.String uuid)
Element that must be encoded as an UUID
uuid - example UUID to use for generated bodiespublic PactDslJsonArray template(DslPart template)
Adds the template object to the array
template - template objectpublic PactDslJsonArray template(DslPart template, int occurrences)
Adds a number of template objects to the array
template - template objectoccurrences - number to addpublic java.lang.String toString()
public static PactDslJsonBody arrayEachLike()
Array where each item must match the following example
public static PactDslJsonBody arrayEachLike(java.lang.Integer numberExamples)
Array where each item must match the following example
numberExamples - Number of examples to generatepublic static PactDslJsonArray arrayEachLike(PactDslJsonRootValue rootValue)
Root level array where each item must match the provided matcher
public static PactDslJsonArray arrayEachLike(java.lang.Integer numberExamples, PactDslJsonRootValue value)
Root level array where each item must match the provided matcher
numberExamples - Number of examples to generatepublic static PactDslJsonBody arrayMinLike(int minSize)
Array with a minimum size where each item must match the following example
minSize - minimum sizepublic 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 generatepublic static PactDslJsonArray arrayMinLike(int minSize, PactDslJsonRootValue value)
Root level array with minimum size where each item must match the provided matcher
minSize - minimum sizepublic static PactDslJsonArray arrayMinLike(int minSize, int numberExamples, PactDslJsonRootValue value)
Root level array with minimum size where each item must match the provided matcher
minSize - minimum sizenumberExamples - Number of examples to generatepublic static PactDslJsonBody arrayMaxLike(int maxSize)
Array with a maximum size where each item must match the following example
maxSize - maximum sizepublic 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 generatepublic static PactDslJsonArray arrayMaxLike(int maxSize, PactDslJsonRootValue value)
Root level array with maximum size where each item must match the provided matcher
maxSize - maximum sizepublic static PactDslJsonArray arrayMaxLike(int maxSize, int numberExamples, PactDslJsonRootValue value)
Root level array with maximum size where each item must match the provided matcher
maxSize - maximum sizenumberExamples - Number of examples to generatepublic 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 sizepublic 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 generatepublic static PactDslJsonArray arrayMinMaxLike(int minSize, int maxSize, PactDslJsonRootValue value)
Root level array with minimum and maximum size where each item must match the provided matcher
minSize - minimum sizemaxSize - maximum sizepublic static PactDslJsonArray arrayMinMaxLike(int minSize, int maxSize, int numberExamples, 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 generatepublic PactDslJsonArray nullValue()
Adds a null value to the list
public int getNumberExamples()
Returns the number of example elements to generate for sample bodies
public void setNumberExamples(int numberExamples)
Sets the number of example elements to generate for sample bodies
public PactDslJsonArray eachArrayLike(java.lang.String name)
public PactDslJsonArray eachArrayLike(java.lang.String name, int numberExamples)
public PactDslJsonArray eachArrayLike()
public PactDslJsonArray eachArrayLike(int numberExamples)
public PactDslJsonArray eachArrayWithMaxLike(java.lang.String name, java.lang.Integer size)
public PactDslJsonArray eachArrayWithMaxLike(java.lang.String name, int numberExamples, java.lang.Integer size)
public PactDslJsonArray eachArrayWithMaxLike(java.lang.Integer size)
public PactDslJsonArray eachArrayWithMaxLike(int numberExamples, java.lang.Integer size)
public PactDslJsonArray eachArrayWithMinLike(java.lang.String name, java.lang.Integer size)
public PactDslJsonArray eachArrayWithMinLike(java.lang.String name, int numberExamples, java.lang.Integer size)
public PactDslJsonArray eachArrayWithMinLike(java.lang.Integer size)
public PactDslJsonArray eachArrayWithMinLike(int numberExamples, java.lang.Integer size)
public PactDslJsonArray eachLike(PactDslJsonRootValue value)
Array of values that are not objects where each item must match the provided example
value - Value to use to match each itempublic PactDslJsonArray eachLike(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 itemnumberExamples - number of examples to generatepublic PactDslJsonArray minArrayLike(java.lang.Integer size, 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 itempublic PactDslJsonArray minArrayLike(java.lang.Integer size, 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 generatepublic PactDslJsonArray maxArrayLike(java.lang.Integer size, 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 itempublic PactDslJsonArray maxArrayLike(java.lang.Integer size, 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 generatepublic PactDslJsonArray includesStr(java.lang.String value)
List item that must include the provided string
value - Value that must be includedpublic PactDslJsonArray equalsTo(java.lang.Object value)
Attribute that must be equal to the provided value.
value - Value that will be used for comparisonspublic PactDslJsonArray and(java.lang.Object value, au.com.dius.pact.core.model.matchingrules.MatchingRule... rules)
Combine all the matchers using AND
value - Attribute example valuerules - Matching rules to applypublic PactDslJsonArray or(java.lang.Object value, au.com.dius.pact.core.model.matchingrules.MatchingRule... rules)
Combine all the matchers using OR
value - Attribute example valuerules - Matching rules to applypublic PactDslJsonArray matchUrl(java.lang.String basePath, 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 be excluded from the matchingpathFragments - Series of path fragments to match on. These can be strings or regular expressions.public PactDslJsonBody minMaxArrayLike(java.lang.String name, java.lang.Integer minSize, java.lang.Integer maxSize)
public PactDslJsonBody minMaxArrayLike(java.lang.Integer minSize, java.lang.Integer maxSize)
public PactDslJsonBody minMaxArrayLike(java.lang.String name, java.lang.Integer minSize, java.lang.Integer maxSize, int numberExamples)
public PactDslJsonBody minMaxArrayLike(java.lang.Integer minSize, java.lang.Integer maxSize, int numberExamples)
public PactDslJsonArray eachArrayWithMinMaxLike(java.lang.String name, java.lang.Integer minSize, java.lang.Integer maxSize)
public PactDslJsonArray eachArrayWithMinMaxLike(java.lang.Integer minSize, java.lang.Integer maxSize)
public PactDslJsonArray eachArrayWithMinMaxLike(java.lang.String name, int numberExamples, java.lang.Integer minSize, java.lang.Integer maxSize)
public PactDslJsonArray eachArrayWithMinMaxLike(int numberExamples, java.lang.Integer minSize, java.lang.Integer maxSize)
public PactDslJsonArray valueFromProviderState(java.lang.String expression, 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 testpublic PactDslJsonArray dateExpression(java.lang.String expression)
Adds a date value formatted as an ISO date with the value generated by the date expression
expression - Date expression to use to generate the valuespublic PactDslJsonArray dateExpression(java.lang.String expression, 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 usepublic PactDslJsonArray timeExpression(java.lang.String expression)
Adds a time value formatted as an ISO time with the value generated by the time expression
expression - Time expression to use to generate the valuespublic PactDslJsonArray timeExpression(java.lang.String expression, 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 usepublic PactDslJsonArray datetimeExpression(java.lang.String expression)
Adds a datetime value formatted as an ISO datetime with the value generated by the expression
expression - Datetime expression to use to generate the valuespublic PactDslJsonArray datetimeExpression(java.lang.String expression, 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