ListPopup (@PopupTitle @Nullable String title, @NlsContexts.Label String yesText, @NlsContexts.Label String noText, Runnable onYes, Runnable onNo, int defaultOptionIndex) { BaseListPopupStep<String> step = new BaseListPopupStep<>(title, yesText, noText) { boolean myRunYes; @Override public PopupStep onChosen(String selectedValue, final boolean finalChoice) { myRunYes = selectedValue.equals(yesText); return FINAL_CHOICE; } @Override public void canceled() { (myRunYes ? onYes : onNo).run(); } @Override public boolean isMnemonicsNavigationEnabled() { return true; } }; step.setDefaultOptionIndex(defaultOptionIndex); final Application app = ApplicationManager.getApplication(); return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step, yesText); }