Greetings! I am validating a reasonable complex J...
# pact-jvm
e
Greetings! I am validating a reasonable complex JSON return from a service (which I hope to simplify moving forward), but I am running into a matching issue: One of the nested objects has a unique name (not standardized), based on the request. In the below example, "ABCD32" is the name, but in a different call, it may be something else.
Copy code
{
  "plans": {
    "ABCD32": {
      "idRequired": true,
      "ids": [
        "1234"
      ]
    }
  }
}
I'm trying to use
object(<name>)
for this, but the name isn't generally predictable.
Copy code
rootResponseObject.object("plans", (plans) ->
    plans.object("??????", (plan) -> {
         ratePlan.booleanType("idRequired", true);
         ratePlan.array("ids", (item) -> item.stringType("12345"));
    })
);
I think I'm a bit confused on when we want things to be more general, and when "test by example" is the right way to go. Since I control the request and data, should I just match to that exact string as the result that fulfills the example?
Ahh, just found the
eachValueLike
method.
In that test, the variant IDs are specific for each document