aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/kotlin-as-java/src/test')
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt54
1 files changed, 50 insertions, 4 deletions
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
index 635abf5a..b77dc23c 100644
--- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
+++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
@@ -176,7 +176,7 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
divergentInstance {
divergent {
group {
- +"final "
+ +"public final "
group {
link {
+"String"
@@ -331,7 +331,7 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/kotlinAsJavaPlugin/-a-b-c/some-fun.html").firstSignature().match(
- "final ", A("Integer"), A("someFun"), "(", Parameters(
+ "public final ", A("Integer"), A("someFun"), "(", Parameters(
Parameter(A("Integer"), "xd")
), ")", Span(), ignoreSpanWithTokenStyle = true
)
@@ -370,7 +370,7 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/kotlinAsJavaPlugin/-a-b-c/some-fun.html").firstSignature().match(
- "final ", A("Integer"), A("someFun"), "(", Parameters(
+ "public final ", A("Integer"), A("someFun"), "(", Parameters(
Parameter(A("Map"), "<", A("String"), ", ", A("Integer"), "> xd"),
), ")", Span(), ignoreSpanWithTokenStyle = true
)
@@ -436,7 +436,7 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/kotlinAsJavaPlugin/-test-kt/sample.html").firstSignature().match(
- "final static ", A("String"), A("sample"), "(", Parameters(
+ "public final static ", A("String"), A("sample"), "(", Parameters(
Parameter(A("Integer"), "a"),
), ")", Span(), ignoreSpanWithTokenStyle = true
)
@@ -583,6 +583,52 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `Java function should keep its access modifier`(){
+ val className = "Test"
+ val accessModifier = "public"
+ val methodName = "method"
+
+ val testClassQuery = """
+ |/src/main/kotlin/kotlinAsJavaPlugin/${className}.java
+ |package kotlinAsJavaPlugin;
+ |
+ |public class $className {
+ | $accessModifier void ${methodName}() {
+ |
+ | }
+ |}
+ """.trimMargin()
+
+ val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ }
+ }
+ }
+
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ testClassQuery,
+ configuration,
+ pluginOverrides = listOf(writerPlugin),
+ cleanupOutput = true
+ ) {
+ renderingStage = { _, _ ->
+ val methodDocumentation = "root/kotlinAsJavaPlugin/-${className.toLowerCase()}/${methodName}.html"
+
+ writerPlugin.writer.renderedContent(methodDocumentation)
+ .firstSignature()
+ .match(
+ "$accessModifier void ", A(methodName), "()", Span(),
+ ignoreSpanWithTokenStyle = true
+ )
+ }
+ }
+ }
}
private val ContentNode.mainContents: List<ContentNode>