From 734e4b8cdcb9c4ac72ed94a38236338f4d46bfcf Mon Sep 17 00:00:00 2001 From: Hyunwoo Gu Date: Mon, 1 Dec 2025 23:38:02 +0900 Subject: [PATCH] Add unit tests for apply() method handling empty and slash-prefixed URIs - Added tests for RootUriTemplateHandler.apply() covering: - URIs starting with '/' - Empty string - Blank string - Absolute URLs - Relative paths - Ensures apply() behaves as expected in all edge cases Signed-off-by: Hyunwoo Gu --- .../boot/restclient/RootUriBuilderFactoryTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/module/spring-boot-restclient/src/test/java/org/springframework/boot/restclient/RootUriBuilderFactoryTests.java b/module/spring-boot-restclient/src/test/java/org/springframework/boot/restclient/RootUriBuilderFactoryTests.java index 7251decdd0b..445d93d93c0 100644 --- a/module/spring-boot-restclient/src/test/java/org/springframework/boot/restclient/RootUriBuilderFactoryTests.java +++ b/module/spring-boot-restclient/src/test/java/org/springframework/boot/restclient/RootUriBuilderFactoryTests.java @@ -32,6 +32,7 @@ import static org.mockito.Mockito.mock; * Tests for {@link RootUriBuilderFactory}. * * @author Scott Frederick + * @author Hyunwoo Gu */ class RootUriBuilderFactoryTests { @@ -43,4 +44,12 @@ class RootUriBuilderFactoryTests { assertThat(builder.build()).isEqualTo(new URI("https://example.com/hello")); } + @Test + void uriStringWhenEmptyShouldReturnRoot() throws URISyntaxException { + UriBuilderFactory builderFactory = new RootUriBuilderFactory("https://example.com", + mock(UriTemplateHandler.class)); + UriBuilder builder = builderFactory.uriString(""); + assertThat(builder.build()).isEqualTo(new URI("https://example.com")); + } + }