void (@NotNull JBPopup popup) { JBList<?> content = popup.isDisposed() ? null : UIUtil.findComponentOfType(popup.getContent(), JBList.class); if (content == null) { fail("JBList not found under " + popup.getContent()); } ListModel<?> model = content.getModel(); List<String> actualOptions = IntStream.range(0, model.getSize()).mapToObj(model::getElementAt).map(Object::toString).collect(Collectors.toList()); if (myOptions != null) { assertEquals(myOptions, actualOptions); } List<String> matched = ContainerUtil.filter(actualOptions, opt -> myToSelect.matcher(opt).matches()); if (matched.isEmpty()) { fail("No option matches pattern " + myToSelect + " (available options: " + String.join(", ", actualOptions) + ")"); } if (matched.size() > 1) { fail("Several options matched: " + matched + " (pattern: " + myToSelect + ")"); } content.setSelectedIndex(actualOptions.indexOf(matched.get(0))); assertTrue(popup.canClose()); // calls cancelHandler if (popup instanceof ListPopup listPopup) { listPopup.handleSelect(true); } popup.closeOk(null); if (!ApplicationManager.getApplication().isWriteAccessAllowed()) { NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); } }