File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.fasterxml.jackson.module.kotlin.test.github.failing
2
+
3
+ import com.fasterxml.jackson.annotation.JsonInclude.Include.NON_DEFAULT
4
+ import com.fasterxml.jackson.module.kotlin.jsonMapper
5
+ import com.fasterxml.jackson.module.kotlin.kotlinModule
6
+ import com.fasterxml.jackson.module.kotlin.readValue
7
+ import com.fasterxml.jackson.module.kotlin.test.expectFailure
8
+ import org.junit.ComparisonFailure
9
+ import org.junit.Test
10
+ import kotlin.test.assertEquals
11
+
12
+ class GitHub478Test {
13
+ val mapper = jsonMapper {
14
+ addModule(kotlinModule())
15
+ serializationInclusion(NON_DEFAULT )
16
+ }
17
+
18
+ data class Data (val flag : Boolean = true )
19
+
20
+ @Test
21
+ fun omitsDefaultValueWhenSerializing () {
22
+ expectFailure<ComparisonFailure >(" GitHub478 has been fixed!" ) {
23
+ assertEquals(""" {}""" , mapper.writeValueAsString(Data ()))
24
+ }
25
+ }
26
+
27
+ @Test
28
+ fun serializesNonDefaultValue () {
29
+ expectFailure<ComparisonFailure >(" GitHub478 has been fixed!" ) {
30
+ assertEquals(""" {"flag": false}""" , mapper.writeValueAsString(Data (flag = false )))
31
+ }
32
+ }
33
+
34
+ @Test
35
+ fun usesDefaultWhenDeserializing () {
36
+ assertEquals(Data (), mapper.readValue(" {}" ))
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments