Skip to content

0.14.2

Latest feature and fixes for Data Catering include:

Simplified API for creating HTTP and message fields

Previously, you had to hand-craft specific fields and their options to create HTTP and message fields. This was error-prone and time-consuming. Now, you can use helper methods to create these fields with ease.

Follow the new steps found in the:

More powerful data validations

A large overhaul of the data validation API has been made to make it more powerful and easier to use. Instead of having two separate methods for each validation, you can now use a single method with a negate flag to invert the validation. For example, isNotNull is now isNull(true).

You can also now define a field with a list of validations you want to apply to it for YAML. It now saves you from having to define the same field multiple times with different validations.

---
name: "account_checks"
dataSources:
  ...
    validations:
      - field: "year"
        validation:
          - type: "null"
            negate: true
          - type: "equal"
            value: 2021
  • Updates
    • ...Col -> ...Field (i.e. isEqualCol -> isEqualField)
    • isNot... -> is...(negate) (i.e. isNotNull -> isNull(true))
    • not... -> ...(negate) (i.e. notStartsWith("a") -> startsWith("a", true))
    • equalToOr... -> ...(strictly) (i.e. equalToOrLessThan(10) -> lessThan(10, false))
    • notIn("a", "b") -> in(List("a", "b"), true)
    • upstreamValidation...withValidation(...) -> upstreamValidation...validations(...)
  • New
    • matchesList(regexes, matchAll, negate)
    • hasTypes(types, negate)
    • distinctInSet(set, negate)
    • distinctContainsSet(set, negate)
    • distinctEqual(set, negate)
    • maxBetween(min, max, negate)
    • meanBetween(min, max, negate)
    • medianBetween(min, max, negate)
    • minBetween(min, max, negate)
    • stdDevBetween(min, max, negate)
    • sumBetween(min, max, negate)
    • lengthBetween(min, max, negate)
    • lengthEqual(value, negate)
    • isDecreasing(strictly)
    • isIncreasing(strictly)
    • isJsonParsable(negate)
    • matchJsonSchema(schema, negate)
    • matchDateTimeFormat(format, negate)
    • mostCommonValueInSet(values, negate)
    • uniqueValuesProportionBetween(min, max, negate)
    • quantileValuesBetween(quantileRanges, negate)

Validate HTTP responses

Now you can validate the HTTP response status code, body and headers. This is useful when you want to ensure that the response from the HTTP request is as expected.

var httpTask = http("my_http", Map.of(Constants.VALIDATION_IDENTIFIER(), "POST/pets"))
        .fields(
                ...
        )
        .validations(
                validation().field("request.method").isEqual("POST"),
                validation().field("response.statusCode").isEqual(200),
                validation().field("response.timeTakenMs").lessThan(100),
                validation().field("response.headers.Content-Length").greaterThan(0),
                validation().field("response.headers.Content-Type").isEqual("application/json")
        )
val httpTask = http("my_http", options = Map(VALIDATION_IDENTIFIER -> "POST/pets"))
  .fields(
    ...
  )
  .validations(
    validation.field("request.method").isEqual("POST"),
    validation.field("response.statusCode").isEqual(200),
    validation.field("response.timeTakenMs").lessThan(100),
    validation.field("response.headers.Content-Length").greaterThan(0),
    validation.field("response.headers.Content-Type").isEqual("application/json"),
  )

In docker/data/custom/validation/http/http-validation.yaml:

name: "http_checks"
dataSources:
  my_http:
    - options:
        validationIdentifier: "POST/pets"
      validations:
        - expr: "request.method == 'POST'"
        - expr: "response.statusCode == 200"
        - expr: "response.timeTakenMs < 100"
        - expr: "response.headers.Content-Length > 0"
        - expr: "response.headers.Content-Type == 'application/json'"

  1. Open Validation
  2. Click on Manual checkbox
  3. Click on + Validation button and click Select validation type and select Field
  4. Enter request.method in the Field text box
  5. Click on + next to Operator and select Equal
  6. Enter POST in the Equal text box
  7. Continue adding validations for response.statusCode, response.timeTakenMs, response.headers.Content-Length and response.headers.Content-Type

Check here for full examples.