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;
}
Aggregations