Akash
05/17/2022, 1:24 AM4.2.20
). We’ve got 2 different similar requests like:
DslPart requestOneResponseBodyDslPart = PactDslJsonArray
.arrayEachLike()
.uuid("id", UUID.randomUUID())
.datetime("startTime", INSTANT_FORMAT_STRING)
// More keys here
.closeObject();
DslPart requestTwoResponseBodyDslPart = PactDslJsonArray
.arrayEachLike()
.uuid("id", UUID.randomUUID())
.datetime("scheduledStartTime", INSTANT_FORMAT_STRING)
.closeObject();
Both of them generate random UUIDs and the default datetime string adhering to the format like: "2000-02-01T00:00:00.000000Z"
in the pact JSON file.
The problem is that `requestOneResponseBodyDslPart`’s provider verification is expecting exact value matches for both the .uuid
and .datetime
fields, which is really odd, considering we’ve used PactDslJsonArray before too.rholshausen
05/17/2022, 1:30 AMAkash
05/17/2022, 1:35 AMrequestOneResponseBodyDslPart
doesn’t include any generators
and matchingRules
for that request 🤔Akash
05/17/2022, 1:52 AM.stringType
🤔rholshausen
05/17/2022, 2:03 AMAkash
05/17/2022, 2:16 AMreturn builder
.given("MY STATE")
.uponReceiving("a request to get all of a participant's recommendations")
.path(String.format("/api/participants/%s/recommendations", DEFAULT_PARTICIPANT_ID))
.method("GET")
.headers(REQUEST_HEADERS_WITH_AUTH)
.willRespondWith()
.status(200)
.headers(RESPONSE_HEADERS_FOR_VALIDATION)
.body(getRecommendationsPactDslJsonBody.toString())
.toPact();
rholshausen
05/17/2022, 2:17 AMgetRecommendationsPactDslJsonBody.toString()
, it converts it to pure JSON and you loose all the matchers and generators. Just remove the toString()
callAkash
05/17/2022, 2:24 AM