use of com.vaadin.flow.router.internal.BeforeLeaveHandler in project flow by vaadin.
the class UITest method before_Leave_listener_priority_should_dictate_sort_order.
@Test
public void before_Leave_listener_priority_should_dictate_sort_order() throws InvalidRouteConfigurationException {
UI ui = createTestUI();
initUI(ui, "", null);
ui.addBeforeLeaveListener(new BeforeLeaveListenerFirst());
ui.addBeforeLeaveListener(new BeforeLeaveListenerThird());
ui.addBeforeLeaveListener(new BeforeLeaveListenerSecond());
ui.addBeforeLeaveListener(new BeforeLeaveListenerThird());
final List<BeforeLeaveHandler> beforeLeaveListeners = ui.getNavigationListeners(BeforeLeaveHandler.class);
assertEquals(4, beforeLeaveListeners.size());
assertTrue(beforeLeaveListeners.get(0) instanceof BeforeLeaveListenerFirst);
assertTrue(beforeLeaveListeners.get(1) instanceof BeforeLeaveListenerSecond);
assertTrue(beforeLeaveListeners.get(2) instanceof BeforeLeaveListenerThird);
assertTrue(beforeLeaveListeners.get(3) instanceof BeforeLeaveListenerThird);
}
Aggregations