I have a request class which has this fields:
private final String pk;
private final String sk;
private final List<String> tags;
private final ZoneId timeZone;
private final String pattern;
private final SomeEnum action;
private final String target;
private final String data;
private final Map<String, String> additionalInfo;
The request can be dynamic, so I am creating a DslPart for this:
DslPart body = new PactDslJsonBody()
.stringType("pk")
.stringType("sk")
.stringType("pattern")
.stringType("target")
.stringType("template")
.object("action").closeObject()
.object("timeZone").closeObject()
.object("metadata").stringType("detail-type").closeObject();
And using it here while creating contract:
pactHelper.contract(pact ->
pact.uponReceiving("Create scheduler rule")
.method("POST")
.path("/rule")
.body(body)
.willRespondWith()
.body("OK")
.status(HttpStatusCode.OK).toPact())
This result in 500: Unexpected Request error