From 05265fb9848c04e6c6c57614c7aaeff2f7b9afc3 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Tue, 10 Jan 2017 17:59:28 +0000 Subject: [PATCH] Sync docs from 1.0.x to gh-pages --- 1.0.x/spring-cloud-contract.html | 104 +++++++++++++++---------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/1.0.x/spring-cloud-contract.html b/1.0.x/spring-cloud-contract.html index 4dea874f40..b06b67f32e 100644 --- a/1.0.x/spring-cloud-contract.html +++ b/1.0.x/spring-cloud-contract.html @@ -764,8 +764,6 @@ $(addBlockSwitches);
  • Dynamic properties in matchers sections
  • -
  • Contract DSL
  • -
  • Base Mock Spec
  • JAX-RS support
  • @@ -6702,7 +6700,57 @@ String isoTime() {
    Executing custom methods on server side

    It is also possible to define a method call to be executed on the server side during the test. Such a method can be added to the class defined as "baseClassForTests" -in the configuration. Please see the examples below:

    +in the configuration. Example:

    +
    +
    +

    Contract

    +
    +
    +
    +
    org.springframework.cloud.contract.spec.Contract.make {
    +	request {
    +		method 'PUT'
    +		url $(consumer(regex('^/api/[0-9]{2}$')), producer('/api/12'))
    +		headers {
    +			header 'Content-Type': 'application/json'
    +		}
    +		body '''\
    +				[{
    +					"text": "Gonna see you at Warsaw"
    +				}]
    +			'''
    +	}
    +	response {
    +		body (
    +				path: $(consumer('/api/12'), producer(regex('^/api/[0-9]{2}$'))),
    +				correlationId: $(consumer('1223456'), producer(execute('isProperCorrelationId($it)')))
    +		)
    +		status 200
    +	}
    +}
    +
    +
    +
    +

    Base class

    +
    +
    +
    +
    abstract class BaseMockMvcSpec extends Specification {
    +
    +	def setup() {
    +		RestAssuredMockMvc.standaloneSetup(new PairIdController())
    +	}
    +
    +	void isProperCorrelationId(Integer correlationId) {
    +		assert correlationId == 123456
    +	}
    +
    +	void isEmpty(String value) {
    +		assert value == null
    +	}
    +
    +}
    +
    @@ -6982,56 +7030,6 @@ assertions and the one from matchers with an and section):

    -
    -
    Contract DSL
    -
    -
    -
    org.springframework.cloud.contract.spec.Contract.make {
    -	request {
    -		method 'PUT'
    -		url $(consumer(regex('^/api/[0-9]{2}$')), producer('/api/12'))
    -		headers {
    -			header 'Content-Type': 'application/json'
    -		}
    -		body '''\
    -				[{
    -					"text": "Gonna see you at Warsaw"
    -				}]
    -			'''
    -	}
    -	response {
    -		body (
    -				path: $(consumer('/api/12'), producer(regex('^/api/[0-9]{2}$'))),
    -				correlationId: $(consumer('1223456'), producer(execute('isProperCorrelationId($it)')))
    -		)
    -		status 200
    -	}
    -}
    -
    -
    -
    -
    -
    Base Mock Spec
    -
    -
    -
    abstract class BaseMockMvcSpec extends Specification {
    -
    -	def setup() {
    -		RestAssuredMockMvc.standaloneSetup(new PairIdController())
    -	}
    -
    -	void isProperCorrelationId(Integer correlationId) {
    -		assert correlationId == 123456
    -	}
    -
    -	void isEmpty(String value) {
    -		assert value == null
    -	}
    -
    -}
    -
    -
    -

    JAX-RS support