Fixed the way contracts are packaged and tests are generated for plugins
the biggest problem was related with the scenario in which a jar with shared contracts is downloaded with this change the output JAR structure is proper fixes #156
This commit is contained in:
@@ -90,10 +90,10 @@ files root as described next.
|
||||
WireMock can read response bodies from files on the classpath or file
|
||||
system. In that case you will see in the JSON DSL that the response
|
||||
has a "bodyFileName" instead of a (literal) "body". The files are
|
||||
resolved relative to a root directory `src/test/resources/__files` by
|
||||
resolved relative to a root directory `src/test/resources/\__files` by
|
||||
default. To customize this location you can set the `files` attribute
|
||||
in the `@AutoConfigureWireMock` annotation to the location of the
|
||||
parent directory (i.e. the place where `__files` is a
|
||||
parent directory (i.e. the place `__files` is a
|
||||
subdirectory). You can use Spring resource notation to refer to
|
||||
`file:...` or `classpath:...` locations (but generic URLs are not
|
||||
supported). A list of values can be given and WireMock will resolve
|
||||
|
||||
@@ -53,10 +53,19 @@ public class ContractDownloader {
|
||||
|
||||
public ContractVerifierConfigProperties updatePropertiesWithInclusion(File contractsDirectory,
|
||||
ContractVerifierConfigProperties config) {
|
||||
String pattern = StringUtils.hasText(this.contractsPath) ? patternFromProperty(contractsDirectory) :
|
||||
groupArtifactToPattern(contractsDirectory);
|
||||
String pattern;
|
||||
String includedAntPattern;
|
||||
if (StringUtils.hasText(this.contractsPath)) {
|
||||
pattern = patternFromProperty(contractsDirectory);
|
||||
includedAntPattern = wrapWithAntPattern(contractsPath());
|
||||
} else {
|
||||
pattern = groupArtifactToPattern(contractsDirectory);
|
||||
includedAntPattern = wrapWithAntPattern(slashSeparatedGroupId() + "/" + this.projectArtifactId);
|
||||
}
|
||||
log.info("Pattern to pick contracts equals [" + pattern + "]");
|
||||
log.info("Ant Pattern to pick files equals [" + includedAntPattern + "]");
|
||||
config.setIncludedContracts(pattern);
|
||||
config.setIncludedRootFolderAntPattern(includedAntPattern);
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -66,7 +75,17 @@ public class ContractDownloader {
|
||||
}
|
||||
|
||||
private String contractsPath() {
|
||||
return this.contractsPath.startsWith(File.separator) ? this.contractsPath : File.separator + this.contractsPath;
|
||||
return surroundWithSeparator(this.contractsPath);
|
||||
}
|
||||
|
||||
private String surroundWithSeparator(String string) {
|
||||
String path = string.startsWith(File.separator) ? string : File.separator + string;
|
||||
return path.endsWith(File.separator) ? path : path + File.separator;
|
||||
}
|
||||
|
||||
private String wrapWithAntPattern(String path) {
|
||||
String changedPath = path.replace(File.separator, "/");
|
||||
return "**" + surroundWithSeparator(changedPath) + "**/";
|
||||
}
|
||||
|
||||
private File unpackAndDownloadContracts() {
|
||||
@@ -83,10 +102,14 @@ public class ContractDownloader {
|
||||
return ("^" +
|
||||
contractsDirectory.getAbsolutePath() +
|
||||
File.separator +
|
||||
this.projectGroupId.replace(".", File.separator) +
|
||||
slashSeparatedGroupId() +
|
||||
File.separator +
|
||||
this.projectArtifactId
|
||||
+ File.separator +
|
||||
".*$").replace("\\", "\\\\");
|
||||
}
|
||||
|
||||
private String slashSeparatedGroupId() {
|
||||
return this.projectGroupId.replace(".", File.separator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class ContractDownloaderSpec extends Specification {
|
||||
then:
|
||||
properties.includedContracts.startsWith('^')
|
||||
properties.includedContracts.endsWith('$')
|
||||
properties.includedContracts.contains(fileSeparated('/some/path/to/somewhere/a/b/c/d.*'))
|
||||
properties.includedContracts.contains(fileSeparated('/some/path/to/somewhere/a/b/c/d/.*'))
|
||||
}
|
||||
|
||||
def 'should set inclusion pattern on config when path pattern was explicitly provided without a separator at the beginning'() {
|
||||
@@ -41,7 +41,7 @@ class ContractDownloaderSpec extends Specification {
|
||||
then:
|
||||
properties.includedContracts.startsWith('^')
|
||||
properties.includedContracts.endsWith('$')
|
||||
properties.includedContracts.contains(fileSeparated('/some/path/to/somewhere/a/b/c/d.*'))
|
||||
properties.includedContracts.contains(fileSeparated('/some/path/to/somewhere/a/b/c/d/.*'))
|
||||
}
|
||||
|
||||
private static String fileSeparated(String string) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.springframework.cloud.contract.verifier.plugin
|
||||
|
||||
import groovy.transform.PackageScope
|
||||
import org.gradle.api.internal.ConventionTask
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
|
||||
/**
|
||||
* Task that copies the contracts in order for the jar task to
|
||||
* generate the jar. It takes into consideration the inclusion
|
||||
* patterns when working with repo with shared contracts.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.2
|
||||
*/
|
||||
@PackageScope
|
||||
class ContractsCopyTask extends ConventionTask {
|
||||
ContractVerifierExtension extension
|
||||
GradleContractsDownloader downloader
|
||||
|
||||
@TaskAction
|
||||
void copy() {
|
||||
ContractVerifierConfigProperties props = ExtensionToProperties.fromExtension(getExtension())
|
||||
File file = getDownloader().downloadAndUnpackContractsIfRequired(getExtension(), props)
|
||||
String antPattern = "${props.includedRootFolderAntPattern}*.*"
|
||||
ext.contractVerifierConfigProperties = props
|
||||
File outputContractsFolder = getExtension().stubsOutputDir != null ?
|
||||
project.file("${getExtension().stubsOutputDir}/contracts") :
|
||||
project.file("${project.buildDir}/stubs/contracts")
|
||||
ext.contractsDslDir = outputContractsFolder
|
||||
project.logger.info("Downloading and unpacking files from [$file] to [$outputContractsFolder]. The inclusion ant pattern is [$antPattern]")
|
||||
project.copy {
|
||||
from(file)
|
||||
include(antPattern)
|
||||
into(outputContractsFolder)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,14 +17,16 @@
|
||||
package org.springframework.cloud.contract.verifier.plugin
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.internal.ConventionTask
|
||||
import org.gradle.api.tasks.InputDirectory
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.springframework.cloud.contract.spec.ContractVerifierException
|
||||
import org.springframework.cloud.contract.verifier.TestGenerator
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
|
||||
import static org.springframework.cloud.contract.verifier.plugin.SpringCloudContractVerifierGradlePlugin.COPY_CONTRACTS_TASK_NAME
|
||||
|
||||
/**
|
||||
* Task used to generate server side tests
|
||||
*
|
||||
@@ -32,17 +34,22 @@ import org.springframework.cloud.contract.verifier.config.ContractVerifierConfig
|
||||
*/
|
||||
class GenerateServerTestsTask extends ConventionTask {
|
||||
|
||||
@InputDirectory
|
||||
File contractsDslDir
|
||||
@OutputDirectory
|
||||
File generatedTestSourcesDir
|
||||
|
||||
//TODO: How to deal with @Input*, @Output* and that domain object?
|
||||
ContractVerifierExtension configProperties
|
||||
GradleContractsDownloader downloader
|
||||
|
||||
@TaskAction
|
||||
void generate() {
|
||||
Task copyContractsTask = project.getTasksByName(COPY_CONTRACTS_TASK_NAME, false).first()
|
||||
ContractVerifierConfigProperties props = props(copyContractsTask)
|
||||
File contractsDslDir = contractsDslDir(copyContractsTask, props)
|
||||
|
||||
project.logger.info("Spring Cloud Contract Verifier Plugin: Invoking test sources generation")
|
||||
project.logger.info("Contracts are unpacked to [${contractsDslDir}]")
|
||||
project.logger.info("Included contracts are [${props.includedContracts}]")
|
||||
|
||||
project.sourceSets.test.groovy {
|
||||
project.logger.info("Registering ${getConfigProperties().generatedTestSourcesDir} as test source directory")
|
||||
@@ -50,9 +57,8 @@ class GenerateServerTestsTask extends ConventionTask {
|
||||
}
|
||||
|
||||
try {
|
||||
//TODO: What with that? How to pass?
|
||||
ContractVerifierConfigProperties props = ExtensionToProperties.fromExtension(getConfigProperties())
|
||||
props.contractsDslDir = getContractsDslDir()
|
||||
props = props ?: ExtensionToProperties.fromExtension(getConfigProperties())
|
||||
props.contractsDslDir = contractsDslDir
|
||||
TestGenerator generator = new TestGenerator(props)
|
||||
int generatedClasses = generator.generate()
|
||||
project.logger.info("Generated {} test classes", generatedClasses)
|
||||
@@ -60,4 +66,24 @@ class GenerateServerTestsTask extends ConventionTask {
|
||||
throw new GradleException("Spring Cloud Contract Verifier Plugin exception: ${e.message}", e)
|
||||
}
|
||||
}
|
||||
|
||||
private ContractVerifierConfigProperties props(Task task) {
|
||||
try {
|
||||
return task.ext.contractVerifierConfigProperties
|
||||
} catch (Exception e) {
|
||||
project.logger.error("Couldn't retrieve the configuration property set by the copy contracts task", e)
|
||||
ContractVerifierConfigProperties props = ExtensionToProperties.fromExtension(getConfigProperties())
|
||||
getDownloader().downloadAndUnpackContractsIfRequired(getConfigProperties(), props)
|
||||
return props
|
||||
}
|
||||
}
|
||||
|
||||
private File contractsDslDir(Task task, ContractVerifierConfigProperties props) {
|
||||
try {
|
||||
return task.ext.contractsDslDir
|
||||
} catch (Exception e) {
|
||||
project.logger.error("Couldn't retrieve the contractdsl property set by the copy contracts task", e)
|
||||
return props.contractsDslDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,16 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.plugin
|
||||
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.internal.ConventionTask
|
||||
import org.gradle.api.tasks.InputDirectory
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
import org.springframework.cloud.contract.verifier.wiremock.DslToWireMockClientConverter
|
||||
import org.springframework.cloud.contract.verifier.wiremock.RecursiveFilesConverter
|
||||
|
||||
import static org.springframework.cloud.contract.verifier.plugin.SpringCloudContractVerifierGradlePlugin.COPY_CONTRACTS_TASK_NAME
|
||||
|
||||
//TODO: Implement as an incremental task: https://gradle.org/docs/current/userguide/custom_tasks.html#incremental_tasks ?
|
||||
/**
|
||||
* Generates WireMock stubs from the contracts
|
||||
@@ -33,24 +36,46 @@ class GenerateWireMockClientStubsFromDslTask extends ConventionTask {
|
||||
|
||||
private static final String DEFAULT_MAPPINGS_FOLDER = 'mappings'
|
||||
|
||||
@InputDirectory
|
||||
File contractsDslDir
|
||||
@OutputDirectory
|
||||
File stubsOutputDir
|
||||
|
||||
ContractVerifierExtension configProperties
|
||||
GradleContractsDownloader downloader
|
||||
|
||||
@TaskAction
|
||||
void generate() {
|
||||
Task copyContractsTask = project.getTasksByName(COPY_CONTRACTS_TASK_NAME, false).first()
|
||||
ContractVerifierConfigProperties props = props(copyContractsTask)
|
||||
File contractsDslDir = contractsDslDir(copyContractsTask, props)
|
||||
logger.info("Spring Cloud Contract Verifier Plugin: Invoking DSL to WireMock client stubs conversion")
|
||||
logger.debug("From '${getContractsDslDir()}' to '${getStubsOutputDir()}'")
|
||||
ContractVerifierConfigProperties props = ExtensionToProperties.fromExtension(getConfigProperties())
|
||||
props.contractsDslDir = getContractsDslDir()
|
||||
File outMappingsDir = props.stubsOutputDir != null ? new File(props.stubsOutputDir, DEFAULT_MAPPINGS_FOLDER)
|
||||
props.contractsDslDir = contractsDslDir
|
||||
props.includedContracts = ".*"
|
||||
File outMappingsDir = getStubsOutputDir() != null ? new File(getStubsOutputDir(), DEFAULT_MAPPINGS_FOLDER)
|
||||
: new File(project.buildDir, "stubs/$DEFAULT_MAPPINGS_FOLDER")
|
||||
logger.info("Contracts dir is [${contractsDslDir}] output stubs dir is [${outMappingsDir}]")
|
||||
RecursiveFilesConverter converter = new RecursiveFilesConverter(
|
||||
new DslToWireMockClientConverter(),
|
||||
props, outMappingsDir)
|
||||
converter.processFiles()
|
||||
}
|
||||
|
||||
private ContractVerifierConfigProperties props(Task task) {
|
||||
try {
|
||||
return task.ext.contractVerifierConfigProperties
|
||||
} catch (Exception e) {
|
||||
project.logger.error("Couldn't retrieve the configuration property set by the copy contracts task", e)
|
||||
ContractVerifierConfigProperties props = ExtensionToProperties.fromExtension(getConfigProperties())
|
||||
getDownloader().downloadAndUnpackContractsIfRequired(getConfigProperties(), props)
|
||||
return props
|
||||
}
|
||||
}
|
||||
|
||||
private File contractsDslDir(Task task, ContractVerifierConfigProperties props) {
|
||||
try {
|
||||
return task.ext.contractsDslDir
|
||||
} catch (Exception e) {
|
||||
project.logger.error("Couldn't retrieve the contractdsl property set by the copy contracts task", e)
|
||||
return props.contractsDslDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.cloud.contract.stubrunner.AetherStubDownloader
|
||||
import org.springframework.cloud.contract.stubrunner.ContractDownloader
|
||||
import org.springframework.cloud.contract.stubrunner.StubConfiguration
|
||||
import org.springframework.cloud.contract.stubrunner.StubRunnerOptionsBuilder
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
import org.springframework.util.StringUtils
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
@@ -27,18 +28,21 @@ class GradleContractsDownloader {
|
||||
this.log = log
|
||||
}
|
||||
|
||||
File downloadAndUnpackContractsIfRequired(ContractVerifierExtension extension) {
|
||||
File downloadAndUnpackContractsIfRequired(ContractVerifierExtension extension,
|
||||
ContractVerifierConfigProperties config) {
|
||||
File defaultContractsDir = extension.contractsDslDir
|
||||
this.log.info("Project has group id [${this.project.group}], artifact id [${this.project.name}]")
|
||||
// download contracts, unzip them and pass as output directory
|
||||
if (shouldDownloadContracts(extension)) {
|
||||
this.log.info("For project [${this.project.name}] Download dependency is provided - will download contract jars")
|
||||
StubConfiguration configuration = stubConfiguration(extension.contractDependency)
|
||||
if (downloadedContract.get(configuration)) {
|
||||
File cachedFolder = downloadedContract.get(configuration)
|
||||
if (cachedFolder) {
|
||||
this.log.info("For project [${this.project.name}] Returning the cached location of the contracts")
|
||||
return downloadedContract.get(configuration)
|
||||
contractDownloader(extension, configuration).updatePropertiesWithInclusion(cachedFolder, config)
|
||||
return cachedFolder
|
||||
}
|
||||
File downloadedContracts = contractDownloader(extension, configuration).unpackedDownloadedContracts(
|
||||
ExtensionToProperties.fromExtension(extension))
|
||||
File downloadedContracts = contractDownloader(extension, configuration).unpackedDownloadedContracts(config)
|
||||
downloadedContract.put(configuration, downloadedContracts)
|
||||
return downloadedContracts
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.plugin
|
||||
|
||||
import groovy.transform.PackageScope
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.plugins.GroovyPlugin
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
/**
|
||||
* Gradle plugin for Spring Cloud Contract Verifier that from the DSL contract can
|
||||
@@ -48,7 +48,7 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
|
||||
|
||||
private static final String GENERATE_SERVER_TESTS_TASK_NAME = 'generateContractTests'
|
||||
private static final String DSL_TO_WIREMOCK_CLIENT_TASK_NAME = 'generateWireMockClientStubs'
|
||||
private static final String COPY_CONTRACTS_TASK_NAME = 'copyContracts'
|
||||
@PackageScope static final String COPY_CONTRACTS_TASK_NAME = 'copyContracts'
|
||||
private static final String VERIFIER_STUBS_JAR_TASK_NAME = 'verifierStubsJar'
|
||||
|
||||
private static final Class IDEA_PLUGIN_CLASS = org.gradle.plugins.ide.idea.IdeaPlugin
|
||||
@@ -65,11 +65,11 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
|
||||
GradleContractsDownloader downloader = new GradleContractsDownloader(this.project, this.project.logger)
|
||||
project.check.dependsOn(GENERATE_SERVER_TESTS_TASK_NAME)
|
||||
setConfigurationDefaults(extension)
|
||||
createGenerateTestsTask(downloader, extension)
|
||||
createAndConfigureGenerateWireMockClientStubsFromDslTask(downloader, extension)
|
||||
Task stubsJar = createAndConfigureStubsJarTasks(extension)
|
||||
createAndConfigureCopyContractsTask(stubsJar, downloader, extension)
|
||||
Task copyContracts = createAndConfigureCopyContractsTask(stubsJar, downloader, extension)
|
||||
createAndConfigureMavenPublishPlugin(stubsJar)
|
||||
createGenerateTestsTask(extension, copyContracts)
|
||||
createAndConfigureGenerateWireMockClientStubsFromDslTask(extension, copyContracts)
|
||||
addProjectDependencies(project)
|
||||
addIdeaTestSources(project, extension)
|
||||
}
|
||||
@@ -107,28 +107,29 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
|
||||
return project.file("${project.rootDir}/src/test/resources/contracts")
|
||||
}
|
||||
|
||||
private void createGenerateTestsTask(GradleContractsDownloader downloader,
|
||||
ContractVerifierExtension extension) {
|
||||
private void createGenerateTestsTask(ContractVerifierExtension extension, Task copyContracts) {
|
||||
Task task = project.tasks.create(GENERATE_SERVER_TESTS_TASK_NAME, GenerateServerTestsTask)
|
||||
task.description = "Generate server tests from the contracts"
|
||||
task.group = GROUP_NAME
|
||||
task.conventionMapping.with {
|
||||
contractsDslDir = { downloader.downloadAndUnpackContractsIfRequired(extension) }
|
||||
downloader = { gradleContractsDownloader }
|
||||
generatedTestSourcesDir = { extension.generatedTestSourcesDir }
|
||||
configProperties = { extension }
|
||||
}
|
||||
task.dependsOn copyContracts
|
||||
}
|
||||
|
||||
private void createAndConfigureGenerateWireMockClientStubsFromDslTask(
|
||||
GradleContractsDownloader downloader, ContractVerifierExtension extension) {
|
||||
private void createAndConfigureGenerateWireMockClientStubsFromDslTask(ContractVerifierExtension extension,
|
||||
Task copyContracts) {
|
||||
Task task = project.tasks.create(DSL_TO_WIREMOCK_CLIENT_TASK_NAME, GenerateWireMockClientStubsFromDslTask)
|
||||
task.description = "Generate WireMock client stubs from the contracts"
|
||||
task.group = GROUP_NAME
|
||||
task.conventionMapping.with {
|
||||
contractsDslDir = { downloader.downloadAndUnpackContractsIfRequired(extension) }
|
||||
downloader = { gradleContractsDownloader }
|
||||
stubsOutputDir = { extension.stubsOutputDir }
|
||||
configProperties = { extension }
|
||||
}
|
||||
task.dependsOn copyContracts
|
||||
}
|
||||
|
||||
private Task createAndConfigureStubsJarTasks(ContractVerifierExtension extension) {
|
||||
@@ -161,15 +162,15 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
|
||||
}
|
||||
|
||||
private Task createAndConfigureCopyContractsTask(Task stubs,
|
||||
GradleContractsDownloader downloader,
|
||||
ContractVerifierExtension extension) {
|
||||
Task task = project.tasks.create(type: Copy, name: COPY_CONTRACTS_TASK_NAME) {
|
||||
from { downloader.downloadAndUnpackContractsIfRequired(extension) }
|
||||
into { extension.stubsOutputDir != null ?
|
||||
project.file("${extension.stubsOutputDir}/contracts") : project.file("${project.buildDir}/stubs/contracts") }
|
||||
}
|
||||
GradleContractsDownloader gradleContractsDownloader,
|
||||
ContractVerifierExtension contractVerifierExtension) {
|
||||
Task task = project.tasks.create(COPY_CONTRACTS_TASK_NAME, ContractsCopyTask)
|
||||
task.description = "Copies contracts to the output folder"
|
||||
task.group = GROUP_NAME
|
||||
task.conventionMapping.with {
|
||||
downloader = { gradleContractsDownloader }
|
||||
extension = { contractVerifierExtension }
|
||||
}
|
||||
stubs.dependsOn task
|
||||
return task
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
group = 'org.springframework.cloud.testprojects'
|
||||
allprojects {
|
||||
group = 'com.example.jersey'
|
||||
}
|
||||
|
||||
ext {
|
||||
restAssuredVersion = '2.5.0'
|
||||
|
||||
Binary file not shown.
@@ -53,6 +53,7 @@ class CopyContracts {
|
||||
+ "[" + this.config.getIncludedContracts() + "] pattern will end up in "
|
||||
+ "the final JAR with stubs.");
|
||||
Resource resource = new Resource();
|
||||
resource.addInclude(this.config.getIncludedRootFolderAntPattern() + "*.*");
|
||||
resource.setDirectory(contractsDirectory.getAbsolutePath());
|
||||
MavenResourcesExecution execution = new MavenResourcesExecution();
|
||||
execution.setResources(Collections.singletonList(resource));
|
||||
@@ -70,6 +71,6 @@ class CopyContracts {
|
||||
catch (MavenFilteringException e) {
|
||||
throw new MojoExecutionException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ public class PluginUnitTest {
|
||||
this.maven.executeMojo(basedir, "convert", newParameter("contractsRepositoryUrl", "file://" + PluginUnitTest.class.getClassLoader().getResource("m2repo/repository").getFile().replace("/", File.separator)));
|
||||
assertFilesPresent(basedir, "target/stubs/mappings/com/example/server/client1/contracts/shouldMarkClientAsFraud.json");
|
||||
assertFilesNotPresent(basedir, "target/stubs/mappings/com/foo/bar/baz/shouldBeIgnoredByPlugin.json");
|
||||
assertFilesNotPresent(basedir, "target/stubs/contracts/com/foo/bar/baz/shouldBeIgnoredByPlugin.groovy");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,6 +163,7 @@ public class PluginUnitTest {
|
||||
this.maven.executeMojo(basedir, "generateTests", newParameter("contractsRepositoryUrl", "file://" + PluginUnitTest.class.getClassLoader().getResource("m2repo/repository").getFile().replace("/", File.separator)));
|
||||
assertFilesPresent(basedir, "target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/com/example/server/client1/ContractsTest.java");
|
||||
assertFilesNotPresent(basedir, "target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/com/foo/bar/BazTest.java");
|
||||
assertFilesNotPresent(basedir, "target/stubs/contracts/com/foo/bar/baz/shouldBeIgnoredByPlugin.groovy");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -109,6 +109,12 @@ class ContractVerifierConfigProperties {
|
||||
*/
|
||||
String includedContracts = ".*"
|
||||
|
||||
/**
|
||||
* A ant pattern to match files. Relates to contracts, stubs etc. You can append
|
||||
* any kind of files you wish e.g {@code $includedRootFolderAntPattern/*.groovy}
|
||||
*/
|
||||
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}
|
||||
|
||||
Reference in New Issue
Block a user