void () { final FindModel findModel = new FindModel(); String toFind = "xxx"; findModel.setStringToFind(toFind); @SuppressWarnings("SpellCheckingInspection") String toReplace = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; findModel.setStringToReplace(toReplace); findModel.setWholeWordsOnly(true); findModel.setFromCursor(false); findModel.setGlobal(true); findModel.setMultipleFiles(false); findModel.setProjectScope(true); findModel.setRegularExpressions(false); findModel.setPromptOnReplace(false); myFindManager.setFindNextModel(null); myFindManager.getFindInFileModel().copyFrom(findModel); String text = StringUtil.repeat(toFind + "\n",6); configureByText(FileTypes.PLAIN_TEXT, text); final List<Usage> usages = FindUtil.findAll(getProject(), myFile, findModel); assertNotNull(usages); CommandProcessor.getInstance().executeCommand(getProject(), () -> { for (Usage usage : usages) { try { ReplaceInProjectManager.getInstance(getProject()).replaceUsage(usage, findModel, Collections.emptySet(), false); } catch (FindManager.MalformedReplacementStringException e) { throw new RuntimeException(e); } } }, "", null); String newText = StringUtil.repeat(toReplace + "\n",6); assertEquals(newText, getEditor().getDocument().getText()); }