Merge branch 'master' into 2.0.x
This commit is contained in:
@@ -73,7 +73,9 @@ class TestSideRequestTemplateModel {
|
||||
private static List<String> buildPathsFromUrl(String url) {
|
||||
String fakeUrl = "http://foo.bar" + (url.startsWith("/") ? url : "/" + url)
|
||||
List<String> paths = new URL(fakeUrl).path.split("/") as List<String>
|
||||
paths.remove(0)
|
||||
if (!paths.isEmpty()) {
|
||||
paths.remove(0)
|
||||
}
|
||||
return paths
|
||||
}
|
||||
|
||||
@@ -84,7 +86,7 @@ class TestSideRequestTemplateModel {
|
||||
|
||||
private static String getBodyAsRawJson(Object body) {
|
||||
Object bodyValue = extractServerValueFromBody(body)
|
||||
return new JsonOutput().toJson(bodyValue)
|
||||
return bodyValue != null ? new JsonOutput().toJson(bodyValue) : bodyValue
|
||||
}
|
||||
|
||||
protected static Object extractServerValueFromBody(bodyValue) {
|
||||
|
||||
@@ -348,6 +348,49 @@ DocumentContext parsedJson = JsonPath.parse(json);
|
||||
"JaxRsClientJUnitMethodBodyBuilder" | { Contract dsl -> new JaxRsClientJUnitMethodBodyBuilder(dsl, properties) }
|
||||
}
|
||||
|
||||
@Issue("#465")
|
||||
def "should work for '/' url for [#methodBuilderName]"() {
|
||||
given:
|
||||
Contract contractDsl = Contract.make {
|
||||
description("""
|
||||
Represents a request to the shouldReturnName service
|
||||
|
||||
given:
|
||||
a request to the shouldReturnName service
|
||||
when:
|
||||
it is a GET
|
||||
then:
|
||||
return Ryan
|
||||
""")
|
||||
request {
|
||||
method 'GET'
|
||||
url '/'
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body("Ryan")
|
||||
headers {
|
||||
contentType(textHtml())
|
||||
}
|
||||
}
|
||||
}
|
||||
MethodBodyBuilder builder = methodBuilder(contractDsl)
|
||||
BlockBuilder blockBuilder = new BlockBuilder(" ")
|
||||
when:
|
||||
builder.appendTo(blockBuilder)
|
||||
String test = blockBuilder.toString()
|
||||
then:
|
||||
SyntaxChecker.tryToCompileWithoutCompileStatic(methodBuilderName, test)
|
||||
and:
|
||||
stubMappingIsValidWireMockStub(contractDsl)
|
||||
where:
|
||||
methodBuilderName | methodBuilder
|
||||
"MockMvcSpockMethodBuilder" | { Contract dsl -> new MockMvcSpockMethodRequestProcessingBodyBuilder(dsl, properties) }
|
||||
"MockMvcJUnitMethodBuilder" | { Contract dsl -> new MockMvcJUnitMethodBodyBuilder(dsl, properties) }
|
||||
"JaxRsClientSpockMethodRequestProcessingBodyBuilder" | { Contract dsl -> new JaxRsClientSpockMethodRequestProcessingBodyBuilder(dsl, properties) }
|
||||
"JaxRsClientJUnitMethodBodyBuilder" | { Contract dsl -> new JaxRsClientJUnitMethodBodyBuilder(dsl, properties) }
|
||||
}
|
||||
|
||||
def "should use fixed delay milliseconds in the generated test [#methodBuilderName]"() {
|
||||
given:
|
||||
Contract contractDsl = Contract.make {
|
||||
|
||||
Reference in New Issue
Block a user