### Question:
StackController extends ParentController<StackLayout> { public void setRoot(List<ViewController> children, CommandListener listener) { animator.cancelPushAnimations(); if (children.size() == 1) { backButtonHelper.clear(CollectionUtils.last(children)); push(CollectionUtils.last(children), new CommandListenerAdapter() { @Override public void onSuccess(String childId) { removeChildrenBellowTop(); listener.onSuccess(childId); } }); } else { push(CollectionUtils.last(children), new CommandListenerAdapter() { @Override public void onSuccess(String childId) { removeChildrenBellowTop(); for (int i = 0; i < children.size() - 1; i++) { stack.set(children.get(i).getId(), children.get(i), i); children.get(i).setParentController(StackController.this); if (i == 0) { backButtonHelper.clear(children.get(i)); } else { backButtonHelper.addToPushedChild(children.get(i)); } } listener.onSuccess(childId); } }); } } StackController(Activity activity, List<ViewController> children, ChildControllersRegistry childRegistry, TopBarController topBarController, NavigationAnimator animator, String id, Options initialOptions, BackButtonHelper backButtonHelper, StackPresenter stackPresenter, Presenter presenter); @Override boolean isRendered(); @Override void setDefaultOptions(Options defaultOptions); @Override void onAttachToParent(); @Override void mergeOptions(Options options); @Override void applyChildOptions(Options options, Component child); @Override void mergeChildOptions(Options options, ViewController childController, Component child); @Override void destroy(); @Override void clearOptions(); @Override void onChildDestroyed(Component child); void push(ViewController child, CommandListener listener); void setRoot(List<ViewController> children, CommandListener listener); void pop(Options mergeOptions, CommandListener listener); void popTo(ViewController viewController, Options mergeOptions, CommandListener listener); void popToRoot(Options mergeOptions, CommandListener listener); int size(); boolean isEmpty(); @Override boolean handleBack(CommandListener listener); @Override void sendOnNavigationButtonPressed(String buttonId); @NonNull @Override Collection<ViewController> getChildControllers(); @Override void setupTopTabsWithViewPager(ViewPager viewPager); @Override void clearTopTabs(); @RestrictTo(RestrictTo.Scope.TESTS) TopBar getTopBar(); @RestrictTo(RestrictTo.Scope.TESTS) StackLayout getStackLayout();  }### Answer:
@Test public void setRoot_doesNotCrashWhenCalledInQuickSuccession() { disablePushAnimation(child1); uut.setRoot(Collections.singletonList(child1), new CommandListenerAdapter()); uut.setRoot(Collections.singletonList(child2), new CommandListenerAdapter()); uut.setRoot(Collections.singletonList(child3), new CommandListenerAdapter()); animator.endPushAnimation(child2.getView()); animator.endPushAnimation(child3.getView()); assertContainsOnlyId(child3.getId()); }