aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc/src/test/kotlin/org
diff options
context:
space:
mode:
authorCharlesG-Branch <43424788+CharlesG-Branch@users.noreply.github.com>2022-02-18 07:39:33 -0500
committerGitHub <noreply@github.com>2022-02-18 15:39:33 +0300
commitdf4780c31026aaa626746f49f0e6fa3fa0278a05 (patch)
tree5d562bcbf2240d8a1bd50ef5f97040088b68f781 /plugins/javadoc/src/test/kotlin/org
parent9a1434d583b931671e2c5e9c5275af725938d503 (diff)
downloaddokka-df4780c31026aaa626746f49f0e6fa3fa0278a05.tar.gz
dokka-df4780c31026aaa626746f49f0e6fa3fa0278a05.tar.bz2
dokka-df4780c31026aaa626746f49f0e6fa3fa0278a05.zip
Fix java getter / setter name generation (#2356)
Kotlin has special rules for conversion around properties that start with "is" For more info see: https://kotlinlang.org/docs/java-interop.html#getters-and-setters https://kotlinlang.org/docs/java-to-kotlin-interop.html#properties
Diffstat (limited to 'plugins/javadoc/src/test/kotlin/org')
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt80
1 files changed, 80 insertions, 0 deletions
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt
new file mode 100644
index 00000000..edb0bd6b
--- /dev/null
+++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocAccessorNamingTest.kt
@@ -0,0 +1,80 @@
+package org.jetbrains.dokka.javadoc
+
+import org.jsoup.Jsoup
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.Assertions.assertEquals
+import utils.*
+
+internal class JavadocAccessorNamingTest : AbstractJavadocTemplateMapTest() {
+
+ val configuration = dokkaConfiguration {
+ suppressObviousFunctions = true
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/main/kotlin")
+ }
+ }
+ }
+
+ /**
+ * This is a quick sanity check for the AccessorMethodNamingTest
+ */
+ @Test
+ fun verifySpecialIsRuleIsApplied() {
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ """
+ /src/main/kotlin/sample/TestCase.kt
+ package sample
+
+ /**
+ * Test links:
+ * - [TestCase.issuesFetched]
+ * - [TestCase.isFoo]
+ */
+ data class TestCase(
+ var issuesFetched: Int,
+ var isFoo: String,
+ )
+ """.trimIndent(),
+ configuration,
+ cleanupOutput = false,
+ pluginOverrides = listOf(writerPlugin, JavadocPlugin())
+ ) {
+ renderingStage = { _, _ ->
+ val html = writerPlugin.writer.contents["sample/TestCase.html"].let { Jsoup.parse(it) }
+ val props = html
+ .select("#memberSummary_tabpanel")
+ .select("th[scope=row].colSecond")
+ .select("code")
+ .map { it.text() }
+ .toSet()
+
+ assertEquals(setOf(
+ "getIssuesFetched()",
+ "setIssuesFetched(Integer issuesFetched)",
+ "isFoo()",
+ "setFoo(String isFoo)",
+ ), props)
+
+ val descriptionLinks = html
+ .select("div.description")
+ .select("p")
+ .select("a")
+ .eachAttr("href")
+ .map { a -> a.takeLastWhile { it != '#' } }
+
+ assertEquals(setOf(
+ "issuesFetched",
+ "isFoo()",
+ ), descriptionLinks.toSet())
+
+ // Make sure that the ids from above actually exist
+ assertEquals(1, html.select("[id = isFoo()]").size)
+ // Bug! Nothing in the doc has the right id
+ assertEquals(0, html.select("[id = issuesFetched]").size)
+ }
+ }
+ }
+} \ No newline at end of file