Hi All, I am pretty new to Pact and may be I am do...
# pact-jvm
s
Hi All, I am pretty new to Pact and may be I am doing something wrong . I have created a Pact like this @Pact(consumer = "AddressClient") public RequestResponsePact PactFetchAddressCheck(PactDslWithProvider builder) { return builder.given("address exist") .uponReceiving("getting all address details") .path("/getAddress") .method("GET") .willRespondWith() .status(200) .body(new PactDslJsonBody() .stringType("name","Jon Doe1") .stringType("address","Ynglingavagen 10, jarfalla") .stringType("zipCode","17757") ) .toPact(); } but I am getting an out put json as "{\"address\":\"Ynglingavagen 10, jarfalla\",\"name\":\"Jon Doe1\",\"zipCode\":\"17757\"}". My question is why I am getting Address as first attribute in the json object ?
m
Why does the order matter?
s
I want to compare with a response from my provider API. junit assertions fails when there is mismatch in order
m
Pact will already assert the body is correct when it verifies a provider, you don't need to do that in the unit test.
The unit test should be asserting the behaviour of your API client.
1
s
@Matt (pactflow.io / pact-js / pact-go) How can I verify the structure of the response(Json) using the Pact ?
m
what have you tried so far?
The consumer Pact test job is to unit test your API client, and capture its needs of the provider API (you need not assert in the consumer tests anything about the provider, as pact captures that in the contract and will verify the provider when those tests run)
To ensure the API does what it should do, you run a provider verification step. It will read the contract and stand in for the API consumer(s) and hit your API, checking the API behaves as needed
which part are you wanting to do?
s
To ensure API does it should do
m
That’s what Pact does
I’d recommend running through a basic tutorial here: https://docs.pactflow.io/docs/tutorials
We have a Java one that might be helpful for you. You can do it in the browser, and takes 15-30 minutes to run through