Avoid quoting of floating point numbers
This commit is contained in:
committed by
Marcin Grzejszczak
parent
91d686cd52
commit
82fb1cdac3
@@ -164,7 +164,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()
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user