-
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.
Merge remote-tracking branch 'FasterXML/2.17'
- Loading branch information
Showing
8 changed files
with
46 additions
and
22 deletions.
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
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
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
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
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
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
33 changes: 33 additions & 0 deletions
33
src/test/kotlin/tools/jackson/module/kotlin/test/FailNullForPrimitiveTest.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,33 @@ | ||
package tools.jackson.module.kotlin.test | ||
|
||
import junit.framework.TestCase.assertEquals | ||
import org.junit.Assert.assertThrows | ||
import tools.jackson.databind.DeserializationFeature | ||
import tools.jackson.databind.exc.MismatchedInputException | ||
import tools.jackson.module.kotlin.jacksonMapperBuilder | ||
import tools.jackson.module.kotlin.readValue | ||
import kotlin.test.Test | ||
|
||
class FailNullForPrimitiveTest { | ||
data class Dto( | ||
val foo: Int, | ||
val bar: Int? | ||
) | ||
|
||
@Test | ||
fun test() { | ||
val mapper = jacksonMapperBuilder() | ||
.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true) | ||
.build() | ||
|
||
assertThrows(MismatchedInputException::class.java) { | ||
mapper.readValue<Dto>("{}") | ||
} | ||
|
||
assertThrows(MismatchedInputException::class.java) { | ||
mapper.readValue<Dto>("""{"foo":null}""") | ||
} | ||
|
||
assertEquals(Dto(0, null), mapper.readValue<Dto>("""{"foo":0}""")) | ||
} | ||
} |
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