use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterLinkTest method createReconfigureRouterLink_explicitRouter.
@Test
public void createReconfigureRouterLink_explicitRouter() {
Router router = new Router();
router.reconfigure(c -> c.setRoute("show/{bar}", TestView.class));
RouterLink link = new RouterLink(router, "Show something", TestView.class, "something");
link.setRoute(router, TestView.class, "other");
Assert.assertEquals("show/other", link.getElement().getAttribute("href"));
link.setRoute(router, TestView.class, "changed");
Assert.assertEquals("show/changed", link.getElement().getAttribute("href"));
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterLinkTest method buildEmptyUrlWithRouter.
@Test
public void buildEmptyUrlWithRouter() {
Router router = new Router();
router.reconfigure(c -> c.setRoute("", TestView.class));
String url = RouterLink.buildUrl(router, TestView.class);
Assert.assertEquals("", url);
RouterLink link = new RouterLink(router, "Home", TestView.class);
Assert.assertEquals("", link.getHref());
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterLinkTest method testFailForWrongImplementation.
@Test
public void testFailForWrongImplementation() throws InvalidRouteConfigurationException {
registry.setNavigationTargets(Stream.of(FaultySetup.class).collect(Collectors.toSet()));
com.vaadin.flow.router.Router router = new com.vaadin.flow.router.Router(registry);
VaadinService service = Mockito.mock(VaadinService.class);
Mockito.when(service.getRouter()).thenReturn(router);
CurrentInstance.set(VaadinService.class, service);
expectedEx.expect(RuntimeException.class);
expectedEx.expectMessage("Only navigation targets for old Router should implement 'View'. Remove 'implements View' from '" + FaultySetup.class.getName() + "'");
RouterLink faulty = new RouterLink("Faulty", FaultySetup.class);
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterLinkTest method buildUrlWithRouter_multipleRoutes.
@Test(expected = IllegalArgumentException.class)
public void buildUrlWithRouter_multipleRoutes() {
Router router = new Router();
router.reconfigure(c -> {
c.setRoute("foo/{bar}", TestView.class);
c.setRoute("another/route", TestView.class);
});
RouterLink.buildUrl(router, TestView.class, "asdf");
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterLinkTest method buildUrlWithRouter_noRoutes.
@Test(expected = IllegalArgumentException.class)
public void buildUrlWithRouter_noRoutes() {
Router router = new Router();
RouterLink.buildUrl(router, TestView.class, "asdf");
}
Aggregations