void () { ApplicationManager.getApplication().runWriteAction(() -> { Module a = loadModule(Paths.get(PathManagerEx.getHomePath(getClass())).resolve("java/java-tests/testData/moduleRootManager/rootsChanged/emptyModule/a.iml")); myModuleRootListener.assertEventsCount(1); final Sdk jdk = ProjectJdkTable.getInstance().createSdk("new-jdk", JavaSdk.getInstance()); ProjectJdkTable.getInstance().addJdk(jdk, getTestRootDisposable()); myModuleRootListener.assertNoEvents(); ModuleRootModificationUtil.setModuleSdk(a, jdk); myModuleRootListener.assertEventsCount(1); SdkModificator sdkModificator = jdk.getSdkModificator(); sdkModificator.addRoot(getTempDir().createVirtualDir(), OrderRootType.CLASSES); sdkModificator.commitChanges(); }); myModuleRootListener.assertEventsCount(1); }