Merge branch '2.0.x'
This commit is contained in:
@@ -1048,6 +1048,31 @@ response:
|
||||
async: true
|
||||
----
|
||||
|
||||
You can also use the `fixedDelayMilliseconds` method / property to add delay to your stubs.
|
||||
|
||||
.Groovy DSL
|
||||
[source,groovy,indent=0]
|
||||
----
|
||||
org.springframework.cloud.contract.spec.Contract.make {
|
||||
request {
|
||||
method GET()
|
||||
url '/get'
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body 'Passed'
|
||||
fixedDelayMilliseconds 1000
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
.YAML
|
||||
[source,yml,indent=0]
|
||||
----
|
||||
response:
|
||||
fixedDelayMilliseconds: 1000
|
||||
----
|
||||
|
||||
=== Working with Context Paths
|
||||
|
||||
Spring Cloud Contract supports context paths.
|
||||
|
||||
@@ -212,6 +212,7 @@ class ContractsToYaml {
|
||||
yamlContract.response = new YamlContract.Response()
|
||||
yamlContract.response.with { YamlContract.Response response ->
|
||||
response.async = contract.response.async
|
||||
response.fixedDelayMilliseconds = contract.response?.delay?.clientValue as Integer
|
||||
response.status = contract.response?.status?.clientValue as Integer
|
||||
response.headers = (contract.response?.headers as Headers)?.asMap {
|
||||
String headerName, DslProperty prop ->
|
||||
|
||||
@@ -217,6 +217,7 @@ class YamlContract {
|
||||
public String bodyFromFile
|
||||
public TestMatchers matchers = new TestMatchers()
|
||||
public Boolean async
|
||||
public Integer fixedDelayMilliseconds
|
||||
}
|
||||
|
||||
@CompileStatic
|
||||
|
||||
@@ -250,6 +250,7 @@ class YamlToContracts {
|
||||
}
|
||||
if (yamlContract.response.bodyFromFile) body(file(yamlContract.response.bodyFromFile))
|
||||
if (yamlContract.response.async) async()
|
||||
if (yamlContract.response.fixedDelayMilliseconds) fixedDelayMilliseconds(yamlContract.response.fixedDelayMilliseconds)
|
||||
bodyMatchers {
|
||||
yamlContract.response?.matchers?.body?.each { YamlContract.BodyTestMatcher testMatcher ->
|
||||
MatchingTypeValue value = null
|
||||
|
||||
@@ -121,6 +121,7 @@ class YamlContractConverterSpec extends Specification {
|
||||
contract.request.bodyMatchers.jsonPathRegexMatchers[0].value() == 'bar'
|
||||
and:
|
||||
contract.response.status.clientValue == 200
|
||||
if (yamlFile == ymlWithRest) contract.response.delay.clientValue == 1000 else !contract.response.delay
|
||||
contract.response.headers.entries.find { it.name == "foo2" &&
|
||||
((Pattern) it.serverValue).pattern == "bar" && it.clientValue == "bar" }
|
||||
contract.response.headers.entries.find { it.name == "foo3" &&
|
||||
@@ -570,6 +571,7 @@ class YamlContractConverterSpec extends Specification {
|
||||
body([foo: "bar"])
|
||||
}
|
||||
response {
|
||||
fixedDelayMilliseconds 1000
|
||||
status(200)
|
||||
headers {
|
||||
header("foo2", "bar")
|
||||
@@ -597,6 +599,7 @@ class YamlContractConverterSpec extends Specification {
|
||||
yamlContract.response.body == [foo2: "bar"]
|
||||
yamlContract.response.cookies.find { it.key == "foo" && it.value == "client" }
|
||||
yamlContract.response.cookies.find { it.key == "bar" && it.value == "client" }
|
||||
yamlContract.response.fixedDelayMilliseconds == 1000
|
||||
}
|
||||
|
||||
def "should convert multiple messaging DSLs to YAML"() {
|
||||
|
||||
@@ -52,6 +52,7 @@ response:
|
||||
#tag::response_obligatory[]
|
||||
status: 200
|
||||
#end::response_obligatory[]
|
||||
fixedDelayMilliseconds: 1000
|
||||
headers:
|
||||
foo2: bar
|
||||
foo3: foo33
|
||||
|
||||
Reference in New Issue
Block a user