pact-jvm-consumer-groovy generates incorrect contents in message pact file
See original GitHub issueVersion 4.0.2
of pact-jvm-consumer-groovy
seems to have introduced a bug where the generated message pact file contains incorrect contents
. Rather than being a JSON object, contents
is a String representation of the expected JSON.
With this code:
def pactMessageBuilder = new PactMessageBuilder().with {
serviceConsumer 'consumer'
hasPactWith 'provider'
expectsToReceive 'feed entry'
withMetaData(contentType: 'application/json')
withContent(contentType: 'application/json') {
type 'foo'
data {
reference {
id string('abc')
}
}
}
}
4.0.2
generates:
{
"consumer": {
"name": "consumer"
},
"provider": {
"name": "provider"
},
"messages": [
{
"description": "feed entry",
"metaData": {
"contentType": "application/json"
},
"contents": "{\n \"type\": \"foo\",\n \"data\": {\n \"reference\": {\n \"id\": \"abc\"\n }\n }\n}",
"matchingRules": {
"body": {
"$.data.reference.id": {
"matchers": [
{
"match": "type"
}
],
"combine": "AND"
}
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "3.0.0"
},
"pact-jvm": {
"version": "4.0.2"
}
}
}
whereas 4.0.1
generates:
{
"consumer": {
"name": "consumer"
},
"provider": {
"name": "provider"
},
"messages": [
{
"description": "feed entry",
"metaData": {
"contentType": "application/json"
},
"contents": {
"type": "foo",
"data": {
"reference": {
"id": "abc"
}
}
},
"matchingRules": {
"body": {
"$.data.reference.id": {
"matchers": [
{
"match": "type"
}
],
"combine": "AND"
}
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "3.0.0"
},
"pact-jvm": {
"version": "4.0.1"
}
}
}
I have created a repo to reproduce the issue here: https://github.com/qmg-rbass/pact-bug
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
pact-jvm-consumer-groovy generates incorrect contents in ...
Version 4.0.2 of pact-jvm-consumer-groovy seems to have introduced a bug where the generated message pact file contains incorrect contents.
Read more >pact-jvm-consumer-groovy | Pact Docs
Introduces a new message pact format for testing interactions via a message queue. Multiple provider states can be defined with data parameters.
Read more >“How-to” Guides - Spring Cloud
Starting from Spring Cloud Contract 2.0.0, you can fetch Pact files from the Pact Broker to generate tests and stubs. Pact follows the...
Read more >Contract Tests With Pact JVM — The Tricky Parts - Medium
Below you can find three code excerpts, limited to body matchers only, using different DSL variants: groovy, java, and java 8 (with lambdas):....
Read more >Writing Contract Tests with Pact in Spring Boot - kreuzwerker
The consumer is a messaging app that shows the user's name. ... The easiest way to create the Pact file is via a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Working well after upgrade, thanks @uglyog
Version 4.0.7 has been released with this change