void () { WriteAction.run(() -> { //duplicate class in resource directory VirtualFile resourceDir = createChildDirectory(myPrjDir1, "rSrc1"); VirtualFile file1 = createChildData(createChildDirectory(resourceDir, "p"), "A.java"); setFileText(file1, "package p; public class A{ public void foo(); }"); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); PsiTestUtil.addSourceRoot(myModule, resourceDir, JavaResourceRootType.RESOURCE); PsiClass[] classes = myJavaFacade.findClasses("p.A", GlobalSearchScope.allScope(myProject)); assertSize(1, classes); }); }