Upgraded to Greenwhich

This commit is contained in:
Marcin Grzejszczak
2018-08-29 14:04:28 +02:00
parent da2989b053
commit 096790e04d
88 changed files with 779 additions and 403 deletions

1
.gitignore vendored
View File

@@ -33,6 +33,7 @@ hs_err_pid*
.gradle/
target/
build/
out/
hs_err_pid*
.DS_Store

View File

@@ -2,7 +2,7 @@
set -e
WRAPPER_VERSION="4.4.1"
WRAPPER_VERSION="4.10"
GRADLE_BIN_DIR="gradle-${WRAPPER_VERSION}-bin"
GRADLE_WRAPPER_DIR="${HOME}/.gradle/wrapper/dists/${GRADLE_BIN_DIR}"
CURRENT_DIR="$( pwd )"

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip

93
pom.xml
View File

@@ -42,6 +42,8 @@
<handlebars.version>4.0.6</handlebars.version>
<jgit.version>4.6.0.201612231935-r</jgit.version>
<javax-inject.version>1</javax-inject.version>
<!-- We need to have compatibility with Gradle -->
<groovy.version>2.4.15</groovy.version>
</properties>
<modules>
@@ -228,6 +230,97 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-ant</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-bsf</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-console</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-docgenerator</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-groovydoc</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-groovysh</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-jmx</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-json</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-jsr223</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-nio</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-servlet</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-sql</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-swing</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-templates</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-test</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-testng</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-xml</artifactId>
<version>${groovy.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.0.M2</version>
<relativePath />
</parent>
@@ -21,7 +21,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract.version>2.1.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
<spring-cloud-release.version>Finchley.BUILD-SNAPSHOT</spring-cloud-release.version>
<spring-cloud-release.version>Greenwich.BUILD-SNAPSHOT</spring-cloud-release.version>
<excludeBuildFolders>true</excludeBuildFolders>
</properties>

View File

@@ -7,7 +7,7 @@ buildscript {
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
}
}

View File

@@ -1,2 +1,2 @@
org.gradle.daemon=false
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:41:49 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -20,7 +20,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-release-train.version>Finchley.BUILD-SNAPSHOT</spring-cloud-release-train.version>
<spring-cloud-release-train.version>Greenwich.BUILD-SNAPSHOT</spring-cloud-release-train.version>
</properties>
<dependencies>

View File

@@ -10,7 +10,7 @@ buildscript {
// end::repos[]
dependencies {
classpath 'org.codehaus.groovy:groovy-all:2.5.0-beta-1'
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${findProperty('verifierVersion') ?: verifierVersion}"
}
}

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=false
verifierVersion=2.1.0.BUILD-SNAPSHOT
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:41:57 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.0.M2</version>
<relativePath />
</parent>
@@ -21,7 +21,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract.version>2.1.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
<spring-cloud-release.version>Finchley.BUILD-SNAPSHOT</spring-cloud-release.version>
<spring-cloud-release.version>Greenwich.BUILD-SNAPSHOT</spring-cloud-release.version>
</properties>
<dependencies>

View File

@@ -7,7 +7,7 @@ buildscript {
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
}
}

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=false
verifierVersion=2.1.0.BUILD-SNAPSHOT
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:42:27 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.0.M2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
@@ -48,7 +48,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.BUILD-SNAPSHOT</version>
<version>Greenwich.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@@ -7,10 +7,11 @@ buildscript {
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${findProperty('verifierVersion') ?: verifierVersion}"
classpath "com.jayway.restassured:rest-assured:2.9.0"
classpath "com.jayway.restassured:spring-mock-mvc:2.9.0"
// Example of using Rest Assured 3.x. If you don't add this section Rest Assured 2.9.0 will be used
// classpath "com.jayway.restassured:rest-assured:2.9.0"
// classpath "com.jayway.restassured:spring-mock-mvc:2.9.0"
}
}
@@ -55,8 +56,9 @@ dependencies {
testCompile 'org.springframework.cloud:spring-cloud-starter-contract-verifier'
testCompile "org.springframework.cloud:spring-cloud-stream-test-support"
testCompile "com.jayway.restassured:rest-assured:2.9.0"
testCompile "com.jayway.restassured:spring-mock-mvc:2.9.0"
// Example of using Rest Assured 3.x. If you don't add this section Rest Assured 2.9.0 will be used
// testCompile "com.jayway.restassured:rest-assured:2.9.0"
// testCompile "com.jayway.restassured:spring-mock-mvc:2.9.0"
}
task stubsJar(type: Jar, dependsOn: "generateClientStubs") {

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=false
verifierVersion=2.1.0.BUILD-SNAPSHOT
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:42:35 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.0.M2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
@@ -41,23 +41,12 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-verifier</artifactId>
<version>${spring-cloud-contract.version}</version>
<artifactId>spring-cloud-starter-contract-verifier</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
</exclusion>
<exclusion>
<groupId>io.rest-assured</groupId>
<artifactId>spring-mock-mvc</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Example of overriding Rest Assured version -->
<dependency>
<!--<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.9.0</version>
@@ -68,7 +57,7 @@
<artifactId>spring-mock-mvc</artifactId>
<version>2.9.0</version>
<scope>test</scope>
</dependency>
</dependency>-->
</dependencies>
<dependencyManagement>
@@ -76,7 +65,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.BUILD-SNAPSHOT</version>
<version>Greenwich.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -104,7 +93,7 @@
</configuration>
<!-- Example of using Rest Assured 3.x. If you don't add this section Rest Assured 2.9.0 will be used -->
<dependencies>
<!--<dependencies>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
@@ -117,7 +106,7 @@
<version>2.9.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencies>-->
</plugin>
<plugin>

View File

@@ -16,7 +16,7 @@
package com.example.source;
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
import io.restassured.module.mockmvc.RestAssuredMockMvc;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -7,7 +7,7 @@ buildscript {
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
}
}

