From 00a3ff1486a620191604f91be016d7e02535ec44 Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Wed, 3 Jul 2024 17:57:25 +0200 Subject: [PATCH] Fixed bugs and structured tests --- .../mappie/generation/MappieIrTransformer.kt | 7 +++- .../classes/ObjectMappingBodyCollector.kt | 2 +- ...=> MapperClassCanContainPropertiesTest.kt} | 4 +- ...sCanContainPropertiesUsedInForListTest.kt} | 4 +- .../EnumsWithDifferentEntriesTest.kt | 10 +++-- .../{ => enums}/EnumsWithSameEntriesTest.kt | 8 ++-- .../{ => enums}/ObjectWithNestedEnumTest.kt | 5 ++- .../ObjectWithNestedNullableEnumTest.kt | 7 ++-- .../NonNullListToNullListTest.kt} | 19 +++++---- .../NullToNonNullTest.kt} | 10 +++-- .../{ => lists}/ObjectWithNestedListTest.kt | 5 ++- .../mappie/testing/{ => lists}/ViaListTest.kt | 5 ++- .../ConstructorParameterNotAFieldTest.kt | 8 ++-- .../{ => objects}/ConstructorSelectionTest.kt | 7 ++-- .../DefaultValueTest.kt} | 7 ++-- .../{ => objects}/FromExpressionTest.kt | 5 ++- .../testing/{ => objects}/FromValueTest.kt | 5 ++- .../NestedNonNullToNullPropertyTest.kt} | 11 ++--- .../objects/NoVisibleConstructorTest.kt | 41 +++++++++++++++++++ .../NonNullToNullPropertyTest.kt} | 7 ++-- .../ObjectWithDifferentValuesTest.kt | 12 +++--- .../ObjectWithNestedClassTest.kt | 13 +++--- .../{ => objects}/ObjectWithSameValuesTest.kt | 8 ++-- .../WrongTypeAssignmentTest.kt} | 11 ++--- .../{ => sets}/ObjectWithNestedSetTest.kt | 5 ++- .../mappie/testing/{ => sets}/ViaSetTest.kt | 5 ++- 26 files changed, 153 insertions(+), 78 deletions(-) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{MaperClassCanContainPropertiesTest.kt => MapperClassCanContainPropertiesTest.kt} (92%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{MaperClassCanContainPropertiesUsedInForListTest.kt => MapperClassCanContainPropertiesUsedInForListTest.kt} (92%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => enums}/EnumsWithDifferentEntriesTest.kt (90%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => enums}/EnumsWithSameEntriesTest.kt (89%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => enums}/ObjectWithNestedEnumTest.kt (90%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => enums}/ObjectWithNestedNullableEnumTest.kt (91%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ObjectWithNestedNonNullToNullTest.kt => lists/NonNullListToNullListTest.kt} (63%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ObjectWithNullToNonNullTest.kt => lists/NullToNonNullTest.kt} (88%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => lists}/ObjectWithNestedListTest.kt (91%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => lists}/ViaListTest.kt (92%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => objects}/ConstructorParameterNotAFieldTest.kt (89%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => objects}/ConstructorSelectionTest.kt (90%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ObjectWithDefaultValueTest.kt => objects/DefaultValueTest.kt} (88%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => objects}/FromExpressionTest.kt (90%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => objects}/FromValueTest.kt (90%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ObjectWithNestedNullTest.kt => objects/NestedNonNullToNullPropertyTest.kt} (90%) create mode 100644 compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/NoVisibleConstructorTest.kt rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ObjectWithNonNullToNullTest.kt => objects/NonNullToNullPropertyTest.kt} (86%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => objects}/ObjectWithDifferentValuesTest.kt (90%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => objects}/ObjectWithNestedClassTest.kt (92%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => objects}/ObjectWithSameValuesTest.kt (89%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ObjectAssignedWithWrongTypeTest.kt => objects/WrongTypeAssignmentTest.kt} (89%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => sets}/ObjectWithNestedSetTest.kt (91%) rename compiler-plugin/src/test/kotlin/tech/mappie/testing/{ => sets}/ViaSetTest.kt (92%) diff --git a/compiler-plugin/src/main/kotlin/tech/mappie/generation/MappieIrTransformer.kt b/compiler-plugin/src/main/kotlin/tech/mappie/generation/MappieIrTransformer.kt index 9cd7be64..097f982b 100644 --- a/compiler-plugin/src/main/kotlin/tech/mappie/generation/MappieIrTransformer.kt +++ b/compiler-plugin/src/main/kotlin/tech/mappie/generation/MappieIrTransformer.kt @@ -92,7 +92,12 @@ class MappieIrTransformer(private val symbols: List) : IrEleme } } } else { - logAll(invalids.first().second.problems, location(declaration)) + val first = invalids.firstOrNull() + if (first != null) { + logAll(invalids.first().second.problems, location(declaration)) + } else { + logError("No constructor visible to use", location(declaration)) + } } } return declaration diff --git a/compiler-plugin/src/main/kotlin/tech/mappie/resolving/classes/ObjectMappingBodyCollector.kt b/compiler-plugin/src/main/kotlin/tech/mappie/resolving/classes/ObjectMappingBodyCollector.kt index 40141fbb..fcd1e668 100644 --- a/compiler-plugin/src/main/kotlin/tech/mappie/resolving/classes/ObjectMappingBodyCollector.kt +++ b/compiler-plugin/src/main/kotlin/tech/mappie/resolving/classes/ObjectMappingBodyCollector.kt @@ -191,7 +191,7 @@ private class MapperReferenceCollector : BaseVisitor putValueArgument(0, irGet(itParameter)) }) }, - IrStatementOrigin.ANONYMOUS_FUNCTION + IrStatementOrigin.LAMBDA ) } diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/MaperClassCanContainPropertiesTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassCanContainPropertiesTest.kt similarity index 92% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/MaperClassCanContainPropertiesTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassCanContainPropertiesTest.kt index 45b9370c..a44f19bb 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/MaperClassCanContainPropertiesTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassCanContainPropertiesTest.kt @@ -8,7 +8,7 @@ import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin import java.io.File -class MaperClassCanContainPropertiesTest { +class MapperClassCanContainPropertiesTest { data class Input(val text: String) data class Output(val text: String, val int: Int) @@ -24,7 +24,7 @@ class MaperClassCanContainPropertiesTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.MaperClassCanContainPropertiesTest.* + import tech.mappie.testing.MapperClassCanContainPropertiesTest.* class Mapper(private val int: Int) : ObjectMappie() { override fun map(from: Input) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/MaperClassCanContainPropertiesUsedInForListTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassCanContainPropertiesUsedInForListTest.kt similarity index 92% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/MaperClassCanContainPropertiesUsedInForListTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassCanContainPropertiesUsedInForListTest.kt index 3119a6d7..b836190c 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/MaperClassCanContainPropertiesUsedInForListTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassCanContainPropertiesUsedInForListTest.kt @@ -8,7 +8,7 @@ import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin import java.io.File -class MaperClassCanContainPropertiesUsedInForListTest { +class MapperClassCanContainPropertiesUsedInForListTest { data class Input(val text: List) data class InnerInput(val text: String) @@ -26,7 +26,7 @@ class MaperClassCanContainPropertiesUsedInForListTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.MaperClassCanContainPropertiesUsedInForListTest.* + import tech.mappie.testing.MapperClassCanContainPropertiesUsedInForListTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/EnumsWithDifferentEntriesTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/EnumsWithDifferentEntriesTest.kt similarity index 90% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/EnumsWithDifferentEntriesTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/EnumsWithDifferentEntriesTest.kt index ac998487..bc90c402 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/EnumsWithDifferentEntriesTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/EnumsWithDifferentEntriesTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.enums import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy @@ -6,6 +6,8 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.containsError +import tech.mappie.testing.loadEnumMappieClass import java.io.File import kotlin.test.Test @@ -25,7 +27,7 @@ class EnumsWithDifferentEntriesTest { kotlin("Test.kt", """ import tech.mappie.api.EnumMappie - import tech.mappie.testing.EnumsWithDifferentEntriesTest.* + import tech.mappie.testing.enums.EnumsWithDifferentEntriesTest.* class Mapper : EnumMappie() { override fun map(from: Input) = mapping { @@ -59,7 +61,7 @@ class EnumsWithDifferentEntriesTest { kotlin("Test.kt", """ import tech.mappie.api.EnumMappie - import tech.mappie.testing.EnumsWithDifferentEntriesTest.* + import tech.mappie.testing.enums.EnumsWithDifferentEntriesTest.* class Mapper : EnumMappie() { override fun map(from: Input) = mapping { @@ -94,7 +96,7 @@ class EnumsWithDifferentEntriesTest { kotlin("Test.kt", """ import tech.mappie.api.EnumMappie - import tech.mappie.testing.EnumsWithDifferentEntriesTest.* + import tech.mappie.testing.enums.EnumsWithDifferentEntriesTest.* class Mapper : EnumMappie() """ diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/EnumsWithSameEntriesTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/EnumsWithSameEntriesTest.kt similarity index 89% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/EnumsWithSameEntriesTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/EnumsWithSameEntriesTest.kt index 63f5da5c..e2b8849f 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/EnumsWithSameEntriesTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/EnumsWithSameEntriesTest.kt @@ -1,10 +1,12 @@ -package tech.mappie.testing +package tech.mappie.testing.enums import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.containsWarning +import tech.mappie.testing.loadEnumMappieClass import java.io.File import kotlin.test.Test @@ -24,7 +26,7 @@ class EnumsWithSameEntriesTest { kotlin("Test.kt", """ import tech.mappie.api.EnumMappie - import tech.mappie.testing.EnumsWithSameEntriesTest.* + import tech.mappie.testing.enums.EnumsWithSameEntriesTest.* class Mapper : EnumMappie() """ @@ -55,7 +57,7 @@ class EnumsWithSameEntriesTest { kotlin("Test.kt", """ import tech.mappie.api.EnumMappie - import tech.mappie.testing.EnumsWithSameEntriesTest.* + import tech.mappie.testing.enums.EnumsWithSameEntriesTest.* class Mapper : EnumMappie() { override fun map(from: Input) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedEnumTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/ObjectWithNestedEnumTest.kt similarity index 90% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedEnumTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/ObjectWithNestedEnumTest.kt index 184dc25e..d47ad097 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedEnumTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/ObjectWithNestedEnumTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.enums import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,7 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ObjectWithNestedEnumTest { @@ -26,7 +27,7 @@ class ObjectWithNestedEnumTest { """ import tech.mappie.api.ObjectMappie import tech.mappie.api.EnumMappie - import tech.mappie.testing.ObjectWithNestedEnumTest.* + import tech.mappie.testing.enums.ObjectWithNestedEnumTest.* class Mapper : ObjectMappie() diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedNullableEnumTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/ObjectWithNestedNullableEnumTest.kt similarity index 91% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedNullableEnumTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/ObjectWithNestedNullableEnumTest.kt index 40fdb687..9b492de3 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedNullableEnumTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/enums/ObjectWithNestedNullableEnumTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.enums import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,7 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ObjectWithNestedNullableEnumTest { @@ -26,7 +27,7 @@ class ObjectWithNestedNullableEnumTest { """ import tech.mappie.api.ObjectMappie import tech.mappie.api.EnumMappie - import tech.mappie.testing.ObjectWithNestedNullableEnumTest.* + import tech.mappie.testing.enums.ObjectWithNestedNullableEnumTest.* class Mapper : ObjectMappie() @@ -59,7 +60,7 @@ class ObjectWithNestedNullableEnumTest { """ import tech.mappie.api.ObjectMappie import tech.mappie.api.EnumMappie - import tech.mappie.testing.ObjectWithNestedNullableEnumTest.* + import tech.mappie.testing.enums.ObjectWithNestedNullableEnumTest.* class Mapper : ObjectMappie() diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedNonNullToNullTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/NonNullListToNullListTest.kt similarity index 63% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedNonNullToNullTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/NonNullListToNullListTest.kt index eee3d63d..6b9bd67a 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedNonNullToNullTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/NonNullListToNullListTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.lists import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,30 +6,33 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File -class ObjectWithNestedNonNullToNullTest { - data class Input(val text: InnerInput, val int: Int) +class NonNullListToNullListTest { + data class Input(val text: List, val int: Int) data class InnerInput(val value: String) - data class Output(val text: InnerOutput?, val int: Int) + data class Output(val text: List?, val int: Int) data class InnerOutput(val value: String) @TempDir private lateinit var directory: File @Test - fun `map data classes with nested null to non-null using object InnerMapper without declaring mapping should succeed`() { + fun `map data classes with nested null list to non-null list using object InnerMapper without declaring mapping should succeed`() { KotlinCompilation(directory).apply { sources = buildList { add( kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedNonNullToNullTest.* + import tech.mappie.testing.lists.NonNullListToNullListTest.* class Mapper : ObjectMappie() object InnerMapper : ObjectMappie() + + object SecondInnerMapper : ObjectMappie() """ ) ) @@ -44,8 +47,8 @@ class ObjectWithNestedNonNullToNullTest { .first() .call() - assertThat(mapper.map(Input(InnerInput("value"), 20))) - .isEqualTo(Output(InnerOutput("value"), 20)) + assertThat(mapper.map(Input(listOf(InnerInput("first"), InnerInput("second")), 20))) + .isEqualTo(Output(listOf(InnerOutput("first"), InnerOutput("second")), 20)) } } } \ No newline at end of file diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNullToNonNullTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/NullToNonNullTest.kt similarity index 88% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNullToNonNullTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/NullToNonNullTest.kt index 6bcb5025..56d4de96 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNullToNonNullTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/NullToNonNullTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.lists import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,9 +6,11 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.containsError +import tech.mappie.testing.loadObjectMappieClass import java.io.File -class ObjectWithNullToNonNullTest { +class NullToNonNullTest { data class Input(val value: String?) data class Output(val value: String) @@ -23,7 +25,7 @@ class ObjectWithNullToNonNullTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNullToNonNullTest.* + import tech.mappie.testing.lists.NullToNonNullTest.* class Mapper : ObjectMappie() """ @@ -45,7 +47,7 @@ class ObjectWithNullToNonNullTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNullToNonNullTest.* + import tech.mappie.testing.lists.NullToNonNullTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedListTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/ObjectWithNestedListTest.kt similarity index 91% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedListTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/ObjectWithNestedListTest.kt index e6177926..b9ce9079 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedListTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/ObjectWithNestedListTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.lists import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,7 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ObjectWithNestedListTest { @@ -25,7 +26,7 @@ class ObjectWithNestedListTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedListTest.* + import tech.mappie.testing.lists.ObjectWithNestedListTest.* class Mapper : ObjectMappie() diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ViaListTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/ViaListTest.kt similarity index 92% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ViaListTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/ViaListTest.kt index febf649a..d559585f 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ViaListTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/lists/ViaListTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.lists import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,7 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ViaListTest { @@ -24,7 +25,7 @@ class ViaListTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ViaListTest.* + import tech.mappie.testing.lists.ViaListTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ConstructorParameterNotAFieldTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ConstructorParameterNotAFieldTest.kt similarity index 89% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ConstructorParameterNotAFieldTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ConstructorParameterNotAFieldTest.kt index ef11d3a4..81bbf58f 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ConstructorParameterNotAFieldTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ConstructorParameterNotAFieldTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.jetbrains.kotlin.com.google.common.base.Objects @@ -7,6 +7,8 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.containsError +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ConstructorParameterNotAFieldTest { @@ -30,7 +32,7 @@ class ConstructorParameterNotAFieldTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ConstructorParameterNotAFieldTest.* + import tech.mappie.testing.objects.ConstructorParameterNotAFieldTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { @@ -55,7 +57,7 @@ class ConstructorParameterNotAFieldTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ConstructorParameterNotAFieldTest.* + import tech.mappie.testing.objects.ConstructorParameterNotAFieldTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ConstructorSelectionTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ConstructorSelectionTest.kt similarity index 90% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ConstructorSelectionTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ConstructorSelectionTest.kt index 0ee7d222..ca8f9a42 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ConstructorSelectionTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ConstructorSelectionTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,7 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ConstructorSelectionTest { @@ -26,7 +27,7 @@ class ConstructorSelectionTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ConstructorSelectionTest.* + import tech.mappie.testing.objects.ConstructorSelectionTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { @@ -60,7 +61,7 @@ class ConstructorSelectionTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ConstructorSelectionTest.* + import tech.mappie.testing.objects.ConstructorSelectionTest.* class Mapper : ObjectMappie() """ diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithDefaultValueTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/DefaultValueTest.kt similarity index 88% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithDefaultValueTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/DefaultValueTest.kt index 6cbb973a..ad26c9ba 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithDefaultValueTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/DefaultValueTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled @@ -7,9 +7,10 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File -class ObjectWithDefaultValueTest { +class DefaultValueTest { data class Input(val age: Int) data class Output(val name: String = "unknown", val age: Int) @@ -25,7 +26,7 @@ class ObjectWithDefaultValueTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithDefaultValueTest.* + import tech.mappie.testing.objects.DefaultValueTest.* class Mapper : ObjectMappie() """ diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/FromExpressionTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/FromExpressionTest.kt similarity index 90% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/FromExpressionTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/FromExpressionTest.kt index 2dfd2036..cfaa0855 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/FromExpressionTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/FromExpressionTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,7 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File class FromExpressionTest { @@ -23,7 +24,7 @@ class FromExpressionTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.FromExpressionTest.* + import tech.mappie.testing.objects.FromExpressionTest.* class Mapper : ObjectMappie() { override fun map(from: Unit) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/FromValueTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/FromValueTest.kt similarity index 90% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/FromValueTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/FromValueTest.kt index f2eac7f9..36bd0736 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/FromValueTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/FromValueTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,7 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File class FromValueTest { @@ -23,7 +24,7 @@ class FromValueTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.FromValueTest.* + import tech.mappie.testing.objects.FromValueTest.* class Mapper : ObjectMappie() { override fun map(from: Unit) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedNullTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/NestedNonNullToNullPropertyTest.kt similarity index 90% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedNullTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/NestedNonNullToNullPropertyTest.kt index 589292b5..4bd9a03e 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedNullTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/NestedNonNullToNullPropertyTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,9 +6,10 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File -class ObjectWithNestedNullTest { +class NestedNonNullToNullPropertyTest { data class Input(val text: InnerInput?, val int: Int) data class InnerInput(val value: String) data class Output(val text: InnerOutput?, val int: Int) @@ -25,7 +26,7 @@ class ObjectWithNestedNullTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedNullTest.* + import tech.mappie.testing.objects.NestedNonNullToNullPropertyTest.* class Mapper : ObjectMappie() @@ -57,7 +58,7 @@ class ObjectWithNestedNullTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedNullTest.* + import tech.mappie.testing.objects.NestedNonNullToNullPropertyTest.* class Mapper : ObjectMappie() @@ -89,7 +90,7 @@ class ObjectWithNestedNullTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedNullTest.* + import tech.mappie.testing.objects.NestedNonNullToNullPropertyTest.* class Mapper : ObjectMappie() diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/NoVisibleConstructorTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/NoVisibleConstructorTest.kt new file mode 100644 index 00000000..0d146229 --- /dev/null +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/NoVisibleConstructorTest.kt @@ -0,0 +1,41 @@ +package tech.mappie.testing.objects + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import tech.mappie.testing.compilation.KotlinCompilation +import tech.mappie.testing.compilation.KotlinCompilation.ExitCode +import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.containsError +import java.io.File + +class NoVisibleConstructorTest { + + data class Input(val name: String) + data class Output private constructor(val name: String) + + @TempDir + private lateinit var directory: File + + @Test + fun `map data class without a visible constructor should fail`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.testing.objects.NoVisibleConstructorTest.* + + class Mapper : ObjectMappie() + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.COMPILATION_ERROR) + assertThat(messages) + .containsError("No constructor visible to use") + } + } +} \ No newline at end of file diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNonNullToNullTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/NonNullToNullPropertyTest.kt similarity index 86% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNonNullToNullTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/NonNullToNullPropertyTest.kt index 95d59d10..f3d30d0c 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNonNullToNullTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/NonNullToNullPropertyTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,9 +6,10 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File -class ObjectWithNonNullToNullTest { +class NonNullToNullPropertyTest { data class Input(val value: String) data class Output(val value: String?) @@ -23,7 +24,7 @@ class ObjectWithNonNullToNullTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNonNullToNullTest.* + import tech.mappie.testing.objects.NonNullToNullPropertyTest.* class Mapper : ObjectMappie() """ diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithDifferentValuesTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ObjectWithDifferentValuesTest.kt similarity index 90% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithDifferentValuesTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ObjectWithDifferentValuesTest.kt index 66e46bc2..97e2f9bf 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithDifferentValuesTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ObjectWithDifferentValuesTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,8 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.containsError +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ObjectWithDifferentValuesTest { @@ -24,7 +26,7 @@ class ObjectWithDifferentValuesTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithDifferentValuesTest.* + import tech.mappie.testing.objects.ObjectWithDifferentValuesTest.* class Mapper : ObjectMappie() """ @@ -45,7 +47,7 @@ class ObjectWithDifferentValuesTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithDifferentValuesTest.* + import tech.mappie.testing.objects.ObjectWithDifferentValuesTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { @@ -78,7 +80,7 @@ class ObjectWithDifferentValuesTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithDifferentValuesTest.* + import tech.mappie.testing.objects.ObjectWithDifferentValuesTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { @@ -111,7 +113,7 @@ class ObjectWithDifferentValuesTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithDifferentValuesTest.* + import tech.mappie.testing.objects.ObjectWithDifferentValuesTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedClassTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ObjectWithNestedClassTest.kt similarity index 92% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedClassTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ObjectWithNestedClassTest.kt index e61d54d8..97e1b14c 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedClassTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ObjectWithNestedClassTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,7 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ObjectWithNestedClassTest { @@ -25,7 +26,7 @@ class ObjectWithNestedClassTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedClassTest.* + import tech.mappie.testing.objects.ObjectWithNestedClassTest.* class Mapper : ObjectMappie() @@ -57,7 +58,7 @@ class ObjectWithNestedClassTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedClassTest.* + import tech.mappie.testing.objects.ObjectWithNestedClassTest.* class Mapper : ObjectMappie() @@ -89,7 +90,7 @@ class ObjectWithNestedClassTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedClassTest.* + import tech.mappie.testing.objects.ObjectWithNestedClassTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { @@ -125,7 +126,7 @@ class ObjectWithNestedClassTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedClassTest.* + import tech.mappie.testing.objects.ObjectWithNestedClassTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { @@ -161,7 +162,7 @@ class ObjectWithNestedClassTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedClassTest.* + import tech.mappie.testing.objects.ObjectWithNestedClassTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithSameValuesTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ObjectWithSameValuesTest.kt similarity index 89% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithSameValuesTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ObjectWithSameValuesTest.kt index fc9996e9..8e9a53a6 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithSameValuesTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/ObjectWithSameValuesTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Disabled @@ -7,6 +7,8 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.containsWarning +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ObjectWithSameValuesTest { @@ -25,7 +27,7 @@ class ObjectWithSameValuesTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithSameValuesTest.* + import tech.mappie.testing.objects.ObjectWithSameValuesTest.* class Mapper : ObjectMappie() """ @@ -55,7 +57,7 @@ class ObjectWithSameValuesTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithSameValuesTest.* + import tech.mappie.testing.objects.ObjectWithSameValuesTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectAssignedWithWrongTypeTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/WrongTypeAssignmentTest.kt similarity index 89% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectAssignedWithWrongTypeTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/WrongTypeAssignmentTest.kt index 5493e542..45e0b779 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectAssignedWithWrongTypeTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/WrongTypeAssignmentTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,9 +6,10 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.containsError import java.io.File -class ObjectAssignedWithWrongTypeTest { +class WrongTypeAssignmentTest { data class Input(val value: String) data class Output(val value: Int) @@ -24,7 +25,7 @@ class ObjectAssignedWithWrongTypeTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectAssignedWithWrongTypeTest.* + import tech.mappie.testing.objects.WrongTypeAssignmentTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { @@ -50,7 +51,7 @@ class ObjectAssignedWithWrongTypeTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectAssignedWithWrongTypeTest.* + import tech.mappie.testing.objects.WrongTypeAssignmentTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { @@ -76,7 +77,7 @@ class ObjectAssignedWithWrongTypeTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectAssignedWithWrongTypeTest.* + import tech.mappie.testing.objects.WrongTypeAssignmentTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedSetTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/sets/ObjectWithNestedSetTest.kt similarity index 91% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedSetTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/sets/ObjectWithNestedSetTest.kt index 25e0895e..13047a60 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ObjectWithNestedSetTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/sets/ObjectWithNestedSetTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.sets import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,7 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ObjectWithNestedSetTest { @@ -25,7 +26,7 @@ class ObjectWithNestedSetTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ObjectWithNestedSetTest.* + import tech.mappie.testing.sets.ObjectWithNestedSetTest.* class Mapper : ObjectMappie() diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ViaSetTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/sets/ViaSetTest.kt similarity index 92% rename from compiler-plugin/src/test/kotlin/tech/mappie/testing/ViaSetTest.kt rename to compiler-plugin/src/test/kotlin/tech/mappie/testing/sets/ViaSetTest.kt index 84f991c2..8b63e11e 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/ViaSetTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/sets/ViaSetTest.kt @@ -1,4 +1,4 @@ -package tech.mappie.testing +package tech.mappie.testing.sets import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -6,6 +6,7 @@ import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass import java.io.File class ViaSetTest { @@ -24,7 +25,7 @@ class ViaSetTest { kotlin("Test.kt", """ import tech.mappie.api.ObjectMappie - import tech.mappie.testing.ViaSetTest.* + import tech.mappie.testing.sets.ViaSetTest.* class Mapper : ObjectMappie() { override fun map(from: Input) = mapping {