Hey there :wave: is there any way to create a `Dsl...
# pact-jvm
j
Hey there 👋 is there any way to create a
DslPart
from an existing JSON file or object? Or is it only the
PactDslJsonBody
and
newJsonBody
approaches listed here? We have existing JSON files used by our tests so it’d be nice to not have to rewrite all of them into this format
u
DslPart
classes are for building JSON payloads. If you already have JSON files, why not just use them directly?
j
I’m pretty sure that’s what we do for our other contract tests, but it seems to be different for Message Pact We’re using a
MessagePactBuilder
, and its
withContent()
method only accepts a
DslPart
or
PactXmlBuilder
Is there something simple I’m missing that lets us do this?
For example, is it possible to do something like this?
Copy code
JSONObject jsonObject = loadJsonFromFile(...);

return new MessagePactBuilder()
            .expectsToReceive("a user created message")
            .withContent(jsonObject)
            .toPact();
u
Ok, can you raise a GitHub issue for that?
j
Sure thing thanks @uglyog 😄
Raised it here: https://github.com/pact-foundation/pact-jvm/issues/1669 If there’s anything else you need just let me know, cheers!