* Added a test to MappingIT, that defines the expected behavior
* Fixed the behavior in HtmlController accordingly
@GetMapping("/")
- public String fetch(Model model, @RequestParam String path)
+ public String fetch(Model model, @RequestParam(required = false) String path)
{
model.addAttribute(
"text",
- service
- .getRemoteText(path)
- .onErrorResume(t -> Mono.just(t.getMessage())));
+ path == null
+ ? ""
+ : service
+ .getRemoteText(path)
+ .onErrorResume(t -> Mono.just(t.getMessage())));
return "home";
}
}
});
verify(service).getRemoteText("foo");
}
+
+ @Test
+ @DisplayName("Mapping for HtmlController: /")
+ void testUriWithoutParameter()
+ {
+ webClient
+ .get()
+ .uri("/")
+ .exchange()
+ .expectStatus().isOk()
+ .expectBody(String.class).value(rendered ->
+ {
+ Document doc = Jsoup.parse(rendered);
+ assertThat(
+ doc
+ .select("html > body > main > div > div > div > pre")
+ .isEmpty())
+ .isFalse();
+ assertThat(
+ doc
+ .select("html > body > main > div > div > div > pre")
+ .text())
+ .isEmpty();
+ });
+ }
}