use of com.vaadin.flow.server.MockVaadinServletService in project flow by vaadin.
the class NavigationStateRendererTest method instantiatorUse.
@Test
public void instantiatorUse() throws ServiceException {
MockVaadinServletService service = new MockVaadinServletService();
service.init(new MockInstantiator() {
@Override
public <T extends HasElement> T createRouteTarget(Class<T> routeTargetType, NavigationEvent event) {
Assert.assertEquals(Component.class, routeTargetType);
return (T) new Text("foo");
}
});
MockUI ui = new MockUI(new MockVaadinSession(service));
NavigationEvent event = new NavigationEvent(new Router(new TestRouteRegistry()), new Location(""), ui, NavigationTrigger.PAGE_LOAD);
NavigationStateRenderer renderer = new NavigationStateRenderer(navigationStateFromTarget(ChildConfiguration.class));
Component routeTarget = renderer.getRouteTarget(Component.class, event);
Assert.assertEquals(Text.class, routeTarget.getClass());
UI.setCurrent(null);
}
Aggregations