Skip to content

Commit 76ca345

Browse files
author
Ronald Holshausen
committedApr 5, 2020
chore: add example for provider state injection where the value is missing
1 parent fe33c75 commit 76ca345

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed
 

‎provider/pact-jvm-provider-junit5/src/test/groovy/au/com/dius/pact/provider/junit5/StateInjectedProviderTest.groovy

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ class StateInjectedProviderTest {
6464
.withRequestBody(matchingJsonPath('$.[?(@.entityName =~ /\\w+/)]'))
6565
.willReturn(aResponse()
6666
.withStatus(201)
67-
.withHeader('Location', "http://localhost:${server.port()}/entity/1234"))
67+
.withHeader('Location', "http://localhost:${server.port()}/entity/1234")
68+
.withHeader('Content-Type', 'application/json')
69+
.withBody('{"accountId": "4beb44f1-53f7-4281-abcd-12c06d682067"}'))
6870
)
6971
}
7072

‎provider/pact-jvm-provider-junit5/src/test/resources/pacts/xml-in-json-pact.json

+24-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,30 @@
3636
}
3737
},
3838
"response": {
39-
"status": 201
39+
"status": 201,
40+
"body": {
41+
"accountId": "4beb44f1-53f7-4281-a78b-12c06d682067"
42+
},
43+
"matchingRules": {
44+
"body": {
45+
"$.accountId": {
46+
"matchers": [
47+
{
48+
"match": "type"
49+
}
50+
],
51+
"combine": "AND"
52+
}
53+
}
54+
},
55+
"generators": {
56+
"body": {
57+
"$.accountId": {
58+
"type": "ProviderState",
59+
"expression": "${accountId}"
60+
}
61+
}
62+
}
4063
}
4164
}
4265
],

0 commit comments

Comments
 (0)
Please sign in to comment.