From ff168d479763926ecf969693c7e450fd3d84d1a1 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sun, 6 Apr 2025 10:07:31 -0700 Subject: [PATCH] Now that databind#5032 has merged `jackson-datatype-jsr310`, need to remove dep from kotlin module --- pom.xml | 6 ++++- .../module/kotlin/test/DurationTests.kt | 25 +++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 377480c36..092e6cb87 100644 --- a/pom.xml +++ b/pom.xml @@ -119,12 +119,16 @@ jackson-dataformat-xml test + + tools.jackson.datatype jackson-datatype-jsr310 test + --> diff --git a/src/test/kotlin/tools/jackson/module/kotlin/test/DurationTests.kt b/src/test/kotlin/tools/jackson/module/kotlin/test/DurationTests.kt index 012fee785..5dd53ff8d 100644 --- a/src/test/kotlin/tools/jackson/module/kotlin/test/DurationTests.kt +++ b/src/test/kotlin/tools/jackson/module/kotlin/test/DurationTests.kt @@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonFormat import com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING import tools.jackson.databind.SerializationFeature import tools.jackson.databind.json.JsonMapper -import tools.jackson.datatype.jsr310.JavaTimeModule import tools.jackson.module.kotlin.KotlinFeature import tools.jackson.module.kotlin.kotlinModule import tools.jackson.module.kotlin.readValue @@ -24,7 +23,7 @@ class DurationTests { @Test fun `should serialize Kotlin duration using Java time module`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()) + val mapper = mapperBuilder .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) .build() @@ -35,7 +34,7 @@ class DurationTests { @Test fun `should deserialize Kotlin duration`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()).build() + val mapper = mapperBuilder.build() val result = mapper.readValue("\"PT1H\"") @@ -44,7 +43,7 @@ class DurationTests { @Test fun `should serialize Kotlin duration inside list using Java time module`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()) + val mapper = mapperBuilder .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) .build() @@ -55,7 +54,7 @@ class DurationTests { @Test fun `should deserialize Kotlin duration inside list`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()).build() + val mapper = mapperBuilder.build() val result = mapper.readValue>("""["PT1H","PT2H","PT3H"]""") @@ -64,7 +63,7 @@ class DurationTests { @Test fun `should serialize Kotlin duration inside map using Java time module`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()) + val mapper = mapperBuilder .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) .build() @@ -81,7 +80,7 @@ class DurationTests { @Test fun `should deserialize Kotlin duration inside map`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()).build() + val mapper = mapperBuilder.build() val result = mapper.readValue>("""{"a":"PT1H","b":"PT2H","c":"PT3H"}""") @@ -109,7 +108,7 @@ class DurationTests { @Test fun `should serialize Kotlin duration inside data class using Java time module`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()) + val mapper = mapperBuilder .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) .build() @@ -121,7 +120,7 @@ class DurationTests { @Test fun `should deserialize Kotlin duration inside data class`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()).build() + val mapper = mapperBuilder.build() val result = mapper.readValue("""{"start":"2023-06-20T14:00:00Z","duration":"PT1H30M"}""") @@ -131,7 +130,7 @@ class DurationTests { @Test fun `should deserialize Kotlin duration inside data class using mixin`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()) + val mapper = mapperBuilder .addMixIn(Meeting::class.java, MeetingMixin::class.java) .build() @@ -143,7 +142,7 @@ class DurationTests { @Test fun `should serialize Kotlin duration inside data class using Java time module and mixin`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()) + val mapper = mapperBuilder .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .addMixIn(Meeting::class.java, MeetingMixin::class.java) .build() @@ -173,7 +172,7 @@ class DurationTests { @Test fun `should serialize Kotlin duration exactly as Java duration`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()).build() + val mapper = mapperBuilder.build() val jdto = JDTO() val kdto = KDTO() @@ -198,7 +197,7 @@ class DurationTests { @Test fun `should deserialize using custom units specified by format annotation`() { - val mapper = mapperBuilder.addModule(JavaTimeModule()).build() + val mapper = mapperBuilder.build() val actual = mapper.readValue("""{"formatted":1,"default":1}""")