Merge branch '2.2.x'

This commit is contained in:
Tim Ysewyn
2021-06-18 15:46:54 +02:00
2 changed files with 44 additions and 1 deletions

View File

@@ -69,7 +69,12 @@ class ResponseDsl : CommonDsl() {
fun code(code: Int): DslProperty<Any> = code.toDslProperty()
fun fixedMilliseconds(delay: Long): DslProperty<Any> = delay.toDslProperty()
fun fixedMilliseconds(delay: Int): DslProperty<Any> = delay.toDslProperty()
/**
* @deprecated Use the {@link #fixedMilliseconds(int) fixedMilliseconds} method.
*/
fun fixedMilliseconds(delay: Long): DslProperty<Any> = fixedMilliseconds(delay.toInt())
fun headers(headers: HeadersDsl.() -> Unit) {
this.headers = ResponseHeadersDsl().apply(headers).get()

View File

@@ -825,4 +825,42 @@ then:
}
}
@Test
/**
* See issue https://github.com/spring-cloud/spring-cloud-contract/issues/1668
*/
fun `should convert delay from long to int`() {
val contract = contract {
name = "Test Controller"
description = "Some description"
request {
method = GET
url = url("/credentials") withQueryParameters {
parameter("type", "foo")
}
}
response {
delay = fixedMilliseconds(1000L)
status = OK
body = body(
listOf(
mapOf(
"type" to "test1"
)
)
)
}
}
assertDoesNotThrow {
Contract.assertContract(contract)
}.also {
val response = contract.response
assertThat(response.delay.clientValue).isInstanceOf(java.lang.Integer::class.java)
assertThat(response.delay.clientValue).isEqualTo(1000)
assertThat(response.delay.serverValue).isInstanceOf(java.lang.Integer::class.java)
assertThat(response.delay.serverValue).isEqualTo(1000)
}
}
}