-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16ed3c8
commit 57b57d7
Showing
4 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,5 +67,4 @@ class MapperClassCanContainAllDeclarationsTest { | |
.isEqualTo(Output("test")) | ||
} | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassInsideOtherDeclarationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package tech.mappie.testing | ||
|
||
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 java.io.File | ||
|
||
class MapperClassInsideOtherDeclarationTest { | ||
|
||
data class Input(val text: String) | ||
data class Output(val text: String) | ||
|
||
@TempDir | ||
lateinit var directory: File | ||
|
||
@Test | ||
fun `mapper can be declared nested`() { | ||
KotlinCompilation(directory).apply { | ||
sources = buildList { | ||
add( | ||
kotlin("Test.kt", | ||
""" | ||
import tech.mappie.api.ObjectMappie | ||
import tech.mappie.testing.MapperClassInsideOtherDeclarationTest.* | ||
class Thing { | ||
class Mapper : ObjectMappie<Input, Output>() | ||
} | ||
""" | ||
) | ||
) | ||
} | ||
}.compile { | ||
assertThat(exitCode).isEqualTo(ExitCode.OK) | ||
assertThat(messages).isEmpty() | ||
|
||
val mapper = classLoader | ||
.loadObjectMappieClass<Input, Output>("Thing\$Mapper") | ||
.constructors | ||
.first() | ||
.call() | ||
|
||
assertThat(mapper.map(Input("test"))) | ||
.isEqualTo(Output("test")) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters