aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/content/seealso
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test/kotlin/content/seealso')
-rw-r--r--plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt80
1 files changed, 80 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt
index 911066fc..e9a54e87 100644
--- a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt
+++ b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt
@@ -4,6 +4,11 @@ import matchers.content.*
import org.jetbrains.dokka.pages.ContentDRILink
import org.jetbrains.dokka.pages.ContentPage
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
+import org.jetbrains.dokka.links.Callable
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.links.JavaClassReference
+import org.jetbrains.dokka.model.doc.See
+import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import org.junit.jupiter.api.Test
import utils.*
import kotlin.test.assertEquals
@@ -469,4 +474,79 @@ class ContentForSeeAlsoTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `undocumented see also from java`(){
+ testInline(
+ """
+ |/src/main/java/example/Source.java
+ |package example;
+ |
+ |public interface Source {
+ | String getProperty(String k, String v);
+ |
+ | /**
+ | * @see #getProperty(String, String)
+ | */
+ | String getProperty(String k);
+ |}
+ """.trimIndent(), testConfiguration
+ ) {
+ documentablesTransformationStage = { module ->
+ val functionWithSeeTag = module.packages.flatMap { it.classlikes }.flatMap { it.functions }.find { it.name == "getProperty" && it.parameters.count() == 1 }
+ val seeTag = functionWithSeeTag?.docs()?.firstIsInstanceOrNull<See>()
+ val expectedLinkDestinationDRI = DRI(
+ packageName = "example",
+ classNames = "Source",
+ callable = Callable(
+ name = "getProperty",
+ params = listOf(JavaClassReference("java.lang.String"), JavaClassReference("java.lang.String"))
+ )
+ )
+
+ kotlin.test.assertNotNull(seeTag)
+ assertEquals("getProperty(String, String)", seeTag.name)
+ assertEquals(expectedLinkDestinationDRI, seeTag.address)
+ assertEquals(emptyList(), seeTag.children)
+ }
+ }
+ }
+
+ @Test
+ fun `documented see also from java`(){
+ testInline(
+ """
+ |/src/main/java/example/Source.java
+ |package example;
+ |
+ |public interface Source {
+ | String getProperty(String k, String v);
+ |
+ | /**
+ | * @see #getProperty(String, String) this is a reference to a method that is present on the same class.
+ | */
+ | String getProperty(String k);
+ |}
+ """.trimIndent(), testConfiguration
+ ) {
+ documentablesTransformationStage = { module ->
+ val functionWithSeeTag = module.packages.flatMap { it.classlikes }.flatMap { it.functions }.find { it.name == "getProperty" && it.parameters.size == 1 }
+ val seeTag = functionWithSeeTag?.docs()?.firstIsInstanceOrNull<See>()
+ val expectedLinkDestinationDRI = DRI(
+ packageName = "example",
+ classNames = "Source",
+ callable = Callable(
+ name = "getProperty",
+ params = listOf(JavaClassReference("java.lang.String"), JavaClassReference("java.lang.String"))
+ )
+ )
+
+ kotlin.test.assertNotNull(seeTag)
+ assertEquals("getProperty(String, String)", seeTag.name)
+ assertEquals(expectedLinkDestinationDRI, seeTag.address)
+ assertEquals("this is a reference to a method that is present on the same class.", seeTag.children.first().text().trim())
+ assertEquals(1, seeTag.children.size)
+ }
+ }
+ }
}