This repository has been archived by the owner on Jan 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from k163377/conversion_service
Add ConversionService support.
- Loading branch information
Showing
9 changed files
with
117 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/kotlin/com/mapk/krowmapper/DeserializeByConversionServiceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.mapk.krowmapper | ||
|
||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.DisplayName | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.core.convert.ConversionService | ||
import java.sql.ResultSet | ||
import java.time.YearMonth | ||
|
||
@DisplayName("ConversionServiceによるデシリアライズのテスト") | ||
private class DeserializeByConversionServiceTest { | ||
data class Dst(val yearMonth: YearMonth) | ||
|
||
@Test | ||
fun test() { | ||
val conversionService = mockk<ConversionService> { | ||
every { convert(202101, YearMonth::class.java) } returns (YearMonth.of(2021, 1)) | ||
} | ||
val mapper = KRowMapper<Dst>(conversionService) | ||
val resultSet = mockk<ResultSet> { | ||
every { getObject("yearMonth") } returns 202101 | ||
} | ||
|
||
assertEquals(Dst(YearMonth.of(2021, 1)), mapper.mapRow(resultSet, 0)) | ||
verify(exactly = 1) { conversionService.convert(202101, YearMonth::class.java) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters