}
- @GetMapping(path = "/", produces = MediaType.TEXT_PLAIN_VALUE)
+ @GetMapping(path = { "", "/" }, produces = MediaType.TEXT_PLAIN_VALUE)
public Mono<String> fetch(@RequestParam String path)
{
return service.getRemoteText(path);
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
RemoteContentService service;
- @Test
- @DisplayName("Mapping for HtmlController with a parameter: /?path=foo")
- void testUriWithParameter()
+ @DisplayName("Valid mappings for HtmlController with a parameter")
+ @ParameterizedTest()
+ @ValueSource(strings = { "/?path=foo", "?path=foo" })
+ void testUriWithParameter(String uri)
{
when(service.getRemoteText("foo")).thenReturn(Mono.just("bar"));
webClient
.get()
- .uri("/?path=foo")
+ .uri(uri)
.exchange()
.expectStatus().isOk()
.expectBody(String.class).value(rendered ->
import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.springframework.beans.factory.annotation.Autowired;
RemoteContentService service;
- @Test
- @DisplayName("Valid mapping for RestController: /?path=foo")
- void testUriWithParameter()
+ @DisplayName("Valid mappings for RestController with parameter")
+ @ParameterizedTest()
+ @ValueSource(strings = { "/?path=foo", "?path=foo" })
+ void testUriWithParameter(String uri)
{
when(service.getRemoteText("foo")).thenReturn(Mono.just("bar"));
webClient
.get()
- .uri("/?path=foo")
+ .uri(uri)
.header("Accept", MediaType.TEXT_PLAIN_VALUE)
.exchange()
.expectStatus().isOk()