use of cn.taketoday.web.view.ModelAndView in project today-infrastructure by TAKETODAY.
the class ControllerTests method parameterizableViewController.
@Test
public void parameterizableViewController() throws Exception {
String viewName = "viewName";
ParameterizableViewController pvc = new ParameterizableViewController();
pvc.setViewName(viewName);
// We don't care about the params.
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.refresh();
ServletRequestContext context = new ServletRequestContext(wac, new MockHttpServletRequest("GET", "foo.html"), new MockHttpServletResponse());
ModelAndView mv = pvc.handleRequest(context);
assertThat(mv.getModel().size() == 0).as("model has no data").isTrue();
assertThat(mv.getViewName().equals(viewName)).as("model has correct viewname").isTrue();
assertThat(pvc.getViewName().equals(viewName)).as("getViewName matches").isTrue();
}
use of cn.taketoday.web.view.ModelAndView in project today-infrastructure by TAKETODAY.
the class UrlFilenameViewControllerTests method withPrefix.
@PathPatternsParameterizedTest
void withPrefix(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
controller.setPrefix("mypre_");
RequestContext request = requestFactory.apply("/index.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("mypre_index");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of cn.taketoday.web.view.ModelAndView in project today-infrastructure by TAKETODAY.
the class UrlFilenameViewControllerTests method withPrefixAndSuffix.
@PathPatternsParameterizedTest
void withPrefixAndSuffix(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
controller.setPrefix("mypre_");
controller.setSuffix("_mysuf");
RequestContext request = requestFactory.apply("/index.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("mypre_index_mysuf");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of cn.taketoday.web.view.ModelAndView in project today-infrastructure by TAKETODAY.
the class UrlFilenameViewControllerTests method withFilenamePlusExtension.
@PathPatternsParameterizedTest
void withFilenamePlusExtension(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
RequestContext request = requestFactory.apply("/index.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("index");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of cn.taketoday.web.view.ModelAndView in project today-infrastructure by TAKETODAY.
the class UrlFilenameViewControllerTests method multiLevelWithMapping.
@PathPatternsParameterizedTest
void multiLevelWithMapping(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
RequestContext request = requestFactory.apply("/cvs/commit.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("cvs/commit");
assertThat(mv.getModel().isEmpty()).isTrue();
}
Aggregations