diff --git a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/UnsignedNumbersOnKeyTest.kt b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/UnsignedNumbersOnKeyTest.kt index 28b038d6..082eff77 100644 --- a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/UnsignedNumbersOnKeyTest.kt +++ b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/UnsignedNumbersOnKeyTest.kt @@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.exc.InputCoercionException import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.fasterxml.jackson.module.kotlin.readValue import org.junit.jupiter.api.Assertions.assertThrows +import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import java.math.BigInteger import kotlin.test.assertEquals @@ -13,7 +14,8 @@ internal class UnsignedNumbersOnKeyTest { val MAPPER = jacksonObjectMapper() } - class ForUByte { + @Nested + inner class ForUByte { private fun makeSrc(v: Int): String = MAPPER.writeValueAsString(mapOf(v to 0)) @Test @@ -37,7 +39,8 @@ internal class UnsignedNumbersOnKeyTest { } } - class ForUShort { + @Nested + inner class ForUShort { private fun makeSrc(v: Int): String = MAPPER.writeValueAsString(mapOf(v to 0)) @Test @@ -61,7 +64,8 @@ internal class UnsignedNumbersOnKeyTest { } } - class ForUInt { + @Nested + inner class ForUInt { private fun makeSrc(v: Long): String = MAPPER.writeValueAsString(mapOf(v to 0)) @Test @@ -85,7 +89,8 @@ internal class UnsignedNumbersOnKeyTest { } } - class ForULong { + @Nested + inner class ForULong { private fun makeSrc(v: BigInteger): String = MAPPER.writeValueAsString(mapOf(v to 0)) @Test diff --git a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github101.kt b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github101.kt index de01e095..f7b4fcba 100644 --- a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github101.kt +++ b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github101.kt @@ -10,13 +10,15 @@ import kotlin.test.assertEquals class TestGithub101_JacksonInjectTest { @Test fun `JacksonInject-annotated parameters are populated when constructing Kotlin data classes`() { - val mapper = jacksonObjectMapper() val contextualValue = UUID.randomUUID() - assertEquals(SomeDatum("test", contextualValue), - mapper.readerFor(SomeDatum::class.java) - .with(InjectableValues.Std(mapOf("context" to contextualValue))) - .readValue("""{ "value": "test" }""")) + val reader = jacksonObjectMapper() + .readerFor(SomeDatum::class.java) + .with(InjectableValues.Std(mapOf("context" to contextualValue))) + assertEquals( + SomeDatum("test", contextualValue), + reader.readValue("""{ "value": "test" }""") + ) } data class SomeDatum(val value: String, @JacksonInject("context") val contextualValue: UUID) -} \ No newline at end of file +} diff --git a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github148.kt b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github148.kt index b4904fe8..b44504f8 100644 --- a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github148.kt +++ b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github148.kt @@ -1,6 +1,7 @@ package com.fasterxml.jackson.module.kotlin.test.github import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import kotlin.test.assertEquals @@ -32,7 +33,8 @@ class TestGithub148 { val type: IncorrectType ) - class DemoApplicationTests { + @Nested + inner class DemoApplicationTests { val objectMapper = jacksonObjectMapper() @Test @@ -45,4 +47,4 @@ class TestGithub148 { assertEquals("{\"name\":\"incorrent\",\"type\":\"TYPEA\"}", objectMapper.writeValueAsString(IncorrentBean("incorrent", IncorrectType.TYPEA))) } } -} \ No newline at end of file +} diff --git a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github168.kt b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github168.kt index 114bba16..29d31995 100644 --- a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github168.kt +++ b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github168.kt @@ -13,7 +13,7 @@ class TestGithub168 { class TestClass(@JsonProperty(value = "foo", required = true) foo: String?, val baz: String) @Test - fun testIfRequiredIsReallyRequiredWhenNullused() { + fun testIfRequiredIsReallyRequiredWhenNullUsed() { val obj = jacksonObjectMapper().readValue("""{"foo":null,"baz":"whatever"}""") assertEquals("whatever", obj.baz) } @@ -27,7 +27,7 @@ class TestGithub168 { } @Test - fun testIfRequiredIsReallyRequiredWhenVauePresent() { + fun testIfRequiredIsReallyRequiredWhenValuePresent() { val obj = jacksonObjectMapper().readValue("""{"foo":"yay!","baz":"whatever"}""") assertEquals("whatever", obj.baz) } diff --git a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github722.kt b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github722.kt index 4ce93214..d7c51893 100644 --- a/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github722.kt +++ b/src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github/Github722.kt @@ -6,10 +6,8 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.InjectableValues import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import kotlin.math.exp import org.junit.jupiter.api.Test import kotlin.test.assertEquals -import kotlin.test.assertNotEquals class Github722 { data class FailingDto @JsonCreator constructor( @@ -39,11 +37,13 @@ class Github722 { @Test fun failing() { // The kotlin mapper uses the Kotlin default value instead of the Inject value. - val kotlinMapper = jacksonObjectMapper() - val result = kotlinMapper.readerFor(FailingDto::class.java) + val reader = jacksonObjectMapper() + .readerFor(FailingDto::class.java) .with(InjectableValues.Std(injectValues)) - .readValue("{}") + val result = reader.readValue("{}") + // fixed + // assertNotEquals(result, expected, "GitHubXXX fixed.") assertEquals(expected, result) } @@ -56,10 +56,10 @@ class Github722 { @Test fun withoutDefaultValue() { - val kotlinMapper = jacksonObjectMapper() - val result = kotlinMapper.readerFor(WithoutDefaultValue::class.java) + val reader = jacksonObjectMapper() + .readerFor(WithoutDefaultValue::class.java) .with(InjectableValues.Std(injectValues)) - .readValue("{}") + val result = reader.readValue("{}") // If there is no default value, the problem does not occur. assertEquals(WithoutDefaultValue(1, 2), result)