Added helper methods for contract extension

without these methods to use  and  fields you need to prepend the  word - otherwise you're setting it on the project

fixes #328
This commit is contained in:
Marcin Grzejszczak
2017-06-14 12:46:58 +02:00
parent 88c959beea
commit 69d1be515d
2 changed files with 66 additions and 0 deletions

View File

@@ -158,6 +158,26 @@ class ContractVerifierExtension {
String classifier
String version
String stringNotation
void groupId(String groupId) {
this.groupId = groupId
}
void artifactId(String artifactId) {
this.artifactId = artifactId
}
void classifier(String classifier) {
this.classifier = classifier
}
void version(String version) {
this.version = version
}
void stringNotation(String stringNotation) {
this.stringNotation = stringNotation
}
}
static class BaseClassMapping {

View File

@@ -20,4 +20,50 @@ class GradleContractsDownloaderSpec extends Specification {
stubConfig.version == "1.0.0"
stubConfig.classifier == "stubs"
}
def "should parse dependency via direct setting"() {
given:
def dep = new ContractVerifierExtension.Dependency(
groupId: "com.example",
artifactId: "foo",
version: "1.0.0",
classifier: "stubs"
)
when:
StubConfiguration stubConfig = new GradleContractsDownloader(null, null).stubConfiguration(dep)
then:
stubConfig.groupId == "com.example"
stubConfig.artifactId == "foo"
stubConfig.version == "1.0.0"
stubConfig.classifier == "stubs"
}
def "should parse dependency via string notation with methods"() {
given:
String stringNotation = "com.example:foo:1.0.0:stubs"
def dep = new ContractVerifierExtension.Dependency()
dep.stringNotation(stringNotation)
when:
StubConfiguration stubConfig = new GradleContractsDownloader(null, null).stubConfiguration(dep)
then:
stubConfig.groupId == "com.example"
stubConfig.artifactId == "foo"
stubConfig.version == "1.0.0"
stubConfig.classifier == "stubs"
}
def "should parse dependency via direct setting with methods"() {
given:
def dep = new ContractVerifierExtension.Dependency()
dep.groupId("com.example")
dep.artifactId("foo")
dep.version("1.0.0")
dep.classifier("stubs")
when:
StubConfiguration stubConfig = new GradleContractsDownloader(null, null).stubConfiguration(dep)
then:
stubConfig.groupId == "com.example"
stubConfig.artifactId == "foo"
stubConfig.version == "1.0.0"
stubConfig.classifier == "stubs"
}
}