Fixes wrong test side entry resolution; fixes gh-1304

This commit is contained in:
Marcin Grzejszczak
2020-01-10 10:16:38 +01:00
parent 7a3e3166e6
commit 22779b6eb8
2 changed files with 49 additions and 3 deletions

View File

@@ -123,12 +123,14 @@ interface BodyParser extends BodyThen {
return extractValue((GString) bodyValue, contentType,
ContentUtils.GET_TEST_SIDE);
}
if (TEXT != contentType && FORM != contentType && DEFINED != contentType) {
else if (bodyValue instanceof FromFileProperty) {
return MapConverter.transformValues(bodyValue, ContentUtils.GET_TEST_SIDE);
}
else if (TEXT != contentType && FORM != contentType && DEFINED != contentType) {
boolean dontParseStrings = contentType == JSON && bodyValue instanceof Map;
Closure parsingClosure = dontParseStrings ? Closure.IDENTITY
: MapConverter.JSON_PARSING_CLOSURE;
return MapConverter.transformValues(bodyValue, ContentUtils.GET_TEST_SIDE,
parsingClosure);
return MapConverter.getTestSideValues(bodyValue, parsingClosure);
}
return bodyValue;
}

View File

@@ -1927,4 +1927,48 @@ response:
}
}
def 'should work with an array of uuids'() {
given:
Contract contractDsl = Contract.make {
description "TEST ARRAY"
request {
method POST()
urlPath($(c('/TEST'), p('/TEST')))
body([
$(c(anyUuid()), p("00000000-0000-0000-0000-000000000002")),
$(c(anyUuid()), p("00000000-0000-0000-0000-000000000001"))
])
}
response {
status OK()
}
}
methodBuilder()
when:
String test = singleTestGenerator(contractDsl)
then:
SyntaxChecker.tryToCompileWithoutCompileStatic(methodBuilderName, test)
and:
!test.contains('singleValue')
and:
stubMappingIsValidWireMockStub(contractDsl)
where:
methodBuilderName | methodBuilder
"spock" | {
properties.testFramework = TestFramework.SPOCK
}
"mockmvc" | {
properties.testMode = TestMode.MOCKMVC
}
"jaxrs-spock" | {
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
}
"jaxrs" | {
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
}
"testNG" | {
properties.testFramework = TestFramework.TESTNG
}
}
}