matcher now correctly matches response instead of request 511 (#517)

This commit is contained in:
Tom Hombergs
2018-01-12 22:51:59 +01:00
committed by Marcin Grzejszczak
parent bea0d4f78d
commit 833a7114ab
3 changed files with 6 additions and 3 deletions

View File

@@ -138,7 +138,7 @@ class PactContractConverter implements ContractConverter<Pact> {
Map<String, Map<String, Object>> rules = requestResponseInteraction.response.matchingRules
Map<String, Object> fullBodyCheck = rules.get(FULL_BODY)
if (fullBodyCheck != null) {
JsonPaths jsonPaths = JsonToJsonPathsConverter.transformToJsonPathWithStubsSideValuesAndNoArraySizeCheck(requestResponseInteraction.request?.body?.value)
JsonPaths jsonPaths = JsonToJsonPathsConverter.transformToJsonPathWithStubsSideValuesAndNoArraySizeCheck(requestResponseInteraction.response?.body?.value)
jsonPaths.each {
jsonPath(it.keyBeforeChecking(), byType())
}

View File

@@ -96,8 +96,9 @@ class PactContractConverterSpec extends Specification {
headers {
contentType(applicationJson())
}
body(id: 42)
body(id: 42, firstName: "Arthur", lastName: "Dent")
testMatchers {
jsonPath('''$.['id']''', byType())
jsonPath('''$.['lastName']''', byType())
jsonPath('''$.['firstName']''', byType())
}

View File

@@ -26,7 +26,9 @@
"Content-Type": "application/json;charset=UTF-8"
},
"body": {
"id": 42
"id": 42,
"firstName": "Arthur",
"lastName": "Dent"
},
"matchingRules": {
"$.body": {