From 68cc5f0320720dd2dd1928ed441df3e7981c01b7 Mon Sep 17 00:00:00 2001 From: Vladislav Frolov <50615459+Cheshiriks@users.noreply.github.com> Date: Fri, 16 Feb 2024 12:28:43 +0300 Subject: [PATCH] Move WebConfig.kt to common (#2923) * Move WebConfig.kt to common --- .../save/backend/SaveApplication.kt | 1 + .../save/backend/DownloadFilesTest.kt | 2 +- .../controller/OrganizationControllerTest.kt | 2 +- save-cloud-common/build.gradle.kts | 1 + .../saveourtool/save}/configs/WebConfig.kt | 14 ++++---- .../save/cosv/configs/WebConfig.kt | 32 ------------------- 6 files changed, 11 insertions(+), 41 deletions(-) rename {save-backend/src/main/kotlin/com/saveourtool/save/backend => save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save}/configs/WebConfig.kt (73%) delete mode 100644 save-cosv/src/main/kotlin/com/saveourtool/save/cosv/configs/WebConfig.kt diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/SaveApplication.kt b/save-backend/src/main/kotlin/com/saveourtool/save/backend/SaveApplication.kt index 83eb779bc8..7f8fc88db8 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/SaveApplication.kt +++ b/save-backend/src/main/kotlin/com/saveourtool/save/backend/SaveApplication.kt @@ -11,6 +11,7 @@ import org.springframework.context.annotation.Import * An entrypoint for spring for save-backend */ @SpringBootApplication(scanBasePackages = [ + "com.saveourtool.save.configs", "com.saveourtool.save.backend", "com.saveourtool.save.service", "com.saveourtool.save.storage", diff --git a/save-backend/src/test/kotlin/com/saveourtool/save/backend/DownloadFilesTest.kt b/save-backend/src/test/kotlin/com/saveourtool/save/backend/DownloadFilesTest.kt index 2d9a68a113..0af52031bc 100644 --- a/save-backend/src/test/kotlin/com/saveourtool/save/backend/DownloadFilesTest.kt +++ b/save-backend/src/test/kotlin/com/saveourtool/save/backend/DownloadFilesTest.kt @@ -2,13 +2,13 @@ package com.saveourtool.save.backend import com.saveourtool.save.backend.configs.ConfigProperties import com.saveourtool.save.authservice.config.NoopWebSecurityConfig -import com.saveourtool.save.backend.configs.WebConfig import com.saveourtool.save.backend.controllers.DownloadFilesController import com.saveourtool.save.backend.controllers.FileController import com.saveourtool.save.backend.controllers.internal.FileInternalController import com.saveourtool.save.backend.service.* import com.saveourtool.save.backend.storage.* import com.saveourtool.save.backend.utils.mutateMockedUser +import com.saveourtool.save.configs.WebConfig import com.saveourtool.save.core.result.DebugInfo import com.saveourtool.save.core.result.Pass import com.saveourtool.save.domain.* diff --git a/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/OrganizationControllerTest.kt b/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/OrganizationControllerTest.kt index 90b90c4e88..40a9699dc8 100644 --- a/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/OrganizationControllerTest.kt +++ b/save-backend/src/test/kotlin/com/saveourtool/save/backend/controller/OrganizationControllerTest.kt @@ -1,13 +1,13 @@ package com.saveourtool.save.backend.controller import com.saveourtool.save.authservice.config.NoopWebSecurityConfig -import com.saveourtool.save.backend.configs.WebConfig import com.saveourtool.save.backend.controllers.OrganizationController import com.saveourtool.save.backend.repository.* import com.saveourtool.save.backend.service.* import com.saveourtool.save.backend.S11nTestConfig import com.saveourtool.save.backend.storage.TestsSourceSnapshotStorage import com.saveourtool.save.backend.utils.mutateMockedUser +import com.saveourtool.save.configs.WebConfig import com.saveourtool.save.domain.Role import com.saveourtool.save.entities.* import com.saveourtool.save.repository.* diff --git a/save-cloud-common/build.gradle.kts b/save-cloud-common/build.gradle.kts index 5aa7db2d44..3d174a82f4 100644 --- a/save-cloud-common/build.gradle.kts +++ b/save-cloud-common/build.gradle.kts @@ -74,6 +74,7 @@ kotlin { implementation(libs.spring.web) implementation(libs.spring.webflux) implementation(libs.spring.boot) + implementation(libs.spring.boot.starter.quartz) implementation(libs.spring.data.jpa) implementation(libs.jackson.module.kotlin) implementation(libs.hibernate.core) diff --git a/save-backend/src/main/kotlin/com/saveourtool/save/backend/configs/WebConfig.kt b/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/configs/WebConfig.kt similarity index 73% rename from save-backend/src/main/kotlin/com/saveourtool/save/backend/configs/WebConfig.kt rename to save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/configs/WebConfig.kt index 51280776dc..6f0682631a 100644 --- a/save-backend/src/main/kotlin/com/saveourtool/save/backend/configs/WebConfig.kt +++ b/save-cloud-common/src/jvmMain/kotlin/com/saveourtool/save/configs/WebConfig.kt @@ -5,7 +5,7 @@ "MISSING_KDOC_ON_FUNCTION", ) -package com.saveourtool.save.backend.configs +package com.saveourtool.save.configs import com.saveourtool.save.domain.supportTestStatus import com.saveourtool.save.test.analysis.metrics.supportTestMetrics @@ -24,9 +24,9 @@ import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder import org.springframework.web.reactive.config.WebFluxConfigurer @Configuration -class WebConfig { +open class WebConfig { @Bean - fun jackson2ObjectMapperBuilderCustomizer() = Jackson2ObjectMapperBuilderCustomizer { builder: Jackson2ObjectMapperBuilder -> + open fun jackson2ObjectMapperBuilderCustomizer() = Jackson2ObjectMapperBuilderCustomizer { builder: Jackson2ObjectMapperBuilder -> builder .supportTestStatus() .supportKLocalDateTime() @@ -35,13 +35,13 @@ class WebConfig { } @Bean - fun jackson2JsonEncoder(mapper: ObjectMapper) = Jackson2JsonEncoder(mapper) + open fun jackson2JsonEncoder(mapper: ObjectMapper) = Jackson2JsonEncoder(mapper) @Bean - fun jackson2JsonDecoder(mapper: ObjectMapper) = Jackson2JsonDecoder(mapper) + open fun jackson2JsonDecoder(mapper: ObjectMapper) = Jackson2JsonDecoder(mapper) @Bean - fun webFluxConfigurer(encoder: Jackson2JsonEncoder, decoder: Jackson2JsonDecoder) = + open fun webFluxConfigurer(encoder: Jackson2JsonEncoder, decoder: Jackson2JsonDecoder) = object : WebFluxConfigurer { override fun configureHttpMessageCodecs(configurer: ServerCodecConfigurer) { configurer.defaultCodecs().jackson2JsonEncoder(encoder) @@ -50,7 +50,7 @@ class WebConfig { } @Bean - fun jackson2WebClientCustomizer(jackson2JsonEncoder: Jackson2JsonEncoder, jackson2JsonDecoder: Jackson2JsonDecoder): WebClientCustomizer = WebClientCustomizer { builder -> + open fun jackson2WebClientCustomizer(jackson2JsonEncoder: Jackson2JsonEncoder, jackson2JsonDecoder: Jackson2JsonDecoder): WebClientCustomizer = WebClientCustomizer { builder -> builder.codecs { it.defaultCodecs().jackson2JsonEncoder(jackson2JsonEncoder) it.defaultCodecs().jackson2JsonDecoder(jackson2JsonDecoder) diff --git a/save-cosv/src/main/kotlin/com/saveourtool/save/cosv/configs/WebConfig.kt b/save-cosv/src/main/kotlin/com/saveourtool/save/cosv/configs/WebConfig.kt deleted file mode 100644 index f0866204e1..0000000000 --- a/save-cosv/src/main/kotlin/com/saveourtool/save/cosv/configs/WebConfig.kt +++ /dev/null @@ -1,32 +0,0 @@ -@file:Suppress( - "HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE", - "MISSING_KDOC_TOP_LEVEL", - "MISSING_KDOC_CLASS_ELEMENTS", - "MISSING_KDOC_ON_FUNCTION", -) - -package com.saveourtool.save.cosv.configs - -import com.fasterxml.jackson.databind.ObjectMapper -import org.springframework.boot.web.reactive.function.client.WebClientCustomizer -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.http.codec.json.Jackson2JsonDecoder -import org.springframework.http.codec.json.Jackson2JsonEncoder - -@Configuration -class WebConfig { - @Bean - fun jackson2JsonEncoder(mapper: ObjectMapper) = Jackson2JsonEncoder(mapper) - - @Bean - fun jackson2JsonDecoder(mapper: ObjectMapper) = Jackson2JsonDecoder(mapper) - - @Bean - fun jackson2WebClientCustomizer(jackson2JsonEncoder: Jackson2JsonEncoder, jackson2JsonDecoder: Jackson2JsonDecoder): WebClientCustomizer = WebClientCustomizer { builder -> - builder.codecs { - it.defaultCodecs().jackson2JsonEncoder(jackson2JsonEncoder) - it.defaultCodecs().jackson2JsonDecoder(jackson2JsonDecoder) - } - } -}