Skip to content

Commit b237e01

Browse files
committed
Merge remote-tracking branch 'FasterXML/2.19'
2 parents 88ac686 + 76ec01c commit b237e01

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

release-notes/CREDITS-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Tatu Saloranta (@cowtowncoder)
2121
* #889: Upgrade kotlin dep to 1.9.25 (from 1.9.24)
2222

2323
WrongWrong (@k163377)
24+
* #930: Add tests for #917
2425
* #929: Bug fixes to hasRequiredMarker and added isRequired considerations
2526
* #914: Add test case to serialize Nothing? (for #314)
2627
* #910: Add default KeyDeserializer for value class
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package tools.jackson.module.kotlin.test.github
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude
4+
import com.fasterxml.jackson.annotation.JsonProperty
5+
import com.fasterxml.jackson.annotation.OptBoolean
6+
import org.junit.jupiter.api.Test
7+
import org.junit.jupiter.api.assertThrows
8+
import tools.jackson.databind.exc.InvalidNullException
9+
import tools.jackson.module.kotlin.jsonMapper
10+
import tools.jackson.module.kotlin.kotlinModule
11+
import tools.jackson.module.kotlin.readValue
12+
import kotlin.test.assertEquals
13+
14+
class GitHub917 {
15+
data class Failing<T>(val data: T)
16+
17+
val mapper = jsonMapper {
18+
changeDefaultPropertyInclusion { it.withValueInclusion(JsonInclude.Include.NON_NULL) }
19+
addModule(kotlinModule())
20+
}
21+
22+
@Test
23+
fun failing() {
24+
val value = Failing<String?>(null)
25+
val json = mapper.writeValueAsString(value)
26+
27+
assertThrows<InvalidNullException> {
28+
val deserializedValue = mapper.readValue<Failing<String?>>(json)
29+
assertEquals(value ,deserializedValue)
30+
}
31+
}
32+
33+
data class WorkAround<T>(@JsonProperty(isRequired = OptBoolean.FALSE) val data: T)
34+
35+
@Test
36+
fun workAround() {
37+
val value = WorkAround<String?>(null)
38+
val json = mapper.writeValueAsString(value)
39+
40+
val deserializedValue = mapper.readValue<WorkAround<String?>>(json)
41+
assertEquals(value ,deserializedValue)
42+
}
43+
}

0 commit comments

Comments
 (0)