void (String selectedText, TemplateImpl template, String expectedResult) { configureFromFileText("text." + getExtension(), selectSourceData(selectedText)); ApplicationManager.getApplication().runWriteAction(() -> TemplateManager.getInstance(getProject()).startTemplate(getEditor(), selectedText, template)); NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); UIUtil.dispatchAllInvocationEvents(); checkResultByText(expectedResult); }