use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterLinkTest method invalidRoute_attachedLink.
@Test(expected = IllegalArgumentException.class)
public void invalidRoute_attachedLink() {
Router router = new Router();
RouterTestUI ui = new RouterTestUI(router);
router.reconfigure(c -> c.setRoute("show/{bar}", TestView.class));
RouterLink link = new RouterLink();
ui.add(link);
link.setRoute(TestView.class);
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterLinkTest method invalidRoute_explicitRouter.
@Test(expected = IllegalArgumentException.class)
public void invalidRoute_explicitRouter() {
Router router = new Router();
router.reconfigure(c -> c.setRoute("show/{bar}", TestView.class));
new RouterLink(router, "Show something", TestView.class);
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterLinkTest method setRoute_attachedLink.
@Test
public void setRoute_attachedLink() {
RouterTestUI ui = new RouterTestUI(new Router());
ui.getRouterInterface().get().reconfigure(c -> c.setRoute("show/{bar}", TestView.class));
RouterLink link = new RouterLink();
ui.add(link);
link.setRoute(TestView.class, "foo");
Assert.assertTrue(link.getElement().hasAttribute("href"));
Assert.assertEquals("show/foo", link.getElement().getAttribute("href"));
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterConfigurationTest method getRoute.
@Test
public void getRoute() {
Router router = new Router();
router.reconfigure(conf -> {
conf.setRoute("route1", TestView.class, ParentView.class);
conf.setRoute("route2", AnotherTestView.class);
});
assertRoute(router, TestView.class, "route1");
assertRoute(router, AnotherTestView.class, "route2");
assertRoute(router, ParentView.class, null);
}
use of com.vaadin.flow.router.legacy.Router in project flow by vaadin.
the class RouterConfigurationTest method normalViewStatusCode.
@Test
public void normalViewStatusCode() {
Router router = new Router();
router.reconfigure(c -> c.setRoute("*", ParentView.class));
int statusCode = router.getConfiguration().resolveRoute(new Location("")).get().handle(new NavigationEvent(router, new Location(""), new UI(), NavigationTrigger.PROGRAMMATIC));
Assert.assertEquals(HttpServletResponse.SC_OK, statusCode);
}
Aggregations