Search in sources :

Example 1 with RouterConfiguration

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

the class RouterConfigurationTest method routeMatches.

private static boolean routeMatches(String location, String route) {
    RouterConfiguration configuration = createConfiguration();
    configuration.setRoute(route, createNoopHandler());
    Optional<NavigationHandler> resolveRoute = configuration.resolveRoute(new Location(location));
    return resolveRoute.isPresent();
}
Also used : RouterConfiguration(com.vaadin.flow.router.legacy.RouterConfiguration) NavigationHandler(com.vaadin.flow.router.NavigationHandler) Location(com.vaadin.flow.router.Location)

Example 2 with RouterConfiguration

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

the class RouterConfigurationTest method testSetExistingWildcardThrows.

@Test(expected = IllegalStateException.class)
public void testSetExistingWildcardThrows() {
    RouterConfiguration configuration = createConfiguration();
    configuration.setRoute("foo/*", createNoopHandler());
    configuration.setRoute("foo/*", createNoopHandler());
}
Also used : RouterConfiguration(com.vaadin.flow.router.legacy.RouterConfiguration) Test(org.junit.Test)

Example 3 with RouterConfiguration

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

the class RouterConfigurationTest method testSetExistingRouteThrows.

@Test(expected = IllegalStateException.class)
public void testSetExistingRouteThrows() {
    RouterConfiguration configuration = createConfiguration();
    configuration.setRoute("foo", createNoopHandler());
    configuration.setRoute("foo", createNoopHandler());
}
Also used : RouterConfiguration(com.vaadin.flow.router.legacy.RouterConfiguration) Test(org.junit.Test)

Example 4 with RouterConfiguration

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

the class RouterConfigurationTest method testRemoveRoutes.

@Test
public void testRemoveRoutes() {
    RouterConfiguration configuration = createConfiguration();
    NavigationHandler navigationHandler = createNoopHandler();
    configuration.setRoute("foo", navigationHandler);
    configuration.setRoute("{name}", navigationHandler);
    configuration.setRoute("*", navigationHandler);
    configuration.removeRoute("foo");
    Assert.assertNotNull(configuration.resolveRoute(new Location("foo")));
    configuration.removeRoute("{otherName}");
    Assert.assertNotNull(configuration.resolveRoute(new Location("foo")));
    configuration.removeRoute("*");
    // Should resolve to empty optional only after removing all the routes
    Assert.assertFalse(configuration.resolveRoute(new Location("foo")).isPresent());
}
Also used : RouterConfiguration(com.vaadin.flow.router.legacy.RouterConfiguration) NavigationHandler(com.vaadin.flow.router.NavigationHandler) Location(com.vaadin.flow.router.Location) Test(org.junit.Test)

Example 5 with RouterConfiguration

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

the class RouterConfigurationTest method testSetParentViewTwice.

@Test
public void testSetParentViewTwice() {
    RouterConfiguration configuration = createConfiguration();
    configuration.setParentView(TestView.class, ParentView.class);
    configuration.setParentView(TestView.class, ParentView.class);
}
Also used : RouterConfiguration(com.vaadin.flow.router.legacy.RouterConfiguration) Test(org.junit.Test)

Aggregations

RouterConfiguration (com.vaadin.flow.router.legacy.RouterConfiguration)13 Test (org.junit.Test)11 Location (com.vaadin.flow.router.Location)5 NavigationHandler (com.vaadin.flow.router.NavigationHandler)4 ImmutableRouterConfiguration (com.vaadin.flow.router.legacy.ImmutableRouterConfiguration)2 Router (com.vaadin.flow.router.legacy.Router)2 UI (com.vaadin.flow.component.UI)1 HistoryStateChangeEvent (com.vaadin.flow.component.page.History.HistoryStateChangeEvent)1 CurrentInstance (com.vaadin.flow.internal.CurrentInstance)1 NavigationEvent (com.vaadin.flow.router.NavigationEvent)1 NavigationTrigger (com.vaadin.flow.router.NavigationTrigger)1 RouterInterface (com.vaadin.flow.router.RouterInterface)1 DefaultErrorView (com.vaadin.flow.router.legacy.DefaultErrorView)1 Resolver (com.vaadin.flow.router.legacy.Resolver)1 ErrorView (com.vaadin.flow.router.legacy.ViewRendererTest.ErrorView)1 TestView (com.vaadin.flow.router.legacy.ViewRendererTest.TestView)1 MockServletConfig (com.vaadin.flow.server.MockServletConfig)1 VaadinRequest (com.vaadin.flow.server.VaadinRequest)1 VaadinResponse (com.vaadin.flow.server.VaadinResponse)1 VaadinService (com.vaadin.flow.server.VaadinService)1