Search in sources :

Example 26 with Router

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

the class RouterLinkTest method buildUrlWithRouter.

@Test
public void buildUrlWithRouter() {
    Router router = new Router();
    router.reconfigure(c -> c.setRoute("foo/{bar}", TestView.class));
    String url = RouterLink.buildUrl(router, TestView.class, "asdf");
    Assert.assertEquals("foo/asdf", url);
}
Also used : TestView(com.vaadin.flow.router.legacy.ViewRendererTest.TestView) Router(com.vaadin.flow.router.legacy.Router) Test(org.junit.Test)

Example 27 with Router

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

the class RouterConfigurationTest method testDefaultErrorView.

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

Example 28 with Router

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

the class RouterConfigurationTest method getRoutesMultipleMappings.

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

Example 29 with Router

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

the class RouterConfigurationTest method getRoutesNoMapping.

@Test
public void getRoutesNoMapping() {
    Router router = new Router();
    assertRoutes(router, TestView.class);
}
Also used : Router(com.vaadin.flow.router.legacy.Router) Test(org.junit.Test)

Example 30 with Router

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

the class RouterConfigurationTest method testParentViewsWithParent.

@Test
public void testParentViewsWithParent() {
    UI ui = new UI();
    Router router = new Router();
    router.reconfigure(conf -> {
        conf.setRoute("route", TestView.class, ParentView.class);
        conf.setParentView(ParentView.class, AnotherParentView.class);
    });
    router.navigate(ui, new Location("route"), NavigationTrigger.PROGRAMMATIC);
    Assert.assertEquals(ParentView.class, router.getConfiguration().getParentView(TestView.class).get());
    Assert.assertEquals(AnotherParentView.class, router.getConfiguration().getParentView(ParentView.class).get());
    Assert.assertEquals(Arrays.asList(TestView.class, ParentView.class, AnotherParentView.class), getViewChainTypes(ui));
}
Also used : AnotherParentView(com.vaadin.flow.router.legacy.ViewRendererTest.AnotherParentView) ParentView(com.vaadin.flow.router.legacy.ViewRendererTest.ParentView) UI(com.vaadin.flow.component.UI) AnotherParentView(com.vaadin.flow.router.legacy.ViewRendererTest.AnotherParentView) TestView(com.vaadin.flow.router.legacy.ViewRendererTest.TestView) AnotherTestView(com.vaadin.flow.router.legacy.ViewRendererTest.AnotherTestView) Router(com.vaadin.flow.router.legacy.Router) Location(com.vaadin.flow.router.Location) 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