use of com.vaadin.flow.router.legacy.RouterTest.RouterTestUI in project flow by vaadin.
the class RouterLinkTest method reconfigureRouterLink_attachedLink.
@Test
public void reconfigureRouterLink_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, "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.RouterTest.RouterTestUI in project flow by vaadin.
the class RouterLinkTest method createUI.
private RouterTestUI createUI() {
RouterTestUI ui = new RouterTestUI();
VaadinService service = VaadinService.getCurrent();
Mockito.when(service.getRouter()).thenReturn(ui.getRouterInterface().get());
return ui;
}
use of com.vaadin.flow.router.legacy.RouterTest.RouterTestUI in project flow by vaadin.
the class RouterLinkTest method createReconfigureRouterLink_implicitCurrentVaadinServiceRouter.
@Test
public void createReconfigureRouterLink_implicitCurrentVaadinServiceRouter() {
// This method sets mock VaadinService instance which returns
// Router from the UI.
RouterTestUI ui = createUI();
ui.getRouterInterface().get().reconfigure(c -> c.setRoute("show/{bar}", TestView.class));
RouterLink link = new RouterLink("Show something", TestView.class, "something");
link.setRoute(TestView.class, "other");
Assert.assertEquals("show/other", link.getElement().getAttribute("href"));
link.setRoute(TestView.class, "changed");
Assert.assertEquals("show/changed", link.getElement().getAttribute("href"));
}
Aggregations