use of com.vaadin.flow.router.RoutePathProvider in project flow by vaadin.
the class LookupServletContainerInitializerTest method processLookupServletContainerInitializer_routePathProviderIsProvidedAsScannedClass_lookupReturnsTheProviderInstance.
@Test
public void processLookupServletContainerInitializer_routePathProviderIsProvidedAsScannedClass_lookupReturnsTheProviderInstance() throws ServletException {
Lookup lookup = mockLookup(TestRoutePathProvider.class);
RoutePathProvider handler = lookup.lookup(RoutePathProvider.class);
Assert.assertNotNull(handler);
Assert.assertEquals(TestRoutePathProvider.class, handler.getClass());
Collection<RoutePathProvider> allHandlers = lookup.lookupAll(RoutePathProvider.class);
Assert.assertEquals(1, allHandlers.size());
Assert.assertEquals(TestRoutePathProvider.class, allHandlers.iterator().next().getClass());
}
use of com.vaadin.flow.router.RoutePathProvider in project flow by vaadin.
the class RouteUtil method resolve.
/**
* Gets the effective route path value of the annotated class.
*
* @param context
* a Vaadin contexxt
* @param component
* the component where the route points to
* @return The value of the annotation or naming convention based value if
* no explicit value is given.
*/
public static String resolve(VaadinContext context, Class<?> component) {
Lookup lookup = context.getAttribute(Lookup.class);
RoutePathProvider provider = lookup.lookup(RoutePathProvider.class);
assert provider != null;
return provider.getRoutePath(component);
}
Aggregations