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

Commit 2a44067

Browse files
committed
比較まで作成
1 parent e780d48 commit 2a44067

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/test/kotlin/com/mapk/krowmapper/UseDBMappingTest.kt

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package com.mapk.krowmapper
22

33
import com.google.common.base.CaseFormat
4+
import javax.sql.DataSource
45
import org.h2.jdbcx.JdbcDataSource
6+
import org.junit.jupiter.api.Assertions.assertEquals
57
import org.junit.jupiter.api.BeforeAll
68
import org.junit.jupiter.api.Test
79
import org.junit.jupiter.api.TestInstance
810
import org.springframework.jdbc.core.JdbcTemplate
911
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource
1012
import org.springframework.jdbc.core.simple.SimpleJdbcInsert
11-
import javax.sql.DataSource
1213

1314
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
1415
class UseDBMappingTest {
@@ -22,7 +23,19 @@ class UseDBMappingTest {
2223
val fooStatus: FooStatus,
2324
val isBar: Boolean,
2425
val description: String?
25-
)
26+
) {
27+
companion object {
28+
fun fooFactory(
29+
fooId: Int,
30+
fooName: String,
31+
fooStatus: FooStatus,
32+
isBar: String,
33+
description: String?
34+
) = Foo(
35+
fooId, fooName, fooStatus, isBar.toBoolean(), description
36+
)
37+
}
38+
}
2639

2740
data class FooInsert(
2841
val fooId: Int,
@@ -63,9 +76,13 @@ class UseDBMappingTest {
6376

6477
@Test
6578
fun test() {
66-
val result = jdbcTemplate.query("SELECT * FROM foo_table", KRowMapper(::Foo) {
79+
val result = jdbcTemplate.query("SELECT * FROM foo_table", KRowMapper((Foo)::fooFactory) {
6780
CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, it)
68-
})
69-
println(result)
81+
}).single()
82+
83+
assertEquals(
84+
Foo(10, "Foo", FooStatus.archive, false, null),
85+
result
86+
)
7087
}
7188
}

0 commit comments

Comments
 (0)