View File

@@ -1,2 +1,2 @@
org.gradle.daemon=false
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:42:45 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -20,7 +20,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-release-train.version>Finchley.BUILD-SNAPSHOT</spring-cloud-release-train.version>
<spring-cloud-release-train.version>Greenwich.BUILD-SNAPSHOT</spring-cloud-release-train.version>
</properties>
<dependencies>

View File

@@ -7,7 +7,7 @@ buildscript {
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${findProperty('verifierVersion') ?: verifierVersion}"
//tag::pact_dependency[]
classpath "org.springframework.cloud:spring-cloud-contract-pact:${findProperty('verifierVersion') ?: verifierVersion}"

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=false
verifierVersion=2.1.0.BUILD-SNAPSHOT
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:42:54 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.0.M2</version>
<relativePath />
</parent>
@@ -21,7 +21,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract.version>2.1.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
<spring-cloud-release.version>Finchley.BUILD-SNAPSHOT</spring-cloud-release.version>
<spring-cloud-release.version>Greenwich.BUILD-SNAPSHOT</spring-cloud-release.version>
</properties>
<dependencies>

View File

@@ -7,7 +7,7 @@ buildscript {
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
}
}

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=false
verifierVersion=2.1.0.BUILD-SNAPSHOT
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:43:04 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.0.M2</version>
<relativePath />
</parent>

View File

