diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle deleted file mode 100644 index ae57b5ca31..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -buildscript { - repositories { - mavenLocal() - mavenCentral() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } - maven { url "https://repo.spring.io/release" } - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${bootVersion}") - } -} - -apply plugin: 'checkstyle' - -allprojects { - group = 'com.example.jersey' -} - -ext { - spockVersion = '1.0-groovy-2.4' - - contractVerifierStubsBaseDirectory = 'src/test/resources/stubs' -} - -subprojects { - apply plugin: 'groovy' - - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - - repositories { - mavenCentral() - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } - maven { url "https://repo.spring.io/release" } - } - - dependencies { - testCompile "org.codehaus.groovy:groovy" - testCompile("org.spockframework:spock-core:$spockVersion") { - exclude(group: 'org.codehaus.groovy') - } - testCompile 'junit:junit:4.12' - testCompile "com.github.tomakehurst:wiremock:${wiremockVersion}" - testCompile "com.toomuchcoding.jsonassert:jsonassert:${jsonAssertVersion}" - testCompile "org.springframework.cloud:spring-cloud-contract-verifier:${verifierVersion}" - } -} - -configure([project(':fraudDetectionService'), project(':loanApplicationService')]) { - apply plugin: 'org.springframework.boot' - apply plugin: 'io.spring.dependency-management' - apply plugin: 'maven-publish' - - jar { - version = '0.0.1' - } - - bootJar { - enabled = false - } - - configurations { - compile.exclude module: "spring-boot-starter-tomcat" - } - - dependencies { - compile 'org.springframework.boot:spring-boot-starter-jersey' - compile 'org.springframework.boot:spring-boot-starter-jetty' - - testRuntime("org.spockframework:spock-spring:$spockVersion") { - exclude(group: 'org.codehaus.groovy') - } - - testCompile "org.mockito:mockito-core" - testCompile "org.springframework:spring-test" - testCompile "org.springframework.boot:spring-boot-test" - testCompile("com.github.tomakehurst:wiremock:${wiremockVersion}") { - exclude group: 'org.eclipse.jetty' - } - } - - task cleanup(type: Delete) { - delete 'src/test/resources/mappings', 'src/test/resources/stubs' - } - - clean.dependsOn('cleanup') - - test { - testLogging { - exceptionFormat = 'full' - } - } - -} - -configure(project(':fraudDetectionService')) { - test.dependsOn('generateClientStubs') - - apply plugin: 'spring-cloud-contract' - - ext { - contractsDir = file("mappings") - stubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/") - } - - tasks.create(type: Jar, name: 'verifierStubsJar', dependsOn: 'generateClientStubs') { - baseName = project.name - classifier = contracts.stubsSuffix - from ext.stubsOutputDir - } - - contracts { - contractsMode = "REMOTE" - testFramework = 'Spock' - testMode = 'JaxRsClient' - baseClassForTests = 'org.springframework.cloud.MvcSpec' - contractDependency { - stringNotation("com.example:jersey-contracts:+:") - } - contractRepository { - repositoryUrl = "file://" + file("${project.rootDir.absolutePath}/m2repo/repository").absolutePath - } - generatedTestSourcesDir = file("${project.buildDir}/generated-test-sources/") - stubsOutputDir = stubsOutputDirRoot - disableStubPublication(project.hasProperty("disablePublication")) - } -} - -configure(project(':loanApplicationService')) { - - task copyCollaboratorStubs(type: Copy) { - File fraudBuildDir = project(':fraudDetectionService').buildDir - from(new File(fraudBuildDir, "/production/${project(':fraudDetectionService').name}-stubs/")) { - include '**/*.json' - } - into "src/test/resources/mappings" - } - - test.dependsOn('copyCollaboratorStubs') -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/FraudDetectionController.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/FraudDetectionController.java deleted file mode 100644 index 858ebcf143..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/FraudDetectionController.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import java.math.BigDecimal; - -import org.springframework.cloud.frauddetection.model.FraudCheck; -import org.springframework.cloud.frauddetection.model.FraudCheckResult; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; - -import static org.springframework.cloud.frauddetection.model.FraudCheckStatus.FRAUD; -import static org.springframework.cloud.frauddetection.model.FraudCheckStatus.OK; - -@Controller -@Path("/") -public class FraudDetectionController { - - private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json"; - - private static final String NO_REASON = null; - - private static final String AMOUNT_TOO_HIGH = "Amount too high"; - - private static final BigDecimal MAX_AMOUNT = new BigDecimal("5000"); - - @PUT - @Path("/fraudcheck") - @Produces(FRAUD_SERVICE_JSON_VERSION_1) - @Consumes(FRAUD_SERVICE_JSON_VERSION_1) - public FraudCheckResult fraudCheck( - @RequestBody(required = false) FraudCheck fraudCheck) { - if (amountGreaterThanThreshold(fraudCheck)) { - return new FraudCheckResult(FRAUD, AMOUNT_TOO_HIGH); - } - return new FraudCheckResult(OK, NO_REASON); - } - - @GET - @Path("/frauds/name") - public String cookie(@CookieParam("name") Cookie name, - @CookieParam("name2") Cookie name2) { - return name.getValue() + " " + name2.getValue(); - } - - private boolean amountGreaterThanThreshold(FraudCheck fraudCheck) { - return MAX_AMOUNT.compareTo(fraudCheck.getLoanAmount()) < 0; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheck.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheck.java deleted file mode 100644 index d29096c59a..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheck.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -import java.math.BigDecimal; - -public class FraudCheck { - - private String clientPesel; - - private BigDecimal loanAmount; - - public FraudCheck() { - } - - public String getClientPesel() { - return this.clientPesel; - } - - public void setClientPesel(String clientPesel) { - this.clientPesel = clientPesel; - } - - public BigDecimal getLoanAmount() { - return this.loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckResult.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckResult.java deleted file mode 100644 index 7704dbaa4e..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckResult.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class FraudCheckResult { - - private FraudCheckStatus fraudCheckStatus; - - private String rejectionReason; - - public FraudCheckResult() { - } - - public FraudCheckResult(FraudCheckStatus fraudCheckStatus, String rejectionReason) { - this.fraudCheckStatus = fraudCheckStatus; - this.rejectionReason = rejectionReason; - } - - public FraudCheckStatus getFraudCheckStatus() { - return this.fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java deleted file mode 100644 index 1cadcdfa93..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/resources/application.yml b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/resources/application.yml deleted file mode 100644 index cbe617ef03..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/resources/application.yml +++ /dev/null @@ -1 +0,0 @@ -server.port=0 diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/test/groovy/org/springframework/cloud/MvcSpec.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/test/groovy/org/springframework/cloud/MvcSpec.groovy deleted file mode 100644 index 9a0dedb42b..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/test/groovy/org/springframework/cloud/MvcSpec.groovy +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud - -import javax.ws.rs.client.Client -import javax.ws.rs.client.ClientBuilder -import javax.ws.rs.client.WebTarget -import javax.ws.rs.core.UriBuilder - -import org.eclipse.jetty.server.Server -import org.eclipse.jetty.servlet.ServletContextHandler -import org.eclipse.jetty.servlet.ServletHolder -import org.glassfish.jersey.client.ClientConfig -import spock.lang.Shared -import spock.lang.Specification - -import org.springframework.cloud.frauddetection.FraudDetectionController - -import static org.springframework.util.SocketUtils.findAvailableTcpPort - -abstract class MvcSpec extends Specification { - - @Shared - WebTarget webTarget - - @Shared - private Server server - - @Shared - private Client client - - def setupSpec() { - int port = findAvailableTcpPort(8000) - URI baseUri = UriBuilder.fromUri("http://localhost").port(port).build() - // Create Server - Server server = new Server(port) - // Configure ServletContextHandler - ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS) - context.setContextPath("/") - server.setHandler(context) - // Create Servlet Container - ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*") - jerseyServlet.setInitOrder(0) - // Tells the Jersey Servlet which REST service/class to load. - jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", FraudDetectionController.class.getCanonicalName()) - // Start the server - server.start() - ClientConfig clientConfig = new ClientConfig() - client = ClientBuilder.newClient(clientConfig) - webTarget = client.target(baseUri) - } - - def cleanupSpec() { - client?.close() - server?.stop() - } - - void assertThatRejectionReasonIsNull(def rejectionReason) { - assert !rejectionReason - } -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/test/java/org/springframework/cloud/MvcTest.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/test/java/org/springframework/cloud/MvcTest.java deleted file mode 100644 index 5769f5ae0f..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/test/java/org/springframework/cloud/MvcTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud; - -import java.net.URI; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.UriBuilder; - -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.glassfish.jersey.client.ClientConfig; -import org.junit.AfterClass; -import org.junit.BeforeClass; - -import org.springframework.cloud.frauddetection.FraudDetectionController; - -import static org.springframework.util.SocketUtils.findAvailableTcpPort; - -public abstract class MvcTest { - - public static WebTarget webTarget; - - private static Server server; - - private static Client client; - - @BeforeClass - public static void setupTest() throws Exception { - int port = findAvailableTcpPort(10000); - URI baseUri = UriBuilder.fromUri("http://localhost").port(port).build(); - // Create Server - Server server = new Server(port); - // Configure ServletContextHandler - ServletContextHandler context = new ServletContextHandler( - ServletContextHandler.SESSIONS); - context.setContextPath("/"); - server.setHandler(context); - // Create Servlet Container - ServletHolder jerseyServlet = context - .addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*"); - jerseyServlet.setInitOrder(0); - // Tells the Jersey Servlet which REST service/class to load. - jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", - FraudDetectionController.class.getCanonicalName()); - // Start the server - server.start(); - ClientConfig clientConfig = new ClientConfig(); - client = ClientBuilder.newClient(clientConfig); - webTarget = client.target(baseUri); - try { - server.start(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - @AfterClass - public static void cleanupTest() { - if (client != null) { - client.close(); - } - if (server != null) { - try { - server.stop(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - } - - public void assertThatRejectionReasonIsNull(Object rejectionReason) { - assert rejectionReason == null; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradle.properties b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradle.properties deleted file mode 100644 index bdf083b1e9..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradle.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright 2013-2019 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -wiremockVersion=2.24.1 -jsonAssertVersion=0.4.13 -verifierVersion=2.2.0.BUILD-SNAPSHOT -bootVersion=2.2.0.BUILD-SNAPSHOT diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradle/wrapper/gradle-wrapper.jar b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 87b738cbd0..0000000000 Binary files a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradle/wrapper/gradle-wrapper.properties b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index b0acbdcd73..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradlew b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradlew deleted file mode 100755 index af6708ff22..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradlew.bat b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradlew.bat deleted file mode 100644 index 0f8d5937c4..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/mappings/.gitkeep b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/mappings/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/Application.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/Application.java deleted file mode 100644 index 982a795302..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/Application.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableAutoConfiguration -@ComponentScan -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/LoanApplicationService.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/LoanApplicationService.java deleted file mode 100644 index 5cea9434a9..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/LoanApplicationService.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import org.springframework.cloud.frauddetection.model.FraudCheckStatus; -import org.springframework.cloud.frauddetection.model.FraudServiceRequest; -import org.springframework.cloud.frauddetection.model.FraudServiceResponse; -import org.springframework.cloud.frauddetection.model.LoanApplication; -import org.springframework.cloud.frauddetection.model.LoanApplicationResult; -import org.springframework.cloud.frauddetection.model.LoanApplicationStatus; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -@Service -public class LoanApplicationService { - - private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json"; - - private final RestTemplate restTemplate; - - private int port = 8080; - - public LoanApplicationService() { - this.restTemplate = new RestTemplate(); - } - - public LoanApplicationResult loanApplication(LoanApplication loanApplication) { - FraudServiceRequest request = new FraudServiceRequest(loanApplication); - - FraudServiceResponse response = sendRequestToFraudDetectionService(request); - - return buildResponseFromFraudResult(response); - } - - private FraudServiceResponse sendRequestToFraudDetectionService( - FraudServiceRequest request) { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add(HttpHeaders.CONTENT_TYPE, FRAUD_SERVICE_JSON_VERSION_1); - - ResponseEntity response = this.restTemplate.exchange( - "http://localhost:" + this.port + "/fraudcheck", HttpMethod.PUT, - new HttpEntity<>(request, httpHeaders), FraudServiceResponse.class); - - return response.getBody(); - } - - private LoanApplicationResult buildResponseFromFraudResult( - FraudServiceResponse response) { - LoanApplicationStatus applicationStatus = null; - if (FraudCheckStatus.OK == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLIED; - } - else if (FraudCheckStatus.FRAUD == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLICATION_REJECTED; - } - - return new LoanApplicationResult(applicationStatus, - response.getRejectionReason()); - } - - public void setPort(int port) { - this.port = port; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/Client.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/Client.java deleted file mode 100644 index 72024217cc..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/Client.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class Client { - - private String pesel; - - public String getPesel() { - return this.pesel; - } - - public void setPesel(String pesel) { - this.pesel = pesel; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java deleted file mode 100644 index 1cadcdfa93..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceRequest.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceRequest.java deleted file mode 100644 index 6a76e76ed6..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceRequest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -import java.math.BigDecimal; - -public class FraudServiceRequest { - - private String clientPesel; - - private BigDecimal loanAmount; - - public FraudServiceRequest() { - } - - public FraudServiceRequest(LoanApplication loanApplication) { - this.clientPesel = loanApplication.getClient().getPesel(); - this.loanAmount = loanApplication.getAmount(); - } - - public String getClientPesel() { - return this.clientPesel; - } - - public void setClientPesel(String clientPesel) { - this.clientPesel = clientPesel; - } - - public BigDecimal getLoanAmount() { - return this.loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceResponse.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceResponse.java deleted file mode 100644 index 4f4579e901..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class FraudServiceResponse { - - private FraudCheckStatus fraudCheckStatus; - - private String rejectionReason; - - public FraudServiceResponse() { - } - - public FraudCheckStatus getFraudCheckStatus() { - return this.fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplication.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplication.java deleted file mode 100644 index f2cac2fddd..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplication.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -import java.math.BigDecimal; - -public class LoanApplication { - - private Client client; - - private BigDecimal amount; - - private String loanApplicationId; - - public Client getClient() { - return this.client; - } - - public void setClient(Client client) { - this.client = client; - } - - public BigDecimal getAmount() { - return this.amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public String getLoanApplicationId() { - return this.loanApplicationId; - } - - public void setLoanApplicationId(String loanApplicationId) { - this.loanApplicationId = loanApplicationId; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationResult.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationResult.java deleted file mode 100644 index e90dc70ead..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationResult.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class LoanApplicationResult { - - private LoanApplicationStatus loanApplicationStatus; - - private String rejectionReason; - - public LoanApplicationResult() { - } - - public LoanApplicationResult(LoanApplicationStatus loanApplicationStatus, - String rejectionReason) { - this.loanApplicationStatus = loanApplicationStatus; - this.rejectionReason = rejectionReason; - } - - public LoanApplicationStatus getLoanApplicationStatus() { - return this.loanApplicationStatus; - } - - public void setLoanApplicationStatus(LoanApplicationStatus loanApplicationStatus) { - this.loanApplicationStatus = loanApplicationStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationStatus.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationStatus.java deleted file mode 100644 index 68a39e88fd..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public enum LoanApplicationStatus { - - LOAN_APPLIED, LOAN_APPLICATION_REJECTED - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/resources/application.yml b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/resources/application.yml deleted file mode 100644 index cbe617ef03..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/main/resources/application.yml +++ /dev/null @@ -1 +0,0 @@ -server.port=0 diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/groovy/org/springframework/cloud/LoanApplicationServiceSpec.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/groovy/org/springframework/cloud/LoanApplicationServiceSpec.groovy deleted file mode 100644 index 403c97f67d..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/groovy/org/springframework/cloud/LoanApplicationServiceSpec.groovy +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud - -import com.github.tomakehurst.wiremock.junit.WireMockClassRule -import org.junit.ClassRule -import spock.lang.Shared -import spock.lang.Specification - -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootContextLoader -import org.springframework.cloud.frauddetection.Application -import org.springframework.cloud.frauddetection.LoanApplicationService -import org.springframework.cloud.frauddetection.model.Client -import org.springframework.cloud.frauddetection.model.LoanApplication -import org.springframework.cloud.frauddetection.model.LoanApplicationResult -import org.springframework.cloud.frauddetection.model.LoanApplicationStatus -import org.springframework.test.context.ContextConfiguration - -@ContextConfiguration(loader = SpringBootContextLoader, classes = Application) -class LoanApplicationServiceSpec extends Specification { - - public static int port = org.springframework.util.SocketUtils.findAvailableTcpPort() - - @ClassRule - @Shared - WireMockClassRule wireMockRule = new WireMockClassRule(port) - - @Autowired - LoanApplicationService sut - - def setup() { - sut.port = port - } - - def 'should successfully apply for loan'() { - given: - LoanApplication application = - new LoanApplication(client: new Client(pesel: '1234567890'), amount: 123.123) - when: - LoanApplicationResult loanApplication = sut.loanApplication(application) - then: - loanApplication.loanApplicationStatus == LoanApplicationStatus.LOAN_APPLIED - loanApplication.rejectionReason == null - } - - def 'should be rejected due to abnormal loan amount'() { - given: - LoanApplication application = - new LoanApplication(client: new Client(pesel: '1234567890'), amount: 99_999) - when: - LoanApplicationResult loanApplication = sut.loanApplication(application) - then: - loanApplication.loanApplicationStatus == LoanApplicationStatus.LOAN_APPLICATION_REJECTED - loanApplication.rejectionReason == 'Amount too high' - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/META-INF/com.example.jersey/fraudDetectionService/unspecified/mappings/contracts/com/example/jersey/fraudDetectionService/shouldMarkClientAsFraud.json b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/META-INF/com.example.jersey/fraudDetectionService/unspecified/mappings/contracts/com/example/jersey/fraudDetectionService/shouldMarkClientAsFraud.json deleted file mode 100644 index 25a67001a6..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/META-INF/com.example.jersey/fraudDetectionService/unspecified/mappings/contracts/com/example/jersey/fraudDetectionService/shouldMarkClientAsFraud.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "id": "856bd753-2488-4549-b84f-512e851958a9", - "request": { - "url": "/fraudcheck", - "method": "PUT", - "headers": { - "Content-Type": { - "equalTo": "application/vnd.fraud.v1+json" - } - }, - "bodyPatterns": [ - { - "matchesJsonPath": "$[?(@.['loanAmount'] == 99999)]" - }, - { - "matchesJsonPath": "$[?(@.['clientPesel'] =~ /[0-9]{10}/)]" - } - ] - }, - "response": { - "status": 200, - "body": "{\"fraudCheckStatus\":\"FRAUD\",\"rejectionReason\":\"Amount too high\"}", - "headers": { - "Content-Type": "application/vnd.fraud.v1+json" - }, - "transformers": [ - "response-template" - ] - }, - "uuid": "856bd753-2488-4549-b84f-512e851958a9" -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/META-INF/com.example.jersey/fraudDetectionService/unspecified/mappings/contracts/com/example/jersey/fraudDetectionService/shouldMarkClientAsNotFraud.json b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/META-INF/com.example.jersey/fraudDetectionService/unspecified/mappings/contracts/com/example/jersey/fraudDetectionService/shouldMarkClientAsNotFraud.json deleted file mode 100644 index d62d2b8532..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/resources/mappings/META-INF/com.example.jersey/fraudDetectionService/unspecified/mappings/contracts/com/example/jersey/fraudDetectionService/shouldMarkClientAsNotFraud.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "id": "263aac46-1534-497d-9cc6-114a29ffa0de", - "request": { - "url": "/fraudcheck", - "method": "PUT", - "headers": { - "Content-Type": { - "equalTo": "application/vnd.fraud.v1+json" - } - }, - "bodyPatterns": [ - { - "matchesJsonPath": "$[?(@.['loanAmount'] == 123.123)]" - }, - { - "matchesJsonPath": "$[?(@.['clientPesel'] =~ /[0-9]{10}/)]" - } - ] - }, - "response": { - "status": 200, - "body": "{\"fraudCheckStatus\":\"OK\",\"rejectionReason\":null}", - "headers": { - "Content-Type": "application/vnd.fraud.v1+json" - }, - "transformers": [ - "response-template" - ] - }, - "uuid": "263aac46-1534-497d-9cc6-114a29ffa0de" -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/0.0.1-SNAPSHOT/jersey-contracts-0.0.1-SNAPSHOT.jar b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/0.0.1-SNAPSHOT/jersey-contracts-0.0.1-SNAPSHOT.jar deleted file mode 100644 index 8de83843d0..0000000000 Binary files a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/0.0.1-SNAPSHOT/jersey-contracts-0.0.1-SNAPSHOT.jar and /dev/null differ diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/0.0.1-SNAPSHOT/jersey-contracts-0.0.1-SNAPSHOT.pom b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/0.0.1-SNAPSHOT/jersey-contracts-0.0.1-SNAPSHOT.pom deleted file mode 100644 index 4b4ae1a9dc..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/0.0.1-SNAPSHOT/jersey-contracts-0.0.1-SNAPSHOT.pom +++ /dev/null @@ -1,26 +0,0 @@ - - - - - 4.0.0 - com.example - jersey-contracts - 0.0.1-SNAPSHOT - pom - diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/0.0.1-SNAPSHOT/maven-metadata-local.xml b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/0.0.1-SNAPSHOT/maven-metadata-local.xml deleted file mode 100644 index b6f14758ae..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/0.0.1-SNAPSHOT/maven-metadata-local.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - com.example - jersey-contracts - 0.0.1-SNAPSHOT - - - true - - 20160916125313 - - - jar - 0.0.1-SNAPSHOT - 20170916125313 - - - pom - 0.0.1-SNAPSHOT - 20160916125313 - - - - diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/maven-metadata.xml b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/maven-metadata.xml deleted file mode 100644 index 4a03c77e61..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/m2repo/repository/com/example/jersey-contracts/maven-metadata.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - com.example - jersey-contracts - 0.0.1-SNAPSHOT - - - 0.0.1-SNAPSHOT - - 20160409062112 - - diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/settings.gradle b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/settings.gradle deleted file mode 100644 index 747ffa4306..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/settings.gradle +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -include ':fraudDetectionService' -include ':loanApplicationService' diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle deleted file mode 100644 index 87a648e058..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -buildscript { - repositories { - mavenCentral() - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } - maven { url "https://repo.spring.io/release" } - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${bootVersion}") - } -} - -ext { - restAssuredVersion = '3.0.7' - spockVersion = '1.0-groovy-2.4' - - contractVerifierStubsBaseDirectory = 'src/test/resources/stubs' -} - -group = 'org.springframework.cloud.testprojects' - -subprojects { - apply plugin: 'groovy' - - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - - repositories { - mavenCentral() - mavenLocal() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } - maven { url "https://repo.spring.io/release" } - } - - dependencies { - testCompile("org.codehaus.groovy:groovy") - testCompile "org.spockframework:spock-core:$spockVersion" - testCompile("junit:junit:4.12") - testCompile "com.github.tomakehurst:wiremock:${wiremockVersion}" - testCompile "com.toomuchcoding.jsonassert:jsonassert:${jsonAssertVersion}" - testCompile "org.springframework.cloud:spring-cloud-contract-verifier:${verifierVersion}" - } -} - -configure([project(':fraudDetectionService'), project(':loanApplicationService')]) { - apply plugin: 'org.springframework.boot' - apply plugin: 'io.spring.dependency-management' - apply plugin: 'spring-cloud-contract' - apply plugin: 'maven-publish' - - ext { - contractsDir = file("mappings") - stubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/") - } - - contracts { - contractsMode = "REMOTE" - testFramework = 'Spock' - testMode = 'MockMvc' - baseClassForTests = 'org.springframework.cloud.MvcSpec' - contractsDslDir = file("${project.projectDir.absolutePath}/mappings/") - generatedTestSourcesDir = file("${project.buildDir}/generated-test-sources/") - stubsOutputDir = stubsOutputDirRoot - } - - jar { - version = '0.0.1' - } - - dependencies { - compile("org.springframework.boot:spring-boot-starter-web") { - exclude module: "spring-boot-starter-tomcat" - } - compile("org.springframework.boot:spring-boot-starter-jetty") - compile("org.springframework.boot:spring-boot-starter-actuator") - - testRuntime("org.spockframework:spock-spring:$spockVersion") { - exclude(group: 'org.codehaus.groovy') - } - testCompile "org.mockito:mockito-core" - testCompile "org.springframework:spring-test" - testCompile "org.springframework.boot:spring-boot-test" - testCompile "io.rest-assured:rest-assured:$restAssuredVersion" - testCompile "io.rest-assured:spring-mock-mvc:$restAssuredVersion" - } - - task cleanup(type: Delete) { - delete 'src/test/resources/mappings', 'src/test/resources/stubs' - } - - clean.dependsOn('cleanup') - - test { - testLogging { - exceptionFormat = 'full' - } - } -} - -configure(project(':fraudDetectionService')) { - test.dependsOn('generateClientStubs') -} - -configure(project(':loanApplicationService')) { - - task copyCollaboratorStubs(type: Copy) { - File fraudBuildDir = project(':fraudDetectionService').buildDir - from(new File(fraudBuildDir, "/production/${project(':fraudDetectionService').name}-stubs/")) - into "src/test/resources/" - } - - project.tasks.named("generateContractTests").get().dependsOn('copyCollaboratorStubs') -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy deleted file mode 100644 index 8cfbba1828..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.springframework.cloud.contract.spec.Contract - -Contract.make { - request { - method """PUT""" - url """/fraudcheck""" - body(""" - { - "clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}", - "loanAmount":99999} - """ - ) - headers { - header("""Content-Type""", """application/vnd.fraud.v1+json""") - } - - } - response { - status OK() - body("""{ - "fraudCheckStatus": "${value(consumer('FRAUD'), producer(regex('[A-Z]{5}')))}", - "rejectionReason": "Amount too high" -}""") - headers { - header('Content-Type': value( - producer(regex('application/vnd.fraud.v1.json.*')), - consumer('application/vnd.fraud.v1+json')) - ) - } - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy deleted file mode 100644 index 22f9f2a382..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.springframework.cloud.contract.spec.Contract - -Contract.make { - request { - method 'PUT' - url '/fraudcheck' - body(""" - { - "clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}", - "loanAmount":123.123 - } - """ - ) - headers { - header('Content-Type', 'application/vnd.fraud.v1+json') - } - - } - response { - status OK() - body( - fraudCheckStatus: "OK", - rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)'))) - ) - headers { - header('Content-Type': value( - producer(regex('application/vnd.fraud.v1.json.*')), - consumer('application/vnd.fraud.v1+json')) - ) - } - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/Application.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/Application.java deleted file mode 100644 index b90770da93..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/Application.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableAutoConfiguration -@ComponentScan -public class Application { - - public static void main(String[] args) { - SpringApplication.run(org.springframework.cloud.frauddetection.Application.class, - args); - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/FraudDetectionController.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/FraudDetectionController.java deleted file mode 100644 index c7fed217b9..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/FraudDetectionController.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import java.math.BigDecimal; - -import org.springframework.cloud.frauddetection.model.FraudCheck; -import org.springframework.cloud.frauddetection.model.FraudCheckResult; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.cloud.frauddetection.model.FraudCheckStatus.FRAUD; -import static org.springframework.cloud.frauddetection.model.FraudCheckStatus.OK; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -@RestController -public class FraudDetectionController { - - private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json"; - - private static final String NO_REASON = null; - - private static final String AMOUNT_TOO_HIGH = "Amount too high"; - - private static final BigDecimal MAX_AMOUNT = new BigDecimal("5000"); - - @RequestMapping(value = "/fraudcheck", method = PUT, consumes = FRAUD_SERVICE_JSON_VERSION_1, produces = FRAUD_SERVICE_JSON_VERSION_1) - public FraudCheckResult fraudCheck(@RequestBody FraudCheck fraudCheck) { - if (amountGreaterThanThreshold(fraudCheck)) { - return new FraudCheckResult(FRAUD, AMOUNT_TOO_HIGH); - } - return new FraudCheckResult(OK, NO_REASON); - } - - private boolean amountGreaterThanThreshold(FraudCheck fraudCheck) { - return MAX_AMOUNT.compareTo(fraudCheck.getLoanAmount()) < 0; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheck.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheck.java deleted file mode 100644 index d29096c59a..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheck.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -import java.math.BigDecimal; - -public class FraudCheck { - - private String clientPesel; - - private BigDecimal loanAmount; - - public FraudCheck() { - } - - public String getClientPesel() { - return this.clientPesel; - } - - public void setClientPesel(String clientPesel) { - this.clientPesel = clientPesel; - } - - public BigDecimal getLoanAmount() { - return this.loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckResult.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckResult.java deleted file mode 100644 index 7704dbaa4e..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckResult.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class FraudCheckResult { - - private FraudCheckStatus fraudCheckStatus; - - private String rejectionReason; - - public FraudCheckResult() { - } - - public FraudCheckResult(FraudCheckStatus fraudCheckStatus, String rejectionReason) { - this.fraudCheckStatus = fraudCheckStatus; - this.rejectionReason = rejectionReason; - } - - public FraudCheckStatus getFraudCheckStatus() { - return this.fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckStatus.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckStatus.java deleted file mode 100644 index 1cadcdfa93..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/resources/application.properties b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/resources/application.properties deleted file mode 100644 index 17d0b12361..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/resources/application.properties +++ /dev/null @@ -1,4 +0,0 @@ -#WireMock password - https://wiremock.org/docs/running-standalone/ -server.ssl.key-store-password=password -server.ssl.key-password=password -server.ssl.trust-store-password=password diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/resources/application.yml b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/resources/application.yml deleted file mode 100644 index cbe617ef03..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/main/resources/application.yml +++ /dev/null @@ -1 +0,0 @@ -server.port=0 diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/test/groovy/org/springframework/cloud/MvcSpec.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/test/groovy/org/springframework/cloud/MvcSpec.groovy deleted file mode 100644 index eb309f4157..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/test/groovy/org/springframework/cloud/MvcSpec.groovy +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud - -import io.restassured.module.mockmvc.RestAssuredMockMvc -import spock.lang.Specification - -import org.springframework.cloud.frauddetection.FraudDetectionController - -class MvcSpec extends Specification { - def setup() { - RestAssuredMockMvc.standaloneSetup(new FraudDetectionController()) - } - - void assertThatRejectionReasonIsNull(def rejectionReason) { - assert !rejectionReason - } -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/test/java/org/springframework/cloud/MvcTest.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/test/java/org/springframework/cloud/MvcTest.java deleted file mode 100644 index 072ac799f1..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/test/java/org/springframework/cloud/MvcTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.Before; - -public class MvcTest { - - @Before - public void setup() { - RestAssuredMockMvc.standaloneSetup( - new org.springframework.cloud.frauddetection.FraudDetectionController()); - } - - public void assertThatRejectionReasonIsNull(Object rejectionReason) { - assert rejectionReason == null; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradle.properties b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradle.properties deleted file mode 100644 index bdf083b1e9..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradle.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright 2013-2019 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -wiremockVersion=2.24.1 -jsonAssertVersion=0.4.13 -verifierVersion=2.2.0.BUILD-SNAPSHOT -bootVersion=2.2.0.BUILD-SNAPSHOT diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradle/wrapper/gradle-wrapper.jar b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 87b738cbd0..0000000000 Binary files a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradle/wrapper/gradle-wrapper.properties b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index b0acbdcd73..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradlew b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradlew deleted file mode 100755 index af6708ff22..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradlew.bat b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradlew.bat deleted file mode 100644 index 0f8d5937c4..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/mappings/.gitkeep b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/mappings/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/Application.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/Application.java deleted file mode 100644 index b90770da93..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/Application.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableAutoConfiguration -@ComponentScan -public class Application { - - public static void main(String[] args) { - SpringApplication.run(org.springframework.cloud.frauddetection.Application.class, - args); - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/LoanApplicationService.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/LoanApplicationService.java deleted file mode 100644 index 5cea9434a9..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/LoanApplicationService.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import org.springframework.cloud.frauddetection.model.FraudCheckStatus; -import org.springframework.cloud.frauddetection.model.FraudServiceRequest; -import org.springframework.cloud.frauddetection.model.FraudServiceResponse; -import org.springframework.cloud.frauddetection.model.LoanApplication; -import org.springframework.cloud.frauddetection.model.LoanApplicationResult; -import org.springframework.cloud.frauddetection.model.LoanApplicationStatus; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -@Service -public class LoanApplicationService { - - private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json"; - - private final RestTemplate restTemplate; - - private int port = 8080; - - public LoanApplicationService() { - this.restTemplate = new RestTemplate(); - } - - public LoanApplicationResult loanApplication(LoanApplication loanApplication) { - FraudServiceRequest request = new FraudServiceRequest(loanApplication); - - FraudServiceResponse response = sendRequestToFraudDetectionService(request); - - return buildResponseFromFraudResult(response); - } - - private FraudServiceResponse sendRequestToFraudDetectionService( - FraudServiceRequest request) { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add(HttpHeaders.CONTENT_TYPE, FRAUD_SERVICE_JSON_VERSION_1); - - ResponseEntity response = this.restTemplate.exchange( - "http://localhost:" + this.port + "/fraudcheck", HttpMethod.PUT, - new HttpEntity<>(request, httpHeaders), FraudServiceResponse.class); - - return response.getBody(); - } - - private LoanApplicationResult buildResponseFromFraudResult( - FraudServiceResponse response) { - LoanApplicationStatus applicationStatus = null; - if (FraudCheckStatus.OK == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLIED; - } - else if (FraudCheckStatus.FRAUD == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLICATION_REJECTED; - } - - return new LoanApplicationResult(applicationStatus, - response.getRejectionReason()); - } - - public void setPort(int port) { - this.port = port; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/Client.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/Client.java deleted file mode 100644 index 72024217cc..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/Client.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class Client { - - private String pesel; - - public String getPesel() { - return this.pesel; - } - - public void setPesel(String pesel) { - this.pesel = pesel; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java deleted file mode 100644 index 1cadcdfa93..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceRequest.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceRequest.java deleted file mode 100644 index 6a76e76ed6..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceRequest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -import java.math.BigDecimal; - -public class FraudServiceRequest { - - private String clientPesel; - - private BigDecimal loanAmount; - - public FraudServiceRequest() { - } - - public FraudServiceRequest(LoanApplication loanApplication) { - this.clientPesel = loanApplication.getClient().getPesel(); - this.loanAmount = loanApplication.getAmount(); - } - - public String getClientPesel() { - return this.clientPesel; - } - - public void setClientPesel(String clientPesel) { - this.clientPesel = clientPesel; - } - - public BigDecimal getLoanAmount() { - return this.loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceResponse.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceResponse.java deleted file mode 100644 index 4f4579e901..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class FraudServiceResponse { - - private FraudCheckStatus fraudCheckStatus; - - private String rejectionReason; - - public FraudServiceResponse() { - } - - public FraudCheckStatus getFraudCheckStatus() { - return this.fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplication.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplication.java deleted file mode 100644 index f2cac2fddd..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplication.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -import java.math.BigDecimal; - -public class LoanApplication { - - private Client client; - - private BigDecimal amount; - - private String loanApplicationId; - - public Client getClient() { - return this.client; - } - - public void setClient(Client client) { - this.client = client; - } - - public BigDecimal getAmount() { - return this.amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public String getLoanApplicationId() { - return this.loanApplicationId; - } - - public void setLoanApplicationId(String loanApplicationId) { - this.loanApplicationId = loanApplicationId; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationResult.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationResult.java deleted file mode 100644 index e90dc70ead..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationResult.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class LoanApplicationResult { - - private LoanApplicationStatus loanApplicationStatus; - - private String rejectionReason; - - public LoanApplicationResult() { - } - - public LoanApplicationResult(LoanApplicationStatus loanApplicationStatus, - String rejectionReason) { - this.loanApplicationStatus = loanApplicationStatus; - this.rejectionReason = rejectionReason; - } - - public LoanApplicationStatus getLoanApplicationStatus() { - return this.loanApplicationStatus; - } - - public void setLoanApplicationStatus(LoanApplicationStatus loanApplicationStatus) { - this.loanApplicationStatus = loanApplicationStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationStatus.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationStatus.java deleted file mode 100644 index 68a39e88fd..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public enum LoanApplicationStatus { - - LOAN_APPLIED, LOAN_APPLICATION_REJECTED - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/resources/application.yml b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/resources/application.yml deleted file mode 100644 index cbe617ef03..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/main/resources/application.yml +++ /dev/null @@ -1 +0,0 @@ -server.port=0 diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/groovy/org/springframework/cloud/LoanApplicationServiceSpec.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/groovy/org/springframework/cloud/LoanApplicationServiceSpec.groovy deleted file mode 100644 index 403c97f67d..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/groovy/org/springframework/cloud/LoanApplicationServiceSpec.groovy +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud - -import com.github.tomakehurst.wiremock.junit.WireMockClassRule -import org.junit.ClassRule -import spock.lang.Shared -import spock.lang.Specification - -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootContextLoader -import org.springframework.cloud.frauddetection.Application -import org.springframework.cloud.frauddetection.LoanApplicationService -import org.springframework.cloud.frauddetection.model.Client -import org.springframework.cloud.frauddetection.model.LoanApplication -import org.springframework.cloud.frauddetection.model.LoanApplicationResult -import org.springframework.cloud.frauddetection.model.LoanApplicationStatus -import org.springframework.test.context.ContextConfiguration - -@ContextConfiguration(loader = SpringBootContextLoader, classes = Application) -class LoanApplicationServiceSpec extends Specification { - - public static int port = org.springframework.util.SocketUtils.findAvailableTcpPort() - - @ClassRule - @Shared - WireMockClassRule wireMockRule = new WireMockClassRule(port) - - @Autowired - LoanApplicationService sut - - def setup() { - sut.port = port - } - - def 'should successfully apply for loan'() { - given: - LoanApplication application = - new LoanApplication(client: new Client(pesel: '1234567890'), amount: 123.123) - when: - LoanApplicationResult loanApplication = sut.loanApplication(application) - then: - loanApplication.loanApplicationStatus == LoanApplicationStatus.LOAN_APPLIED - loanApplication.rejectionReason == null - } - - def 'should be rejected due to abnormal loan amount'() { - given: - LoanApplication application = - new LoanApplication(client: new Client(pesel: '1234567890'), amount: 99_999) - when: - LoanApplicationResult loanApplication = sut.loanApplication(application) - then: - loanApplication.loanApplicationStatus == LoanApplicationStatus.LOAN_APPLICATION_REJECTED - loanApplication.rejectionReason == 'Amount too high' - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json deleted file mode 100644 index fe037dc7ef..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "request": { - "method": "PUT", - "headers": { - "Content-Type": { - "equalTo": "application/vnd.fraud.v1+json" - } - }, - "url": "/fraudcheck", - "bodyPatterns": [ - { - "matches": "{\"clientPesel\":\"[0-9]{10}\",\"loanAmount\":\"99999\"}" - } - ] - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/vnd.fraud.v1+json" - }, - "body": "{\"fraudCheckStatus\":\"FRAUD\",\"rejectionReason\":\"Amount too high\"}" - } -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json deleted file mode 100644 index 8b89b6d54e..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "request": { - "method": "PUT", - "headers": { - "Content-Type": { - "equalTo": "application/vnd.fraud.v1+json" - } - }, - "url": "/fraudcheck", - "bodyPatterns": [ - { - "matches": "{\"clientPesel\":\"[0-9]{10}\",\"loanAmount\":\"123.123\"}" - } - ] - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/vnd.fraud.v1+json" - }, - "body": "{\"fraudCheckStatus\":\"OK\",\"rejectionReason\":null}" - } -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/settings.gradle b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/settings.gradle deleted file mode 100644 index 22aab22cb1..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProject/settings.gradle +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -include ':fraudDetectionService' -include ':loanApplicationService' diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/build.gradle.kts b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/build.gradle.kts deleted file mode 100644 index d48b576e66..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/build.gradle.kts +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -buildscript { - val bootVersion: String by extra - - repositories { - mavenCentral() - mavenLocal() - maven(url = "https://repo.spring.io/snapshot") - maven(url = "https://repo.spring.io/milestone") - maven(url = "https://repo.spring.io/release") - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:$bootVersion") - } -} - -import org.springframework.cloud.contract.stubrunner.spring.StubRunnerProperties -import org.springframework.cloud.contract.verifier.config.TestFramework -import org.springframework.cloud.contract.verifier.config.TestMode -import org.springframework.cloud.contract.verifier.plugin.ContractVerifierExtension - -plugins { - groovy -} - -val restAssuredVersion by extra("3.0.7") -val spockVersion by extra("1.0-groovy-2.4") -val wiremockVersion: String by extra -val jsonAssertVersion: String by extra -val verifierVersion: String by extra - -val contractVerifierStubsBaseDirectory by extra("src/test/resources/stubs") - -group = "org.springframework.cloud.testprojects" - -subprojects { - apply(plugin = "groovy") - - java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - repositories { - mavenCentral() - mavenLocal() - maven(url = "https://repo.spring.io/snapshot") - maven(url = "https://repo.spring.io/milestone") - maven(url = "https://repo.spring.io/release") - } - - dependencies { - testCompile("org.codehaus.groovy:groovy") - testCompile("org.spockframework:spock-core:$spockVersion") - testCompile("junit:junit:4.12") - testCompile("com.github.tomakehurst:wiremock:$wiremockVersion") - testCompile("com.toomuchcoding.jsonassert:jsonassert:$jsonAssertVersion") - testCompile("org.springframework.cloud:spring-cloud-contract-verifier:$verifierVersion") - } -} - -configure(listOf(project(":fraudDetectionService"), project(":loanApplicationService"))) { - apply(plugin = "org.springframework.boot") - apply(plugin = "io.spring.dependency-management") - apply(plugin = "spring-cloud-contract") - apply(plugin = "maven-publish") - - configure { - contractsMode.set(StubRunnerProperties.StubsMode.REMOTE) - testFramework.set(TestFramework.SPOCK) - testMode.set(TestMode.MOCKMVC) - baseClassForTests.set("org.springframework.cloud.MvcSpec") - contractsDslDir.set(file("${project.projectDir}/mappings/")) - generatedTestSourcesDir.set(file("${project.buildDir}/generated-test-sources/")) - stubsOutputDir.set(file("${project.buildDir}/production/${project.name}-stubs/")) - } - - dependencies { - compile("org.springframework.boot:spring-boot-starter-web") { - exclude(module = "spring-boot-starter-tomcat") - } - compile("org.springframework.boot:spring-boot-starter-jetty") - compile("org.springframework.boot:spring-boot-starter-actuator") - - testRuntime("org.spockframework:spock-spring:$spockVersion") { - exclude(group = "org.codehaus.groovy") - } - testCompile("org.mockito:mockito-core") - testCompile("org.springframework:spring-test") - testCompile("org.springframework.boot:spring-boot-test") - testCompile("io.rest-assured:rest-assured:$restAssuredVersion") - testCompile("io.rest-assured:spring-mock-mvc:$restAssuredVersion") - } - - tasks { - jar { - version = "0.0.1" - } - - test { - testLogging.showExceptions = true - } - - val cleanup by registering(Delete::class) { - delete("src/test/resources/mappings", "src/test/resources/stubs") - } - - clean { - dependsOn(cleanup) - } - } -} - -configure(listOf(project(":fraudDetectionService"))) { - tasks { - test { - dependsOn("generateClientStubs") - } - } -} - -configure(listOf(project(":loanApplicationService"))) { - tasks { - val copyCollaboratorStubs by registering(Copy::class) { - val fraudDetectionService = project(":fraudDetectionService") - from(file("${fraudDetectionService.buildDir}/production/${fraudDetectionService.name}-stubs")) - into("src/test/resources/mappings") - } - - val generateContractTests by existing - generateContractTests { - dependsOn(copyCollaboratorStubs) - } - } -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/build.gradle.kts b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/build.gradle.kts deleted file mode 100644 index 92753b2437..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/build.gradle.kts +++ /dev/null @@ -1,3 +0,0 @@ -plugins { - groovy -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy deleted file mode 100644 index 8cfbba1828..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.springframework.cloud.contract.spec.Contract - -Contract.make { - request { - method """PUT""" - url """/fraudcheck""" - body(""" - { - "clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}", - "loanAmount":99999} - """ - ) - headers { - header("""Content-Type""", """application/vnd.fraud.v1+json""") - } - - } - response { - status OK() - body("""{ - "fraudCheckStatus": "${value(consumer('FRAUD'), producer(regex('[A-Z]{5}')))}", - "rejectionReason": "Amount too high" -}""") - headers { - header('Content-Type': value( - producer(regex('application/vnd.fraud.v1.json.*')), - consumer('application/vnd.fraud.v1+json')) - ) - } - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy deleted file mode 100644 index 22f9f2a382..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.springframework.cloud.contract.spec.Contract - -Contract.make { - request { - method 'PUT' - url '/fraudcheck' - body(""" - { - "clientPesel":"${value(consumer(regex('[0-9]{10}')), producer('1234567890'))}", - "loanAmount":123.123 - } - """ - ) - headers { - header('Content-Type', 'application/vnd.fraud.v1+json') - } - - } - response { - status OK() - body( - fraudCheckStatus: "OK", - rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)'))) - ) - headers { - header('Content-Type': value( - producer(regex('application/vnd.fraud.v1.json.*')), - consumer('application/vnd.fraud.v1+json')) - ) - } - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/Application.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/Application.java deleted file mode 100644 index b90770da93..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/Application.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableAutoConfiguration -@ComponentScan -public class Application { - - public static void main(String[] args) { - SpringApplication.run(org.springframework.cloud.frauddetection.Application.class, - args); - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/FraudDetectionController.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/FraudDetectionController.java deleted file mode 100644 index c7fed217b9..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/FraudDetectionController.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import java.math.BigDecimal; - -import org.springframework.cloud.frauddetection.model.FraudCheck; -import org.springframework.cloud.frauddetection.model.FraudCheckResult; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.cloud.frauddetection.model.FraudCheckStatus.FRAUD; -import static org.springframework.cloud.frauddetection.model.FraudCheckStatus.OK; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -@RestController -public class FraudDetectionController { - - private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json"; - - private static final String NO_REASON = null; - - private static final String AMOUNT_TOO_HIGH = "Amount too high"; - - private static final BigDecimal MAX_AMOUNT = new BigDecimal("5000"); - - @RequestMapping(value = "/fraudcheck", method = PUT, consumes = FRAUD_SERVICE_JSON_VERSION_1, produces = FRAUD_SERVICE_JSON_VERSION_1) - public FraudCheckResult fraudCheck(@RequestBody FraudCheck fraudCheck) { - if (amountGreaterThanThreshold(fraudCheck)) { - return new FraudCheckResult(FRAUD, AMOUNT_TOO_HIGH); - } - return new FraudCheckResult(OK, NO_REASON); - } - - private boolean amountGreaterThanThreshold(FraudCheck fraudCheck) { - return MAX_AMOUNT.compareTo(fraudCheck.getLoanAmount()) < 0; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheck.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheck.java deleted file mode 100644 index d29096c59a..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheck.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -import java.math.BigDecimal; - -public class FraudCheck { - - private String clientPesel; - - private BigDecimal loanAmount; - - public FraudCheck() { - } - - public String getClientPesel() { - return this.clientPesel; - } - - public void setClientPesel(String clientPesel) { - this.clientPesel = clientPesel; - } - - public BigDecimal getLoanAmount() { - return this.loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckResult.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckResult.java deleted file mode 100644 index 7704dbaa4e..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckResult.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class FraudCheckResult { - - private FraudCheckStatus fraudCheckStatus; - - private String rejectionReason; - - public FraudCheckResult() { - } - - public FraudCheckResult(FraudCheckStatus fraudCheckStatus, String rejectionReason) { - this.fraudCheckStatus = fraudCheckStatus; - this.rejectionReason = rejectionReason; - } - - public FraudCheckStatus getFraudCheckStatus() { - return this.fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckStatus.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckStatus.java deleted file mode 100644 index 1cadcdfa93..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/java/org/springframework/frauddetection/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/resources/application.properties b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/resources/application.properties deleted file mode 100644 index 17d0b12361..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/resources/application.properties +++ /dev/null @@ -1,4 +0,0 @@ -#WireMock password - https://wiremock.org/docs/running-standalone/ -server.ssl.key-store-password=password -server.ssl.key-password=password -server.ssl.trust-store-password=password diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/resources/application.yml b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/resources/application.yml deleted file mode 100644 index cbe617ef03..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/main/resources/application.yml +++ /dev/null @@ -1 +0,0 @@ -server.port=0 diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/test/groovy/org/springframework/cloud/MvcSpec.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/test/groovy/org/springframework/cloud/MvcSpec.groovy deleted file mode 100644 index eb309f4157..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/test/groovy/org/springframework/cloud/MvcSpec.groovy +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud - -import io.restassured.module.mockmvc.RestAssuredMockMvc -import spock.lang.Specification - -import org.springframework.cloud.frauddetection.FraudDetectionController - -class MvcSpec extends Specification { - def setup() { - RestAssuredMockMvc.standaloneSetup(new FraudDetectionController()) - } - - void assertThatRejectionReasonIsNull(def rejectionReason) { - assert !rejectionReason - } -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/test/java/org/springframework/cloud/MvcTest.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/test/java/org/springframework/cloud/MvcTest.java deleted file mode 100644 index 072ac799f1..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/fraudDetectionService/src/test/java/org/springframework/cloud/MvcTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud; - -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import org.junit.Before; - -public class MvcTest { - - @Before - public void setup() { - RestAssuredMockMvc.standaloneSetup( - new org.springframework.cloud.frauddetection.FraudDetectionController()); - } - - public void assertThatRejectionReasonIsNull(Object rejectionReason) { - assert rejectionReason == null; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradle.properties b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradle.properties deleted file mode 100644 index bdf083b1e9..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradle.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright 2013-2019 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -wiremockVersion=2.24.1 -jsonAssertVersion=0.4.13 -verifierVersion=2.2.0.BUILD-SNAPSHOT -bootVersion=2.2.0.BUILD-SNAPSHOT diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradle/wrapper/gradle-wrapper.jar b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 87b738cbd0..0000000000 Binary files a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradle/wrapper/gradle-wrapper.properties b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index b0acbdcd73..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradlew b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradlew deleted file mode 100644 index af6708ff22..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradlew.bat b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradlew.bat deleted file mode 100644 index 6d57edc706..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/mappings/.gitkeep b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/mappings/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/Application.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/Application.java deleted file mode 100644 index b90770da93..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/Application.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableAutoConfiguration -@ComponentScan -public class Application { - - public static void main(String[] args) { - SpringApplication.run(org.springframework.cloud.frauddetection.Application.class, - args); - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/LoanApplicationService.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/LoanApplicationService.java deleted file mode 100644 index 5cea9434a9..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/LoanApplicationService.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection; - -import org.springframework.cloud.frauddetection.model.FraudCheckStatus; -import org.springframework.cloud.frauddetection.model.FraudServiceRequest; -import org.springframework.cloud.frauddetection.model.FraudServiceResponse; -import org.springframework.cloud.frauddetection.model.LoanApplication; -import org.springframework.cloud.frauddetection.model.LoanApplicationResult; -import org.springframework.cloud.frauddetection.model.LoanApplicationStatus; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -@Service -public class LoanApplicationService { - - private static final String FRAUD_SERVICE_JSON_VERSION_1 = "application/vnd.fraud.v1+json"; - - private final RestTemplate restTemplate; - - private int port = 8080; - - public LoanApplicationService() { - this.restTemplate = new RestTemplate(); - } - - public LoanApplicationResult loanApplication(LoanApplication loanApplication) { - FraudServiceRequest request = new FraudServiceRequest(loanApplication); - - FraudServiceResponse response = sendRequestToFraudDetectionService(request); - - return buildResponseFromFraudResult(response); - } - - private FraudServiceResponse sendRequestToFraudDetectionService( - FraudServiceRequest request) { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add(HttpHeaders.CONTENT_TYPE, FRAUD_SERVICE_JSON_VERSION_1); - - ResponseEntity response = this.restTemplate.exchange( - "http://localhost:" + this.port + "/fraudcheck", HttpMethod.PUT, - new HttpEntity<>(request, httpHeaders), FraudServiceResponse.class); - - return response.getBody(); - } - - private LoanApplicationResult buildResponseFromFraudResult( - FraudServiceResponse response) { - LoanApplicationStatus applicationStatus = null; - if (FraudCheckStatus.OK == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLIED; - } - else if (FraudCheckStatus.FRAUD == response.getFraudCheckStatus()) { - applicationStatus = LoanApplicationStatus.LOAN_APPLICATION_REJECTED; - } - - return new LoanApplicationResult(applicationStatus, - response.getRejectionReason()); - } - - public void setPort(int port) { - this.port = port; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/Client.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/Client.java deleted file mode 100644 index 72024217cc..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/Client.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class Client { - - private String pesel; - - public String getPesel() { - return this.pesel; - } - - public void setPesel(String pesel) { - this.pesel = pesel; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java deleted file mode 100644 index 1cadcdfa93..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudCheckStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public enum FraudCheckStatus { - - OK, FRAUD - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceRequest.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceRequest.java deleted file mode 100644 index 6a76e76ed6..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceRequest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -import java.math.BigDecimal; - -public class FraudServiceRequest { - - private String clientPesel; - - private BigDecimal loanAmount; - - public FraudServiceRequest() { - } - - public FraudServiceRequest(LoanApplication loanApplication) { - this.clientPesel = loanApplication.getClient().getPesel(); - this.loanAmount = loanApplication.getAmount(); - } - - public String getClientPesel() { - return this.clientPesel; - } - - public void setClientPesel(String clientPesel) { - this.clientPesel = clientPesel; - } - - public BigDecimal getLoanAmount() { - return this.loanAmount; - } - - public void setLoanAmount(BigDecimal loanAmount) { - this.loanAmount = loanAmount; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceResponse.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceResponse.java deleted file mode 100644 index 4f4579e901..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/FraudServiceResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class FraudServiceResponse { - - private FraudCheckStatus fraudCheckStatus; - - private String rejectionReason; - - public FraudServiceResponse() { - } - - public FraudCheckStatus getFraudCheckStatus() { - return this.fraudCheckStatus; - } - - public void setFraudCheckStatus(FraudCheckStatus fraudCheckStatus) { - this.fraudCheckStatus = fraudCheckStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplication.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplication.java deleted file mode 100644 index f2cac2fddd..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplication.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -import java.math.BigDecimal; - -public class LoanApplication { - - private Client client; - - private BigDecimal amount; - - private String loanApplicationId; - - public Client getClient() { - return this.client; - } - - public void setClient(Client client) { - this.client = client; - } - - public BigDecimal getAmount() { - return this.amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public String getLoanApplicationId() { - return this.loanApplicationId; - } - - public void setLoanApplicationId(String loanApplicationId) { - this.loanApplicationId = loanApplicationId; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationResult.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationResult.java deleted file mode 100644 index e90dc70ead..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationResult.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public class LoanApplicationResult { - - private LoanApplicationStatus loanApplicationStatus; - - private String rejectionReason; - - public LoanApplicationResult() { - } - - public LoanApplicationResult(LoanApplicationStatus loanApplicationStatus, - String rejectionReason) { - this.loanApplicationStatus = loanApplicationStatus; - this.rejectionReason = rejectionReason; - } - - public LoanApplicationStatus getLoanApplicationStatus() { - return this.loanApplicationStatus; - } - - public void setLoanApplicationStatus(LoanApplicationStatus loanApplicationStatus) { - this.loanApplicationStatus = loanApplicationStatus; - } - - public String getRejectionReason() { - return this.rejectionReason; - } - - public void setRejectionReason(String rejectionReason) { - this.rejectionReason = rejectionReason; - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationStatus.java b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationStatus.java deleted file mode 100644 index 68a39e88fd..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/java/org/springframework/cloud/frauddetection/model/LoanApplicationStatus.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.frauddetection.model; - -public enum LoanApplicationStatus { - - LOAN_APPLIED, LOAN_APPLICATION_REJECTED - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/resources/application.yml b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/resources/application.yml deleted file mode 100644 index cbe617ef03..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/main/resources/application.yml +++ /dev/null @@ -1 +0,0 @@ -server.port=0 diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/test/groovy/org/springframework/cloud/LoanApplicationServiceSpec.groovy b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/test/groovy/org/springframework/cloud/LoanApplicationServiceSpec.groovy deleted file mode 100644 index 403c97f67d..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/test/groovy/org/springframework/cloud/LoanApplicationServiceSpec.groovy +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud - -import com.github.tomakehurst.wiremock.junit.WireMockClassRule -import org.junit.ClassRule -import spock.lang.Shared -import spock.lang.Specification - -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootContextLoader -import org.springframework.cloud.frauddetection.Application -import org.springframework.cloud.frauddetection.LoanApplicationService -import org.springframework.cloud.frauddetection.model.Client -import org.springframework.cloud.frauddetection.model.LoanApplication -import org.springframework.cloud.frauddetection.model.LoanApplicationResult -import org.springframework.cloud.frauddetection.model.LoanApplicationStatus -import org.springframework.test.context.ContextConfiguration - -@ContextConfiguration(loader = SpringBootContextLoader, classes = Application) -class LoanApplicationServiceSpec extends Specification { - - public static int port = org.springframework.util.SocketUtils.findAvailableTcpPort() - - @ClassRule - @Shared - WireMockClassRule wireMockRule = new WireMockClassRule(port) - - @Autowired - LoanApplicationService sut - - def setup() { - sut.port = port - } - - def 'should successfully apply for loan'() { - given: - LoanApplication application = - new LoanApplication(client: new Client(pesel: '1234567890'), amount: 123.123) - when: - LoanApplicationResult loanApplication = sut.loanApplication(application) - then: - loanApplication.loanApplicationStatus == LoanApplicationStatus.LOAN_APPLIED - loanApplication.rejectionReason == null - } - - def 'should be rejected due to abnormal loan amount'() { - given: - LoanApplication application = - new LoanApplication(client: new Client(pesel: '1234567890'), amount: 99_999) - when: - LoanApplicationResult loanApplication = sut.loanApplication(application) - then: - loanApplication.loanApplicationStatus == LoanApplicationStatus.LOAN_APPLICATION_REJECTED - loanApplication.rejectionReason == 'Amount too high' - } - -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json deleted file mode 100644 index fe037dc7ef..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsFraud.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "request": { - "method": "PUT", - "headers": { - "Content-Type": { - "equalTo": "application/vnd.fraud.v1+json" - } - }, - "url": "/fraudcheck", - "bodyPatterns": [ - { - "matches": "{\"clientPesel\":\"[0-9]{10}\",\"loanAmount\":\"99999\"}" - } - ] - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/vnd.fraud.v1+json" - }, - "body": "{\"fraudCheckStatus\":\"FRAUD\",\"rejectionReason\":\"Amount too high\"}" - } -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json deleted file mode 100644 index 8b89b6d54e..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/loanApplicationService/src/test/resources/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "request": { - "method": "PUT", - "headers": { - "Content-Type": { - "equalTo": "application/vnd.fraud.v1+json" - } - }, - "url": "/fraudcheck", - "bodyPatterns": [ - { - "matches": "{\"clientPesel\":\"[0-9]{10}\",\"loanAmount\":\"123.123\"}" - } - ] - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/vnd.fraud.v1+json" - }, - "body": "{\"fraudCheckStatus\":\"OK\",\"rejectionReason\":null}" - } -} diff --git a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/settings.gradle.kts b/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/settings.gradle.kts deleted file mode 100644 index 8d278951af..0000000000 --- a/spring-cloud-contract-tools/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/sampleProjectKotlin/settings.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -include(":fraudDetectionService") -include(":loanApplicationService")