Skip to content

Commit cdfa1dc

Browse files
committed
Merge remote-tracking branch 'FasterXML/2.x' into 3.x
2 parents cb39e4e + f54ef6e commit cdfa1dc

File tree

14 files changed

+528
-4
lines changed

14 files changed

+528
-4
lines changed

.github/workflows/dep_build_v2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
matrix:
1717
java_version: ['8', '17', '21', '24']
1818
# Versions need to align with ones in 'main.yml' workflow
19-
kotlin_version: ['2.0.21', '2.1.20', '2.2.0-RC']
19+
kotlin_version: ['2.0.21', '2.1.21', '2.2.0-RC2']
2020
env:
2121
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
2222
steps:

.github/workflows/dep_build_v3.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
java_version: ['17', '21', '24']
1616
# Versions need to align with ones in 'main.yml' workflow
17-
kotlin_version: ['2.0.21', '2.1.20', '2.2.0-RC']
17+
kotlin_version: ['2.0.21', '2.1.21', '2.2.0-RC2']
1818
env:
1919
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
2020
steps:

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
max-parallel: 5
2222
matrix:
2323
java_version: ['17', '21', '24']
24-
kotlin_version: ['2.0.21', '2.1.20', '2.2.0-RC']
24+
kotlin_version: ['2.0.21', '2.1.21', '2.2.0-RC2']
2525
include:
2626
- java_version: '17'
2727
kotlin_version: '2.0.21'

release-notes/VERSION-2.x

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Co-maintainers:
2222
#967: Kotlin has been upgraded to 2.0.21.
2323
- Generate SBOMs [JSTEP-14]
2424

25-
2.19.1 (not yet released)
25+
2.19.1 (13-Jun-2025)
26+
27+
No changes since 2.19.0
2628

