From a8d8724d2121865c96692a25fd29ecf0d266bf7e Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 14 Jan 2020 20:04:27 +0100 Subject: [PATCH] Verified, that requests to the RestController without "path" are invalid --- .../java/de/juplo/demo/RestControllerIT.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/de/juplo/demo/RestControllerIT.java b/src/test/java/de/juplo/demo/RestControllerIT.java index 1e4e0ad..0334b04 100644 --- a/src/test/java/de/juplo/demo/RestControllerIT.java +++ b/src/test/java/de/juplo/demo/RestControllerIT.java @@ -45,4 +45,22 @@ public class RestControllerIT .expectBody(String.class).isEqualTo("bar"); verify(service).getRemoteText("foo"); } + + @DisplayName("Mappings for RestController without a parameter") + @ParameterizedTest(name = "{arguments} ==> uri={0}") + @ValueSource(strings = { "/", "", "?foo=bar", "/?foo=bar"}) + void testUriWithoutParameter(String uri) + { + webClient + .get() + .uri(uri) + .header("Accept", MediaType.TEXT_PLAIN_VALUE) + .exchange() + .expectStatus().isBadRequest() + .expectBody() + .jsonPath("status").isEqualTo(400) + .jsonPath("error").isEqualTo("Bad Request") + .jsonPath("message").isEqualTo("Required String parameter 'path' is not present") + .jsonPath("timestamp").exists(); + } } -- 2.20.1