use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.
the class AndroidModuleDependenciesSetupTest method testSetUpLibraryWithExistingLibrary.
public void testSetUpLibraryWithExistingLibrary() throws IOException {
File binaryPath = createTempFile("fakeLibrary", "jar");
File sourcePath = createTempFile("fakeLibrary-src", "jar");
Library newLibrary = createLibrary(binaryPath, sourcePath);
String libraryName = binaryPath.getName();
Module module = getModule();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
File[] binaryPaths = { binaryPath };
myDependenciesSetup.setUpLibraryDependency(module, modelsProvider, libraryName, COMPILE, binaryPath, binaryPaths, EMPTY_FILE_ARRAY);
// Apply changes before checking state.
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
List<LibraryOrderEntry> libraryOrderEntries = getLibraryOrderEntries(module);
// Only one library should be in the library table.
assertThat(libraryOrderEntries).hasSize(1);
LibraryOrderEntry libraryOrderEntry = libraryOrderEntries.get(0);
// The existing library should not have been changed.
assertSame(newLibrary, libraryOrderEntry.getLibrary());
verify(myLibraryRegistry).markAsUsed(newLibrary, binaryPaths);
// Should not attemp to look up sources for existing libraries.
verify(myLibraryFilePaths, never()).findSourceJarPath(binaryPath);
}
Aggregations