use of cn.taketoday.web.view.ModelAndView in project today-framework by TAKETODAY.
the class UrlFilenameViewControllerTests method multiLevelMappingWithFallback.
@PathPatternsParameterizedTest
void multiLevelMappingWithFallback(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
RequestContext request = requestFactory.apply("/docs/cvs/commit.html");
exposePathInMapping(request, "/docs/cvs/commit.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("docs/cvs/commit");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of cn.taketoday.web.view.ModelAndView in project today-framework by TAKETODAY.
the class ParameterizableViewControllerTests method handleRequestWithFlashAttributes.
@Test
public void handleRequestWithFlashAttributes() throws Exception {
this.request.setAttribute(RedirectModel.INPUT_ATTRIBUTE, new RedirectModel("name", "value"));
ModelAndView mav = this.controller.handleRequest(this.context);
assertThat(mav.getModel().size()).isEqualTo(1);
assertThat(mav.getModel().get("name")).isEqualTo("value");
}
use of cn.taketoday.web.view.ModelAndView in project today-framework by TAKETODAY.
the class ParameterizableViewControllerTests method redirectView.
@Test
public void redirectView() throws Exception {
RedirectView view = new RedirectView("/foo");
this.controller.setView(view);
ModelAndView modelAndView = this.controller.handleRequest(this.context);
assertThat(modelAndView.getView()).isSameAs(view);
}
use of cn.taketoday.web.view.ModelAndView in project today-framework by TAKETODAY.
the class ParameterizableViewControllerTests method redirectStatusWithRedirectPrefix.
@Test
public void redirectStatusWithRedirectPrefix() throws Exception {
this.controller.setStatusCode(HttpStatus.PERMANENT_REDIRECT);
this.controller.setViewName("redirect:/foo");
ModelAndView modelAndView = this.controller.handleRequest(this.context);
assertThat(modelAndView.getViewName()).isEqualTo("redirect:/foo");
assertThat(this.response.getStatus()).as("3xx status should be left to RedirectView to set").isEqualTo(200);
assertThat(this.request.getAttribute(View.RESPONSE_STATUS_ATTRIBUTE)).isEqualTo(HttpStatus.PERMANENT_REDIRECT);
}
use of cn.taketoday.web.view.ModelAndView in project today-framework by TAKETODAY.
the class UrlFilenameViewControllerTests method withSuffix.
@PathPatternsParameterizedTest
void withSuffix(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
controller.setSuffix("_mysuf");
RequestContext request = requestFactory.apply("/index.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("index_mysuf");
assertThat(mv.getModel().isEmpty()).isTrue();
}
Aggregations