Fixed the broken build
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import org.gradle.api.JavaVersion
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -158,7 +156,3 @@ task resolveDependencies {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '4.10.2'
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -28,7 +28,7 @@ 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=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
@@ -14,7 +14,7 @@ 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=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
@@ -24,9 +24,6 @@ import org.gradle.api.plugins.GroovyPlugin
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
|
||||
/**
|
||||
* Gradle plugin for Spring Cloud Contract Verifier that from the DSL contract can
|
||||
* <ul>
|
||||
@@ -150,12 +147,11 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
|
||||
return task
|
||||
}
|
||||
else {
|
||||
ContractVerifierConfigProperties props = ExtensionToProperties.fromExtension(extension)
|
||||
task = project.tasks.create(type: Jar, name: VERIFIER_STUBS_JAR_TASK_NAME,
|
||||
dependsOn: DSL_TO_CLIENT_TASK_NAME) {
|
||||
baseName = project.name
|
||||
classifier = props.stubsSuffix
|
||||
from { props.stubsOutputDir ?: project.file("${project.buildDir}/stubs") }
|
||||
classifier = extension.stubsSuffix
|
||||
from { extension.stubsOutputDir ?: project.file("${project.buildDir}/stubs") }
|
||||
}
|
||||
task.description = "Creates the stubs JAR task"
|
||||
task.group = GROUP_NAME
|
||||
|
||||
@@ -59,10 +59,6 @@ contracts {
|
||||
|
||||
generateContractTests.dependsOn generateClientStubs
|
||||
|
||||
wrapper {
|
||||
gradleVersion '4.10.2'
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging {
|
||||
exceptionFormat = 'full'
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
wiremockVersion=2.20.0
|
||||
wiremockVersion=2.23.2
|
||||
jsonAssertVersion=0.4.13
|
||||
verifierVersion=2.2.0.BUILD-SNAPSHOT
|
||||
groovyVersion=2.4.15
|
||||
groovyVersion=2.4.17
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -28,7 +28,7 @@ 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=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
@@ -14,7 +14,7 @@ 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=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
@@ -123,6 +123,12 @@ configure(project(':fraudDetectionService')) {
|
||||
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'
|
||||
@@ -152,7 +158,3 @@ configure(project(':loanApplicationService')) {
|
||||
|
||||
test.dependsOn('copyCollaboratorStubs')
|
||||
}
|
||||
|
||||
wrapper {
|
||||
gradleVersion '4.10.2'
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
server.port=0
|
||||
@@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
wiremockVersion=2.20.0
|
||||
wiremockVersion=2.23.2
|
||||
jsonAssertVersion=0.4.13
|
||||
verifierVersion=2.2.0.BUILD-SNAPSHOT
|
||||
bootVersion=2.2.0.BUILD-SNAPSHOT
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -28,7 +28,7 @@ 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=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
@@ -14,7 +14,7 @@ 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=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
@@ -130,7 +130,3 @@ configure(project(':loanApplicationService')) {
|
||||
|
||||
generateContractTests.dependsOn('copyCollaboratorStubs')
|
||||
}
|
||||
|
||||
wrapper {
|
||||
gradleVersion '4.10.2'
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
wiremockVersion=2.20.0
|
||||
wiremockVersion=2.23.2
|
||||
jsonAssertVersion=0.4.13
|
||||
verifierVersion=2.2.0.BUILD-SNAPSHOT
|
||||
bootVersion=2.2.0.BUILD-SNAPSHOT
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -28,7 +28,7 @@ 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=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
@@ -14,7 +14,7 @@ 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=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
@@ -156,7 +156,3 @@ configure(project(':loanApplicationService')) {
|
||||
|
||||
generateContractTests.dependsOn('copyCollaboratorStubs')
|
||||
}
|
||||
|
||||
wrapper {
|
||||
gradleVersion '4.10.2'
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
wiremockVersion=2.20.0
|
||||
wiremockVersion=2.23.2
|
||||
jsonAssertVersion=0.4.13
|
||||
verifierVersion=2.2.0.BUILD-SNAPSHOT
|
||||
bootVersion=2.2.0.BUILD-SNAPSHOT
|
||||
groovyVersion=2.4.15
|
||||
groovyVersion=2.4.17
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -28,7 +28,7 @@ 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=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
@@ -14,7 +14,7 @@ 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=
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
@@ -58,8 +58,8 @@ class MockMvcQueryParamsWhen implements When, MockMvcAcceptor, QueryParamsResolv
|
||||
}
|
||||
|
||||
private void addQueryParameters(Url buildUrl) {
|
||||
List<QueryParameter> queryParameters = buildUrl.getQueryParameters().getParameters().stream()
|
||||
.filter(this::allowedQueryParameter)
|
||||
List<QueryParameter> queryParameters = buildUrl.getQueryParameters()
|
||||
.getParameters().stream().filter(this::allowedQueryParameter)
|
||||
.collect(Collectors.toList());
|
||||
Iterator<QueryParameter> iterator = queryParameters.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -67,7 +67,8 @@ class MockMvcQueryParamsWhen implements When, MockMvcAcceptor, QueryParamsResolv
|
||||
String text = addQueryParameter(parameter);
|
||||
if (iterator.hasNext()) {
|
||||
this.blockBuilder.addLine(text);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.blockBuilder.addIndented(text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,180 +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.contract.verifier.config
|
||||
|
||||
import org.apache.commons.logging.Log
|
||||
import org.apache.commons.logging.LogFactory
|
||||
|
||||
/**
|
||||
* Represents Contract Verifier configuration properties
|
||||
*
|
||||
* @author Jakub Kubrynski, codearte.io
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ContractVerifierConfigProperties {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ContractVerifierConfigProperties)
|
||||
|
||||
/**
|
||||
* For which unit test library tests should be generated
|
||||
* @deprecated - use {@code testFramework}
|
||||
*/
|
||||
@Deprecated
|
||||
TestFramework targetFramework
|
||||
|
||||
@Deprecated
|
||||
void setTargetFramework(TestFramework targetFramework) {
|
||||
log.warn("Please use the [testFramework] field. [targetFramework] is deprecated")
|
||||
setTestFramework(targetFramework)
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
TestFramework getTargetFramework() {
|
||||
return getTestFramework()
|
||||
}
|
||||
|
||||
/**
|
||||
* For which unit test library tests should be generated
|
||||
*/
|
||||
TestFramework testFramework = TestFramework.JUNIT
|
||||
|
||||
/**
|
||||
* Which mechanism should be used to invoke REST calls during tests
|
||||
*/
|
||||
TestMode testMode = TestMode.MOCKMVC
|
||||
|
||||
/**
|
||||
* Base package for generated tests
|
||||
*/
|
||||
String basePackageForTests
|
||||
|
||||
/**
|
||||
* Class which all generated tests should extend
|
||||
*/
|
||||
String baseClassForTests
|
||||
|
||||
/**
|
||||
* Suffix for generated test classes, like Spec or Test
|
||||
*/
|
||||
String nameSuffixForTests
|
||||
|
||||
/**
|
||||
* Rule class that should be added to generated tests
|
||||
*/
|
||||
String ruleClassForTests
|
||||
|
||||
/**
|
||||
* Patterns that should not be taken into account for processing
|
||||
*/
|
||||
List<String> excludedFiles = []
|
||||
|
||||
/**
|
||||
* Patterns that should be taken into account for processing
|
||||
*/
|
||||
List<String> includedFiles = []
|
||||
|
||||
/**
|
||||
* Patterns for which generated tests should be @Ignored
|
||||
*/
|
||||
List<String> ignoredFiles = []
|
||||
|
||||
/**
|
||||
* Imports that should be added to generated tests
|
||||
*/
|
||||
String[] imports = []
|
||||
|
||||
/**
|
||||
* Static imports that should be added to generated tests
|
||||
*/
|
||||
String[] staticImports = []
|
||||
|
||||
/**
|
||||
* Directory containing contracts
|
||||
*/
|
||||
File contractsDslDir
|
||||
|
||||
/**
|
||||
* Test source directory where tests generated
|
||||
*/
|
||||
File generatedTestSourcesDir
|
||||
|
||||
/**
|
||||
* Test resource directory where additional resources for tests will be set
|
||||
*/
|
||||
File generatedTestResourcesDir
|
||||
|
||||
/**
|
||||
* Dir where the generated stubs from the contracts should be placed.
|
||||
* You can then mention them in your packaging task to create jar with stubs
|
||||
*/
|
||||
File stubsOutputDir
|
||||
|
||||
/**
|
||||
* Suffix for the generated Stubs Jar task
|
||||
*/
|
||||
String stubsSuffix = 'stubs'
|
||||
|
||||
/**
|
||||
* Incubating feature. You can check the size of JSON arrays. If not turned on
|
||||
* explicitly will be disabled.
|
||||
*/
|
||||
Boolean assertJsonSize = false
|
||||
|
||||
/**
|
||||
* A regular expression that matches contracts. Especially useful when using a single JAR containing
|
||||
* all the contracts in the system. In this case you'd like to take into consideration only some of them.
|
||||
* Defaults to picking all files.
|
||||
*/
|
||||
String includedContracts = ".*"
|
||||
|
||||
/**
|
||||
* A ant pattern to match files. Gets updated when using repo with common contracts
|
||||
* to reflect the path to proper folder with contracts.
|
||||
*/
|
||||
String includedRootFolderAntPattern = "**/"
|
||||
|
||||
/**
|
||||
* A package that contains all the base clases for generated tests. If your contract resides in a location
|
||||
* {@code src/test/resources/contracts/com/example/v1/} and you provide the {@code packageWithBaseClasses}
|
||||
* value to {@code com.example.contracts.base} then we will search for a test source file that will
|
||||
* have the package {@code com.example.contracts.base} and name {@code ExampleV1Base}. As you can see
|
||||
* it will take the two last folders to and attach {@code Base} to its name.
|
||||
*/
|
||||
String packageWithBaseClasses
|
||||
|
||||
/**
|
||||
* A way to override any base class mappings. The keys are regular expressions on the package name of the contract
|
||||
* and the values FQN to a base class for that given expression.
|
||||
* </p>
|
||||
* Example of a mapping
|
||||
* </p>
|
||||
* {@code .*.com.example.v1..*} -> {@code com.example.SomeBaseClass}
|
||||
* </p>
|
||||
* When a contract's package matches the provided regular expression then extending class will be the one
|
||||
* provided in the map - in this case {@code com.example.SomeBaseClass}
|
||||
*/
|
||||
Map<String, String> baseClassMappings
|
||||
|
||||
/**
|
||||
* If set to true then the {@code target} or {@code build} folders are getting
|
||||
* excluded from any operations. This is used out of the box when working with
|
||||
* common repo with contracts.
|
||||
*/
|
||||
boolean excludeBuildFolders
|
||||
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
/*
|
||||
* 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.contract.verifier.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Represents Contract Verifier configuration properties.
|
||||
*
|
||||
* @author Jakub Kubrynski, codearte.io
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ContractVerifierConfigProperties {
|
||||
|
||||
private static final Log log = LogFactory
|
||||
.getLog(ContractVerifierConfigProperties.class);
|
||||
|
||||
/**
|
||||
* For which unit test library tests should be generated.
|
||||
* @deprecated - use {@code testFramework}
|
||||
*/
|
||||
@Deprecated
|
||||
private TestFramework targetFramework;
|
||||
|
||||
/**
|
||||
* For which unit test library tests should be generated.
|
||||
*/
|
||||
private TestFramework testFramework = TestFramework.JUNIT;
|
||||
|
||||
/**
|
||||
* Which mechanism should be used to invoke REST calls during. tests
|
||||
*/
|
||||
private TestMode testMode = TestMode.MOCKMVC;
|
||||
|
||||
/**
|
||||
* Base package for generated tests.
|
||||
*/
|
||||
private String basePackageForTests;
|
||||
|
||||
/**
|
||||
* Class which all generated tests should extend.
|
||||
*/
|
||||
private String baseClassForTests;
|
||||
|
||||
/**
|
||||
* Suffix for generated test classes, like Spec or Test.
|
||||
*/
|
||||
private String nameSuffixForTests;
|
||||
|
||||
/**
|
||||
* Rule class that should be added to generated tests.
|
||||
*/
|
||||
private String ruleClassForTests;
|
||||
|
||||
/**
|
||||
* Patterns that should not be taken into account for processing.
|
||||
*/
|
||||
private List<String> excludedFiles = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Patterns that should be taken into account for processing.
|
||||
*/
|
||||
private List<String> includedFiles = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Patterns for which generated tests should be @Ignored.
|
||||
*/
|
||||
private List<String> ignoredFiles = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Imports that should be added to generated tests.
|
||||
*/
|
||||
private String[] imports = new String[0];
|
||||
|
||||
/**
|
||||
* Static imports that should be added to generated tests.
|
||||
*/
|
||||
private String[] staticImports = new String[0];
|
||||
|
||||
/**
|
||||
* Directory containing contracts.
|
||||
*/
|
||||
private File contractsDslDir;
|
||||
|
||||
/**
|
||||
* Test source directory where tests generated.
|
||||
*/
|
||||
private File generatedTestSourcesDir;
|
||||
|
||||
/**
|
||||
* Test resource directory where additional resources for tests will be set.
|
||||
*/
|
||||
private File generatedTestResourcesDir;
|
||||
|
||||
/**
|
||||
* Dir where the generated stubs from the contracts should be placed. You can then
|
||||
* mention them in your packaging task to create jar with stubs.
|
||||
*/
|
||||
private File stubsOutputDir;
|
||||
|
||||
/**
|
||||
* Suffix for the generated Stubs Jar task.
|
||||
*/
|
||||
private String stubsSuffix = "stubs";
|
||||
|
||||
/**
|
||||
* Incubating feature. You can check the size of JSON arrays. If not turned on
|
||||
* explicitly will be disabled.
|
||||
*/
|
||||
private Boolean assertJsonSize = false;
|
||||
|
||||
/**
|
||||
* A regular expression that matches contracts. Especially useful when using a single
|
||||
* JAR containing all the contracts in the system. In this case you'd like to take
|
||||
* into consideration only some of them. Defaults to picking all files.
|
||||
*/
|
||||
private String includedContracts = ".*";
|
||||
|
||||
/**
|
||||
* A ant pattern to match files. Gets updated when using repo with common contracts to
|
||||
* reflect the path to proper folder with contracts.
|
||||
*/
|
||||
private String includedRootFolderAntPattern = "**/";
|
||||
|
||||
/**
|
||||
* A package that contains all the base clases for generated tests. If your contract
|
||||
* resides in a location {@code src/test/resources/contracts/com/example/v1/} and you
|
||||
* provide the {@code packageWithBaseClasses} value to
|
||||
* {@code com.example.contracts.base} then we will search for a test source file that
|
||||
* will have the package {@code com.example.contracts.base} and name
|
||||
* {@code ExampleV1Base}. As you can see it will take the two last folders to and
|
||||
* attach {@code Base} to its name.
|
||||
*/
|
||||
private String packageWithBaseClasses;
|
||||
|
||||
/**
|
||||
* A way to override any base class mappings. The keys are regular expressions on the
|
||||
* package name of the contract and the values FQN to a base class for that given
|
||||
* expression.
|
||||
* </p>
|
||||
* Example of a mapping
|
||||
* </p>
|
||||
* {@code .*.com.example.v1..*} -> {@code com.example.SomeBaseClass}
|
||||
* </p>
|
||||
* When a contract's package matches the provided regular expression then extending
|
||||
* class will be the one provided in the map - in this case
|
||||
* {@code com.example.SomeBaseClass}
|
||||
*/
|
||||
private Map<String, String> baseClassMappings;
|
||||
|
||||
/**
|
||||
* If set to true then the {@code target} or {@code build} folders are getting
|
||||
* excluded from any operations. This is used out of the box when working with common
|
||||
* repo with contracts.
|
||||
*/
|
||||
private boolean excludeBuildFolders;
|
||||
|
||||
@Deprecated
|
||||
public void setTargetFramework(TestFramework targetFramework) {
|
||||
log.warn("Please use the [testFramework] field. [targetFramework] is deprecated");
|
||||
setTestFramework(targetFramework);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public TestFramework getTargetFramework() {
|
||||
return getTestFramework();
|
||||
}
|
||||
|
||||
public TestFramework getTestFramework() {
|
||||
return testFramework;
|
||||
}
|
||||
|
||||
public void setTestFramework(TestFramework testFramework) {
|
||||
this.testFramework = testFramework;
|
||||
}
|
||||
|
||||
public TestMode getTestMode() {
|
||||
return testMode;
|
||||
}
|
||||
|
||||
public void setTestMode(TestMode testMode) {
|
||||
this.testMode = testMode;
|
||||
}
|
||||
|
||||
public String getBasePackageForTests() {
|
||||
return basePackageForTests;
|
||||
}
|
||||
|
||||
public void setBasePackageForTests(String basePackageForTests) {
|
||||
this.basePackageForTests = basePackageForTests;
|
||||
}
|
||||
|
||||
public String getBaseClassForTests() {
|
||||
return baseClassForTests;
|
||||
}
|
||||
|
||||
public void setBaseClassForTests(String baseClassForTests) {
|
||||
this.baseClassForTests = baseClassForTests;
|
||||
}
|
||||
|
||||
public String getNameSuffixForTests() {
|
||||
return nameSuffixForTests;
|
||||
}
|
||||
|
||||
public void setNameSuffixForTests(String nameSuffixForTests) {
|
||||
this.nameSuffixForTests = nameSuffixForTests;
|
||||
}
|
||||
|
||||
public String getRuleClassForTests() {
|
||||
return ruleClassForTests;
|
||||
}
|
||||
|
||||
public void setRuleClassForTests(String ruleClassForTests) {
|
||||
this.ruleClassForTests = ruleClassForTests;
|
||||
}
|
||||
|
||||
public List<String> getExcludedFiles() {
|
||||
return excludedFiles;
|
||||
}
|
||||
|
||||
public void setExcludedFiles(List<String> excludedFiles) {
|
||||
this.excludedFiles = excludedFiles;
|
||||
}
|
||||
|
||||
public List<String> getIncludedFiles() {
|
||||
return includedFiles;
|
||||
}
|
||||
|
||||
public void setIncludedFiles(List<String> includedFiles) {
|
||||
this.includedFiles = includedFiles;
|
||||
}
|
||||
|
||||
public List<String> getIgnoredFiles() {
|
||||
return ignoredFiles;
|
||||
}
|
||||
|
||||
public void setIgnoredFiles(List<String> ignoredFiles) {
|
||||
this.ignoredFiles = ignoredFiles;
|
||||
}
|
||||
|
||||
public String[] getImports() {
|
||||
return imports;
|
||||
}
|
||||
|
||||
public void setImports(String[] imports) {
|
||||
this.imports = imports;
|
||||
}
|
||||
|
||||
public String[] getStaticImports() {
|
||||
return staticImports;
|
||||
}
|
||||
|
||||
public void setStaticImports(String[] staticImports) {
|
||||
this.staticImports = staticImports;
|
||||
}
|
||||
|
||||
public File getContractsDslDir() {
|
||||
return contractsDslDir;
|
||||
}
|
||||
|
||||
public void setContractsDslDir(File contractsDslDir) {
|
||||
this.contractsDslDir = contractsDslDir;
|
||||
}
|
||||
|
||||
public File getGeneratedTestSourcesDir() {
|
||||
return generatedTestSourcesDir;
|
||||
}
|
||||
|
||||
public void setGeneratedTestSourcesDir(File generatedTestSourcesDir) {
|
||||
this.generatedTestSourcesDir = generatedTestSourcesDir;
|
||||
}
|
||||
|
||||
public File getGeneratedTestResourcesDir() {
|
||||
return generatedTestResourcesDir;
|
||||
}
|
||||
|
||||
public void setGeneratedTestResourcesDir(File generatedTestResourcesDir) {
|
||||
this.generatedTestResourcesDir = generatedTestResourcesDir;
|
||||
}
|
||||
|
||||
public File getStubsOutputDir() {
|
||||
return stubsOutputDir;
|
||||
}
|
||||
|
||||
public void setStubsOutputDir(File stubsOutputDir) {
|
||||
this.stubsOutputDir = stubsOutputDir;
|
||||
}
|
||||
|
||||
public String getStubsSuffix() {
|
||||
return stubsSuffix;
|
||||
}
|
||||
|
||||
public void setStubsSuffix(String stubsSuffix) {
|
||||
this.stubsSuffix = stubsSuffix;
|
||||
}
|
||||
|
||||
public Boolean getAssertJsonSize() {
|
||||
return assertJsonSize;
|
||||
}
|
||||
|
||||
public void setAssertJsonSize(Boolean assertJsonSize) {
|
||||
this.assertJsonSize = assertJsonSize;
|
||||
}
|
||||
|
||||
public String getIncludedContracts() {
|
||||
return includedContracts;
|
||||
}
|
||||
|
||||
public void setIncludedContracts(String includedContracts) {
|
||||
this.includedContracts = includedContracts;
|
||||
}
|
||||
|
||||
public String getIncludedRootFolderAntPattern() {
|
||||
return includedRootFolderAntPattern;
|
||||
}
|
||||
|
||||
public void setIncludedRootFolderAntPattern(String includedRootFolderAntPattern) {
|
||||
this.includedRootFolderAntPattern = includedRootFolderAntPattern;
|
||||
}
|
||||
|
||||
public String getPackageWithBaseClasses() {
|
||||
return packageWithBaseClasses;
|
||||
}
|
||||
|
||||
public void setPackageWithBaseClasses(String packageWithBaseClasses) {
|
||||
this.packageWithBaseClasses = packageWithBaseClasses;
|
||||
}
|
||||
|
||||
public Map<String, String> getBaseClassMappings() {
|
||||
return baseClassMappings;
|
||||
}
|
||||
|
||||
public void setBaseClassMappings(Map<String, String> baseClassMappings) {
|
||||
this.baseClassMappings = baseClassMappings;
|
||||
}
|
||||
|
||||
public boolean getExcludeBuildFolders() {
|
||||
return excludeBuildFolders;
|
||||
}
|
||||
|
||||
public boolean isExcludeBuildFolders() {
|
||||
return excludeBuildFolders;
|
||||
}
|
||||
|
||||
public void setExcludeBuildFolders(boolean excludeBuildFolders) {
|
||||
this.excludeBuildFolders = excludeBuildFolders;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,166 +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.contract.verifier.config
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
import org.springframework.cloud.contract.verifier.config.framework.CustomDefinition
|
||||
import org.springframework.cloud.contract.verifier.config.framework.JUnit5Definition
|
||||
import org.springframework.cloud.contract.verifier.config.framework.JUnitDefinition
|
||||
import org.springframework.cloud.contract.verifier.config.framework.SpockDefinition
|
||||
import org.springframework.cloud.contract.verifier.config.framework.TestFrameworkDefinition
|
||||
|
||||
/**
|
||||
* Contains main building blocks for a test class for the given framework
|
||||
*
|
||||
* @author Jakub Kubrynski, codearte.io
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@CompileStatic
|
||||
enum TestFramework {
|
||||
|
||||
SPOCK(new SpockDefinition()),
|
||||
JUNIT(new JUnitDefinition()),
|
||||
JUNIT5(new JUnit5Definition()),
|
||||
CUSTOM(new CustomDefinition())
|
||||
|
||||
private final TestFrameworkDefinition testFrameworkDefinition
|
||||
|
||||
|
||||
TestFramework(TestFrameworkDefinition testFrameworkDefinition) {
|
||||
this.testFrameworkDefinition = testFrameworkDefinition
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use{@link #TestFramework(TestFrameworkDefinition)}
|
||||
* @param classModifier
|
||||
* @param methodModifier
|
||||
* @param lineSuffix
|
||||
* @param classExtension
|
||||
* @param classNameSuffix
|
||||
* @param ignoreClass
|
||||
* @param orderAnnotationImports
|
||||
* @param orderAnnotation
|
||||
*/
|
||||
@Deprecated
|
||||
TestFramework(String classModifier, String methodModifier, String lineSuffix, String classExtension, String classNameSuffix,
|
||||
String ignoreClass, List<String> orderAnnotationImports, String orderAnnotation) {
|
||||
testFrameworkDefinition = new TestFrameworkDefinition() {
|
||||
|
||||
@Override
|
||||
String getClassModifier() {
|
||||
return classModifier
|
||||
}
|
||||
|
||||
@Override
|
||||
String getMethodModifier() {
|
||||
return methodModifier
|
||||
}
|
||||
|
||||
@Override
|
||||
String getLineSuffix() {
|
||||
return lineSuffix
|
||||
}
|
||||
|
||||
@Override
|
||||
String getClassExtension() {
|
||||
return classExtension
|
||||
}
|
||||
|
||||
@Override
|
||||
String getClassNameSuffix() {
|
||||
return classNameSuffix
|
||||
}
|
||||
|
||||
@Override
|
||||
String getIgnoreClass() {
|
||||
return ignoreClass
|
||||
}
|
||||
|
||||
@Override
|
||||
List<String> getOrderAnnotationImports() {
|
||||
return orderAnnotationImports
|
||||
}
|
||||
|
||||
@Override
|
||||
String getOrderAnnotation() {
|
||||
return orderAnnotation
|
||||
}
|
||||
|
||||
@Override
|
||||
String getIgnoreAnnotation() {
|
||||
return '@Ignore'
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean annotationLevelRules() {
|
||||
return false
|
||||
}
|
||||
|
||||
@Override
|
||||
String getRuleAnnotation(String annotationValue) {
|
||||
throw new UnsupportedOperationException('Not available in framework.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getClassModifier() {
|
||||
return this.testFrameworkDefinition.classModifier
|
||||
}
|
||||
|
||||
String getMethodModifier() {
|
||||
return this.testFrameworkDefinition.methodModifier
|
||||
}
|
||||
|
||||
String getLineSuffix() {
|
||||
return this.testFrameworkDefinition.lineSuffix
|
||||
}
|
||||
|
||||
String getClassExtension() {
|
||||
return this.testFrameworkDefinition.classExtension
|
||||
}
|
||||
|
||||
String getClassNameSuffix() {
|
||||
return this.testFrameworkDefinition.classNameSuffix
|
||||
}
|
||||
|
||||
String getIgnoreClass() {
|
||||
return this.testFrameworkDefinition.ignoreClass
|
||||
}
|
||||
|
||||
List<String> getOrderAnnotationImports() {
|
||||
return this.testFrameworkDefinition.orderAnnotationImports
|
||||
}
|
||||
|
||||
String getOrderAnnotation() {
|
||||
return this.testFrameworkDefinition.orderAnnotation
|
||||
}
|
||||
|
||||
String getIgnoreAnnotation() {
|
||||
return this.testFrameworkDefinition.ignoreAnnotation
|
||||
}
|
||||
|
||||
boolean annotationLevelRules() {
|
||||
return this.testFrameworkDefinition.annotationLevelRules()
|
||||
}
|
||||
|
||||
String getRuleAnnotation(String annotationValue) {
|
||||
return this.testFrameworkDefinition.getRuleAnnotation(annotationValue)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* 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.contract.verifier.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cloud.contract.verifier.config.framework.CustomDefinition;
|
||||
import org.springframework.cloud.contract.verifier.config.framework.JUnit5Definition;
|
||||
import org.springframework.cloud.contract.verifier.config.framework.JUnitDefinition;
|
||||
import org.springframework.cloud.contract.verifier.config.framework.SpockDefinition;
|
||||
import org.springframework.cloud.contract.verifier.config.framework.TestFrameworkDefinition;
|
||||
|
||||
/**
|
||||
* Contains main building blocks for a test class for the given framework.
|
||||
*
|
||||
* @author Jakub Kubrynski, codearte.io
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public enum TestFramework {
|
||||
|
||||
/**
|
||||
* Spock test framework.
|
||||
*/
|
||||
SPOCK(new SpockDefinition()),
|
||||
/**
|
||||
* JUnit test framework.
|
||||
*/
|
||||
JUNIT(new JUnitDefinition()),
|
||||
/**
|
||||
* JUnit5 test framework.
|
||||
*/
|
||||
JUNIT5(new JUnit5Definition()),
|
||||
/**
|
||||
* Custom test framework.
|
||||
*/
|
||||
CUSTOM(new CustomDefinition());
|
||||
|
||||
private final TestFrameworkDefinition testFrameworkDefinition;
|
||||
|
||||
TestFramework(TestFrameworkDefinition testFrameworkDefinition) {
|
||||
this.testFrameworkDefinition = testFrameworkDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use{@link #TestFramework(TestFrameworkDefinition)}
|
||||
* @param classModifier class modifier
|
||||
* @param methodModifier method modifier
|
||||
* @param lineSuffix line suffix
|
||||
* @param classExtension class extension
|
||||
* @param classNameSuffix class name suffix
|
||||
* @param ignoreClass ignore class
|
||||
* @param orderAnnotationImports order annotation imports
|
||||
* @param orderAnnotation order annotation
|
||||
*/
|
||||
@Deprecated
|
||||
TestFramework(final String classModifier, final String methodModifier,
|
||||
final String lineSuffix, final String classExtension,
|
||||
final String classNameSuffix, final String ignoreClass,
|
||||
final List<String> orderAnnotationImports, final String orderAnnotation) {
|
||||
testFrameworkDefinition = new TestFrameworkDefinition() {
|
||||
@Override
|
||||
public String getClassModifier() {
|
||||
return classModifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodModifier() {
|
||||
return methodModifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLineSuffix() {
|
||||
return lineSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassExtension() {
|
||||
return classExtension;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassNameSuffix() {
|
||||
return classNameSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIgnoreClass() {
|
||||
return ignoreClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getOrderAnnotationImports() {
|
||||
return orderAnnotationImports;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrderAnnotation() {
|
||||
return orderAnnotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIgnoreAnnotation() {
|
||||
return "@Ignore";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean annotationLevelRules() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRuleAnnotation(String annotationValue) {
|
||||
throw new UnsupportedOperationException("Not available in framework.");
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public String getClassModifier() {
|
||||
return this.testFrameworkDefinition.getClassModifier();
|
||||
}
|
||||
|
||||
public String getMethodModifier() {
|
||||
return this.testFrameworkDefinition.getMethodModifier();
|
||||
}
|
||||
|
||||
public String getLineSuffix() {
|
||||
return this.testFrameworkDefinition.getLineSuffix();
|
||||
}
|
||||
|
||||
public String getClassExtension() {
|
||||
return this.testFrameworkDefinition.getClassExtension();
|
||||
}
|
||||
|
||||
public String getClassNameSuffix() {
|
||||
return this.testFrameworkDefinition.getClassNameSuffix();
|
||||
}
|
||||
|
||||
public String getIgnoreClass() {
|
||||
return this.testFrameworkDefinition.getIgnoreClass();
|
||||
}
|
||||
|
||||
public List<String> getOrderAnnotationImports() {
|
||||
return this.testFrameworkDefinition.getOrderAnnotationImports();
|
||||
}
|
||||
|
||||
public String getOrderAnnotation() {
|
||||
return this.testFrameworkDefinition.getOrderAnnotation();
|
||||
}
|
||||
|
||||
public String getIgnoreAnnotation() {
|
||||
return this.testFrameworkDefinition.getIgnoreAnnotation();
|
||||
}
|
||||
|
||||
public boolean annotationLevelRules() {
|
||||
return this.testFrameworkDefinition.annotationLevelRules();
|
||||
}
|
||||
|
||||
public String getRuleAnnotation(String annotationValue) {
|
||||
return this.testFrameworkDefinition.getRuleAnnotation(annotationValue);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,33 +14,32 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.contract.verifier.config
|
||||
package org.springframework.cloud.contract.verifier.config;
|
||||
|
||||
/**
|
||||
* Provides different testing modes
|
||||
* Provides different testing modes.
|
||||
*
|
||||
* @author Jakub Kubrynski, codearte.io
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
enum TestMode {
|
||||
public enum TestMode {
|
||||
|
||||
/**
|
||||
* Uses Spring's MockMvc with Rest Assured 2.x
|
||||
* Uses Spring's MockMvc mode.
|
||||
*/
|
||||
MOCKMVC,
|
||||
|
||||
/**
|
||||
* Uses direct HTTP invocations with Rest Assured 2.x
|
||||
* Uses direct HTTP invocations with Rest Assured.
|
||||
*/
|
||||
EXPLICIT,
|
||||
|
||||
/**
|
||||
* Uses JAX-RS client
|
||||
* Uses JAX-RS client.
|
||||
*/
|
||||
JAXRSCLIENT,
|
||||
|
||||
/**
|
||||
* Uses Spring's reactive WebTestClient
|
||||
* Uses Spring's reactive WebTestClient.
|
||||
*/
|
||||
WEBTESTCLIENT
|
||||
WEBTESTCLIENT;
|
||||
|
||||
}
|
||||
@@ -14,72 +14,73 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.contract.verifier.config.framework
|
||||
package org.springframework.cloud.contract.verifier.config.framework;
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Defines elements characteristic of Custom test framework to be used during test class construction.
|
||||
* Defines elements characteristic of Custom test framework to be used during test class
|
||||
* construction.
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@CompileStatic
|
||||
class CustomDefinition implements TestFrameworkDefinition {
|
||||
public class CustomDefinition implements TestFrameworkDefinition {
|
||||
|
||||
@Override
|
||||
String getClassModifier() {
|
||||
return ''
|
||||
public String getClassModifier() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getMethodModifier() {
|
||||
return ''
|
||||
public String getMethodModifier() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getLineSuffix() {
|
||||
return ''
|
||||
public String getLineSuffix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getClassExtension() {
|
||||
return ''
|
||||
public String getClassExtension() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getClassNameSuffix() {
|
||||
return ''
|
||||
public String getClassNameSuffix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getIgnoreClass() {
|
||||
return ''
|
||||
public String getIgnoreClass() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
List<String> getOrderAnnotationImports() {
|
||||
return []
|
||||
public List<String> getOrderAnnotationImports() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
String getOrderAnnotation() {
|
||||
return ''
|
||||
public String getOrderAnnotation() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getIgnoreAnnotation() {
|
||||
return '@Ignore'
|
||||
public String getIgnoreAnnotation() {
|
||||
return "@Ignore";
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean annotationLevelRules() {
|
||||
return false
|
||||
public boolean annotationLevelRules() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
String getRuleAnnotation(String annotationValue) {
|
||||
throw new UnsupportedOperationException('Not available in framework.')
|
||||
public String getRuleAnnotation(String annotationValue) {
|
||||
throw new UnsupportedOperationException("Not available in framework.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,85 +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.contract.verifier.config.framework
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
/**
|
||||
* Defines elements characteristic of JUnit5 test framework to be used during test class construction.
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@CompileStatic
|
||||
class JUnit5Definition implements TestFrameworkDefinition {
|
||||
|
||||
@Override
|
||||
String getClassModifier() {
|
||||
return 'public '
|
||||
}
|
||||
|
||||
@Override
|
||||
String getMethodModifier() {
|
||||
return 'public void '
|
||||
}
|
||||
|
||||
@Override
|
||||
String getLineSuffix() {
|
||||
return ';'
|
||||
}
|
||||
|
||||
@Override
|
||||
String getClassExtension() {
|
||||
'.java'
|
||||
}
|
||||
|
||||
@Override
|
||||
String getClassNameSuffix() {
|
||||
return 'Test'
|
||||
}
|
||||
|
||||
@Override
|
||||
String getIgnoreClass() {
|
||||
return 'org.junit.jupiter.api.Disabled'
|
||||
}
|
||||
|
||||
@Override
|
||||
List<String> getOrderAnnotationImports() {
|
||||
throw new UnsupportedOperationException('Not implemented yet in JUnit5 - https://github.com/junit-team/junit5/issues/48')
|
||||
}
|
||||
|
||||
@Override
|
||||
String getOrderAnnotation() {
|
||||
throw new UnsupportedOperationException('Not implemented yet in JUnit5 - https://github.com/junit-team/junit5/issues/48')
|
||||
}
|
||||
|
||||
@Override
|
||||
String getIgnoreAnnotation() {
|
||||
return '@Disabled'
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean annotationLevelRules() {
|
||||
return true
|
||||
}
|
||||
|
||||
@Override
|
||||
String getRuleAnnotation(String annotationValue) {
|
||||
return ("@ExtendWith(${annotationValue}.class)")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.contract.verifier.config.framework;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Defines elements characteristic of JUnit5 test framework to be used during test class
|
||||
* construction.
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public class JUnit5Definition implements TestFrameworkDefinition {
|
||||
|
||||
@Override
|
||||
public String getClassModifier() {
|
||||
return "public ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodModifier() {
|
||||
return "public void ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLineSuffix() {
|
||||
return ";";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassExtension() {
|
||||
return ".java";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassNameSuffix() {
|
||||
return "Test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIgnoreClass() {
|
||||
return "org.junit.jupiter.api.Disabled";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getOrderAnnotationImports() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Not implemented yet in JUnit5 - https://github.com/junit-team/junit5/issues/48");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrderAnnotation() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Not implemented yet in JUnit5 - https://github.com/junit-team/junit5/issues/48");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIgnoreAnnotation() {
|
||||
return "@Disabled";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean annotationLevelRules() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRuleAnnotation(final String annotationValue) {
|
||||
return ("@ExtendWith(" + annotationValue + ".class)");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,85 +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.contract.verifier.config.framework
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
/**
|
||||
* Defines elements characteristic of JUnit test framework to be used during test class construction.
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@CompileStatic
|
||||
class JUnitDefinition implements TestFrameworkDefinition {
|
||||
|
||||
@Override
|
||||
String getClassModifier() {
|
||||
return 'public '
|
||||
}
|
||||
|
||||
@Override
|
||||
String getMethodModifier() {
|
||||
return 'public void '
|
||||
}
|
||||
|
||||
@Override
|
||||
String getLineSuffix() {
|
||||
return ';'
|
||||
}
|
||||
|
||||
@Override
|
||||
String getClassExtension() {
|
||||
return '.java'
|
||||
}
|
||||
|
||||
@Override
|
||||
String getClassNameSuffix() {
|
||||
return 'Test'
|
||||
}
|
||||
|
||||
@Override
|
||||
String getIgnoreClass() {
|
||||
return 'org.junit.Ignore'
|
||||
}
|
||||
|
||||
@Override
|
||||
List<String> getOrderAnnotationImports() {
|
||||
return ['org.junit.FixMethodOrder', 'org.junit.runners.MethodSorters']
|
||||
}
|
||||
|
||||
@Override
|
||||
String getOrderAnnotation() {
|
||||
return '@FixMethodOrder(MethodSorters.NAME_ASCENDING)'
|
||||
}
|
||||
|
||||
@Override
|
||||
String getIgnoreAnnotation() {
|
||||
return '@Ignore'
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean annotationLevelRules() {
|
||||
return false
|
||||
}
|
||||
|
||||
@Override
|
||||
String getRuleAnnotation(String annotationValue) {
|
||||
throw new UnsupportedOperationException('Not available in JUnit.')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.contract.verifier.config.framework;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Defines elements characteristic of JUnit test framework to be used during test class
|
||||
* construction.
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public class JUnitDefinition implements TestFrameworkDefinition {
|
||||
|
||||
@Override
|
||||
public String getClassModifier() {
|
||||
return "public ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodModifier() {
|
||||
return "public void ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLineSuffix() {
|
||||
return ";";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassExtension() {
|
||||
return ".java";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassNameSuffix() {
|
||||
return "Test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIgnoreClass() {
|
||||
return "org.junit.Ignore";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getOrderAnnotationImports() {
|
||||
return new ArrayList<String>(Arrays.asList("org.junit.FixMethodOrder",
|
||||
"org.junit.runners.MethodSorters"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrderAnnotation() {
|
||||
return "@FixMethodOrder(MethodSorters.NAME_ASCENDING)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIgnoreAnnotation() {
|
||||
return "@Ignore";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean annotationLevelRules() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRuleAnnotation(String annotationValue) {
|
||||
throw new UnsupportedOperationException("Not available in JUnit.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,72 +14,74 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.contract.verifier.config.framework
|
||||
package org.springframework.cloud.contract.verifier.config.framework;
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Defines elements characteristic of Spock test framework to be used during test class construction.
|
||||
* Defines elements characteristic of Spock test framework to be used during test class
|
||||
* construction.
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@CompileStatic
|
||||
class SpockDefinition implements TestFrameworkDefinition {
|
||||
public class SpockDefinition implements TestFrameworkDefinition {
|
||||
|
||||
@Override
|
||||
String getClassModifier() {
|
||||
return ''
|
||||
public String getClassModifier() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getMethodModifier() {
|
||||
return 'def '
|
||||
public String getMethodModifier() {
|
||||
return "def ";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getLineSuffix() {
|
||||
return ''
|
||||
public String getLineSuffix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getClassExtension() {
|
||||
return '.groovy'
|
||||
public String getClassExtension() {
|
||||
return ".groovy";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getClassNameSuffix() {
|
||||
return 'Spec'
|
||||
public String getClassNameSuffix() {
|
||||
return "Spec";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getIgnoreClass() {
|
||||
return 'spock.lang.Ignore'
|
||||
public String getIgnoreClass() {
|
||||
return "spock.lang.Ignore";
|
||||
}
|
||||
|
||||
@Override
|
||||
List<String> getOrderAnnotationImports() {
|
||||
return ['spock.lang.Stepwise']
|
||||
public List<String> getOrderAnnotationImports() {
|
||||
return new ArrayList<String>(Arrays.asList("spock.lang.Stepwise"));
|
||||
}
|
||||
|
||||
@Override
|
||||
String getOrderAnnotation() {
|
||||
return '@Stepwise'
|
||||
public String getOrderAnnotation() {
|
||||
return "@Stepwise";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getIgnoreAnnotation() {
|
||||
return '@Ignore'
|
||||
public String getIgnoreAnnotation() {
|
||||
return "@Ignore";
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean annotationLevelRules() {
|
||||
return false
|
||||
public boolean annotationLevelRules() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
String getRuleAnnotation(String annotationValue) {
|
||||
throw new UnsupportedOperationException('Not available in Spock.')
|
||||
public String getRuleAnnotation(String annotationValue) {
|
||||
throw new UnsupportedOperationException("Not available in Spock.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,78 +14,84 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.contract.verifier.config.framework
|
||||
package org.springframework.cloud.contract.verifier.config.framework;
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Defines elements characteristic of a given test framework to be used during test class construction.
|
||||
* Defines elements characteristic of a given test framework to be used during test class
|
||||
* construction.
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@CompileStatic
|
||||
interface TestFrameworkDefinition {
|
||||
public interface TestFrameworkDefinition {
|
||||
|
||||
/**
|
||||
* @return the class access level modifier. E.g. for Java tests that would mean {@code public}
|
||||
* */
|
||||
String getClassModifier()
|
||||
* @return the class access level modifier. E.g. for Java tests that would mean
|
||||
* {@code public}
|
||||
*/
|
||||
String getClassModifier();
|
||||
|
||||
/**
|
||||
* @return the method access level modifier along with the return type.
|
||||
* E.g. for Java tests that would mean {@code public void}
|
||||
* */
|
||||
String getMethodModifier()
|
||||
* @return the method access level modifier along with the return type. E.g. for Java
|
||||
* tests that would mean {@code public void}
|
||||
*/
|
||||
String getMethodModifier();
|
||||
|
||||
/**
|
||||
* @return the characters that should end each line. E.g. for Java tests that would mean {@code ;}
|
||||
* */
|
||||
String getLineSuffix()
|
||||
* @return the characters that should end each line. E.g. for Java tests that would
|
||||
* mean {@code ;}
|
||||
*/
|
||||
String getLineSuffix();
|
||||
|
||||
/**
|
||||
* @return the file extension. E.g. for Java tests that would be {@code .java}
|
||||
* */
|
||||
String getClassExtension()
|
||||
*/
|
||||
String getClassExtension();
|
||||
|
||||
/**
|
||||
* @return the test class name suffix. E.g. for JUnit tests that would be {@code Test}
|
||||
* */
|
||||
String getClassNameSuffix()
|
||||
*/
|
||||
String getClassNameSuffix();
|
||||
|
||||
/**
|
||||
* @return the qualified name of the class used to ignore or disable tests. E.g. for JUnit 4 tests that would
|
||||
* be {@code org.junit.Ignore}
|
||||
* */
|
||||
String getIgnoreClass()
|
||||
* @return the qualified name of the class used to ignore or disable tests. E.g. for
|
||||
* JUnit 4 tests that would be {@code org.junit.Ignore}
|
||||
*/
|
||||
String getIgnoreClass();
|
||||
|
||||
/**
|
||||
* @return the qualified names of the classes that are used for arranging tests into scenarios.
|
||||
* E.g. for JUnit 4 tests that would be {@code 'org.junit.FixMethodOrder'}, {@code 'org.junit.runners.MethodSorters'}
|
||||
* */
|
||||
List<String> getOrderAnnotationImports()
|
||||
* @return the qualified names of the classes that are used for arranging tests into
|
||||
* scenarios. E.g. for JUnit 4 tests that would be {@code 'org.junit.FixMethodOrder'},
|
||||
* {@code 'org.junit.runners.MethodSorters'}
|
||||
*/
|
||||
List<String> getOrderAnnotationImports();
|
||||
|
||||
/**
|
||||
* @return the annotation used for arranging tests into scenarios.
|
||||
* E.g. for JUnit test that would be {@code @FixMethodOrder(MethodSorters.NAME_ASCENDING)}
|
||||
* */
|
||||
String getOrderAnnotation()
|
||||
* @return the annotation used for arranging tests into scenarios. E.g. for JUnit test
|
||||
* that would be {@code @FixMethodOrder(MethodSorters.NAME_ASCENDING)}
|
||||
*/
|
||||
String getOrderAnnotation();
|
||||
|
||||
/**
|
||||
* @return the annotation used for ignoring or disabling tests. E.g. for JUnit tests that would mean {@code @Ignore}
|
||||
* */
|
||||
String getIgnoreAnnotation()
|
||||
* @return the annotation used for ignoring or disabling tests. E.g. for JUnit tests
|
||||
* that would mean {@code @Ignore}
|
||||
*/
|
||||
String getIgnoreAnnotation();
|
||||
|
||||
/**
|
||||
* @return a boolean indicating whether an annotation-type rule or extension is being used or not.
|
||||
* E.g. for JUnit 5 tests that would return {@code true}
|
||||
* */
|
||||
boolean annotationLevelRules()
|
||||
* @return a boolean indicating whether an annotation-type rule or extension is being
|
||||
* used or not. E.g. for JUnit 5 tests that would return {@code true}
|
||||
*/
|
||||
boolean annotationLevelRules();
|
||||
|
||||
/**
|
||||
* @return the test rule or extension annotation with the {@annotationValue} passed as an argument.
|
||||
* E.g. for JUnit 5 tests that could be {@code @ExtendWith(Example.class)}
|
||||
* */
|
||||
String getRuleAnnotation(String annotationValue)
|
||||
* @param annotationValue value of the annotation
|
||||
* @return the test rule or extension annotation with the {@annotationValue} passed as
|
||||
* an argument. E.g. for JUnit 5 tests that could be
|
||||
* {@code @ExtendWith(Example.class)}
|
||||
*/
|
||||
String getRuleAnnotation(String annotationValue);
|
||||
|
||||
}
|
||||
@@ -14,15 +14,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.contract.verifier.util
|
||||
package org.springframework.cloud.contract.verifier.util;
|
||||
|
||||
import org.skyscreamer.jsonassert.JSONAssert
|
||||
import org.json.JSONException;
|
||||
import org.skyscreamer.jsonassert.JSONAssert;
|
||||
|
||||
class AssertionUtil {
|
||||
public final class AssertionUtil {
|
||||
|
||||
private static boolean NON_STRICT = false
|
||||
private static boolean NON_STRICT = false;
|
||||
|
||||
static void assertThatJsonsAreEqual(String expected, String actual) {
|
||||
JSONAssert.assertEquals(expected, actual, NON_STRICT)
|
||||
private AssertionUtil() {
|
||||
throw new IllegalStateException("You shouldn't instantiate the utility class");
|
||||
}
|
||||
|
||||
public static void assertThatJsonsAreEqual(String expected, String actual) {
|
||||
try {
|
||||
JSONAssert.assertEquals(expected, actual, NON_STRICT);
|
||||
}
|
||||
catch (JSONException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,4 +40,5 @@
|
||||
<suppress files=".*StubRunnerJUnit5ExtensionExceptionThrowingTests.*" checks="RegexpSinglelineJavaCheck"/>
|
||||
<suppress files=".*StubRunnerSliceTests.*" checks="LineLengthCheck"/>
|
||||
<suppress files=".*WiremockServerApplicationTests.*" checks="LineLengthCheck"/>
|
||||
<suppress files=".*ContractVerifierConfigProperties.*" checks="JavadocStyle"/>
|
||||
</suppressions>
|
||||
|
||||
Reference in New Issue
Block a user