This commit is contained in:
Marcin Grzejszczak
2021-11-23 10:37:57 +01:00
parent 6da8e89a39
commit e03c2f98b0
4 changed files with 133 additions and 40 deletions

View File

@@ -81,28 +81,35 @@ abstract class BaseWireMockStubStrategy {
/**
* For the given {@link ContentType} returns the String version of the body.
*/
String parseBody(Object value, ContentType contentType) {
Object parseBody(Object value, ContentType contentType) {
if (value instanceof Number) {
return value;
} else if (value instanceof FromFileProperty) {
return parseBody((FromFileProperty) value, contentType);
} else if (value instanceof Boolean) {
return parseBody((Boolean) value, contentType);
}
return parseBody(value.toString(), contentType);
}
/**
* Return body as String from file.
*/
String parseBody(FromFileProperty value, ContentType contentType) {
Object parseBody(FromFileProperty value, ContentType contentType) {
return value.asString();
}
/**
* For the given {@link ContentType} returns the Boolean version of the body.
*/
String parseBody(Boolean value, ContentType contentType) {
return value.toString();
Object parseBody(Boolean value, ContentType contentType) {
return value;
}
/**
* For the given {@link ContentType} returns the String version of the body.
*/
String parseBody(Map<?, ?> map, ContentType contentType) {
Object parseBody(Map<?, ?> map, ContentType contentType) {
Object transformedMap = MapConverter.getStubSideValues(map);
transformedMap = transformMapIfRequestPresent(transformedMap);
String json = toJson(transformedMap);
@@ -147,7 +154,7 @@ abstract class BaseWireMockStubStrategy {
/**
* For the given {@link ContentType} returns the String version of the body.
*/
String parseBody(List<?> list, ContentType contentType) {
Object parseBody(List<?> list, ContentType contentType) {
final List<Object> result = new ArrayList<>();
list.forEach(l -> {
if (l instanceof Map) {
@@ -160,13 +167,20 @@ abstract class BaseWireMockStubStrategy {
result.add(parseBody(l, contentType));
}
});
return parseBody(toJson(result), contentType);
return result;
}
String finalParseBody(Object object, ContentType contentType) {
if (contentType == ContentType.JSON) {
return toJson(object);
}
return object.toString();
}
/**
* For the given {@link ContentType} returns the String version of the body.
*/
String parseBody(GString value, ContentType contentType) {
Object parseBody(GString value, ContentType contentType) {
Object processedValue = extractValue(value, contentType,
(o) -> o instanceof DslProperty ? ((DslProperty<?>) o).getClientValue() : o);
if (processedValue instanceof GString) {
@@ -178,7 +192,7 @@ abstract class BaseWireMockStubStrategy {
/**
* For the given {@link ContentType} returns the String version of the body.
*/
String parseBody(String value, ContentType contentType) {
Object parseBody(String value, ContentType contentType) {
return value;
}

View File

@@ -22,11 +22,14 @@ import java.util.Map;
import java.util.function.Function;
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
import com.github.tomakehurst.wiremock.common.Json;
import com.github.tomakehurst.wiremock.extension.Extension;
import com.github.tomakehurst.wiremock.http.HttpHeader;
import com.github.tomakehurst.wiremock.http.HttpHeaders;
import com.github.tomakehurst.wiremock.http.ResponseDefinition;
import groovy.lang.GString;
import wiremock.com.fasterxml.jackson.databind.JsonNode;
import wiremock.com.jayway.jsonpath.internal.filter.ValueNodes;
import org.springframework.cloud.contract.spec.Contract;
import org.springframework.cloud.contract.spec.internal.FromFileProperty;
@@ -108,16 +111,36 @@ class WireMockResponseStubStrategy extends BaseWireMockStubStrategy {
builder.withBody(((FromFileProperty) body).asBytes());
}
else if (body instanceof Map) {
builder.withBody(parseBody((Map<?, ?>) body, contentType));
Object parseBody = parseBody((Map<?, ?>) body, contentType);
if (contentType == ContentType.JSON) {
builder.withJsonBody(Json.read(finalParseBody(parseBody, contentType), JsonNode.class));
} else {
builder.withBody(finalParseBody(parseBody, contentType));
}
}
else if (body instanceof List) {
builder.withBody(parseBody((List<?>) body, contentType));
Object parseBody = parseBody((List<?>) body, contentType);
if (contentType == ContentType.JSON) {
builder.withJsonBody(Json.read(finalParseBody(parseBody, contentType), JsonNode.class));
} else {
builder.withBody(finalParseBody(parseBody, contentType));
}
}
else if (body instanceof GString) {
builder.withBody(parseBody((GString) body, contentType));
Object parseBody = parseBody((GString) body, contentType);
if (contentType == ContentType.JSON) {
builder.withJsonBody(Json.read(finalParseBody(parseBody, contentType), JsonNode.class));
} else {
builder.withBody(finalParseBody(parseBody, contentType));
}
}
else {
builder.withBody(parseBody(body, contentType));
Object parseBody = parseBody(body, contentType);
if (contentType == ContentType.JSON) {
builder.withJsonBody(Json.read(finalParseBody(parseBody, contentType), JsonNode.class));
} else {
builder.withBody(finalParseBody(parseBody, contentType));
}
}
}
}

View File

@@ -80,7 +80,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"id\\":\\"123\\",\\"surname\\":\\"Kowalsky\\",\\"name\\":\\"Jan\\",\\"created\\":\\"2014-02-02 12:23:43\\"}",
"jsonBody" : "{\\"id\\":\\"123\\",\\"surname\\":\\"Kowalsky\\",\\"name\\":\\"Jan\\",\\"created\\":\\"2014-02-02 12:23:43\\"}",
"headers" : {
"Content-Type" : "application/json"
},
@@ -133,7 +133,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"ingredients\\":[{\\"type\\":\\"MALT\\",\\"quantity\\":100},{\\"type\\":\\"WATER\\",\\"quantity\\":200},{\\"type\\":\\"HOP\\",\\"quantity\\":300},{\\"type\\":\\"YIEST\\",\\"quantity\\":400}]}",
"jsonBody" : "{\\"ingredients\\":[{\\"type\\":\\"MALT\\",\\"quantity\\":100},{\\"type\\":\\"WATER\\",\\"quantity\\":200},{\\"type\\":\\"HOP\\",\\"quantity\\":300},{\\"type\\":\\"YIEST\\",\\"quantity\\":400}]}",
"transformers" : [ "response-template", "foo-transformer" ]
}
}
@@ -193,7 +193,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response": {
"status": 204,
"body": "{\\"paymentId\\":\\"4\\",\\"foundExistingPayment\\":false}",
"jsonBody": "{\\"paymentId\\":\\"4\\",\\"foundExistingPayment\\":false}",
"transformers" : [ "response-template", "foo-transformer" ]
}
}
@@ -244,7 +244,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"id\\":\\"123\\",\\"surname\\":\\"Kowalsky\\",\\"name\\":\\"Jan\\",\\"created\\":\\"2014-02-02 12:23:43\\"}",
"jsonBody" : "{\\"id\\":\\"123\\",\\"surname\\":\\"Kowalsky\\",\\"name\\":\\"Jan\\",\\"created\\":\\"2014-02-02 12:23:43\\"}",
"headers" : {
"Content-Type" : "application/json"
},
@@ -255,8 +255,8 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
actual.request == expected.request
actual.response.status == expected.response.status
actual.response.headers == expected.response.headers
def actualBody = new JsonSlurper().parseText(actual.response.body)
def expectedBody = new JsonSlurper().parseText(expected.response.body)
def actualBody = new JsonSlurper().parseText(actual.response.jsonBody)
def expectedBody = new JsonSlurper().parseText(expected.response.jsonBody)
actualBody == expectedBody
and:
stubMappingIsValidWireMockStub(wireMockStub)
@@ -303,7 +303,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"name\\":\\"Jan\\"}",
"jsonBody" : "{\\"name\\":\\"Jan\\"}",
"headers" : {
"Content-Type" : "application/json"
},
@@ -835,7 +835,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"name\\":\\"Jan\\"}",
"jsonBody" : "{\\"name\\":\\"Jan\\"}",
"headers" : {
"Content-Type" : "application/json"
},
@@ -904,7 +904,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"fraudCheckStatus\\":\\"OK\\",\\"rejectionReason\\":null}",
"jsonBody" : "{\\"fraudCheckStatus\\":\\"OK\\",\\"rejectionReason\\":null}",
"headers" : {
"Content-Type" : "application/vnd.fraud.v1+json"
},
@@ -1374,7 +1374,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"name\\":\\"Jan\\"}",
"jsonBody" : "{\\"name\\":\\"Jan\\"}",
"headers" : {
"Content-Type" : "application/json"
},
@@ -1440,7 +1440,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"status\\":\\"OK\\"}",
"jsonBody" : "{\\"status\\":\\"OK\\"}",
"headers" : {
"Content-Type" : "application/json"
},
@@ -1646,7 +1646,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 404,
"body" : "{\\"code\\":4,\\"message\\":\\"User not found by email = [not.existing@user.com]\\"}",
"jsonBody" : "{\\"code\\":4,\\"message\\":\\"User not found by email = [not.existing@user.com]\\"}",
"headers" : {
"Content-Type" : "application/json"
},
@@ -1730,7 +1730,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 404,
"body" : "{\\"code\\":\\"123123\\",\\"message\\":\\"User not found by email = [not.existing@user.com]\\"}",
"jsonBody" : "{\\"code\\":\\"123123\\",\\"message\\":\\"User not found by email = [not.existing@user.com]\\"}",
"headers" : {
"Content-Type" : "application/json"
},
@@ -1970,7 +1970,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"content\\":[{\\"id\\":\\"00000000-0000-0000-0000-000000000000\\",\\"type\\":\\"Extraordinary\\",\\"state\\":\\"ACTIVE\\"}],\\"totalPages\\":1,\\"totalElements\\":1,\\"last\\":true,\\"sort\\":[{\\"direction\\":\\"ASC\\",\\"property\\":\\"id\\",\\"ignoreCase\\":false,\\"nullHandling\\":\\"NATIVE\\",\\"ascending\\":true}],\\"first\\":true,\\"numberOfElements\\":1,\\"size\\":1,\\"number\\":0}",
"jsonBody" : "{\\"content\\":[{\\"id\\":\\"00000000-0000-0000-0000-000000000000\\",\\"type\\":\\"Extraordinary\\",\\"state\\":\\"ACTIVE\\"}],\\"totalPages\\":1,\\"totalElements\\":1,\\"last\\":true,\\"sort\\":[{\\"direction\\":\\"ASC\\",\\"property\\":\\"id\\",\\"ignoreCase\\":false,\\"nullHandling\\":\\"NATIVE\\",\\"ascending\\":true}],\\"first\\":true,\\"numberOfElements\\":1,\\"size\\":1,\\"number\\":0}",
"transformers" : [ "response-template", "foo-transformer" ]
}
}
@@ -2066,7 +2066,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"authorization\\":\\"{{{request.headers.Authorization.[0]}}}\\",\\"path\\":\\"{{{request.path}}}\\",\\"responseBaz\\":{{{jsonpath this '$.baz'}}} ,\\"param\\":\\"{{{request.query.foo.[0]}}}\\",\\"pathIndex\\":\\"{{{request.path.[1]}}}\\",\\"responseBaz2\\":\\"Bla bla {{{jsonpath this '$.foo'}}} bla bla\\",\\"responseFoo\\":\\"{{{jsonpath this '$.foo'}}}\\",\\"authorization2\\":\\"{{{request.headers.Authorization.[1]}}}\\",\\"fullBody\\":\\"{{{escapejsonbody}}}\\",\\"url\\":\\"{{{request.url}}}\\",\\"paramIndex\\":\\"{{{request.query.foo.[1]}}}\\"}",
"jsonBody" : "{\\"authorization\\":\\"{{{request.headers.Authorization.[0]}}}\\",\\"path\\":\\"{{{request.path}}}\\",\\"responseBaz\\":{{{jsonpath this '$.baz'}}} ,\\"param\\":\\"{{{request.query.foo.[0]}}}\\",\\"pathIndex\\":\\"{{{request.path.[1]}}}\\",\\"responseBaz2\\":\\"Bla bla {{{jsonpath this '$.foo'}}} bla bla\\",\\"responseFoo\\":\\"{{{jsonpath this '$.foo'}}}\\",\\"authorization2\\":\\"{{{request.headers.Authorization.[1]}}}\\",\\"fullBody\\":\\"{{{escapejsonbody}}}\\",\\"url\\":\\"{{{request.url}}}\\",\\"paramIndex\\":\\"{{{request.query.foo.[1]}}}\\"}",
"headers" : {
"Authorization" : "{{{request.headers.Authorization.[0]}}};foo"
},
@@ -2218,7 +2218,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"url\\":\\"{{{request.url}}}\\",\\"path\\":\\"{{{request.path}}}\\",\\"pathIndex\\":\\"{{{request.path.[1]}}}\\",\\"param\\":\\"{{{request.query.foo.[0]}}}\\",\\"paramIndex\\":\\"{{{request.query.foo.[1]}}}\\",\\"authorization\\":\\"{{{request.headers.Authorization.[0]}}}\\",\\"authorization2\\":\\"{{{request.headers.Authorization.[1]}}}\\",\\"fullBody\\":\\"{{{escapejsonbody}}}\\",\\"responseFoo\\":\\"{{{jsonPath request.body '$.foo'}}}\\",\\"responseBaz\\":{{{jsonPath request.body '$.baz'}}} ,\\"responseBaz2\\":\\"Bla bla {{{jsonPath request.body '$.foo'}}} bla bla\\",\\"rawUrl\\":\\"{{request.url}}\\",\\"rawPath\\":\\"{{request.path}}\\",\\"rawPathIndex\\":\\"{{request.path.[1]}}\\",\\"rawParam\\":\\"{{request.query.foo.[0]}}\\",\\"rawParamIndex\\":\\"{{request.query.foo.[1]}}\\",\\"rawAuthorization\\":\\"{{request.headers.Authorization.[0]}}\\",\\"rawAuthorization2\\":\\"{{request.headers.Authorization.[1]}}\\",\\"rawResponseFoo\\":\\"{{jsonPath request.body '$.foo'}}\\",\\"rawResponseBaz\\":{{jsonPath request.body '$.baz'}} ,\\"rawResponseBaz2\\":\\"Bla bla {{jsonPath request.body '$.foo'}} bla bla\\"}",
"jsonBody" : "{\\"url\\":\\"{{{request.url}}}\\",\\"path\\":\\"{{{request.path}}}\\",\\"pathIndex\\":\\"{{{request.path.[1]}}}\\",\\"param\\":\\"{{{request.query.foo.[0]}}}\\",\\"paramIndex\\":\\"{{{request.query.foo.[1]}}}\\",\\"authorization\\":\\"{{{request.headers.Authorization.[0]}}}\\",\\"authorization2\\":\\"{{{request.headers.Authorization.[1]}}}\\",\\"fullBody\\":\\"{{{escapejsonbody}}}\\",\\"responseFoo\\":\\"{{{jsonPath request.body '$.foo'}}}\\",\\"responseBaz\\":{{{jsonPath request.body '$.baz'}}} ,\\"responseBaz2\\":\\"Bla bla {{{jsonPath request.body '$.foo'}}} bla bla\\",\\"rawUrl\\":\\"{{request.url}}\\",\\"rawPath\\":\\"{{request.path}}\\",\\"rawPathIndex\\":\\"{{request.path.[1]}}\\",\\"rawParam\\":\\"{{request.query.foo.[0]}}\\",\\"rawParamIndex\\":\\"{{request.query.foo.[1]}}\\",\\"rawAuthorization\\":\\"{{request.headers.Authorization.[0]}}\\",\\"rawAuthorization2\\":\\"{{request.headers.Authorization.[1]}}\\",\\"rawResponseFoo\\":\\"{{jsonPath request.body '$.foo'}}\\",\\"rawResponseBaz\\":{{jsonPath request.body '$.baz'}} ,\\"rawResponseBaz2\\":\\"Bla bla {{jsonPath request.body '$.foo'}} bla bla\\"}",
"headers" : {
"Authorization" : "{{{request.headers.Authorization.[0]}}};foo"
},
@@ -2329,7 +2329,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"refresh_token\\":\\"RANDOM_REFRESH_TOKEN\\",\\"access_token\\":\\"RANDOM_ACCESS_TOKEN\\",\\"token_type\\":\\"bearer\\",\\"expires_in\\":3600,\\"scope\\":[\\"task\\"],\\"user\\":{\\"id\\":1,\\"username\\":\\"user\\",\\"name\\":\\"User\\"}}",
"jsonBody" : "{\\"refresh_token\\":\\"RANDOM_REFRESH_TOKEN\\",\\"access_token\\":\\"RANDOM_ACCESS_TOKEN\\",\\"token_type\\":\\"bearer\\",\\"expires_in\\":3600,\\"scope\\":[\\"task\\"],\\"user\\":{\\"id\\":1,\\"username\\":\\"user\\",\\"name\\":\\"User\\"}}",
"headers" : {
"Content-Type" : "application/json"
},
@@ -2386,7 +2386,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "[\\"[\\\\\\"Programming\\\\\\",\\\\\\"Java\\\\\\"]\\",\\"[\\\\\\"Programming\\\\\\",\\\\\\"Java\\\\\\",\\\\\\"Spring\\\\\\",\\\\\\"Boot\\\\\\"]\\"]",
"jsonBody" : [ [ "Programming", "Java" ], [ "Programming", "Java", "Spring", "Boot" ] ],
"headers" : {
"Content-Type" : "application/json;charset=UTF-8"
},
@@ -2405,7 +2405,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
ResponseEntity<String> entity = callApiCategories(port)
and:
AssertionUtil.assertThatJsonsAreEqual(('''
["[\\"Programming\\",\\"Java\\"]","[\\"Programming\\",\\"Java\\",\\"Spring\\",\\"Boot\\"]"]
[["Programming","Java"],["Programming","Java","Spring","Boot"]]
'''), entity.getBody())
cleanup:
server?.shutdown()
@@ -2512,7 +2512,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 201,
"body" : "{\\"id\\":\\"foo\\"}",
"jsonBody" : "{\\"id\\":\\"foo\\"}",
"headers" : {
"Content-Type" : "application/json;charset=UTF-8"
}
@@ -2572,7 +2572,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"code\\":91015,\\"description\\":\\"\\",\\"lastUpdateTime\\":\\"0\\",\\"payload\\":null}",
"jsonBody" : "{\\"code\\":91015,\\"description\\":\\"\\",\\"lastUpdateTime\\":\\"0\\",\\"payload\\":null}",
"transformers" : [ "response-template", "foo-transformer" ]
}
}
@@ -2643,7 +2643,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"refresh_token\\":\\"RANDOM_REFRESH_TOKEN\\",\\"access_token\\":\\"RANDOM_ACCESS_TOKEN\\",\\"token_type\\":\\"bearer\\",\\"expires_in\\":3600,\\"scope\\":[\\"task\\"],\\"user\\":{\\"id\\":1,\\"username\\":\\"user\\",\\"name\\":\\"User\\"}}",
"jsonBody" : "{\\"refresh_token\\":\\"RANDOM_REFRESH_TOKEN\\",\\"access_token\\":\\"RANDOM_ACCESS_TOKEN\\",\\"token_type\\":\\"bearer\\",\\"expires_in\\":3600,\\"scope\\":[\\"task\\"],\\"user\\":{\\"id\\":1,\\"username\\":\\"user\\",\\"name\\":\\"User\\"}}",
"headers" : {
"Content-Type" : "application/json;charset=UTF-8"
},
@@ -2689,7 +2689,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "{\\"jsonString\\":\\"{\\\\\\"attribute\\\\\\": \\\\\\"value\\\\\\"}\\"}",
"jsonBody" : "{\\"jsonString\\":\\"{\\\\\\"attribute\\\\\\": \\\\\\"value\\\\\\"}\\"}",
"headers" : {
"Content-Type" : "application/json;charset=UTF-8"
},
@@ -2730,7 +2730,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
},
"response" : {
"status" : 200,
"body" : "true",
"jsonBody" : "true",
"headers" : {
"Content-Type" : "application/json;charset=UTF-8"
},
@@ -2858,7 +2858,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
.toWireMockClientStub()
then:
wireMockStub.contains('''\\"country\\":\\"日本\\"''')
wireMockStub.contains('''"country" : "日本"''')
stubMappingIsValidWireMockStub(wireMockStub)
}
@@ -3130,6 +3130,62 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie
stubMappingIsValidWireMockStub(wireMockStub)
}
@Issue("#1635")
def "should work with a list of numbers"() {
given:
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.
make {
request {
method GET()
url("/api/foo/61923376")
headers {
accept(applicationJson())
}
}
response {
status(OK())
headers {
contentType(applicationJson())
}
body(
[
813146,
814952,
813102,
813282
]
)
}
}
when:
String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).
toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
{
"request" : {
"url" : "/api/foo/61923376",
"method" : "GET",
"headers" : {
"Accept" : {
"matches" : "application/json.*"
}
}
},
"response" : {
"status" : 200,
"jsonBody" : [813146,814952,813102,813282],
"headers" : {
"Content-Type" : "application/json"
},
"transformers" : [ "response-template", "foo-transformer" ]
}
}
''', wireMockStub)
and:
stubMappingIsValidWireMockStub(wireMockStub)
}
WireMockConfiguration config() {
return new WireMockConfiguration().extensions(responseTemplateTransformer())
}

View File

@@ -56,7 +56,7 @@ class WireMockResponseStubStrategySpec extends Specification {
}
def content = subject.buildClientResponseContent()
then:
'{"value":1.5}' == content.body
'{"value":1.5}' == content.jsonBody
}
@Issue("#468")
@@ -89,7 +89,7 @@ class WireMockResponseStubStrategySpec extends Specification {
}
def content = subject.buildClientResponseContent()
then:
Map body = new JsonSlurper().parseText(content.body) as Map
Map body = new JsonSlurper().parseText(content.jsonBody) as Map
assert body.get("number") instanceof Number
assert body.get("integer") instanceof Integer
assert body.get("positiveInt") instanceof Integer