Skip to content

Commit 549cbb7

Browse files
author
Thomas May
committedFeb 11, 2020
Move to groovy 3, spock 2.0-M1, and replace http-builder with http-build-ng
1 parent b1b2e89 commit 549cbb7

File tree

13 files changed

+275
-148
lines changed

13 files changed

+275
-148
lines changed
 

‎build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ subprojects {
7676
testCompile "org.junit.jupiter:junit-jupiter-api:${project.junit5Version}"
7777
testRuntime "org.junit.jupiter:junit-jupiter-engine:${project.junit5Version}"
7878
testCompile 'org.hamcrest:hamcrest:2.1'
79-
testCompile('org.spockframework:spock-core:1.3-groovy-2.5') {
79+
testCompile('org.spockframework:spock-core:2.0-M2-groovy-3.0') {
8080
exclude group: 'org.codehaus.groovy'
8181
}
8282
testRuntime 'net.bytebuddy:byte-buddy:1.9.16'

‎consumer/pact-jvm-consumer-groovy/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ dependencies {
33
compile "org.codehaus.groovy:groovy:${project.groovyVersion}"
44
compile "org.codehaus.groovy:groovy-json:${project.groovyVersion}"
55

6-
testCompile "org.codehaus.groovy.modules.http-builder:http-builder:${project.httpBuilderVersion}",
6+
testCompile "io.github.http-builder-ng:http-builder-ng-apache:${project.httpBuilderVersion}",
77
"ch.qos.logback:logback-classic:${project.logbackVersion}"
88
testCompile "org.codehaus.groovy:groovy-xml:${project.groovyVersion}"
99
testCompile "org.codehaus.groovy:groovy-dateutil:${project.groovyVersion}"

‎consumer/pact-jvm-consumer-groovy/src/test/groovy/au/com/dius/pact/consumer/groovy/ExampleFormPostTest.groovy

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package au.com.dius.pact.consumer.groovy
22

33
import au.com.dius.pact.consumer.PactVerificationResult
4-
import groovyx.net.http.ContentType
5-
import groovyx.net.http.HTTPBuilder
4+
import groovyx.net.http.ContentTypes
5+
import groovyx.net.http.HttpBuilder
66
import org.junit.Test
77

88
class ExampleFormPostTest {
@@ -24,9 +24,14 @@ class ExampleFormPostTest {
2424
}
2525

2626
assert service.runTest {
27-
def http = new HTTPBuilder( 'http://localhost:8000' )
28-
http.post(path: '/path', body: [number: '12345678'], requestContentType: ContentType.URLENC) { resp ->
29-
assert resp.statusLine.statusCode == 201
27+
def http = HttpBuilder.configure { request.uri = 'http://localhost:8000' }
28+
http.post {
29+
request.uri.path = '/path'
30+
request.body = [number: '12345678']
31+
request.contentType = ContentTypes.URLENC[0]
32+
response.parser(ContentTypes.ANY[0]) { config, resp ->
33+
assert resp.statusCode == 201
34+
}
3035
}
3136
} instanceof PactVerificationResult.Ok
3237
}

‎consumer/pact-jvm-consumer-groovy/src/test/groovy/au/com/dius/pact/consumer/groovy/ExampleGroovyConsumerPactTest.groovy

+44-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package au.com.dius.pact.consumer.groovy
22

33
import au.com.dius.pact.consumer.PactVerificationResult
44
import groovy.json.JsonBuilder
5-
import groovyx.net.http.RESTClient
5+
import groovy.json.JsonSlurper
6+
import groovyx.net.http.ContentTypes
7+
import groovyx.net.http.FromServer
8+
import groovyx.net.http.HttpBuilder
69
import org.junit.Test
710

811
class ExampleGroovyConsumerPactTest {
@@ -54,37 +57,59 @@ class ExampleGroovyConsumerPactTest {
5457
}
5558

5659
PactVerificationResult result = aliceService.runTest {
57-
def client = new RESTClient('http://localhost:1233/')
58-
def aliceResponse = client.get(path: '/mallory', query: [status: 'good', name: 'ron'])
60+
def client = HttpBuilder.configure {
61+
request.uri = 'http://localhost:1233/'
62+
}
63+
def aliceResponse = client.get(FromServer) {
64+
request.uri.path = '/mallory'
65+
request.uri.query = [status: 'good', name: 'ron']
66+
response.parser(ContentTypes.HTML) { config, resp ->
67+
return resp
68+
}
69+
}
5970

60-
assert aliceResponse.status == 200
71+
assert aliceResponse.statusCode == 200
6172
assert aliceResponse.contentType == 'text/html'
6273

63-
def data = aliceResponse.data.text()
74+
def data = aliceResponse.inputStream.text
6475
assert data == '"That is some good Mallory."'
6576
}
6677
assert result instanceof PactVerificationResult.Ok
6778

6879
result = bobService.runTest { mockServer, context ->
69-
def client = new RESTClient(mockServer.url)
80+
def client = HttpBuilder.configure {
81+
request.uri = mockServer.url
82+
}
7083
def body = new JsonBuilder([name: 'Bobby'])
71-
def bobPostResponse = client.post(path: '/donuts', requestContentType: 'application/json',
72-
headers: [
73-
'Accept': 'text/plain',
74-
'Content-Type': 'application/json'
75-
], body: body.toPrettyString()
76-
)
84+
def bobPostResponse = client.post(FromServer) {
85+
request.uri.path = '/donuts'
86+
request.contentType = 'application/json'
87+
request.headers = [
88+
'Accept' : 'text/plain',
89+
'Content-Type': 'application/json'
90+
]
91+
request.body = body.toPrettyString()
92+
response.parser(ContentTypes.TEXT) { config, resp ->
93+
return resp
94+
}
95+
}
7796

78-
assert bobPostResponse.status == 201
79-
assert bobPostResponse.data.text == '"Donut created."'
97+
assert bobPostResponse.statusCode == 201
98+
assert bobPostResponse.inputStream.text == '"Donut created."'
8099

81100
body = new JsonBuilder([ [name: 'Roger'] ])
82-
def bobPutResponse = client.put(path: '/alligators', requestContentType: 'application/json',
83-
headers: [ 'Content-Type': 'application/json' ], body: body.toPrettyString()
84-
)
101+
def bobPutResponse = client.put(FromServer){
102+
request.uri.path = "/alligators"
103+
request.contentType = 'application/json'
104+
request.headers = [ 'Content-Type': 'application/json' ]
105+
request.body = body.toPrettyString()
106+
response.parser(ContentTypes.ANY) { config, resp ->
107+
return resp
108+
}
109+
}
85110

86-
assert bobPutResponse.status == 200
87-
assert bobPutResponse.data == [ [age: 20, name: 'Roger'] ]
111+
assert bobPutResponse.statusCode == 200
112+
assert new JsonSlurper().parse(bobPutResponse.inputStream) == [[age: 20, name: 'Roger'] ]
88113
}
89114
assert result instanceof PactVerificationResult.ExpectedButNotReceived
90115
assert result.expectedRequests.size() == 1

‎consumer/pact-jvm-consumer-groovy/src/test/groovy/au/com/dius/pact/consumer/groovy/ExampleGroovyConsumerV3PactTest.groovy

+16-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package au.com.dius.pact.consumer.groovy
33
import au.com.dius.pact.consumer.PactConsumerConfig
44
import au.com.dius.pact.consumer.PactVerificationResult
55
import groovy.json.JsonSlurper
6-
import groovyx.net.http.RESTClient
6+
import groovyx.net.http.ContentTypes
7+
import groovyx.net.http.FromServer
8+
import groovyx.net.http.HttpBuilder
79
import org.junit.Test
810

911
import java.time.LocalDate
@@ -36,14 +38,22 @@ class ExampleGroovyConsumerV3PactTest {
3638
}
3739

3840
PactVerificationResult result = aliceService.runTest { mockServer ->
39-
def client = new RESTClient(mockServer.url)
40-
def aliceResponse = client.get(path: '/mallory', query: [status: 'good', name: 'ron',
41-
date: LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE)])
41+
def client = HttpBuilder.configure {
42+
request.uri = mockServer.url
43+
}
44+
def aliceResponse = client.get(FromServer){
45+
request.uri.path = '/mallory'
46+
request.uri.query = [status: 'good', name: 'ron',
47+
date: LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE)]
48+
response.parser(ContentTypes.ANY) { config, resp ->
49+
return resp
50+
}
51+
}
4252

43-
assert aliceResponse.status == 200
53+
assert aliceResponse.statusCode == 200
4454
assert aliceResponse.contentType == 'text/html'
4555

46-
def data = aliceResponse.data.text()
56+
def data = aliceResponse.inputStream.text
4757
assert data == '"That is some good Mallory."'
4858
}
4959
assert result instanceof PactVerificationResult.Ok

‎consumer/pact-jvm-consumer-groovy/src/test/groovy/au/com/dius/pact/consumer/groovy/GroovyConsumerMatchersPactSpec.groovy

+79-54
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package au.com.dius.pact.consumer.groovy
22

33
import au.com.dius.pact.consumer.PactVerificationResult
44
import groovy.json.JsonOutput
5-
import groovyx.net.http.RESTClient
5+
import groovy.json.JsonSlurper
6+
import groovyx.net.http.ContentTypes
7+
import groovyx.net.http.FromServer
8+
import groovyx.net.http.HttpBuilder
69
import spock.lang.Specification
710

8-
import static groovyx.net.http.ContentType.JSON
11+
import static groovyx.net.http.ContentTypes.JSON
912

1013
class GroovyConsumerMatchersPactSpec extends Specification {
1114

@@ -21,7 +24,7 @@ class GroovyConsumerMatchersPactSpec extends Specification {
2124
matcherService {
2225
uponReceiving('a request')
2326
withAttributes(method: 'put', path: '/')
24-
withBody(mimeType: JSON.toString()) {
27+
withBody(mimeType: ContentTypes.JSON[0]) {
2528
name(~/\w+/, 'harry')
2629
surname includesStr('larry')
2730
position regexp(~/staff|contractor/, 'staff')
@@ -58,56 +61,63 @@ class GroovyConsumerMatchersPactSpec extends Specification {
5861
}
5962
}
6063
willRespondWith(status: 200)
61-
withBody(mimeType: JSON.toString()) {
64+
withBody(mimeType: ContentTypes.JSON[0]) {
6265
name(~/\w+/, 'harry')
6366
}
6467
}
6568

6669
when:
6770
PactVerificationResult result = matcherService.runTest { server, context ->
68-
def client = new RESTClient(server.url)
69-
def response = client.put(requestContentType: JSON, body: [
70-
'name': 'harry',
71-
'surname': 'larry',
72-
'position': 'staff',
73-
'happy': true,
74-
'hexCode': '9d1883afcd',
75-
'hexCode2': '01234AB',
76-
'id': 6444667731,
77-
'id2': 1234567890,
78-
'localAddress': '127.0.0.1',
79-
'localAddress2': '192.169.0.2',
80-
'age': 100,
81-
'age2': 9817343207,
82-
'salary': 59458983.55,
83-
'ts': '2015-12-05T16:24:28',
84-
'timestamp': '2015/12/05 - 16:24:28.429',
85-
'values': [
86-
1,
87-
2,
88-
3,
89-
9232527554
90-
],
91-
'role': [
92-
'name': 'admin',
93-
'id': '7a97e929-c5b1-43cf-9b2c-295e9d4fa3cd',
94-
'kind': [
95-
'id': 100
96-
],
97-
'dob': '12/05/2015'
98-
],
99-
'roles': [
100-
[
101-
'name': 'dev',
102-
'id': '3590e5cf-8777-4d30-be4c-dac824765b9b'
103-
]
104-
],
105-
nextReview: '2001-01-01'
106-
]
107-
)
108-
109-
assert response.status == 200
110-
assert response.data == [name: 'harry']
71+
def client = HttpBuilder.configure {
72+
request.uri = server.url
73+
}
74+
def resp = client.put(FromServer){
75+
request.contentType = JSON[0]
76+
request.body = JsonOutput.toJson([
77+
'name': 'harry',
78+
'surname': 'larry',
79+
'position': 'staff',
80+
'happy': true,
81+
'hexCode': '9d1883afcd',
82+
'hexCode2': '01234AB',
83+
'id': 6444667731,
84+
'id2': 1234567890,
85+
'localAddress': '127.0.0.1',
86+
'localAddress2': '192.169.0.2',
87+
'age': 100,
88+
'age2': 9817343207,
89+
'salary': 59458983.55,
90+
'ts': '2015-12-05T16:24:28',
91+
'timestamp': '2015/12/05 - 16:24:28.429',
92+
'values': [
93+
1,
94+
2,
95+
3,
96+
9232527554
97+
],
98+
'role': [
99+
'name': 'admin',
100+
'id': '7a97e929-c5b1-43cf-9b2c-295e9d4fa3cd',
101+
'kind': [
102+
'id': 100
103+
],
104+
'dob': '12/05/2015'
105+
],
106+
'roles': [
107+
[
108+
'name': 'dev',
109+
'id': '3590e5cf-8777-4d30-be4c-dac824765b9b'
110+
]
111+
],
112+
nextReview: '2001-01-01'
113+
])
114+
response.parser(JSON) { config, r ->
115+
return r
116+
}
117+
}
118+
119+
assert resp.statusCode == 200
120+
assert new JsonSlurper().parse(resp.inputStream) == [name: 'harry']
111121
}
112122

113123
then:
@@ -131,10 +141,17 @@ class GroovyConsumerMatchersPactSpec extends Specification {
131141

132142
when:
133143
PactVerificationResult result = matcherService.runTest { server ->
134-
def client = new RESTClient(server.url)
135-
def response = client.get(query: [a: '100', b: 'Z'])
144+
def client = HttpBuilder.configure {
145+
request.uri = server.url
146+
}
147+
def resp = client.get(FromServer){
148+
request.uri.query = [a: '100', b: 'Z']
149+
response.success { r, v ->
150+
return r
151+
}
152+
}
136153

137-
assert response.status == 200
154+
assert resp.statusCode == 200
138155
}
139156

140157
then:
@@ -163,11 +180,19 @@ class GroovyConsumerMatchersPactSpec extends Specification {
163180

164181
when:
165182
PactVerificationResult result = matcherService.runTest { server ->
166-
def client = new RESTClient(server.url)
167-
def response = client.put(requestContentType: JSON, body: JsonOutput.toJson([
168-
valueA: 100, valueB: 'AZB', valueC: null]))
183+
def client = HttpBuilder.configure {
184+
request.uri = server.url
185+
}
186+
def resp = client.put(FromServer){
187+
request.contentType = JSON[0]
188+
request.body = JsonOutput.toJson([
189+
valueA: 100, valueB: 'AZB', valueC: null])
190+
response.success { resp, v ->
191+
return resp
192+
}
193+
}
169194

170-
assert response.status == 200
195+
assert resp.statusCode == 200
171196
}
172197

173198
then:

‎consumer/pact-jvm-consumer-groovy/src/test/groovy/au/com/dius/pact/consumer/groovy/PactResultSpec.groovy

+66-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package au.com.dius.pact.consumer.groovy
22

3-
import groovyx.net.http.RESTClient
3+
import groovy.json.JsonSlurper
4+
import groovyx.net.http.ContentTypes
5+
import groovyx.net.http.FromServer
6+
import groovyx.net.http.HttpBuilder
47
import spock.lang.Specification
58

69
class PactResultSpec extends Specification {
@@ -20,17 +23,25 @@ class PactResultSpec extends Specification {
2023
}
2124

2225
when:
23-
def response
26+
def resp
2427
def data
2528
testService.runTestAndVerify { mockServer, context ->
26-
def client = new RESTClient(mockServer.url)
27-
response = client.get(path: '/path', query: [status: 'good', name: 'ron'],
28-
requestContentType: 'application/json')
29-
data = response.data
29+
def client = HttpBuilder.configure {
30+
request.uri = mockServer.url
31+
}
32+
resp = client.get(FromServer){
33+
request.uri.path = '/path'
34+
request.uri.query = [status: 'good', name: 'ron']
35+
request.contentType = 'application/json'
36+
response.parser(ContentTypes.JSON) { config, r ->
37+
return r
38+
}
39+
}
40+
data = new JsonSlurper().parse(resp.inputStream)
3041
}
3142

3243
then:
33-
response.status == 200
44+
resp.statusCode == 200
3445
data == [status: 'isGood']
3546
}
3647

@@ -49,22 +60,30 @@ class PactResultSpec extends Specification {
4960
}
5061

5162
when:
52-
def response
63+
def resp
5364
testService.runTestAndVerify { mockServer, context ->
54-
def client = new RESTClient(mockServer.url)
55-
response = client.get(path: '/path', query: [status: 'good', name: 'ron'],
56-
requestContentType: 'application/json')
57-
58-
assert response.status == 201
65+
def client = HttpBuilder.configure {
66+
request.uri = mockServer.url
67+
}
68+
resp = client.get(FromServer) {
69+
request.uri.path = '/path'
70+
request.uri.query = [status: 'good', name: 'ron']
71+
request.contentType = 'application/json'
72+
response.parser(ContentTypes.ANY) { config, r ->
73+
return r
74+
}
75+
}
76+
77+
assert resp.statusCode == 201
5978
}
6079

6180
then:
6281
def e = thrown(AssertionError)
6382
e.message.contains('Pact Test function failed with an exception: Condition not satisfied:\n' +
6483
'\n' +
65-
'response.status == 201\n' +
66-
'| | |\n' +
67-
'| 200 false')
84+
'resp.statusCode == 201\n' +
85+
'| | |\n' +
86+
'| 200 false')
6887
}
6988

7089
def 'case when the test fails and the pact has a mismatch'() {
@@ -84,10 +103,15 @@ class PactResultSpec extends Specification {
84103
when:
85104
def response
86105
testService.runTestAndVerify { mockServer, context ->
87-
def client = new RESTClient(mockServer.url)
88-
response = client.get(path: '/path', query: [status: 'bad', name: 'ron'],
89-
requestContentType: 'application/json')
90-
assert response.status == 200
106+
def client = HttpBuilder.configure {
107+
request.uri = mockServer.url
108+
}
109+
response = client.get(FromServer){
110+
request.uri.path = '/path'
111+
request.uri.query = [status: 'bad', name: 'ron']
112+
request.contentType = 'application/json'
113+
}
114+
assert response.statusCode == 200
91115
}
92116

93117
then:
@@ -121,24 +145,32 @@ class PactResultSpec extends Specification {
121145

122146
when:
123147
testService.runTestAndVerify { mockServer, context ->
124-
def client = new RESTClient(mockServer.url)
125-
def response = client.get(path: '/path', query: [status: 'good', name: 'ron'],
126-
requestContentType: 'application/json')
127-
assert response.status == 200
148+
def client = HttpBuilder.configure {
149+
request.uri = mockServer.url
150+
}
151+
def resp = client.get(FromServer) {
152+
request.uri.path = '/path'
153+
request.uri.query = [status: 'good', name: 'ron']
154+
request.contentType = 'application/json'
155+
response.parser(ContentTypes.ANY) {config, r ->
156+
return r
157+
}
158+
}
159+
assert resp.statusCode == 200
128160
}
129161

130162
then:
131163
def e = thrown(PactFailedException)
132164
e.message.contains(
133-
'''|The following requests were not received:
134-
|\tmethod: post
135-
|\tpath: /path
136-
|\tquery: {}
137-
|\theaders: {Content-Type=[application/json]}
138-
|\tmatchers: MatchingRules(rules={body=Category(name=body, matchingRules={}), path=Category(name=path, matchingRules={})})
139-
|\tgenerators: Generators(categories={})
140-
|\tbody: PRESENT({
141-
| "status": "isGood"
142-
|})'''.stripMargin())
165+
'''The following requests were not received:
166+
|\tmethod: post
167+
|\tpath: /path
168+
|\tquery: {}
169+
|\theaders: {Content-Type=[application/json]}
170+
|\tmatchers: MatchingRules(rules={body=Category(name=body, matchingRules={}), path=Category(name=path, matchingRules={}), header=Category(name=header, matchingRules={})})
171+
|\tgenerators: Generators(categories={})
172+
|\tbody: PRESENT({
173+
| "status": "isGood"
174+
})'''.stripMargin())
143175
}
144176
}

‎consumer/pact-jvm-consumer-groovy/src/test/groovy/au/com/dius/pact/consumer/groovy/ProviderStateInjectedPactTest.groovy

+16-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package au.com.dius.pact.consumer.groovy
33
import au.com.dius.pact.consumer.PactConsumerConfig
44
import au.com.dius.pact.consumer.PactVerificationResult
55
import groovy.json.JsonSlurper
6-
import groovyx.net.http.RESTClient
6+
import groovyx.net.http.ContentTypes
7+
import groovyx.net.http.FromServer
8+
import groovyx.net.http.HttpBuilder
79
import org.junit.Test
810

911
@SuppressWarnings('GStringExpressionWithinString')
@@ -35,11 +37,20 @@ class ProviderStateInjectedPactTest {
3537
}
3638

3739
PactVerificationResult result = service.runTest { mockServer, context ->
38-
def client = new RESTClient(mockServer.url, 'application/json')
39-
def response = client.post(path: '/values', body: [userName: 'Test', userClass: 'Shoddy'])
40+
def client = HttpBuilder.configure {
41+
request.uri = mockServer.url
42+
request.contentType = 'application/json'
43+
}
44+
def resp = client.post(FromServer) {
45+
request.uri.path = '/values'
46+
request.body = [userName: 'Test', userClass: 'Shoddy']
47+
response.parser(ContentTypes.ANY) { config, r ->
48+
return r
49+
}
50+
}
4051

41-
assert response.status == 200
42-
assert response.data == [userName: 'Test', userId: 100]
52+
assert resp.statusCode == 200
53+
assert new JsonSlurper().parse(resp.inputStream) == [userName: 'Test', userId: 100]
4354
}
4455
assert result instanceof PactVerificationResult.Ok
4556

‎consumer/pact-jvm-consumer-groovy/src/test/groovy/au/com/dius/pact/consumer/groovy/WildcardPactSpec.groovy

+37-18
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ package au.com.dius.pact.consumer.groovy
22

33
import au.com.dius.pact.consumer.PactVerificationResult
44
import au.com.dius.pact.core.model.FeatureToggles
5-
import groovyx.net.http.RESTClient
5+
import groovy.json.JsonSlurper
6+
import groovyx.net.http.ContentTypes
7+
import groovyx.net.http.FromServer
8+
import groovyx.net.http.HttpBuilder
69
import spock.lang.Specification
710

8-
import static groovyx.net.http.ContentType.JSON
11+
import static groovyx.net.http.ContentTypes.JSON
912

1013
@SuppressWarnings(['AbcMetric'])
1114
class WildcardPactSpec extends Specification {
@@ -45,16 +48,24 @@ class WildcardPactSpec extends Specification {
4548

4649
when:
4750
PactVerificationResult result = articleService.runTest { server, context ->
48-
def client = new RESTClient(server.url)
49-
def response = client.get(requestContentType: JSON)
50-
51-
assert response.status == 200
52-
assert response.data.articles.size() == 1
53-
assert response.data.articles[0].variants.size() == 1
54-
assert response.data.articles[0].variants[0].keySet() == ['001'] as Set
55-
assert response.data.articles[0].variants[0].'001'.size() == 1
56-
assert response.data.articles[0].variants[0].'001'[0].bundles.size() == 1
57-
assert response.data.articles[0].variants[0].'001'[0].bundles[0].keySet() == ['001-A'] as Set
51+
def client = HttpBuilder.configure {
52+
request.uri = server.url
53+
}
54+
def response = client.get(FromServer){
55+
request.contentType = JSON[0]
56+
response.parser(ContentTypes.ANY) {config, resp ->
57+
return resp
58+
}
59+
}
60+
61+
assert response.statusCode == 200
62+
def data = new JsonSlurper().parse(response.inputStream)
63+
assert data.articles.size() == 1
64+
assert data.articles[0].variants.size() == 1
65+
assert data.articles[0].variants[0].keySet() == ['001'] as Set
66+
assert data.articles[0].variants[0].'001'.size() == 1
67+
assert data.articles[0].variants[0].'001'[0].bundles.size() == 1
68+
assert data.articles[0].variants[0].'001'[0].bundles[0].keySet() == ['001-A'] as Set
5869
}
5970

6071
then:
@@ -89,7 +100,7 @@ class WildcardPactSpec extends Specification {
89100
uponReceiving('a request for events with useMatchValuesMatcher turned on')
90101
withAttributes(method: 'get', path: '/')
91102
willRespondWith(status: 200)
92-
withBody(mimeType: JSON.toString()) {
103+
withBody(mimeType: ContentTypes.JSON[0].toString()) {
93104
events {
94105
keyLike('001') {
95106
description string('some description')
@@ -106,12 +117,20 @@ class WildcardPactSpec extends Specification {
106117

107118
when:
108119
PactVerificationResult result = articleService.runTest { server, context ->
109-
def client = new RESTClient(server.url)
110-
def response = client.get(requestContentType: JSON)
120+
def client = HttpBuilder.configure {
121+
request.uri = server.url
122+
}
123+
def response = client.get(FromServer){
124+
request.contentType = JSON[0]
125+
response.parser(ContentTypes.ANY) { config, resp ->
126+
return resp
127+
}
128+
}
111129

112-
assert response.status == 200
113-
assert response.data.events.size() == 1
114-
assert response.data.events.keySet() == ['001'] as Set
130+
assert response.statusCode == 200
131+
def data = new JsonSlurper().parse(response.inputStream)
132+
assert data.events.size() == 1
133+
assert data.events.keySet() == ['001'] as Set
115134
}
116135

117136
then:

‎consumer/pact-jvm-consumer-junit/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dependencies {
2121
testCompile "org.codehaus.groovy:groovy:${project.groovyVersion}"
2222
testCompile "org.codehaus.groovy:groovy-json:${project.groovyVersion}"
2323
testCompile "org.codehaus.groovy:groovy-xml:${project.groovyVersion}"
24-
testCompile "org.codehaus.groovy.modules.http-builder:http-builder:${project.httpBuilderVersion}"
24+
testCompile "io.github.http-builder-ng:http-builder-ng-apache:http-builder:${project.httpBuilderVersion}"
2525
// Required for Java 9
2626
testCompile 'javax.xml.bind:jaxb-api:2.3.0'
2727
testRuntime "org.junit.vintage:junit-vintage-engine:${project.junit5Version}"

‎consumer/pact-jvm-consumer-junit5/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dependencies {
55

66
testCompile "ch.qos.logback:logback-core:${project.logbackVersion}",
77
"ch.qos.logback:logback-classic:${project.logbackVersion}"
8-
testCompile "org.codehaus.groovy.modules.http-builder:http-builder:${project.httpBuilderVersion}"
8+
testCompile "io.github.http-builder-ng:http-builder-ng-apache:${project.httpBuilderVersion}"
99
testCompile "org.codehaus.groovy:groovy-json:${project.groovyVersion}"
1010
testCompile "org.codehaus.groovy:groovy-xml:${project.groovyVersion}"
1111
testCompile 'org.apache.commons:commons-io:1.3.2'

‎core/model/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies {
2929
implementation 'com.github.salomonbrys.kotson:kotson:2.5.0'
3030

3131
testCompile "ch.qos.logback:logback-classic:${project.logbackVersion}"
32-
testCompile "org.codehaus.groovy.modules.http-builder:http-builder:${project.httpBuilderVersion}"
32+
testCompile "io.github.http-builder-ng:http-builder-ng-apache:${project.httpBuilderVersion}"
3333
testRuntime project(path: project.path, configuration: 'testJars')
3434
testCompile "org.codehaus.groovy:groovy-datetime:${project.groovyVersion}"
3535
testRuntime "org.junit.vintage:junit-vintage-engine:${project.junit5Version}"

‎gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
groovyVersion=2.5.8
1+
groovyVersion=3.0.0
22
kotlinVersion=1.3.60
3-
httpBuilderVersion=0.7.1
3+
httpBuilderVersion=1.0.4
44
commonsLang3Version=3.4
55
httpClientVersion=4.5.5
66
scalaVersion=2.12.8

0 commit comments

Comments
 (0)
Please sign in to comment.