Skip to content

Commit

Permalink
Merge branch '2.12' of github.com:FasterXML/jackson-module-kotlin int…
Browse files Browse the repository at this point in the history
…o 2.12
  • Loading branch information
cowtowncoder committed Aug 27, 2021
2 parents 1359837 + a36b648 commit d865c64
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.fasterxml.jackson.module.kotlin.test.github.failing

import com.fasterxml.jackson.annotation.JsonInclude.Include.NON_DEFAULT
import com.fasterxml.jackson.module.kotlin.jsonMapper
import com.fasterxml.jackson.module.kotlin.kotlinModule
import com.fasterxml.jackson.module.kotlin.readValue
import com.fasterxml.jackson.module.kotlin.test.expectFailure
import org.junit.ComparisonFailure
import org.junit.Test
import kotlin.test.assertEquals

class GitHub478Test {
val mapper = jsonMapper {
addModule(kotlinModule())
serializationInclusion(NON_DEFAULT)
}

data class Data(val flag: Boolean = true)

@Test
fun omitsDefaultValueWhenSerializing() {
expectFailure<ComparisonFailure>("GitHub478 has been fixed!") {
assertEquals("""{}""", mapper.writeValueAsString(Data()))
}
}

@Test
fun serializesNonDefaultValue() {
expectFailure<ComparisonFailure>("GitHub478 has been fixed!") {
assertEquals("""{"flag": false}""", mapper.writeValueAsString(Data(flag = false)))
}
}

@Test
fun usesDefaultWhenDeserializing() {
assertEquals(Data(), mapper.readValue("{}"))
}
}

0 comments on commit d865c64

Please sign in to comment.