void (String oldPattern, String newPattern) { final PsiClass psiClass = myFixture.addClass("package p; public class A {}"); final VirtualFile file = PsiUtilCore.getVirtualFile(psiClass); assertNotNull(file); myFixture.openFileInEditor(file); final String scopeName = "myscope"; PackageSet packageSet; try { packageSet = PackageSetFactory.getInstance().compile(oldPattern); } catch (ParsingException e) { throw new RuntimeException(e); } NamedScope namedScope = new NamedScope(scopeName, packageSet); final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(getProject()); validationManager.addScope(namedScope); WriteCommandAction.runWriteCommandAction( getProject(), () -> RenameUtil.doRename(psiClass, "B", UsageInfo.EMPTY_ARRAY, getProject(), new RefactoringScopeElementListenerProvider().getListener(psiClass))); namedScope = validationManager.getScope(scopeName); assertNotNull(namedScope); PackageSet value = namedScope.getValue(); assertNotNull(value); String valueText = value.getText(); assertEquals(newPattern, valueText); final FileEditor selectedEditor = FileEditorManager.getInstance(getProject()).getSelectedEditor(file); UndoManager.getInstance(getProject()).undo(selectedEditor); namedScope = validationManager.getScope(scopeName); assertNotNull(namedScope); value = namedScope.getValue(); assertNotNull(value); valueText = value.getText(); assertEquals(oldPattern, valueText); validationManager.setScopes(NamedScope.EMPTY_ARRAY); }