diff --git a/specs/spring-cloud-contract-spec-kotlin/src/main/kotlin/org/springframework/cloud/contract/spec/internal/ResponseDsl.kt b/specs/spring-cloud-contract-spec-kotlin/src/main/kotlin/org/springframework/cloud/contract/spec/internal/ResponseDsl.kt index ce1826a247..27b540d61a 100644 --- a/specs/spring-cloud-contract-spec-kotlin/src/main/kotlin/org/springframework/cloud/contract/spec/internal/ResponseDsl.kt +++ b/specs/spring-cloud-contract-spec-kotlin/src/main/kotlin/org/springframework/cloud/contract/spec/internal/ResponseDsl.kt @@ -69,7 +69,12 @@ class ResponseDsl : CommonDsl() { fun code(code: Int): DslProperty = code.toDslProperty() - fun fixedMilliseconds(delay: Long): DslProperty = delay.toDslProperty() + fun fixedMilliseconds(delay: Int): DslProperty = delay.toDslProperty() + + /** + * @deprecated Use the {@link #fixedMilliseconds(int) fixedMilliseconds} method. + */ + fun fixedMilliseconds(delay: Long): DslProperty = fixedMilliseconds(delay.toInt()) fun headers(headers: HeadersDsl.() -> Unit) { this.headers = ResponseHeadersDsl().apply(headers).get() diff --git a/specs/spring-cloud-contract-spec-kotlin/src/test/kotlin/org/springframework/cloud/contract/spec/ContractTests.kt b/specs/spring-cloud-contract-spec-kotlin/src/test/kotlin/org/springframework/cloud/contract/spec/ContractTests.kt index 1314c4cded..ff7bdbea68 100644 --- a/specs/spring-cloud-contract-spec-kotlin/src/test/kotlin/org/springframework/cloud/contract/spec/ContractTests.kt +++ b/specs/spring-cloud-contract-spec-kotlin/src/test/kotlin/org/springframework/cloud/contract/spec/ContractTests.kt @@ -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) + } + } + } \ No newline at end of file