@@ -29,10 +29,10 @@ public class LoanApplicationServiceTests {
@Autowired
private LoanApplicationService service;
@Value("classpath:META-INF/com.example/http-server-restdocs/0.0.1-SNAPSHOT/mappings/markClientAsFraud.json")
@Value("classpath:META-INF/com.example/http-server-restdocs/0.0.1-SNAPSHOT/mappings/standalone/shouldMarkClientAsFraud.json")
private Resource markClientAsFraud;
@Value("classpath:META-INF/com.example/http-server-restdocs/0.0.1-SNAPSHOT/mappings/markClientAsNotFraud.json")
@Value("classpath:META-INF/com.example/http-server-restdocs/0.0.1-SNAPSHOT/mappings/webapp/shouldMarkClientAsNotFraud.json")
private Resource markClientAsNotFraud;
@Autowired

View File

@@ -10,7 +10,7 @@ buildscript {
maven { url "http://repo.spring.io/plugins-staging-local/" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${project.findProperty('verifierVersion') ?: verifierVersion}"
}
}
@@ -70,7 +70,7 @@ contracts {
generateClientStubs.enabled = false
task wrapper(type: Wrapper) {
gradleVersion = '4.0.2'
gradleVersion = '4.10'
}
task stubsJar(type: Jar, dependsOn: ['copySnippets', 'copySources', 'copyClasses']) {

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=false
verifierVersion=2.1.0.BUILD-SNAPSHOT
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:43:13 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.0.M2</version>
<relativePath />
</parent>
@@ -21,7 +21,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract.version>2.1.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
<spring.cloud.contract.verifier.skip>true</spring.cloud.contract.verifier.skip>
<spring.cloud.contract.verifier.jar.skip>true</spring.cloud.contract.verifier.jar.skip>
</properties>
<dependencies>

View File

@@ -1 +1 @@
rootProject.name = 'http-server-restdocs-gradle'
rootProject.name = 'http-server-restdocs'

View File

@@ -29,5 +29,12 @@
<include>**/*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/stubs</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@@ -24,7 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
@AutoConfigureRestDocs(outputDir = "target/snippets")
@AutoConfigureRestDocs
@AutoConfigureMockMvc
@AutoConfigureJsonTesters
public class StubGeneratorTests {

View File

@@ -7,7 +7,7 @@ buildscript {
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
}
}

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=false
verifierVersion=2.1.0.BUILD-SNAPSHOT
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:43:22 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.0.M2</version>
<relativePath />
</parent>

View File

@@ -10,7 +10,7 @@ buildscript {
maven { url "http://repo.spring.io/plugins-staging-local/" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
}
}

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=false
verifierVersion=2.1.0.BUILD-SNAPSHOT
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:43:29 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.0.M2</version>
<relativePath />
</parent>

View File

@@ -7,7 +7,7 @@ buildscript {
maven { url "http://repo.spring.io/release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
}
}
@@ -48,7 +48,7 @@ test {
}
task wrapper(type: Wrapper) {
gradleVersion = '2.14'
gradleVersion = '4.10'
}
task resolveDependencies {

View File

@@ -1,2 +1,2 @@
org.gradle.daemon=false
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -20,7 +20,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-release.version>Finchley.BUILD-SNAPSHOT</spring-cloud-release.version>
<spring-cloud-release.version>Greenwich.BUILD-SNAPSHOT</spring-cloud-release.version>
</properties>
<dependencies>

View File

@@ -9,7 +9,7 @@ buildscript {
}
// end::repos[]
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.0.M2"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${findProperty('verifierVersion') ?: verifierVersion}"
}
}
@@ -59,7 +59,7 @@ test {
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4.1'
gradleVersion = '4.10'
}
clean.doFirst {

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=false
verifierVersion=2.1.0.BUILD-SNAPSHOT
BOM_VERSION=Finchley.BUILD-SNAPSHOT
BOM_VERSION=Greenwich.BUILD-SNAPSHOT

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.0.M2</version>
<relativePath />
</parent>
@@ -21,7 +21,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-cloud-contract.version>2.1.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
<spring-cloud-release.version>Finchley.BUILD-SNAPSHOT</spring-cloud-release.version>
<spring-cloud-release.version>Greenwich.BUILD-SNAPSHOT</spring-cloud-release.version>
</properties>
<dependencies>

View File

@@ -37,6 +37,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -1,6 +1,6 @@
#Mon Jul 31 11:13:36 CEST 2017
#Tue Aug 28 16:43:49 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

View File

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
fi
# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}

View File

@@ -138,6 +138,95 @@ class MessagingSCContractCreator {
})
}
protected Closure<Contract> process() {
return { Message message ->
Contract.make {
label("$message.description")
if (!message.providerStates.isEmpty()) {
input {
triggeredBy(getTriggeredBy(message))
}
}
outputMessage {
if (message.contents.present) {
body(BodyConverter.toSCCBody(message))
Category bodyRules = message.matchingRules.rulesForCategory('body')
if (bodyRules && !bodyRules.matchingRules.isEmpty()) {
bodyMatchers {
bodyRules.matchingRules.each { String key, MatchingRuleGroup ruleGroup ->
if (ruleGroup.ruleLogic != RuleLogic.AND) {
throw new UnsupportedOperationException("Currently only the AND combination rule logic is supported")
}
if (FULL_BODY.equals(key)) {
JsonPaths jsonPaths = JsonToJsonPathsConverter.transformToJsonPathWithStubsSideValuesAndNoArraySizeCheck(message.contents.value)
jsonPaths.each {
jsonPath(it.keyBeforeChecking(), byType())
}
} else {
ruleGroup.rules.each { MatchingRule rule ->
if (rule instanceof NullMatcher) {
jsonPath(key, byNull())
} else if (rule instanceof RegexMatcher) {
jsonPath(key, byRegex(rule.regex))
} else if (rule instanceof DateMatcher) {
jsonPath(key, byDate())
} else if (rule instanceof TimeMatcher) {
jsonPath(key, byTime())
} else if (rule instanceof TimestampMatcher) {
jsonPath(key, byTimestamp())
} else if (rule instanceof MinTypeMatcher) {
jsonPath(key, byType() {
minOccurrence((rule as MinTypeMatcher).min)
})
} else if (rule instanceof MinMaxTypeMatcher) {
jsonPath(key, byType() {
minOccurrence((rule as MinMaxTypeMatcher).min)
maxOccurrence((rule as MinMaxTypeMatcher).max)
})
} else if (rule instanceof MaxTypeMatcher) {
jsonPath(key, byType() {
maxOccurrence((rule as MaxTypeMatcher).max)
})
} else if (rule instanceof TypeMatcher) {
jsonPath(key, byType())
} else if (rule instanceof NumberTypeMatcher) {
switch (rule.numberType) {
case NumberTypeMatcher.NumberType.NUMBER:
jsonPath(key, byRegex(number()))
break
case NumberTypeMatcher.NumberType.INTEGER:
jsonPath(key, byRegex(anInteger()))
break
case NumberTypeMatcher.NumberType.DECIMAL:
jsonPath(key, byRegex(aDouble()))
break
default:
throw new RuntimeException("Unsupported number type!")
}
}
}
}
}
}
}
}
if (!message.metaData.isEmpty()) {
headers {
message.metaData.each { String k, String v ->
if (k.equalsIgnoreCase("contentType")) {
messagingContentType(v)
} else {
header(k, v)
}
}
}
}
}
}
}
}
private String getTriggeredBy(Message message) {
return message.providerStates.first().name
.replace(':', ' ')

View File

@@ -64,14 +64,14 @@ class PactContractConverter implements ContractConverter<Collection<Pact>> {
@Override
Collection<Pact> convertTo(Collection<Contract> contracts) {
List<Pact> pactContracts = new ArrayList<>()
contracts.collect({ Contract contract ->
for (Contract contract : contracts) {
if (contract.request) {
pactContracts.add(requestResponsePactCreator.createFromContract(contract))
}
if (contract.input) {
pactContracts.add(messagePactCreator.createFromContract(contract))
}
})
}
return pactContracts
}
}

View File

@@ -246,6 +246,193 @@ class RequestResponseSCContractCreator {
}
}
protected Closure<Contract> process() {
return { RequestResponseInteraction interaction ->
Contract.make {
description(buildDescription(interaction))
request {
Request request = interaction.request
method(request.method)
if (request.query) {
url(request.path) {
queryParameters {
request.query.each { String key, List<String> value ->
value.each { String singleValue ->
parameter(key, singleValue)
}
}
}
}
} else {
url(request.path)
}
if (request.headers) {
Category headerRules = request.matchingRules.rulesForCategory('header')
headers {
request.headers.each { k, v ->
if (headerRules.matchingRules.containsKey(k)) {
MatchingRuleGroup ruleGroup = headerRules.matchingRules.get(k)
if (ruleGroup.rules.size() > 1) {
throw new UnsupportedOperationException("Currently only 1 rule at a time for a header is supported")
}
MatchingRule rule = ruleGroup.rules[0]
if (rule instanceof RegexMatcher) {
header(k, new DslProperty((Object)Pattern.compile(rule.getRegex()), (Object)v))
} else {
throw new UnsupportedOperationException("Currently only the header matcher of type regex is supported")
}
} else {
header(k, v)
}
}
}
}
if (request.body.state == OptionalBody.State.PRESENT) {
def parsedBody = BodyConverter.toSCCBody(request)
if (parsedBody instanceof Map) {
body(parsedBody as Map)
} else if (parsedBody instanceof List) {
body(parsedBody as List)
} else {
body(parsedBody.toString())
}
}
Category bodyRules = request.matchingRules.rulesForCategory('body')
if (bodyRules && !bodyRules.matchingRules.isEmpty()) {
bodyMatchers {
bodyRules.matchingRules.each { String key, MatchingRuleGroup ruleGroup ->
if (ruleGroup.ruleLogic != RuleLogic.AND) {
throw new UnsupportedOperationException("Currently only the AND combination rule logic is supported")
}
ruleGroup.rules.each { MatchingRule rule ->
if (rule instanceof RegexMatcher) {
jsonPath(key, byRegex(rule.regex))
} else if (rule instanceof DateMatcher) {
jsonPath(key, byDate())
} else if (rule instanceof TimeMatcher) {
jsonPath(key, byTime())
} else if (rule instanceof TimestampMatcher) {
jsonPath(key, byTimestamp())
} else if (rule instanceof NumberTypeMatcher) {
switch (rule.numberType) {
case NumberTypeMatcher.NumberType.NUMBER:
jsonPath(key, byRegex(regexPatterns.number()))
break
case NumberTypeMatcher.NumberType.INTEGER:
jsonPath(key, byRegex(regexPatterns.anInteger()))
break
case NumberTypeMatcher.NumberType.DECIMAL:
jsonPath(key, byRegex(regexPatterns.aDouble()))
break
default:
throw new RuntimeException("Unsupported number type!")
}
}
}
}
}
}
}
response {
Response response = interaction.response
status(response.status)
if (response.body.present) {
def parsedBody = BodyConverter.toSCCBody(response)
if (parsedBody instanceof Map) {
body(parsedBody as Map)
} else if (parsedBody instanceof List) {
body(parsedBody as List)
} else {
body(parsedBody.toString())
}
}
Category bodyRules = response.matchingRules.rulesForCategory('body')
if (bodyRules && !bodyRules.matchingRules.isEmpty()) {
bodyMatchers {
bodyRules.matchingRules.each { String key, MatchingRuleGroup ruleGroup ->
if (ruleGroup.ruleLogic != RuleLogic.AND) {
throw new UnsupportedOperationException("Currently only the AND combination rule logic is supported")
}
if (FULL_BODY.equals(key)) {
JsonPaths jsonPaths = JsonToJsonPathsConverter.transformToJsonPathWithStubsSideValuesAndNoArraySizeCheck(response.body.value)
jsonPaths.each {
jsonPath(it.keyBeforeChecking(), byType())
}
} else {
ruleGroup.rules.each { MatchingRule rule ->
if (rule instanceof NullMatcher) {
jsonPath(key, byNull())
} else if (rule instanceof RegexMatcher) {
jsonPath(key, byRegex(rule.regex))
} else if (rule instanceof DateMatcher) {
jsonPath(key, byDate())
} else if (rule instanceof TimeMatcher) {
jsonPath(key, byTime())
} else if (rule instanceof TimestampMatcher) {
jsonPath(key, byTimestamp())
} else if (rule instanceof MinTypeMatcher) {
jsonPath(key, byType() {
minOccurrence((rule as MinTypeMatcher).min)
})
} else if (rule instanceof MinMaxTypeMatcher) {
jsonPath(key, byType() {
minOccurrence((rule as MinMaxTypeMatcher).min)
maxOccurrence((rule as MinMaxTypeMatcher).max)
})
} else if (rule instanceof MaxTypeMatcher) {
jsonPath(key, byType() {
maxOccurrence((rule as MaxTypeMatcher).max)
})
} else if (rule instanceof TypeMatcher) {
jsonPath(key, byType())
} else if (rule instanceof NumberTypeMatcher) {
switch (rule.numberType) {
case NumberTypeMatcher.NumberType.NUMBER:
jsonPath(key, byRegex(regexPatterns.number()))
break
case NumberTypeMatcher.NumberType.INTEGER:
jsonPath(key, byRegex(regexPatterns.anInteger()))
break
case NumberTypeMatcher.NumberType.DECIMAL:
jsonPath(key, byRegex(regexPatterns.aDouble()))
break
default:
throw new UnsupportedOperationException("Unsupported number type!")
}
}
}
}
}
}
}
if (response.headers) {
Category headerRules = response.matchingRules.rulesForCategory('header')
headers {
response.headers.forEach({ String k, String v ->
if (headerRules.matchingRules.containsKey(k)) {
MatchingRuleGroup ruleGroup = headerRules.matchingRules.get(k)
if (ruleGroup.rules.size() > 1) {
throw new UnsupportedOperationException("Currently only 1 rule at a time for a header is supported")
}
MatchingRule rule = ruleGroup.rules[0]
if (rule instanceof RegexMatcher) {
header(k, new DslProperty(new DslProperty(v), new NotToEscapePattern(Pattern.compile(rule.getRegex()))))
} else {
throw new UnsupportedOperationException("Currently only the header matcher of type regex is supported")
}
} else {
header(k, v)
}
})
}
}
}
}
}
}
private String buildDescription(RequestResponseInteraction interaction) {
String description = "$interaction.description"
interaction.providerStates.forEach({ ProviderState it ->

View File

@@ -73,172 +73,295 @@ class YamlContractConverter implements ContractConverter<List<YamlContract>> {
ClassLoader classLoader = YamlContractConverter.getClassLoader()
ObjectMapper mapper = new ObjectMapper()
try {
return new Yaml().loadAll(Files.newInputStream(contractFile.toPath())).collect {
YamlContract yamlContract = mapper.convertValue(it, YamlContract.class);
Thread.currentThread().setContextClassLoader(updatedClassLoader(contractFile.getParentFile(), classLoader))
return Contract.make {
if (yamlContract.description) description(yamlContract.description)
if (yamlContract.label) label(yamlContract.label)
if (yamlContract.name) name(yamlContract.name)
if (yamlContract.priority) priority(yamlContract.priority)
if (yamlContract.ignored) ignored()
if (yamlContract.request?.method) {
request {
method(yamlContract.request?.method)
if (yamlContract.request?.url) {
url(yamlContract.request?.url) {
if (yamlContract.request.queryParameters) {
queryParameters {
yamlContract.request.queryParameters.each { String key, Object value ->
if (value instanceof List) {
((List) value).each {
parameter(key, it)
}
} else {
parameter(key, value)
}
}
}
}
}
}
if (yamlContract.request?.urlPath) {
urlPath(yamlContract.request?.urlPath) {
if (yamlContract.request.queryParameters) {
queryParameters {
yamlContract.request.queryParameters.each { String key, Object value ->
if (value instanceof List) {
((List) value).each {
parameter(key, it)
}
} else {
parameter(key, value)
}
}
}
}
}
}
if (yamlContract.request?.headers) {
headers {
yamlContract.request?.headers?.each { String key, Object value ->
KeyValueMatcher matcher = yamlContract.request.matchers.headers.find { it.key == key }
if (value instanceof List) {
((List) value).each {
Object clientValue = clientValue(it, matcher, key)
header(key, new DslProperty(clientValue, it))
}
} else {
Object clientValue = clientValue(value, matcher, key)
header(key, new DslProperty(clientValue, value))
}
}
}
}
if (yamlContract.request?.cookies) {
cookies {
yamlContract.request?.cookies?.each { String key, Object value ->
KeyValueMatcher matcher = yamlContract.request.matchers.cookies.find { it.key == key }
Object clientValue = clientValue(value, matcher, key)
Iterable<Object> iterables = new Yaml().loadAll(Files.newInputStream(contractFile.toPath()))
Collection<Contract> contracts = []
for (Object o : iterables) {
Closure<Contract> processYaml = processYaml(mapper, classLoader, contractFile)
contracts.add(processYaml(o))
}
return contracts
}
catch (FileNotFoundException e) {
throw new IllegalStateException(e)
}
catch (IllegalStateException ise) {
throw ise
}
catch (Exception e1) {
throw new IllegalStateException("Exception occurred while processing the file [" + contractFile + "]", e1)
} finally {
Thread.currentThread().setContextClassLoader(classLoader)
}
}
cookie(key, new DslProperty(clientValue, value))
}
}
}
if (yamlContract.request.body) body(yamlContract.request.body)
if (yamlContract.request.bodyFromFile) body(file(yamlContract.request.bodyFromFile))
if (yamlContract.request.multipart) {
Map multipartMap = [:]
Map<String, DslProperty> multiPartParams = yamlContract.request.multipart.params.collectEntries { String paramKey, String paramValue ->
KeyValueMatcher matcher = yamlContract.request.matchers.multipart.params.find {
it.key == paramKey
}
Object value = paramValue
if (matcher) {
value = matcher.regex ? Pattern.compile(matcher.regex) :
predefinedToPattern(matcher.predefined)
}
return [(paramKey), new DslProperty<>(value, paramValue)]
} as Map<String, DslProperty>
multipartMap.putAll(multiPartParams)
yamlContract.request.multipart.named.each { Named namedParam ->
YamlContract.MultipartNamedStubMatcher matcher = yamlContract.request.matchers.multipart.named.find {
it.paramName == namedParam.paramName
}
Object fileNameValue = namedParam.fileName
Object fileContentValue = namedParam.fileContent
if (matcher && matcher.fileName) {
fileNameValue = matcher.fileName.regex ? Pattern.compile(matcher.fileName.regex) :
predefinedToPattern(matcher.fileName.predefined)
}
if (matcher && matcher.fileContent) {
fileContentValue = matcher.fileContent.regex ? Pattern.compile(matcher.fileContent.regex) :
predefinedToPattern(matcher.fileContent.predefined)
}
multipartMap.put(namedParam.paramName, new NamedProperty(new DslProperty<>(fileNameValue, namedParam.fileName),
new DslProperty<>(fileContentValue, namedParam.fileContent)))
}
multipart(multipartMap)
}
bodyMatchers {
yamlContract.request.matchers?.body?.each { BodyStubMatcher matcher ->
MatchingTypeValue value = null
switch (matcher.type) {
case StubMatcherType.by_date:
value = byDate()
break
case StubMatcherType.by_time:
value = byTime()
break
case StubMatcherType.by_timestamp:
value = byTimestamp()
break
case StubMatcherType.by_regex:
String regex = matcher.value
if (matcher.predefined) {
regex = predefinedToPattern(matcher.predefined).pattern()
protected Closure<Contract> processYaml(ObjectMapper mapper, ClassLoader classLoader, File contractFile) {
return {
YamlContract yamlContract = mapper.convertValue(it, YamlContract.class)
Thread.currentThread().setContextClassLoader(updatedClassLoader(contractFile.getParentFile(), classLoader))
return Contract.make {
if (yamlContract.description) description(yamlContract.description)
if (yamlContract.label) label(yamlContract.label)
if (yamlContract.name) name(yamlContract.name)
if (yamlContract.priority) priority(yamlContract.priority)
if (yamlContract.ignored) ignored()
if (yamlContract.request?.method) {
request {
method(yamlContract.request?.method)
if (yamlContract.request?.url) {
url(yamlContract.request?.url) {
if (yamlContract.request.queryParameters) {
queryParameters {
yamlContract.request.queryParameters.each { String key, Object value ->
if (value instanceof List) {
((List) value).each {
parameter(key, it)
}
} else {
parameter(key, value)
}
value = byRegex(regex)
break
case StubMatcherType.by_equality:
value = byEquality()
break
}
}
jsonPath(matcher.path, value)
}
}
}
response {
status(yamlContract.response.status)
if (yamlContract.request?.urlPath) {
urlPath(yamlContract.request?.urlPath) {
if (yamlContract.request.queryParameters) {
queryParameters {
yamlContract.request.queryParameters.each { String key, Object value ->
if (value instanceof List) {
((List) value).each {
parameter(key, it)
}
} else {
parameter(key, value)
}
}
}
}
}
}
if (yamlContract.request?.headers) {
headers {
yamlContract.response?.headers?.each { String key, Object value ->
TestHeaderMatcher matcher = yamlContract.response.matchers.headers.find { it.key == key }
yamlContract.request?.headers?.each { String key, Object value ->
KeyValueMatcher matcher = yamlContract.request.matchers.headers.find { it.key == key }
if (value instanceof List) {
((List) value).each {
Object serverValue = serverValue(it, matcher, key)
header(key, new DslProperty(it, serverValue))
Object clientValue = clientValue(it, matcher, key)
header(key, new DslProperty(clientValue, it))
}
} else {
Object serverValue = serverValue(value, matcher, key)
header(key, new DslProperty(value, serverValue))
Object clientValue = clientValue(value, matcher, key)
header(key, new DslProperty(clientValue, value))
}
}
}
if (yamlContract.response?.cookies) {
cookies {
yamlContract.response?.cookies?.each { String key, Object value ->
TestCookieMatcher matcher = yamlContract.response.matchers.cookies.find { it.key == key }
Object serverValue = serverCookieValue(value, matcher, key)
}
if (yamlContract.request?.cookies) {
cookies {
yamlContract.request?.cookies?.each { String key, Object value ->
KeyValueMatcher matcher = yamlContract.request.matchers.cookies.find { it.key == key }
Object clientValue = clientValue(value, matcher, key)
cookie(key, new DslProperty(value, serverValue))
}
cookie(key, new DslProperty(clientValue, value))
}
}
if (yamlContract.response.body) body(yamlContract.response.body)
if (yamlContract.response.bodyFromFile) body(file(yamlContract.response.bodyFromFile))
if (yamlContract.response.async) async()
}
if (yamlContract.request.body) body(yamlContract.request.body)
if (yamlContract.request.bodyFromFile) body(file(yamlContract.request.bodyFromFile))
if (yamlContract.request.multipart) {
Map multipartMap = [:]
Map<String, DslProperty> multiPartParams = yamlContract.request.multipart.params.collectEntries { String paramKey, String paramValue ->
KeyValueMatcher matcher = yamlContract.request.matchers.multipart.params.find {
it.key == paramKey
}
Object value = paramValue
if (matcher) {
value = matcher.regex ? Pattern.compile(matcher.regex) :
predefinedToPattern(matcher.predefined)
}
return [(paramKey), new DslProperty<>(value, paramValue)]
} as Map<String, DslProperty>
multipartMap.putAll(multiPartParams)
yamlContract.request.multipart.named.each { Named namedParam ->
YamlContract.MultipartNamedStubMatcher matcher = yamlContract.request.matchers.multipart.named.find {
it.paramName == namedParam.paramName
}
Object fileNameValue = namedParam.fileName
Object fileContentValue = namedParam.fileContent
if (matcher && matcher.fileName) {
fileNameValue = matcher.fileName.regex ? Pattern.compile(matcher.fileName.regex) :
predefinedToPattern(matcher.fileName.predefined)
}
if (matcher && matcher.fileContent) {
fileContentValue = matcher.fileContent.regex ? Pattern.compile(matcher.fileContent.regex) :
predefinedToPattern(matcher.fileContent.predefined)
}
multipartMap.put(namedParam.paramName, new NamedProperty(new DslProperty<>(fileNameValue, namedParam.fileName),
new DslProperty<>(fileContentValue, namedParam.fileContent)))
}
multipart(multipartMap)
}
bodyMatchers {
yamlContract.request.matchers?.body?.each { BodyStubMatcher matcher ->
MatchingTypeValue value = null
switch (matcher.type) {
case StubMatcherType.by_date:
value = byDate()
break
case StubMatcherType.by_time:
value = byTime()
break
case StubMatcherType.by_timestamp:
value = byTimestamp()
break
case StubMatcherType.by_regex:
String regex = matcher.value
if (matcher.predefined) {
regex = predefinedToPattern(matcher.predefined).pattern()
}
value = byRegex(regex)
break
case StubMatcherType.by_equality:
value = byEquality()
break
}
jsonPath(matcher.path, value)
}
}
}
response {
status(yamlContract.response.status)
headers {
yamlContract.response?.headers?.each { String key, Object value ->
TestHeaderMatcher matcher = yamlContract.response.matchers.headers.find { it.key == key }
if (value instanceof List) {
((List) value).each {
Object serverValue = serverValue(it, matcher, key)
header(key, new DslProperty(it, serverValue))
}
} else {
Object serverValue = serverValue(value, matcher, key)
header(key, new DslProperty(value, serverValue))
}
}
}
if (yamlContract.response?.cookies) {
cookies {
yamlContract.response?.cookies?.each { String key, Object value ->
TestCookieMatcher matcher = yamlContract.response.matchers.cookies.find { it.key == key }
Object serverValue = serverCookieValue(value, matcher, key)
cookie(key, new DslProperty(value, serverValue))
}
}
}
if (yamlContract.response.body) body(yamlContract.response.body)
if (yamlContract.response.bodyFromFile) body(file(yamlContract.response.bodyFromFile))
if (yamlContract.response.async) async()
bodyMatchers {
yamlContract.response?.matchers?.body?.each { BodyTestMatcher testMatcher ->
MatchingTypeValue value = null
switch (testMatcher.type) {
case TestMatcherType.by_date:
value = byDate()
break
case TestMatcherType.by_time:
value = byTime()
break
case TestMatcherType.by_timestamp:
value = byTimestamp()
break
case TestMatcherType.by_regex:
String regex = testMatcher.value
if (testMatcher.predefined) {
regex = predefinedToPattern(testMatcher.predefined).pattern()
}
value = byRegex(regex)
break
case TestMatcherType.by_equality:
value = byEquality()
break
case TestMatcherType.by_type:
value = byType() {
if (testMatcher.minOccurrence != null) minOccurrence(testMatcher.minOccurrence)
if (testMatcher.maxOccurrence != null) maxOccurrence(testMatcher.maxOccurrence)
}
break
case TestMatcherType.by_command:
value = byCommand(testMatcher.value)
break
case TestMatcherType.by_null:
value = byNull()
break
}
jsonPath(testMatcher.path, value)
}
}
}
}
if (yamlContract.input) {
input {
if (yamlContract.input.messageFrom) messageFrom(yamlContract.input.messageFrom)
if (yamlContract.input.assertThat) assertThat(yamlContract.input.assertThat)
if (yamlContract.input.triggeredBy) triggeredBy(yamlContract.input.triggeredBy)
messageHeaders {
yamlContract.input?.messageHeaders?.each { String key, Object value ->
KeyValueMatcher matcher = yamlContract.input.matchers?.headers?.find { it.key == key }
Object clientValue = clientValue(value, matcher, key)
header(key, new DslProperty(clientValue, value))
}
}
if (yamlContract.input.messageBody) messageBody(yamlContract.input.messageBody)
if (yamlContract.input.messageBodyFromFile) messageBody(file(yamlContract.input.messageBodyFromFile))
bodyMatchers {
yamlContract.input.matchers.body?.each { BodyStubMatcher matcher ->
MatchingTypeValue value = null
switch (matcher.type) {
case StubMatcherType.by_date:
value = byDate()
break
case StubMatcherType.by_time:
value = byTime()
break
case StubMatcherType.by_timestamp:
value = byTimestamp()
break
case StubMatcherType.by_regex:
String regex = matcher.value
if (matcher.predefined) {
regex = predefinedToPattern(matcher.predefined).pattern()
}
value = byRegex(regex)
break
case StubMatcherType.by_equality:
value = byEquality()
break
default:
throw new UnsupportedOperationException("The type [" + matcher.type + "] is unsupported. Hint: If you're using <predefined> remember to pass <type: by_regex>")
}
jsonPath(matcher.path, value)
}
}
}
}
OutputMessage outputMsg = yamlContract.outputMessage
if (outputMsg) {
outputMessage {
if (outputMsg.assertThat) assertThat(outputMsg.assertThat)
if (outputMsg.sentTo) sentTo(outputMsg.sentTo)
headers {
outputMsg.headers?.each { String key, Object value ->
TestHeaderMatcher matcher = outputMsg.matchers?.headers?.find { it.key == key }
Object serverValue = serverValue(value, matcher, key)
header(key, new DslProperty(value, serverValue))
}
}
if (outputMsg.body) body(outputMsg.body)
if (outputMsg.bodyFromFile) body(file(outputMsg.bodyFromFile))
if (outputMsg.matchers) {
bodyMatchers {
yamlContract.response?.matchers?.body?.each { BodyTestMatcher testMatcher ->
yamlContract.outputMessage?.matchers?.body?.each { BodyTestMatcher testMatcher ->
MatchingTypeValue value = null
switch (testMatcher.type) {
case TestMatcherType.by_date:
@@ -272,130 +395,17 @@ class YamlContractConverter implements ContractConverter<List<YamlContract>> {
case TestMatcherType.by_null:
value = byNull()
break
default:
throw new UnsupportedOperationException("The type [" + testMatcher.type + "] is unsupported. Hint: If you're using <predefined> remember to pass <type: by_regex>")
}
jsonPath(testMatcher.path, value)
}
}
}
}
if (yamlContract.input) {
input {
if (yamlContract.input.messageFrom) messageFrom(yamlContract.input.messageFrom)
if (yamlContract.input.assertThat) assertThat(yamlContract.input.assertThat)
if (yamlContract.input.triggeredBy) triggeredBy(yamlContract.input.triggeredBy)
messageHeaders {
yamlContract.input?.messageHeaders?.each { String key, Object value ->
KeyValueMatcher matcher = yamlContract.input.matchers?.headers?.find { it.key == key }
Object clientValue = clientValue(value, matcher, key)
header(key, new DslProperty(clientValue, value))
}
}
if (yamlContract.input.messageBody) messageBody(yamlContract.input.messageBody)
if (yamlContract.input.messageBodyFromFile) messageBody(file(yamlContract.input.messageBodyFromFile))
bodyMatchers {
yamlContract.input.matchers.body?.each { BodyStubMatcher matcher ->
MatchingTypeValue value = null
switch (matcher.type) {
case StubMatcherType.by_date:
value = byDate()
break
case StubMatcherType.by_time:
value = byTime()
break
case StubMatcherType.by_timestamp:
value = byTimestamp()
break
case StubMatcherType.by_regex:
String regex = matcher.value
if (matcher.predefined) {
regex = predefinedToPattern(matcher.predefined).pattern()
}
value = byRegex(regex)
break
case StubMatcherType.by_equality:
value = byEquality()
break
default:
throw new UnsupportedOperationException("The type [" + matcher.type + "] is unsupported. Hint: If you're using <predefined> remember to pass <type: by_regex>")
}
jsonPath(matcher.path, value)
}
}
}
}
OutputMessage outputMsg = yamlContract.outputMessage
if (outputMsg) {
outputMessage {
if (outputMsg.assertThat) assertThat(outputMsg.assertThat)
if (outputMsg.sentTo) sentTo(outputMsg.sentTo)
headers {
outputMsg.headers?.each { String key, Object value ->
TestHeaderMatcher matcher = outputMsg.matchers?.headers?.find { it.key == key }
Object serverValue = serverValue(value, matcher, key)
header(key, new DslProperty(value, serverValue))
}
}
if (outputMsg.body) body(outputMsg.body)
if (outputMsg.bodyFromFile) body(file(outputMsg.bodyFromFile))
if (outputMsg.matchers) {
bodyMatchers {
yamlContract.outputMessage?.matchers?.body?.each { BodyTestMatcher testMatcher ->
MatchingTypeValue value = null
switch (testMatcher.type) {
case TestMatcherType.by_date:
value = byDate()
break
case TestMatcherType.by_time:
value = byTime()
break
case TestMatcherType.by_timestamp:
value = byTimestamp()
break
case TestMatcherType.by_regex:
String regex = testMatcher.value
if (testMatcher.predefined) {
regex = predefinedToPattern(testMatcher.predefined).pattern()
}
value = byRegex(regex)
break
case TestMatcherType.by_equality:
value = byEquality()
break
case TestMatcherType.by_type:
value = byType() {
if (testMatcher.minOccurrence != null) minOccurrence(testMatcher.minOccurrence)
if (testMatcher.maxOccurrence != null) maxOccurrence(testMatcher.maxOccurrence)
}
break
case TestMatcherType.by_command:
value = byCommand(testMatcher.value)
break
case TestMatcherType.by_null:
value = byNull()
break
default:
throw new UnsupportedOperationException("The type [" + testMatcher.type + "] is unsupported. Hint: If you're using <predefined> remember to pass <type: by_regex>")
}
jsonPath(testMatcher.path, value)
}
}
}
}
}
}
}
}
catch (FileNotFoundException e) {
throw new IllegalStateException(e)
}
catch (IllegalStateException ise) {
throw ise
}
catch (Exception e1) {
throw new IllegalStateException("Exception occurred while processing the file [" + contractFile + "]", e1)
} finally {
Thread.currentThread().setContextClassLoader(classLoader)
}
}
protected Object serverValue(Object value, TestHeaderMatcher matcher, String key) {

View File

@@ -48,7 +48,6 @@ import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.ResultHandler;
import org.springframework.util.StreamUtils;
import wiremock.com.google.common.base.Function;
import wiremock.com.google.common.base.Joiner;
import wiremock.com.google.common.base.Optional;
@@ -123,12 +122,7 @@ public class ContractResultHandler
}
@Override protected byte[] getRequestBodyContent(MvcResult result) {
try {
return StreamUtils.copyToByteArray(result.getRequest().getInputStream());
}
catch (IOException e) {
throw new IllegalStateException("Cannot create request body", e);
}
return new WireMockHttpServletRequestAdapter(result.getRequest()).getBody();
}
}