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:
@@ -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 {
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user