aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src/test
diff options
context:
space:
mode:
authorMarcin Aman <maman@virtuslab.com>2020-07-06 17:00:13 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-07-13 14:48:27 +0200
commit6377d964819f937bd4a7633488d69edc327542d8 (patch)
tree5e52cf65cfce31de9a1500d08a9bfe25deb00a90 /plugins/kotlin-as-java/src/test
parentd180633e91afd76de788a0bd1bfe75fe09f19aea (diff)
downloaddokka-6377d964819f937bd4a7633488d69edc327542d8.tar.gz
dokka-6377d964819f937bd4a7633488d69edc327542d8.tar.bz2
dokka-6377d964819f937bd4a7633488d69edc327542d8.zip
Java sources in Kotlin-As-Java plugin should have original property visibilites
Diffstat (limited to 'plugins/kotlin-as-java/src/test')
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt107
1 files changed, 107 insertions, 0 deletions
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
index 96446201..ba513bf2 100644
--- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
+++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
@@ -1,9 +1,11 @@
package kotlinAsJavaPlugin
+import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.junit.jupiter.api.Test
+import matchers.content.*
class KotlinAsJavaPluginTest : AbstractCoreTest() {
@@ -130,6 +132,111 @@ class KotlinAsJavaPluginTest : AbstractCoreTest() {
}
}
+ @Test
+ fun `public kotlin properties should have a getter with same visibilities`(){
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ }
+ }
+ }
+ testInline(
+ """
+ |/src/main/kotlin/kotlinAsJavaPlugin/Test.kt
+ |package kotlinAsJavaPlugin
+ |
+ |class Test {
+ | public val publicProperty: String = ""
+ |}
+ """,
+ configuration,
+ cleanupOutput = true
+ ) {
+ pagesTransformationStage = { rootPageNode ->
+ val propertyGetter = rootPageNode.dfs { it is MemberPageNode && it.name == "getPublicProperty" } as? MemberPageNode
+ assert(propertyGetter != null)
+ propertyGetter!!.content.assertNode {
+ group {
+ header(1) {
+ +"getPublicProperty"
+ }
+ }
+ divergentGroup {
+ divergentInstance {
+ divergent {
+ group {
+ +"final"
+ group {
+ link {
+ +" String"
+ }
+ }
+ group {
+ link {
+ +"getPublicProperty"
+ }
+ +"()"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `java properties should keep its modifiers`(){
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ }
+ }
+ }
+ testInline(
+ """
+ |/src/main/kotlin/kotlinAsJavaPlugin/TestJ.java
+ |package kotlinAsJavaPlugin
+ |
+ |class TestJ {
+ | public Int publicProperty = 1;
+ |}
+ """,
+ configuration,
+ cleanupOutput = true
+ ) {
+ pagesGenerationStage = { root ->
+ val testClass = root.dfs { it.name == "TestJ" } as? ClasslikePageNode
+ assert(testClass != null)
+ (testClass!!.content as ContentGroup).children.last().assertNode {
+ group {
+ header(2){
+ +"Properties"
+ }
+ table {
+ group {
+ link {
+ +"publicProperty"
+ }
+ platformHinted {
+ group {
+ +"public Int"
+ link {
+ +"publicProperty"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
private fun <T> Collection<T>.assertCount(n: Int, prefix: String = "") =
assert(count() == n) { "${prefix}Expected $n, got ${count()}" }