diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 61e019d5..e1ed60f7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -52,6 +52,7 @@ couchbase-client-metrics = { module = "com.couchbase.client:metrics-micrometer", jackson-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" } jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" } jackson-arrow = { module = "io.arrow-kt:arrow-integrations-jackson-module", version = "0.14.1" } +jackson-jsr310 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "jackson" } slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" } ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" } diff --git a/lib/stove-testing-e2e-http/build.gradle.kts b/lib/stove-testing-e2e-http/build.gradle.kts index 9a4492f4..7c0b3c5c 100644 --- a/lib/stove-testing-e2e-http/build.gradle.kts +++ b/lib/stove-testing-e2e-http/build.gradle.kts @@ -10,4 +10,5 @@ dependencies { implementation(libs.ktor.client.content.negotiation) implementation(libs.ktor.serialization.jackson.json) testImplementation(projects.lib.stoveTestingE2eWiremock) + testImplementation(libs.jackson.jsr310) } diff --git a/lib/stove-testing-e2e-http/src/main/kotlin/com/trendyol/stove/testing/e2e/http/HttpSystem.kt b/lib/stove-testing-e2e-http/src/main/kotlin/com/trendyol/stove/testing/e2e/http/HttpSystem.kt index ebb5fabf..4842a547 100644 --- a/lib/stove-testing-e2e-http/src/main/kotlin/com/trendyol/stove/testing/e2e/http/HttpSystem.kt +++ b/lib/stove-testing-e2e-http/src/main/kotlin/com/trendyol/stove/testing/e2e/http/HttpSystem.kt @@ -268,13 +268,7 @@ class HttpSystem( } install(ContentNegotiation) { - jackson { - setTypeFactory(objectMapper.typeFactory) - setConfig(objectMapper.deserializationConfig) - setConfig(objectMapper.serializationConfig) - setSerializerFactory(objectMapper.serializerFactory) - setNodeFactory(objectMapper.nodeFactory) - } + register(ContentType.Application.Json, JacksonConverter(objectMapper)) } defaultRequest { diff --git a/lib/stove-testing-e2e-http/src/test/kotlin/com/trendyol/stove/testing/e2e/http/HttpSystemTests.kt b/lib/stove-testing-e2e-http/src/test/kotlin/com/trendyol/stove/testing/e2e/http/HttpSystemTests.kt index 45f3ab56..6fcb9fc0 100644 --- a/lib/stove-testing-e2e-http/src/test/kotlin/com/trendyol/stove/testing/e2e/http/HttpSystemTests.kt +++ b/lib/stove-testing-e2e-http/src/test/kotlin/com/trendyol/stove/testing/e2e/http/HttpSystemTests.kt @@ -3,12 +3,14 @@ package com.trendyol.stove.testing.e2e.http import arrow.core.* import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.matching.MultipartValuePattern +import com.trendyol.stove.testing.e2e.serialization.StoveObjectMapper import com.trendyol.stove.testing.e2e.system.TestSystem import com.trendyol.stove.testing.e2e.system.abstractions.ApplicationUnderTest import com.trendyol.stove.testing.e2e.wiremock.* import io.kotest.core.config.AbstractProjectConfig import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe +import java.time.Instant import java.util.* class NoApplication : ApplicationUnderTest { @@ -25,7 +27,13 @@ class TestConfig : AbstractProjectConfig() { override suspend fun beforeProject(): Unit = TestSystem("http://localhost:8086") .with { - httpClient() + httpClient { + HttpClientSystemOptions( + objectMapper = StoveObjectMapper.byConfiguring { + findAndRegisterModules() + } + ) + } wiremock { WireMockSystemOptions(8086) @@ -235,8 +243,28 @@ class HttpSystemTests : FunSpec({ } } } + + test("java time instant should work") { + val expectedGetDtoName = UUID.randomUUID().toString() + TestSystem.validate { + wiremock { + mockGet("/get", 200, responseBody = TestDtoWithInstant(expectedGetDtoName, Instant.now()).some()) + } + + http { + get("/get") { actual -> + actual.name shouldBe expectedGetDtoName + } + } + } + } }) data class TestDto( val name: String ) + +data class TestDtoWithInstant( + val name: String, + val instant: Instant +)