use of com.intellij.openapi.roots.impl.ModuleRootManagerComponent in project intellij-community by JetBrains.
the class LibraryTest method testFindLibraryByNameAfterRename.
public void testFindLibraryByNameAfterRename() {
final long moduleModificationCount = ((ModuleRootManagerComponent) ModuleRootManager.getInstance(myModule)).getStateModificationCount();
ProjectLibraryTable table = (ProjectLibraryTable) getLibraryTable();
final long projectLibraryModificationCount = table.getStateModificationCount();
Library a = createLibrary("a", null, null);
LibraryTable.ModifiableModel model = table.getModifiableModel();
assertSame(a, table.getLibraryByName("a"));
assertSame(a, model.getLibraryByName("a"));
Library.ModifiableModel libraryModel = a.getModifiableModel();
libraryModel.setName("b");
commit(libraryModel);
// module not marked as to save if project library modified, but module is not affected
assertThat(((ModuleRootManagerComponent) ModuleRootManager.getInstance(myModule)).getStateModificationCount()).isEqualTo(moduleModificationCount);
assertThat(table.getStateModificationCount()).isGreaterThan(projectLibraryModificationCount);
assertNull(table.getLibraryByName("a"));
assertNull(model.getLibraryByName("a"));
assertSame(a, table.getLibraryByName("b"));
assertSame(a, model.getLibraryByName("b"));
commit(model);
assertSame(a, table.getLibraryByName("b"));
}
use of com.intellij.openapi.roots.impl.ModuleRootManagerComponent in project intellij-community by JetBrains.
the class LibraryTest method testLibrarySerialization.
public void testLibrarySerialization() {
final long moduleModificationCount = ((ModuleRootManagerComponent) ModuleRootManager.getInstance(myModule)).getStateModificationCount();
Library library = PsiTestUtil.addProjectLibrary(myModule, "junit", Collections.singletonList(getJDomJar()), Collections.singletonList(getJDomSources()));
assertThat(((ModuleRootManagerComponent) ModuleRootManager.getInstance(myModule)).getStateModificationCount()).isGreaterThan(moduleModificationCount);
Element element = serialize(library);
String classesUrl = getJDomJar().getUrl();
String sourcesUrl = getJDomSources().getUrl();
PlatformTestUtil.assertElementEquals("<root><library name=\"junit\"><CLASSES><root url=\"" + classesUrl + "\" /></CLASSES>" + "<JAVADOC /><SOURCES><root url=\"" + sourcesUrl + "\" /></SOURCES></library></root>", element);
}
Aggregations