Skip to content

Commit 738f1a7

Browse files
committed
Merge remote-tracking branch 'FasterXML/2.x' into 3.x
2 parents fccba37 + bacd832 commit 738f1a7

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

src/test/kotlin/tools/jackson/module/kotlin/test/UnsignedNumbersOnKeyTest.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import tools.jackson.core.exc.InputCoercionException
44
import tools.jackson.module.kotlin.jacksonObjectMapper
55
import tools.jackson.module.kotlin.readValue
66
import org.junit.jupiter.api.Assertions.assertThrows
7+
import org.junit.jupiter.api.Nested
78
import org.junit.jupiter.api.Test
89
import java.math.BigInteger
910
import kotlin.test.assertEquals
@@ -13,7 +14,8 @@ internal class UnsignedNumbersOnKeyTest {
1314
val MAPPER = jacksonObjectMapper()
1415
}
1516

16-
class ForUByte {
17+
@Nested
18+
inner class ForUByte {
1719
private fun makeSrc(v: Int): String = MAPPER.writeValueAsString(mapOf(v to 0))
1820

1921
@Test
@@ -37,7 +39,8 @@ internal class UnsignedNumbersOnKeyTest {
3739
}
3840
}
3941

40-
class ForUShort {
42+
@Nested
43+
inner class ForUShort {
4144
private fun makeSrc(v: Int): String = MAPPER.writeValueAsString(mapOf(v to 0))
4245

4346
@Test
@@ -61,7 +64,8 @@ internal class UnsignedNumbersOnKeyTest {
6164
}
6265
}
6366

64-
class ForUInt {
67+
@Nested
68+
inner class ForUInt {
6569
private fun makeSrc(v: Long): String = MAPPER.writeValueAsString(mapOf(v to 0))
6670

6771
@Test
@@ -85,7 +89,8 @@ internal class UnsignedNumbersOnKeyTest {
8589
}
8690
}
8791

88-
class ForULong {
92+
@Nested
93+
inner class ForULong {
8994
private fun makeSrc(v: BigInteger): String = MAPPER.writeValueAsString(mapOf(v to 0))
9095

9196
@Test

src/test/kotlin/tools/jackson/module/kotlin/test/github/Github101.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import kotlin.test.assertEquals
1010
class TestGithub101_JacksonInjectTest {
1111
@Test
1212
fun `JacksonInject-annotated parameters are populated when constructing Kotlin data classes`() {
13-
val mapper = jacksonObjectMapper()
1413
val contextualValue = UUID.randomUUID()
15-
assertEquals(SomeDatum("test", contextualValue),
16-
mapper.readerFor(SomeDatum::class.java)
17-
.with(InjectableValues.Std(mapOf("context" to contextualValue)))
18-
.readValue("""{ "value": "test" }"""))
14+
val reader = jacksonObjectMapper()
15+
.readerFor(SomeDatum::class.java)
16+
.with(InjectableValues.Std(mapOf("context" to contextualValue)))
17+
assertEquals(
18+
SomeDatum("test", contextualValue),
19+
reader.readValue("""{ "value": "test" }""")
20+
)
1921
}
2022

2123
data class SomeDatum(val value: String, @JacksonInject("context") val contextualValue: UUID)

src/test/kotlin/tools/jackson/module/kotlin/test/github/Github148.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package tools.jackson.module.kotlin.test.github
22

3+
import org.junit.jupiter.api.Nested
34
import tools.jackson.module.kotlin.jacksonObjectMapper
45
import org.junit.jupiter.api.Test
56
import kotlin.test.assertEquals
@@ -32,7 +33,8 @@ class TestGithub148 {
3233
val type: IncorrectType
3334
)
3435

35-
class DemoApplicationTests {
36+
@Nested
37+
inner class DemoApplicationTests {
3638
val objectMapper = jacksonObjectMapper()
3739

3840
@Test
@@ -45,4 +47,4 @@ class TestGithub148 {
4547
assertEquals("{\"name\":\"incorrent\",\"type\":\"TYPEA\"}", objectMapper.writeValueAsString(IncorrentBean("incorrent", IncorrectType.TYPEA)))
4648
}
4749
}
48-
}
50+
}

src/test/kotlin/tools/jackson/module/kotlin/test/github/Github168.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TestGithub168 {
1818

1919
@Test
2020
fun testIfRequiredIsReallyRequiredWhenNullUsed() {
21-
val obj = MAPPER.readValue<TestClass>("""{"foo":null,"baz":"whatever"}""")
21+
val obj = jacksonObjectMapper().readValue<TestClass>("""{"foo":null,"baz":"whatever"}""")
2222
assertEquals("whatever", obj.baz)
2323
}
2424

@@ -32,7 +32,7 @@ class TestGithub168 {
3232

3333
@Test
3434
fun testIfRequiredIsReallyRequiredWhenValuePresent() {
35-
val obj = MAPPER.readValue<TestClass>("""{"foo":"yay!","baz":"whatever"}""")
35+
val obj = jacksonObjectMapper().readValue<TestClass>("""{"foo":"yay!","baz":"whatever"}""")
3636
assertNotNull(obj)
3737
assertEquals("whatever", obj.baz)
3838
}

src/test/kotlin/tools/jackson/module/kotlin/test/github/Github722.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonProperty
66
import tools.jackson.databind.InjectableValues
77
import tools.jackson.databind.ObjectMapper
88
import tools.jackson.module.kotlin.jacksonObjectMapper
9-
import kotlin.math.exp
109
import org.junit.jupiter.api.Test
1110
import kotlin.test.assertEquals
1211

@@ -38,11 +37,13 @@ class Github722 {
3837
@Test
3938
fun failing() {
4039
// The kotlin mapper uses the Kotlin default value instead of the Inject value.
41-
val kotlinMapper = jacksonObjectMapper()
42-
val result = kotlinMapper.readerFor(FailingDto::class.java)
40+
val reader = jacksonObjectMapper()
41+
.readerFor(FailingDto::class.java)
4342
.with(InjectableValues.Std(injectValues))
44-
.readValue<FailingDto>("{}")
43+
val result = reader.readValue<FailingDto>("{}")
4544

45+
// fixed
46+
// assertNotEquals(result, expected, "GitHubXXX fixed.")
4647
assertEquals(expected, result)
4748
}
4849

@@ -55,10 +56,10 @@ class Github722 {
5556

5657
@Test
5758
fun withoutDefaultValue() {
58-
val kotlinMapper = jacksonObjectMapper()
59-
val result = kotlinMapper.readerFor(WithoutDefaultValue::class.java)
59+
val reader = jacksonObjectMapper()
60+
.readerFor(WithoutDefaultValue::class.java)
6061
.with(InjectableValues.Std(injectValues))
61-
.readValue<WithoutDefaultValue>("{}")
62+
val result = reader.readValue<WithoutDefaultValue>("{}")
6263

6364
// If there is no default value, the problem does not occur.
6465
assertEquals(WithoutDefaultValue(1, 2), result)

0 commit comments

Comments
 (0)