Search in sources :

Example 1 with RoutePathProviderImpl

use of com.vaadin.flow.server.MockVaadinContext.RoutePathProviderImpl in project flow by vaadin.

the class UidlWriterTest method initializeUIForDependenciesTest.

private UI initializeUIForDependenciesTest(UI ui) throws Exception {
    mocks = new MockServletServiceSessionSetup();
    VaadinServletContext context = (VaadinServletContext) mocks.getService().getContext();
    Lookup lookup = context.getAttribute(Lookup.class);
    Mockito.when(lookup.lookup(RoutePathProvider.class)).thenReturn(new RoutePathProviderImpl());
    VaadinSession session = mocks.getSession();
    session.lock();
    ui.getInternals().setSession(session);
    RouteConfiguration routeConfiguration = RouteConfiguration.forRegistry(ui.getInternals().getRouter().getRegistry());
    routeConfiguration.update(() -> {
        routeConfiguration.getHandledRegistry().clean();
        routeConfiguration.setAnnotatedRoute(BaseClass.class);
    });
    for (String type : new String[] { "html", "js", "css" }) {
        mocks.getServlet().addServletContextResource("inline." + type, "inline." + type);
    }
    HttpServletRequest servletRequestMock = mock(HttpServletRequest.class);
    VaadinServletRequest vaadinRequestMock = mock(VaadinServletRequest.class);
    when(vaadinRequestMock.getHttpServletRequest()).thenReturn(servletRequestMock);
    ui.doInit(vaadinRequestMock, 1);
    ui.getInternals().getRouter().initializeUI(ui, BootstrapHandlerTest.requestToLocation(vaadinRequestMock));
    return ui;
}
Also used : VaadinServletContext(com.vaadin.flow.server.VaadinServletContext) HttpServletRequest(javax.servlet.http.HttpServletRequest) VaadinSession(com.vaadin.flow.server.VaadinSession) RouteConfiguration(com.vaadin.flow.router.RouteConfiguration) VaadinServletRequest(com.vaadin.flow.server.VaadinServletRequest) RoutePathProviderImpl(com.vaadin.flow.server.MockVaadinContext.RoutePathProviderImpl) Lookup(com.vaadin.flow.di.Lookup) MockServletServiceSessionSetup(com.vaadin.flow.server.MockServletServiceSessionSetup)

Aggregations

Lookup (com.vaadin.flow.di.Lookup)1 RouteConfiguration (com.vaadin.flow.router.RouteConfiguration)1 MockServletServiceSessionSetup (com.vaadin.flow.server.MockServletServiceSessionSetup)1 RoutePathProviderImpl (com.vaadin.flow.server.MockVaadinContext.RoutePathProviderImpl)1 VaadinServletContext (com.vaadin.flow.server.VaadinServletContext)1 VaadinServletRequest (com.vaadin.flow.server.VaadinServletRequest)1 VaadinSession (com.vaadin.flow.server.VaadinSession)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1