Class DslPart
-
- All Implemented Interfaces:
public abstract class DslPart
Abstract base class to support Object and Array JSON DSL builders
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
DslPart.Companion
-
Method Summary
Modifier and Type Method Description final DslPart
getParent()
Returns the parent of this part (object or array) final String
getRootPath()
final String
getRootName()
final MatchingRuleCategory
getMatchers()
final Unit
setMatchers(MatchingRuleCategory matchers)
final Generators
getGenerators()
final Unit
setGenerators(Generators generators)
abstract JsonValue
getBody()
abstract Unit
setBody(JsonValue body)
abstract Unit
putObjectPrivate(DslPart obj)
abstract Unit
putArrayPrivate(DslPart obj)
abstract PactDslJsonArray
array(String name)
Field which is an array abstract PactDslJsonArray
array()
Element as an array abstract PactDslJsonArray
unorderedArray(String name)
Array field where order is ignored abstract PactDslJsonArray
unorderedArray()
Array element where order is ignored abstract PactDslJsonArray
unorderedMinArray(String name, Integer size)
Array field of min size where order is ignored abstract PactDslJsonArray
unorderedMinArray(Integer size)
Array element of min size where order is ignored abstract PactDslJsonArray
unorderedMaxArray(String name, Integer size)
Array field of max size where order is ignored abstract PactDslJsonArray
unorderedMaxArray(Integer size)
Array element of max size where order is ignored abstract PactDslJsonArray
unorderedMinMaxArray(String name, Integer minSize, Integer maxSize)
Array field of min and max size where order is ignored abstract PactDslJsonArray
unorderedMinMaxArray(Integer minSize, Integer maxSize)
Array element of min and max size where order is ignored abstract DslPart
closeArray()
Close of the previous array element abstract PactDslJsonBody
eachLike(String name)
Array field where each element must match the following object abstract PactDslJsonBody
eachLike(String name, DslPart obj)
Array field where each element must match the following object abstract PactDslJsonBody
eachLike()
Array element where each element of the array must match the following object abstract PactDslJsonArray
eachLike(DslPart obj)
Array element where each element of the array must match the provided object abstract PactDslJsonBody
eachLike(String name, Integer numberExamples)
Array field where each element must match the following object abstract PactDslJsonBody
eachLike(Integer numberExamples)
Array element where each element of the array must match the following object abstract PactDslJsonBody
minArrayLike(String name, Integer size)
Array field with a minimum size and each element must match the following object abstract PactDslJsonBody
minArrayLike(Integer size)
Array element with a minimum size and each element of the array must match the following object abstract PactDslJsonBody
minArrayLike(String name, Integer size, DslPart obj)
Array field with a minimum size and each element must match the provided object abstract PactDslJsonArray
minArrayLike(Integer size, DslPart obj)
Array element with a minumum size and each element of the array must match the provided object abstract PactDslJsonBody
minArrayLike(String name, Integer size, Integer numberExamples)
Array field with a minumum size and each element must match the following object abstract PactDslJsonBody
minArrayLike(Integer size, Integer numberExamples)
Array element with a minimum size and each element of the array must match the following object abstract PactDslJsonBody
maxArrayLike(String name, Integer size)
Array field with a maximum size and each element must match the following object abstract PactDslJsonBody
maxArrayLike(Integer size)
Array element with a maximum size and each element of the array must match the following object abstract PactDslJsonBody
maxArrayLike(String name, Integer size, DslPart obj)
Array field with a maximum size and each element must match the provided object abstract PactDslJsonArray
maxArrayLike(Integer size, DslPart obj)
Array element with a maximum size and each element of the array must match the provided object abstract PactDslJsonBody
maxArrayLike(String name, Integer size, Integer numberExamples)
Array field with a maximum size and each element must match the following object abstract PactDslJsonBody
maxArrayLike(Integer size, Integer numberExamples)
Array element with a maximum size and each element of the array must match the following object abstract PactDslJsonBody
minMaxArrayLike(String name, Integer minSize, Integer maxSize)
Array field with a minimum and maximum size and each element must match the following object abstract PactDslJsonBody
minMaxArrayLike(String name, Integer minSize, Integer maxSize, DslPart obj)
Array field with a minimum and maximum size and each element must match the provided object abstract PactDslJsonBody
minMaxArrayLike(Integer minSize, Integer maxSize)
Array element with a minimum and maximum size and each element of the array must match the following object abstract PactDslJsonArray
minMaxArrayLike(Integer minSize, Integer maxSize, DslPart obj)
Array element with a minimum and maximum size and each element of the array must match the provided object abstract PactDslJsonBody
minMaxArrayLike(String name, Integer minSize, Integer maxSize, Integer numberExamples)
Array field with a minimum and maximum size and each element must match the following object abstract PactDslJsonBody
minMaxArrayLike(Integer minSize, Integer maxSize, Integer numberExamples)
Array element with a minimum and maximum size and each element of the array must match the following object abstract PactDslJsonArray
eachArrayLike(String name)
Array field where each element is an array and must match the following object abstract PactDslJsonArray
eachArrayLike()
Array element where each element of the array is an array and must match the following object abstract PactDslJsonArray
eachArrayLike(String name, Integer numberExamples)
Array field where each element is an array and must match the following object abstract PactDslJsonArray
eachArrayLike(Integer numberExamples)
Array element where each element of the array is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMaxLike(String name, Integer size)
Array field where each element is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMaxLike(Integer size)
Array element where each element of the array is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMaxLike(String name, Integer numberExamples, Integer size)
Array field where each element is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMaxLike(Integer numberExamples, Integer size)
Array element where each element of the array is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMinLike(String name, Integer size)
Array field where each element is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMinLike(Integer size)
Array element where each element of the array is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMinLike(String name, Integer numberExamples, Integer size)
Array field where each element is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMinLike(Integer numberExamples, Integer size)
Array element where each element of the array is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMinMaxLike(String name, Integer minSize, Integer maxSize)
Array field where each element is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMinMaxLike(Integer minSize, Integer maxSize)
Array element where each element of the array is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMinMaxLike(String name, Integer numberExamples, Integer minSize, Integer maxSize)
Array field where each element is an array and must match the following object abstract PactDslJsonArray
eachArrayWithMinMaxLike(Integer numberExamples, Integer minSize, Integer maxSize)
Array element where each element of the array is an array and must match the following object abstract PactDslJsonBody
object(String name)
Object field abstract PactDslJsonBody
object()
Object element abstract DslPart
closeObject()
Close off the previous object final PactDslJsonBody
asBody()
final PactDslJsonArray
asArray()
abstract DslPart
close()
This closes off the object graph build from the DSL in case any closeObject|Array methods have not been called. abstract DslPart
matchUrl(String name, String basePath, Object pathFragments)
Matches a URL that is composed of a base path and a sequence of path expressions abstract DslPart
matchUrl(String basePath, Object pathFragments)
Matches a URL that is composed of a base path and a sequence of path expressions abstract DslPart
matchUrl2(String name, Object pathFragments)
Matches a URL that is composed of a base path and a sequence of path expressions. abstract DslPart
matchUrl2(Object pathFragments)
Matches a URL that is composed of a base path and a sequence of path expressions. abstract DslPart
arrayContaining(String name)
Matches the items in an array against a number of variants. final static RegexMatcher
regex(String regex, String example)
Returns a regular expression matcher final static RegexMatcher
regex(String regex)
Returns a regular expression matcher. -
-
Method Detail
-
getRootPath
final String getRootPath()
-
getRootName
final String getRootName()
-
getMatchers
final MatchingRuleCategory getMatchers()
-
setMatchers
final Unit setMatchers(MatchingRuleCategory matchers)
-
getGenerators
final Generators getGenerators()
-
setGenerators
final Unit setGenerators(Generators generators)
-
getBody
abstract JsonValue getBody()
-
putObjectPrivate
abstract Unit putObjectPrivate(DslPart obj)
-
putArrayPrivate
abstract Unit putArrayPrivate(DslPart obj)
-
array
abstract PactDslJsonArray array(String name)
Field which is an array
- Parameters:
name
- field name
-
array
abstract PactDslJsonArray array()
Element as an array
-
unorderedArray
abstract PactDslJsonArray unorderedArray(String name)
Array field where order is ignored
- Parameters:
name
- field name
-
unorderedArray
abstract PactDslJsonArray unorderedArray()
Array element where order is ignored
-
unorderedMinArray
abstract PactDslJsonArray unorderedMinArray(String name, Integer size)
Array field of min size where order is ignored
- Parameters:
name
- field namesize
- minimum size
-
unorderedMinArray
abstract PactDslJsonArray unorderedMinArray(Integer size)
Array element of min size where order is ignored
- Parameters:
size
- minimum size
-
unorderedMaxArray
abstract PactDslJsonArray unorderedMaxArray(String name, Integer size)
Array field of max size where order is ignored
- Parameters:
name
- field namesize
- maximum size
-
unorderedMaxArray
abstract PactDslJsonArray unorderedMaxArray(Integer size)
Array element of max size where order is ignored
- Parameters:
size
- maximum size
-
unorderedMinMaxArray
abstract PactDslJsonArray unorderedMinMaxArray(String name, Integer minSize, Integer maxSize)
Array field of min and max size where order is ignored
- Parameters:
name
- field nameminSize
- minimum sizemaxSize
- maximum size
-
unorderedMinMaxArray
abstract PactDslJsonArray unorderedMinMaxArray(Integer minSize, Integer maxSize)
Array element of min and max size where order is ignored
- Parameters:
minSize
- minimum sizemaxSize
- maximum size
-
closeArray
abstract DslPart closeArray()
Close of the previous array element
-
eachLike
abstract PactDslJsonBody eachLike(String name)
Array field where each element must match the following object
- Parameters:
name
- field name
-
eachLike
abstract PactDslJsonBody eachLike(String name, DslPart obj)
Array field where each element must match the following object
- Parameters:
name
- field name
-
eachLike
abstract PactDslJsonBody eachLike()
Array element where each element of the array must match the following object
-
eachLike
abstract PactDslJsonArray eachLike(DslPart obj)
Array element where each element of the array must match the provided object
-
eachLike
abstract PactDslJsonBody eachLike(String name, Integer numberExamples)
Array field where each element must match the following object
- Parameters:
name
- field namenumberExamples
- number of examples to generate
-
eachLike
abstract PactDslJsonBody eachLike(Integer numberExamples)
Array element where each element of the array must match the following object
- Parameters:
numberExamples
- number of examples to generate
-
minArrayLike
abstract PactDslJsonBody minArrayLike(String name, Integer size)
Array field with a minimum size and each element must match the following object
- Parameters:
name
- field namesize
- minimum size
-
minArrayLike
abstract PactDslJsonBody minArrayLike(Integer size)
Array element with a minimum size and each element of the array must match the following object
- Parameters:
size
- minimum size
-
minArrayLike
abstract PactDslJsonBody minArrayLike(String name, Integer size, DslPart obj)
Array field with a minimum size and each element must match the provided object
- Parameters:
name
- field namesize
- minimum size
-
minArrayLike
abstract PactDslJsonArray minArrayLike(Integer size, DslPart obj)
Array element with a minumum size and each element of the array must match the provided object
- Parameters:
size
- minimum size
-
minArrayLike
abstract PactDslJsonBody minArrayLike(String name, Integer size, Integer numberExamples)
Array field with a minumum size and each element must match the following object
- Parameters:
name
- field namesize
- minimum sizenumberExamples
- number of examples to generate
-
minArrayLike
abstract PactDslJsonBody minArrayLike(Integer size, Integer numberExamples)
Array element with a minimum size and each element of the array must match the following object
- Parameters:
size
- minimum sizenumberExamples
- number of examples to generate
-
maxArrayLike
abstract PactDslJsonBody maxArrayLike(String name, Integer size)
Array field with a maximum size and each element must match the following object
- Parameters:
name
- field namesize
- maximum size
-
maxArrayLike
abstract PactDslJsonBody maxArrayLike(Integer size)
Array element with a maximum size and each element of the array must match the following object
- Parameters:
size
- maximum size
-
maxArrayLike
abstract PactDslJsonBody maxArrayLike(String name, Integer size, DslPart obj)
Array field with a maximum size and each element must match the provided object
- Parameters:
name
- field namesize
- maximum size
-
maxArrayLike
abstract PactDslJsonArray maxArrayLike(Integer size, DslPart obj)
Array element with a maximum size and each element of the array must match the provided object
- Parameters:
size
- minimum size
-
maxArrayLike
abstract PactDslJsonBody maxArrayLike(String name, Integer size, Integer numberExamples)
Array field with a maximum size and each element must match the following object
- Parameters:
name
- field namesize
- maximum sizenumberExamples
- number of examples to generate
-
maxArrayLike
abstract PactDslJsonBody maxArrayLike(Integer size, Integer numberExamples)
Array element with a maximum size and each element of the array must match the following object
- Parameters:
size
- maximum sizenumberExamples
- number of examples to generate
-
minMaxArrayLike
abstract PactDslJsonBody minMaxArrayLike(String name, Integer minSize, Integer maxSize)
Array field with a minimum and maximum size and each element must match the following object
- Parameters:
name
- field nameminSize
- minimum sizemaxSize
- maximum size
-
minMaxArrayLike
abstract PactDslJsonBody minMaxArrayLike(String name, Integer minSize, Integer maxSize, DslPart obj)
Array field with a minimum and maximum size and each element must match the provided object
- Parameters:
name
- field nameminSize
- minimum sizemaxSize
- maximum size
-
minMaxArrayLike
abstract PactDslJsonBody minMaxArrayLike(Integer minSize, Integer maxSize)
Array element with a minimum and maximum size and each element of the array must match the following object
- Parameters:
minSize
- minimum sizemaxSize
- maximum size
-
minMaxArrayLike
abstract PactDslJsonArray minMaxArrayLike(Integer minSize, Integer maxSize, DslPart obj)
Array element with a minimum and maximum size and each element of the array must match the provided object
- Parameters:
minSize
- minimum sizemaxSize
- maximum size
-
minMaxArrayLike
abstract PactDslJsonBody minMaxArrayLike(String name, Integer minSize, Integer maxSize, Integer numberExamples)
Array field with a minimum and maximum size and each element must match the following object
- Parameters:
name
- field nameminSize
- minimum sizemaxSize
- maximum sizenumberExamples
- number of examples to generate
-
minMaxArrayLike
abstract PactDslJsonBody minMaxArrayLike(Integer minSize, Integer maxSize, Integer numberExamples)
Array element with a minimum and maximum size and each element of the array must match the following object
- Parameters:
minSize
- minimum sizemaxSize
- maximum sizenumberExamples
- number of examples to generate
-
eachArrayLike
abstract PactDslJsonArray eachArrayLike(String name)
Array field where each element is an array and must match the following object
- Parameters:
name
- field name
-
eachArrayLike
abstract PactDslJsonArray eachArrayLike()
Array element where each element of the array is an array and must match the following object
-
eachArrayLike
abstract PactDslJsonArray eachArrayLike(String name, Integer numberExamples)
Array field where each element is an array and must match the following object
- Parameters:
name
- field namenumberExamples
- number of examples to generate
-
eachArrayLike
abstract PactDslJsonArray eachArrayLike(Integer numberExamples)
Array element where each element of the array is an array and must match the following object
- Parameters:
numberExamples
- number of examples to generate
-
eachArrayWithMaxLike
abstract PactDslJsonArray eachArrayWithMaxLike(String name, Integer size)
Array field where each element is an array and must match the following object
- Parameters:
name
- field namesize
- Maximum size of the outer array
-
eachArrayWithMaxLike
abstract PactDslJsonArray eachArrayWithMaxLike(Integer size)
Array element where each element of the array is an array and must match the following object
- Parameters:
size
- Maximum size of the outer array
-
eachArrayWithMaxLike
abstract PactDslJsonArray eachArrayWithMaxLike(String name, Integer numberExamples, Integer size)
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
-
eachArrayWithMaxLike
abstract PactDslJsonArray eachArrayWithMaxLike(Integer numberExamples, Integer size)
Array element where each element of the array is an array and must match the following object
- Parameters:
numberExamples
- number of examples to generatesize
- Maximum size of the outer array
-
eachArrayWithMinLike
abstract PactDslJsonArray eachArrayWithMinLike(String name, Integer size)
Array field where each element is an array and must match the following object
- Parameters:
name
- field namesize
- Minimum size of the outer array
-
eachArrayWithMinLike
abstract PactDslJsonArray eachArrayWithMinLike(Integer size)
Array element where each element of the array is an array and must match the following object
- Parameters:
size
- Minimum size of the outer array
-
eachArrayWithMinLike
abstract PactDslJsonArray eachArrayWithMinLike(String name, Integer numberExamples, Integer size)
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
-
eachArrayWithMinLike
abstract PactDslJsonArray eachArrayWithMinLike(Integer numberExamples, Integer size)
Array element where each element of the array is an array and must match the following object
- Parameters:
numberExamples
- number of examples to generatesize
- Minimum size of the outer array
-
eachArrayWithMinMaxLike
abstract PactDslJsonArray eachArrayWithMinMaxLike(String name, Integer minSize, Integer maxSize)
Array field where each element is an array and must match the following object
- Parameters:
name
- field nameminSize
- minimum sizemaxSize
- maximum size
-
eachArrayWithMinMaxLike
abstract PactDslJsonArray eachArrayWithMinMaxLike(Integer minSize, Integer maxSize)
Array element where each element of the array is an array and must match the following object
- Parameters:
minSize
- minimum sizemaxSize
- maximum size
-
eachArrayWithMinMaxLike
abstract PactDslJsonArray eachArrayWithMinMaxLike(String name, Integer numberExamples, Integer minSize, Integer maxSize)
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
-
eachArrayWithMinMaxLike
abstract PactDslJsonArray eachArrayWithMinMaxLike(Integer numberExamples, Integer minSize, Integer maxSize)
Array element where each element of the array is an array and must match the following object
- Parameters:
numberExamples
- number of examples to generateminSize
- minimum sizemaxSize
- maximum size
-
object
abstract PactDslJsonBody object(String name)
Object field
- Parameters:
name
- field name
-
object
abstract PactDslJsonBody object()
Object element
-
closeObject
abstract DslPart closeObject()
Close off the previous object
-
asBody
final PactDslJsonBody asBody()
-
asArray
final PactDslJsonArray asArray()
-
close
abstract DslPart close()
This closes off the object graph build from the DSL in case any closeObject|Array methods have not been called.
-
matchUrl
abstract DslPart matchUrl(String name, String basePath, Object pathFragments)
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.
-
matchUrl
abstract DslPart matchUrl(String basePath, Object pathFragments)
Matches a URL that is composed of a base path and a sequence of path expressions
- Parameters:
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.
-
matchUrl2
abstract DslPart matchUrl2(String name, 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.
- Parameters:
name
- Attribute namepathFragments
- Series of path fragments to match on.
-
matchUrl2
abstract DslPart matchUrl2(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.
- Parameters:
pathFragments
- Series of path fragments to match on.
-
arrayContaining
abstract DslPart arrayContaining(String name)
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
-
regex
final static RegexMatcher regex(String regex, String example)
Returns a regular expression matcher
- Parameters:
regex
- Regex to match withexample
- Example value to use
-
-
-
-