use of com.vaadin.flow.router.internal.AfterNavigationHandler in project flow by vaadin.
the class VaadinRouteScopeTest method navigateTo.
private void navigateTo(UI ui, Component component) {
AfterNavigationEvent event = Mockito.mock(AfterNavigationEvent.class);
Mockito.when(event.getActiveChain()).thenReturn(Collections.singletonList(component));
List<AfterNavigationHandler> navigationListeners = ui.getNavigationListeners(AfterNavigationHandler.class);
navigationListeners.forEach(listener -> listener.afterNavigation(event));
}
use of com.vaadin.flow.router.internal.AfterNavigationHandler in project flow by vaadin.
the class UITest method after_navigation_listener_priority_should_dictate_sort_order.
@Test
public void after_navigation_listener_priority_should_dictate_sort_order() throws InvalidRouteConfigurationException {
UI ui = createTestUI();
initUI(ui, "", null);
ui.addAfterNavigationListener(new AfterNavigationListenerThird());
ui.addAfterNavigationListener(new AfterNavigationListenerThird());
ui.addAfterNavigationListener(new AfterNavigationListenerFirst());
ui.addAfterNavigationListener(new AfterNavigationListenerSecond());
final List<AfterNavigationHandler> AfterNavigationListeners = ui.getNavigationListeners(AfterNavigationHandler.class);
assertEquals(4, AfterNavigationListeners.size());
assertTrue(AfterNavigationListeners.get(0) instanceof AfterNavigationListenerFirst);
assertTrue(AfterNavigationListeners.get(1) instanceof AfterNavigationListenerSecond);
assertTrue(AfterNavigationListeners.get(2) instanceof AfterNavigationListenerThird);
assertTrue(AfterNavigationListeners.get(3) instanceof AfterNavigationListenerThird);
}
Aggregations