This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
src/test/kotlin/com/mapk/krowmapper Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.mapk.krowmapper
2
+
3
+ import com.google.common.base.CaseFormat
4
+ import com.mapk.core.KFunctionForCall
5
+ import io.mockk.every
6
+ import io.mockk.mockk
7
+ import io.mockk.verify
8
+ import java.sql.ResultSet
9
+ import org.junit.jupiter.api.Assertions.assertEquals
10
+ import org.junit.jupiter.api.DisplayName
11
+ import org.junit.jupiter.api.Test
12
+
13
+ @DisplayName(" 単純なマッピングテスト" )
14
+ class SimpleMappingTest {
15
+ data class Dst (val fooId : Int , val strValue : String )
16
+
17
+ private fun camelToSnake (camel : String ): String = CaseFormat .LOWER_CAMEL .to(CaseFormat .LOWER_UNDERSCORE , camel)
18
+
19
+ @Test
20
+ @DisplayName(" スネークケースsrc -> キャメルケースdst" )
21
+ fun test () {
22
+ val resultSet = mockk<ResultSet >()
23
+ every { resultSet.getObject(" foo_id" , any<Class <* >>()) } returns 1
24
+ every { resultSet.getObject(" str_value" , any<Class <* >>()) } returns " str"
25
+
26
+ val result = KRowMapper (KFunctionForCall (::Dst ), this ::camelToSnake).mapRow(resultSet, 0 )
27
+
28
+ assertEquals(1 , result.fooId)
29
+ assertEquals(" str" , result.strValue)
30
+
31
+ verify(exactly = 1 ) { resultSet.getObject(" foo_id" , Int ::class .java) }
32
+ verify(exactly = 1 ) { resultSet.getObject(" str_value" , String ::class .java) }
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments