demos/testing
3 years agoFurther refined the example: Simplified the setup
Kai Moritz [Sun, 27 Sep 2020 09:23:03 +0000 (11:23 +0200)]
Further refined the example: Simplified the setup

* Goal: Do not rely on knowledge about Thymeleaf
* Goal: Separate MVC (controller) from business logic (service)
* Introduced an ExampleService
* The service checks the answer for
  The Ultimate Question Of Life, The Universe And Everything
* Requests without any answer are tolarated, so that the page with the
  question can be rendered
* Only numbers (Integer) are allowed as answer.
* Negative numbers are not allowed as answers: the service answers with an
  empty Optional.
* The view contains a bug, that results in a 503 for negative answers:
  Optional.get() is called, regardless of the state of the Optional

* The view renders the question, if no answer is specified (initial request!)
* If a valid request is specified, the answer and the outcome is rendered
* If an invalid request (negative number!) is specified, the view generates
  an exception, because it tries to resolve the Optional anyway

3 years agoRefined the example, to clearify the intent
Kai Moritz [Sat, 19 Sep 2020 08:24:44 +0000 (10:24 +0200)]
Refined the example, to clearify the intent

* Removed unnecessary Annotation from test
* Renamed and pimped up the example templates
* Splitted up the test in separate units
* Remapped the controller to the root of the web-context
* Switched to @WebMvcTest, to load only the controller-layer

3 years agoRenamed and repackaged the example for the blog-article
Kai Moritz [Sat, 19 Sep 2020 08:11:41 +0000 (10:11 +0200)]
Renamed and repackaged the example for the blog-article

3 years agoInitial Commit: Spring-Boot-Project, that pinns down a bug in a test-case
Kai Moritz [Sat, 19 Sep 2020 07:50:41 +0000 (09:50 +0200)]
Initial Commit: Spring-Boot-Project, that pinns down a bug in a test-case

* I stumbled accros the unexpected behaviour of Springs MockMvc in a
  test-case for one of my projects.
* This version pinned down the unexpected behaviour explicitly.