From cc7ee1753efb06c175c644217c92dce9807b6477 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Mon, 11 Dec 2023 11:56:45 +0000 Subject: [PATCH] REVIEW: IDE error markers over lack of this keyword use ".... can't be called from this context by implicit receiver. Use the explicit one if necessary" Think it is an IDE issue using 1.9.21 capable editor against a 1.3 configured codebase? --- .../xjc/testutil/assertions/BuildResult.kt | 2 +- .../gradle/plugins/xjc/XjcGenerateTest.kt | 46 +++++------ .../gradle/plugins/xjc/XjcPluginTest.kt | 80 +++++++++---------- .../plugins/xjc/XjcSourceSetConventionTest.kt | 28 +++---- .../xjc/testutil/assertions/Configuration.kt | 4 +- .../xjc/testutil/assertions/Container.kt | 4 +- .../xjc/testutil/assertions/Extension.kt | 18 ++--- .../xjc/testutil/assertions/GradleProject.kt | 4 +- .../xjc/testutil/assertions/GradleTask.kt | 10 +-- .../xjc/testutil/assertions/Provider.kt | 14 ++-- 10 files changed, 102 insertions(+), 108 deletions(-) diff --git a/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/BuildResult.kt b/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/BuildResult.kt index ec4b890..38024cd 100644 --- a/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/BuildResult.kt +++ b/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/BuildResult.kt @@ -13,7 +13,7 @@ import org.gradle.testkit.runner.TaskOutcome fun Assert.task(taskPath: String) = transform(name = "task $taskPath") { actual -> actual.task(taskPath) - ?: expected("to include task '$taskPath', but was: ${show(actual.tasks.map { it.path })}") + ?: this.expected("to include task '$taskPath', but was: ${show(actual.tasks.map { it.path })}") } diff --git a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcGenerateTest.kt b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcGenerateTest.kt index 0d414a4..02546cf 100644 --- a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcGenerateTest.kt +++ b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcGenerateTest.kt @@ -54,16 +54,16 @@ object XjcGenerateTest : Spek({ } assertThat(task, "task").all { - prop(XjcGenerate::targetVersion).hasValueEqualTo("XYZ") - prop(XjcGenerate::encoding).hasValueEqualTo("ISO-8859-1") - prop(XjcGenerate::docLocale).hasValueEqualTo(Locale.ITALIAN.toString()) - prop(XjcGenerate::strictCheck).isFalse() - prop(XjcGenerate::packageLevelAnnotations).isFalse() - prop(XjcGenerate::noFileHeader).isFalse() - prop(XjcGenerate::enableIntrospection).isTrue() - prop(XjcGenerate::contentForWildcard).isTrue() - prop(XjcGenerate::readOnly).isTrue() - prop(XjcGenerate::extension).isTrue() + this.prop(XjcGenerate::targetVersion).hasValueEqualTo("XYZ") + this.prop(XjcGenerate::encoding).hasValueEqualTo("ISO-8859-1") + this.prop(XjcGenerate::docLocale).hasValueEqualTo(Locale.ITALIAN.toString()) + this.prop(XjcGenerate::strictCheck).isFalse() + this.prop(XjcGenerate::packageLevelAnnotations).isFalse() + this.prop(XjcGenerate::noFileHeader).isFalse() + this.prop(XjcGenerate::enableIntrospection).isTrue() + this.prop(XjcGenerate::contentForWildcard).isTrue() + this.prop(XjcGenerate::readOnly).isTrue() + this.prop(XjcGenerate::extension).isTrue() } } @@ -104,9 +104,9 @@ object XjcGenerateTest : Spek({ it("should create an XjcGenerate task for each existing source set") { assertThat(project.tasks, name = "tasks").all { - containsItem("xjcGenerate") + this.containsItem("xjcGenerate") .isInstanceOf(XjcGenerate::class) - containsItem("xjcGenerateTest") + this.containsItem("xjcGenerateTest") .isInstanceOf(XjcGenerate::class) } } @@ -125,13 +125,13 @@ object XjcGenerateTest : Spek({ } assertThat(task, name = "task").all { - prop(XjcGenerate::source) + this.prop(XjcGenerate::source) .containsOnly(project.file("src/main/schema/schema.xsd")) - prop(XjcGenerate::bindingFiles) + this.prop(XjcGenerate::bindingFiles) .containsOnly(project.file("src/main/schema/binding.xjb")) - prop(XjcGenerate::urlSources) + this.prop(XjcGenerate::urlSources) .containsOnly(project.file("src/main/schema/externals.url")) - prop(XjcGenerate::catalogs) + this.prop(XjcGenerate::catalogs) .containsOnly(project.file("src/main/schema/catalog.cat")) } } @@ -148,9 +148,9 @@ object XjcGenerateTest : Spek({ ) assertThat(task, name = "task").all { - prop(XjcGenerate::pluginClasspath) + this.prop(XjcGenerate::pluginClasspath) .containsOnly(project.file("custom-jaxb-plugin-1.2.3.jar")) - prop(XjcGenerate::episodes) + this.prop(XjcGenerate::episodes) .containsOnly(project.file("custom-episode-1.2.3.jar")) } } @@ -162,7 +162,7 @@ object XjcGenerateTest : Spek({ val resolved = XjcGenerate.resolveArtifactsForMavenUri(catalogResolutionConfig) assertThat(task, name = "task").all { - prop(XjcGenerate::catalogSerializableResolvedArtifact) + this.prop(XjcGenerate::catalogSerializableResolvedArtifact) .hasValueEqualTo(resolved) } } @@ -178,9 +178,9 @@ object XjcGenerateTest : Spek({ xjcSourceSetConvention.xjcGenerateEpisode.set(true) assertThat(task, name = "task").all { - prop(XjcGenerate::targetPackage) + this.prop(XjcGenerate::targetPackage) .hasValueEqualTo("com.example") - prop(XjcGenerate::generateEpisode) + this.prop(XjcGenerate::generateEpisode) .hasValueEqualTo(true) } } @@ -211,9 +211,9 @@ object XjcGenerateTest : Spek({ val task = project.tasks.getByName("xjcGenerate") as XjcGenerate assertThat(task, name = "task").all { - prop(XjcGenerate::outputDirectory) + this.prop(XjcGenerate::outputDirectory) .dirValue().isEqualTo(project.file("build/generated/sources/xjc/java/main")) - prop(XjcGenerate::episodeOutputDirectory) + this.prop(XjcGenerate::episodeOutputDirectory) .dirValue().isEqualTo(project.file("build/generated/resources/xjc/main")) } } diff --git a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcPluginTest.kt b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcPluginTest.kt index 854d569..f8f9b5b 100644 --- a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcPluginTest.kt +++ b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcPluginTest.kt @@ -9,15 +9,9 @@ import org.gradle.api.plugins.JavaPlugin import org.gradle.api.tasks.SourceSetContainer import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.describe -import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.containsItem -import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.hasConvention -import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.hasExtension -import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.hasValueEqualTo import org.unbrokendome.gradle.plugins.xjc.spek.applyPlugin import org.unbrokendome.gradle.plugins.xjc.spek.setupGradleProject -import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.extendsOnlyFrom -import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.isFalse -import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.isTrue +import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.* import org.unbrokendome.gradle.plugins.xjc.testutil.evaluate import org.unbrokendome.gradle.plugins.xjc.testutil.requiredExtension import org.unbrokendome.gradle.plugins.xjc.testutil.sourceSets @@ -48,17 +42,17 @@ object XjcPluginTest : Spek({ it("xjc DSL extension should apply defaults") { assertThat(project) .hasExtension().all { - prop(XjcExtension::xjcVersion).hasValueEqualTo(XjcExtension.DEFAULT_XJC_VERSION) - prop(XjcExtension::xjcVersionUnsupportedStrategy).hasValueEqualTo(XjcExtension.DEFAULT_XJC_VERSION_UNSUPPORTED_STRATEGY) - prop(XjcExtension::srcDirName).hasValueEqualTo(XjcExtension.DEFAULT_SRC_DIR_NAME) - prop(XjcExtension::encoding).hasValueEqualTo("UTF-8") - prop(XjcExtension::strictCheck).isTrue() - prop(XjcExtension::packageLevelAnnotations).isTrue() - prop(XjcExtension::noFileHeader).isTrue() - prop(XjcExtension::enableIntrospection).isFalse() - prop(XjcExtension::contentForWildcard).isFalse() - prop(XjcExtension::readOnly).isFalse() - prop(XjcExtension::extension).isFalse() + this.prop(XjcExtension::xjcVersion).hasValueEqualTo(XjcExtension.DEFAULT_XJC_VERSION) + this.prop(XjcExtension::xjcVersionUnsupportedStrategy).hasValueEqualTo(XjcExtension.DEFAULT_XJC_VERSION_UNSUPPORTED_STRATEGY) + this.prop(XjcExtension::srcDirName).hasValueEqualTo(XjcExtension.DEFAULT_SRC_DIR_NAME) + this.prop(XjcExtension::encoding).hasValueEqualTo("UTF-8") + this.prop(XjcExtension::strictCheck).isTrue() + this.prop(XjcExtension::packageLevelAnnotations).isTrue() + this.prop(XjcExtension::noFileHeader).isTrue() + this.prop(XjcExtension::enableIntrospection).isFalse() + this.prop(XjcExtension::contentForWildcard).isFalse() + this.prop(XjcExtension::readOnly).isFalse() + this.prop(XjcExtension::extension).isFalse() } } @@ -81,28 +75,28 @@ object XjcPluginTest : Spek({ assertThat(project) .hasExtension().all { - prop(XjcExtension::xjcVersion).hasValueEqualTo("3.0") - prop(XjcExtension::xjcVersionUnsupportedStrategy).hasValueEqualTo("default") - prop(XjcExtension::srcDirName).hasValueEqualTo("xjc") - prop(XjcExtension::targetVersion).hasValueEqualTo("2.2") - prop(XjcExtension::encoding).hasValueEqualTo("ISO-8859-1") - prop(XjcExtension::docLocale).hasValueEqualTo(Locale.ITALIAN.toString()) - prop(XjcExtension::strictCheck).isFalse() - prop(XjcExtension::packageLevelAnnotations).isFalse() - prop(XjcExtension::noFileHeader).isFalse() - prop(XjcExtension::enableIntrospection).isTrue() - prop(XjcExtension::contentForWildcard).isTrue() - prop(XjcExtension::readOnly).isTrue() - prop(XjcExtension::extension).isTrue() + this.prop(XjcExtension::xjcVersion).hasValueEqualTo("3.0") + this.prop(XjcExtension::xjcVersionUnsupportedStrategy).hasValueEqualTo("default") + this.prop(XjcExtension::srcDirName).hasValueEqualTo("xjc") + this.prop(XjcExtension::targetVersion).hasValueEqualTo("2.2") + this.prop(XjcExtension::encoding).hasValueEqualTo("ISO-8859-1") + this.prop(XjcExtension::docLocale).hasValueEqualTo(Locale.ITALIAN.toString()) + this.prop(XjcExtension::strictCheck).isFalse() + this.prop(XjcExtension::packageLevelAnnotations).isFalse() + this.prop(XjcExtension::noFileHeader).isFalse() + this.prop(XjcExtension::enableIntrospection).isTrue() + this.prop(XjcExtension::contentForWildcard).isTrue() + this.prop(XjcExtension::readOnly).isTrue() + this.prop(XjcExtension::extension).isTrue() } } it("should create global XJC configurations") { assertThat(project.configurations, "configurations").all { - containsItem("xjcTool") - containsItem("xjcClasspathGlobal") - containsItem("xjcCatalogResolutionGlobal") + this.containsItem("xjcTool") + this.containsItem("xjcClasspathGlobal") + this.containsItem("xjcCatalogResolutionGlobal") } } } @@ -119,9 +113,9 @@ object XjcPluginTest : Spek({ val sourceSets = project.extensions.getByType(SourceSetContainer::class.java) assertThat(sourceSets).all { - containsItem("main") + this.containsItem("main") .hasConvention() - containsItem("test") + this.containsItem("test") .hasConvention() } } @@ -136,17 +130,17 @@ object XjcPluginTest : Spek({ it("should create XJC configurations for each existing source set") { assertThat(project.configurations, name = "configurations").all { - containsItem("xjcClasspath") + this.containsItem("xjcClasspath") .extendsOnlyFrom("xjcClasspathGlobal") - containsItem("xjcEpisodes") - containsItem("xjcCatalogResolution").all { + this.containsItem("xjcEpisodes") + this.containsItem("xjcCatalogResolution").all { extendsOnlyFrom("xjcCatalogResolutionGlobal", "compileClasspath") } - containsItem("testXjcClasspath") + this.containsItem("testXjcClasspath") .extendsOnlyFrom("xjcClasspathGlobal") - containsItem("testXjcEpisodes") - containsItem("testXjcCatalogResolution").all { + this.containsItem("testXjcEpisodes") + this.containsItem("testXjcCatalogResolution").all { extendsOnlyFrom("xjcCatalogResolutionGlobal", "testCompileClasspath") } } @@ -156,7 +150,7 @@ object XjcPluginTest : Spek({ it("should create XJC configurations for each new source set") { project.sourceSets.create("foo") assertThat(project.configurations, name = "configurations").all { - containsItem("fooXjcClasspath") + this.containsItem("fooXjcClasspath") .extendsOnlyFrom("xjcClasspathGlobal") } } diff --git a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcSourceSetConventionTest.kt b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcSourceSetConventionTest.kt index 1f1ee6f..2f2c53a 100644 --- a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcSourceSetConventionTest.kt +++ b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/XjcSourceSetConventionTest.kt @@ -40,13 +40,13 @@ object XjcSourceSetConventionTest : Spek({ it("should return the correct task and configuration names") { assertThat(xjcSourceSetConvention).all { - prop(XjcSourceSetConvention::xjcGenerateTaskName) + this.prop(XjcSourceSetConvention::xjcGenerateTaskName) .isEqualTo("xjcGenerate") - prop(XjcSourceSetConvention::xjcClasspathConfigurationName) + this.prop(XjcSourceSetConvention::xjcClasspathConfigurationName) .isEqualTo("xjcClasspath") - prop(XjcSourceSetConvention::xjcEpisodesConfigurationName) + this.prop(XjcSourceSetConvention::xjcEpisodesConfigurationName) .isEqualTo("xjcEpisodes") - prop(XjcSourceSetConvention::xjcCatalogResolutionConfigurationName) + this.prop(XjcSourceSetConvention::xjcCatalogResolutionConfigurationName) .isEqualTo("xjcCatalogResolution") } } @@ -66,13 +66,13 @@ object XjcSourceSetConventionTest : Spek({ it("should return the correct task and configuration names") { assertThat(xjcSourceSetConvention).all { - prop(XjcSourceSetConvention::xjcGenerateTaskName) + this.prop(XjcSourceSetConvention::xjcGenerateTaskName) .isEqualTo("xjcGenerateCustom") - prop(XjcSourceSetConvention::xjcClasspathConfigurationName) + this.prop(XjcSourceSetConvention::xjcClasspathConfigurationName) .isEqualTo("customXjcClasspath") - prop(XjcSourceSetConvention::xjcEpisodesConfigurationName) + this.prop(XjcSourceSetConvention::xjcEpisodesConfigurationName) .isEqualTo("customXjcEpisodes") - prop(XjcSourceSetConvention::xjcCatalogResolutionConfigurationName) + this.prop(XjcSourceSetConvention::xjcCatalogResolutionConfigurationName) .isEqualTo("customXjcCatalogResolution") } } @@ -80,13 +80,13 @@ object XjcSourceSetConventionTest : Spek({ it("should set default include filters") { assertThat(xjcSourceSetConvention).all { - prop("xjcSchema") { it.xjcSchema } + this.prop("xjcSchema") { it.xjcSchema } .prop("includes") { it.includes } .containsOnly("**/*.xsd") - prop("xjcBinding") { it.xjcBinding } + this.prop("xjcBinding") { it.xjcBinding } .prop("includes") { it.includes } .containsOnly("**/*.xjb") - prop("xjcUrl") { it.xjcUrl } + this.prop("xjcUrl") { it.xjcUrl } .prop("includes") { it.includes } .containsOnly("**/*.url") } @@ -98,13 +98,13 @@ object XjcSourceSetConventionTest : Spek({ xjc.srcDirName.set("xjc") assertThat(xjcSourceSetConvention).all { - prop("xjcSchema") { it.xjcSchema } + this.prop("xjcSchema") { it.xjcSchema } .prop("srcDirs") { it.srcDirs } .containsOnly(project.file("src/custom/xjc")) - prop("xjcBinding") { it.xjcBinding } + this.prop("xjcBinding") { it.xjcBinding } .prop("srcDirs") { it.srcDirs } .containsOnly(project.file("src/custom/xjc")) - prop("xjcUrl") { it.xjcUrl } + this.prop("xjcUrl") { it.xjcUrl } .prop("srcDirs") { it.srcDirs } .containsOnly(project.file("src/custom/xjc")) } diff --git a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Configuration.kt b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Configuration.kt index 91d3149..9537a48 100644 --- a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Configuration.kt +++ b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Configuration.kt @@ -10,7 +10,7 @@ import org.gradle.api.artifacts.Configuration fun Assert.extendsFrom(other: String) = given { actual -> if (other in actual.extendsFrom.map { it.name }) return - expected( + this.expected( "to extend from configuration \"$other\", but extends from: ${show(actual.extendsFrom)}", actual = actual.extendsFrom, expected = other ) @@ -21,7 +21,7 @@ fun Assert.extendsOnlyFrom(vararg others: String) = given { actua val extendsFromNames = actual.extendsFrom.map { it.name }.toSet() if (others.toSet() == extendsFromNames) return - expected( + this.expected( "to extend only from configuration(s) ${show(others)}, but extends from: ${show(extendsFromNames)}", actual = extendsFromNames, expected = others ) diff --git a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Container.kt b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Container.kt index 60f4b87..810f33d 100644 --- a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Container.kt +++ b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Container.kt @@ -8,13 +8,13 @@ import org.gradle.api.NamedDomainObjectCollection fun Assert>.containsItem(name: String) = transform(name = "${this.name}[\"$name\"]") { actual -> - actual.findByName(name) ?: expected("to contain an item named \"$name\"", actual = actual.names) + actual.findByName(name) ?: this.expected("to contain an item named \"$name\"", actual = actual.names) } fun Assert>.doesNotContainItem(name: String) = given { actual -> val item = actual.findByName(name) if (item != null) { - expected("to contain no item named \"$name\", but did contain: ${show(item)}", actual = actual.names) + this.expected("to contain no item named \"$name\", but did contain: ${show(item)}", actual = actual.names) } } diff --git a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Extension.kt b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Extension.kt index fa146db..4a5c0e8 100644 --- a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Extension.kt +++ b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Extension.kt @@ -11,32 +11,32 @@ import kotlin.reflect.KClass fun Assert.hasExtensionNamed(name: String): Assert = transform("extension \"$name\"") { actual -> if (actual !is ExtensionAware) { - expected("to be ExtensionAware") + this.expected("to be ExtensionAware") } actual.extensions.findByName(name) - ?: expected("to have an extension named \"$name\"") + ?: this.expected("to have an extension named \"$name\"") } inline fun Assert.hasExtension(name: String? = null): Assert = transform("extension " + (name?.let { "\"$it\"" } ?: show(E::class))) { actual -> if (actual !is ExtensionAware) { - expected("to be ExtensionAware") + this.expected("to be ExtensionAware") } val extensions = actual.extensions if (name != null) { val extension = extensions.findByName(name) - ?: expected("to have an extension named \"$name\" of type ${show(E::class)}") + ?: this.expected("to have an extension named \"$name\" of type ${show(E::class)}") (extension as? E) - ?: expected( + ?: this.expected( "to have an extension named \"$name\" of type ${show(E::class)}, " + "but actual type was: ${show(extension.javaClass)}" ) } else { extensions.findByType(E::class.java) - ?: expected("to have an extension of type ${show(E::class)}") + ?: this.expected("to have an extension of type ${show(E::class)}") } } @@ -44,12 +44,12 @@ inline fun Assert.hasExtension(name: String? = null): Ass fun Assert.hasConvention(type: KClass): Assert = transform("convention ${show(type)}") { actual -> if (actual !is HasConvention) { - expected("to support conventions") + this.expected("to support conventions") } actual.convention.findPlugin(type.java) - ?: expected("to have a convention plugin of type ${show(type)}") + ?: this.expected("to have a convention plugin of type ${show(type)}") } inline fun Assert.hasConvention(): Assert = - hasConvention(C::class) + this.hasConvention(C::class) diff --git a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/GradleProject.kt b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/GradleProject.kt index 8a2fa0d..21fe4e5 100644 --- a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/GradleProject.kt +++ b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/GradleProject.kt @@ -11,7 +11,7 @@ import kotlin.reflect.KClass private fun Assert.containsTaskInternal(taskName: String) = transform("task \"$taskName\"") { actual -> actual.tasks.findByName(taskName) - ?: expected("to contain a task named \"$taskName\"") + ?: this.expected("to contain a task named \"$taskName\"") } @@ -21,4 +21,4 @@ fun Assert.containsTask(taskName: String, taskType: KClass Assert.containsTask(taskName: String) = - containsTask(taskName, T::class) + this.containsTask(taskName, T::class) diff --git a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/GradleTask.kt b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/GradleTask.kt index 6965bc3..9bd20f7 100644 --- a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/GradleTask.kt +++ b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/GradleTask.kt @@ -18,7 +18,7 @@ val Assert.taskDependencies fun Assert.hasTaskDependency(taskName: String) = given { actual -> val dependencies = actual.taskDependencies.getDependencies(actual) if (dependencies.none { it.name == taskName }) { - expected("to have a dependency on task \"${taskName}\", but dependencies were: ${show(dependencies)}") + this.expected("to have a dependency on task \"${taskName}\", but dependencies were: ${show(dependencies)}") } } @@ -26,7 +26,7 @@ fun Assert.hasTaskDependency(taskName: String) = given { actual -> fun Assert.hasOnlyTaskDependency(taskName: String) = given { actual -> val dependencies = actual.taskDependencies.getDependencies(actual) if (dependencies.size != 1 || dependencies.firstOrNull()?.name != taskName) { - expected("to have a single dependency on task \"${taskName}\", but dependencies were: ${show(dependencies)}") + this.expected("to have a single dependency on task \"${taskName}\", but dependencies were: ${show(dependencies)}") } } @@ -49,20 +49,20 @@ fun Assert.hasTaskDependencies(vararg taskNames: String, exactly: Boolean fun Assert.doesNotHaveTaskDependency(taskName: String) = given { actual -> val dependencies = actual.taskDependencies.getDependencies(actual) if (dependencies.any { it.name == taskName }) { - expected("to have no dependency on task \"${taskName}\", but dependencies were: ${show(dependencies)}") + this.expected("to have no dependency on task \"${taskName}\", but dependencies were: ${show(dependencies)}") } } fun Assert.isSkipped() = given { actual -> if (!actual.isSkipped()) { - expected("to be skipped, but was not skipped") + this.expected("to be skipped, but was not skipped") } } fun Assert.isNotSkipped() = given { actual -> if (actual.isSkipped()) { - expected("not to be skipped, but was skipped") + this.expected("not to be skipped, but was skipped") } } diff --git a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Provider.kt b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Provider.kt index c27a072..09614ff 100644 --- a/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Provider.kt +++ b/src/test/kotlin/org/unbrokendome/gradle/plugins/xjc/testutil/assertions/Provider.kt @@ -14,31 +14,31 @@ import org.gradle.api.provider.Provider fun Assert>.isPresent() = transform { actual -> - actual.orNull ?: expected("${show(actual)} to have a value", actual = actual) + actual.orNull ?: this.expected("${show(actual)} to have a value", actual = actual) } fun Assert>.isTrue() = - isPresent().isTrue() + this.isPresent().isTrue() fun Assert>.isFalse() = - isPresent().isFalse() + this.isPresent().isFalse() fun Assert>.hasValueEqualTo(value: T) = - isPresent().isEqualTo(value) + this.isPresent().isEqualTo(value) fun Assert>.fileValue() = - isPresent() + this.isPresent() .prop("file") { it.asFile } fun Assert>.dirValue() = - isPresent() + this.isPresent() .prop("directory") { it.asFile } fun Assert>>.contains(key: K, value: V) = - isPresent().contains(key, value) + this.isPresent().contains(key, value)