This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed
main/kotlin/com/mapk/kmapper
test/kotlin/com/mapk/kmapper Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ plugins {
6
6
}
7
7
8
8
group = " com.mapk"
9
- version = " 0.15 "
9
+ version = " 0.16 "
10
10
11
11
java {
12
12
sourceCompatibility = JavaVersion .VERSION_1_8
@@ -30,7 +30,7 @@ repositories {
30
30
dependencies {
31
31
implementation(" org.jetbrains.kotlin:kotlin-stdlib-jdk8" )
32
32
implementation(kotlin(" reflect" ))
33
- implementation (" com.github.ProjectMapK:Shared:0.6 " )
33
+ api (" com.github.ProjectMapK:Shared:0.7 " )
34
34
35
35
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter
36
36
testImplementation(group = " org.junit.jupiter" , name = " junit-jupiter" , version = " 5.6.0" ) {
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import com.mapk.core.ArgumentBucket
6
6
import com.mapk.core.EnumMapper
7
7
import com.mapk.core.KFunctionForCall
8
8
import com.mapk.core.getAliasOrName
9
+ import com.mapk.core.isUseDefaultArgument
9
10
import com.mapk.core.toKConstructor
10
11
import java.lang.reflect.Method
11
12
import kotlin.reflect.KClass
@@ -29,7 +30,7 @@ class KMapper<T : Any> private constructor(
29
30
)
30
31
31
32
private val parameterMap: Map <String , ParameterForMap <* >> = function.parameters
32
- .filter { it.kind != KParameter .Kind .INSTANCE }
33
+ .filter { it.kind != KParameter .Kind .INSTANCE && ! it.isUseDefaultArgument() }
33
34
.associate { (propertyNameConverter(it.getAliasOrName()!! )) to ParameterForMap .newInstance(it) }
34
35
35
36
private fun bindArguments (argumentBucket : ArgumentBucket , src : Any ) {
Original file line number Diff line number Diff line change
1
+ package com.mapk.kmapper
2
+
3
+ import com.mapk.annotations.KUseDefaultArgument
4
+ import org.junit.jupiter.api.Assertions.assertEquals
5
+ import org.junit.jupiter.api.DisplayName
6
+ import org.junit.jupiter.api.Test
7
+
8
+ @DisplayName(" デフォルト引数を指定するテスト" )
9
+ class DefaultArgumentTest {
10
+ data class Dst (val fooArgument : Int , @param:KUseDefaultArgument val barArgument : String = " default" )
11
+ data class Src (val fooArgument : Int , val barArgument : String )
12
+
13
+ @Test
14
+ fun test () {
15
+ val src = Src (1 , " src" )
16
+
17
+ val result = KMapper (::Dst ).map(src)
18
+ assertEquals(Dst (1 , " default" ), result)
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments