aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc/src/test
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-06-30 09:48:14 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-01 09:43:03 +0200
commitfac44e07465a57bd95a08379caf6ec1f767e8ec7 (patch)
tree35dd8c7aa3e711678571534dbacd31a3b136edf3 /plugins/javadoc/src/test
parenta16e101fad10d024a84aa36069ec6032fcbaf3e6 (diff)
downloaddokka-fac44e07465a57bd95a08379caf6ec1f767e8ec7.tar.gz
dokka-fac44e07465a57bd95a08379caf6ec1f767e8ec7.tar.bz2
dokka-fac44e07465a57bd95a08379caf6ec1f767e8ec7.zip
Implement first simple JavadocModuleTemplateMapTest.kt
Diffstat (limited to 'plugins/javadoc/src/test')
-rw-r--r--plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt43
-rw-r--r--plugins/javadoc/src/test/kotlin/javadoc/JavadocModuleTemplateMapTest.kt70
2 files changed, 106 insertions, 7 deletions
diff --git a/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt
index 7b31d064..30082092 100644
--- a/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt
+++ b/plugins/javadoc/src/test/kotlin/javadoc/AbstractJavadocTemplateMapTest.kt
@@ -65,5 +65,48 @@ internal abstract class AbstractJavadocTemplateMapTest : AbstractCoreTest() {
}
}
}
+
+ fun dualTestTemplateMapInline(
+ kotlin: String? = null,
+ java: String? = null,
+ configuration: DokkaConfigurationImpl = config,
+ assertions: Result.() -> Unit
+ ) {
+ val kotlinException = kotlin?.let {
+ runCatching {
+ testTemplateMapInline(
+ query = kotlin,
+ configuration = configuration,
+ assertions = assertions
+ )
+ }.exceptionOrNull()
+ }
+
+ val javaException = java?.let {
+ runCatching {
+ testTemplateMapInline(
+ query = java,
+ configuration = configuration,
+ assertions = assertions
+ )
+ }.exceptionOrNull()
+ }
+
+ if (kotlinException != null && javaException != null) {
+ throw AssertionError("Kotlin and Java Code failed assertions\n" +
+ "Kotlin: ${kotlinException.message}\n" +
+ "Java: ${javaException.message}",
+ kotlinException
+ )
+ }
+
+ if (kotlinException != null) {
+ throw AssertionError("Kotlin Code failed assertions", kotlinException)
+ }
+
+ if (javaException != null) {
+ throw AssertionError("Java Code failed assertions", javaException)
+ }
+ }
}
diff --git a/plugins/javadoc/src/test/kotlin/javadoc/JavadocModuleTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/javadoc/JavadocModuleTemplateMapTest.kt
index 732454f7..4f9194d7 100644
--- a/plugins/javadoc/src/test/kotlin/javadoc/JavadocModuleTemplateMapTest.kt
+++ b/plugins/javadoc/src/test/kotlin/javadoc/JavadocModuleTemplateMapTest.kt
@@ -1,22 +1,78 @@
package javadoc
import javadoc.pages.JavadocModulePageNode
+import javadoc.pages.RowJavadocListEntry
+import org.jetbrains.dokka.links.DRI
+import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
+import testApi.utils.assertIsInstance
internal class JavadocModuleTemplateMapTest : AbstractJavadocTemplateMapTest() {
@Test
- fun simpleKotlinExample() {
- testTemplateMapInline(
+ fun singleEmptyClass() {
+ dualTestTemplateMapInline(
+ kotlin =
"""
/src/source.kt
- package test
+ package com.test.package
class Test
- """.trimIndent(),
- config
+ """,
+ java =
+ """
+ /src/com/test/package/Source.java
+ package com.test.package
+ public class Test { }
+ """
+ ) {
+ val moduleTemplateMap = singlePageOfType<JavadocModulePageNode>().templateMap
+ assertEquals("main", moduleTemplateMap["kind"])
+ assertEquals("root", moduleTemplateMap["title"])
+ assertEquals("", moduleTemplateMap["subtitle"])
+ assertEquals("Packages", moduleTemplateMap["tabTitle"])
+ assertEquals("Package", moduleTemplateMap["colTitle"])
+ assertEquals("", moduleTemplateMap["pathToRoot"])
+
+ val list = moduleTemplateMap["list"] as List<*>
+ assertEquals(1, list.size, "Expected only one entry in 'list'")
+ val rowListEntry = assertIsInstance<RowJavadocListEntry>(list.first())
+
+ assertEquals("com.test", rowListEntry.link.name)
+ assertEquals(DRI("com.test"), rowListEntry.link.dri.single())
+ }
+ }
+
+ @Test
+ fun multiplePackages() {
+ dualTestTemplateMapInline(
+ kotlin =
+ """
+ /src/source0.kt
+ package com.test.package0
+ class Test0
+
+ /src/source1.kt
+ package com.test.package1
+ class Test1
+ """,
+ java =
+ """
+ /src/com/test/package0/Test0.java
+ package com.test.package0
+ public class Test0 {}
+
+ /src/com/test/package1/Test1.java
+ package com.test.package1
+ public class Test1 {}
+ """
) {
- val moduleContentMap = singlePageOfType<JavadocModulePageNode>().templateMap
- println("module")
+ val moduleTemplateMap = singlePageOfType<JavadocModulePageNode>().templateMap
+ val list = assertIsInstance<List<*>>(moduleTemplateMap["list"])
+ assertEquals(2, list.size, "Expected two entries in 'list'")
+ assertEquals("com.test.package0", assertIsInstance<RowJavadocListEntry>(list[0]).link.name)
+ assertEquals("com.test.package1", assertIsInstance<RowJavadocListEntry>(list[1]).link.name)
+ assertEquals(DRI("com.test.package0"), assertIsInstance<RowJavadocListEntry>(list[0]).link.dri.single())
+ assertEquals(DRI("com.test.package1"), assertIsInstance<RowJavadocListEntry>(list[1]).link.dri.single())
}
}
}