void (String choiceText, String secondChoiceText, Consumer<AbstractInplaceIntroducer<?, ?>> pass, @Nullable List<String> expectedOptions) { String name = getTestName(true); configureByFile(getBasePath() + name + getExtension()); final boolean enabled = getEditor().getSettings().isVariableInplaceRenameEnabled(); try { TemplateManagerImpl.setTemplateTesting(getTestRootDisposable()); getEditor().getSettings().setVariableInplaceRenameEnabled(true); MyIntroduceHandler handler = createIntroduceHandler(); UiInterceptors.register(new ChooserInterceptor(expectedOptions, Pattern.quote(choiceText))); if (secondChoiceText != null) { UiInterceptors.register(new ChooserInterceptor(expectedOptions, Pattern.quote(secondChoiceText))); } final AbstractInplaceIntroducer<?, ?> introducer = invokeRefactoring(handler); NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); if (pass != null) { pass.accept(introducer); } TemplateState state = TemplateManagerImpl.getTemplateState(getEditor()); assert state != null; state.gotoEnd(false); checkResultByFile(getBasePath() + name + "_after" + getExtension()); } finally { getEditor().getSettings().setVariableInplaceRenameEnabled(enabled); } }