UI extends Component implements PollNotifier, HasComponents, RouterLayout { public SerializableRunnable accessLater(SerializableRunnable accessTask, SerializableRunnable detachHandler) { Objects.requireNonNull(accessTask, "Access task cannot be null"); return () -> access(accessTask::run, detachHandler); } UI(); protected  UI(UIInternalUpdater internalsHandler); VaadinSession getSession(); int getUIId(); void doInit(VaadinRequest request, int uiId); static void setCurrent(UI ui); static UI getCurrent(); void close(); boolean isClosing(); void accessSynchronously(Command command); Future<Void> access(final Command command); SerializableRunnable accessLater(SerializableRunnable accessTask,
            SerializableRunnable detachHandler); SerializableConsumer<T> accessLater(
            SerializableConsumer<T> accessTask,
            SerializableRunnable detachHandler); void setPollInterval(int intervalInMillis); int getPollInterval(); LoadingIndicatorConfiguration getLoadingIndicatorConfiguration(); void push(); PushConfiguration getPushConfiguration(); ReconnectDialogConfiguration getReconnectDialogConfiguration(); @Override Locale getLocale(); void setLocale(Locale locale); void setDirection(Direction direction); @Override Element getElement(); UIInternals getInternals(); Page getPage(); void navigate(Class<? extends Component> navigationTarget); void navigate(
            Class<? extends C> navigationTarget, T parameter); void navigate(Class<? extends Component> navigationTarget,
            RouteParameters parameters); void navigate(String location); void navigate(String location, QueryParameters queryParameters); boolean isNavigationSupported(); @Deprecated Router getRouter(); ExecutionRegistration beforeClientResponse(Component component,
            SerializableConsumer<ExecutionContext> execution); @Override void add(Component... components); @Override Optional<UI> getUI(); Registration addBeforeEnterListener(BeforeEnterListener listener); Registration addBeforeLeaveListener(BeforeLeaveListener listener); Registration addAfterNavigationListener(
            AfterNavigationListener listener); List<E> getNavigationListeners(Class<E> navigationHandler); ShortcutRegistration addShortcutListener(Command command, Key key,
            KeyModifier... keyModifiers); ShortcutRegistration addShortcutListener(
            ShortcutEventListener listener, Key key,
            KeyModifier... keyModifiers); Component getActiveDragSourceComponent(); String getCsrfToken();  }
@Test(expected = NullPointerException.class) public void accessLaterRunnable_nullHandler_exception() { UI ui = createAccessableTestUI(); ui.accessLater((SerializableRunnable) null, () -> { }); }
@Test(expected = UIDetachedException.class) public void accessLaterRunnable_detachedUiNoHandler_throws() { UI ui = createTestUI(); SerializableRunnable wrapped = ui.accessLater( () -> Assert.fail("Action should never run"), null); wrapped.run(); }
@Test public void accessLaterRunnable_detachedUi_detachHandlerCalled() { AtomicInteger runCount = new AtomicInteger(); UI ui = createTestUI(); SerializableRunnable wrapped = ui.accessLater( () -> Assert.fail("Action should never run"), runCount::incrementAndGet); assertEquals("Handler should not yet have run", 0, runCount.get()); wrapped.run(); assertEquals("Handler should have run once", 1, runCount.get()); }
@Test(expected = NullPointerException.class) public void accessLaterConsumer_nullHandler_exception() { UI ui = createAccessableTestUI(); ui.accessLater((SerializableConsumer<Object>) null, () -> { }); }
@Test(expected = UIDetachedException.class) public void accessLaterConsumer_detachedUiNoHandler_throws() { UI ui = createTestUI(); SerializableConsumer<Object> wrapped = ui.accessLater( value -> Assert.fail("Action should never run"), null); wrapped.accept(null); }
@Test public void accessLaterConsumer_detachedUi_detachHandlerCalled() { AtomicInteger runCount = new AtomicInteger(); UI ui = createTestUI(); SerializableConsumer<Object> wrapped = ui.accessLater( value -> Assert.fail("Action should never run"), runCount::incrementAndGet); assertEquals("Handler should not yet have run", 0, runCount.get()); wrapped.accept(null); assertEquals("Handler should have run once", 1, runCount.get()); }