Package au.com.dius.pact.consumer.dsl
Class LambdaDslObject
java.lang.Object
au.com.dius.pact.consumer.dsl.LambdaDslObject
- Direct Known Subclasses:
LambdaDslJsonBody
-
Method Summary
Modifier and TypeMethodDescriptionCombine all the matchers using ANDarray
(String name, Consumer<LambdaDslJsonArray> array) Attribute that is an arrayarrayContaining
(String name, Consumer<LambdaDslJsonArray> nestedArray) Matches the items in an array against a number of variants.booleanType
(String... names) Attributes that must be a booleanbooleanType
(String name, Boolean example) Attribute that must be a booleanbooleanValue
(String name, Boolean value) Attribute that must be the specified booleandate()
Attribute named 'date' that must be formatted as an ISO dateAttribute that must be formatted as an ISO dateAttribute that must match the provided date formatAttribute that must match the provided date formatdate
(String name, String format, ZonedDateTime example) Attribute that must match the provided date formatAttribute that must match the provided date formatAttribute that must match the provided date formatdateExpression
(String name, String expression) Attribute whose values are generated from the provided expression.dateExpression
(String name, String expression, String format) Attribute whose values are generated from the provided expressionDeprecated.Use datetimeAttribute that must match the given datetime formatAttribute that must match the given datetime formatdatetime
(String name, String format, ZonedDateTime example) Attribute that must match the given timestamp formatAttribute that must match the given datetime formatAttribute that must match the given datetime formatdatetimeExpression
(String name, String expression) Attribute whose values are generated from the provided expression.datetimeExpression
(String name, String expression, String format) Attribute whose values are generated from the provided expressiondecimalMatching
(String name, String regex, Double example) Attribute that can be any number decimal number (has significant digits after the decimal point) and which must match the provided regular expressiondecimalType
(String... names) Attributes that must be decimal values (have significant digits after the decimal point)decimalType
(String name, Double example) Attribute that must be a decimalType value (has significant digits after the decimal point)decimalType
(String name, BigDecimal example) Attribute that must be a decimalType value (has significant digits after the decimal point)eachArrayLike
(String name, int numberExamples, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following objecteachArrayLike
(String name, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following objecteachArrayWithMaxLike
(String name, int numberExamples, Integer size, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following objecteachArrayWithMaxLike
(String name, Integer size, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following object.eachArrayWithMinLike
(String name, int numberExamples, Integer size, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following objecteachArrayWithMinLike
(String name, Integer size, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following object.eachArrayWithMinMaxLike
(String name, Integer minSize, Integer maxSize, int numberExamples, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following objecteachArrayWithMinMaxLike
(String name, Integer minSize, Integer maxSize, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following object.eachKeyLike
(String exampleKey, au.com.dius.pact.consumer.dsl.PactDslJsonRootValue value) Accepts any key, and each key is mapped to a map that must match the provided object definitioneachKeyLike
(String exampleKey, Consumer<LambdaDslObject> nestedObject) Accepts any key, and each key is mapped to a map that must match the following object definition.eachKeyMappedToAnArrayLike
(String exampleKey, Consumer<LambdaDslObject> nestedObject) Accepts any key, and each key is mapped to a list of items that must match the following object definition.eachLike
(String name, int numberExamples, Consumer<LambdaDslObject> nestedObject) Attribute that is an array where each item must match the following exampleAttribute that is an array where each item is a primitive that must match the provided valueAttribute that is an array where each item is a primitive that must match the provided valueeachLike
(String name, Consumer<LambdaDslObject> nestedObject) Attribute that is an array where each item must match the following exampleau.com.dius.pact.consumer.dsl.PactDslJsonBody
Get the rawPactDslJsonBody
which is abstracted withLambdaDslObject
id()
Attribute named 'id' that must be a numeric identifierAttribute that must be a numeric identifierAttribute that must be a numeric identifierintegerMatching
(String name, String regex, Integer example) Attribute that can be any integer and which must match the provided regular expressionintegerType
(String... names) Attributes that must be an integerintegerType
(String name, Integer example) Attribute that must be an integeripV4Address
(String name) Attribute that must be an IP4 addressMatches a URL that is composed of a base path and a sequence of path expressionsMatches a URL that is composed of a base path and a sequence of path expressions.maxArrayLike
(String name, Integer size, int numberExamples, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a maximum size where each item must match the following examplemaxArrayLike
(String name, Integer size, au.com.dius.pact.consumer.dsl.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 examplemaxArrayLike
(String name, Integer size, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a maximum size where each item must match the following exampleminArrayLike
(String name, Integer size, int numberExamples, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a minimum size where each item must match the following exampleminArrayLike
(String name, Integer size, au.com.dius.pact.consumer.dsl.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 exampleminArrayLike
(String name, Integer size, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a minimum size where each item must match the following exampleminMaxArrayLike
(String name, Integer minSize, Integer maxSize, int numberExamples, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a minimum and maximum size where each item must match the following exampleminMaxArrayLike
(String name, Integer minSize, Integer maxSize, au.com.dius.pact.consumer.dsl.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 exampleminMaxArrayLike
(String name, Integer minSize, Integer maxSize, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a minimum and maximum size where each item must match the following exampleSets the field to a null valuenumberMatching
(String name, String regex, Number example) Attribute that can be any number and which must match the provided regular expressionnumberType
(String... names) Attributes that can be any numbernumberType
(String name, Number example) Attribute that can be any numbernumberValue
(String name, Number value) Attribute that must be the specified numberobject
(String name, Consumer<LambdaDslObject> nestedObject) Attribute that is a JSON objectCombine all the matchers using ORstringMatcher
(String name, String regex) Attribute that must match the regular expressionstringMatcher
(String name, String regex, String example) Attribute that must match the regular expressionstringType
(String name) Attribute that can be any stringstringType
(String... names) Attributes that can be any stringstringType
(String name, String example) Attribute that can be any stringstringValue
(String name, String value) Attribute that must be the specified valuetime()
Attribute named 'time' that must be an ISO formatted timeAttribute that must be an ISO formatted timeAttribute that must match the provided time formattime
(String name, String format, ZonedDateTime example) Attribute that must match the provided time formatAttribute that must match the provided time formatAttribute that must match the provided time formattimeExpression
(String name, String expression) Attribute whose values are generated from the provided expression.timeExpression
(String name, String expression, String format) Attribute whose values are generated from the provided expressionDeprecated.Use datetimeunorderedArray
(String name, Consumer<LambdaDslJsonArray> nestedArray) Array field where order is ignoredunorderedMaxArray
(String name, int size, Consumer<LambdaDslJsonArray> nestedArray) Array field of max size where order is ignoredunorderedMinArray
(String name, int size, Consumer<LambdaDslJsonArray> nestedArray) Array field of min size where order is ignoredunorderedMinMaxArray
(String name, int minSize, int maxSize, Consumer<LambdaDslJsonArray> nestedArray) Array field of min and max size where order is ignoredAttribute that must be encoded as an UUIDAttribute that must be encoded as an UUIDvalueFromProviderState
(String name, String expression, Object example) Attribute that will have its value injected from the provider state
-
Method Details
-
getPactDslObject
public au.com.dius.pact.consumer.dsl.PactDslJsonBody getPactDslObject()Get the rawPactDslJsonBody
which is abstracted withLambdaDslObject
-
stringValue
Attribute that must be the specified value- Parameters:
name
- attribute namevalue
- string value
-
stringType
Attribute that can be any string- Parameters:
name
- attribute nameexample
- example value to use for generated bodies
-
stringType
Attribute that can be any string- Parameters:
name
- attribute name
-
stringType
Attributes that can be any string- Parameters:
names
- attribute names
-
stringMatcher
Attribute that must match the regular expression- Parameters:
name
- attribute nameregex
- regular expression
-
stringMatcher
Attribute that must match the regular expression- Parameters:
name
- attribute nameregex
- regular expressionexample
- example value to use for generated bodies
-
numberValue
Attribute that must be the specified number- Parameters:
name
- attribute namevalue
- number value
-
numberType
Attribute that can be any number- Parameters:
name
- attribute nameexample
- example number to use for generated bodies
-
numberType
Attributes that can be any number- Parameters:
names
- attribute names
-
integerType
Attribute that must be an integer- Parameters:
name
- attribute nameexample
- example integer value to use for generated bodies
-
integerType
Attributes that must be an integer- Parameters:
names
- attribute names
-
decimalType
Attribute that must be a decimalType value (has significant digits after the decimal point)- Parameters:
name
- attribute nameexample
- example decimalType value
-
decimalType
Attribute that must be a decimalType value (has significant digits after the decimal point)- Parameters:
name
- attribute nameexample
- example decimalType value
-
decimalType
Attributes that must be decimal values (have significant digits after the decimal point)- Parameters:
names
- attribute names
-
numberMatching
Attribute that can be any number and which must match the provided regular expression- Parameters:
name
- attribute nameregex
- Regular expression that the numbers string form must matchexample
- example number to use for generated bodies
-
decimalMatching
Attribute that can be any number decimal number (has significant digits after the decimal point) and which must match the provided regular expression- Parameters:
name
- attribute nameregex
- Regular expression that the numbers string form must matchexample
- example number to use for generated bodies
-
integerMatching
Attribute that can be any integer and which must match the provided regular expression- Parameters:
name
- attribute nameregex
- Regular expression that the numbers string form must matchexample
- example integer to use for generated bodies
-
booleanValue
Attribute that must be the specified boolean- Parameters:
name
- attribute namevalue
- boolean value
-
booleanType
Attribute that must be a boolean- Parameters:
name
- attribute nameexample
- example boolean to use for generated bodies
-
booleanType
Attributes that must be a boolean- Parameters:
names
- attribute names
-
id
Attribute named 'id' that must be a numeric identifier -
id
Attribute that must be a numeric identifier- Parameters:
name
- attribute name
-
id
Attribute that must be a numeric identifier- Parameters:
name
- attribute nameexample
- example id to use for generated bodies
-
uuid
Attribute that must be encoded as an UUID- Parameters:
name
- attribute name
-
uuid
Attribute that must be encoded as an UUID- Parameters:
name
- attribute nameexample
- example UUID to use for generated bodies
-
date
Attribute named 'date' that must be formatted as an ISO date -
date
Attribute that must be formatted as an ISO date- Parameters:
name
- attribute name
-
date
Attribute that must match the provided date format- Parameters:
name
- attribute dateformat
- date format to match
-
date
Attribute that must match the provided date format- Parameters:
name
- attribute dateformat
- date format to matchexample
- example date to use for generated values
-
date
Attribute that must match the provided date format- Parameters:
name
- attribute dateformat
- date format to matchexample
- example date to use for generated valuestimeZone
- time zone used for formatting of example date
-
date
Attribute that must match the provided date format- Parameters:
name
- attribute dateformat
- date format to matchexample
- example date to use for generated values
-
date
Attribute that must match the provided date format- Parameters:
name
- attribute dateformat
- date format to matchexample
- example date to use for generated values
-
time
Attribute named 'time' that must be an ISO formatted time -
time
Attribute that must be an ISO formatted time- Parameters:
name
- attribute name
-
time
Attribute that must match the provided time format- Parameters:
name
- attribute timeformat
- time format to match
-
time
Attribute that must match the provided time format- Parameters:
name
- attribute nameformat
- time format to matchexample
- example time to use for generated values
-
time
Attribute that must match the provided time format- Parameters:
name
- attribute nameformat
- time format to matchexample
- example time to use for generated valuestimeZone
- time zone used for formatting of example time
-
time
Attribute that must match the provided time format- Parameters:
name
- attribute nameformat
- time format to matchexample
- example time to use for generated values
-
timestamp
Deprecated.Use datetimeAttribute named 'timestamp' that must be an ISO formatted timestamp -
datetime
Deprecated.Use datetimeAttribute that must be an ISO formatted datetime- Parameters:
name
- attribute name
-
datetime
Attribute that must match the given datetime format- Parameters:
name
- attribute nameformat
- datetime format
-
datetime
Attribute that must match the given datetime format- Parameters:
name
- attribute nameformat
- datetime formatexample
- example date and time to use for generated bodies
-
datetime
Attribute that must match the given datetime format- Parameters:
name
- attribute nameformat
- datetime formatexample
- example date and time to use for generated bodies
-
datetime
Attribute that must match the given datetime format- Parameters:
name
- attribute nameformat
- datetime formatexample
- example date and time to use for generated bodiestimeZone
- time zone used for formatting of example date and time
-
datetime
Attribute that must match the given timestamp format- Parameters:
name
- attribute nameformat
- datetime formatexample
- example date and time to use for generated bodies
-
ipV4Address
Attribute that must be an IP4 address- Parameters:
name
- attribute name
-
valueFromProviderState
Attribute that will have its value injected from the provider state- Parameters:
name
- Attribute nameexpression
- Expression to be evaluated from the provider stateexample
- Example value to be used in the consumer test
-
and
public LambdaDslObject and(String name, Object value, au.com.dius.pact.core.model.matchingrules.MatchingRule... rules) Combine all the matchers using AND- Parameters:
name
- Attribute namevalue
- Attribute example valuerules
- Matching rules to apply
-
or
public LambdaDslObject or(String name, Object value, au.com.dius.pact.core.model.matchingrules.MatchingRule... rules) Combine all the matchers using OR- Parameters:
name
- Attribute namevalue
- Attribute example valuerules
- Matching rules to apply
-
array
Attribute that is an array- Parameters:
name
- field name
-
object
Attribute that is a JSON object- Parameters:
name
- field name
-
eachLike
Attribute that is an array where each item must match the following example- Parameters:
name
- field name
-
eachLike
public LambdaDslObject eachLike(String name, int numberExamples, Consumer<LambdaDslObject> nestedObject) Attribute that is an array where each item must match the following example- Parameters:
name
- field namenumberExamples
- number of examples to generate
-
eachLike
public LambdaDslObject eachLike(String name, au.com.dius.pact.consumer.dsl.PactDslJsonRootValue value) Attribute that is an array where each item is a primitive that must match the provided value- Parameters:
name
- field namevalue
- Value that each item in the array must match
-
eachLike
public LambdaDslObject eachLike(String name, au.com.dius.pact.consumer.dsl.PactDslJsonRootValue value, int numberExamples) Attribute that is an array where each item is a primitive that must match the provided value- Parameters:
name
- field namevalue
- Value that each item in the array must matchnumberExamples
- Number of examples to generate
-
minArrayLike
public LambdaDslObject minArrayLike(String name, Integer size, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a minimum size where each item must match the following example- Parameters:
name
- field namesize
- minimum size of the array
-
minArrayLike
public LambdaDslObject minArrayLike(String name, Integer size, int numberExamples, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a minimum size where each item must match the following example- Parameters:
name
- field namesize
- minimum size of the arraynumberExamples
- number of examples to generate
-
minArrayLike
public LambdaDslObject minArrayLike(String name, Integer size, au.com.dius.pact.consumer.dsl.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- Parameters:
name
- field namesize
- minimum size of the arrayvalue
- Value to use to match each itemnumberExamples
- number of examples to generate
-
maxArrayLike
public LambdaDslObject maxArrayLike(String name, Integer size, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a maximum size where each item must match the following example- Parameters:
name
- field namesize
- maximum size of the array
-
maxArrayLike
public LambdaDslObject maxArrayLike(String name, Integer size, int numberExamples, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a maximum size where each item must match the following example- Parameters:
name
- field namesize
- maximum size of the arraynumberExamples
- number of examples to generate
-
maxArrayLike
public LambdaDslObject maxArrayLike(String name, Integer size, au.com.dius.pact.consumer.dsl.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- Parameters:
name
- field namesize
- maximum size of the arrayvalue
- Value to use to match each itemnumberExamples
- number of examples to generate
-
minMaxArrayLike
public LambdaDslObject minMaxArrayLike(String name, Integer minSize, Integer maxSize, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a minimum and maximum size where each item must match the following example- Parameters:
name
- field nameminSize
- minimum size of the arraymaxSize
- maximum size of the array
-
minMaxArrayLike
public LambdaDslObject minMaxArrayLike(String name, Integer minSize, Integer maxSize, int numberExamples, Consumer<LambdaDslObject> nestedObject) Attribute that is an array with a minimum and maximum size where each item must match the following example- Parameters:
name
- field nameminSize
- minimum size of the arraymaxSize
- maximum size of the arraynumberExamples
- number of examples to generate
-
minMaxArrayLike
public LambdaDslObject minMaxArrayLike(String name, Integer minSize, Integer maxSize, au.com.dius.pact.consumer.dsl.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- Parameters:
name
- field nameminSize
- minimum size of the arraymaxSize
- maximum size of the arrayvalue
- Value to use to match each itemnumberExamples
- number of examples to generate
-
nullValue
Sets the field to a null value- Parameters:
fieldName
- field name
-
eachArrayLike
Array field where each element is an array and must match the following object- Parameters:
name
- field name
-
eachArrayLike
public LambdaDslObject eachArrayLike(String name, int numberExamples, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following object- Parameters:
name
- field namenumberExamples
- number of examples to generate
-
eachArrayWithMaxLike
public LambdaDslObject eachArrayWithMaxLike(String name, Integer size, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following object. This will generate 1 example value, if you want to change that number useeachArrayWithMaxLike(String, int, Integer, Consumer)
- Parameters:
name
- field namesize
- Maximum size of the outer array
-
eachArrayWithMaxLike
public LambdaDslObject eachArrayWithMaxLike(String name, int numberExamples, Integer size, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following object- Parameters:
name
- field namenumberExamples
- number of examples to generatesize
- Maximum size of the outer array
-
eachArrayWithMinLike
public LambdaDslObject eachArrayWithMinLike(String name, Integer size, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following object. This will generate 1 example value, if you want to change that number useeachArrayWithMinLike(String, int, Integer, Consumer)
- Parameters:
name
- field namesize
- Minimum size of the outer array
-
eachArrayWithMinLike
public LambdaDslObject eachArrayWithMinLike(String name, int numberExamples, Integer size, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following object- Parameters:
name
- field namenumberExamples
- number of examples to generatesize
- Minimum size of the outer array
-
eachArrayWithMinMaxLike
public LambdaDslObject eachArrayWithMinMaxLike(String name, Integer minSize, Integer maxSize, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following object. This will generate 1 example value, if you want to change that number useeachArrayWithMinMaxLike(String, Integer, Integer, int, Consumer)
- Parameters:
name
- field nameminSize
- minimum sizemaxSize
- maximum size
-
eachArrayWithMinMaxLike
public LambdaDslObject eachArrayWithMinMaxLike(String name, Integer minSize, Integer maxSize, int numberExamples, Consumer<LambdaDslJsonArray> nestedArray) Array field where each element is an array and must match the following object- Parameters:
name
- field namenumberExamples
- number of examples to generateminSize
- minimum sizemaxSize
- maximum size
-
eachKeyMappedToAnArrayLike
public LambdaDslObject eachKeyMappedToAnArrayLike(String exampleKey, Consumer<LambdaDslObject> nestedObject) Accepts any key, and each key is mapped to a list of items that must match the following object definition.- Parameters:
exampleKey
- Example key to use for generating bodies
-
eachKeyLike
Accepts any key, and each key is mapped to a map that must match the following object definition.- Parameters:
exampleKey
- Example key to use for generating bodies
-
eachKeyLike
public LambdaDslObject eachKeyLike(String exampleKey, au.com.dius.pact.consumer.dsl.PactDslJsonRootValue value) Accepts any key, and each key is mapped to a map that must match the provided object definition- Parameters:
exampleKey
- Example key to use for generating bodiesvalue
- Value to use for matching and generated bodies
-
dateExpression
Attribute whose values are generated from the provided expression. Will use an ISO format.- Parameters:
name
- Attribute nameexpression
- Date expression
-
dateExpression
Attribute whose values are generated from the provided expression- Parameters:
name
- Attribute nameexpression
- Date expressionformat
- Date format to use for values
-
timeExpression
Attribute whose values are generated from the provided expression. Will use an ISO format.- Parameters:
name
- Attribute nameexpression
- Time expression
-
timeExpression
Attribute whose values are generated from the provided expression- Parameters:
name
- Attribute nameexpression
- Time expressionformat
- Time format to use for values
-
datetimeExpression
Attribute whose values are generated from the provided expression. Will use an ISO format.- Parameters:
name
- Attribute nameexpression
- Datetime expression
-
datetimeExpression
Attribute whose values are generated from the provided expression- Parameters:
name
- Attribute nameexpression
- Datetime expressionformat
- Datetime format to use for values
-
unorderedArray
Array field where order is ignored- Parameters:
name
- field name
-
unorderedMinArray
public LambdaDslObject unorderedMinArray(String name, int size, Consumer<LambdaDslJsonArray> nestedArray) Array field of min size where order is ignored- Parameters:
name
- field namesize
- minimum size
-
unorderedMaxArray
public LambdaDslObject unorderedMaxArray(String name, int size, Consumer<LambdaDslJsonArray> nestedArray) Array field of max size where order is ignored- Parameters:
name
- field namesize
- maximum size
-
unorderedMinMaxArray
public LambdaDslObject unorderedMinMaxArray(String name, int minSize, int maxSize, Consumer<LambdaDslJsonArray> nestedArray) Array field of min and max size where order is ignored- Parameters:
name
- field nameminSize
- minimum sizemaxSize
- maximum size
-
matchUrl
Matches a URL that is composed of a base path and a sequence of path expressions- Parameters:
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.
-
matchUrl2
Matches a URL that is composed of a base path and a sequence of path expressions. The base path of the mock server will be used.- Parameters:
name
- Attribute namepathFragments
- Series of path fragments to match on. These can be strings or regular expressions.
-
arrayContaining
Matches the items in an array against a number of variants. Matching is successful if each variant occurs once in the array. Variants may be objects containing matching rules.- Parameters:
name
- Attribute name
-