void () { final String packageName = "pack1"; doTest(new MyPerformAction(packageName, "target"){ private static final String FOO = "pack1.subPack.Foo"; @Override protected void preprocessSrcDir(PsiDirectory srcDirectory) { final PsiClass empty = JavaPsiFacade.getInstance(getProject()).findClass(FOO, GlobalSearchScope.projectScope(getProject())); assert empty != null; ApplicationManager.getApplication().runWriteAction(empty::delete); } @Override protected void postProcessTargetDir(PsiDirectory targetDirectory) { final PsiDirectory subdirectory = targetDirectory.findSubdirectory(packageName); assert subdirectory != null; final PsiDirectory emptyDir = subdirectory.findSubdirectory("subPack"); assert emptyDir != null; ApplicationManager.getApplication().runWriteAction(() -> { emptyDir.createFile(EMPTY_TXT); }); } }); }