Bumped RestAssured to 6.0.0
This commit is contained in:
@@ -79,7 +79,6 @@
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>${rest-assured.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -100,12 +100,6 @@ public class ContractVerifierExtension implements Serializable {
|
||||
*/
|
||||
private final DirectoryProperty contractsDslDir;
|
||||
|
||||
/**
|
||||
* Test source directory where tests generated from Groovy DSL should be placed
|
||||
*/
|
||||
@Deprecated
|
||||
private final DirectoryProperty generatedTestSourcesDir;
|
||||
|
||||
/**
|
||||
* Java test source directory where tests generated from Contract DSL should be placed
|
||||
*/
|
||||
@@ -220,14 +214,6 @@ public class ContractVerifierExtension implements Serializable {
|
||||
*/
|
||||
private final MapProperty<String, String> contractsProperties;
|
||||
|
||||
/**
|
||||
* Is set to true will not provide the default publication task
|
||||
* @deprecated - with 3.0.0, the user should include stubs with their own
|
||||
* publication(s)
|
||||
*/
|
||||
@Deprecated
|
||||
private final Property<Boolean> disableStubPublication;
|
||||
|
||||
/**
|
||||
* Source set where the contracts are stored. If not provided will assume
|
||||
* {@code test}.
|
||||
@@ -248,7 +234,6 @@ public class ContractVerifierExtension implements Serializable {
|
||||
this.staticImports = objects.listProperty(String.class).convention(new ArrayList<>());
|
||||
this.contractsDslDir = objects.directoryProperty()
|
||||
.convention(layout.getProjectDirectory().dir("src/contractTest/resources/contracts"));
|
||||
this.generatedTestSourcesDir = objects.directoryProperty();
|
||||
this.generatedTestJavaSourcesDir = objects.directoryProperty()
|
||||
.convention(layout.getBuildDirectory().dir("generated-test-sources/contractTest/java"));
|
||||
this.generatedTestGroovySourcesDir = objects.directoryProperty()
|
||||
@@ -272,7 +257,6 @@ public class ContractVerifierExtension implements Serializable {
|
||||
this.deleteStubsAfterTest = objects.property(Boolean.class).convention(true);
|
||||
this.convertToYaml = objects.property(Boolean.class).convention(false);
|
||||
this.contractsProperties = objects.mapProperty(String.class, String.class).convention(new HashMap<>());
|
||||
this.disableStubPublication = objects.property(Boolean.class).convention(true);
|
||||
this.sourceSet = objects.property(String.class);
|
||||
}
|
||||
|
||||
@@ -380,16 +364,6 @@ public class ContractVerifierExtension implements Serializable {
|
||||
this.contractsDslDir.set(contractsDslDir);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public DirectoryProperty getGeneratedTestSourcesDir() {
|
||||
return generatedTestSourcesDir;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setGeneratedTestSourcesDir(File generatedTestSourcesDir) {
|
||||
this.generatedTestSourcesDir.set(generatedTestSourcesDir);
|
||||
}
|
||||
|
||||
public DirectoryProperty getGeneratedTestJavaSourcesDir() {
|
||||
return generatedTestJavaSourcesDir;
|
||||
}
|
||||
@@ -550,16 +524,6 @@ public class ContractVerifierExtension implements Serializable {
|
||||
this.contractsProperties.set(contractsProperties);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Property<Boolean> getDisableStubPublication() {
|
||||
return disableStubPublication;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDisableStubPublication(boolean disableStubPublication) {
|
||||
this.disableStubPublication.set(disableStubPublication);
|
||||
}
|
||||
|
||||
public Property<String> getSourceSet() {
|
||||
return sourceSet;
|
||||
}
|
||||
|
||||
@@ -110,16 +110,18 @@ public class SpringCloudContractVerifierGradlePlugin implements Plugin<Project>
|
||||
project.getDependencies().add(CONTRACT_TEST_GENERATOR_RUNTIME_CLASSPATH_CONFIGURATION_NAME, "org.springframework.cloud:spring-cloud-contract-converters:" + SPRING_CLOUD_VERSION);
|
||||
|
||||
project.afterEvaluate(inner -> {
|
||||
DirectoryProperty generatedTestSourcesDir = extension.getGeneratedTestSourcesDir();
|
||||
if (generatedTestSourcesDir.isPresent()) {
|
||||
if (extension.getTestFramework().get() == TestFramework.SPOCK) {
|
||||
if (extension.getTestFramework().get() == TestFramework.SPOCK) {
|
||||
DirectoryProperty generatedTestSourcesDir = extension.getGeneratedTestGroovySourcesDir();
|
||||
if (generatedTestSourcesDir.isPresent()) {
|
||||
project.getPlugins().withType(GroovyPlugin.class, groovyPlugin -> {
|
||||
GroovySourceSet groovy = ((HasConvention) contractTestSourceSet).getConvention()
|
||||
.getPlugin(GroovySourceSet.class);
|
||||
groovy.getGroovy().srcDirs(generatedTestSourcesDir);
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
DirectoryProperty generatedTestSourcesDir = extension.getGeneratedTestJavaSourcesDir();
|
||||
if (generatedTestSourcesDir.isPresent()) {
|
||||
contractTestSourceSet.getJava().srcDirs(generatedTestSourcesDir);
|
||||
}
|
||||
}
|
||||
@@ -222,11 +224,12 @@ public class SpringCloudContractVerifierGradlePlugin implements Plugin<Project>
|
||||
Property<Directory> correctSourceSetDir;
|
||||
if (testFramework == TestFramework.SPOCK) {
|
||||
correctSourceSetDir = extension.getGeneratedTestGroovySourcesDir();
|
||||
return extension.getGeneratedTestGroovySourcesDir().orElse(correctSourceSetDir);
|
||||
}
|
||||
else {
|
||||
correctSourceSetDir = extension.getGeneratedTestJavaSourcesDir();
|
||||
return extension.getGeneratedTestJavaSourcesDir().orElse(correctSourceSetDir);
|
||||
}
|
||||
return extension.getGeneratedTestSourcesDir().orElse(correctSourceSetDir);
|
||||
}));
|
||||
generateServerTestsTask.getGeneratedTestResourcesDir().convention(extension.getGeneratedTestResourcesDir());
|
||||
|
||||
@@ -320,58 +323,6 @@ public class SpringCloudContractVerifierGradlePlugin implements Plugin<Project>
|
||||
stubsJar.dependsOn(generateClientStubs);
|
||||
});
|
||||
project.artifacts(artifactHandler -> artifactHandler.add("archives", verifierStubsJar));
|
||||
createAndConfigureMavenPublishPlugin(verifierStubsJar, extension);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void createAndConfigureMavenPublishPlugin(TaskProvider<Jar> stubsTask,
|
||||
ContractVerifierExtension extension) {
|
||||
if (!classIsOnClasspath("org.gradle.api.publish.maven.plugins.MavenPublishPlugin")) {
|
||||
project.getLogger().debug("Maven Publish Plugin is not present - won't add default publication");
|
||||
return;
|
||||
}
|
||||
// This must be called within afterEvaluate due to getting data from extension,
|
||||
// which must be initialised first:
|
||||
project.afterEvaluate(inner -> {
|
||||
project.getLogger().debug("Spring Cloud Contract Verifier Plugin: Generating default publication");
|
||||
if (extension.getDisableStubPublication().get()) {
|
||||
project.getLogger().info("You've switched off the stub publication - won't add default publication");
|
||||
return;
|
||||
}
|
||||
project.getPlugins().withType(MavenPublishPlugin.class, publishingPlugin -> {
|
||||
PublishingExtension publishingExtension = project.getExtensions().findByType(PublishingExtension.class);
|
||||
if (hasStubsPublication(publishingExtension)) {
|
||||
project.getLogger().info(
|
||||
"Spring Cloud Contract Verifier Plugin: Stubs publication was present - won't create a new one. Remember about passing stubs as artifact");
|
||||
}
|
||||
else {
|
||||
project.getLogger().debug(
|
||||
"Spring Cloud Contract Verifier Plugin: Stubs publication is not present - will create one");
|
||||
setPublications(publishingExtension, stubsTask);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void setPublications(PublishingExtension publishingExtension, TaskProvider<Jar> stubsTask) {
|
||||
project.getLogger().warn("Spring Cloud Contract Verifier Plugin: Creating stubs publication is deprecated");
|
||||
publishingExtension.publications(publicationsContainer -> {
|
||||
publicationsContainer.create("stubs", MavenPublication.class, stubsPublication -> {
|
||||
stubsPublication.setArtifactId(project.getName());
|
||||
stubsPublication.artifact(stubsTask.get());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private boolean hasStubsPublication(PublishingExtension publishingExtension) {
|
||||
try {
|
||||
return publishingExtension.getPublications().getByName("stubs") != null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private TaskProvider<ContractsCopyTask> createAndConfigureCopyContractsTask(ContractVerifierExtension extension) {
|
||||
@@ -438,18 +389,6 @@ public class SpringCloudContractVerifierGradlePlugin implements Plugin<Project>
|
||||
return task;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private boolean classIsOnClasspath(String className) {
|
||||
try {
|
||||
Class.forName(className);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
project.getLogger().debug("Maven Publish Plugin is not available");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Provider<String> buildRootPath(String path) {
|
||||
return project.provider(() -> {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -134,28 +134,6 @@ class ContractVerifierTest {
|
||||
assert project.tasks.compileContractTestGroovy.getDependsOn().contains(project.tasks.named("generateContractTests"))
|
||||
}
|
||||
|
||||
@Test
|
||||
void "should configure generatedTestSourcesDir with the appropriate directories"() {
|
||||
when:
|
||||
ContractVerifierExtension extension = project.extensions.findByType(ContractVerifierExtension)
|
||||
GenerateServerTestsTask generateServerTestsTask = project.tasks.getByName("generateContractTests") as GenerateServerTestsTask
|
||||
|
||||
then:
|
||||
assert generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestJavaSourcesDir.get().asFile
|
||||
|
||||
and:
|
||||
extension.testFramework.set(TestFramework.SPOCK)
|
||||
|
||||
then:
|
||||
assert generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestGroovySourcesDir.get().asFile
|
||||
|
||||
and:
|
||||
extension.generatedTestSourcesDir.set(project.file("src/random"))
|
||||
|
||||
then:
|
||||
assert generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestSourcesDir.get().asFile
|
||||
}
|
||||
|
||||
@Test
|
||||
void "should create generateClientStubs task"() {
|
||||
expect:
|
||||
@@ -192,32 +170,6 @@ class ContractVerifierTest {
|
||||
assert project.tasks.verifierStubsJar.getDependsOn().contains(project.tasks.named("generateClientStubs"))
|
||||
}
|
||||
|
||||
/**
|
||||
* project.evaluate() is used here in order to trigger the evaluation lifecycle of a project.
|
||||
* This method is currently exposed via the internal API and is subject to change, however, Gradle
|
||||
* does not yet expose a way to test this portion of the lifecycle.
|
||||
*
|
||||
* In the next version, this test will be completely removed as publication will be fully a user
|
||||
* responsibility.
|
||||
*/
|
||||
@Deprecated
|
||||
@Test
|
||||
void "should configure maven-publish plugin, if enabled"() {
|
||||
given:
|
||||
project.plugins.apply(MavenPublishPlugin)
|
||||
project.plugins.apply(SpringCloudContractVerifierGradlePlugin)
|
||||
ContractVerifierExtension extension = project.getExtensions().findByType(ContractVerifierExtension)
|
||||
extension.with {
|
||||
disableStubPublication = false
|
||||
}
|
||||
project.evaluate() // Currently internal method to trigger afterEvaluate blocks.
|
||||
|
||||
expect:
|
||||
PublicationContainer publications = project.extensions.getByType(PublishingExtension).publications
|
||||
assert publications.size() > 0
|
||||
assert publications.named("stubs") != null
|
||||
}
|
||||
|
||||
@Test
|
||||
void "should compile"() {
|
||||
given:
|
||||
|
||||
Reference in New Issue
Block a user