From 2d1ffd512f80521b85b841e4dc50f672c5541edb Mon Sep 17 00:00:00 2001 From: buildmaster Date: Sun, 12 Aug 2018 06:32:00 +0000 Subject: [PATCH] Sync docs from 2.0.x to gh-pages --- 2.0.x/multi/multi__customization.html | 43 +++++++++++- ...ti__spring_cloud_contract_stub_runner.html | 25 ++++++- 2.0.x/single/spring-cloud-contract.html | 68 ++++++++++++++++++- 2.0.x/spring-cloud-contract.xml | 68 ++++++++++++++++++- 4 files changed, 195 insertions(+), 9 deletions(-) diff --git a/2.0.x/multi/multi__customization.html b/2.0.x/multi/multi__customization.html index 5b5a284ccd..3522c8d4ec 100644 --- a/2.0.x/multi/multi__customization.html +++ b/2.0.x/multi/multi__customization.html @@ -173,4 +173,45 @@ following example:

Maven.  </plugin>

Gradle. 

classpath "com.example:beer-common:0.0.1-SNAPSHOT"

-

9.1.5 Referencing classes in DSLs

You can now reference your classes in your DSL, as shown in the following example:

Unresolved directive in verifier_contract.adoc - include::https://raw.githubusercontent.com/spring-cloud-samples/spring-cloud-contract-samples/master/producer/src/test/resources/contracts/beer/rest/shouldGrantABeerIfOldEnough.groovy[indent=0]
\ No newline at end of file +

9.1.5 Referencing classes in DSLs

You can now reference your classes in your DSL, as shown in the following example:

package contracts.beer.rest
+
+import com.example.ConsumerUtils
+import com.example.ProducerUtils
+import org.springframework.cloud.contract.spec.Contract
+
+Contract.make {
+	description("""
+Represents a successful scenario of getting a beer
+
+```
+given:
+	client is old enough
+when:
+	he applies for a beer
+then:
+	we'll grant him the beer
+```
+
+""")
+	request {
+		method 'POST'
+		url '/check'
+		body(
+				age: $(ConsumerUtils.oldEnough())
+		)
+		headers {
+			contentType(applicationJson())
+		}
+	}
+	response {
+		status 200
+		body("""
+			{
+				"status": "${value(ProducerUtils.ok())}"
+			}
+			""")
+		headers {
+			contentType(applicationJson())
+		}
+	}
+}
\ No newline at end of file diff --git a/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html b/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html index 01b281f817..c8f3a9b83e 100644 --- a/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html +++ b/2.0.x/multi/multi__spring_cloud_contract_stub_runner.html @@ -71,10 +71,31 @@ versions, which are automatically uploaded after every successful build:

[Tip]Tip

For both Maven and Gradle, the setup comes ready to work. However, you can customize it if you want to.

Maven. 

<!-- First disable the default jar setup in the properties section -->
-Unresolved directive in verifier_stubrunner.adoc - include::https://raw.githubusercontent.com/spring-cloud-samples/spring-cloud-contract-samples/master/producer_with_restdocs/pom.xml[tags=skip_jar,indent=0]
+<!-- we don't want the verifier to do a jar for us -->
+<spring.cloud.contract.verifier.skip>true</spring.cloud.contract.verifier.skip>
 
 <!-- Next add the assembly plugin to your build -->
-Unresolved directive in verifier_stubrunner.adoc - include::https://raw.githubusercontent.com/spring-cloud-samples/spring-cloud-contract-samples/master/producer_with_restdocs/pom.xml[tags=assembly,indent=0]
+<!-- we want the assembly plugin to generate the JAR -->
+<plugin>
+	<groupId>org.apache.maven.plugins</groupId>
+	<artifactId>maven-assembly-plugin</artifactId>
+	<executions>
+		<execution>
+			<id>stub</id>
+			<phase>prepare-package</phase>
+			<goals>
+				<goal>single</goal>
+			</goals>
+			<inherited>false</inherited>
+			<configuration>
+				<attach>true</attach>
+				<descriptors>
+					${basedir}/src/assembly/stub.xml
+				</descriptors>
+			</configuration>
+		</execution>
+	</executions>
+</plugin>
 
 <!-- Finally setup your assembly. Below you can find the contents of src/main/assembly/stub.xml -->
 <assembly
diff --git a/2.0.x/single/spring-cloud-contract.html b/2.0.x/single/spring-cloud-contract.html
index f0f65f229a..0d8c692517 100644
--- a/2.0.x/single/spring-cloud-contract.html
+++ b/2.0.x/single/spring-cloud-contract.html
@@ -2439,10 +2439,31 @@ versions, which are automatically uploaded after every successful build:

[Tip]Tip

For both Maven and Gradle, the setup comes ready to work. However, you can customize it if you want to.

Maven. 

<!-- First disable the default jar setup in the properties section -->
-Unresolved directive in verifier_stubrunner.adoc - include::https://raw.githubusercontent.com/spring-cloud-samples/spring-cloud-contract-samples/master/producer_with_restdocs/pom.xml[tags=skip_jar,indent=0]
+<!-- we don't want the verifier to do a jar for us -->
+<spring.cloud.contract.verifier.skip>true</spring.cloud.contract.verifier.skip>
 
 <!-- Next add the assembly plugin to your build -->
