From 04df9563b389f76a84ce533207f1b0b112d4ac35 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Tue, 3 Nov 2026 13:19:09 +0200 Subject: [PATCH 01/19] Release `v1.3.2`. --- CHANGELOG.md | 4 ++++ README.md | 4 ++-- apiphany-core/pom.xml | 2 +- apiphany-httpclient5/pom.xml | 2 +- apiphany-integration-tests/pom.xml | 2 +- apiphany-okhttp/pom.xml | 2 +- apiphany-spring/pom.xml | 2 +- apiphany-test/pom.xml | 2 +- integration/apiphany-httpclient5-tests/pom.xml | 2 +- integration/apiphany-json-jackson2-tests/pom.xml | 2 +- integration/apiphany-json-jackson3-tests/pom.xml | 2 +- integration/apiphany-json-no-dependency-tests/pom.xml | 2 +- integration/apiphany-okhttp-tests/pom.xml | 2 +- integration/apiphany-spring-no-client-tests/pom.xml | 2 +- integration/apiphany-spring-tests/pom.xml | 2 +- pom.xml | 2 +- 16 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 949fc484..d816f8c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Release Notes +`1.3.2` + +--- + `1.3.1` - Preserved header insertion order in `Headers.of()`. diff --git a/README.md b/README.md index f5e33fd5..b0f72fea 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Support is being developed for other HTTP clients like Netty, Jersey, etc. If yo ### Releases -Current release `1.3.1` +Current release `1.3.2` ### Getting Started @@ -62,7 +62,7 @@ Maven: add this dependency to your `pom.xml` io.github.raduking apiphany - 1.3.1 + 1.3.2 ``` diff --git a/apiphany-core/pom.xml b/apiphany-core/pom.xml index 8f7a035f..401b4494 100644 --- a/apiphany-core/pom.xml +++ b/apiphany-core/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 apiphany diff --git a/apiphany-httpclient5/pom.xml b/apiphany-httpclient5/pom.xml index a3f7a50f..0bf01a48 100644 --- a/apiphany-httpclient5/pom.xml +++ b/apiphany-httpclient5/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 apiphany-httpclient5 diff --git a/apiphany-integration-tests/pom.xml b/apiphany-integration-tests/pom.xml index 2ee2cb41..b9e52eeb 100644 --- a/apiphany-integration-tests/pom.xml +++ b/apiphany-integration-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 apiphany-integration-tests diff --git a/apiphany-okhttp/pom.xml b/apiphany-okhttp/pom.xml index 194636cd..df660240 100644 --- a/apiphany-okhttp/pom.xml +++ b/apiphany-okhttp/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 apiphany-okhttp diff --git a/apiphany-spring/pom.xml b/apiphany-spring/pom.xml index b2474320..d02d12a4 100644 --- a/apiphany-spring/pom.xml +++ b/apiphany-spring/pom.xml @@ -7,7 +7,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 apiphany-spring diff --git a/apiphany-test/pom.xml b/apiphany-test/pom.xml index 947c9527..df2f5dfb 100644 --- a/apiphany-test/pom.xml +++ b/apiphany-test/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 apiphany-test diff --git a/integration/apiphany-httpclient5-tests/pom.xml b/integration/apiphany-httpclient5-tests/pom.xml index 121c6eef..d131d492 100644 --- a/integration/apiphany-httpclient5-tests/pom.xml +++ b/integration/apiphany-httpclient5-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 ../../pom.xml diff --git a/integration/apiphany-json-jackson2-tests/pom.xml b/integration/apiphany-json-jackson2-tests/pom.xml index a52e5a18..0336b8ee 100644 --- a/integration/apiphany-json-jackson2-tests/pom.xml +++ b/integration/apiphany-json-jackson2-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 ../../pom.xml diff --git a/integration/apiphany-json-jackson3-tests/pom.xml b/integration/apiphany-json-jackson3-tests/pom.xml index 214d2a49..f9707b76 100644 --- a/integration/apiphany-json-jackson3-tests/pom.xml +++ b/integration/apiphany-json-jackson3-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 ../../pom.xml diff --git a/integration/apiphany-json-no-dependency-tests/pom.xml b/integration/apiphany-json-no-dependency-tests/pom.xml index 70d05d00..5e0803a9 100644 --- a/integration/apiphany-json-no-dependency-tests/pom.xml +++ b/integration/apiphany-json-no-dependency-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 ../../pom.xml diff --git a/integration/apiphany-okhttp-tests/pom.xml b/integration/apiphany-okhttp-tests/pom.xml index 5ac0a941..e127e5ec 100644 --- a/integration/apiphany-okhttp-tests/pom.xml +++ b/integration/apiphany-okhttp-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 ../../pom.xml diff --git a/integration/apiphany-spring-no-client-tests/pom.xml b/integration/apiphany-spring-no-client-tests/pom.xml index 173b090e..72f85be2 100644 --- a/integration/apiphany-spring-no-client-tests/pom.xml +++ b/integration/apiphany-spring-no-client-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 ../../pom.xml diff --git a/integration/apiphany-spring-tests/pom.xml b/integration/apiphany-spring-tests/pom.xml index d4140ad4..ea14c64a 100644 --- a/integration/apiphany-spring-tests/pom.xml +++ b/integration/apiphany-spring-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 ../../pom.xml diff --git a/pom.xml b/pom.xml index 12cf2a4c..62117aed 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ io.github.raduking apiphany-parent - 1.3.1 + 1.3.2 pom ${project.groupId}:${project.artifactId} From d281d0112a16479d848d09834eb17c1b0e8eff73 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Tue, 3 Nov 2026 18:44:01 +0200 Subject: [PATCH 02/19] Use the new `CaseInsensitiveLinkedHashMap`. --- .../client/http/OkHttpExchangeClient.java | 69 +------------------ 1 file changed, 2 insertions(+), 67 deletions(-) diff --git a/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java b/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java index 94b35d97..0ed24fc2 100644 --- a/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java +++ b/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java @@ -2,14 +2,12 @@ import java.io.File; import java.io.InputStream; -import java.io.Serial; import java.io.Serializable; import java.net.URI; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.ArrayList; -import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -36,6 +34,7 @@ import org.apiphany.security.ssl.SSLProperties; import org.morphix.lang.JavaObjects; import org.morphix.lang.Nullables; +import org.morphix.lang.collections.CaseInsensitiveLinkedHashMap; import org.morphix.lang.collections.Lists; import org.morphix.lang.collections.Maps; import org.morphix.lang.function.Predicates; @@ -308,7 +307,7 @@ protected ApiResponse buildResponse(final ApiRequest apiRequest, fi * @return HTTP headers in their first-seen order */ static Map> toHttpHeadersMap(final Headers headers) { - Map> result = new CaseInsensitiveStringLinkedHashMap<>(); + Map> result = new CaseInsensitiveLinkedHashMap<>(); for (int i = 0; i < headers.size(); ++i) { String name = headers.name(i).toLowerCase(Locale.US); result.computeIfAbsent(name, key -> new ArrayList<>(2)).add(headers.value(i)); @@ -316,70 +315,6 @@ static Map> toHttpHeadersMap(final Headers headers) { return result; } - /** - * Insertion-ordered map used for OkHttp response headers. Header names are stored in lowercase and can be retrieved - * case-insensitively. - * - * @author Radu Sebastian LAZIN - */ - private static final class CaseInsensitiveStringLinkedHashMap extends LinkedHashMap { - - /** - * Serial version UID for serialization. - */ - @Serial - private static final long serialVersionUID = -1595053084733211507L; - - /** - * Constructs a new, empty map with insertion order. - */ - public CaseInsensitiveStringLinkedHashMap() { - // empty - } - - /** - * @see LinkedHashMap#get(Object) - */ - @Override - public V get(final Object key) { - return super.get(normalize(key)); - } - - /** - * @see LinkedHashMap#put(String, Object) - */ - @Override - public boolean containsKey(final Object key) { - return super.containsKey(normalize(key)); - } - - /** - * @see LinkedHashMap#put(String, Object) - */ - @Override - public V remove(final Object key) { - return super.remove(normalize(key)); - } - - /** - * @see LinkedHashMap#put(String, Object) - */ - @Override - public V getOrDefault(final Object key, final V defaultValue) { - return super.getOrDefault(normalize(key), defaultValue); - } - - /** - * Normalizes the given key to a lowercase string using {@link Locale#US}. Returns null if the key is not a string. - * - * @param key the key to normalize - * @return the normalized key, or null if the key is not a string - */ - private static String normalize(final Object key) { - return key instanceof String string ? string.toLowerCase(Locale.US) : null; - } - } - /** * Returns the response body converted to the target type. If the request is a stream, the response body is returned as * an input stream, otherwise it is returned as a byte array. From 274ae05a0bf6ff40cd646150369a4eebc55e4edf Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Tue, 3 Nov 2026 20:17:51 +0200 Subject: [PATCH 03/19] Ignore version override warnings in `apiphany-spring`. --- apiphany-spring/pom.xml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/apiphany-spring/pom.xml b/apiphany-spring/pom.xml index d02d12a4..a4bd75da 100644 --- a/apiphany-spring/pom.xml +++ b/apiphany-spring/pom.xml @@ -126,7 +126,7 @@ com.fasterxml.jackson.core jackson-core - ${jackson2.version} + ${jackson2.version} provided true @@ -134,7 +134,7 @@ com.fasterxml.jackson.core jackson-databind - ${jackson2.version} + ${jackson2.version} provided true @@ -142,7 +142,7 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 - ${jackson2.version} + ${jackson2.version} provided true @@ -150,7 +150,7 @@ com.fasterxml.jackson.datatype jackson-datatype-jdk8 - ${jackson2.version} + ${jackson2.version} provided true @@ -158,7 +158,7 @@ com.fasterxml.jackson.dataformat jackson-dataformat-xml - ${jackson2.version} + ${jackson2.version} provided true @@ -166,7 +166,7 @@ tools.jackson.core jackson-core - ${jackson3.version} + ${jackson3.version} provided true @@ -174,7 +174,7 @@ tools.jackson.core jackson-databind - ${jackson3.version} + ${jackson3.version} provided true @@ -182,16 +182,23 @@ tools.jackson.dataformat jackson-dataformat-xml - ${jackson3.version} + ${jackson3.version} provided true + + ch.qos.logback + logback-core + ${logback.version} + test + + ch.qos.logback logback-classic - ${logback.version} + ${logback.version} test From fd86999e45197537b16dac0c4e725cf0a48137b1 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Tue, 3 Nov 2026 20:56:04 +0200 Subject: [PATCH 04/19] Changed classes that use headers to use `CaseInsensitiveLinkedHashMap`. --- CHANGELOG.md | 4 ++++ apiphany-core/src/main/java/org/apiphany/header/Headers.java | 5 ++--- .../apiphany/client/http/ApacheHC5HttpExchangeClient.java | 4 ++-- .../java/org/apiphany/client/http/OkHttpExchangeClient.java | 5 +++-- .../org/apiphany/client/http/OkHttpExchangeClientTest.java | 3 ++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d816f8c2..8b8c235c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ `1.3.2` +- Changed `Headers.of` to use `CaseInsensitiveLinkedHashMap` from MorphiX. +- Updated `ApacheHC5ExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. +- Updated `OkHttpExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. + --- `1.3.1` diff --git a/apiphany-core/src/main/java/org/apiphany/header/Headers.java b/apiphany-core/src/main/java/org/apiphany/header/Headers.java index d760e2f8..f4c65bba 100644 --- a/apiphany-core/src/main/java/org/apiphany/header/Headers.java +++ b/apiphany-core/src/main/java/org/apiphany/header/Headers.java @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.BiPredicate; @@ -12,6 +11,7 @@ import org.apiphany.lang.Strings; import org.morphix.lang.Nullables; +import org.morphix.lang.collections.CaseInsensitiveLinkedHashMap; import org.morphix.lang.collections.Lists; import org.morphix.lang.collections.Maps; @@ -39,8 +39,7 @@ static Map> of(final HeaderFunction... headerFunctions) { if (null == headerFunctions || 0 == headerFunctions.length) { return Collections.emptyMap(); } - // TODO: implement a case insensitive linked hash map - var map = new LinkedHashMap>(); + var map = new CaseInsensitiveLinkedHashMap>(); for (HeaderFunction headerFunction : headerFunctions) { headerFunction.addTo(map); } diff --git a/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java b/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java index 58195e5c..8e05ce62 100644 --- a/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java +++ b/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java @@ -5,7 +5,6 @@ import java.io.Serializable; import java.net.URI; import java.nio.file.Path; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Predicate; @@ -51,6 +50,7 @@ import org.apiphany.io.InputStreamSupplier; import org.morphix.lang.JavaObjects; import org.morphix.lang.Nullables; +import org.morphix.lang.collections.CaseInsensitiveLinkedHashMap; import org.morphix.lang.collections.Lists; import org.morphix.lang.collections.Maps; import org.morphix.lang.function.Predicates; @@ -380,7 +380,7 @@ public static HttpUriRequest toHttpUriRequest(final URI uri, final String httpMe * @return HTTP headers */ public static Map> toHttpHeadersMap(final Header[] headers) { - var httpHeaders = new LinkedHashMap>(); + var httpHeaders = new CaseInsensitiveLinkedHashMap>(); for (Header header : headers) { Headers.addTo(httpHeaders, header.getName(), header.getValue()); } diff --git a/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java b/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java index 0ed24fc2..9b05f153 100644 --- a/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java +++ b/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java @@ -309,8 +309,9 @@ protected ApiResponse buildResponse(final ApiRequest apiRequest, fi static Map> toHttpHeadersMap(final Headers headers) { Map> result = new CaseInsensitiveLinkedHashMap<>(); for (int i = 0; i < headers.size(); ++i) { - String name = headers.name(i).toLowerCase(Locale.US); - result.computeIfAbsent(name, key -> new ArrayList<>(2)).add(headers.value(i)); + String name = headers.name(i); + String value = headers.value(i); + result.computeIfAbsent(name, key -> new ArrayList<>(2)).add(value); } return result; } diff --git a/apiphany-okhttp/src/test/java/org/apiphany/client/http/OkHttpExchangeClientTest.java b/apiphany-okhttp/src/test/java/org/apiphany/client/http/OkHttpExchangeClientTest.java index b4883625..7683a284 100644 --- a/apiphany-okhttp/src/test/java/org/apiphany/client/http/OkHttpExchangeClientTest.java +++ b/apiphany-okhttp/src/test/java/org/apiphany/client/http/OkHttpExchangeClientTest.java @@ -28,8 +28,9 @@ void shouldConvertHeadersToAnInsertionOrderedMap() { Map> result = OkHttpExchangeClient.toHttpHeadersMap(headers); - assertThat(new ArrayList<>(result.keySet()), equalTo(List.of("z-header", "a-header"))); + assertThat(new ArrayList<>(result.keySet()), equalTo(List.of("Z-Header", "A-Header"))); assertThat(result.get("z-header"), equalTo(List.of("value1", "value3"))); assertThat(result.get("a-header"), equalTo(List.of("value2"))); + assertThat(result.get("Z-Header"), equalTo(List.of("value1", "value3"))); } } From 2d6556b8070ff15cfbdc35aa17e0339c7553bff7 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Tue, 3 Nov 2026 21:07:28 +0200 Subject: [PATCH 05/19] More test coverage. --- .../test/java/org/apiphany/header/HeadersTest.java | 11 +++++++++++ .../http/ApacheHC5HttpExchangeClientTest.java | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java b/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java index 19a7465a..f85fe983 100644 --- a/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java +++ b/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java @@ -472,6 +472,17 @@ void shouldPreserveHeaderInsertionOrder() { assertThat(List.copyOf(resultHeaders.keySet()), equalTo(List.of("first", "second", "third"))); } + @Test + void shouldTreatHeaderNamesAsCaseInsensitive() { + Map> resultHeaders = Headers.of( + HeaderFunction.header("Content-Type", "application/json"), + HeaderFunction.header("content-type", "text/plain")); + + assertThat(resultHeaders.size(), equalTo(1)); + assertThat(resultHeaders.get("CONTENT-TYPE"), equalTo(List.of("application/json", "text/plain"))); + assertThat(List.copyOf(resultHeaders.keySet()), equalTo(List.of("Content-Type"))); + } + @Test void shouldCreateHeadersMapWithNoHeaders() { Map> resultHeaders = Headers.of(); diff --git a/apiphany-httpclient5/src/test/java/org/apiphany/client/http/ApacheHC5HttpExchangeClientTest.java b/apiphany-httpclient5/src/test/java/org/apiphany/client/http/ApacheHC5HttpExchangeClientTest.java index e32d5384..97ce2cdd 100644 --- a/apiphany-httpclient5/src/test/java/org/apiphany/client/http/ApacheHC5HttpExchangeClientTest.java +++ b/apiphany-httpclient5/src/test/java/org/apiphany/client/http/ApacheHC5HttpExchangeClientTest.java @@ -246,6 +246,20 @@ void shouldAccumulateMultipleValuesForSameHeader() { assertThat(result.get("Accept"), equalTo(List.of("text/html", "application/json"))); } + + @Test + void shouldTreatHeaderNamesAsCaseInsensitive() { + Header[] headers = new Header[] { + new BasicHeader("Content-Type", "application/json"), + new BasicHeader("content-type", "text/plain") + }; + + Map> result = ApacheHC5HttpExchangeClient.toHttpHeadersMap(headers); + + assertThat(result.size(), equalTo(1)); + assertThat(result.get("CONTENT-TYPE"), equalTo(List.of("application/json", "text/plain"))); + assertThat(result.keySet().iterator().next(), equalTo("Content-Type")); + } } @Nested From 572bead83d3055507178e56d769d8ec2c47c6a2c Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Sun, 8 Nov 2026 15:37:35 +0200 Subject: [PATCH 06/19] Update `oauth2-oidc-sdk` to `11.39`. --- CHANGELOG.md | 1 + pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b8c235c..888c2b0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Changed `Headers.of` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Updated `ApacheHC5ExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Updated `OkHttpExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. +- Upgraded `oauth2-oidc-sdk` to `11.39`. --- diff --git a/pom.xml b/pom.xml index 62117aed..1fc67947 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ 2.0.5 4.4.0 10.10 - 11.38.2 + 11.39 3.13.2 3.0.0 From 1018eacec2732af0bec885524e7ffd5a960a2150 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Mon, 9 Nov 2026 00:48:33 +0200 Subject: [PATCH 07/19] Update minimum HTTP clients versions. --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 1fc67947..3bc25336 100644 --- a/pom.xml +++ b/pom.xml @@ -457,7 +457,7 @@ httpclient5-max - 5.6.4 + 5.6.5 @@ -470,13 +470,13 @@ okhttp-min - 4.9.0 + 4.12.1 okhttp-current - 4.12.0 + 4.12.1 From b99e6440c0633585371413ef1eb708fc485be7d7 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Mon, 9 Nov 2026 01:02:39 +0200 Subject: [PATCH 08/19] OkHttp compatibility upgrade. --- .../main/java/org/apiphany/http/OkHttpLibrary.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java b/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java index 6698338d..890f5a02 100644 --- a/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java +++ b/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java @@ -33,22 +33,18 @@ public class OkHttpLibrary { private static final LibraryVersion MAXIMUM_VERSION = LibraryVersion.of(CLIENT_NAME, 4, 12, 1); /** - * The OkHttp OkHttpClient class name. + * The OkHttp client class name, used as the version anchor because the OkHttp jar does not carry an + * {@code Implementation-Version} manifest entry. This is a public class so the check remains compatible with OkHttp's + * Java module boundaries. */ private static final String OKHTTP_CLIENT_CLASS_NAME = "okhttp3.OkHttpClient"; - /** - * The OkHttp {@code Platform} class name, used as the version anchor because the OkHttp jar does not carry an - * {@code Implementation-Version} manifest entry. - */ - private static final String OKHTTP_PLATFORM_CLASS_NAME = "okhttp3.internal.platform.Platform"; - /** * The runtime version of the OkHttp library. OkHttp jars do not declare an {@code Implementation-Version} manifest * entry, so the version cannot be detected at runtime and this is always {@code null}; use {@link #isPresent()} to - * check for the library instead. + * check for the library instead. The public {@code OkHttpClient} class is used as the package version anchor. */ - private static final LibraryVersion VERSION = LibraryVersion.of(CLIENT_NAME, Classes.Safe.getOne(OKHTTP_PLATFORM_CLASS_NAME)); + private static final LibraryVersion VERSION = LibraryVersion.of(CLIENT_NAME, Classes.Safe.getOne(OKHTTP_CLIENT_CLASS_NAME)); /** * Checks if the OkHttp library is present in the classpath. From b4411a634a41e75b728d0543a3b2c07dd895a3ab Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Mon, 9 Nov 2026 01:31:38 +0200 Subject: [PATCH 09/19] Upgraded OkHttp to `5.5.1`. --- CHANGELOG.md | 1 + README.md | 6 ++++-- apiphany-okhttp/pom.xml | 2 +- .../main/java/org/apiphany/http/OkHttpLibrary.java | 8 ++++---- .../java/org/apiphany/http/OkHttpLibraryTest.java | 8 ++++---- apiphany-spring/pom.xml | 9 ++++++++- integration/apiphany-okhttp-tests/pom.xml | 2 +- integration/apiphany-spring-tests/pom.xml | 2 +- pom.xml | 14 +++++++++----- 9 files changed, 33 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 888c2b0f..f2164fcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Updated `ApacheHC5ExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Updated `OkHttpExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Upgraded `oauth2-oidc-sdk` to `11.39`. +- Upgraded OkHttp to `5.5.1`, Maven users now resolve the JVM artifact as `okhttp-jvm`. --- diff --git a/README.md b/README.md index b0f72fea..2b53316d 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ By default Apiphany uses the JDK `java.net.http` client. You can switch to anoth #### Apache HttpClient5 -Add the `apiphany-httpclient5` dependency, then: +Add the `apiphany-httpclient5` and `org.apache.httpcomponents.client5:httpclient5` dependencies, then: ```java import org.apiphany.client.http.ApacheHC5HttpExchangeClient; @@ -162,7 +162,7 @@ String name = http(client) #### OkHttp -Add the `apiphany-okhttp` dependency, then: +Add the `apiphany-okhttp` and `com.squareup.okhttp3:okhttp-jvm` dependencies, then: ```java import org.apiphany.client.http.OkHttpExchangeClient; @@ -176,6 +176,8 @@ String name = http(client) .orRethrow(); ``` +If you want to use the most used OkHttp version `4.12.x` you need to add `com.squareup.okhttp3:okhttp` dependency. + #### Spring `RestClient` Add the `apiphany-spring` dependency, then: diff --git a/apiphany-okhttp/pom.xml b/apiphany-okhttp/pom.xml index df660240..cacfcfaa 100644 --- a/apiphany-okhttp/pom.xml +++ b/apiphany-okhttp/pom.xml @@ -65,7 +65,7 @@ com.squareup.okhttp3 - okhttp + ${okhttp.artifact.id} provided diff --git a/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java b/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java index 890f5a02..87c32973 100644 --- a/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java +++ b/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java @@ -21,16 +21,16 @@ public class OkHttpLibrary { public static final String CLIENT_NAME = "okhttp"; /** - * The minimum OkHttp version this module was built against and requires at runtime: 4.9.0. + * The minimum OkHttp version this module was built against and requires at runtime: 4.12.1. */ - private static final LibraryVersion MINIMUM_VERSION = LibraryVersion.of(CLIENT_NAME, 4, 9, 0); + private static final LibraryVersion MINIMUM_VERSION = LibraryVersion.of(CLIENT_NAME, 4, 12, 1); /** - * The maximum OkHttp version this module supports, i.e. the highest version it was tested against: 4.12.1. + * The maximum OkHttp version this module supports, i.e. the highest version it was tested against: 5.5.1. *

