@Test @DisplayName("insertMain画面に遷移する") public void insertMainTest() { Method indexMethod = assertDoesNotThrow(() -> CustomerController.class.getMethod("insertMain", Model.class)); GetMapping getMapping = indexMethod.getAnnotation(GetMapping.class); ExtendedModelMap model = new ExtendedModelMap(); String logicalViewName = customerController.insertMain(model); Object customerFormObj = model.get("customerForm"); assertAll( () -> assertNotNull(getMapping), () -> assertEquals("/insertMain", getMapping.value()[0]), () -> assertEquals("insertMain", logicalViewName), () -> assertNotNull(customerFormObj), () -> assertTrue(customerFormObj instanceof CustomerForm) ); CustomerForm customerForm = (CustomerForm) customerFormObj; assertAll( () -> assertNull(customerForm.getFirstName()), () -> assertNull(customerForm.getLastName()), () -> assertNull(customerForm.getEmail()), () -> assertNull(customerForm.getBirthday()) ); }
@GetMapping("/insertMain") public String insertMain(Model model) { model.addAttribute(CustomerForm.createEmptyForm()); return "insertMain"; }
CustomerController { @GetMapping("/insertMain") public String insertMain(Model model) { model.addAttribute(CustomerForm.createEmptyForm()); return "insertMain"; } }
CustomerController { @GetMapping("/insertMain") public String insertMain(Model model) { model.addAttribute(CustomerForm.createEmptyForm()); return "insertMain"; }  }
CustomerController { @GetMapping("/insertMain") public String insertMain(Model model) { model.addAttribute(CustomerForm.createEmptyForm()); return "insertMain"; }  String index(Model model); @GetMapping("/insertMain") String insertMain(Model model); String insertComplete(
            // Bean Validationを実行するアノテーションを付加する
               CustomerForm customerForm,
            BindingResult bindingResult); }
CustomerController { @GetMapping("/insertMain") public String insertMain(Model model) { model.addAttribute(CustomerForm.createEmptyForm()); return "insertMain"; }  String index(Model model); @GetMapping("/insertMain") String insertMain(Model model); String insertComplete(
            // Bean Validationを実行するアノテーションを付加する
               CustomerForm customerForm,
            BindingResult bindingResult);  }