Merge branch '2.1.x'
This commit is contained in:
@@ -104,7 +104,8 @@ class GenericJsonBodyThen implements Then {
|
||||
this.generatedClassMetaData.configProperties
|
||||
.getTestFramework() != TestFramework.SPOCK);
|
||||
if (!(convertedResponseBody instanceof Map
|
||||
|| convertedResponseBody instanceof List)) {
|
||||
|| convertedResponseBody instanceof List
|
||||
|| convertedResponseBody instanceof ExecutionProperty)) {
|
||||
simpleTextResponseBodyCheck(contractMetadata, convertedResponseBody);
|
||||
}
|
||||
processBodyElement("", "", convertedResponseBody);
|
||||
|
||||
@@ -3202,4 +3202,52 @@ DocumentContext parsedJson = JsonPath.parse(json);
|
||||
}
|
||||
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
|
||||
}
|
||||
|
||||
@Issue('#1263')
|
||||
def 'should allow using execute in the request body [#methodBuilderName]'() {
|
||||
given:
|
||||
Contract contractDsl = Contract.make {
|
||||
description "should migrate spaceship"
|
||||
request {
|
||||
method POST()
|
||||
url('/api/migration')
|
||||
headers {
|
||||
accept('application/json')
|
||||
contentType(applicationJson())
|
||||
}
|
||||
body(
|
||||
$(c([id: 4, foo:5, whatever:"hello"]), p(execute('hashCode()')))
|
||||
)
|
||||
}
|
||||
response {
|
||||
status OK()
|
||||
headers {
|
||||
contentType(applicationJson())
|
||||
}
|
||||
body(
|
||||
$(c([id: 4, foo:5, whatever:"hello"]), p(execute('hashCode()')))
|
||||
)
|
||||
}
|
||||
}
|
||||
methodBuilder()
|
||||
when:
|
||||
String test = singleTestGenerator(contractDsl)
|
||||
then:
|
||||
SyntaxChecker.tryToCompile(methodBuilderName, test)
|
||||
then:
|
||||
// 1 in the request and 1 in the response
|
||||
test.findAll("hashCode()").size() == 2
|
||||
where:
|
||||
methodBuilderName | methodBuilder
|
||||
"spock" | { properties.testFramework = TestFramework.SPOCK }
|
||||
"testng" | { properties.testFramework = TestFramework.TESTNG }
|
||||
"mockmvc" | { properties.testMode = TestMode.MOCKMVC }
|
||||
"jaxrs-spock" | {
|
||||
properties.testFramework = TestFramework.SPOCK; properties.testMode = TestMode.JAXRSCLIENT
|
||||
}
|
||||
"jaxrs" | {
|
||||
properties.testFramework = TestFramework.JUNIT; properties.testMode = TestMode.JAXRSCLIENT
|
||||
}
|
||||
"webclient" | { properties.testMode = TestMode.WEBTESTCLIENT }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2862,6 +2862,46 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
|
||||
|
||||
}
|
||||
|
||||
@Issue("#1263")
|
||||
def "should work with complex objects in the body"() {
|
||||
given:
|
||||
Contract contractDsl = Contract.make {
|
||||
description "should migrate spaceship"
|
||||
request {
|
||||
method POST()
|
||||
url('/api/migration')
|
||||
headers {
|
||||
accept('application/json')
|
||||
contentType(applicationJson())
|
||||
}
|
||||
body(
|
||||
$(c([id: 4, foo:5, whatever:"hello"]), p(execute('hashCode()')))
|
||||
)
|
||||
}
|
||||
response {
|
||||
status OK()
|
||||
headers {
|
||||
contentType(applicationJson())
|
||||
}
|
||||
body(
|
||||
$(c([id: 4, foo:5, whatever:"hello"]), p(execute('hashCode()')))
|
||||
)
|
||||
}
|
||||
}
|
||||
when:
|
||||
String wireMockStub = new WireMockStubStrategy("Test",
|
||||
new ContractMetadata(null, false, 0, null, contractDsl), contractDsl)
|
||||
.toWireMockClientStub()
|
||||
|
||||
then:
|
||||
wireMockStub.contains('''$[?(@.['whatever'] == 'hello')]''')
|
||||
wireMockStub.contains('''$[?(@.['id'] == 4)]''')
|
||||
wireMockStub.contains('''$[?(@.['foo'] == 5)]''')
|
||||
wireMockStub.contains('''"{\\"id\\":4,\\"foo\\":5,\\"whatever\\":\\"hello\\"}"''')
|
||||
stubMappingIsValidWireMockStub(wireMockStub)
|
||||
|
||||
}
|
||||
|
||||
@Issue("#1257")
|
||||
def "should work with null request element on the client side and optional stub entry"() {
|
||||
given:
|
||||
|
||||
Reference in New Issue
Block a user