* A newer runtime version is outside the tested range and is rejected by {@link #verifyVersion()}. */ - private static final LibraryVersion MAXIMUM_VERSION = LibraryVersion.of(CLIENT_NAME, 4, 12, 1); + private static final LibraryVersion MAXIMUM_VERSION = LibraryVersion.of(CLIENT_NAME, 5, 5, 1); /** * The OkHttp client class name, used as the version anchor because the OkHttp jar does not carry an diff --git a/apiphany-okhttp/src/test/java/org/apiphany/http/OkHttpLibraryTest.java b/apiphany-okhttp/src/test/java/org/apiphany/http/OkHttpLibraryTest.java index fb97fef3..64fa08a8 100644 --- a/apiphany-okhttp/src/test/java/org/apiphany/http/OkHttpLibraryTest.java +++ b/apiphany-okhttp/src/test/java/org/apiphany/http/OkHttpLibraryTest.java @@ -19,8 +19,8 @@ */ class OkHttpLibraryTest { - private static final String MIN_SUPPORTED_VERSION = "4.9.0"; - private static final String MAX_SUPPORTED_VERSION = "4.12.1"; + private static final String MIN_SUPPORTED_VERSION = "4.12.1"; + private static final String MAX_SUPPORTED_VERSION = "5.5.1"; @Nested class IsPresentTests { @@ -51,7 +51,7 @@ void shouldNotThrowForRuntimeVersion() { @Test void shouldThrowWhenRuntimeVersionIsOlderThanMinimum() { - LibraryVersion oldVersion = LibraryVersion.of(OkHttpLibrary.CLIENT_NAME, "4.8.1"); + LibraryVersion oldVersion = LibraryVersion.of(OkHttpLibrary.CLIENT_NAME, "4.12.0"); LibraryVersion minimumVersion = OkHttpLibrary.minimumVersion(); assertThrows(IllegalStateException.class, () -> oldVersion.verifyAtLeast(minimumVersion)); @@ -59,7 +59,7 @@ void shouldThrowWhenRuntimeVersionIsOlderThanMinimum() { @Test void shouldThrowWhenRuntimeVersionIsNewerThanMaximum() { - LibraryVersion newVersion = LibraryVersion.of(OkHttpLibrary.CLIENT_NAME, "5.0.0"); + LibraryVersion newVersion = LibraryVersion.of(OkHttpLibrary.CLIENT_NAME, "5.5.2"); LibraryVersion maximumVersion = OkHttpLibrary.maximumVersion(); assertThrows(IllegalStateException.class, () -> newVersion.verifyAtMost(maximumVersion)); diff --git a/apiphany-spring/pom.xml b/apiphany-spring/pom.xml index a4bd75da..9bbd9140 100644 --- a/apiphany-spring/pom.xml +++ b/apiphany-spring/pom.xml @@ -103,7 +103,14 @@ com.squareup.okhttp3 - okhttp + ${okhttp.artifact.id} + provided + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.stdlib.version} provided diff --git a/integration/apiphany-okhttp-tests/pom.xml b/integration/apiphany-okhttp-tests/pom.xml index e127e5ec..90b6acb7 100644 --- a/integration/apiphany-okhttp-tests/pom.xml +++ b/integration/apiphany-okhttp-tests/pom.xml @@ -49,7 +49,7 @@ com.squareup.okhttp3 - okhttp + ${okhttp.artifact.id} diff --git a/integration/apiphany-spring-tests/pom.xml b/integration/apiphany-spring-tests/pom.xml index ea14c64a..19c7a847 100644 --- a/integration/apiphany-spring-tests/pom.xml +++ b/integration/apiphany-spring-tests/pom.xml @@ -73,7 +73,7 @@ com.squareup.okhttp3 - okhttp + ${okhttp.artifact.id} diff --git a/pom.xml b/pom.xml index 3bc25336..f2cda4e9 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,9 @@ 3.1.8 2.0.20 5.6.5 - 4.12.1 + 5.5.1 + okhttp-jvm + 2.4.21 7.0.10 4.1.2 @@ -150,7 +152,7 @@ com.squareup.okhttp3 - okhttp + ${okhttp.artifact.id} ${okhttp.version} @@ -463,20 +465,22 @@ okhttp-min 4.12.1 + okhttp okhttp-current - 4.12.1 + 5.5.1 + okhttp-jvm From 2594591dbfc331dd7681a1f0f7d5a981b6a18267 Mon Sep 17 00:00:00 2001 From: raduking Date: Wed, 11 Nov 2026 19:42:06 +0200 Subject: [PATCH 10/19] Update MorphiX to `1.1.0`. --- CHANGELOG.md | 1 + pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2164fcf..37fc2c42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Updated `OkHttpExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Upgraded `oauth2-oidc-sdk` to `11.39`. - Upgraded OkHttp to `5.5.1`, Maven users now resolve the JVM artifact as `okhttp-jvm`. +- Upgraded `morphix-all` to `1.1.0`. --- diff --git a/pom.xml b/pom.xml index f2cda4e9..9e73ecdc 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ - 1.0.48 + 1.1.0 1.17.2 2.21.8 3.1.8 From 66805ed0f1bf85ea0e19c6eafc7b07eafe6df613 Mon Sep 17 00:00:00 2001 From: raduking Date: Tue, 17 Nov 2026 15:04:27 +0200 Subject: [PATCH 11/19] Added `nonBlankOrDefault` and `nonBlankOrGet` to `Strings`. --- CHANGELOG.md | 2 + .../main/java/org/apiphany/lang/Strings.java | 23 ++++++ .../java/org/apiphany/lang/StringsTest.java | 71 +++++++++++++++++++ 3 files changed, 96 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37fc2c42..66e7747d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ `1.3.2` +- Added `Strings.nonBlankOrDefault(String, String)` to return a default when the value is blank. +- Added `Strings.nonBlankOrGet(String, Supplier)` to return a supplied default when the value is blank. - Changed `Headers.of` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Updated `ApacheHC5ExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Updated `OkHttpExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. diff --git a/apiphany-core/src/main/java/org/apiphany/lang/Strings.java b/apiphany-core/src/main/java/org/apiphany/lang/Strings.java index 1fa23e3b..a9f609b5 100644 --- a/apiphany-core/src/main/java/org/apiphany/lang/Strings.java +++ b/apiphany-core/src/main/java/org/apiphany/lang/Strings.java @@ -7,6 +7,7 @@ import java.util.Collection; import java.util.Objects; import java.util.function.Consumer; +import java.util.function.Supplier; import org.apiphany.io.IOStreams; import org.apiphany.io.ResourceLocation; @@ -543,4 +544,26 @@ static boolean equalsIgnoreCase(final String a, final String b) { } return null != a && a.equalsIgnoreCase(b); } + + /** + * Returns the given string if it is not blank, otherwise the default value. + * + * @param value a string + * @param defaultValue default value if value is blank + * @return the given string if it is not blank, otherwise the default value + */ + static String nonBlankOrDefault(final String value, final String defaultValue) { + return isNotBlank(value) ? value : defaultValue; + } + + /** + * Returns the given string if it is not blank, otherwise the supplied default value. + * + * @param value a string + * @param defaultValue default value if value is blank + * @return the given string if it is not blank, otherwise the supplied default value + */ + static String nonBlankOrGet(final String value, final Supplier defaultValue) { + return isNotBlank(value) ? value : defaultValue.get(); + } } diff --git a/apiphany-core/src/test/java/org/apiphany/lang/StringsTest.java b/apiphany-core/src/test/java/org/apiphany/lang/StringsTest.java index 4109c948..0b6112fa 100644 --- a/apiphany-core/src/test/java/org/apiphany/lang/StringsTest.java +++ b/apiphany-core/src/test/java/org/apiphany/lang/StringsTest.java @@ -7,7 +7,9 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -19,6 +21,7 @@ import java.util.Arrays; import java.util.List; import java.util.function.Consumer; +import java.util.function.Supplier; import java.util.stream.Stream; import org.junit.jupiter.api.Nested; @@ -794,6 +797,74 @@ private static Stream provideUnequalIgnoreCasePairs() { } } + /** + * Tests for: + *

    + *
  • {@link Strings#nonBlankOrDefault(String, String)}
  • + *
+ */ + @Nested + class NonBlankOrDefaultTests { + + @Test + void shouldReturnValueWhenNotBlank() { + assertThat(Strings.nonBlankOrDefault(TEST_STRING, "default"), equalTo(TEST_STRING)); + assertThat(Strings.nonBlankOrDefault(NOT_BLANK_STRING, "default"), equalTo(NOT_BLANK_STRING)); + } + + @ParameterizedTest + @MethodSource("provideBlankValues") + void shouldReturnDefaultWhenValueIsBlank(final String blankValue) { + assertThat(Strings.nonBlankOrDefault(blankValue, "default"), equalTo("default")); + } + + private static Stream provideBlankValues() { + return Stream.of( + Arguments.of((String) null), + Arguments.of(""), + Arguments.of(BLANK_STRING)); + } + } + + /** + * Tests for: + *
    + *
  • {@link Strings#nonBlankOrGet(String, Supplier)}
  • + *
+ */ + @Nested + class NonBlankOrGetTests { + + @Test + void shouldReturnValueWhenNotBlankWithoutCallingSupplier() { + @SuppressWarnings("unchecked") + Supplier defaultValue = mock(Supplier.class); + + assertThat(Strings.nonBlankOrGet(TEST_STRING, defaultValue), equalTo(TEST_STRING)); + + verify(defaultValue, never()).get(); + } + + @ParameterizedTest + @MethodSource("provideBlankValues") + void shouldReturnSuppliedDefaultWhenValueIsBlank(final String blankValue) { + @SuppressWarnings("unchecked") + Supplier defaultValue = mock(Supplier.class); + when(defaultValue.get()).thenReturn("default"); + + assertThat(Strings.nonBlankOrGet(blankValue, defaultValue), equalTo("default")); + + verify(defaultValue).get(); + } + + private static Stream provideBlankValues() { + return Stream.of( + Arguments.of((String) null), + Arguments.of(""), + Arguments.of(BLANK_STRING)); + } + } + @Nested class EndsWithAnyTests { From 79c476c623352d69af19cd2a780d24a08343cc08 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Sun, 22 Nov 2026 03:59:35 +0200 Subject: [PATCH 12/19] Updated Spring Boot to `4.1.3` and Spring to `7.0.11`. --- CHANGELOG.md | 4 +++- pom.xml | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66e7747d..c80c9bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,9 @@ - Updated `OkHttpExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Upgraded `oauth2-oidc-sdk` to `11.39`. - Upgraded OkHttp to `5.5.1`, Maven users now resolve the JVM artifact as `okhttp-jvm`. -- Upgraded `morphix-all` to `1.1.0`. +- Upgraded `morphix-all` to `1.1.2`. +- Upgraded Spring Boot to `4.1.3` for `apiphany-spring`. +- Upgraded Spring to `7.0.11` for `apiphany-spring`. --- diff --git a/pom.xml b/pom.xml index 9e73ecdc..80d3b884 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ - 1.1.0 + 1.1.2 1.17.2 2.21.8 3.1.8 @@ -71,8 +71,8 @@ 5.5.1 okhttp-jvm 2.4.21 - 7.0.10 - 4.1.2 + 7.0.11 + 4.1.3 21 From 31c754934d549427927474e0c1e43c68d893e74f Mon Sep 17 00:00:00 2001 From: raduking Date: Sun, 22 Nov 2026 22:54:44 +0200 Subject: [PATCH 13/19] Updated dependencies. --- CHANGELOG.md | 8 +++-- apiphany-spring/pom.xml | 28 ++++++++------- .../apiphany-httpclient5-tests/pom.xml | 36 +++++++++++++++++++ pom.xml | 14 +++++--- 4 files changed, 66 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c80c9bc1..bcc52dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,15 @@ - Changed `Headers.of` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Updated `ApacheHC5ExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Updated `OkHttpExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. -- Upgraded `oauth2-oidc-sdk` to `11.39`. -- Upgraded OkHttp to `5.5.1`, Maven users now resolve the JVM artifact as `okhttp-jvm`. - Upgraded `morphix-all` to `1.1.2`. - Upgraded Spring Boot to `4.1.3` for `apiphany-spring`. - Upgraded Spring to `7.0.11` for `apiphany-spring`. +- Upgraded Spring Security to `7.2.0`. +- Upgraded OkHttp to `5.5.1`, Maven users now resolve the JVM artifact as `okhttp-jvm`. +- Upgraded Micrometer to `1.17.3`. +- Upgraded `oauth2-oidc-sdk` to `11.39`. +- Upgraded `logback-core` to `1.6.8`. +- Upgraded `pitest-maven` to `1.30.2`. --- diff --git a/apiphany-spring/pom.xml b/apiphany-spring/pom.xml index 9bbd9140..11195f8d 100644 --- a/apiphany-spring/pom.xml +++ b/apiphany-spring/pom.xml @@ -54,6 +54,21 @@ + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + + @@ -255,19 +270,6 @@ - - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - - diff --git a/integration/apiphany-httpclient5-tests/pom.xml b/integration/apiphany-httpclient5-tests/pom.xml index d131d492..1efc9ecb 100644 --- a/integration/apiphany-httpclient5-tests/pom.xml +++ b/integration/apiphany-httpclient5-tests/pom.xml @@ -137,6 +137,42 @@ test + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson2.annotations.version} + test + + + + com.fasterxml.jackson.core + jackson-core + ${jackson2.version} + test + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson2.version} + test + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson2.version} + test + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + ${jackson2.version} + test + + org.wiremock diff --git a/pom.xml b/pom.xml index 80d3b884..e7c38be6 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,8 @@ 1.1.2 - 1.17.2 + 1.17.3 + 2.21 2.21.8 3.1.8 2.0.20 @@ -87,8 +88,8 @@ 3.0 6.1.3 5.24.0 - 1.6.6 - 7.1.2 + 1.6.8 + 7.2.0 2.0.5 4.4.0 10.10 @@ -106,7 +107,7 @@ 0.12.0 - 1.30.1 + 1.30.2 1.2.3 0.8.16 3.9.0 @@ -139,22 +140,25 @@ + org.apache.httpcomponents.client5 httpclient5 ${httpclient5.version} + com.squareup.okhttp3 ${okhttp.artifact.id} ${okhttp.version} + From 0986ea20476dd8218b9bff4153bf00a37d4076fa Mon Sep 17 00:00:00 2001 From: raduking Date: Mon, 23 Nov 2026 00:48:30 +0200 Subject: [PATCH 14/19] More multi-value query parameter object strategy tests. --- .../java/org/apiphany/RequestParameter.java | 5 +- .../org/apiphany/RequestParametersTest.java | 409 ++++++++++++++++++ .../openapi/MultiValueStrategyTest.java | 12 + 3 files changed, 424 insertions(+), 2 deletions(-) diff --git a/apiphany-core/src/main/java/org/apiphany/RequestParameter.java b/apiphany-core/src/main/java/org/apiphany/RequestParameter.java index 286c2f42..5c4a904a 100644 --- a/apiphany-core/src/main/java/org/apiphany/RequestParameter.java +++ b/apiphany-core/src/main/java/org/apiphany/RequestParameter.java @@ -13,6 +13,7 @@ import org.morphix.convert.ArrayConversions; import org.morphix.lang.JavaArrays; import org.morphix.lang.Nullables; +import org.morphix.lang.collections.Iterables; /** * Represents a parameter in the API context. When constructing request parameters prefer using the @@ -168,7 +169,7 @@ public static List toValues(final String string) { if (null == string) { return NOT_PRESENT; } - List list = new ArrayList<>(); + List list = new ArrayList<>(1); list.add(string); return list; } @@ -202,7 +203,7 @@ public static List toValues(final Iterable iterable) { * @return the list of string representations of the values */ public static List toValues(final Collection collection) { - if (null == collection || collection.isEmpty()) { + if (Iterables.isEmpty(collection)) { return NOT_PRESENT; } List list = new ArrayList<>(collection.size()); diff --git a/apiphany-core/src/test/java/org/apiphany/RequestParametersTest.java b/apiphany-core/src/test/java/org/apiphany/RequestParametersTest.java index 79c2ab49..7459a8a6 100644 --- a/apiphany-core/src/test/java/org/apiphany/RequestParametersTest.java +++ b/apiphany-core/src/test/java/org/apiphany/RequestParametersTest.java @@ -4,18 +4,25 @@ import static org.apiphany.ParameterFunction.withCondition; import static org.apiphany.test.Assertions.assertDefaultConstructorThrows; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.HashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Function; import java.util.stream.Stream; +import org.apiphany.openapi.MultiValueStrategy; import org.apiphany.openapi.ParameterMode; +import org.apiphany.openapi.ParameterStyle; import org.apiphany.openapi.QueryParam; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -478,4 +485,406 @@ void shouldAddParameterWithParameterRecord() { assertThat(params.get("param1"), equalTo(List.of("value1"))); assertThat(params.get("param2"), equalTo(List.of("value2"))); } + + /** + * Tests how {@link MultiValueStrategy} (selected through {@link QueryParam}) influences the final request parameters + * string, i.e. what is actually sent on the wire. + */ + @Nested + class MultiValueStrategyTests { + + private static final String TAGS = "tags"; + + private static final List LETTERS = List.of("a", "b", "c"); + private static final List SPECIAL_CHARACTERS = List.of("a b", "c&d"); + + static class PlainTags { + + @SuppressWarnings("unused") + private final List tags; + + PlainTags(final List tags) { + this.tags = tags; + } + } + + static class DefaultMultiTags { + + @QueryParam + private final List tags; + + DefaultMultiTags(final List tags) { + this.tags = tags; + } + } + + static class ExplicitMultiTags { + + @QueryParam(strategy = MultiValueStrategy.Value.MULTI) + private final List tags; + + ExplicitMultiTags(final List tags) { + this.tags = tags; + } + } + + static class FormExplodeTags { + + @QueryParam(style = ParameterStyle.FORM, mode = ParameterMode.EXPLODE) + private final List tags; + + FormExplodeTags(final List tags) { + this.tags = tags; + } + } + + static class CsvTags { + + @QueryParam(strategy = MultiValueStrategy.Value.CSV) + private final List tags; + + CsvTags(final List tags) { + this.tags = tags; + } + } + + static class FormJoinedTags { + + @QueryParam(style = ParameterStyle.FORM, mode = ParameterMode.JOINED) + private final List tags; + + FormJoinedTags(final List tags) { + this.tags = tags; + } + } + + static class SsvTags { + + @QueryParam(strategy = MultiValueStrategy.Value.SSV) + private final List tags; + + SsvTags(final List tags) { + this.tags = tags; + } + } + + static class SpaceDelimitedTags { + + @QueryParam(style = ParameterStyle.SPACE_DELIMITED) + private final List tags; + + SpaceDelimitedTags(final List tags) { + this.tags = tags; + } + } + + static class TsvTags { + + @QueryParam(strategy = MultiValueStrategy.Value.TSV) + private final List tags; + + TsvTags(final List tags) { + this.tags = tags; + } + } + + static class PipesTags { + + @QueryParam(strategy = MultiValueStrategy.Value.PIPES) + private final List tags; + + PipesTags(final List tags) { + this.tags = tags; + } + } + + static class PipeDelimitedTags { + + @QueryParam(style = ParameterStyle.PIPE_DELIMITED) + private final List tags; + + PipeDelimitedTags(final List tags) { + this.tags = tags; + } + } + + static class MultiValues { + + @QueryParam + private final Object values; + + MultiValues(final Object values) { + this.values = values; + } + } + + static class CsvValues { + + @QueryParam(strategy = MultiValueStrategy.Value.CSV) + private final Object values; + + CsvValues(final Object values) { + this.values = values; + } + } + + static class MixedParams { + + @SuppressWarnings("unused") + private String query = "x"; + + @QueryParam + private List tags = List.of("a", "b"); + + @QueryParam(strategy = MultiValueStrategy.Value.CSV) + private List ids = List.of(1, 2, 3); + + @QueryParam + private List empty = List.of(); + + @QueryParam + private List missing = null; + + @SuppressWarnings("unused") + private String nothing = null; + } + + @FunctionalInterface + interface ParamObjectConstructor extends Function, Object> { + // empty + } + + @Test + void shouldContainMultipleParametersWithTheSameNameWhenFieldIsAnnotatedWithExplicitMulti() { + ExplicitMultiTags paramsObject = new ExplicitMultiTags(LETTERS); + Map> params = RequestParameters.from(paramsObject); + + String result = RequestParameters.asString(params); + + assertThat(params.entrySet(), hasSize(1)); + assertThat(params.get(TAGS), equalTo(LETTERS)); + assertThat(result, equalTo("tags=a&tags=b&tags=c")); + assertThat(List.of(result.split(RequestParameters.SEPARATOR)), equalTo(List.of("tags=a", "tags=b", "tags=c"))); + } + + @Test + void shouldContainMultipleParametersWithTheSameNameWhenFieldIsAnnotatedWithDefaultMulti() { + DefaultMultiTags paramsObject = new DefaultMultiTags(LETTERS); + Map> params = RequestParameters.from(paramsObject); + + String result = RequestParameters.asString(params); + + assertThat(result, equalTo("tags=a&tags=b&tags=c")); + } + + @Test + void shouldContainMultipleParametersWithTheSameNameWhenFieldIsNotAnnotated() { + PlainTags paramsObject = new PlainTags(LETTERS); + Map> params = RequestParameters.from(paramsObject); + + String result = RequestParameters.asString(params); + + assertThat(result, equalTo("tags=a&tags=b&tags=c")); + } + + @Test + void shouldBuildUrlSuffixWithRepeatedParametersWhenUsingMulti() { + ExplicitMultiTags paramsObject = new ExplicitMultiTags(LETTERS); + Map> params = RequestParameters.from(paramsObject); + + String suffix = RequestParameters.asUrlSuffix(params); + + assertThat(suffix, equalTo("?tags=a&tags=b&tags=c")); + } + + @Test + void shouldAppendRepeatedParametersToUrlWithExistingQueryWhenUsingMulti() { + ExplicitMultiTags paramsObject = new ExplicitMultiTags(LETTERS); + Map> params = RequestParameters.from(paramsObject); + + String suffix = RequestParameters.asUrlSuffix(params, "http://localhost/path?x=1"); + + assertThat(suffix, equalTo("&tags=a&tags=b&tags=c")); + } + + @ParameterizedTest(name = "{0}") + @MethodSource("provideStrategySelectors") + @SuppressWarnings("unused") + void shouldBuildParametersStringAccordingToSelectedStrategy(final String selector, final ParamObjectConstructor factory, + final String expected, final String expectedEncoded) { + Object paramsObject = factory.apply(LETTERS); + Map> params = RequestParameters.from(paramsObject); + + String result = RequestParameters.asString(params); + + assertThat(result, equalTo(expected)); + } + + @ParameterizedTest(name = "{0}") + @MethodSource("provideStrategySelectors") + @SuppressWarnings("unused") + void shouldBuildEncodedParametersStringAccordingToSelectedStrategy(final String selector, final ParamObjectConstructor factory, + final String expected, final String expectedEncoded) { + Object paramsObject = factory.apply(SPECIAL_CHARACTERS); + Map> params = RequestParameters.from(paramsObject); + Map> encoded = RequestParameters.encode(params); + + String result = RequestParameters.asString(encoded); + + assertThat(result, equalTo(expectedEncoded)); + } + + private static Stream provideStrategySelectors() { + return Stream.of( + Arguments.of( + "no annotation (multi)", + constructor(PlainTags::new), + "tags=a&tags=b&tags=c", + "tags=a+b&tags=c%26d"), + Arguments.of( + "@QueryParam (multi)", + constructor(DefaultMultiTags::new), + "tags=a&tags=b&tags=c", + "tags=a+b&tags=c%26d"), + Arguments.of( + "strategy = multi", + constructor(ExplicitMultiTags::new), + "tags=a&tags=b&tags=c", + "tags=a+b&tags=c%26d"), + Arguments.of( + "style = FORM, mode = EXPLODE (multi)", + constructor(FormExplodeTags::new), + "tags=a&tags=b&tags=c", + "tags=a+b&tags=c%26d"), + Arguments.of( + "strategy = csv", + constructor(CsvTags::new), + "tags=a,b,c", + "tags=a+b%2Cc%26d"), + Arguments.of( + "style = FORM, mode = JOINED (csv)", + constructor(FormJoinedTags::new), + "tags=a,b,c", + "tags=a+b%2Cc%26d"), + Arguments.of( + "strategy = ssv", + constructor(SsvTags::new), + "tags=a b c", + "tags=a+b+c%26d"), + Arguments.of( + "style = SPACE_DELIMITED (ssv)", + constructor(SpaceDelimitedTags::new), + "tags=a b c", + "tags=a+b+c%26d"), + Arguments.of( + "strategy = tsv", + constructor(TsvTags::new), + "tags=a\tb\tc", + "tags=a+b%09c%26d"), + Arguments.of( + "strategy = pipes", + constructor(PipesTags::new), + "tags=a|b|c", + "tags=a+b%7Cc%26d"), + Arguments.of( + "style = PIPE_DELIMITED (pipes)", + constructor(PipeDelimitedTags::new), + "tags=a|b|c", + "tags=a+b%7Cc%26d")); + } + + private static ParamObjectConstructor constructor(final ParamObjectConstructor function) { + return function; + } + + @ParameterizedTest + @MethodSource("provideCollectionKinds") + void shouldContainMultipleParametersWithTheSameNameForAnyCollectionKindWhenUsingMulti(final Object values) { + MultiValues paramsObject = new MultiValues(values); + Map> params = RequestParameters.from(paramsObject); + + String result = RequestParameters.asString(params); + + assertThat(result, equalTo("values=1&values=2&values=3")); + } + + @ParameterizedTest + @MethodSource("provideCollectionKinds") + void shouldJoinValuesIntoSingleParameterForAnyCollectionKindWhenUsingCsv(final Object values) { + CsvValues paramsObject = new CsvValues(values); + Map> params = RequestParameters.from(paramsObject); + + String result = RequestParameters.asString(params); + + assertThat(result, equalTo("values=1,2,3")); + } + + private static Stream provideCollectionKinds() { + Iterable iterable = () -> List.of(1, 2, 3).iterator(); + return Stream.of( + Arguments.of(List.of(1, 2, 3)), + Arguments.of(new LinkedHashSet<>(List.of(1, 2, 3))), + Arguments.of((Object) new String[] { "1", "2", "3" }), + Arguments.of((Object) new Integer[] { 1, 2, 3 }), + Arguments.of(new int[] { 1, 2, 3 }), + Arguments.of(iterable)); + } + + @Test + void shouldBuildCombinedParametersStringFromObjectWithMixedFields() { + MixedParams paramsObject = new MixedParams(); + Map> params = RequestParameters.from(paramsObject); + + String result = RequestParameters.asString(params); + + assertThat(List.of(result.split(RequestParameters.SEPARATOR)), containsInAnyOrder("query=x", "tags=a", "tags=b", "ids=1,2,3")); + assertThat(result, containsString("tags=a&tags=b")); + } + + @Test + void shouldNotContainParametersForNullOrEmptyCollectionsOrNullValues() { + MixedParams paramsObject = new MixedParams(); + Map> params = RequestParameters.from(paramsObject); + + assertThat(params.keySet(), containsInAnyOrder("query", TAGS, "ids")); + } + + @Test + void shouldReturnEmptyStringWhenCollectionIsEmptyWithAnyStrategy() { + ExplicitMultiTags multiParamsObject = new ExplicitMultiTags(List.of()); + Map> multiParams = RequestParameters.from(multiParamsObject); + String multiResult = RequestParameters.asString(multiParams); + + CsvTags csvParamsObject = new CsvTags(List.of()); + Map> csvParams = RequestParameters.from(csvParamsObject); + String csvResult = RequestParameters.asString(csvParams); + + assertThat(multiResult, equalTo("")); + assertThat(csvResult, equalTo("")); + } + + @Test + void shouldParseBackRepeatedParametersIntoTheSameValuesWhenUsingMulti() { + ExplicitMultiTags paramsObject = new ExplicitMultiTags(LETTERS); + Map> params = RequestParameters.from(paramsObject); + String result = RequestParameters.asString(params); + + Map> parsed = RequestParameters.from(result); + + assertThat(parsed.entrySet(), hasSize(1)); + assertThat(parsed.get(TAGS), equalTo(LETTERS)); + } + + @Test + void shouldParseBackJoinedParameterIntoSingleValueWhenUsingCsv() { + CsvTags paramsObject = new CsvTags(LETTERS); + Map> params = RequestParameters.from(paramsObject); + String result = RequestParameters.asString(params); + + Map> parsed = RequestParameters.from(result); + + assertThat(parsed.entrySet(), hasSize(1)); + assertThat(parsed.get(TAGS), equalTo(List.of("a,b,c"))); + } + } } diff --git a/apiphany-core/src/test/java/org/apiphany/openapi/MultiValueStrategyTest.java b/apiphany-core/src/test/java/org/apiphany/openapi/MultiValueStrategyTest.java index 35f84f93..08341c24 100644 --- a/apiphany-core/src/test/java/org/apiphany/openapi/MultiValueStrategyTest.java +++ b/apiphany-core/src/test/java/org/apiphany/openapi/MultiValueStrategyTest.java @@ -8,6 +8,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import java.lang.annotation.Annotation; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -185,6 +186,17 @@ void shouldCorrectlyAddTheParameterToTheMap() { assertThat(map.get(parameterName), equalTo(values)); } + @Test + void shouldAppendToExistingValuesWhenParameterAlreadyExistsWithMulti() { + Map> map = new HashMap<>(); + map.put(TEST_PARAM, new ArrayList<>(List.of("existing"))); + + MultiValueStrategy.MULTI.apply(TEST_PARAM, List.of(VALUE1, VALUE2)).putInto(map); + + assertThat(map.size(), equalTo(1)); + assertThat(map.get(TEST_PARAM), equalTo(List.of("existing", VALUE1, VALUE2))); + } + @Test void shouldNotAddParameterToMapWhenValuesAreEmptyWithMulti() { List values = List.of(); From f0ff6097382395a6996d2edf53a4e880cff55556 Mon Sep 17 00:00:00 2001 From: raduking Date: Mon, 23 Nov 2026 01:43:42 +0200 Subject: [PATCH 15/19] Simplify some request parameters methods. --- .../java/org/apiphany/RequestParameter.java | 8 +- .../java/org/apiphany/RequestParameters.java | 15 ++- docs/multi-value-query-params.md | 109 ++++++++++++++++++ 3 files changed, 122 insertions(+), 10 deletions(-) create mode 100644 docs/multi-value-query-params.md diff --git a/apiphany-core/src/main/java/org/apiphany/RequestParameter.java b/apiphany-core/src/main/java/org/apiphany/RequestParameter.java index 5c4a904a..63bbc10d 100644 --- a/apiphany-core/src/main/java/org/apiphany/RequestParameter.java +++ b/apiphany-core/src/main/java/org/apiphany/RequestParameter.java @@ -118,10 +118,8 @@ public void putInto(final Map> map) { * @return true if the object is multi-valued, false otherwise */ public static boolean isMultiValued(final Object object) { - if (null == object) { - return false; - } return switch (object) { + case null -> false; case Collection collection -> true; case Iterable iterable -> true; case Object[] array -> true; @@ -147,10 +145,8 @@ public static boolean isSingleValued(final Object object) { * @return the string representation of the value */ public static List toValues(final Object object) { - if (null == object) { - return NOT_PRESENT; - } return switch (object) { + case null -> NOT_PRESENT; case Collection collection -> toValues(collection); case Iterable iterable -> toValues(iterable); case Object[] array -> toValues(array); diff --git a/apiphany-core/src/main/java/org/apiphany/RequestParameters.java b/apiphany-core/src/main/java/org/apiphany/RequestParameters.java index b00409f9..9685b97d 100644 --- a/apiphany-core/src/main/java/org/apiphany/RequestParameters.java +++ b/apiphany-core/src/main/java/org/apiphany/RequestParameters.java @@ -273,9 +273,7 @@ public static Map> from(final Map map, final S * @return a map representation of the object's fields */ protected static Map> fromObject(final Object queryParams, final SimpleConverter nameConverter) { - List extendedFields = ExtendedFields.findAllNonStatic(queryParams, - extendedField -> null != extendedField.getFieldValue()); - + List extendedFields = ExtendedFields.findAllNonStatic(queryParams, RequestParameters::fieldValueNotNull); Map> paramMap = LinkedHashMap.newLinkedHashMap(extendedFields.size()); if (Lists.isEmpty(extendedFields)) { return paramMap; @@ -286,7 +284,6 @@ protected static Map> fromObject(final Object queryParams, continue; } String paramName = nameConverter.convert(extendedField.getName()); - QueryParam annotation = extendedField.getAnnotation(QueryParam.class); MultiValueStrategy strategy = MultiValueStrategy.from(annotation); ParameterFunction parameter = strategy.apply(paramName, paramValues); @@ -295,6 +292,16 @@ protected static Map> fromObject(final Object queryParams, return paramMap; } + /** + * Returns true if the field value is not {@code null}. + * + * @param extendedField the field to check. + * @return true if the field value is not {@code null}, false otherwise + */ + private static boolean fieldValueNotNull(final ExtendedField extendedField) { + return null != extendedField.getFieldValue(); + } + /** * Hide constructor. */ diff --git a/docs/multi-value-query-params.md b/docs/multi-value-query-params.md new file mode 100644 index 00000000..7f9301e6 --- /dev/null +++ b/docs/multi-value-query-params.md @@ -0,0 +1,109 @@ +# Multi-value query parameters + +A query parameter can have more than one value, for example a list of tags. There is no single standard way to put a list in a URL, +so Apiphany lets you choose with a `MultiValueStrategy`. + +The default is `MULTI`: the parameter name is repeated once per value. + +``` +tags = [a, b, c] + +MULTI -> tags=a&tags=b&tags=c +CSV -> tags=a,b,c +SSV -> tags=a b c +TSV -> tags=abc +PIPES -> tags=a|b|c +``` + +## Using it with a parameters object + +Put the values in a POJO and add `@QueryParam` on the field (or the getter) to pick the strategy. + +```java +public class SearchParams { + + @QueryParam(strategy = MultiValueStrategy.Value.CSV) + private List tags = List.of("a", "b", "c"); + + private String query = "x"; + + // no annotation = MULTI + private List ids = List.of(1, 2, 3); +} +``` + +```java +client() + .get() + .path("search") + .params(new SearchParams()) + .retrieve(Result.class) + .orDefault(Result::new); +``` + +Request: `.../search?tags=a,b,c&query=x&ids=1&ids=2&ids=3` + +Rules: + +- A field without `@QueryParam` behaves like `MULTI`. +- `null` fields and empty collections are left out. +- Lists, sets, arrays (including `int[]`) and any `Iterable` are supported. + +## Choosing the strategy + +There are two ways, both on `@QueryParam`: + +| How | Result | +|------------------------------------------------|---------| +| `strategy = "multi"` (or `Value.MULTI`) | `MULTI` | +| `strategy = "csv"` | `CSV` | +| `strategy = "ssv"` | `SSV` | +| `strategy = "tsv"` | `TSV` | +| `strategy = "pipes"` | `PIPES` | +| `style = FORM, mode = EXPLODE` (the default) | `MULTI` | +| `style = FORM, mode = JOINED` | `CSV` | +| `style = SPACE_DELIMITED` | `SSV` | +| `style = PIPE_DELIMITED` | `PIPES` | + +If `strategy` is set it wins over `style` and `mode`. An unknown strategy name falls back to `MULTI`. + +## Without an object + +You can also give the strategy directly: + +```java +client() + .get() + .path("search") + .param("tags", List.of("a", "b", "c")) // MULTI + .param("ids", List.of(1, 2, 3), MultiValueStrategy.CSV) // CSV + .retrieve(Result.class) + .orDefault(Result::new); +``` + +Or build the parameters map yourself: + +```java +Map> params = RequestParameters.of( + parameter("tags", List.of("a", "b", "c"), MultiValueStrategy.PIPES)); +``` + +## How it works + +`MULTI` stores all the values under one name in the parameters map. `RequestParameters.asString` then writes one +`name=value` pair for each value. The other strategies join the values with their separator into one value first. + +```java +Map> params = RequestParameters.from(new SearchParams()); +String query = RequestParameters.asString(params); // tags=a,b,c&query=x&ids=1&ids=2&ids=3 +String encoded = RequestParameters.asString(RequestParameters.encode(params)); +``` + +Encoding is applied after joining, so the separators are encoded too: `CSV` gives `tags=a%2Cb%2Cc`, `TSV` gives `%09` and +`PIPES` gives `%7C`. A space inside a value is encoded as `+`. + +## Where it is tested + +- [`RequestParametersTest.MultiValueStrategyTests`](../apiphany-core/src/test/java/org/apiphany/RequestParametersTest.java) for the full + object-to-string behavior of every strategy +- [`MultiValueStrategyTest`](../apiphany-core/src/test/java/org/apiphany/openapi/MultiValueStrategyTest.java) for the strategies on their own From ff2b36bddd1b29963c4e8d02e075fb02b96f1285 Mon Sep 17 00:00:00 2001 From: raduking Date: Mon, 23 Nov 2026 03:42:24 +0200 Subject: [PATCH 16/19] Upgraded `morphix-all` to `1.1.3`. --- CHANGELOG.md | 2 +- .../java/org/apiphany/RequestParameter.java | 5 +++-- .../java/org/apiphany/RequestParameters.java | 18 +++--------------- pom.xml | 2 +- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcc52dac..34748391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - Changed `Headers.of` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Updated `ApacheHC5ExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. - Updated `OkHttpExchangeClient` to use `CaseInsensitiveLinkedHashMap` from MorphiX. -- Upgraded `morphix-all` to `1.1.2`. +- Upgraded `morphix-all` to `1.1.3`. - Upgraded Spring Boot to `4.1.3` for `apiphany-spring`. - Upgraded Spring to `7.0.11` for `apiphany-spring`. - Upgraded Spring Security to `7.2.0`. diff --git a/apiphany-core/src/main/java/org/apiphany/RequestParameter.java b/apiphany-core/src/main/java/org/apiphany/RequestParameter.java index 63bbc10d..00bf3855 100644 --- a/apiphany-core/src/main/java/org/apiphany/RequestParameter.java +++ b/apiphany-core/src/main/java/org/apiphany/RequestParameter.java @@ -12,6 +12,7 @@ import org.apiphany.lang.Strings; import org.morphix.convert.ArrayConversions; import org.morphix.lang.JavaArrays; +import org.morphix.lang.JavaObjects; import org.morphix.lang.Nullables; import org.morphix.lang.collections.Iterables; @@ -123,7 +124,7 @@ public static boolean isMultiValued(final Object object) { case Collection collection -> true; case Iterable iterable -> true; case Object[] array -> true; - case Object o when o.getClass().isArray() -> true; + case Object o when JavaObjects.isArray(o) -> true; default -> false; }; } @@ -150,7 +151,7 @@ public static List toValues(final Object object) { case Collection collection -> toValues(collection); case Iterable iterable -> toValues(iterable); case Object[] array -> toValues(array); - case Object o when o.getClass().isArray() -> toValues(JavaArrays.toArray(o)); + case Object o when JavaObjects.isArray(o) -> toValues(JavaArrays.toArray(o)); default -> toValues(String.valueOf(object)); }; } diff --git a/apiphany-core/src/main/java/org/apiphany/RequestParameters.java b/apiphany-core/src/main/java/org/apiphany/RequestParameters.java index 9685b97d..273f64f9 100644 --- a/apiphany-core/src/main/java/org/apiphany/RequestParameters.java +++ b/apiphany-core/src/main/java/org/apiphany/RequestParameters.java @@ -16,6 +16,7 @@ import org.morphix.convert.MapConversions; import org.morphix.convert.function.SimpleConverter; import org.morphix.lang.JavaArrays; +import org.morphix.lang.JavaObjects; import org.morphix.lang.collections.Lists; import org.morphix.lang.collections.Maps; import org.morphix.lang.function.PutFunction; @@ -149,12 +150,10 @@ public static Map> from(final String body, final Charset en return params; } String[] bodyParams = body.split(SEPARATOR); - for (String bodyParam : bodyParams) { int index = bodyParam.indexOf(RequestParameter.NAME_VALUE_SEPARATOR); final String decodedKey; final String decodedValue; - if (index >= 0) { decodedKey = URLDecoder.decode(bodyParam.substring(0, index), encoding); decodedValue = URLDecoder.decode(bodyParam.substring(index + 1), encoding); @@ -231,8 +230,7 @@ public static Map> from(final Object queryParams, final Sim } Require.thatNot(queryParams instanceof List, "Cannot convert a List into request parameters map. Expected a POJO or a Map."); Require.thatNot(queryParams instanceof Set, "Cannot convert a Set into request parameters map. Expected a POJO or a Map."); - Require.thatNot(queryParams.getClass().isArray(), "Cannot convert an Array into request parameters map. Expected a POJO or a Map."); - + Require.thatNot(JavaObjects.isArray(queryParams), "Cannot convert an Array into request parameters map. Expected a POJO or a Map."); if (queryParams instanceof Map map) { return from(map, nameConverter); } @@ -273,7 +271,7 @@ public static Map> from(final Map map, final S * @return a map representation of the object's fields */ protected static Map> fromObject(final Object queryParams, final SimpleConverter nameConverter) { - List extendedFields = ExtendedFields.findAllNonStatic(queryParams, RequestParameters::fieldValueNotNull); + List extendedFields = ExtendedFields.findAllNonStatic(queryParams, ExtendedField::valueNotNull); Map> paramMap = LinkedHashMap.newLinkedHashMap(extendedFields.size()); if (Lists.isEmpty(extendedFields)) { return paramMap; @@ -292,16 +290,6 @@ protected static Map> fromObject(final Object queryParams, return paramMap; } - /** - * Returns true if the field value is not {@code null}. - * - * @param extendedField the field to check. - * @return true if the field value is not {@code null}, false otherwise - */ - private static boolean fieldValueNotNull(final ExtendedField extendedField) { - return null != extendedField.getFieldValue(); - } - /** * Hide constructor. */ diff --git a/pom.xml b/pom.xml index e7c38be6..313f3dae 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ - 1.1.2 + 1.1.3 1.17.3 2.21 2.21.8 From 5c49e2d958d2b34b3921d89ee5e0024547de9b72 Mon Sep 17 00:00:00 2001 From: raduking Date: Mon, 23 Nov 2026 15:01:21 +0200 Subject: [PATCH 17/19] Move Spring clients integration to specific packages. --- .../apiphany/tests/ApiClientWithDefaultClientIT.java | 7 ++++++- .../tests/ApiClientWithDefaultClientRedirectsIT.java | 2 +- .../src/test/java/org/apiphany/tests/ApiIT.java | 4 ++-- .../ApiClientWithDefaultClientSecurityIT.java | 7 ++++++- ...RestClientJavaNetRedirectsWithClientLibraryIT.java | 11 ++--------- ...lientWithRestClientJavaNetWithClientLibraryIT.java | 10 ++-------- ...stTemplateJavaNetRedirectsWithClientLibraryIT.java | 11 ++--------- ...entWithRestTemplateJavaNetWithClientLibraryIT.java | 10 ++-------- .../ApiClientWithRestClientHC5IT.java | 5 +++-- .../ApiClientWithRestClientHC5RedirectsIT.java | 5 +++-- .../ApiClientWithRestTemplateHC5IT.java | 5 +++-- .../ApiClientWithRestTemplateHC5RedirectsIT.java | 5 +++-- .../{ => httpclient5}/ApiWithRestClientHC5IT.java | 5 +++-- .../{ => httpclient5}/ApiWithRestTemplateHC5IT.java | 7 ++++--- .../ApiClientWithRestClientHC5SecurityIT.java | 5 +++-- .../ApiClientWithRestTemplateHC5SecurityIT.java | 5 +++-- .../{ => okhttp}/ApiClientWithRestClientOkHttpIT.java | 5 +++-- .../ApiClientWithRestClientOkHttpRedirectsIT.java | 5 +++-- .../ApiClientWithRestTemplateOkHttpIT.java | 5 +++-- .../ApiClientWithRestTemplateOkHttpRedirectsIT.java | 5 +++-- .../tests/{ => okhttp}/ApiWithRestClientOkHttpIT.java | 5 +++-- .../{ => okhttp}/ApiWithRestTemplateOkHttpIT.java | 5 +++-- .../ApiClientWithRestClientOkHttpSecurityIT.java | 5 +++-- .../ApiClientWithRestTemplateOkHttpSecurityIT.java | 5 +++-- ...estTemplateJavaNetSecurityWithClientLibraryIT.java | 11 ++--------- 25 files changed, 74 insertions(+), 81 deletions(-) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => httpclient5}/ApiClientWithRestClientHC5IT.java (79%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => httpclient5}/ApiClientWithRestClientHC5RedirectsIT.java (75%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => httpclient5}/ApiClientWithRestTemplateHC5IT.java (79%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => httpclient5}/ApiClientWithRestTemplateHC5RedirectsIT.java (76%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => httpclient5}/ApiWithRestClientHC5IT.java (73%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => httpclient5}/ApiWithRestTemplateHC5IT.java (67%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => httpclient5}/security/ApiClientWithRestClientHC5SecurityIT.java (77%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => httpclient5}/security/ApiClientWithRestTemplateHC5SecurityIT.java (75%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => okhttp}/ApiClientWithRestClientOkHttpIT.java (74%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => okhttp}/ApiClientWithRestClientOkHttpRedirectsIT.java (72%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => okhttp}/ApiClientWithRestTemplateOkHttpIT.java (74%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => okhttp}/ApiClientWithRestTemplateOkHttpRedirectsIT.java (72%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => okhttp}/ApiWithRestClientOkHttpIT.java (84%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => okhttp}/ApiWithRestTemplateOkHttpIT.java (84%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => okhttp}/security/ApiClientWithRestClientOkHttpSecurityIT.java (70%) rename integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/{ => okhttp}/security/ApiClientWithRestTemplateOkHttpSecurityIT.java (70%) diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java index d479eabe..a781a61f 100644 --- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java +++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java @@ -43,7 +43,7 @@ * * @author Radu Sebastian LAZIN */ -class ApiClientWithDefaultClientIT implements ApiphanyContract { +public class ApiClientWithDefaultClientIT implements ApiphanyContract { @RegisterExtension private static final WireMockExtension wiremock = @@ -57,6 +57,11 @@ public WireMockExtension wiremock() { return wiremock; } + @Override + public ClientProperties clientProperties() { + return ApiphanyContract.super.clientProperties(); + } + private abstract class NestedContract implements ApiphanyContract { @Override diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java index a747d7bf..98595540 100644 --- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java +++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java @@ -16,7 +16,7 @@ * * @author Radu Sebastian LAZIN */ -class ApiClientWithDefaultClientRedirectsIT implements ApiphanyContract { +public class ApiClientWithDefaultClientRedirectsIT implements ApiphanyContract { @RegisterExtension private static final WireMockExtension wiremock = diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiIT.java index 0a7d4f4d..c8d3deb4 100644 --- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiIT.java +++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiIT.java @@ -21,7 +21,7 @@ * * @author Radu Sebastian LAZIN */ -class ApiIT { +public class ApiIT { private static final String PATH = "/hello"; @@ -32,7 +32,7 @@ class ApiIT { .options(options().dynamicPort()) .build(); - ExchangeClient client() { + public ExchangeClient client() { return new JavaNetHttpExchangeClient(); } diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java index a2fc08c6..a41738d4 100644 --- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java +++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java @@ -27,7 +27,7 @@ * * @author Radu Sebastian LAZIN */ -class ApiClientWithDefaultClientSecurityIT implements ApiphanyContract { +public class ApiClientWithDefaultClientSecurityIT implements ApiphanyContract { @RegisterExtension private static final WireMockExtension wiremock = @@ -55,6 +55,11 @@ public WireMockExtension wiremock() { return wiremock; } + @Override + public ClientProperties clientProperties() { + return ApiphanyContract.super.clientProperties(); + } + private abstract class NestedContract implements ApiphanyContract { @Override diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientJavaNetRedirectsWithClientLibraryIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientJavaNetRedirectsWithClientLibraryIT.java index e76e25b4..405efe24 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientJavaNetRedirectsWithClientLibraryIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientJavaNetRedirectsWithClientLibraryIT.java @@ -11,17 +11,10 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestClientJavaNetRedirectsWithClientLibraryIT - extends ApiClientWithRestClientJavaNetRedirectsIT { +class ApiClientWithRestClientJavaNetRedirectsWithClientLibraryIT extends ApiClientWithRestClientJavaNetRedirectsIT { @Override public ClientProperties clientProperties() { - ClientProperties properties = super.clientProperties(); - properties.setCustomProperties(SpringRestClientProperties.ROOT, new SpringRestClientProperties() { - { - setClientLibrary(JavaNetHttpLibrary.CLIENT_NAME); - } - }); - return properties; + return SpringRestClientProperties.withClientLibrary(super.clientProperties(), JavaNetHttpLibrary.CLIENT_NAME); } } diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientJavaNetWithClientLibraryIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientJavaNetWithClientLibraryIT.java index 6f9108e4..e00668de 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientJavaNetWithClientLibraryIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientJavaNetWithClientLibraryIT.java @@ -10,16 +10,10 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestClientJavaNetWithClientLibraryIT extends ApiClientWithRestClientJavaNetIT { +class ApiClientWithRestClientJavaNetWithClientLibraryIT extends ApiClientWithRestClientJavaNetIT { @Override public ClientProperties clientProperties() { - ClientProperties properties = super.clientProperties(); - properties.setCustomProperties(SpringRestClientProperties.ROOT, new SpringRestClientProperties() { - { - setClientLibrary(JavaNetHttpLibrary.CLIENT_NAME); - } - }); - return properties; + return SpringRestClientProperties.withClientLibrary(super.clientProperties(), JavaNetHttpLibrary.CLIENT_NAME); } } diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateJavaNetRedirectsWithClientLibraryIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateJavaNetRedirectsWithClientLibraryIT.java index c89f9f90..9e0c7c7a 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateJavaNetRedirectsWithClientLibraryIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateJavaNetRedirectsWithClientLibraryIT.java @@ -11,17 +11,10 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestTemplateJavaNetRedirectsWithClientLibraryIT - extends ApiClientWithRestTemplateJavaNetRedirectsIT { +class ApiClientWithRestTemplateJavaNetRedirectsWithClientLibraryIT extends ApiClientWithRestTemplateJavaNetRedirectsIT { @Override public ClientProperties clientProperties() { - ClientProperties properties = super.clientProperties(); - properties.setCustomProperties(SpringRestClientProperties.ROOT, new SpringRestClientProperties() { - { - setClientLibrary(JavaNetHttpLibrary.CLIENT_NAME); - } - }); - return properties; + return SpringRestClientProperties.withClientLibrary(super.clientProperties(), JavaNetHttpLibrary.CLIENT_NAME); } } diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateJavaNetWithClientLibraryIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateJavaNetWithClientLibraryIT.java index 93f228f1..6d367533 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateJavaNetWithClientLibraryIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateJavaNetWithClientLibraryIT.java @@ -10,16 +10,10 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestTemplateJavaNetWithClientLibraryIT extends ApiClientWithRestTemplateJavaNetIT { +class ApiClientWithRestTemplateJavaNetWithClientLibraryIT extends ApiClientWithRestTemplateJavaNetIT { @Override public ClientProperties clientProperties() { - ClientProperties properties = super.clientProperties(); - properties.setCustomProperties(SpringRestClientProperties.ROOT, new SpringRestClientProperties() { - { - setClientLibrary(JavaNetHttpLibrary.CLIENT_NAME); - } - }); - return properties; + return SpringRestClientProperties.withClientLibrary(super.clientProperties(), JavaNetHttpLibrary.CLIENT_NAME); } } diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientHC5IT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestClientHC5IT.java similarity index 79% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientHC5IT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestClientHC5IT.java index bb2b9f84..490b891d 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientHC5IT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestClientHC5IT.java @@ -1,16 +1,17 @@ -package org.apiphany.tests; +package org.apiphany.tests.httpclient5; import org.apiphany.ApiClient; import org.apiphany.client.ExchangeClient; import org.apiphany.client.http.SpringRestExchangeClient; import org.apiphany.security.AuthenticationType; +import org.apiphany.tests.ApiClientWithDefaultClientIT; /** * Test class for {@link ApiClient} using {@link SpringRestExchangeClient}. * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestClientHC5IT extends ApiClientWithDefaultClientIT { +class ApiClientWithRestClientHC5IT extends ApiClientWithDefaultClientIT { @Override public Class exchangeClientClass() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientHC5RedirectsIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestClientHC5RedirectsIT.java similarity index 75% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientHC5RedirectsIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestClientHC5RedirectsIT.java index cd4627b5..149068b6 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientHC5RedirectsIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestClientHC5RedirectsIT.java @@ -1,15 +1,16 @@ -package org.apiphany.tests; +package org.apiphany.tests.httpclient5; import org.apiphany.client.ExchangeClient; import org.apiphany.client.http.SpringRestExchangeClient; import org.apiphany.security.AuthenticationType; +import org.apiphany.tests.ApiClientWithDefaultClientRedirectsIT; /** * Redirect-focused test class for {@link SpringRestExchangeClient}. * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestClientHC5RedirectsIT extends ApiClientWithDefaultClientRedirectsIT { +class ApiClientWithRestClientHC5RedirectsIT extends ApiClientWithDefaultClientRedirectsIT { @Override public Class exchangeClientClass() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateHC5IT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestTemplateHC5IT.java similarity index 79% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateHC5IT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestTemplateHC5IT.java index f2934589..4a1261f0 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateHC5IT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestTemplateHC5IT.java @@ -1,16 +1,17 @@ -package org.apiphany.tests; +package org.apiphany.tests.httpclient5; import org.apiphany.ApiClient; import org.apiphany.client.ExchangeClient; import org.apiphany.client.http.RestTemplateExchangeClient; import org.apiphany.security.AuthenticationType; +import org.apiphany.tests.ApiClientWithDefaultClientIT; /** * Test class for {@link ApiClient} using {@link RestTemplateExchangeClient}. * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestTemplateHC5IT extends ApiClientWithDefaultClientIT { +class ApiClientWithRestTemplateHC5IT extends ApiClientWithDefaultClientIT { @Override public Class exchangeClientClass() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateHC5RedirectsIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestTemplateHC5RedirectsIT.java similarity index 76% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateHC5RedirectsIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestTemplateHC5RedirectsIT.java index 7c41c084..ca49a1b1 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateHC5RedirectsIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiClientWithRestTemplateHC5RedirectsIT.java @@ -1,15 +1,16 @@ -package org.apiphany.tests; +package org.apiphany.tests.httpclient5; import org.apiphany.client.ExchangeClient; import org.apiphany.client.http.RestTemplateExchangeClient; import org.apiphany.security.AuthenticationType; +import org.apiphany.tests.ApiClientWithDefaultClientRedirectsIT; /** * Redirect-focused test class for {@link RestTemplateExchangeClient} using Apache HC5 backend. * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestTemplateHC5RedirectsIT extends ApiClientWithDefaultClientRedirectsIT { +class ApiClientWithRestTemplateHC5RedirectsIT extends ApiClientWithDefaultClientRedirectsIT { @Override public Class exchangeClientClass() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestClientHC5IT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiWithRestClientHC5IT.java similarity index 73% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestClientHC5IT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiWithRestClientHC5IT.java index 18b07c2f..1f0143d4 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestClientHC5IT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiWithRestClientHC5IT.java @@ -1,15 +1,16 @@ -package org.apiphany.tests; +package org.apiphany.tests.httpclient5; import org.apiphany.Api; import org.apiphany.client.ExchangeClient; import org.apiphany.client.http.SpringRestExchangeClient; +import org.apiphany.tests.ApiIT; /** * Test class for {@link Api} using {@link SpringRestExchangeClient}. * * @author Radu Sebastian LAZIN */ -public class ApiWithRestClientHC5IT extends ApiIT { +class ApiWithRestClientHC5IT extends ApiIT { @Override public ExchangeClient client() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestTemplateHC5IT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiWithRestTemplateHC5IT.java similarity index 67% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestTemplateHC5IT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiWithRestTemplateHC5IT.java index 60f0a4b1..ce60d4f1 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestTemplateHC5IT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/ApiWithRestTemplateHC5IT.java @@ -1,18 +1,19 @@ -package org.apiphany.tests; +package org.apiphany.tests.httpclient5; import org.apiphany.ApiClient; import org.apiphany.client.ExchangeClient; import org.apiphany.client.http.RestTemplateExchangeClient; +import org.apiphany.tests.ApiIT; /** * Test class for {@link ApiClient} using {@link RestTemplateExchangeClient}. * * @author Radu Sebastian LAZIN */ -public class ApiWithRestTemplateHC5IT extends ApiIT { +class ApiWithRestTemplateHC5IT extends ApiIT { @Override - ExchangeClient client() { + public ExchangeClient client() { return new RestTemplateExchangeClient(); } } diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestClientHC5SecurityIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/security/ApiClientWithRestClientHC5SecurityIT.java similarity index 77% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestClientHC5SecurityIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/security/ApiClientWithRestClientHC5SecurityIT.java index b408e97a..b8b77db5 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestClientHC5SecurityIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/security/ApiClientWithRestClientHC5SecurityIT.java @@ -1,17 +1,18 @@ -package org.apiphany.tests.security; +package org.apiphany.tests.httpclient5.security; import org.apiphany.ApiClient; import org.apiphany.client.ExchangeClient; import org.apiphany.client.http.RestTemplateExchangeClient; import org.apiphany.client.http.SpringRestExchangeClient; import org.apiphany.security.AuthenticationType; +import org.apiphany.tests.security.ApiClientWithDefaultClientSecurityIT; /** * Security test class for {@link ApiClient} using {@link RestTemplateExchangeClient}. * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestClientHC5SecurityIT extends ApiClientWithDefaultClientSecurityIT { +class ApiClientWithRestClientHC5SecurityIT extends ApiClientWithDefaultClientSecurityIT { @Override public Class exchangeClientClass() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestTemplateHC5SecurityIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/security/ApiClientWithRestTemplateHC5SecurityIT.java similarity index 75% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestTemplateHC5SecurityIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/security/ApiClientWithRestTemplateHC5SecurityIT.java index 50010d23..74143d77 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestTemplateHC5SecurityIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/httpclient5/security/ApiClientWithRestTemplateHC5SecurityIT.java @@ -1,16 +1,17 @@ -package org.apiphany.tests.security; +package org.apiphany.tests.httpclient5.security; import org.apiphany.ApiClient; import org.apiphany.client.ExchangeClient; import org.apiphany.client.http.RestTemplateExchangeClient; import org.apiphany.security.AuthenticationType; +import org.apiphany.tests.security.ApiClientWithDefaultClientSecurityIT; /** * Security test class for {@link ApiClient} using {@link RestTemplateExchangeClient}. * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestTemplateHC5SecurityIT extends ApiClientWithDefaultClientSecurityIT { +class ApiClientWithRestTemplateHC5SecurityIT extends ApiClientWithDefaultClientSecurityIT { @Override public Class exchangeClientClass() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientOkHttpIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestClientOkHttpIT.java similarity index 74% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientOkHttpIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestClientOkHttpIT.java index c98cca66..5613a2fa 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientOkHttpIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestClientOkHttpIT.java @@ -1,8 +1,9 @@ -package org.apiphany.tests; +package org.apiphany.tests.okhttp; import org.apiphany.client.ClientProperties; import org.apiphany.client.http.SpringRestClientProperties; import org.apiphany.http.OkHttpLibrary; +import org.apiphany.tests.ApiClientWithDefaultClientIT; /** * Test class for {@link org.apiphany.client.http.SpringRestExchangeClient} with OkHttp as the Spring request factory @@ -10,7 +11,7 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestClientOkHttpIT extends ApiClientWithRestClientHC5IT { +class ApiClientWithRestClientOkHttpIT extends ApiClientWithDefaultClientIT { @Override public ClientProperties clientProperties() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientOkHttpRedirectsIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestClientOkHttpRedirectsIT.java similarity index 72% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientOkHttpRedirectsIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestClientOkHttpRedirectsIT.java index 9a3d62fa..023b93e6 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestClientOkHttpRedirectsIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestClientOkHttpRedirectsIT.java @@ -1,8 +1,9 @@ -package org.apiphany.tests; +package org.apiphany.tests.okhttp; import org.apiphany.client.ClientProperties; import org.apiphany.client.http.SpringRestClientProperties; import org.apiphany.http.OkHttpLibrary; +import org.apiphany.tests.ApiClientWithDefaultClientRedirectsIT; /** * Redirect-focused test class for {@link org.apiphany.client.http.SpringRestExchangeClient} with OkHttp as the Spring @@ -10,7 +11,7 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestClientOkHttpRedirectsIT extends ApiClientWithRestClientHC5RedirectsIT { +class ApiClientWithRestClientOkHttpRedirectsIT extends ApiClientWithDefaultClientRedirectsIT { @Override public ClientProperties clientProperties() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateOkHttpIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestTemplateOkHttpIT.java similarity index 74% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateOkHttpIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestTemplateOkHttpIT.java index 55deb8ca..af510b66 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateOkHttpIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestTemplateOkHttpIT.java @@ -1,8 +1,9 @@ -package org.apiphany.tests; +package org.apiphany.tests.okhttp; import org.apiphany.client.ClientProperties; import org.apiphany.client.http.SpringRestClientProperties; import org.apiphany.http.OkHttpLibrary; +import org.apiphany.tests.ApiClientWithDefaultClientIT; /** * Test class for {@link org.apiphany.client.http.RestTemplateExchangeClient} with OkHttp as the Spring request factory @@ -10,7 +11,7 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestTemplateOkHttpIT extends ApiClientWithRestTemplateHC5IT { +class ApiClientWithRestTemplateOkHttpIT extends ApiClientWithDefaultClientIT { @Override public ClientProperties clientProperties() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateOkHttpRedirectsIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestTemplateOkHttpRedirectsIT.java similarity index 72% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateOkHttpRedirectsIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestTemplateOkHttpRedirectsIT.java index 4b8534ba..c7d02e5c 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiClientWithRestTemplateOkHttpRedirectsIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiClientWithRestTemplateOkHttpRedirectsIT.java @@ -1,8 +1,9 @@ -package org.apiphany.tests; +package org.apiphany.tests.okhttp; import org.apiphany.client.ClientProperties; import org.apiphany.client.http.SpringRestClientProperties; import org.apiphany.http.OkHttpLibrary; +import org.apiphany.tests.ApiClientWithDefaultClientRedirectsIT; /** * Redirect-focused test class for {@link org.apiphany.client.http.RestTemplateExchangeClient} with OkHttp as the Spring @@ -10,7 +11,7 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestTemplateOkHttpRedirectsIT extends ApiClientWithRestTemplateHC5RedirectsIT { +class ApiClientWithRestTemplateOkHttpRedirectsIT extends ApiClientWithDefaultClientRedirectsIT { @Override public ClientProperties clientProperties() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestClientOkHttpIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiWithRestClientOkHttpIT.java similarity index 84% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestClientOkHttpIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiWithRestClientOkHttpIT.java index ab08b22e..6e907179 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestClientOkHttpIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiWithRestClientOkHttpIT.java @@ -1,10 +1,11 @@ -package org.apiphany.tests; +package org.apiphany.tests.okhttp; import org.apiphany.client.ClientProperties; import org.apiphany.client.ExchangeClient; import org.apiphany.client.http.SpringRestClientProperties; import org.apiphany.client.http.SpringRestExchangeClient; import org.apiphany.http.OkHttpLibrary; +import org.apiphany.tests.ApiIT; /** * Test class for {@link org.apiphany.Api} using {@link SpringRestExchangeClient} with OkHttp as the Spring request @@ -12,7 +13,7 @@ * * @author Radu Sebastian LAZIN */ -public class ApiWithRestClientOkHttpIT extends ApiWithRestClientHC5IT { +class ApiWithRestClientOkHttpIT extends ApiIT { @Override public ExchangeClient client() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestTemplateOkHttpIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiWithRestTemplateOkHttpIT.java similarity index 84% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestTemplateOkHttpIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiWithRestTemplateOkHttpIT.java index ec6b8dd5..a3c6ccd1 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/ApiWithRestTemplateOkHttpIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/ApiWithRestTemplateOkHttpIT.java @@ -1,10 +1,11 @@ -package org.apiphany.tests; +package org.apiphany.tests.okhttp; import org.apiphany.client.ClientProperties; import org.apiphany.client.ExchangeClient; import org.apiphany.client.http.RestTemplateExchangeClient; import org.apiphany.client.http.SpringRestClientProperties; import org.apiphany.http.OkHttpLibrary; +import org.apiphany.tests.ApiIT; /** * Test class for {@link org.apiphany.Api} using {@link RestTemplateExchangeClient} with OkHttp as the Spring request @@ -12,7 +13,7 @@ * * @author Radu Sebastian LAZIN */ -public class ApiWithRestTemplateOkHttpIT extends ApiWithRestTemplateHC5IT { +class ApiWithRestTemplateOkHttpIT extends ApiIT { @Override public ExchangeClient client() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestClientOkHttpSecurityIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/security/ApiClientWithRestClientOkHttpSecurityIT.java similarity index 70% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestClientOkHttpSecurityIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/security/ApiClientWithRestClientOkHttpSecurityIT.java index 9bd2b8f0..bd8913b3 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestClientOkHttpSecurityIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/security/ApiClientWithRestClientOkHttpSecurityIT.java @@ -1,8 +1,9 @@ -package org.apiphany.tests.security; +package org.apiphany.tests.okhttp.security; import org.apiphany.client.ClientProperties; import org.apiphany.client.http.SpringRestClientProperties; import org.apiphany.http.OkHttpLibrary; +import org.apiphany.tests.security.ApiClientWithDefaultClientSecurityIT; /** * Security test class for {@link org.apiphany.client.http.SpringRestExchangeClient} with OkHttp as the Spring request @@ -10,7 +11,7 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestClientOkHttpSecurityIT extends ApiClientWithRestClientHC5SecurityIT { +class ApiClientWithRestClientOkHttpSecurityIT extends ApiClientWithDefaultClientSecurityIT { @Override public ClientProperties clientProperties() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestTemplateOkHttpSecurityIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/security/ApiClientWithRestTemplateOkHttpSecurityIT.java similarity index 70% rename from integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestTemplateOkHttpSecurityIT.java rename to integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/security/ApiClientWithRestTemplateOkHttpSecurityIT.java index 6dae1f33..fce7133a 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestTemplateOkHttpSecurityIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/okhttp/security/ApiClientWithRestTemplateOkHttpSecurityIT.java @@ -1,8 +1,9 @@ -package org.apiphany.tests.security; +package org.apiphany.tests.okhttp.security; import org.apiphany.client.ClientProperties; import org.apiphany.client.http.SpringRestClientProperties; import org.apiphany.http.OkHttpLibrary; +import org.apiphany.tests.security.ApiClientWithDefaultClientSecurityIT; /** * Security test class for {@link org.apiphany.client.http.RestTemplateExchangeClient} with OkHttp as the Spring request @@ -10,7 +11,7 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestTemplateOkHttpSecurityIT extends ApiClientWithRestTemplateHC5SecurityIT { +class ApiClientWithRestTemplateOkHttpSecurityIT extends ApiClientWithDefaultClientSecurityIT { @Override public ClientProperties clientProperties() { diff --git a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestTemplateJavaNetSecurityWithClientLibraryIT.java b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestTemplateJavaNetSecurityWithClientLibraryIT.java index 0fd69099..4426923a 100644 --- a/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestTemplateJavaNetSecurityWithClientLibraryIT.java +++ b/integration/apiphany-spring-tests/src/test/java/org/apiphany/tests/security/ApiClientWithRestTemplateJavaNetSecurityWithClientLibraryIT.java @@ -11,17 +11,10 @@ * * @author Radu Sebastian LAZIN */ -public class ApiClientWithRestTemplateJavaNetSecurityWithClientLibraryIT - extends ApiClientWithRestTemplateJavaNetSecurityIT { +class ApiClientWithRestTemplateJavaNetSecurityWithClientLibraryIT extends ApiClientWithRestTemplateJavaNetSecurityIT { @Override public ClientProperties clientProperties() { - ClientProperties properties = super.clientProperties(); - properties.setCustomProperties(SpringRestClientProperties.ROOT, new SpringRestClientProperties() { - { - setClientLibrary(JavaNetHttpLibrary.CLIENT_NAME); - } - }); - return properties; + return SpringRestClientProperties.withClientLibrary(super.clientProperties(), JavaNetHttpLibrary.CLIENT_NAME); } } From 0e28dee30183a204e637c28072650c0545a8810a Mon Sep 17 00:00:00 2001 From: raduking Date: Mon, 23 Nov 2026 17:00:13 +0200 Subject: [PATCH 18/19] Add reset Wiremock before each IT test so there is no interference. --- .../org/apiphany/tests/ApiClientWithDefaultClientIT.java | 6 ++++++ .../tests/ApiClientWithDefaultClientRedirectsIT.java | 6 ++++++ .../security/ApiClientWithDefaultClientSecurityIT.java | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java index a781a61f..4454e522 100644 --- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java +++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java @@ -22,6 +22,7 @@ import org.apiphany.tests.contract.RedirectsContract; import org.apiphany.tests.contract.RetryContract; import org.apiphany.tests.contract.StreamContract; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.extension.RegisterExtension; @@ -57,6 +58,11 @@ public WireMockExtension wiremock() { return wiremock; } + @BeforeEach + void resetWireMock() { + wiremock.resetAll(); + } + @Override public ClientProperties clientProperties() { return ApiphanyContract.super.clientProperties(); diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java index 98595540..29c0d465 100644 --- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java +++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java @@ -6,6 +6,7 @@ import org.apiphany.client.ClientProperties; import org.apiphany.tests.contract.ApiphanyContract; import org.apiphany.tests.contract.RedirectsContract; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.extension.RegisterExtension; @@ -30,6 +31,11 @@ public WireMockExtension wiremock() { return wiremock; } + @BeforeEach + void resetWireMock() { + wiremock.resetAll(); + } + @Override public boolean enableRedirects() { return true; diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java index a41738d4..cbe30fe3 100644 --- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java +++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java @@ -11,6 +11,7 @@ import org.apiphany.test.Tests; import org.apiphany.tests.contract.ApiphanyContract; import org.apiphany.tests.contract.TLSContract; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.extension.RegisterExtension; @@ -55,6 +56,11 @@ public WireMockExtension wiremock() { return wiremock; } + @BeforeEach + void resetWireMock() { + wiremock.resetAll(); + } + @Override public ClientProperties clientProperties() { return ApiphanyContract.super.clientProperties(); From 0f1459c725cf1b9524cf9c5a0a6cd24bc438f3d3 Mon Sep 17 00:00:00 2001 From: raduking Date: Tue, 24 Nov 2026 01:54:09 +0200 Subject: [PATCH 19/19] Change Wiremock lifecycle per tests. --- .../java/org/apiphany/tests/ApiClientWithDefaultClientIT.java | 4 +++- .../apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java | 4 +++- .../tests/security/ApiClientWithDefaultClientSecurityIT.java | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java index 4454e522..eda75542 100644 --- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java +++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientIT.java @@ -24,6 +24,7 @@ import org.apiphany.tests.contract.StreamContract; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.RegisterExtension; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; @@ -44,10 +45,11 @@ * * @author Radu Sebastian LAZIN */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ApiClientWithDefaultClientIT implements ApiphanyContract { @RegisterExtension - private static final WireMockExtension wiremock = + private final WireMockExtension wiremock = WireMockExtension.newInstance() .options(options() .dynamicPort()) diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java index 29c0d465..4746a4e0 100644 --- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java +++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/ApiClientWithDefaultClientRedirectsIT.java @@ -8,6 +8,7 @@ import org.apiphany.tests.contract.RedirectsContract; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.RegisterExtension; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; @@ -17,10 +18,11 @@ * * @author Radu Sebastian LAZIN */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ApiClientWithDefaultClientRedirectsIT implements ApiphanyContract { @RegisterExtension - private static final WireMockExtension wiremock = + private final WireMockExtension wiremock = WireMockExtension.newInstance() .options(options() .dynamicPort()) diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java index cbe30fe3..1bec9eeb 100644 --- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java +++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ApiClientWithDefaultClientSecurityIT.java @@ -13,6 +13,7 @@ import org.apiphany.tests.contract.TLSContract; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.RegisterExtension; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; @@ -28,10 +29,11 @@ * * @author Radu Sebastian LAZIN */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ApiClientWithDefaultClientSecurityIT implements ApiphanyContract { @RegisterExtension - private static final WireMockExtension wiremock = + private final WireMockExtension wiremock = WireMockExtension.newInstance() .options(options() .dynamicHttpsPort()