Search in sources :

Example 1 with ImmutableRouterConfiguration

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

the class VaadinUIScopeTest method mockUI.

private UI mockUI() {
    VaadinSession session = mockSession();
    RouterInterface routerIface = mock(RouterInterface.class);
    VaadinService service = session.getService();
    when(service.getRouter()).thenReturn(routerIface);
    ImmutableRouterConfiguration config = mock(ImmutableRouterConfiguration.class);
    when(routerIface.getConfiguration()).thenReturn(config);
    when(config.isConfigured()).thenReturn(false);
    UI ui = new UI();
    ui.getInternals().setSession(session);
    ui.doInit(null, 1);
    UI.setCurrent(ui);
    // prevent UI from being GCed.
    this.ui = ui;
    return ui;
}
Also used : VaadinSession(com.vaadin.flow.server.VaadinSession) SpringVaadinSession(com.vaadin.flow.spring.SpringVaadinSession) UI(com.vaadin.flow.component.UI) VaadinService(com.vaadin.flow.server.VaadinService) ImmutableRouterConfiguration(com.vaadin.flow.router.legacy.ImmutableRouterConfiguration) RouterInterface(com.vaadin.flow.router.RouterInterface)

Example 2 with ImmutableRouterConfiguration

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

the class RouterTest method testConfigurationImmutable.

@Test(expected = IllegalStateException.class)
public void testConfigurationImmutable() {
    Router router = new Router();
    ImmutableRouterConfiguration configuration = router.getConfiguration();
    ((RouterConfiguration) configuration).setResolver(e -> null);
}
Also used : ImmutableRouterConfiguration(com.vaadin.flow.router.legacy.ImmutableRouterConfiguration) Router(com.vaadin.flow.router.legacy.Router) ImmutableRouterConfiguration(com.vaadin.flow.router.legacy.ImmutableRouterConfiguration) RouterConfiguration(com.vaadin.flow.router.legacy.RouterConfiguration) Test(org.junit.Test)

Aggregations

ImmutableRouterConfiguration (com.vaadin.flow.router.legacy.ImmutableRouterConfiguration)2 UI (com.vaadin.flow.component.UI)1 RouterInterface (com.vaadin.flow.router.RouterInterface)1 Router (com.vaadin.flow.router.legacy.Router)1 RouterConfiguration (com.vaadin.flow.router.legacy.RouterConfiguration)1 VaadinService (com.vaadin.flow.server.VaadinService)1 VaadinSession (com.vaadin.flow.server.VaadinSession)1 SpringVaadinSession (com.vaadin.flow.spring.SpringVaadinSession)1 Test (org.junit.Test)1