2729
2.19.0 (24-Apr-2025)
2830

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package tools.jackson.module.kotlin.kogeraIntegration.ser.valueClass.jsonKey
2+
3+
import com.fasterxml.jackson.annotation.JsonKey
4+
import tools.jackson.module.kotlin.defaultMapper
5+
import org.junit.jupiter.api.Assertions.assertEquals
6+
import org.junit.jupiter.api.Test
7+
8+
class NonNullObjectTest {
9+
@JvmInline
10+
value class NonNull(val v: String) {
11+
@JsonKey
12+
fun jsonValue() = v + "_modified"
13+
}
14+
15+
@Test
16+
fun nonNullTest() {
17+
assertEquals(
18+
"""{"test_modified":null}""",
19+
defaultMapper.writeValueAsString(mapOf(NonNull("test") to null)),
20+
)
21+
}
22+
23+
@JvmInline
24+
value class Nullable(val v: String) {
25+
@JsonKey
26+
fun jsonValue() = v.takeIf { it.length % 2 == 0 }?.let { it + "_modified" }
27+
}
28+
29+
// The case of returning null as a key is unnecessary because it will result in an error
30+
@Test
31+
fun nullableTest() {
32+
assertEquals(
33+
"""{"test_modified":null}""",
34+
defaultMapper.writeValueAsString(mapOf(Nullable("test") to null)),
35+
)
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package tools.jackson.module.kotlin.kogeraIntegration.ser.valueClass.jsonKey
2+
3+
import com.fasterxml.jackson.annotation.JsonKey
4+
import tools.jackson.module.kotlin.defaultMapper
5+
import org.junit.jupiter.api.Assertions.assertEquals
6+
import org.junit.jupiter.api.Test
7+
8+
class NullableObjectTest {
9+
@JvmInline
10+
value class Value(val v: String?) {
11+
@JsonKey
12+
fun jsonValue() = v?.let { it + "_modified" }
13+
}
14+
15+
// The case of returning null as a key is unnecessary because it will result in an error
16+
@Test
17+
fun test() {
18+
assertEquals(
19+
"""{"test_modified":null}""",
20+
defaultMapper.writeValueAsString(mapOf(Value("test") to null)),
21+
)
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package tools.jackson.module.kotlin.kogeraIntegration.ser.valueClass.jsonKey
2+
3+
import com.fasterxml.jackson.annotation.JsonKey
4+
import tools.jackson.module.kotlin.defaultMapper
5+
import org.junit.jupiter.api.Assertions.assertEquals
6+
import org.junit.jupiter.api.Test
7+
8+
class NullablePrimitiveTest {
9+
@JvmInline
10+
value class Value(val v: Int?) {
11+
@JsonKey
12+
fun jsonValue() = v?.let { it + 100 }
13+
}
14+
15+
// The case of returning null as a key is unnecessary because it will result in an error
16+
@Test
17+
fun test() {
18+
assertEquals(
19+
"""{"100":null}""",
20+
defaultMapper.writeValueAsString(mapOf(Value(0) to null)),
21+
)
22+
}
23+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package tools.jackson.module.kotlin.kogeraIntegration.ser.valueClass.jsonKey
2+
3+
import com.fasterxml.jackson.annotation.JsonKey
4+
import tools.jackson.module.kotlin.defaultMapper
5+
import org.junit.jupiter.api.Assertions.assertEquals
6+
import org.junit.jupiter.api.Test
7+
8+
class PrimitiveTest {
9+
@JvmInline
10+
value class NonNull(val v: Int) {
11+
@JsonKey
12+
fun jsonValue() = v + 100
13+
}
14+
15+
@Test
16+
fun nonNullTest() {
17+
assertEquals(
18+
"""{"100":null}""",
19+
defaultMapper.writeValueAsString(mapOf(NonNull(0) to null)),
20+
)
21+
}
22+
23+
@JvmInline
24+
value class Nullable(val v: Int) {
25+
@JsonKey
26+
fun jsonValue() = v.takeIf { it % 2 == 0 }?.let { it + 100 }
27+
}
28+
29+
// The case of returning null as a key is unnecessary because it will result in an error
30+
@Test
31+
fun nullableTest() {
32+
assertEquals(
33+
"""{"100":null}""",
34+
defaultMapper.writeValueAsString(mapOf(Nullable(0) to null)),
35+
)
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package tools.jackson.module.kotlin.kogeraIntegration.ser.valueClass.jsonKey
2+
3+
import com.fasterxml.jackson.annotation.JsonKey
4+
import tools.jackson.module.kotlin.defaultMapper
5+
import org.junit.jupiter.api.Assertions.assertEquals
6+
import org.junit.jupiter.api.Test
7+
8+
class TwoUnitPrimitiveTest {
9+
@JvmInline
10+
value class NonNull(val v: Long) {
11+
@JsonKey
12+
fun jsonValue() = v + 100
13+
}
14+
15+
@Test
16+
fun nonNullTest() {
17+
assertEquals(
18+
"""{"100":null}""",
19+
defaultMapper.writeValueAsString(mapOf(NonNull(0) to null)),
20+
)
21+
}
22+
23+
@JvmInline
24+
value class Nullable(val v: Long) {
25+
@JsonKey
26+
fun jsonValue() = v.takeIf { it % 2L == 0L }?.let { it + 100 }
27+
}
28+
29+
// The case of returning null as a key is unnecessary because it will result in an error
30+
@Test
31+
fun nullableTest() {
32+
assertEquals(
33+
"""{"100":null}""",
34+
defaultMapper.writeValueAsString(mapOf(Nullable(0) to null)),
35+
)
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package tools.jackson.module.kotlin.kogeraIntegration.ser.valueClass.jsonValue
2+
3+
import com.fasterxml.jackson.annotation.JsonValue
4+
import tools.jackson.module.kotlin.defaultMapper
5+
import org.junit.jupiter.api.Assertions.assertEquals
6+
import org.junit.jupiter.api.Nested
7+
import org.junit.jupiter.api.Test
8+
9+
class NonNullObjectTest {
10+
@JvmInline
11+
value class NonNull(val v: String) {
12+
@JsonValue
13+
fun jsonValue() = v + "_modified"
14+
}
15+
16+
data class NonNullDto(val v: NonNull)
17+
18+
@Nested
19+
inner class NonNullTest {
20+
@Test
21+
fun direct() {
22+
assertEquals(
23+
"\"test_modified\"",
24+
defaultMapper.writeValueAsString(NonNull("test")),
25+
)
26+
}
27+
28+
@Test
29+
fun asProperty() {
30+
assertEquals(
31+
"""{"v":"test_modified"}""",
32+
defaultMapper.writeValueAsString(NonNullDto(NonNull("test"))),
33+
)
34+
}
35+
}
36+
37+
@JvmInline
38+
value class Nullable(val v: String) {
39+
@JsonValue
40+
fun jsonValue() = v.takeIf { it.length % 2 == 0 }?.let { it + "_modified" }
41+
}
42+
43+
data class NullableDto(val v: Nullable)
44+
45+
@Nested
46+
inner class NullableTest {
47+
@Nested
48+
inner class DirectTest {
49+
@Test
50+
fun nonNull() {
51+
assertEquals(
52+
"\"even_modified\"",
53+
defaultMapper.writeValueAsString(Nullable("even")),
54+
)
55+
}
56+
57+
@Test
58+
fun `null`() {
59+
assertEquals(
60+
"null",
61+
defaultMapper.writeValueAsString(Nullable("odd")),
62+
)
63+
}
64+
}
65+
66+
@Nested
67+
inner class AsPropertyTest {
68+
@Test
69+
fun nonNull() {
70+
assertEquals(
71+
"""{"v":"even_modified"}""",
72+
defaultMapper.writeValueAsString(NullableDto(Nullable("even"))),
73+
)
74+
}
75+
76+
@Test
77+
fun `null`() {
78+
assertEquals(
79+
"""{"v":null}""",
80+
defaultMapper.writeValueAsString(NullableDto(Nullable("odd"))),
81+
)
82+
}
83+
}
84+
}
85+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package tools.jackson.module.kotlin.kogeraIntegration.ser.valueClass.jsonValue
2+
3+
import com.fasterxml.jackson.annotation.JsonValue
4+
import tools.jackson.module.kotlin.defaultMapper
5+
import org.junit.jupiter.api.Assertions.assertEquals
6+
import org.junit.jupiter.api.Nested
7+
import org.junit.jupiter.api.Test
8+
9+
class NullableObjectTest {
10+
@JvmInline
11+
value class Value(val v: String?) {
12+
@JsonValue
13+
fun jsonValue() = v?.let { it + "_modified" }
14+
}
15+
16+
@Nested
17+
inner class DirectTest {
18+
@Test
19+
fun nonNull() {
20+
assertEquals(
21+
"\"test_modified\"",
22+
defaultMapper.writeValueAsString(Value("test")),
23+
)
24+
}
25+
26+
@Test
27+
fun `null`() {
28+
assertEquals(
29+
"null",
30+
defaultMapper.writeValueAsString(Value(null)),
31+
)
32+
}
33+
}
34+
35+
data class Dto(val v: Value)
36+
37+
@Nested
38+
inner class AsPropertyTest {
39+
@Test
40+
fun nonNull() {
41+
assertEquals(
42+
"""{"v":"test_modified"}""",
43+
defaultMapper.writeValueAsString(Dto(Value("test"))),
44+
)
45+
}
46+
47+
@Test
48+
fun `null`() {
49+
assertEquals(
50+
"""{"v":null}""",
51+
defaultMapper.writeValueAsString(Dto(Value(null))),
52+
)
53+
}
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package tools.jackson.module.kotlin.kogeraIntegration.ser.valueClass.jsonValue
2+
3+
import com.fasterxml.jackson.annotation.JsonValue
4+
import tools.jackson.module.kotlin.defaultMapper
5+
import org.junit.jupiter.api.Assertions.assertEquals
6+
import org.junit.jupiter.api.Nested
7+
import org.junit.jupiter.api.Test
8+
9+
class NullablePrimitiveTest {
10+
@JvmInline
11+
value class Value(val v: Int?) {
12+
@JsonValue
13+
fun jsonValue() = v?.let { it + 100 }
14+
}
15+
16+
@Nested
17+
inner class DirectTest {
18+
@Test
19+
fun nonNull() {
20+
assertEquals(
21+
"100",
22+
defaultMapper.writeValueAsString(Value(0)),
23+
)
24+
}
25+
26+
@Test
27+
fun `null`() {
28+
assertEquals(
29+
"null",
30+
defaultMapper.writeValueAsString(Value(null)),
31+
)
32+
}
33+
}
34+
35+
data class Dto(val v: Value)
36+
37+
@Nested
38+
inner class AsPropertyTest {
39+
@Test
40+
fun nonNull() {
41+
assertEquals(
42+
"""{"v":100}""",
43+
defaultMapper.writeValueAsString(Dto(Value(0))),
44+
)
45+
}
46+
47+
@Test
48+
fun `null`() {
49+
assertEquals(
50+
"""{"v":null}""",
51+
defaultMapper.writeValueAsString(Dto(Value(null))),
52+
)
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)