public class PactDslJsonBody
extends DslPart
DSL to define a JSON Object
public PactDslJsonBody()
Constructs a new body as a root
public PactDslJsonBody(java.lang.String rootPath, java.lang.String rootName, DslPart parent)
Constructs a new body as a child
rootPath
- Path to prefix to this childrootName
- Name to associate this object as in the parentparent
- Parent to attach topublic PactDslJsonBody(java.lang.String rootPath, java.lang.String rootName, DslPart parent, PactDslJsonBody body)
Constructs a new body as a child as a copy of an existing one
rootPath
- Path to prefix to this childrootName
- Name to associate this object as in the parentparent
- Parent to attach tobody
- Body to copy values frompublic java.lang.String toString()
protected void putObject(DslPart object)
protected void putArray(DslPart object)
public java.lang.Object getBody()
public PactDslJsonBody stringValue(java.lang.String name, java.lang.String value)
Attribute that must be the specified value
name
- attribute namevalue
- string valuepublic PactDslJsonBody numberValue(java.lang.String name, java.lang.Number value)
Attribute that must be the specified number
name
- attribute namevalue
- number valuepublic PactDslJsonBody booleanValue(java.lang.String name, java.lang.Boolean value)
Attribute that must be the specified boolean
name
- attribute namevalue
- boolean valuepublic PactDslJsonBody stringType(java.lang.String name)
Attribute that can be any string
name
- attribute namepublic PactDslJsonBody stringType(java.lang.String... names)
Attributes that can be any string
names
- attribute namespublic PactDslJsonBody stringType(java.lang.String name, java.lang.String example)
Attribute that can be any string
name
- attribute nameexample
- example value to use for generated bodiespublic PactDslJsonBody numberType(java.lang.String name)
Attribute that can be any number
name
- attribute namepublic PactDslJsonBody numberType(java.lang.String... names)
Attributes that can be any number
names
- attribute namespublic PactDslJsonBody numberType(java.lang.String name, java.lang.Number number)
Attribute that can be any number
name
- attribute namenumber
- example number to use for generated bodiespublic PactDslJsonBody integerType(java.lang.String name)
Attribute that must be an integer
name
- attribute namepublic PactDslJsonBody integerType(java.lang.String... names)
Attributes that must be an integer
names
- attribute namespublic PactDslJsonBody integerType(java.lang.String name, java.lang.Long number)
Attribute that must be an integer
name
- attribute namenumber
- example integer value to use for generated bodiespublic PactDslJsonBody integerType(java.lang.String name, java.lang.Integer number)
Attribute that must be an integer
name
- attribute namenumber
- example integer value to use for generated bodiespublic PactDslJsonBody realType(java.lang.String name)
Attribute that must be a real value
name
- attribute namepublic PactDslJsonBody realType(java.lang.String name, java.lang.Double number)
Attribute that must be a real value
name
- attribute namenumber
- example real valuepublic PactDslJsonBody decimalType(java.lang.String name)
Attribute that must be a decimal value
name
- attribute namepublic PactDslJsonBody decimalType(java.lang.String... names)
Attributes that must be a decimal values
names
- attribute namespublic PactDslJsonBody decimalType(java.lang.String name, java.math.BigDecimal number)
Attribute that must be a decimalType value
name
- attribute namenumber
- example decimalType valuepublic PactDslJsonBody decimalType(java.lang.String name, java.lang.Double number)
Attribute that must be a decimalType value
name
- attribute namenumber
- example decimalType valuepublic PactDslJsonBody booleanType(java.lang.String name)
Attribute that must be a boolean
name
- attribute namepublic PactDslJsonBody booleanType(java.lang.String... names)
Attributes that must be a boolean
names
- attribute namespublic PactDslJsonBody booleanType(java.lang.String name, java.lang.Boolean example)
Attribute that must be a boolean
name
- attribute nameexample
- example boolean to use for generated bodiespublic PactDslJsonBody stringMatcher(java.lang.String name, java.lang.String regex, java.lang.String value)
Attribute that must match the regular expression
name
- attribute nameregex
- regular expressionvalue
- example value to use for generated bodiespublic PactDslJsonBody stringMatcher(java.lang.String name, java.lang.String regex)
Attribute that must match the regular expression
name
- attribute nameregex
- regular expressionpublic PactDslJsonBody timestamp()
Attribute named 'timestamp' that must be an ISO formatted timestamp
public PactDslJsonBody timestamp(java.lang.String name)
Attribute that must be an ISO formatted timestamp
name
- public PactDslJsonBody timestamp(java.lang.String name, java.lang.String format)
Attribute that must match the given timestamp format
name
- attribute nameformat
- timestamp formatpublic PactDslJsonBody timestamp(java.lang.String name, java.lang.String format, java.util.Date example)
Attribute that must match the given timestamp format
name
- attribute nameformat
- timestamp formatexample
- example date and time to use for generated bodiespublic PactDslJsonBody timestamp(java.lang.String name, java.lang.String format, java.util.Date example, java.util.TimeZone timeZone)
Attribute that must match the given timestamp format
name
- attribute nameformat
- timestamp formatexample
- example date and time to use for generated bodiestimeZone
- time zone used for formatting of example date and timepublic PactDslJsonBody timestamp(java.lang.String name, java.lang.String format, java.time.Instant example)
Attribute that must match the given timestamp format
name
- attribute nameformat
- timestamp formatexample
- example date and time to use for generated bodiespublic PactDslJsonBody timestamp(java.lang.String name, java.lang.String format, java.time.Instant example, java.util.TimeZone timeZone)
Attribute that must match the given timestamp format
name
- attribute nameformat
- timestamp formatexample
- example date and time to use for generated bodiestimeZone
- time zone used for formatting of example date and timepublic PactDslJsonBody date()
Attribute named 'date' that must be formatted as an ISO date
public PactDslJsonBody date(java.lang.String name)
Attribute that must be formatted as an ISO date
name
- attribute namepublic PactDslJsonBody date(java.lang.String name, java.lang.String format)
Attribute that must match the provided date format
name
- attribute dateformat
- date format to matchpublic PactDslJsonBody date(java.lang.String name, java.lang.String format, java.util.Date example)
Attribute that must match the provided date format
name
- attribute dateformat
- date format to matchexample
- example date to use for generated valuespublic PactDslJsonBody date(java.lang.String name, java.lang.String format, java.util.Date example, java.util.TimeZone timeZone)
Attribute that must match the provided date format
name
- attribute dateformat
- date format to matchexample
- example date to use for generated valuestimeZone
- time zone used for formatting of example datepublic PactDslJsonBody time()
Attribute named 'time' that must be an ISO formatted time
public PactDslJsonBody time(java.lang.String name)
Attribute that must be an ISO formatted time
name
- attribute namepublic PactDslJsonBody time(java.lang.String name, java.lang.String format)
Attribute that must match the given time format
name
- attribute nameformat
- time format to matchpublic PactDslJsonBody time(java.lang.String name, java.lang.String format, java.util.Date example)
Attribute that must match the given time format
name
- attribute nameformat
- time format to matchexample
- example time to use for generated bodiespublic PactDslJsonBody time(java.lang.String name, java.lang.String format, java.util.Date example, java.util.TimeZone timeZone)
Attribute that must match the given time format
name
- attribute nameformat
- time format to matchexample
- example time to use for generated bodiestimeZone
- time zone used for formatting of example timepublic PactDslJsonBody ipAddress(java.lang.String name)
Attribute that must be an IP4 address
name
- attribute namepublic PactDslJsonBody object(java.lang.String name)
Attribute that is a JSON object
name
- field namepublic PactDslJsonBody object()
public PactDslJsonBody object(java.lang.String name, DslPart value)
Attribute that is a JSON object defined from a DSL part
name
- field namevalue
- DSL Part to set the value aspublic DslPart closeObject()
Closes the current JSON object
public DslPart close()
public PactDslJsonArray array(java.lang.String name)
Attribute that is an array
name
- field namepublic PactDslJsonArray array()
public DslPart closeArray()
Closes the current array
public PactDslJsonBody arrayLike(java.lang.String name)
Attribute that is an array where each item must match the following example
name
- field namepublic PactDslJsonBody arrayLike()
public PactDslJsonBody eachLike(java.lang.String name)
Attribute that is an array where each item must match the following example
name
- field namepublic PactDslJsonBody eachLike()
public PactDslJsonBody eachLike(java.lang.String name, int numberExamples)
Attribute that is an array where each item must match the following example
name
- field namenumberExamples
- number of examples to generatepublic PactDslJsonBody eachLike(int numberExamples)
public PactDslJsonBody eachLike(java.lang.String name, PactDslJsonRootValue value)
Attribute that is an array of values that are not objects where each item must match the following example
name
- field namevalue
- Value to use to match each itempublic PactDslJsonBody eachLike(java.lang.String name, PactDslJsonRootValue value, int numberExamples)
Attribute that is an array of values that are not objects where each item must match the following example
name
- field namevalue
- Value to use to match each itemnumberExamples
- number of examples to generatepublic PactDslJsonBody minArrayLike(java.lang.String name, java.lang.Integer size)
Attribute that is an array with a minimum size where each item must match the following example
name
- field namesize
- minimum size of the arraypublic PactDslJsonBody minArrayLike(java.lang.Integer size)
public PactDslJsonBody minArrayLike(java.lang.String name, java.lang.Integer size, int numberExamples)
Attribute that is an array with a minimum size where each item must match the following example
name
- field namesize
- minimum size of the arraynumberExamples
- number of examples to generatepublic PactDslJsonBody minArrayLike(java.lang.Integer size, int numberExamples)
public PactDslJsonBody minArrayLike(java.lang.String name, java.lang.Integer size, PactDslJsonRootValue value)
Attribute that is an array of values with a minimum size that are not objects where each item must match the following example
name
- field namesize
- minimum size of the arrayvalue
- Value to use to match each itempublic PactDslJsonBody minArrayLike(java.lang.String name, java.lang.Integer size, PactDslJsonRootValue value, int numberExamples)
Attribute that is an array of values with a minimum size that are not objects where each item must match the following example
name
- field namesize
- minimum size of the arrayvalue
- Value to use to match each itemnumberExamples
- number of examples to generatepublic PactDslJsonBody maxArrayLike(java.lang.String name, java.lang.Integer size)
Attribute that is an array with a maximum size where each item must match the following example
name
- field namesize
- maximum size of the arraypublic PactDslJsonBody maxArrayLike(java.lang.Integer size)
public PactDslJsonBody maxArrayLike(java.lang.String name, java.lang.Integer size, int numberExamples)
Attribute that is an array with a maximum size where each item must match the following example
name
- field namesize
- maximum size of the arraynumberExamples
- number of examples to generatepublic PactDslJsonBody maxArrayLike(java.lang.Integer size, int numberExamples)
public PactDslJsonBody maxArrayLike(java.lang.String name, java.lang.Integer size, PactDslJsonRootValue value)
Attribute that is an array of values with a maximum size that are not objects where each item must match the following example
name
- field namesize
- maximum size of the arrayvalue
- Value to use to match each itempublic PactDslJsonBody maxArrayLike(java.lang.String name, java.lang.Integer size, PactDslJsonRootValue value, int numberExamples)
Attribute that is an array of values with a maximum size that are not objects where each item must match the following example
name
- field namesize
- maximum size of the arrayvalue
- Value to use to match each itemnumberExamples
- number of examples to generatepublic PactDslJsonBody id()
Attribute named 'id' that must be a numeric identifier
public PactDslJsonBody id(java.lang.String name)
Attribute that must be a numeric identifier
name
- attribute namepublic PactDslJsonBody id(java.lang.String name, java.lang.Long id)
Attribute that must be a numeric identifier
name
- attribute nameid
- example id to use for generated bodiespublic PactDslJsonBody hexValue(java.lang.String name)
Attribute that must be encoded as a hexadecimal value
name
- attribute namepublic PactDslJsonBody hexValue(java.lang.String name, java.lang.String hexValue)
Attribute that must be encoded as a hexadecimal value
name
- attribute namehexValue
- example value to use for generated bodiespublic PactDslJsonBody guid(java.lang.String name)
Attribute that must be encoded as a GUID
name
- attribute namepublic PactDslJsonBody guid(java.lang.String name, java.util.UUID uuid)
Attribute that must be encoded as a GUID
name
- attribute nameuuid
- example UUID to use for generated bodiespublic PactDslJsonBody guid(java.lang.String name, java.lang.String uuid)
Attribute that must be encoded as a GUID
name
- attribute nameuuid
- example UUID to use for generated bodiespublic PactDslJsonBody uuid(java.lang.String name)
Attribute that must be encoded as an UUID
name
- attribute namepublic PactDslJsonBody uuid(java.lang.String name, java.util.UUID uuid)
Attribute that must be encoded as an UUID
name
- attribute nameuuid
- example UUID to use for generated bodiespublic PactDslJsonBody uuid(java.lang.String name, java.lang.String uuid)
Attribute that must be encoded as an UUID
name
- attribute nameuuid
- example UUID to use for generated bodiespublic PactDslJsonBody nullValue(java.lang.String fieldName)
Sets the field to a null value
fieldName
- field namepublic PactDslJsonArray eachArrayLike(java.lang.String name)
public PactDslJsonArray eachArrayLike()
public PactDslJsonArray eachArrayLike(java.lang.String name, int numberExamples)
public PactDslJsonArray eachArrayLike(int numberExamples)
public PactDslJsonArray eachArrayWithMaxLike(java.lang.String name, java.lang.Integer size)
public PactDslJsonArray eachArrayWithMaxLike(java.lang.Integer size)
public PactDslJsonArray eachArrayWithMaxLike(java.lang.String name, int numberExamples, 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.Integer size)
public PactDslJsonArray eachArrayWithMinLike(java.lang.String name, int numberExamples, java.lang.Integer size)
public PactDslJsonArray eachArrayWithMinLike(int numberExamples, java.lang.Integer size)
public PactDslJsonBody eachKeyMappedToAnArrayLike(java.lang.String exampleKey)
Accepts any key, and each key is mapped to a list of items that must match the following object definition Note: this needs the Java system property "pact.matching.wildcard" set to value "true" when the pact file is verified.
exampleKey
- Example key to use for generating bodiespublic PactDslJsonBody eachKeyLike(java.lang.String exampleKey)
Accepts any key, and each key is mapped to a map that must match the following object definition Note: this needs the Java system property "pact.matching.wildcard" set to value "true" when the pact file is verified.
exampleKey
- Example key to use for generating bodiespublic PactDslJsonBody eachKeyLike(java.lang.String exampleKey, PactDslJsonRootValue value)
Accepts any key, and each key is mapped to a map that must match the provided object definition Note: this needs the Java system property "pact.matching.wildcard" set to value "true" when the pact file is verified.
exampleKey
- Example key to use for generating bodiesvalue
- Value to use for matching and generated bodiespublic PactDslJsonBody includesStr(java.lang.String name, java.lang.String value)
Attribute that must include the provided string value
name
- attribute namevalue
- Value that must be includedpublic PactDslJsonBody equalTo(java.lang.String name, java.lang.Object value)
Attribute that must be equal to the provided value.
name
- attribute namevalue
- Value that will be used for comparisonspublic PactDslJsonBody and(java.lang.String name, java.lang.Object value, au.com.dius.pact.core.model.matchingrules.MatchingRule... rules)
Combine all the matchers using AND
name
- Attribute namevalue
- Attribute example valuerules
- Matching rules to applypublic PactDslJsonBody or(java.lang.String name, java.lang.Object value, au.com.dius.pact.core.model.matchingrules.MatchingRule... rules)
Combine all the matchers using OR
name
- Attribute namevalue
- Attribute example valuerules
- Matching rules to applypublic PactDslJsonBody matchUrl(java.lang.String name, java.lang.String basePath, 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.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 PactDslJsonBody minMaxArrayLike(java.lang.String name, java.lang.Integer minSize, java.lang.Integer maxSize, PactDslJsonRootValue value, int numberExamples)
Attribute that is an array of values with a minimum and maximum size that are not objects where each item must match the following example
name
- field nameminSize
- minimum sizemaxSize
- maximum sizevalue
- Value to use to match each itemnumberExamples
- number of examples to generatepublic PactDslJsonBody valueFromProviderState(java.lang.String name, java.lang.String expression, java.lang.Object example)
Adds an attribute that will have it's value injected from the provider state
name
- Attribute nameexpression
- Expression to be evaluated from the provider stateexample
- Example value to be used in the consumer testpublic PactDslJsonBody dateExpression(java.lang.String name, java.lang.String expression)
Adds a date attribute formatted as an ISO date with the value generated by the date expression
name
- Attribute nameexpression
- Date expression to use to generate the valuespublic PactDslJsonBody dateExpression(java.lang.String name, java.lang.String expression, java.lang.String format)
Adds a date attribute with the value generated by the date expression
name
- Attribute nameexpression
- Date expression to use to generate the valuesformat
- Date format to usepublic PactDslJsonBody timeExpression(java.lang.String name, java.lang.String expression)
Adds a time attribute formatted as an ISO time with the value generated by the time expression
name
- Attribute nameexpression
- Time expression to use to generate the valuespublic PactDslJsonBody timeExpression(java.lang.String name, java.lang.String expression, java.lang.String format)
Adds a time attribute with the value generated by the time expression
name
- Attribute nameexpression
- Time expression to use to generate the valuesformat
- Time format to usepublic PactDslJsonBody datetimeExpression(java.lang.String name, java.lang.String expression)
Adds a datetime attribute formatted as an ISO datetime with the value generated by the expression
name
- Attribute nameexpression
- Datetime expression to use to generate the valuespublic PactDslJsonBody datetimeExpression(java.lang.String name, java.lang.String expression, java.lang.String format)
Adds a datetime attribute with the value generated by the expression
name
- Attribute nameexpression
- Datetime expression to use to generate the valuesformat
- Datetime format to use