aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/kotlin/utilities')
-rw-r--r--core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt72
-rw-r--r--core/src/test/kotlin/utilities/JsonKtTest.kt80
2 files changed, 0 insertions, 152 deletions
diff --git a/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt b/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt
deleted file mode 100644
index c10cb32d..00000000
--- a/core/src/test/kotlin/utilities/DokkaConfigurationJsonTest.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package utilities
-
-import org.jetbrains.dokka.DokkaConfigurationImpl
-import org.jetbrains.dokka.DokkaSourceSetID
-import org.jetbrains.dokka.DokkaSourceSetImpl
-import org.jetbrains.dokka.toCompactJsonString
-import java.io.File
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class DokkaConfigurationJsonTest {
- @Test
- fun `simple configuration toJsonString then parseJson`() {
- val configuration = DokkaConfigurationImpl(
- moduleName = "moduleName",
- outputDir = File("customOutputDir"),
- pluginsClasspath = listOf(File("plugins/customPlugin.jar")),
- sourceSets = listOf(
- DokkaSourceSetImpl(
- sourceRoots = setOf(File("customSourceRoot")),
- sourceSetID = DokkaSourceSetID("customModuleName", "customSourceSetName")
- )
- )
- )
-
- val jsonString = configuration.toCompactJsonString()
- val parsedConfiguration = DokkaConfigurationImpl(jsonString)
- assertEquals(configuration, parsedConfiguration)
- }
-
- @Test
- fun `parse simple configuration json`() {
- val json = """
- {
- "moduleName": "moduleName",
- "outputDir": "customOutputDir",
- "pluginsClasspath": [ "plugins/customPlugin.jar" ],
- "sourceSets": [
- {
- "sourceSetID": {
- "scopeId": "customModuleName",
- "sourceSetName": "customSourceSetName"
- },
- "sourceRoots": [ "customSourceRoot" ],
- "classpath": [ "classpath/custom1.jar", "classpath/custom2.jar" ]
- }
- ]
- }
- """.trimIndent()
-
- val parsedConfiguration = DokkaConfigurationImpl(json)
- assertEquals(
- DokkaConfigurationImpl(
- moduleName = "moduleName",
- outputDir = File("customOutputDir"),
- pluginsClasspath = listOf(File("plugins/customPlugin.jar")),
- sourceSets = listOf(
- DokkaSourceSetImpl(
- sourceRoots = setOf(File("customSourceRoot")),
- sourceSetID = DokkaSourceSetID("customModuleName", "customSourceSetName"),
- classpath = listOf(File("classpath/custom1.jar"), File("classpath/custom2.jar"))
- )
- )
- ),
- parsedConfiguration
- )
- }
-}
diff --git a/core/src/test/kotlin/utilities/JsonKtTest.kt b/core/src/test/kotlin/utilities/JsonKtTest.kt
deleted file mode 100644
index c706de5f..00000000
--- a/core/src/test/kotlin/utilities/JsonKtTest.kt
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package utilities
-
-import org.jetbrains.dokka.utilities.parseJson
-import org.jetbrains.dokka.utilities.serializeAsCompactJson
-import org.jetbrains.dokka.utilities.serializeAsPrettyJson
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class JsonTest {
-
- @Test
- fun `should serialize an object as compact json`() {
- val testObject = SimpleTestDataClass(
- someString = "Foo",
- someInt = 42,
- someDouble = 42.0
- )
-
- val actual = serializeAsCompactJson(testObject)
- val expected = "{\"someString\":\"Foo\",\"someInt\":42,\"someIntWithDefaultValue\":42,\"someDouble\":42.0}"
-
- assertEquals(expected, actual)
- }
-
- @Test
- fun `should serialize an object as pretty json`() {
- val testObject = SimpleTestDataClass(
- someString = "Foo",
- someInt = 42,
- someDouble = 42.0
- )
-
- val actual = serializeAsPrettyJson(testObject)
-
- val expected = """
- {
- "someString" : "Foo",
- "someInt" : 42,
- "someIntWithDefaultValue" : 42,
- "someDouble" : 42.0
- }""".trimIndent().withSystemLineSeparator()
-
- assertEquals(expected, actual)
- }
-
- @Test
- fun `should keep order of Set after serialize and deserialize`() {
- val testObject = SimpleTestSetDataClass(
- someStringSet = setOf("Foo", "Bar", "ABC")
- )
- val expected = testObject.someStringSet.toList() // ["Foo", "Bar", "ABC"]
-
- val jsonString = serializeAsCompactJson(testObject)
- val parsedClass: SimpleTestSetDataClass = parseJson(jsonString)
- val actual = parsedClass.someStringSet.toList()
-
- assertEquals(expected, actual)
- }
-
- /**
- * If the expected output was generated on Linux, but the tests are run under Windows,
- * the test might fail when comparing the strings due to different separators.
- */
- private fun String.withSystemLineSeparator(): String = this.replace("\n", System.lineSeparator())
-}
-
-data class SimpleTestDataClass(
- val someString: String,
- val someInt: Int,
- val someIntWithDefaultValue: Int = 42,
- val someDouble: Double
-)
-
-data class SimpleTestSetDataClass(
- val someStringSet: Set<String>
-)