Verified, that requests to the RestController without "path" are invalid
authorKai Moritz <kai@juplo.de>
Tue, 14 Jan 2020 19:04:27 +0000 (20:04 +0100)
committerKai Moritz <kai@juplo.de>
Thu, 16 Jan 2020 10:18:03 +0000 (11:18 +0100)
src/test/java/de/juplo/demo/RestControllerIT.java

index 1e4e0ad..0334b04 100644 (file)
@@ -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();
+  }
 }