diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-07-16 10:24:02 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-20 12:02:45 +0200 |
commit | 13edb873db122e2088207ca10b94382e30875636 (patch) | |
tree | 44b90392faac5069848b27f6c5084dbca61607fe /core/src/test/kotlin/utilities | |
parent | e7b50c6ba2102fc9a59a460172aa7a4d82ad08df (diff) | |
download | dokka-13edb873db122e2088207ca10b94382e30875636.tar.gz dokka-13edb873db122e2088207ca10b94382e30875636.tar.bz2 dokka-13edb873db122e2088207ca10b94382e30875636.zip |
Use jackson for json serialization and parsing
Diffstat (limited to 'core/src/test/kotlin/utilities')
-rw-r--r-- | core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt b/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt new file mode 100644 index 00000000..d0cb55a1 --- /dev/null +++ b/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt @@ -0,0 +1,68 @@ +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 = "customOutputDir", + pluginsClasspath = listOf(File("plugins/customPlugin.jar")), + sourceSets = listOf( + DokkaSourceSetImpl( + moduleDisplayName = "customModuleDisplayName", + sourceRoots = listOf(SourceRootImpl("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" + }, + "classpath": [], + "sourceRoots": [ + { + "path": "customSourceRoot" + } + ] + } + ] + } + """.trimIndent() + + val parsedConfiguration = DokkaConfigurationImpl(json) + assertEquals( + DokkaConfigurationImpl( + outputDir = "customOutputDir", + pluginsClasspath = listOf(File("plugins/customPlugin.jar")), + sourceSets = listOf( + DokkaSourceSetImpl( + moduleDisplayName = "customModuleDisplayName", + sourceRoots = listOf(SourceRootImpl("customSourceRoot")), + sourceSetID = DokkaSourceSetID("customModuleName", "customSourceSetName") + ) + ) + ), + parsedConfiguration + ) + } +} |