UIInternals implements Serializable { public void showRouteTarget(Location viewLocation, Component target, List<RouterLayout> layouts) { assert target != null; assert viewLocation != null; HasElement oldRoot = null; if (!routerTargetChain.isEmpty()) { oldRoot = routerTargetChain.get(routerTargetChain.size() - 1); } this.viewLocation = viewLocation; Map<RouterLayout, HasElement> oldChildren = new HashMap<>(); for (int i = 0; i < routerTargetChain.size() - 1; i++) { HasElement child = routerTargetChain.get(i); RouterLayout parent = (RouterLayout) routerTargetChain.get(i + 1); oldChildren.put(parent, child); } routerTargetChain = new ArrayList<>(); routerTargetChain.add(target); if (layouts != null) { routerTargetChain.addAll(layouts); } HasElement previous = null; for (HasElement current : routerTargetChain) { if (previous != null || oldChildren.containsKey(current)) { assert current instanceof RouterLayout : "All parts of the chain except the first must implement " + RouterLayout.class.getSimpleName(); HasElement oldContent = oldChildren.get(current); HasElement newContent = previous; if (oldContent != newContent) { RouterLayout layout = (RouterLayout) current; if (oldContent != null) { layout.removeRouterLayoutContent(oldContent); } layout.showRouterLayoutContent(newContent); } } previous = current; } HasElement root = previous; if (root == null) { throw new IllegalArgumentException( "Root can't be null here since we know there's at least one item in the chain"); } configurePush(root); internalsHandler.updateRoot(ui, oldRoot, root); } UIInternals(UI ui);  UIInternals(UI ui, UIInternalUpdater internalsHandler); StateTree getStateTree(); int getLastProcessedClientToServerId(); byte[] getLastProcessedMessageHash(); void setLastProcessedClientToServerId(
            int lastProcessedClientToServerId,
            byte[] lastProcessedMessageHash); int getServerSyncId(); void incrementServerId(); long getLastHeartbeatTimestamp(); void setLastHeartbeatTimestamp(long lastHeartbeat); void setSession(VaadinSession session); PushConnection getPushConnection(); void setPushConnection(PushConnection pushConnection); Registration addBeforeEnterListener(BeforeEnterListener listener); Registration addBeforeLeaveListener(BeforeLeaveListener listener); Registration addAfterNavigationListener(
            AfterNavigationListener listener); Registration addHeartbeatListener(HeartbeatListener listener); List<E> getListeners(Class<E> handler); void addJavaScriptInvocation(
            PendingJavaScriptInvocation invocation); List<PendingJavaScriptInvocation> dumpPendingJavaScriptInvocations(); void setTitle(String title); String getTitle(); boolean cancelPendingTitleUpdate(); void showRouteTarget(Location viewLocation,
            Component target, List<RouterLayout> layouts); void moveElementsFrom(UI otherUI); List<HasElement> getActiveRouterTargetsChain(); Location getActiveViewLocation(); VaadinSession getSession(); DependencyList getDependencyList(); void addComponentDependencies(
            Class<? extends Component> componentClass); ConstantPool getConstantPool(); Location getLastHandledLocation(); void setLastHandledNavigation(Location location); boolean hasLastHandledLocation(); void clearLastHandledNavigation(); ContinueNavigationAction getContinueNavigationAction(); void setContinueNavigationAction(
            ContinueNavigationAction continueNavigationAction); void setAppId(String appId); String getAppId(); Router getRouter(); boolean isDirty(); void setContextRoot(String contextRootRelativePath); String getContextRootRelativePath(); void setActiveDragSourceComponent(
            Component activeDragSourceComponent); Component getActiveDragSourceComponent(); UI getUI(); ExtendedClientDetails getExtendedClientDetails(); void setExtendedClientDetails(ExtendedClientDetails details);  }
@Test public void showRouteTarget_usePushConfigFromComponent() { PushConfiguration pushConfig = setUpInitialPush(); useV14Bootstrap(); internals.showRouteTarget(Mockito.mock(Location.class), new RouteTarget(), Collections.emptyList()); Mockito.verify(pushConfig).setPushMode(PushMode.AUTOMATIC); Mockito.verify(pushConfig).setTransport(Transport.WEBSOCKET_XHR); }
@Test public void showRouteTarget_usePushConfigFromParentLayout() { PushConfiguration pushConfig = setUpInitialPush(); useV14Bootstrap(); internals.showRouteTarget(Mockito.mock(Location.class), new RouteTarget1(), Collections.singletonList(new RouteTarget())); Mockito.verify(pushConfig).setPushMode(PushMode.AUTOMATIC); Mockito.verify(pushConfig).setTransport(Transport.WEBSOCKET_XHR); }
@Test public void showRouteTarget_componentHasNoPush_pushIsDisabled() { PushConfiguration pushConfig = setUpInitialPush(); useV14Bootstrap(); DeploymentConfiguration deploymentConfiguration = vaadinService .getDeploymentConfiguration(); Mockito.when(deploymentConfiguration.getPushMode()) .thenReturn(PushMode.AUTOMATIC); internals.showRouteTarget(Mockito.mock(Location.class), new Text(""), Collections.emptyList()); Mockito.verify(pushConfig).setPushMode(PushMode.AUTOMATIC); Mockito.verify(pushConfig, Mockito.times(0)) .setTransport(Mockito.any()); }
@Test public void showRouteTarget_clientSideBootstrap() { PushConfiguration pushConfig = setUpInitialPush(); internals.showRouteTarget(Mockito.mock(Location.class), new RouteTarget(), Collections.emptyList()); Mockito.verify(pushConfig, Mockito.never()).setPushMode(Mockito.any()); }