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

Commit

Permalink
マッパーの宣言を切り出し
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Jul 24, 2020
1 parent d3a8966 commit 2303efe
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/test/kotlin/com/mapk/kmapper/ConversionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ class ConversionTest {
@Nested
@DisplayName("KMapper")
inner class KMapperTest {
private val mapper = KMapper(::Dst)

@ParameterizedTest
@EnumSource(NumberSource::class)
@DisplayName("Numberソース")
fun fromNumber(numbers: NumberSource) {
numbers.values.forEach {
val actual = KMapper(::Dst).map(NumberSrc(it))
val actual = mapper.map(NumberSrc(it))
assertEquals(0, BigDecimal.valueOf(it.toDouble()).compareTo(actual.number))
}
}
Expand All @@ -90,15 +92,15 @@ class ConversionTest {
@ValueSource(strings = ["100", "2.0", "-500"])
@DisplayName("Stringソース")
fun fromString(str: String) {
val actual = KMapper(::Dst).map(StringSrc(str))
val actual = mapper.map(StringSrc(str))
assertEquals(0, BigDecimal(str).compareTo(actual.number))
}

@Test
@DisplayName("nullを入れた際に変換処理に入らないことのテスト")
fun fromNull() {
assertDoesNotThrow {
val actual = KMapper(::Dst).map(NullSrc)
val actual = mapper.map(NullSrc)
assertNull(actual.number)
}
}
Expand All @@ -107,12 +109,14 @@ class ConversionTest {
@Nested
@DisplayName("PlainKMapper")
inner class PlainKMapperTest {
private val mapper = PlainKMapper(::Dst)

@ParameterizedTest
@EnumSource(NumberSource::class)
@DisplayName("Numberソース")
fun fromNumber(numbers: NumberSource) {
numbers.values.forEach {
val actual = PlainKMapper(::Dst).map(NumberSrc(it))
val actual = mapper.map(NumberSrc(it))
assertEquals(0, BigDecimal.valueOf(it.toDouble()).compareTo(actual.number))
}
}
Expand All @@ -121,15 +125,15 @@ class ConversionTest {
@ValueSource(strings = ["100", "2.0", "-500"])
@DisplayName("Stringソース")
fun fromString(str: String) {
val actual = PlainKMapper(::Dst).map(StringSrc(str))
val actual = mapper.map(StringSrc(str))
assertEquals(0, BigDecimal(str).compareTo(actual.number))
}

@Test
@DisplayName("nullを入れた際に変換処理に入らないことのテスト")
fun fromNull() {
assertDoesNotThrow {
val actual = PlainKMapper(::Dst).map(NullSrc)
val actual = mapper.map(NullSrc)
assertNull(actual.number)
}
}
Expand Down

0 comments on commit 2303efe

Please sign in to comment.