void (String[] fileNames, String newDirName, String dir) { final PsiFile[] files = new PsiFile[fileNames.length]; for (int i = 0; i < files.length; i++) { String fileName = fileNames[i]; final VirtualFile file = myFixture.getTempDirFixture().getFile(dir + "/" + fileName); assertNotNull("File " + fileName + " not found", file); files[i] = PsiManager.getInstance(getProject()).findFile(file); assertNotNull("File " + fileName + " not found", files[i]); } final VirtualFile virDir = myFixture.getTempDirFixture().getFile(dir + "/" + newDirName); assertNotNull("Directory " + newDirName + " not found", virDir); final PsiDirectory psiDirectory = PsiManager.getInstance(getProject()).findDirectory(virDir); assertNotNull("Directory " + newDirName + " not found", psiDirectory); final PsiPackage pkg = JavaDirectoryService.getInstance().getPackage(psiDirectory); List<PsiClass> classList = new ArrayList<>(); for (PsiFile file : files) { Collections.addAll(classList, ((PsiClassOwner)file).getClasses()); } final PsiClass[] classes = classList.toArray(PsiClass.EMPTY_ARRAY); new MoveClassesOrPackagesProcessor(getProject(), classes, new SingleSourceRootMoveDestination(PackageWrapper.create(pkg), psiDirectory), true, true, null).run(); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); FileDocumentManager.getInstance().saveAllDocuments(); }