Search in sources :

Example 6 with Router

use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.

the class RouterConfigurationTest method testSetErrorView_nullParentView_throws.

@Test(expected = IllegalArgumentException.class)
public void testSetErrorView_nullParentView_throws() {
    Router router = new Router();
    router.reconfigure(conf -> conf.setErrorView(TestView.class, null));
}
Also used : TestView(com.vaadin.flow.router.legacy.ViewRendererTest.TestView) AnotherTestView(com.vaadin.flow.router.legacy.ViewRendererTest.AnotherTestView) Router(com.vaadin.flow.router.legacy.Router) Test(org.junit.Test)

Example 7 with Router

use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.

the class RouterConfigurationTest method customErrorViewStatusCode.

@Test
public void customErrorViewStatusCode() {
    Router router = new Router();
    router.reconfigure(c -> {
        c.setErrorView(ParentView.class);
    });
    int statusCode = router.getConfiguration().getErrorHandler().handle(new NavigationEvent(router, new Location(""), new UI(), NavigationTrigger.PROGRAMMATIC));
    Assert.assertEquals(HttpServletResponse.SC_NOT_FOUND, statusCode);
}
Also used : NavigationEvent(com.vaadin.flow.router.NavigationEvent) UI(com.vaadin.flow.component.UI) Router(com.vaadin.flow.router.legacy.Router) Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 8 with Router

use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.

the class RouterConfigurationTest method testSetNullPageTitleGenerator.

@Test(expected = IllegalArgumentException.class)
public void testSetNullPageTitleGenerator() {
    Router router = new Router();
    router.reconfigure(conf -> {
        conf.setPageTitleGenerator(null);
    });
}
Also used : Router(com.vaadin.flow.router.legacy.Router) Test(org.junit.Test)

Example 9 with Router

use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.

the class RouterConfigurationTest method getRouteMultipleMappings.

@Test(expected = IllegalArgumentException.class)
public void getRouteMultipleMappings() {
    Router router = new Router();
    router.reconfigure(conf -> {
        conf.setRoute("route1", TestView.class);
        conf.setRoute("route2", TestView.class);
    });
    assertRoute(router, TestView.class, "Should throw exception");
}
Also used : Router(com.vaadin.flow.router.legacy.Router) Test(org.junit.Test)

Example 10 with Router

use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.

the class RouterConfigurationTest method getRoutesAfterRemoved.

@Test
public void getRoutesAfterRemoved() {
    Router router = new Router();
    router.reconfigure(conf -> {
        conf.setRoute("route1", TestView.class);
        conf.setRoute("route2", AnotherTestView.class);
    });
    router.reconfigure(conf -> {
        conf.removeRoute("route1");
    });
    assertRoutes(router, TestView.class);
    assertRoutes(router, AnotherTestView.class, "route2");
}
Also used : Router(com.vaadin.flow.router.legacy.Router) Test(org.junit.Test)

Aggregations

Router (com.vaadin.flow.router.legacy.Router)44 Test (org.junit.Test)44 Location (com.vaadin.flow.router.Location)17 TestView (com.vaadin.flow.router.legacy.ViewRendererTest.TestView)16 UI (com.vaadin.flow.component.UI)15 NavigationEvent (com.vaadin.flow.router.NavigationEvent)8 DefaultErrorView (com.vaadin.flow.router.legacy.DefaultErrorView)7 VaadinRequest (com.vaadin.flow.server.VaadinRequest)7 HistoryStateChangeEvent (com.vaadin.flow.component.page.History.HistoryStateChangeEvent)6 ImmutableRouterConfiguration (com.vaadin.flow.router.legacy.ImmutableRouterConfiguration)6 RouterConfiguration (com.vaadin.flow.router.legacy.RouterConfiguration)6 ErrorView (com.vaadin.flow.router.legacy.ViewRendererTest.ErrorView)6 VaadinResponse (com.vaadin.flow.server.VaadinResponse)6 VaadinService (com.vaadin.flow.server.VaadinService)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 CurrentInstance (com.vaadin.flow.internal.CurrentInstance)5 NavigationHandler (com.vaadin.flow.router.NavigationHandler)5 NavigationTrigger (com.vaadin.flow.router.NavigationTrigger)5 RouterInterface (com.vaadin.flow.router.RouterInterface)5 Resolver (com.vaadin.flow.router.legacy.Resolver)5