Skip to content

Commit 329dad5

Browse files
committed
update tests
1 parent 27f45bb commit 329dad5

File tree

5 files changed

+51
-28
lines changed

5 files changed

+51
-28
lines changed

gradle-license-plugin/src/test/groovy/com/jaredsburrows/license/LicensePluginJavaSpec.groovy

+10-11
Original file line numberDiff line numberDiff line change
@@ -792,35 +792,35 @@ final class LicensePluginJavaSpec extends Specification {
792792
implementation 'com.android.support:appcompat-v7:26.1.0'
793793
}
794794
795-
${(1..depth-1).collect {
795+
${(1..depth - 1).collect {
796796
"""
797797
project(':subproject_${it}a') {
798798
apply plugin: 'java-library'
799799
800800
dependencies {
801-
implementation project(':subproject_${it+1}a')
802-
implementation project(':subproject_${it+1}b')
803-
implementation project(':subproject_${it+1}c')
801+
implementation project(':subproject_${it + 1}a')
802+
implementation project(':subproject_${it + 1}b')
803+
implementation project(':subproject_${it + 1}c')
804804
}
805805
}
806806
807807
project(':subproject_${it}b') {
808808
apply plugin: 'java-library'
809809
810810
dependencies {
811-
implementation project(':subproject_${it+1}a')
812-
implementation project(':subproject_${it+1}b')
813-
implementation project(':subproject_${it+1}c')
811+
implementation project(':subproject_${it + 1}a')
812+
implementation project(':subproject_${it + 1}b')
813+
implementation project(':subproject_${it + 1}c')
814814
}
815815
}
816816
817817
project(':subproject_${it}c') {
818818
apply plugin: 'java-library'
819819
820820
dependencies {
821-
implementation project(':subproject_${it+1}a')
822-
implementation project(':subproject_${it+1}b')
823-
implementation project(':subproject_${it+1}c')
821+
implementation project(':subproject_${it + 1}a')
822+
implementation project(':subproject_${it + 1}b')
823+
implementation project(':subproject_${it + 1}c')
824824
}
825825
}
826826
"""
@@ -1089,5 +1089,4 @@ final class LicensePluginJavaSpec extends Specification {
10891089
then:
10901090
result.task(':licenseReport').outcome == SUCCESS
10911091
}
1092-
10931092
}

gradle-license-plugin/src/test/groovy/com/jaredsburrows/license/LicensePluginSpec.groovy

+28-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class LicensePluginSpec extends Specification {
3333
buildFile = testProjectDir.newFile('build.gradle')
3434
}
3535

36-
def 'apply with buildscript'() {
36+
def 'apply plugin with buildscript dsl'() {
3737
given:
3838
buildFile <<
3939
"""
@@ -59,7 +59,32 @@ final class LicensePluginSpec extends Specification {
5959
result.task(':licenseReport').outcome == SUCCESS
6060
}
6161

62-
def 'apply with plugins'() {
62+
def 'apply plugin with buildscript dsl and no other plugins'() {
63+
given:
64+
buildFile <<
65+
"""
66+
buildscript {
67+
repositories {
68+
mavenCentral()
69+
google()
70+
}
71+
72+
dependencies {
73+
classpath files($classpathString)
74+
}
75+
}
76+
77+
apply plugin: 'com.jaredsburrows.license'
78+
"""
79+
80+
when:
81+
def result = gradleWithCommandWithFail(testProjectDir.root, 'licenseReport', '-s')
82+
83+
then:
84+
result.output.contains("'com.jaredsburrows.license' requires Java, Kotlin or Android Gradle Plugins.")
85+
}
86+
87+
def 'apply plugin with plugins dsl'() {
6388
given:
6489
buildFile <<
6590
"""
@@ -76,7 +101,7 @@ final class LicensePluginSpec extends Specification {
76101
result.task(':licenseReport').outcome == SUCCESS
77102
}
78103

79-
def 'apply with no plugins'() {
104+
def 'apply plugin with plugins dsl and no other plugins'() {
80105
given:
81106
buildFile <<
82107
"""

gradle-license-plugin/src/test/groovy/com/jaredsburrows/license/LicensePluginVersionSpec.groovy

+7-7
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ final class LicensePluginVersionSpec extends Specification {
100100

101101
when:
102102
def result = GradleRunner.create()
103-
.withGradleVersion(gradleVersion)
103+
.withGradleVersion(gradleVersion as String)
104104
.withProjectDir(testProjectDir.root)
105105
.withArguments('licenseDebugReport', '-s')
106106
.build()
@@ -160,7 +160,7 @@ final class LicensePluginVersionSpec extends Specification {
160160

161161
when:
162162
def result = GradleRunner.create()
163-
.withGradleVersion(gradleVersion)
163+
.withGradleVersion(gradleVersion as String)
164164
.withProjectDir(testProjectDir.root)
165165
.withArguments('licenseDebugReport', '-s')
166166
.build()
@@ -220,7 +220,7 @@ final class LicensePluginVersionSpec extends Specification {
220220

221221
when:
222222
def result = GradleRunner.create()
223-
.withGradleVersion(gradleVersion)
223+
.withGradleVersion(gradleVersion as String)
224224
.withProjectDir(testProjectDir.root)
225225
.withArguments('licenseDebugReport', '-s')
226226
.build()
@@ -280,7 +280,7 @@ final class LicensePluginVersionSpec extends Specification {
280280

281281
when:
282282
def result = GradleRunner.create()
283-
.withGradleVersion(gradleVersion)
283+
.withGradleVersion(gradleVersion as String)
284284
.withProjectDir(testProjectDir.root)
285285
.withArguments('licenseDebugReport', '-s')
286286
.build()
@@ -340,7 +340,7 @@ final class LicensePluginVersionSpec extends Specification {
340340

341341
when:
342342
def result = GradleRunner.create()
343-
.withGradleVersion(gradleVersion)
343+
.withGradleVersion(gradleVersion as String)
344344
.withProjectDir(testProjectDir.root)
345345
.withArguments('licenseDebugReport', '-s')
346346
.build()
@@ -400,7 +400,7 @@ final class LicensePluginVersionSpec extends Specification {
400400

401401
when:
402402
def result = GradleRunner.create()
403-
.withGradleVersion(gradleVersion)
403+
.withGradleVersion(gradleVersion as String)
404404
.withProjectDir(testProjectDir.root)
405405
.withArguments('licenseDebugReport', '-s')
406406
.build()
@@ -459,7 +459,7 @@ final class LicensePluginVersionSpec extends Specification {
459459

460460
when:
461461
def result = GradleRunner.create()
462-
.withGradleVersion(gradleVersion)
462+
.withGradleVersion(gradleVersion as String)
463463
.withProjectDir(testProjectDir.root)
464464
.withArguments('licenseDebugReport', '-s')
465465
.build()

gradle-license-plugin/src/test/groovy/com/jaredsburrows/license/internal/report/TextReportSpec.groovy

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.jaredsburrows.license.internal.report
22

3-
import static test.TestUtils.assertCsv
4-
53
import org.apache.maven.model.Developer
64
import org.apache.maven.model.License
75
import org.apache.maven.model.Model

gradle-license-plugin/src/test/groovy/test/TestUtils.groovy

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ import org.xmlunit.builder.Input
1010

1111
final class TestUtils {
1212
private TestUtils() {
13+
//noinspection GroovyAccessibility
1314
throw new AssertionError('No instances')
1415
}
1516

16-
static def assertCsv(def expected, def actual) {
17+
static def assertCsv(String expected, String actual) {
1718
def left = CSVFormat.DEFAULT.parse(new StringReader(actual)).records.collect { it.toString() }
1819
def right = CSVFormat.DEFAULT.parse(new StringReader(expected)).records.collect { it.toString() }
1920
return left == right
2021
}
2122

22-
static def assertHtml(def expected, def actual) {
23+
static def assertHtml(String expected, String actual) {
2324
def left = htmlToXml(expected)
2425
def right = htmlToXml(actual)
2526
return !DiffBuilder.compare(Input.fromString(right).build())
@@ -30,21 +31,21 @@ final class TestUtils {
3031
.differences
3132
}
3233

33-
static def assertJson(def expected, def actual) {
34+
static def assertJson(String expected, String actual) {
3435
def moshi = new Moshi.Builder().build()
3536
def jsonAdapter = moshi.adapter(Types.newParameterizedType(List.class, Map.class, String.class, Object.class))
3637
return jsonAdapter.fromJson(expected) == jsonAdapter.fromJson(actual)
3738
}
3839

39-
static def gradleWithCommand(def file, String... commands) {
40+
static def gradleWithCommand(File file, String... commands) {
4041
return GradleRunner.create()
4142
.withProjectDir(file)
4243
.withArguments(commands)
4344
.withPluginClasspath()
4445
.build()
4546
}
4647

47-
static def gradleWithCommandWithFail(def file, String... commands) {
48+
static def gradleWithCommandWithFail(File file, String... commands) {
4849
return GradleRunner.create()
4950
.withProjectDir(file)
5051
.withArguments(commands)

0 commit comments

Comments
 (0)