From f518fb0e2778a8b7e68e2209c4b11860f3d7bd60 Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Wed, 30 Oct 2024 17:43:07 +0100 Subject: [PATCH] Add jsr310 dependency --- config/src/test/java/UrlPathUtilsTest.java | 74 ------------------ .../utils/config/utils/UrlPathUtilsTest.java | 76 +++++++++++++++++++ extensions/sovity-messenger/build.gradle.kts | 2 + gradle/libs.versions.toml | 2 + 4 files changed, 80 insertions(+), 74 deletions(-) delete mode 100644 config/src/test/java/UrlPathUtilsTest.java create mode 100644 config/src/test/java/de/sovity/edc/utils/config/utils/UrlPathUtilsTest.java diff --git a/config/src/test/java/UrlPathUtilsTest.java b/config/src/test/java/UrlPathUtilsTest.java deleted file mode 100644 index dfbdf6bc7..000000000 --- a/config/src/test/java/UrlPathUtilsTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2024 sovity GmbH - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * sovity GmbH - init - * - */ - -import org.junit.jupiter.api.Test; - -import static de.sovity.edc.utils.config.utils.UrlPathUtils.urlPathJoin; -import static org.assertj.core.api.Assertions.assertThat; - -class UrlPathUtilsTest { - @Test - void urlPathJoin_empty() { - assertThat(urlPathJoin()).isEmpty(); - assertThat(urlPathJoin("")).isEmpty(); - assertThat(urlPathJoin("/")).isEqualTo("/"); - } - - @Test - void urlPathJoin_relative() { - assertThat(urlPathJoin("a")).isEqualTo("a"); - assertThat(urlPathJoin("a/")).isEqualTo("a/"); - assertThat(urlPathJoin("a", "b")).isEqualTo("a/b"); - assertThat(urlPathJoin("a/", "b")).isEqualTo("a/b"); - assertThat(urlPathJoin("a", "/b")).isEqualTo("a/b"); - assertThat(urlPathJoin("a/", "/b")).isEqualTo("a/b"); - } - - @Test - void urlPathJoin_absolute() { - assertThat(urlPathJoin("/a")).isEqualTo("/a"); - assertThat(urlPathJoin("/a/")).isEqualTo("/a/"); - assertThat(urlPathJoin("/a", "b")).isEqualTo("/a/b"); - assertThat(urlPathJoin("/a/", "b")).isEqualTo("/a/b"); - assertThat(urlPathJoin("/a", "/b")).isEqualTo("/a/b"); - assertThat(urlPathJoin("/a/", "/b")).isEqualTo("/a/b"); - } - - @Test - void urlPathJoin_immediate_protocol() { - assertThat(urlPathJoin("https://")).isEqualTo("https://"); - assertThat(urlPathJoin("https://", "b")).isEqualTo("https://b"); - assertThat(urlPathJoin("https://", "/b")).isEqualTo("https://b"); - } - - @Test - void urlPathJoin_protocol() { - assertThat(urlPathJoin("https://a")).isEqualTo("https://a"); - assertThat(urlPathJoin("https://a/")).isEqualTo("https://a/"); - assertThat(urlPathJoin("https://a", "b")).isEqualTo("https://a/b"); - assertThat(urlPathJoin("https://a/", "b")).isEqualTo("https://a/b"); - assertThat(urlPathJoin("https://a", "/b")).isEqualTo("https://a/b"); - assertThat(urlPathJoin("https://a/", "/b")).isEqualTo("https://a/b"); - } - - @Test - void urlPathJoin_protocol_overruling_not_enabled() { - assertThat(urlPathJoin("https://ignored", "https://a")).isEqualTo("https://ignored/https://a"); - assertThat(urlPathJoin("https://ignored", "https://a/")).isEqualTo("https://ignored/https://a/"); - assertThat(urlPathJoin("https://ignored", "https://a", "b")).isEqualTo("https://ignored/https://a/b"); - assertThat(urlPathJoin("https://ignored", "https://a/", "b")).isEqualTo("https://ignored/https://a/b"); - assertThat(urlPathJoin("https://ignored", "https://a", "/b")).isEqualTo("https://ignored/https://a/b"); - assertThat(urlPathJoin("https://ignored", "https://a/", "/b")).isEqualTo("https://ignored/https://a/b"); - } -} diff --git a/config/src/test/java/de/sovity/edc/utils/config/utils/UrlPathUtilsTest.java b/config/src/test/java/de/sovity/edc/utils/config/utils/UrlPathUtilsTest.java new file mode 100644 index 000000000..37340f9f7 --- /dev/null +++ b/config/src/test/java/de/sovity/edc/utils/config/utils/UrlPathUtilsTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024 sovity GmbH + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * sovity GmbH - initial API and implementation + * + */ + +package de.sovity.edc.utils.config.utils; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +import static de.sovity.edc.utils.config.utils.UrlPathUtils.urlPathJoin; + +class UrlPathUtilsTest { + @Test + void urlPathJoin_empty() { + Assertions.assertThat(urlPathJoin()).isEmpty(); + Assertions.assertThat(urlPathJoin("")).isEmpty(); + Assertions.assertThat(urlPathJoin("/")).isEqualTo("/"); + } + + @Test + void urlPathJoin_relative() { + Assertions.assertThat(urlPathJoin("a")).isEqualTo("a"); + Assertions.assertThat(urlPathJoin("a/")).isEqualTo("a/"); + Assertions.assertThat(urlPathJoin("a", "b")).isEqualTo("a/b"); + Assertions.assertThat(urlPathJoin("a/", "b")).isEqualTo("a/b"); + Assertions.assertThat(urlPathJoin("a", "/b")).isEqualTo("a/b"); + Assertions.assertThat(urlPathJoin("a/", "/b")).isEqualTo("a/b"); + } + + @Test + void urlPathJoin_absolute() { + Assertions.assertThat(urlPathJoin("/a")).isEqualTo("/a"); + Assertions.assertThat(urlPathJoin("/a/")).isEqualTo("/a/"); + Assertions.assertThat(urlPathJoin("/a", "b")).isEqualTo("/a/b"); + Assertions.assertThat(urlPathJoin("/a/", "b")).isEqualTo("/a/b"); + Assertions.assertThat(urlPathJoin("/a", "/b")).isEqualTo("/a/b"); + Assertions.assertThat(urlPathJoin("/a/", "/b")).isEqualTo("/a/b"); + } + + @Test + void urlPathJoin_immediate_protocol() { + Assertions.assertThat(urlPathJoin("https://")).isEqualTo("https://"); + Assertions.assertThat(urlPathJoin("https://", "b")).isEqualTo("https://b"); + Assertions.assertThat(urlPathJoin("https://", "/b")).isEqualTo("https://b"); + } + + @Test + void urlPathJoin_protocol() { + Assertions.assertThat(urlPathJoin("https://a")).isEqualTo("https://a"); + Assertions.assertThat(urlPathJoin("https://a/")).isEqualTo("https://a/"); + Assertions.assertThat(urlPathJoin("https://a", "b")).isEqualTo("https://a/b"); + Assertions.assertThat(urlPathJoin("https://a/", "b")).isEqualTo("https://a/b"); + Assertions.assertThat(urlPathJoin("https://a", "/b")).isEqualTo("https://a/b"); + Assertions.assertThat(urlPathJoin("https://a/", "/b")).isEqualTo("https://a/b"); + } + + @Test + void urlPathJoin_protocol_overruling_not_enabled() { + Assertions.assertThat(urlPathJoin("https://ignored", "https://a")).isEqualTo("https://ignored/https://a"); + Assertions.assertThat(urlPathJoin("https://ignored", "https://a/")).isEqualTo("https://ignored/https://a/"); + Assertions.assertThat(urlPathJoin("https://ignored", "https://a", "b")).isEqualTo("https://ignored/https://a/b"); + Assertions.assertThat(urlPathJoin("https://ignored", "https://a/", "b")).isEqualTo("https://ignored/https://a/b"); + Assertions.assertThat(urlPathJoin("https://ignored", "https://a", "/b")).isEqualTo("https://ignored/https://a/b"); + Assertions.assertThat(urlPathJoin("https://ignored", "https://a/", "/b")).isEqualTo("https://ignored/https://a/b"); + } +} diff --git a/extensions/sovity-messenger/build.gradle.kts b/extensions/sovity-messenger/build.gradle.kts index 0f4207d85..cbec36ade 100644 --- a/extensions/sovity-messenger/build.gradle.kts +++ b/extensions/sovity-messenger/build.gradle.kts @@ -18,6 +18,8 @@ dependencies { implementation(libs.edc.managementApiConfiguration) implementation(libs.edc.transformLib) + implementation(libs.jackson.jsr310) + testAnnotationProcessor(libs.lombok) testCompileOnly(libs.lombok) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8775fb32b..c5421b645 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -33,6 +33,7 @@ gsonFire = "1.8.5" hibernateValidator = "8.0.1.Final" hidetakeSwagger = "2.19.2" hikari = "5.0.1" +jackson = "2.17.1" jakartaAnnotation = "1.3.5" jakartaEl = "4.0.2" jakartaJson = "2.0.1" @@ -177,6 +178,7 @@ gson = { module = "com.google.code.gson:gson", version.ref = "gson" } gsonFire = { module = "io.gsonfire:gson-fire", version.ref = "gsonFire" } hibernate-validation = { module = "org.hibernate.validator:hibernate-validator", version.ref = "hibernateValidator" } hikari = { module = "com.zaxxer:HikariCP", version.ref = "hikari" } +jackson-jsr310 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "jackson" } jakarta-annotationApi = { module = "jakarta.annotation:jakarta.annotation-api", version.ref = "jakartaAnnotation" } jakarta-el = { module = "org.glassfish:jakarta.el", version.ref = "jakartaEl" } jakarta-json = { module = "org.glassfish:jakarta.json", version.ref = "jakartaJson" }