From: Kai Moritz Date: Tue, 14 Jan 2020 17:56:15 +0000 (+0100) Subject: The parameter "path" is added to the model X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=62335040daa75af91c4bd87602c9a09dc2a8c5ce;p=demos%2Ftesting The parameter "path" is added to the model * Modified HtmlControllerTest to verify the new behavior * Fixed the behavior of the HtmlController accordingly * Added a form to the example-layout --- diff --git a/src/main/java/de/juplo/demo/HtmlController.java b/src/main/java/de/juplo/demo/HtmlController.java index ec5919c..92ed7ff 100644 --- a/src/main/java/de/juplo/demo/HtmlController.java +++ b/src/main/java/de/juplo/demo/HtmlController.java @@ -27,6 +27,7 @@ public class HtmlController @GetMapping({ "", "/" }) public String fetch(Model model, @RequestParam(required = false) String path) { + model.addAttribute("path", path); model.addAttribute( "text", path == null diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html index 6076f98..c36c5ef 100644 --- a/src/main/resources/templates/home.html +++ b/src/main/resources/templates/home.html @@ -9,5 +9,14 @@
TEXT
+
+
+
+ + +
+ +
+
diff --git a/src/test/java/de/juplo/demo/HtmlControllerTest.java b/src/test/java/de/juplo/demo/HtmlControllerTest.java index 0aa7f13..96ac20a 100644 --- a/src/test/java/de/juplo/demo/HtmlControllerTest.java +++ b/src/test/java/de/juplo/demo/HtmlControllerTest.java @@ -53,6 +53,7 @@ public class HtmlControllerTest assertThat(result).isEqualTo("home"); ArgumentCaptor> captor = ArgumentCaptor.forClass(Mono.class); + verify(model).addAttribute("path", "foo"); verify(model).addAttribute(eq("text"), captor.capture()); StepVerifier .create(captor.getValue()) @@ -72,6 +73,7 @@ public class HtmlControllerTest assertThat(result).isEqualTo("home"); ArgumentCaptor> captor = ArgumentCaptor.forClass(Mono.class); + verify(model).addAttribute("path", "foo"); verify(model).addAttribute(eq("text"), captor.capture()); StepVerifier .create(captor.getValue())