Search in sources :

Example 1 with ParameterizableViewController

use of cn.taketoday.web.handler.mvc.ParameterizableViewController in project today-framework by TAKETODAY.

the class ViewControllerRegistryTests method addViewController.

@Test
public void addViewController() {
    this.registry.addViewController("/path").setViewName("viewName");
    ParameterizableViewController controller = getController("/path");
    assertThat(controller.getViewName()).isEqualTo("viewName");
    assertThat(controller.getStatusCode()).isNull();
    assertThat(controller.isStatusOnly()).isFalse();
    assertThat(controller.getApplicationContext()).isNotNull();
}
Also used : ParameterizableViewController(cn.taketoday.web.handler.mvc.ParameterizableViewController) Test(org.junit.jupiter.api.Test)

Example 2 with ParameterizableViewController

use of cn.taketoday.web.handler.mvc.ParameterizableViewController in project today-framework by TAKETODAY.

the class ViewControllerRegistryTests method addStatusController.

@Test
public void addStatusController() {
    this.registry.addStatusController("/path", HttpStatus.NOT_FOUND);
    ParameterizableViewController controller = getController("/path");
    assertThat(controller.getViewName()).isNull();
    assertThat(controller.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
    assertThat(controller.isStatusOnly()).isTrue();
    assertThat(controller.getApplicationContext()).isNotNull();
}
Also used : ParameterizableViewController(cn.taketoday.web.handler.mvc.ParameterizableViewController) Test(org.junit.jupiter.api.Test)

Example 3 with ParameterizableViewController

use of cn.taketoday.web.handler.mvc.ParameterizableViewController in project today-framework by TAKETODAY.

the class ViewControllerRegistryTests method getController.

private ParameterizableViewController getController(String path) {
    Map<String, ?> urlMap = this.registry.buildHandlerMapping().getUrlMap();
    ParameterizableViewController controller = (ParameterizableViewController) urlMap.get(path);
    assertThat(controller).isNotNull();
    return controller;
}
Also used : ParameterizableViewController(cn.taketoday.web.handler.mvc.ParameterizableViewController)

Example 4 with ParameterizableViewController

use of cn.taketoday.web.handler.mvc.ParameterizableViewController in project today-framework by TAKETODAY.

the class ViewControllerRegistryTests method addViewControllerWithDefaultViewName.

@Test
public void addViewControllerWithDefaultViewName() {
    this.registry.addViewController("/path");
    ParameterizableViewController controller = getController("/path");
    assertThat(controller.getViewName()).isNull();
    assertThat(controller.getStatusCode()).isNull();
    assertThat(controller.isStatusOnly()).isFalse();
    assertThat(controller.getApplicationContext()).isNotNull();
}
Also used : ParameterizableViewController(cn.taketoday.web.handler.mvc.ParameterizableViewController) Test(org.junit.jupiter.api.Test)

Example 5 with ParameterizableViewController

use of cn.taketoday.web.handler.mvc.ParameterizableViewController in project today-framework by TAKETODAY.

the class ViewControllerRegistryTests method getRedirectView.

private RedirectView getRedirectView(String path) {
    ParameterizableViewController controller = getController(path);
    assertThat(controller.getViewName()).isNull();
    assertThat(controller.getView()).isNotNull();
    assertThat(controller.getView().getClass()).isEqualTo(RedirectView.class);
    return (RedirectView) controller.getView();
}
Also used : ParameterizableViewController(cn.taketoday.web.handler.mvc.ParameterizableViewController) RedirectView(cn.taketoday.web.view.RedirectView)

Aggregations

ParameterizableViewController (cn.taketoday.web.handler.mvc.ParameterizableViewController)5 Test (org.junit.jupiter.api.Test)3 RedirectView (cn.taketoday.web.view.RedirectView)1