Class PactDslJsonBody

    • Constructor Detail

      • PactDslJsonBody

        PactDslJsonBody()
        Constructs a new body as a root
      • PactDslJsonBody

        PactDslJsonBody(String rootPath, String rootName, DslPart parent)
        Constructs a new body as a child
        Parameters:
        rootPath - Path to prefix to this child
        rootName - Name to associate this object as in the parent
        parent - Parent to attach to
      • PactDslJsonBody

        PactDslJsonBody(String rootPath, String rootName, DslPart parent, PactDslJsonBody body)
        Constructs a new body as a child as a copy of an existing one
        Parameters:
        rootPath - Path to prefix to this child
        rootName - Name to associate this object as in the parent
        parent - Parent to attach to
        body - Body to copy values from
      • PactDslJsonBody

        PactDslJsonBody(String rootPath, String rootName, PactDslJsonArray parent, Integer examples)
        Constructs a new body as a child of an array
        Parameters:
        rootPath - Path to prefix to this child
        rootName - Name to associate this object as in the parent
        parent - Parent to attach to
        examples - Number of examples to generate
    • Method Detail

      • decimalType

         final PactDslJsonBody decimalType(String name)

        Attribute that must be a decimal value (has significant digits after the decimal point)

        Parameters:
        name - attribute name
      • decimalType

         final PactDslJsonBody decimalType(String name, Double numbers)

        Attribute that must be a decimalType value (has significant digits after the decimal point)

        Parameters:
        name - attribute name
      • decimalTypes

         final PactDslJsonBody decimalTypes(String names)

        Attributes that must be a decimal values (have significant digits after the decimal point)

        Parameters:
        names - attribute names
      • numberMatching

         final PactDslJsonBody numberMatching(String name, String regex, Number example)

        Attribute that can be any number and which must match the provided regular expression

        Parameters:
        name - attribute name
        regex - Regular expression that the numbers string form must match
        example - example number to use for generated bodies
      • decimalMatching

         final PactDslJsonBody decimalMatching(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 expression

        Parameters:
        name - attribute name
        regex - Regular expression that the numbers string form must match
        example - example number to use for generated bodies
      • integerMatching

         final PactDslJsonBody integerMatching(String name, String regex, Integer example)

        Attribute that can be any integer and which must match the provided regular expression

        Parameters:
        name - attribute name
        regex - Regular expression that the numbers string form must match
        example - example integer to use for generated bodies
      • datetime

         final PactDslJsonBody datetime(String name, String format)

        Attribute that must match the given datetime format

        Parameters:
        name - attribute name
        format - datetime format
      • datetime

        @JvmOverloads() final PactDslJsonBody datetime(String name, String format, Date example, TimeZone timeZone)

        Attribute that must match the given datetime format

        Parameters:
        name - attribute name
        format - datetime format
        example - example date and time to use for generated bodies
        timeZone - time zone used for formatting of example date and time
      • datetime

        @JvmOverloads() final PactDslJsonBody datetime(String name, String format, Date example)

        Attribute that must match the given datetime format

        Parameters:
        name - attribute name
        format - datetime format
        example - example date and time to use for generated bodies
      • datetime

        @JvmOverloads() final PactDslJsonBody datetime(String name, String format, TimeZone timeZone, Date examples)

        Attribute that must match the given datetime format

        Parameters:
        name - attribute name
        format - datetime format
        timeZone - time zone used for formatting of example date and time
      • datetime

        @JvmOverloads() final PactDslJsonBody datetime(String name, String format, Instant example, TimeZone timeZone)

        Attribute that must match the given datetime format

        Parameters:
        name - attribute name
        format - timestamp format
        example - example date and time to use for generated bodies
        timeZone - time zone used for formatting of example date and time
      • datetime

        @JvmOverloads() final PactDslJsonBody datetime(String name, String format, Instant example)

        Attribute that must match the given datetime format

        Parameters:
        name - attribute name
        format - timestamp format
        example - example date and time to use for generated bodies
      • datetime

        @JvmOverloads() final PactDslJsonBody datetime(String name, String format, TimeZone timeZone, Instant examples)

        Attribute that must match the given datetime format

        Parameters:
        name - attribute name
        format - timestamp format
        timeZone - time zone used for formatting of example date and time
        examples - example dates and times to use for generated bodies
      • datetime

        @JvmOverloads() final PactDslJsonBody datetime(String name, String format, Instant examples)

        Attribute that must match the given datetime format

        Parameters:
        name - attribute name
        format - timestamp format
        examples - example dates and times to use for generated bodies
      • date

         final PactDslJsonBody date(String name, String format)

        Attribute that must match the provided date format

        Parameters:
        name - attribute date
        format - date format to match
      • date

        @JvmOverloads() final PactDslJsonBody date(String name, String format, Date example, TimeZone timeZone)

        Attribute that must match the provided date format

        Parameters:
        name - attribute date
        format - date format to match
        example - example date to use for generated values
        timeZone - time zone used for formatting of example date
      • date

        @JvmOverloads() final PactDslJsonBody date(String name, String format, Date example)

        Attribute that must match the provided date format

        Parameters:
        name - attribute date
        format - date format to match
        example - example date to use for generated values
      • date

        @JvmOverloads() final PactDslJsonBody date(String name, String format, TimeZone timeZone, Date examples)

        Attribute that must match the provided date format

        Parameters:
        name - attribute date
        format - date format to match
        timeZone - time zone used for formatting of example date
        examples - example dates to use for generated values
      • date

        @JvmOverloads() final PactDslJsonBody date(String name, String format, Date examples)

        Attribute that must match the provided date format

        Parameters:
        name - attribute date
        format - date format to match
        examples - example dates to use for generated values
      • time

         final PactDslJsonBody time(String name, String format)

        Attribute that must match the given time format

        Parameters:
        name - attribute name
        format - time format to match
      • time

        @JvmOverloads() final PactDslJsonBody time(String name, String format, Date example, TimeZone timeZone)

        Attribute that must match the given time format

        Parameters:
        name - attribute name
        format - time format to match
        example - example time to use for generated bodies
        timeZone - time zone used for formatting of example time
      • time

        @JvmOverloads() final PactDslJsonBody time(String name, String format, Date example)

        Attribute that must match the given time format

        Parameters:
        name - attribute name
        format - time format to match
        example - example time to use for generated bodies
      • time

        @JvmOverloads() final PactDslJsonBody time(String name, String format, TimeZone timeZone, Date examples)

        Attribute that must match the given time format

        Parameters:
        name - attribute name
        format - time format to match
        timeZone - time zone used for formatting of example time
        examples - example times to use for generated bodies
      • time

        @JvmOverloads() final PactDslJsonBody time(String name, String format, Date examples)

        Attribute that must match the given time format

        Parameters:
        name - attribute name
        format - time format to match
        examples - example times to use for generated bodies
      • object

         final PactDslJsonBody object(String name, DslPart value)

        Attribute that is a JSON object defined from a DSL part

        Parameters:
        name - field name
        value - DSL Part to set the value as
      • close

         DslPart close()

        This closes off the object graph build from the DSL in case any closeObject|Array methods have not been called.

      • eachLike

         PactDslJsonBody eachLike(String name)

        Attribute that is an array where each item must match the following example

        Parameters:
        name - field name
      • eachLike

         PactDslJsonBody eachLike()

        Array element where each element of the array must match the following object

      • eachLike

         PactDslJsonBody eachLike(String name, Integer numberExamples)

        Attribute that is an array where each item must match the following example

        Parameters:
        name - field name
        numberExamples - number of examples to generate
      • eachLike

         PactDslJsonBody eachLike(Integer numberExamples)

        Array element where each element of the array must match the following object

        Parameters:
        numberExamples - number of examples to generate
      • eachLike

        @JvmOverloads() final PactDslJsonBody eachLike(String name, PactDslJsonRootValue value, Integer numberExamples)

        Attribute that is an array of values that are not objects where each item must match the following example

        Parameters:
        name - field name
        value - Value to use to match each item
        numberExamples - number of examples to generate
      • minArrayLike

         PactDslJsonBody minArrayLike(String name, Integer size)

        Attribute that is an array with a minimum size where each item must match the following example

        Parameters:
        name - field name
        size - minimum size of the array
      • minArrayLike

         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

         PactDslJsonBody minArrayLike(String name, Integer size, Integer numberExamples)

        Attribute that is an array with a minimum size where each item must match the following example

        Parameters:
        name - field name
        size - minimum size of the array
        numberExamples - number of examples to generate
      • minArrayLike

         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 size
        numberExamples - number of examples to generate
      • minArrayLike

        @JvmOverloads() final PactDslJsonBody minArrayLike(String name, Integer size, PactDslJsonRootValue value, Integer 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 name
        size - minimum size of the array
        value - Value to use to match each item
        numberExamples - number of examples to generate
      • maxArrayLike

         PactDslJsonBody maxArrayLike(String name, Integer size)

        Attribute that is an array with a maximum size where each item must match the following example

        Parameters:
        name - field name
        size - maximum size of the array
      • maxArrayLike

         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

         PactDslJsonBody maxArrayLike(String name, Integer size, Integer numberExamples)

        Attribute that is an array with a maximum size where each item must match the following example

        Parameters:
        name - field name
        size - maximum size of the array
        numberExamples - number of examples to generate
      • maxArrayLike

         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 size
        numberExamples - number of examples to generate
      • maxArrayLike

        @JvmOverloads() final PactDslJsonBody maxArrayLike(String name, Integer size, PactDslJsonRootValue value, Integer 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 name
        size - maximum size of the array
        value - Value to use to match each item
        numberExamples - number of examples to generate
      • id

        @JvmOverloads() final PactDslJsonBody id(String name)

        Attribute that must be a numeric identifier

        Parameters:
        name - attribute name, defaults to 'id', that must be a numeric identifier
      • id

         final PactDslJsonBody id(String name, Long examples)

        Attribute that must be a numeric identifier

        Parameters:
        name - attribute name
        examples - example ids to use for generated bodies
      • eachArrayLike

         PactDslJsonArray eachArrayLike(String name, Integer numberExamples)

        Array field where each element is an array and must match the following object

        Parameters:
        name - field name
        numberExamples - number of examples to generate
      • eachArrayLike

         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

         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

         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 name
        numberExamples - number of examples to generate
        size - Maximum size of the outer array
      • eachArrayWithMaxLike

         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 generate
        size - Maximum size of the outer array
      • eachArrayWithMinLike

         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

         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 name
        numberExamples - number of examples to generate
        size - Minimum size of the outer array
      • eachArrayWithMinLike

         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 generate
        size - Minimum size of the outer array
      • eachKeyMappedToAnArrayLike

         final PactDslJsonBody eachKeyMappedToAnArrayLike(String exampleKey)

        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

         final PactDslJsonBody eachKeyLike(String exampleKey)

        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

         final PactDslJsonBody eachKeyLike(String exampleKey, 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 bodies
        value - Value to use for matching and generated bodies
      • includesStr

         final PactDslJsonBody includesStr(String name, String value)

        Attribute that must include the provided string value

        Parameters:
        name - attribute name
        value - Value that must be included
      • and

         final PactDslJsonBody and(String name, Object value, MatchingRule rules)

        Combine all the matchers using AND

        Parameters:
        name - Attribute name
        value - Attribute example value
        rules - Matching rules to apply
      • or

         final PactDslJsonBody or(String name, Object value, MatchingRule rules)

        Combine all the matchers using OR

        Parameters:
        name - Attribute name
        value - Attribute example value
        rules - Matching rules to apply
      • matchUrl

         PactDslJsonBody 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 name
        basePath - The base path for the URL (like "http://localhost:8080/") which will be excluded from the matching
        pathFragments - Series of path fragments to match on.
      • matchUrl

         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 matching
        pathFragments - Series of path fragments to match on.
      • matchUrl2

         PactDslJsonBody 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 name
        pathFragments - Series of path fragments to match on.
      • matchUrl2

         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.
      • minMaxArrayLike

         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 name
        minSize - minimum size
        maxSize - maximum size
      • minMaxArrayLike

         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 size
        maxSize - maximum size
      • minMaxArrayLike

         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 size
        maxSize - maximum size
      • minMaxArrayLike

         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 name
        minSize - minimum size
        maxSize - maximum size
        numberExamples - number of examples to generate
      • minMaxArrayLike

         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 size
        maxSize - maximum size
        numberExamples - number of examples to generate
      • minMaxArrayLike

         final PactDslJsonBody minMaxArrayLike(String name, Integer minSize, Integer maxSize, PactDslJsonRootValue value, Integer 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 name
        minSize - minimum size
        maxSize - maximum size
        value - Value to use to match each item
        numberExamples - number of examples to generate
      • eachArrayWithMinMaxLike

         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 name
        numberExamples - number of examples to generate
        minSize - minimum size
        maxSize - maximum size
      • eachArrayWithMinMaxLike

         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 generate
        minSize - minimum size
        maxSize - maximum size
      • valueFromProviderState

         final PactDslJsonBody valueFromProviderState(String name, String expression, Object example)

        Adds an attribute that will have its value injected from the provider state

        Parameters:
        name - Attribute name
        expression - Expression to be evaluated from the provider state
        example - Example value to be used in the consumer test
      • dateExpression

        @JvmOverloads() final PactDslJsonBody dateExpression(String name, String expression, String format)

        Adds a date attribute with the value generated by the date expression

        Parameters:
        name - Attribute name
        expression - Date expression to use to generate the values
        format - Date format to use
      • dateExpression

        @JvmOverloads() final PactDslJsonBody dateExpression(String name, String expression)

        Adds a date attribute with the value generated by the date expression

        Parameters:
        name - Attribute name
        expression - Date expression to use to generate the values
      • timeExpression

        @JvmOverloads() final PactDslJsonBody timeExpression(String name, String expression, String format)

        Adds a time attribute with the value generated by the time expression

        Parameters:
        name - Attribute name
        expression - Time expression to use to generate the values
        format - Time format to use
      • timeExpression

        @JvmOverloads() final PactDslJsonBody timeExpression(String name, String expression)

        Adds a time attribute with the value generated by the time expression

        Parameters:
        name - Attribute name
        expression - Time expression to use to generate the values
      • datetimeExpression

        @JvmOverloads() final PactDslJsonBody datetimeExpression(String name, String expression, String format)

        Adds a datetime attribute with the value generated by the expression

        Parameters:
        name - Attribute name
        expression - Datetime expression to use to generate the values
        format - Datetime format to use
      • arrayContaining

         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