Merge branch '1.2.x'

This commit is contained in:
Marcin Grzejszczak
2018-02-19 10:52:40 +01:00
3 changed files with 28 additions and 2 deletions

View File

@@ -173,7 +173,7 @@ abstract class BaseWireMockStubStrategy {
Map convertedMap = MapConverter.transformValues(value) {
it instanceof GString ? it.toString() : it
} as Map
return new JSONObject(convertedMap).toString()
return new JSONObject(new JsonBuilder(convertedMap).toString())
}
return new JsonBuilder(value).toString()
}

View File

@@ -14,6 +14,6 @@ public class JsonAssertTests {
@Test
public void should_compare_big_decimals() {
DocumentContext context = JsonPath.parse("{\"foo\": 55534673.56}");
assertThatJson(context).field("['foo']").isEqualTo(55534673.57);
assertThatJson(context).field("['foo']").isEqualTo(55534673.56);
}
}

View File

@@ -0,0 +1,26 @@
package org.springframework.cloud.contract.verifier.dsl.wiremock
import org.springframework.cloud.contract.spec.Contract
import spock.lang.Specification
class WireMockResponseStubStrategySpec extends Specification {
def "should not quote floating point numbers"() {
given:
def irrelevantStatus = 200
def contract = Contract.make {
request {
}
response {
status irrelevantStatus
body([
value: 1.5
])
}
}
when:
def subject = new WireMockResponseStubStrategy(contract)
def content = subject.buildClientResponseContent()
then:
'{"value":1.5}'.equals(content.body)
}
}