Hi guys, I have this contract ```.body(PactDslJson...
# pact-jvm
o
Hi guys, I have this contract
Copy code
.body(PactDslJsonArray.arrayMinLike(1)
    .stringType("transactionHash")
    .stringType("originWallet")
    .stringType("destinationWallet")
    .decimalType("amount", 1.0)
    .datetime("creationDate")
    .stringType("method")
    .stringType("status")
    .decimalType("fee")
).toPact();
when I execute my consumer tests they are passing, but then when I'm running my provider tests I'm getting this error: body: $.0.creationDate Expected 1652738400000 to match a datetime of 'yyyy-MM-dd'T'HHmmss': Unable to parse the date: 1652738400000
f
it's the format of the date. a datetime should be in that format and it's not
the dateformat it's expect it's something like this: 2022-05-16, 230000
o
yes, the provider is returning a timestamp for the field creationDate and I'm using datetime("creationDate") in PactDslJsonArray, but it is not working
f
if it's a timestamp it is a int
not a datetime
also that timestamp is in what nanoseconds?
o
let me try with an int
but I think it should fail because this field is declared as a Date in the Dto
f
the thing is that a timestamp is a number (number of units of time since a specific instant)
and a date requires localization and other concepts
what does the provider gives
a timestamp or a datetime string with correct localization ?
o
a datetime string with correct localization
f
then your provider has a bug
because it's sending a timestamp
on that field
or you have a wrong expectation
o
I think I have a wrong expectation because the field is a Date, when I check in the database it is also stored as a Date, but then when I receive the response it looks like they are transforming this Date to a timestamp and that is what I'm receiving
f
then contract testing is doing it's job on dealing with expectations
💯 2
🙂