In <Pact JS>, there is an ability to match a body ...
# pact-jvm
a
In Pact JS, there is an ability to match a body field by field by type against an entire json object with somethingLike
will_respond_with(
status: 200,
headers: {"Content-Type" => "application/json"},
body: Pact.like(
name: "Mary",
age: 73)
)
Is somethingLike or anything similar implemented for pact-jvm (specifically Junit5) ?
Could I get some guidance on this?
y
the docs you link to show your answer https://docs.pact.io/implementation_guides/javascript/docs/matching#match-based-on-type just provide
like
a json object
oh sorry! you are after it for JVM!
1
There is a thread I believe on some things that might make it easier ( I assume you don’t have primitive json objects but some class that gets serialised as json) https://pact-foundation.slack.com/archives/C9UN99H24/p1686592166541669 you can search back through our entire history as we are currently on a slack pro trial
c
hi, was there ever an answer on this? I’m interested in generating pact matchers from a POJO.
pact-consumer-builder
doesn’t support kotlin data classes and I think the project is quite old.
y
Hey @chris paul, You may want to tune into this https://pact.io/pactober/2023/pact-jvm-dsl as the OP of the linked thread will be hosting
c
ah great so it sounds like there’s something in the works? I’ve been getting to grips with pact. I think it’s great in principle but I’m going to struggle if I have to maintain pact matchers by hand as well as POJOs for tests
@Yousaf Nabi (pactflow.io) did this talk happen? The link on that site is for a video from earlier in october
y
blobwave Hiya, thanks for the heads up, have updated the link to the event now, but to help you out, it is here

https://www.youtube.com/watch?v=whXaNti7PSg

c
ah brill, thank you
I was pretty excited for this but the library seems strange to me. I’m not sure why they have chosen to generate a separate class to then generate the pact contract. The previous implementation seems more intuitive as it simply maps a pojo to a pact contract - https://github.com/remondis-it/pact-consumer-builder With this library I have to map from a sourcing pojo to a pact generator. I’m not sure if the authors wlil read this but perhaps I’m missing something…
My issue was that the older library did not support kotlin data classes or java records. I was hoping this implementation would simply fix that but they appear to be taking it in a different direction…