File tree 1 file changed +35
-0
lines changed
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.fasterxml.jackson.module.kotlin.test.github
2
+
3
+ import com.fasterxml.jackson.annotation.JsonIgnore
4
+ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
5
+ import com.fasterxml.jackson.annotation.JsonProperty
6
+ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
7
+ import com.fasterxml.jackson.module.kotlin.readValue
8
+ import org.junit.Test
9
+ import kotlin.test.assertEquals
10
+ import kotlin.test.assertNotNull
11
+ import kotlin.test.assertNull
12
+
13
+ class Github308 {
14
+
15
+ @JsonIgnoreProperties(ignoreUnknown = true )
16
+ data class TestDto (
17
+ @JsonIgnore
18
+ var id : Long? = null ,
19
+ var cityId : Int? = null
20
+ ) {
21
+ @JsonProperty(" id" )
22
+ private fun unpackId (idObj : Int? ) {
23
+ cityId = idObj
24
+ }
25
+ }
26
+
27
+ @Test
28
+ fun createTestDto () {
29
+ val dto: TestDto = jacksonObjectMapper().readValue(""" {"id":12345}""" )
30
+
31
+ assertNotNull(dto)
32
+ assertNull(dto.id)
33
+ assertEquals(dto.cityId, 12345 )
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments