Class LambdaDslObject

java.lang.Object
au.com.dius.pact.consumer.dsl.LambdaDslObject
Direct Known Subclasses:
LambdaDslJsonBody

public class LambdaDslObject extends Object
  • Method Details

    • getPactDslObject

      public au.com.dius.pact.consumer.dsl.PactDslJsonBody getPactDslObject()
      Get the raw PactDslJsonBody which is abstracted with LambdaDslObject
    • stringValue

      public LambdaDslObject stringValue(String name, String value)
      Attribute that must be the specified value
      Parameters:
      name - attribute name
      value - string value
    • stringType

      public LambdaDslObject stringType(String name, String example)
      Attribute that can be any string
      Parameters:
      name - attribute name
      example - example value to use for generated bodies
    • stringType

      public LambdaDslObject stringType(String name)
      Attribute that can be any string
      Parameters:
      name - attribute name
    • stringType

      public LambdaDslObject stringType(String... names)
      Attributes that can be any string
      Parameters:
      names - attribute names
    • stringMatcher

      public LambdaDslObject stringMatcher(String name, String regex)
      Attribute that must match the regular expression
      Parameters:
      name - attribute name
      regex - regular expression
    • stringMatcher

      public LambdaDslObject stringMatcher(String name, String regex, String example)
      Attribute that must match the regular expression
      Parameters:
      name - attribute name
      regex - regular expression
      example - example value to use for generated bodies
    • numberValue

      public LambdaDslObject numberValue(String name, Number value)
      Attribute that must be the specified number
      Parameters:
      name - attribute name
      value - number value
    • numberType

      public LambdaDslObject numberType(String name, Number example)
      Attribute that can be any number
      Parameters:
      name - attribute name
      example - example number to use for generated bodies
    • numberType

      public LambdaDslObject numberType(String... names)
      Attributes that can be any number
      Parameters:
      names - attribute names
    • integerType

      public LambdaDslObject integerType(String name, Integer example)
      Attribute that must be an integer
      Parameters:
      name - attribute name
      example - example integer value to use for generated bodies
    • integerType

      public LambdaDslObject integerType(String... names)
      Attributes that must be an integer
      Parameters:
      names - attribute names
    • decimalType

      public LambdaDslObject decimalType(String name, BigDecimal example)
      Attribute that must be a decimalType value (has significant digits after the decimal point)
      Parameters:
      name - attribute name
      example - example decimalType value
    • decimalType

      public LambdaDslObject decimalType(String name, Double example)
      Attribute that must be a decimalType value (has significant digits after the decimal point)
      Parameters:
      name - attribute name
      example - example decimalType value
    • decimalType

      public LambdaDslObject decimalType(String... names)
      Attributes that must be decimal values (have significant digits after the decimal point)
      Parameters:
      names - attribute names
    • numberMatching

      public LambdaDslObject 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

      public LambdaDslObject 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

      public LambdaDslObject 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
    • booleanValue

      public LambdaDslObject booleanValue(String name, Boolean value)
      Attribute that must be the specified boolean
      Parameters:
      name - attribute name
      value - boolean value
    • booleanType

      public LambdaDslObject booleanType(String name, Boolean example)
      Attribute that must be a boolean
      Parameters:
      name - attribute name
      example - example boolean to use for generated bodies
    • booleanType

      public LambdaDslObject booleanType(String... names)
      Attributes that must be a boolean
      Parameters:
      names - attribute names
    • id

      public LambdaDslObject id()
      Attribute named 'id' that must be a numeric identifier
    • id

      public LambdaDslObject id(String name)
      Attribute that must be a numeric identifier
      Parameters:
      name - attribute name
    • id

      public LambdaDslObject id(String name, Long example)
      Attribute that must be a numeric identifier
      Parameters:
      name - attribute name
      example - example id to use for generated bodies
    • uuid

      public LambdaDslObject uuid(String name)
      Attribute that must be encoded as an UUID
      Parameters:
      name - attribute name
    • uuid

      public LambdaDslObject uuid(String name, UUID example)
      Attribute that must be encoded as an UUID
      Parameters:
      name - attribute name
      example - example UUID to use for generated bodies
    • date

      public LambdaDslObject date()
      Attribute named 'date' that must be formatted as an ISO date
    • date

      public LambdaDslObject date(String name)
      Attribute that must be formatted as an ISO date
      Parameters:
      name - attribute name
    • date

      public LambdaDslObject date(String name, String format)
      Attribute that must match the provided date format
      Parameters:
      name - attribute date
      format - date format to match
    • date

      public LambdaDslObject 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

      public LambdaDslObject 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

      public LambdaDslObject date(String name, String format, ZonedDateTime 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

      public LambdaDslObject date(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

      public LambdaDslObject time()
      Attribute named 'time' that must be an ISO formatted time
    • time

      public LambdaDslObject time(String name)
      Attribute that must be an ISO formatted time
      Parameters:
      name - attribute name
    • time

      public LambdaDslObject time(String name, String format)
      Attribute that must match the provided time format
      Parameters:
      name - attribute time
      format - time format to match
    • time

      public LambdaDslObject time(String name, String format, Date example)
      Attribute that must match the provided time format
      Parameters:
      name - attribute name
      format - time format to match
      example - example time to use for generated values
    • time

      public LambdaDslObject time(String name, String format, Date example, TimeZone timeZone)
      Attribute that must match the provided time format
      Parameters:
      name - attribute name
      format - time format to match
      example - example time to use for generated values
      timeZone - time zone used for formatting of example time
    • time

      public LambdaDslObject time(String name, String format, ZonedDateTime example)
      Attribute that must match the provided time format
      Parameters:
      name - attribute name
      format - time format to match
      example - example time to use for generated values
    • timestamp

      @Deprecated public LambdaDslObject timestamp()
      Deprecated.
      Use datetime
      Attribute named 'timestamp' that must be an ISO formatted timestamp
    • datetime

      @Deprecated public LambdaDslObject datetime(String name)
      Deprecated.
      Use datetime
      Attribute that must be an ISO formatted datetime
      Parameters:
      name - attribute name
    • datetime

      public LambdaDslObject datetime(String name, String format)
      Attribute that must match the given datetime format
      Parameters:
      name - attribute name
      format - datetime format
    • datetime

      public LambdaDslObject 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

      public LambdaDslObject datetime(String name, String format, Instant 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

      public LambdaDslObject 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

      public LambdaDslObject datetime(String name, String format, ZonedDateTime example)
      Attribute that must match the given timestamp format
      Parameters:
      name - attribute name
      format - datetime format
      example - example date and time to use for generated bodies
    • ipV4Address

      public LambdaDslObject ipV4Address(String name)
      Attribute that must be an IP4 address
      Parameters:
      name - attribute name
    • valueFromProviderState

      public LambdaDslObject valueFromProviderState(String name, String expression, Object example)
      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
    • 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 name
      value - Attribute example value
      rules - 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 name
      value - Attribute example value
      rules - Matching rules to apply
    • array

      public LambdaDslObject array(String name, Consumer<LambdaDslJsonArray> array)
      Attribute that is an array
      Parameters:
      name - field name
    • object

      public LambdaDslObject object(String name, Consumer<LambdaDslObject> nestedObject)
      Attribute that is a JSON object
      Parameters:
      name - field name
    • eachLike

      public LambdaDslObject eachLike(String name, Consumer<LambdaDslObject> nestedObject)
      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 name
      numberExamples - 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 name
      value - 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 name
      value - Value that each item in the array must match
      numberExamples - 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 name
      size - 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 name
      size - minimum size of the array
      numberExamples - 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 name
      size - minimum size of the array
      value - Value to use to match each item
      numberExamples - 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 name
      size - 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 name
      size - maximum size of the array
      numberExamples - 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 name
      size - maximum size of the array
      value - Value to use to match each item
      numberExamples - 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 name
      minSize - minimum size of the array
      maxSize - 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 name
      minSize - minimum size of the array
      maxSize - maximum size of the array
      numberExamples - 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 name
      minSize - minimum size of the array
      maxSize - maximum size of the array
      value - Value to use to match each item
      numberExamples - number of examples to generate
    • nullValue

      public LambdaDslObject nullValue(String fieldName)
      Sets the field to a null value
      Parameters:
      fieldName - field name
    • eachArrayLike

      public LambdaDslObject eachArrayLike(String name, Consumer<LambdaDslJsonArray> nestedArray)
      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 name
      numberExamples - 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 use eachArrayWithMaxLike(String, int, Integer, Consumer)
      Parameters:
      name - field name
      size - 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 name
      numberExamples - number of examples to generate
      size - 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 use eachArrayWithMinLike(String, int, Integer, Consumer)
      Parameters:
      name - field name
      size - 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 name
      numberExamples - number of examples to generate
      size - 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 use eachArrayWithMinMaxLike(String, Integer, Integer, int, Consumer)
      Parameters:
      name - field name
      minSize - minimum size
      maxSize - 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 name
      numberExamples - number of examples to generate
      minSize - minimum size
      maxSize - 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

      public LambdaDslObject eachKeyLike(String exampleKey, Consumer<LambdaDslObject> nestedObject)
      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 bodies
      value - Value to use for matching and generated bodies
    • dateExpression

      public LambdaDslObject dateExpression(String name, String expression)
      Attribute whose values are generated from the provided expression. Will use an ISO format.
      Parameters:
      name - Attribute name
      expression - Date expression
    • dateExpression

      public LambdaDslObject dateExpression(String name, String expression, String format)
      Attribute whose values are generated from the provided expression
      Parameters:
      name - Attribute name
      expression - Date expression
      format - Date format to use for values
    • timeExpression

      public LambdaDslObject timeExpression(String name, String expression)
      Attribute whose values are generated from the provided expression. Will use an ISO format.
      Parameters:
      name - Attribute name
      expression - Time expression
    • timeExpression

      public LambdaDslObject timeExpression(String name, String expression, String format)
      Attribute whose values are generated from the provided expression
      Parameters:
      name - Attribute name
      expression - Time expression
      format - Time format to use for values
    • datetimeExpression

      public LambdaDslObject datetimeExpression(String name, String expression)
      Attribute whose values are generated from the provided expression. Will use an ISO format.
      Parameters:
      name - Attribute name
      expression - Datetime expression
    • datetimeExpression

      public LambdaDslObject datetimeExpression(String name, String expression, String format)
      Attribute whose values are generated from the provided expression
      Parameters:
      name - Attribute name
      expression - Datetime expression
      format - Datetime format to use for values
    • unorderedArray

      public LambdaDslObject unorderedArray(String name, Consumer<LambdaDslJsonArray> nestedArray)
      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 name
      size - 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 name
      size - 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 name
      minSize - minimum size
      maxSize - maximum size
    • matchUrl

      public LambdaDslObject 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. These can be strings or regular expressions.
    • matchUrl2

      public LambdaDslObject matchUrl2(String name, Object... pathFragments)
      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 name
      pathFragments - Series of path fragments to match on. These can be strings or regular expressions.
    • arrayContaining

      public LambdaDslObject arrayContaining(String name, Consumer<LambdaDslJsonArray> nestedArray)
      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