Upgraded Groovy to 4 and Rest Assured to 5
This commit is contained in:
@@ -35,11 +35,11 @@
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<groupId>org.apache.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<groupId>org.apache.groovy</groupId>
|
||||
<artifactId>groovy-nio</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -79,7 +79,7 @@
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>4.4.0</version>
|
||||
<version>${rest-assured.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -36,7 +36,6 @@ targetCompatibility = 17
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven { url "https://repo.spring.io/snapshot" }
|
||||
maven { url "https://repo.spring.io/milestone" }
|
||||
maven { url "https://repo.spring.io/release" }
|
||||
@@ -75,9 +74,7 @@ dependencies {
|
||||
exclude(group: '*')
|
||||
}
|
||||
|
||||
testImplementation('org.spockframework:spock-core:2.0-M5-groovy-3.0') { // @releaser:version-check-off
|
||||
exclude(group: 'org.codehaus.groovy')
|
||||
}
|
||||
testImplementation "org.springframework.boot:spring-boot-starter-test"
|
||||
testImplementation localGroovy()
|
||||
testImplementation gradleTestKit()
|
||||
}
|
||||
@@ -89,6 +86,7 @@ task libtest() {
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
exceptionFormat = 'full'
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ import org.gradle.testkit.runner.BuildResult
|
||||
import org.gradle.testkit.runner.BuildTask
|
||||
import org.gradle.testkit.runner.GradleRunner
|
||||
import org.gradle.testkit.runner.TaskOutcome
|
||||
import spock.lang.Specification
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8
|
||||
|
||||
abstract class ContractVerifierIntegrationSpec extends Specification {
|
||||
abstract class ContractVerifierIntegrationTest {
|
||||
|
||||
public static final String SPOCK = "testFramework = 'Spock'"
|
||||
public static final String JUNIT = "testFramework = 'JUnit'"
|
||||
@@ -42,7 +42,8 @@ abstract class ContractVerifierIntegrationSpec extends Specification {
|
||||
|
||||
File testProjectDir
|
||||
|
||||
def setup() {
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
def dateString = new Date().format("yyyy-MM-dd_HH-mm-ss")
|
||||
def testFolder = new File("build/generated-tests/${getClass().simpleName}/${dateString}")
|
||||
testFolder.mkdirs()
|
||||
@@ -21,7 +21,7 @@ import java.nio.file.Path
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8
|
||||
|
||||
abstract class ContractVerifierKotlinIntegrationSpec extends ContractVerifierIntegrationSpec {
|
||||
abstract class ContractVerifierKotlinIntegrationTest extends ContractVerifierIntegrationTest {
|
||||
public static final String SPOCK = "testFramework.set(TestFramework.SPOCK)"
|
||||
public static final String JUNIT = "testFramework.set(TestFramework.JUNIT)"
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.plugin
|
||||
|
||||
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.file.Directory
|
||||
import org.gradle.api.internal.project.DefaultProject
|
||||
@@ -28,13 +27,16 @@ import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import org.springframework.cloud.contract.verifier.config.TestFramework
|
||||
import spock.lang.Specification
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ContractVerifierSpec extends Specification {
|
||||
import org.springframework.cloud.contract.verifier.config.TestFramework
|
||||
|
||||
class ContractVerifierTest {
|
||||
DefaultProject project
|
||||
|
||||
def setup() {
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
String dateString = new Date().format("yyyy-MM-dd_HH-mm-ss")
|
||||
File testFolder = new File("build/generated-tests/${getClass().simpleName}/${dateString}")
|
||||
testFolder.mkdirs()
|
||||
@@ -42,31 +44,35 @@ class ContractVerifierSpec extends Specification {
|
||||
project.plugins.apply(SpringCloudContractVerifierGradlePlugin)
|
||||
}
|
||||
|
||||
def "should apply java plugin"() {
|
||||
@Test
|
||||
void "should apply java plugin"() {
|
||||
expect:
|
||||
project.plugins.hasPlugin(JavaPlugin)
|
||||
}
|
||||
|
||||
def "should create contracts extension"() {
|
||||
@Test
|
||||
void "should create contracts extension"() {
|
||||
expect:
|
||||
project.extensions.findByType(ContractVerifierExtension) != null
|
||||
assert project.extensions.findByType(ContractVerifierExtension) != null
|
||||
}
|
||||
|
||||
def "should create a test sourceset with java sources"() {
|
||||
@Test
|
||||
void "should create a test sourceset with java sources"() {
|
||||
given:
|
||||
ContractVerifierExtension extension = project.extensions.getByType(ContractVerifierExtension)
|
||||
Directory projectDir = project.layout.projectDirectory
|
||||
SourceSet contractTest = project.convention.getPlugin(JavaPluginConvention).getSourceSets().getByName("contractTest")
|
||||
|
||||
expect:
|
||||
contractTest != null
|
||||
contractTest.java.srcDirs.contains(projectDir.dir("src/contractTest/java").asFile)
|
||||
contractTest.java.srcDirs.contains(extension.generatedTestJavaSourcesDir.get().asFile)
|
||||
contractTest.resources.srcDirs.contains(projectDir.dir("src/contractTest/resources").asFile)
|
||||
contractTest.resources.srcDirs.contains(extension.generatedTestResourcesDir.get().asFile)
|
||||
assert contractTest != null
|
||||
assert contractTest.java.srcDirs.contains(projectDir.dir("src/contractTest/java").asFile)
|
||||
assert contractTest.java.srcDirs.contains(extension.generatedTestJavaSourcesDir.get().asFile)
|
||||
assert contractTest.resources.srcDirs.contains(projectDir.dir("src/contractTest/resources").asFile)
|
||||
assert contractTest.resources.srcDirs.contains(extension.generatedTestResourcesDir.get().asFile)
|
||||
}
|
||||
|
||||
def "should create a test sourceset with groovy sources, if the groovy plugin is present"() {
|
||||
@Test
|
||||
void "should create a test sourceset with groovy sources, if the groovy plugin is present"() {
|
||||
given:
|
||||
project.plugins.apply(GroovyPlugin)
|
||||
ContractVerifierExtension extension = project.extensions.getByType(ContractVerifierExtension)
|
||||
@@ -74,104 +80,116 @@ class ContractVerifierSpec extends Specification {
|
||||
SourceSet contractTest = project.convention.getPlugin(JavaPluginConvention).getSourceSets().getByName("contractTest")
|
||||
|
||||
expect:
|
||||
contractTest != null
|
||||
contractTest.java.srcDirs.contains(projectDir.dir("src/contractTest/java").asFile)
|
||||
contractTest.java.srcDirs.contains(extension.generatedTestJavaSourcesDir.get().asFile)
|
||||
contractTest.groovy.srcDirs.contains(projectDir.dir('src/contractTest/groovy').asFile)
|
||||
contractTest.groovy.srcDirs.contains(extension.generatedTestGroovySourcesDir.get().asFile)
|
||||
contractTest.resources.srcDirs.contains(projectDir.dir("src/contractTest/resources").asFile)
|
||||
contractTest.resources.srcDirs.contains(extension.generatedTestResourcesDir.get().asFile)
|
||||
assert contractTest != null
|
||||
assert contractTest.java.srcDirs.contains(projectDir.dir("src/contractTest/java").asFile)
|
||||
assert contractTest.java.srcDirs.contains(extension.generatedTestJavaSourcesDir.get().asFile)
|
||||
assert contractTest.groovy.srcDirs.contains(projectDir.dir('src/contractTest/groovy').asFile)
|
||||
assert contractTest.groovy.srcDirs.contains(extension.generatedTestGroovySourcesDir.get().asFile)
|
||||
assert contractTest.resources.srcDirs.contains(projectDir.dir("src/contractTest/resources").asFile)
|
||||
assert contractTest.resources.srcDirs.contains(extension.generatedTestResourcesDir.get().asFile)
|
||||
}
|
||||
|
||||
def "should setup dependency configurations"() {
|
||||
@Test
|
||||
void "should setup dependency configurations"() {
|
||||
given:
|
||||
Configuration contractTestCompileOnly = project.configurations.contractTestCompileOnly
|
||||
Configuration contractTestImplementation = project.configurations.contractTestImplementation
|
||||
Configuration contractTestRuntimeOnly = project.configurations.contractTestRuntimeOnly
|
||||
|
||||
expect:
|
||||
contractTestCompileOnly != null
|
||||
contractTestCompileOnly.extendsFrom.contains(project.configurations.testCompileOnly)
|
||||
contractTestImplementation != null
|
||||
contractTestImplementation.extendsFrom.contains(project.configurations.testImplementation)
|
||||
contractTestRuntimeOnly != null
|
||||
contractTestRuntimeOnly.extendsFrom.contains(project.configurations.testRuntimeOnly)
|
||||
assert contractTestCompileOnly != null
|
||||
assert contractTestCompileOnly.extendsFrom.contains(project.configurations.testCompileOnly)
|
||||
assert contractTestImplementation != null
|
||||
assert contractTestImplementation.extendsFrom.contains(project.configurations.testImplementation)
|
||||
assert contractTestRuntimeOnly != null
|
||||
assert contractTestRuntimeOnly.extendsFrom.contains(project.configurations.testRuntimeOnly)
|
||||
}
|
||||
|
||||
def "should create contract test task"() {
|
||||
@Test
|
||||
void "should create contract test task"() {
|
||||
expect:
|
||||
project.tasks.named("contractTest").get() != null
|
||||
assert project.tasks.named("contractTest").get() != null
|
||||
}
|
||||
|
||||
def "should create generateContractTests task"() {
|
||||
@Test
|
||||
void "should create generateContractTests task"() {
|
||||
expect:
|
||||
project.tasks.named("generateContractTests").get() != null
|
||||
assert project.tasks.named("generateContractTests").get() != null
|
||||
}
|
||||
|
||||
def "should configure generateContractTests task as a dependency of the compileContractTestJava task"() {
|
||||
@Test
|
||||
void "should configure generateContractTests task as a dependency of the compileContractTestJava task"() {
|
||||
expect:
|
||||
project.tasks.compileContractTestJava.getDependsOn().contains(project.tasks.named("generateContractTests"))
|
||||
project.tasks.findByName("compileContractTestGroovy") == null
|
||||
assert project.tasks.compileContractTestJava.getDependsOn().contains(project.tasks.named("generateContractTests"))
|
||||
assert project.tasks.findByName("compileContractTestGroovy") == null
|
||||
}
|
||||
|
||||
def "should configure generateContractTests task as a dependency of the compileContractTestGroovy task"() {
|
||||
@Test
|
||||
void "should configure generateContractTests task as a dependency of the compileContractTestGroovy task"() {
|
||||
given:
|
||||
project.plugins.apply(GroovyPlugin)
|
||||
|
||||
expect:
|
||||
project.tasks.compileContractTestJava.getDependsOn().contains(project.tasks.named("generateContractTests"))
|
||||
project.tasks.compileContractTestGroovy.getDependsOn().contains(project.tasks.named("generateContractTests"))
|
||||
assert project.tasks.compileContractTestJava.getDependsOn().contains(project.tasks.named("generateContractTests"))
|
||||
assert project.tasks.compileContractTestGroovy.getDependsOn().contains(project.tasks.named("generateContractTests"))
|
||||
}
|
||||
|
||||
def "should configure generatedTestSourcesDir with the appropriate directories"() {
|
||||
@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:
|
||||
generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestJavaSourcesDir.get().asFile
|
||||
assert generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestJavaSourcesDir.get().asFile
|
||||
|
||||
and:
|
||||
extension.testFramework.set(TestFramework.SPOCK)
|
||||
|
||||
then:
|
||||
generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestGroovySourcesDir.get().asFile
|
||||
assert generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestGroovySourcesDir.get().asFile
|
||||
|
||||
and:
|
||||
extension.generatedTestSourcesDir.set(project.file("src/random"))
|
||||
|
||||
then:
|
||||
generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestSourcesDir.get().asFile
|
||||
assert generateServerTestsTask.generatedTestSourcesDir.get().asFile == extension.generatedTestSourcesDir.get().asFile
|
||||
}
|
||||
|
||||
def "should create generateClientStubs task"() {
|
||||
@Test
|
||||
void "should create generateClientStubs task"() {
|
||||
expect:
|
||||
project.tasks.named("generateClientStubs").get() != null
|
||||
assert project.tasks.named("generateClientStubs").get() != null
|
||||
}
|
||||
|
||||
def "should create verifierStubsJar task"() {
|
||||
@Test
|
||||
void "should create verifierStubsJar task"() {
|
||||
expect:
|
||||
project.tasks.named("verifierStubsJar").get() != null
|
||||
assert project.tasks.named("verifierStubsJar").get() != null
|
||||
}
|
||||
|
||||
def "should configure generateClientStubs task as a dependency of the verifierStubsJar task"() {
|
||||
@Test
|
||||
void "should configure generateClientStubs task as a dependency of the verifierStubsJar task"() {
|
||||
expect:
|
||||
project.tasks.verifierStubsJar.getDependsOn().contains(project.tasks.named("generateClientStubs"))
|
||||
}
|
||||
|
||||
def "should configure generateClientStubs task as a dependency of the publishStubsToScm task"() {
|
||||
@Test
|
||||
void "should configure generateClientStubs task as a dependency of the publishStubsToScm task"() {
|
||||
expect:
|
||||
project.tasks.publishStubsToScm.getDependsOn().contains(project.tasks.named("generateClientStubs"))
|
||||
assert project.tasks.publishStubsToScm.getDependsOn().contains(project.tasks.named("generateClientStubs"))
|
||||
}
|
||||
|
||||
def "should create copyContracts task"() {
|
||||
@Test
|
||||
void "should create copyContracts task"() {
|
||||
expect:
|
||||
project.tasks.named("copyContracts").get() != null
|
||||
assert project.tasks.named("copyContracts").get() != null
|
||||
}
|
||||
|
||||
def "should configure copyContracts task as a dependency of the verifierStubsJar task"() {
|
||||
@Test
|
||||
void "should configure copyContracts task as a dependency of the verifierStubsJar task"() {
|
||||
expect:
|
||||
project.tasks.verifierStubsJar.getDependsOn().contains(project.tasks.named("generateClientStubs"))
|
||||
assert project.tasks.verifierStubsJar.getDependsOn().contains(project.tasks.named("generateClientStubs"))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +201,8 @@ class ContractVerifierSpec extends Specification {
|
||||
* responsibility.
|
||||
*/
|
||||
@Deprecated
|
||||
def "should configure maven-publish plugin, if enabled"() {
|
||||
@Test
|
||||
void "should configure maven-publish plugin, if enabled"() {
|
||||
given:
|
||||
project.plugins.apply(MavenPublishPlugin)
|
||||
project.plugins.apply(SpringCloudContractVerifierGradlePlugin)
|
||||
@@ -195,11 +214,12 @@ class ContractVerifierSpec extends Specification {
|
||||
|
||||
expect:
|
||||
PublicationContainer publications = project.extensions.getByType(PublishingExtension).publications
|
||||
publications.size() > 0
|
||||
publications.named("stubs") != null
|
||||
assert publications.size() > 0
|
||||
assert publications.named("stubs") != null
|
||||
}
|
||||
|
||||
def "should compile"() {
|
||||
@Test
|
||||
void "should compile"() {
|
||||
given:
|
||||
project.plugins.apply(SpringCloudContractVerifierGradlePlugin)
|
||||
ContractVerifierExtension extension = project.getExtensions().findByType(ContractVerifierExtension)
|
||||
@@ -218,10 +238,11 @@ class ContractVerifierSpec extends Specification {
|
||||
// end::base_class_mappings[]
|
||||
}
|
||||
expect:
|
||||
extension
|
||||
assert extension
|
||||
}
|
||||
|
||||
def "should property merge scm repository settings for publishing stubs to scm"() {
|
||||
@Test
|
||||
void "should property merge scm repository settings for publishing stubs to scm"() {
|
||||
given:
|
||||
project.plugins.apply(SpringCloudContractVerifierGradlePlugin)
|
||||
ContractVerifierExtension extension = project.extensions.findByType(ContractVerifierExtension)
|
||||
@@ -237,11 +258,11 @@ class ContractVerifierSpec extends Specification {
|
||||
}
|
||||
|
||||
then:
|
||||
task.contractRepository.repositoryUrl.get() == "https://git.example.com"
|
||||
task.contractRepository.username.get() == "username"
|
||||
task.contractRepository.password.get() == "password"
|
||||
task.contractRepository.proxyHost.get() == "host"
|
||||
task.contractRepository.proxyPort.get() == 8080
|
||||
assert task.contractRepository.repositoryUrl.get() == "https://git.example.com"
|
||||
assert task.contractRepository.username.get() == "username"
|
||||
assert task.contractRepository.password.get() == "password"
|
||||
assert task.contractRepository.proxyHost.get() == "host"
|
||||
assert task.contractRepository.proxyPort.get() == 8080
|
||||
|
||||
and:
|
||||
extension.publishStubsToScm.contractRepository.with {
|
||||
@@ -253,10 +274,10 @@ class ContractVerifierSpec extends Specification {
|
||||
}
|
||||
|
||||
then:
|
||||
task.contractRepository.repositoryUrl.get() == "https://git2.example.com"
|
||||
task.contractRepository.username.get() == "username2"
|
||||
task.contractRepository.password.get() == "password2"
|
||||
task.contractRepository.proxyHost.get() == "host2"
|
||||
task.contractRepository.proxyPort.get() == 8081
|
||||
assert task.contractRepository.repositoryUrl.get() == "https://git2.example.com"
|
||||
assert task.contractRepository.username.get() == "username2"
|
||||
assert task.contractRepository.password.get() == "password2"
|
||||
assert task.contractRepository.proxyHost.get() == "host2"
|
||||
assert task.contractRepository.proxyPort.get() == 8081
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2020 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.plugin
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult
|
||||
import org.gradle.testkit.runner.TaskOutcome
|
||||
import spock.lang.Ignore
|
||||
import spock.lang.Stepwise
|
||||
|
||||
@Ignore
|
||||
@Stepwise
|
||||
class ScenarioProjectKotlinSpec extends ContractVerifierKotlinIntegrationSpec {
|
||||
|
||||
def setup() {
|
||||
setupForProject("functionalTest/scenarioProjectKotlin")
|
||||
runTasksSuccessfully('clean')
|
||||
//delete accidental output when previously importing SimpleBoot into Idea to tweak it
|
||||
}
|
||||
|
||||
def "should pass basic flow for Spock"() {
|
||||
given:
|
||||
assert fileExists('build.gradle.kts')
|
||||
expect:
|
||||
runTasksSuccessfully(checkAndPublishToMavenLocal())
|
||||
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
|
||||
BuildResult result = run("check", "--info", "--stacktrace")
|
||||
result.task(":fraudDetectionService:check").outcome == TaskOutcome.UP_TO_DATE
|
||||
result.task(":loanApplicationService:check").outcome == TaskOutcome.UP_TO_DATE
|
||||
}
|
||||
|
||||
def "should pass basic flow for JUnit"() {
|
||||
given:
|
||||
assert fileExists('build.gradle.kts')
|
||||
expect:
|
||||
switchToJunitTestFramework()
|
||||
runTasksSuccessfully(checkAndPublishToMavenLocal())
|
||||
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
|
||||
BuildResult result = run("check", "--info", "--stacktrace")
|
||||
result.task(":fraudDetectionService:check").outcome == TaskOutcome.UP_TO_DATE
|
||||
result.task(":loanApplicationService:check").outcome == TaskOutcome.UP_TO_DATE
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2020 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.plugin
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult
|
||||
import org.gradle.testkit.runner.TaskOutcome
|
||||
import spock.lang.Ignore
|
||||
import spock.lang.Stepwise
|
||||
|
||||
@Ignore
|
||||
@Stepwise
|
||||
class ScenarioProjectSpec extends ContractVerifierIntegrationSpec {
|
||||
|
||||
def setup() {
|
||||
setupForProject("functionalTest/scenarioProject")
|
||||
runTasksSuccessfully('clean')
|
||||
//delete accidental output when previously importing SimpleBoot into Idea to tweak it
|
||||
}
|
||||
|
||||
def "should pass basic flow for Spock"() {
|
||||
given:
|
||||
assert fileExists('build.gradle')
|
||||
expect:
|
||||
runTasksSuccessfully(checkAndPublishToMavenLocal())
|
||||
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
|
||||
BuildResult result = run("check", "--info", "--stacktrace")
|
||||
result.task(":fraudDetectionService:check").outcome == TaskOutcome.UP_TO_DATE
|
||||
result.task(":loanApplicationService:check").outcome == TaskOutcome.UP_TO_DATE
|
||||
}
|
||||
|
||||
def "should pass basic flow for JUnit"() {
|
||||
given:
|
||||
assert fileExists('build.gradle')
|
||||
expect:
|
||||
switchToJunitTestFramework()
|
||||
emptySourceSet()
|
||||
runTasksSuccessfully(checkAndPublishToMavenLocal())
|
||||
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
|
||||
BuildResult result = run("check", "--info", "--stacktrace")
|
||||
result.task(":fraudDetectionService:check").outcome == TaskOutcome.UP_TO_DATE
|
||||
result.task(":loanApplicationService:check").outcome == TaskOutcome.UP_TO_DATE
|
||||
}
|
||||
|
||||
def "should properly work with build cache"() {
|
||||
given:
|
||||
def gradleUserHomeDir = new File(testProjectDir, ".gradleUserHome")
|
||||
gradleUserHomeDir.mkdirs()
|
||||
String[] tasks = ["-g ${gradleUserHomeDir}", "clean", "check", "publishToMavenLocal", "--info", "--stacktrace", "--build-cache"]
|
||||
assert fileExists("build.gradle")
|
||||
|
||||
expect:
|
||||
runTasksSuccessfully(tasks)
|
||||
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
|
||||
BuildResult result = run(tasks)
|
||||
result.task(":fraudDetectionService:copyContracts").outcome == TaskOutcome.FROM_CACHE
|
||||
result.task(":fraudDetectionService:generateContractTests").outcome == TaskOutcome.FROM_CACHE
|
||||
result.task(":fraudDetectionService:contractTest").outcome == TaskOutcome.FROM_CACHE
|
||||
result.task(":fraudDetectionService:generateClientStubs").outcome == TaskOutcome.FROM_CACHE
|
||||
result.task(":loanApplicationService:check").outcome == TaskOutcome.UP_TO_DATE
|
||||
}
|
||||
}
|
||||
@@ -33,13 +33,13 @@ repositories {
|
||||
dependencies {
|
||||
implementation "org.springframework:spring-web"
|
||||
implementation "org.springframework:spring-context-support"
|
||||
implementation "org.codehaus.groovy:groovy-all:${groovyVersion}"
|
||||
implementation "org.apache.groovy:groovy-all:${groovyVersion}"
|
||||
implementation 'com.jayway.jsonpath:json-path-assert:2.2.0'
|
||||
|
||||
testImplementation "com.github.tomakehurst:wiremock:${wiremockVersion}"
|
||||
testImplementation "com.toomuchcoding.jsonassert:jsonassert:${jsonAssertVersion}"
|
||||
testImplementation("org.spockframework:spock-spring:1.0-groovy-2.4") {
|
||||
exclude(group: 'org.codehaus.groovy')
|
||||
exclude(group: 'org.apache.groovy')
|
||||
}
|
||||
testImplementation "io.restassured:rest-assured:$restAssuredVersion"
|
||||
testImplementation "io.restassured:spring-mock-mvc:$restAssuredVersion"
|
||||
|
||||
@@ -44,9 +44,9 @@ subprojects {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation "org.codehaus.groovy:groovy"
|
||||
testImplementation "org.apache.groovy:groovy"
|
||||
testImplementation("org.spockframework:spock-core:$spockVersion") {
|
||||
exclude(group: 'org.codehaus.groovy')
|
||||
exclude(group: 'org.apache.groovy')
|
||||
}
|
||||
testImplementation "junit:junit:4.12"
|
||||
testImplementation "com.github.tomakehurst:wiremock:${wiremockVersion}"
|
||||
@@ -112,7 +112,7 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
|
||||
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
||||
|
||||
testRuntime("org.spockframework:spock-spring:$spockVersion") {
|
||||
exclude(group: 'org.codehaus.groovy')
|
||||
exclude(group: 'org.apache.groovy')
|
||||
}
|
||||
testImplementation "org.mockito:mockito-core"
|
||||
testImplementation "org.springframework:spring-test"
|
||||
|
||||
@@ -53,7 +53,7 @@ subprojects {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile("org.codehaus.groovy:groovy")
|
||||
testCompile("org.apache.groovy:groovy")
|
||||
testCompile("org.spockframework:spock-core:$spockVersion")
|
||||
testCompile("junit:junit:4.12")
|
||||
testCompile("com.github.tomakehurst:wiremock:$wiremockVersion")
|
||||
@@ -95,7 +95,7 @@ configure(listOf(project(":fraudDetectionService"), project(":loanApplicationSer
|
||||
compile("org.springframework.boot:spring-boot-starter-actuator")
|
||||
|
||||
testRuntime("org.spockframework:spock-spring:$spockVersion") {
|
||||
exclude(group = "org.codehaus.groovy")
|
||||
exclude(group = "org.apache.groovy")
|
||||
}
|
||||
testCompile("org.mockito:mockito-core")
|
||||
testCompile("org.springframework:spring-test")
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<groupId>org.apache.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -31,11 +31,11 @@
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<groupId>org.apache.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<groupId>org.apache.groovy</groupId>
|
||||
<artifactId>groovy-nio</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -415,10 +415,10 @@ class PactContractConverterSpec extends Specification {
|
||||
Map<String, Collection<Contract>> contracts = contractResources.
|
||||
collectEntries {
|
||||
[(it.filename): ContractVerifierDslConverter.
|
||||
convertAsCollection(new File("/"), it.file)]
|
||||
convertAsCollection(new File("/"), it.getFile())]
|
||||
}
|
||||
Map<String, String> jsonPacts = pactResources.
|
||||
collectEntries { [(it.filename): it.file.text] }
|
||||
collectEntries { [(it.filename): it.getFile().text] }
|
||||
when:
|
||||
Map<String, Collection<Pact>> pacts = contracts.entrySet().
|
||||
collectEntries { [(it.key): converter.convertTo(it.value)] }
|
||||
|
||||
Reference in New Issue
Block a user