Skip to content

Commit 996df60

Browse files
committed
Added tests and updated changelog
1 parent 5b98414 commit 996df60

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package tech.mappie.testing.objects5
2+
3+
import org.assertj.core.api.Assertions.assertThat
4+
import org.junit.jupiter.api.Test
5+
import tech.mappie.testing.MappieTestCase
6+
7+
class Object5WithFromValueTest : MappieTestCase() {
8+
9+
data class Input5(val float: Float)
10+
data class Output(val first: Long, val second: Long, val third: Long, val fourth: String, val float: Float)
11+
12+
@Test
13+
fun `map five data classes into one should succeed`() {
14+
compile {
15+
file("Test.kt",
16+
"""
17+
import tech.mappie.api.ObjectMappie5
18+
import tech.mappie.testing.objects5.Object5WithFromValueTest.*
19+
20+
class Mapper : ObjectMappie5<Long, Long, Long, String, Input5, Output>()
21+
"""
22+
)
23+
} satisfies {
24+
isOk()
25+
hasNoWarningsOrErrors()
26+
27+
val mapper = objectMappie5<Long, Long, Long, String, Input5, Output>()
28+
29+
assertThat(mapper.map(1, 2, 3, "value", Input5(1.0f)))
30+
.isEqualTo(Output(1, 2, 3, "value", 1.0f))
31+
}
32+
}
33+
34+
@Test
35+
fun `map five data classes into one with run should fail`() {
36+
compile {
37+
file("Test.kt",
38+
"""
39+
import tech.mappie.api.ObjectMappie5
40+
import tech.mappie.testing.objects5.Object5WithFromValueTest.*
41+
42+
class Mapper : ObjectMappie5<Long, Long, Long, String, Input5, Output>() {
43+
override fun map(first: Long, second: Long, third: Long, fourth: String, fifth: Input5) = mapping {
44+
to::fourth fromValue run { uppercase("test") }
45+
to::float fromProperty fifth::float transform { it + 1 }
46+
}
47+
}
48+
49+
private fun uppercase(value: String) = value.uppercase()
50+
"""
51+
)
52+
} satisfies {
53+
isCompilationError()
54+
hasErrorMessage(6,
55+
"The function 'run' was called as an extension method on the mapping dsl which does not exist after compilation")
56+
}
57+
}
58+
}

testutil/src/main/kotlin/tech/mappie/testing/MappieTestCase.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import tech.mappie.api.EnumMappie
55
import tech.mappie.api.ObjectMappie
66
import tech.mappie.api.ObjectMappie2
77
import tech.mappie.api.ObjectMappie3
8+
import tech.mappie.api.ObjectMappie5
89
import tech.mappie.testing.compilation.compile
910
import tech.mappie.testing.compilation.CompilationDsl
1011
import java.io.File
@@ -40,4 +41,10 @@ abstract class MappieTestCase {
4041
.constructors
4142
.first()
4243
.call(*args)
44+
45+
protected fun <FROM1, FROM2, FROM3, FROM4, FROM5, TO> CompilationAssertionDsl.objectMappie5(name: String = "Mapper", vararg args: Any?): ObjectMappie5<FROM1, FROM2, FROM3, FROM4, FROM5, TO> =
46+
classLoader.loadObjectMappie5Class<FROM1, FROM2, FROM3, FROM4, FROM5, TO>(name)
47+
.constructors
48+
.first()
49+
.call(*args)
4350
}

website/src/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Changelog"
33
layout: "layouts/changelog.html"
44
changelog:
5-
- date: "2025-10-22"
5+
- date: "2025-10-24"
66
title: "v2.2.20-1.6.1"
77
items:
88
- "[#290](https://github.com/Mr-Mappie/mappie/issues/290) Fix IndexOutOfBoundsException with generic target type."

0 commit comments

Comments
 (0)