-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/failing/Github611.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |