From 5adb5186f0bf56cf0e2ec05e74f0d6d6a751c4c4 Mon Sep 17 00:00:00 2001 From: Alexander Molochko Date: Thu, 25 Apr 2019 11:19:54 -0700 Subject: [PATCH] Add comma-separated example --- .../webclientrequests/WebClientRequestsUnitTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spring-5-webflux/src/test/java/com/baeldung/spring/webclientrequests/WebClientRequestsUnitTest.java b/spring-5-webflux/src/test/java/com/baeldung/spring/webclientrequests/WebClientRequestsUnitTest.java index 62fca0ba9d..c1bab1ecf5 100644 --- a/spring-5-webflux/src/test/java/com/baeldung/spring/webclientrequests/WebClientRequestsUnitTest.java +++ b/spring-5-webflux/src/test/java/com/baeldung/spring/webclientrequests/WebClientRequestsUnitTest.java @@ -131,6 +131,7 @@ public class WebClientRequestsUnitTest { verifyCalledUrl("/posts/?tag%5B%5D=Spring&tag%5B%5D=Kotlin"); } + @Test public void whenCallArrayQueryParams_thenURIMatched() { this.webClient.get() @@ -142,6 +143,17 @@ public class WebClientRequestsUnitTest { verifyCalledUrl("/posts/?category=Web&category=Mobile"); } + @Test + public void whenCallArrayQueryParamsComma_thenURIMatched() { + this.webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/posts/") + .queryParam("category", String.join(",", "Web", "Mobile")) + .build()) + .retrieve(); + verifyCalledUrl("/posts/?category=Web,Mobile"); + } + private void verifyCalledUrl(String relativeUrl) { ClientRequest request = this.argumentCaptor.getValue(); Assert.assertEquals(String.format("%s%s", BASE_URL, relativeUrl), request.url().toString());