Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit b42c5d0

Browse files
committed
複数ソースからマップするテストを追加
1 parent 6442480 commit b42c5d0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/test/kotlin/mapk/core/SimpleKMapperTest.kt

+41
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.junit.jupiter.api.Assertions.assertEquals
55
import org.junit.jupiter.api.DisplayName
66
import org.junit.jupiter.api.Nested
77
import org.junit.jupiter.api.Test
8+
import java.math.BigInteger
89
import kotlin.reflect.full.primaryConstructor
910

1011
data class Dst(
@@ -28,6 +29,8 @@ data class Src1(
2829
val arg4 = null
2930
}
3031

32+
data class Src2(val arg2: String?)
33+
3134
@DisplayName("単純なマッピングのテスト")
3235
class SimpleKMapperTest {
3336
private fun instanceFunction(arg1: Int, arg2: String?, arg3: Number): Dst {
@@ -118,4 +121,42 @@ class SimpleKMapperTest {
118121
}
119122
}
120123
}
124+
125+
@Nested
126+
@DisplayName("複数ソースからのマップ")
127+
inner class FromMultipleSrc {
128+
@Test
129+
@DisplayName("Nullを含まない場合")
130+
fun testWithoutNull() {
131+
val src1 = "arg1" to 1
132+
val src2 = Src2("value")
133+
val src3 = mapOf("arg3" to 5.5)
134+
135+
val dsts = mappers.map { it.map(src1, src2, src3) }
136+
137+
assertEquals(dsts.distinct().size, 1)
138+
dsts.first().let {
139+
assertEquals(it.arg1, 1)
140+
assertEquals(it.arg2, "value")
141+
assertEquals(it.arg3, 5.5)
142+
}
143+
}
144+
145+
@Test
146+
@DisplayName("Nullを含む場合")
147+
fun testContainsNull() {
148+
val src1 = "arg1" to 7
149+
val src2 = Src2(null)
150+
val src3 = mapOf("arg3" to BigInteger.TWO)
151+
152+
val dsts = mappers.map { it.map(src1, src2, src3) }
153+
154+
assertEquals(dsts.distinct().size, 1)
155+
dsts.first().let {
156+
assertEquals(it.arg1, 7)
157+
assertEquals(it.arg2, null)
158+
assertEquals(it.arg3, BigInteger.TWO)
159+
}
160+
}
161+
}
121162
}

0 commit comments

Comments
 (0)