aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt
blob: 8efc84c6514bf182268ea3c010b2b666ebacac01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package utilities

import org.jetbrains.dokka.*
import java.io.File
import kotlin.test.Test
import kotlin.test.assertEquals

class DokkaConfigurationJsonTest {
    @Test
    fun `simple configuration toJsonString then parseJson`() {
        val configuration = DokkaConfigurationImpl(
            outputDir = File("customOutputDir"),
            pluginsClasspath = listOf(File("plugins/customPlugin.jar")),
            sourceSets = listOf(
                DokkaSourceSetImpl(
                    moduleDisplayName = "customModuleDisplayName",
                    sourceRoots = setOf(File("customSourceRoot")),
                    sourceSetID = DokkaSourceSetID("customModuleName", "customSourceSetName")
                )
            )
        )

        val jsonString = configuration.toJsonString()
        val parsedConfiguration = DokkaConfigurationImpl(jsonString)
        assertEquals(configuration, parsedConfiguration)
    }

    @Test
    fun `parse simple configuration json`() {
        val json = """
            {
              "outputDir": "customOutputDir",
              "pluginsClasspath": [ "plugins/customPlugin.jar" ],
              "sourceSets": [
                {
                  "moduleDisplayName": "customModuleDisplayName",
                  "sourceSetID": {
                    "moduleName": "customModuleName",
                    "sourceSetName": "customSourceSetName"
                  },
                  "sourceRoots": [ "customSourceRoot" ], 
                  "classpath": [ "classpath/custom1.jar", "classpath/custom2.jar" ]
                }
              ]
            }
        """.trimIndent()

        val parsedConfiguration = DokkaConfigurationImpl(json)
        assertEquals(
            DokkaConfigurationImpl(
                outputDir = File("customOutputDir"),
                pluginsClasspath = listOf(File("plugins/customPlugin.jar")),
                sourceSets = listOf(
                    DokkaSourceSetImpl(
                        moduleDisplayName = "customModuleDisplayName",
                        sourceRoots = setOf(File("customSourceRoot")),
                        sourceSetID = DokkaSourceSetID("customModuleName", "customSourceSetName"),
                        classpath = listOf(File("classpath/custom1.jar"), File("classpath/custom2.jar"))
                    )
                )
            ),
            parsedConfiguration
        )
    }
}