Merge branch '2.0.x'

This commit is contained in:
Marcin Grzejszczak
2018-11-08 17:21:34 +01:00
6 changed files with 32 additions and 0 deletions

View File

@@ -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.

View File

@@ -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 ->

View File

@@ -217,6 +217,7 @@ class YamlContract {
public String bodyFromFile
public TestMatchers matchers = new TestMatchers()
public Boolean async
public Integer fixedDelayMilliseconds
}
@CompileStatic

View File

@@ -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

View File

@@ -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"() {

View File

@@ -52,6 +52,7 @@ response:
#tag::response_obligatory[]
status: 200
#end::response_obligatory[]
fixedDelayMilliseconds: 1000
headers:
foo2: bar
foo3: foo33