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;
@Test
- @DisplayName("Mapping for HtmlController: /?path=foo")
+ @DisplayName("Mapping for HtmlController with a parameter: /?path=foo")
void testUriWithParameter()
{
when(service.getRemoteText("foo")).thenReturn(Mono.just("bar"));
verify(service).getRemoteText("foo");
}
- @Test
- @DisplayName("Mapping for HtmlController: /")
- void testUriWithoutParameter()
+ @DisplayName("Mappings for HtmlController without a parameter")
+ @ParameterizedTest(name = "{arguments} ==> uri={0}")
+ @ValueSource(strings = { "/", "", "?foo=bar", "/?foo=bar"})
+ void testUriWithoutParameter(String uri)
{
webClient
.get()
- .uri("/")
+ .uri(uri)
.exchange()
.expectStatus().isOk()
.expectBody(String.class).value(rendered ->