Skip to content

Commit

Permalink
Add failing testcase for #611 (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
sconvent authored Jan 16, 2023
1 parent 200f6fb commit bedb6ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fun serializeAndDeserializeTypeable() {
val newEntity = mapper.readValue<MyEntity>(json)

expectFailure<AssertionError>("GitHub #335 has been fixed!") {
// newEntity.type is hte string "null" instead of the null value
// newEntity.type is the string "null" instead of the null value
assertNull(newEntity.type)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.fasterxml.jackson.module.kotlin.test.github.failing

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import com.fasterxml.jackson.module.kotlin.test.expectFailure
import org.junit.Test

class TestGithub611 {

class TestClass(@JsonProperty("id") var id: UShort) {
// Empty constructor
constructor() : this(1u)
}

// Value fits into UShort, but not (Java) Short
private val jsonData = """
{
"id": 50000
}
"""

@Test
fun testJsonParsing() {
val mapper = jacksonObjectMapper()
expectFailure<JsonMappingException>("GitHub #611 has been fixed!") {
val dataClassInstance = mapper.readValue<TestClass>(jsonData)
}
}
}

0 comments on commit bedb6ea

Please sign in to comment.