aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-08-14 14:59:04 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-19 13:34:10 +0200
commitc4e4343bdb8df16e49d4da118fccc076abdc928a (patch)
tree19113d8630d6a24507184876e9d064ec833bc965 /plugins/base/src/test/kotlin
parent28d6598bc749612f75a5c1a4210eb4b0f5aa1f6e (diff)
downloaddokka-c4e4343bdb8df16e49d4da118fccc076abdc928a.tar.gz
dokka-c4e4343bdb8df16e49d4da118fccc076abdc928a.tar.bz2
dokka-c4e4343bdb8df16e49d4da118fccc076abdc928a.zip
Respect relocated declarations
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt52
1 files changed, 52 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt b/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt
new file mode 100644
index 00000000..280fcc24
--- /dev/null
+++ b/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt
@@ -0,0 +1,52 @@
+package locationProvider
+
+import org.jetbrains.dokka.base.resolvers.external.Dokka010ExternalLocationProvider
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation
+import org.jetbrains.dokka.base.resolvers.shared.PackageList
+import org.jetbrains.dokka.links.Callable
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
+import java.net.URL
+
+class Dokka010ExternalLocationProviderTest : AbstractCoreTest() {
+ private val testDataDir = getTestDataDir("locationProvider").toAbsolutePath()
+ private val kotlinLang = "https://kotlinlang.org/api/latest/jvm/stdlib"
+ private val packageListURL = URL("file://$testDataDir/old-package-list")
+ private val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ classpath += jvmStdlibPath!!
+ externalDocumentationLink(kotlinLang, packageListURL.toString())
+ }
+ }
+ }
+
+ private fun getTestLocationProvider(context: DokkaContext? = null): Dokka010ExternalLocationProvider {
+ val dokkaContext = context ?: DokkaContext.create(configuration, logger, emptyList())
+ val packageList = PackageList.load(packageListURL, 8, true)!!
+ val externalDocumentation =
+ ExternalDocumentation(URL(kotlinLang), packageList)
+ return Dokka010ExternalLocationProvider(externalDocumentation, ".html", dokkaContext)
+ }
+
+ @Test
+ fun `ordinary link`() {
+ val locationProvider = getTestLocationProvider()
+ val dri = DRI("kotlin.reflect", "KVisibility")
+
+ assertEquals("$kotlinLang/kotlin.reflect/-k-visibility/index.html", locationProvider.resolve(dri))
+ }
+
+ @Test
+ fun `relocation in package list`() {
+ val locationProvider = getTestLocationProvider()
+ val dri = DRI("kotlin.text", "StringBuilder")
+
+ assertEquals("$kotlinLang/kotlin.relocated.text/-string-builder/index.html", locationProvider.resolve(dri))
+ }
+}