Package 

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
    • Method Detail

      • stringType

         final PactDslJsonBody stringType(String name, String example)

        Attribute that can be any string

        Parameters:
        name - attribute name
        example - example value to use for generated bodies
      • numberType

         final PactDslJsonBody numberType(String name, Number number)

        Attribute that can be any number

        Parameters:
        name - attribute name
        number - example number to use for generated bodies
      • integerType

         final PactDslJsonBody integerType(String name, Long number)

        Attribute that must be an integer

        Parameters:
        name - attribute name
        number - example integer value to use for generated bodies
      • integerType

         final PactDslJsonBody integerType(String name, Integer number)

        Attribute that must be an integer

        Parameters:
        name - attribute name
        number - example integer value to use for generated bodies
      • stringMatcher

         final PactDslJsonBody stringMatcher(String name, String regex, String value)

        Attribute that must match the regular expression

        Parameters:
        name - attribute name
        regex - regular expression
        value - example value to use for generated bodies
      • timestamp

        @Deprecated(message = "use datetime instead") final PactDslJsonBody timestamp(String name, String format)

        Attribute that must match the given datetime format

        Parameters:
        name - attribute name
        format - timestamp format
      • timestamp

        @Deprecated(message = "use datetime instead") final PactDslJsonBody timestamp(String name, String format, Date example)

        Attribute that must match the given timestamp format

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

        @Deprecated(message = "use datetime instead") final PactDslJsonBody timestamp(String name, String format, Date example, TimeZone timeZone)

        Attribute that must match the given timestamp 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
      • timestamp

        @Deprecated(message = "use datetime instead") final PactDslJsonBody timestamp(String name, String format, Instant example)

        Attribute that must match the given timestamp format

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

        @Deprecated(message = "use datetime instead") final PactDslJsonBody timestamp(String name, String format, Instant example, TimeZone timeZone)

        Attribute that must match the given timestamp 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

         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, 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
      • 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
      • localDate

         final PactDslJsonBody localDate(String name, String format, LocalDate 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
      • 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
      • 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

         final PactDslJsonBody id(String name, Long id)

        Attribute that must be a numeric identifier

        Parameters:
        name - attribute name
        id - example id to use for generated bodies
      • hexValue

         final PactDslJsonBody hexValue(String name, String hexValue)

        Attribute that must be encoded as a hexadecimal value

        Parameters:
        name - attribute name
        hexValue - example value to use for generated bodies
      • uuid

         final PactDslJsonBody uuid(String name, UUID uuid)

        Attribute that must be encoded as an UUID

        Parameters:
        name - attribute name
        uuid - example UUID to use for generated bodies
      • uuid

         final PactDslJsonBody uuid(String name, String uuid)

        Attribute that must be encoded as an UUID

        Parameters:
        name - attribute name
        uuid - example UUID 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
      • equalTo

         final PactDslJsonBody equalTo(String name, Object value)

        Attribute that must be equal to the provided value.

        Parameters:
        name - attribute name
        value - Value that will be used for comparisons
      • and

         final PactDslJsonBody and(String name, Object value, Array<out 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, Array<out 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, Array<out 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, Array<out 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, Array<out 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(Array<out 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 it's 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
      • 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
      • 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
      • getParent

         final DslPart getParent()

        Returns the parent of this part (object or array)