-Unresolved directive in verifier_stubrunner.adoc - include::https://raw.githubusercontent.com/spring-cloud-samples/spring-cloud-contract-samples/master/producer_with_restdocs/pom.xml[tags=assembly,indent=0]
+<!-- we want the assembly plugin to generate the JAR -->
+<plugin>
+	<groupId>org.apache.maven.plugins</groupId>
+	<artifactId>maven-assembly-plugin</artifactId>
+	<executions>
+		<execution>
+			<id>stub</id>
+			<phase>prepare-package</phase>
+			<goals>
+				<goal>single</goal>
+			</goals>
+			<inherited>false</inherited>
+			<configuration>
+				<attach>true</attach>
+				<descriptors>
+					${basedir}/src/assembly/stub.xml
+				</descriptors>
+			</configuration>
+		</execution>
+	</executions>
+</plugin>
 
 <!-- Finally setup your assembly. Below you can find the contents of src/main/assembly/stub.xml -->
 <assembly
@@ -5488,7 +5509,48 @@ following example:

Maven.  </plugin>

Gradle. 

classpath "com.example:beer-common:0.0.1-SNAPSHOT"

-

9.1.5 Referencing classes in DSLs

You can now reference your classes in your DSL, as shown in the following example:

Unresolved directive in verifier_contract.adoc - include::https://raw.githubusercontent.com/spring-cloud-samples/spring-cloud-contract-samples/master/producer/src/test/resources/contracts/beer/rest/shouldGrantABeerIfOldEnough.groovy[indent=0]

10. Using the Pluggable Architecture

You may encounter cases where you have your contracts have been defined in other formats, +

9.1.5 Referencing classes in DSLs

You can now reference your classes in your DSL, as shown in the following example:

package contracts.beer.rest
+
+import com.example.ConsumerUtils
+import com.example.ProducerUtils
+import org.springframework.cloud.contract.spec.Contract
+
+Contract.make {
+	description("""
+Represents a successful scenario of getting a beer
+
+```
+given:
+	client is old enough
+when:
+	he applies for a beer
+then:
+	we'll grant him the beer
+```
+
+""")
+	request {
+		method 'POST'
+		url '/check'
+		body(
+				age: $(ConsumerUtils.oldEnough())
+		)
+		headers {
+			contentType(applicationJson())
+		}
+	}
+	response {
+		status 200
+		body("""
+			{
+				"status": "${value(ProducerUtils.ok())}"
+			}
+			""")
+		headers {
+			contentType(applicationJson())
+		}
+	}
+}

10. Using the Pluggable Architecture

You may encounter cases where you have your contracts have been defined in other formats, such as YAML, RAML or PACT. In those cases, you still want to benefit from the automatic generation of tests and stubs. You can add your own implementation for generating both tests and stubs. Also, you can customize the way tests are generated (for example, you diff --git a/2.0.x/spring-cloud-contract.xml b/2.0.x/spring-cloud-contract.xml index 00926a928c..240db349c0 100644 --- a/2.0.x/spring-cloud-contract.xml +++ b/2.0.x/spring-cloud-contract.xml @@ -4162,10 +4162,31 @@ it if you want to. Maven <!-- First disable the default jar setup in the properties section --> -Unresolved directive in verifier_stubrunner.adoc - include::https://raw.githubusercontent.com/spring-cloud-samples/spring-cloud-contract-samples/master/producer_with_restdocs/pom.xml[tags=skip_jar,indent=0] +<!-- we don't want the verifier to do a jar for us --> +<spring.cloud.contract.verifier.skip>true</spring.cloud.contract.verifier.skip> <!-- Next add the assembly plugin to your build --> -Unresolved directive in verifier_stubrunner.adoc - include::https://raw.githubusercontent.com/spring-cloud-samples/spring-cloud-contract-samples/master/producer_with_restdocs/pom.xml[tags=assembly,indent=0] +<!-- we want the assembly plugin to generate the JAR --> +<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>stub</id> + <phase>prepare-package</phase> + <goals> + <goal>single</goal> + </goals> + <inherited>false</inherited> + <configuration> + <attach>true</attach> + <descriptors> + ${basedir}/src/assembly/stub.xml + </descriptors> + </configuration> + </execution> + </executions> +</plugin> <!-- Finally setup your assembly. Below you can find the contents of src/main/assembly/stub.xml --> <assembly @@ -8779,7 +8800,48 @@ following example:

Referencing classes in DSLs You can now reference your classes in your DSL, as shown in the following example: -Unresolved directive in verifier_contract.adoc - include::https://raw.githubusercontent.com/spring-cloud-samples/spring-cloud-contract-samples/master/producer/src/test/resources/contracts/beer/rest/shouldGrantABeerIfOldEnough.groovy[indent=0] +package contracts.beer.rest + +import com.example.ConsumerUtils +import com.example.ProducerUtils +import org.springframework.cloud.contract.spec.Contract + +Contract.make { + description(""" +Represents a successful scenario of getting a beer + +``` +given: + client is old enough +when: + he applies for a beer +then: + we'll grant him the beer +``` + +""") + request { + method 'POST' + url '/check' + body( + age: $(ConsumerUtils.oldEnough()) + ) + headers { + contentType(applicationJson()) + } + } + response { + status 200 + body(""" + { + "status": "${value(ProducerUtils.ok())}" + } + """) + headers { + contentType(applicationJson()) + } + } +}