diff --git a/.github/workflows/compatibility-test.yml b/.github/workflows/compatibility-test.yml index 54058995..afe5fed3 100644 --- a/.github/workflows/compatibility-test.yml +++ b/.github/workflows/compatibility-test.yml @@ -16,7 +16,7 @@ jobs: compatibility: strategy: matrix: - version: ['kotlin-1.9.24', 'kotlin-2.0.0', 'kotlin-2.0.20-Beta1', 'java'] + version: ['kotlin-1.9.24', 'kotlin-2.0.0', 'kotlin-2.0.20-RC', 'java'] name: Compatibility permissions: pull-requests: read diff --git a/gradle-plugin/src/main/kotlin/tech/mappie/MappieGradlePlugin.kt b/gradle-plugin/src/main/kotlin/tech/mappie/MappieGradlePlugin.kt index cf2ac36d..c827f9b1 100644 --- a/gradle-plugin/src/main/kotlin/tech/mappie/MappieGradlePlugin.kt +++ b/gradle-plugin/src/main/kotlin/tech/mappie/MappieGradlePlugin.kt @@ -74,6 +74,10 @@ class MappieGradlePlugin : KotlinCompilerPluginSupportPlugin { private companion object { private const val KOTLIN_GRADLE_PLUGIN_NAME = "kotlin-gradle-plugin" - private val SUPPORTED_KOTLIN_VERSIONS = listOf("1.9.24", "2.0.0", "2.0.20-Beta1") + private val SUPPORTED_KOTLIN_VERSIONS = listOf( + "1.9.24", + "2.0.0", + "2.0.20-RC", + ) } } \ No newline at end of file diff --git a/test/kotlin-2.0.20-Beta1/.gitignore b/test/kotlin-2.0.20-RC/.gitignore similarity index 100% rename from test/kotlin-2.0.20-Beta1/.gitignore rename to test/kotlin-2.0.20-RC/.gitignore diff --git a/test/kotlin-2.0.20-Beta1/build.gradle.kts b/test/kotlin-2.0.20-RC/build.gradle.kts similarity index 86% rename from test/kotlin-2.0.20-Beta1/build.gradle.kts rename to test/kotlin-2.0.20-RC/build.gradle.kts index 6ec0df3c..195cb99d 100644 --- a/test/kotlin-2.0.20-Beta1/build.gradle.kts +++ b/test/kotlin-2.0.20-RC/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.jetbrains.kotlin.jvm") version "2.0.20-Beta1" + id("org.jetbrains.kotlin.jvm") version "2.0.20-RC" id("tech.mappie.plugin") version "+" } diff --git a/test/kotlin-2.0.20-Beta1/gradle/gradle-daemon-jvm.properties b/test/kotlin-2.0.20-RC/gradle/gradle-daemon-jvm.properties similarity index 100% rename from test/kotlin-2.0.20-Beta1/gradle/gradle-daemon-jvm.properties rename to test/kotlin-2.0.20-RC/gradle/gradle-daemon-jvm.properties diff --git a/test/kotlin-2.0.20-Beta1/gradle/wrapper/gradle-wrapper.jar b/test/kotlin-2.0.20-RC/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from test/kotlin-2.0.20-Beta1/gradle/wrapper/gradle-wrapper.jar rename to test/kotlin-2.0.20-RC/gradle/wrapper/gradle-wrapper.jar diff --git a/test/kotlin-2.0.20-Beta1/gradle/wrapper/gradle-wrapper.properties b/test/kotlin-2.0.20-RC/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from test/kotlin-2.0.20-Beta1/gradle/wrapper/gradle-wrapper.properties rename to test/kotlin-2.0.20-RC/gradle/wrapper/gradle-wrapper.properties diff --git a/test/kotlin-2.0.20-Beta1/gradlew b/test/kotlin-2.0.20-RC/gradlew old mode 100755 new mode 100644 similarity index 100% rename from test/kotlin-2.0.20-Beta1/gradlew rename to test/kotlin-2.0.20-RC/gradlew diff --git a/test/kotlin-2.0.20-Beta1/gradlew.bat b/test/kotlin-2.0.20-RC/gradlew.bat similarity index 100% rename from test/kotlin-2.0.20-Beta1/gradlew.bat rename to test/kotlin-2.0.20-RC/gradlew.bat diff --git a/test/kotlin-2.0.20-Beta1/settings.gradle.kts b/test/kotlin-2.0.20-RC/settings.gradle.kts similarity index 79% rename from test/kotlin-2.0.20-Beta1/settings.gradle.kts rename to test/kotlin-2.0.20-RC/settings.gradle.kts index 2dbf85e3..846d7d07 100644 --- a/test/kotlin-2.0.20-Beta1/settings.gradle.kts +++ b/test/kotlin-2.0.20-RC/settings.gradle.kts @@ -1,4 +1,4 @@ -rootProject.name = "mappie-test-kotlin-2.0.20-Beta1" +rootProject.name = "mappie-test-kotlin-2.0.20-RC" pluginManagement { repositories { diff --git a/test/kotlin-2.0.20-RC/src/main/kotlin/EnumMapping.kt b/test/kotlin-2.0.20-RC/src/main/kotlin/EnumMapping.kt new file mode 100644 index 00000000..69903de9 --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/main/kotlin/EnumMapping.kt @@ -0,0 +1,11 @@ +import tech.mappie.api.EnumMappie + +enum class InputEnum { + A, B, C, D; +} + +enum class OutputEnum { + A, B, C, D, E; +} + +object EnumMapper : EnumMappie() \ No newline at end of file diff --git a/test/kotlin-2.0.20-RC/src/main/kotlin/GeneratedEnumMapper.kt b/test/kotlin-2.0.20-RC/src/main/kotlin/GeneratedEnumMapper.kt new file mode 100644 index 00000000..98f428ab --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/main/kotlin/GeneratedEnumMapper.kt @@ -0,0 +1,15 @@ +import tech.mappie.api.ObjectMappie + +data class NestedGeneratedInputObject(val enum: InputEnumTwo) + +enum class InputEnumTwo { + A, B, C, D; +} + +data class NestedGeneratedOutputObject(val enum: OutputEnumTwo) + +enum class OutputEnumTwo { + A, B, C, D, E; +} + +object NestedGeneratedInputToOutputMapper : ObjectMappie() \ No newline at end of file diff --git a/test/kotlin-2.0.20-RC/src/main/kotlin/ObjectMapper.kt b/test/kotlin-2.0.20-RC/src/main/kotlin/ObjectMapper.kt new file mode 100644 index 00000000..01d865c0 --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/main/kotlin/ObjectMapper.kt @@ -0,0 +1,36 @@ +import tech.mappie.api.ObjectMappie + +data class InputObject( + val name: String, + val age: Int, + val nested: NestedInput, +) + +data class NestedInput(val boolean: BooleanEnum) { + enum class BooleanEnum { TRUE, FALSE } +} + +data class OutputObject( + val name: String, + val age: Int, + val boolean: Boolean, +) + +object ObjectMapperWithoutVia : ObjectMappie() { + override fun map(from: InputObject) = mapping { + to::boolean fromProperty from.nested::boolean + } +} + +object ObjectMapper : ObjectMappie() { + override fun map(from: InputObject) = mapping { + to::boolean fromProperty from.nested::boolean via BooleanEnumToBooleanMapper + } +} + +object BooleanEnumToBooleanMapper : ObjectMappie() { + override fun map(from: NestedInput.BooleanEnum) = when (from) { + NestedInput.BooleanEnum.TRUE -> !false + NestedInput.BooleanEnum.FALSE -> !true + } +} diff --git a/test/kotlin-2.0.20-RC/src/test/kotlin/EnumMapperTest.kt b/test/kotlin-2.0.20-RC/src/test/kotlin/EnumMapperTest.kt new file mode 100644 index 00000000..b368d6b7 --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/test/kotlin/EnumMapperTest.kt @@ -0,0 +1,21 @@ +import kotlin.test.Test +import kotlin.test.assertEquals + +class EnumMapperTest { + + private val mappings = listOf( + InputEnum.A to OutputEnum.A, + InputEnum.B to OutputEnum.B, + InputEnum.C to OutputEnum.C, + InputEnum.D to OutputEnum.D, + ) + + @Test + fun `map InputEnum to OutputEnum`() { + mappings.forEach { (input, expected) -> + assertEquals( + EnumMapper.map(input), expected + ) + } + } +} \ No newline at end of file diff --git a/test/kotlin-2.0.20-RC/src/test/kotlin/NestedGeneratedEnumMapperTest.kt b/test/kotlin-2.0.20-RC/src/test/kotlin/NestedGeneratedEnumMapperTest.kt new file mode 100644 index 00000000..a0b8d9be --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/test/kotlin/NestedGeneratedEnumMapperTest.kt @@ -0,0 +1,22 @@ +import kotlin.test.Test +import kotlin.test.assertEquals + +class NestedGeneratedEnumMapperTest { + + private val mappings = listOf( + InputEnumTwo.A to OutputEnumTwo.A, + InputEnumTwo.B to OutputEnumTwo.B, + InputEnumTwo.C to OutputEnumTwo.C, + InputEnumTwo.D to OutputEnumTwo.D, + ) + + @Test + fun `map NestedGeneratedInputObject to NestedGeneratedOutputObject`() { + mappings.forEach { (input, expected) -> + assertEquals( + NestedGeneratedInputToOutputMapper.map(NestedGeneratedInputObject(input)), + NestedGeneratedOutputObject(expected) + ) + } + } +} diff --git a/test/kotlin-2.0.20-RC/src/test/kotlin/ObjectMapperTest.kt b/test/kotlin-2.0.20-RC/src/test/kotlin/ObjectMapperTest.kt new file mode 100644 index 00000000..38c9dcb4 --- /dev/null +++ b/test/kotlin-2.0.20-RC/src/test/kotlin/ObjectMapperTest.kt @@ -0,0 +1,13 @@ +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals + +class ObjectMapperTest { + + @Test + fun `map using ObjectMapper`() { + assertEquals( + OutputObject("name", 22, true), + ObjectMapper.map(InputObject("name", 22, NestedInput(NestedInput.BooleanEnum.TRUE))) + ) + } +} \ No newline at end of file