-
-
Couldn't load subscription status.
- Fork 483
Description
Hello team,
We are trying to write Contract test for Async messages using Pact using Java.
We have the below object
"user": {
"id": "user1",
"email": "example@gmail.com"
}
We want to add the rule like when the "id" is "user1" then "email" field is mandatory. And if "id" is anything else apart from "user1" then "email" field is not mandatory. How can we achieve this using "LambdaDslObject"?
Here is sample LambdaDslObject that we are setting
data.object(
USER,
user -> user.stringValue(ID, "user1"));
Ideally we would like to achieve this with single pact. Meaning that one consumer pact which can be verified by multiple providers.
Eg:
-
Provider1 produce the "id" as "user1" along with "email" field then the pact should pass
{"id": "user1", "email": "example@gmail.com"} -
Provider2 produce the "id" as "user2" and don't send email field then also pact should pass
{"id": "user2"}