### Question:
ModalStack { public void showModal(ViewController viewController, ViewController root, CommandListener listener) { ViewController toRemove = isEmpty() ? root : peek(); modals.add(viewController); presenter.showModal(viewController, toRemove, listener); } ModalStack(Activity activity); @RestrictTo(RestrictTo.Scope.TESTS)  ModalStack(ModalPresenter presenter); void setEventEmitter(EventEmitter eventEmitter); void setModalsLayout(ViewGroup modalsLayout); void setRootLayout(ViewGroup rootLayout); void setDefaultOptions(Options defaultOptions); void showModal(ViewController viewController, ViewController root, CommandListener listener); boolean dismissModal(String componentId, @Nullable ViewController root, CommandListener listener); void dismissAllModals(ViewController root, Options mergeOptions, CommandListener listener); boolean handleBack(CommandListener listener, ViewController root); ViewController get(int index); boolean isEmpty(); int size(); @Nullable ViewController findControllerById(String componentId); void destroy();  }### Answer:
@Test public void modalRefIsSaved() { disableShowModalAnimation(modal1); CommandListener listener = spy(new CommandListenerAdapter()); uut.showModal(modal1, root, listener); verify(listener, times(1)).onSuccess(modal1.getId()); assertThat(findModal(MODAL_ID_1)).isNotNull(); }
@Test public void showModal() { CommandListener listener = spy(new CommandListenerAdapter()); uut.showModal(modal1, root, listener); verify(listener, times(1)).onSuccess(modal1.getId()); assertThat(uut.size()).isOne(); verify(presenter, times(1)).showModal(modal1, root, listener); assertThat(findModal(MODAL_ID_1)).isNotNull(); }