use of com.vaadin.flow.server.RouteRegistry in project flow by vaadin.
the class RouteNotFoundErrorTest method setErrorParameter_productionMode_pathContainRoutesTemplate_renderedElementHasNoRoutes.
@Test
public void setErrorParameter_productionMode_pathContainRoutesTemplate_renderedElementHasNoRoutes() {
RouteNotFoundError page = new RouteNotFoundError();
BeforeEnterEvent event = Mockito.mock(BeforeEnterEvent.class);
Location location = Mockito.mock(Location.class);
Mockito.when(location.getPath()).thenReturn("{{routes}}");
Mockito.when(event.getLocation()).thenReturn(location);
UI ui = Mockito.mock(UI.class);
VaadinSession session = Mockito.mock(VaadinSession.class);
Mockito.when(ui.getSession()).thenReturn(session);
DeploymentConfiguration config = Mockito.mock(DeploymentConfiguration.class);
Mockito.when(session.getConfiguration()).thenReturn(config);
Mockito.when(config.isProductionMode()).thenReturn(true);
Mockito.when(event.getUI()).thenReturn(ui);
ErrorParameter<NotFoundException> param = new ErrorParameter<NotFoundException>(NotFoundException.class, new NotFoundException());
Router router = Mockito.mock(Router.class);
Mockito.when(event.getSource()).thenReturn(router);
RouteRegistry registry = Mockito.mock(RouteRegistry.class);
Mockito.when(router.getRegistry()).thenReturn(registry);
RouteData data = new RouteData(Collections.emptyList(), "bar", Collections.emptyList(), RouteTarget.class, Collections.emptyList());
Mockito.when(registry.getRegisteredRoutes()).thenReturn(Collections.singletonList(data));
event.getSource().getRegistry().getRegisteredRoutes();
page.setErrorParameter(event, param);
MatcherAssert.assertThat(page.getElement().toString(), CoreMatchers.not(CoreMatchers.containsString("bar")));
}
use of com.vaadin.flow.server.RouteRegistry in project flow by vaadin.
the class RouteConfigurationTest method mockRegistry.
private RouteRegistry mockRegistry() {
RouteRegistry registry = Mockito.mock(RouteRegistry.class);
VaadinContext context = new MockVaadinContext();
Mockito.when(registry.getContext()).thenReturn(context);
return registry;
}
use of com.vaadin.flow.server.RouteRegistry in project flow by vaadin.
the class RequestUtilTest method setupMockServlet.
private SpringServlet setupMockServlet() {
SpringServlet servlet = Mockito.mock(SpringServlet.class);
SpringVaadinServletService service = Mockito.mock(SpringVaadinServletService.class);
Router router = Mockito.mock(Router.class);
RouteRegistry routeRegistry = Mockito.mock(RouteRegistry.class);
Mockito.when(springServletRegistration.getServlet()).thenReturn(servlet);
Mockito.when(servlet.getService()).thenReturn(service);
Mockito.when(service.getRouter()).thenReturn(router);
Mockito.when(router.getRegistry()).thenReturn(routeRegistry);
return servlet;
}
Aggregations