Using pact jvm DSL with spring boot (.timestamp(name, format, example) I can specify both:
.timestamp("start", "dd-MM-yyyyy'T'HH:mm:ss'Z'", Instant.parse("2020-10-06T20:48:58.402Z"))
and
.timestamp("start", "yyyy-MM-dd'T'HH:mm:ss'Z'", Instant.parse("2020-10-06T20:48:58.402Z"))
or even
.timestamp("start", "dd-MM-yyyyyyy'T'HH:mm:ss'Z'", Instant.parse("2020-10-06T20:48:58.402Z"))
and the test still passes.
My real provider service errors if you send the date dd-MM-yyyy rather than yyyy-MM-dd, but I can't figure out how you're supposed to get the test on the consumer side to fail when it incorrectly sends the wrong format JSON timestamp to the provider API.
I.e. the bit that looks like this:
@Test
@PactTestFor(pactMethod = "postTheThing")
public void pactWithProvider() {
client.makeApiCall(testPayload);
}
Consumer tests fail only if you add some validation. It is supposed that pacts convert to stubs on the consumer side and that's it.
Just add some
mockition #verify
validation in your consumer test.