use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class FacetsTest method testRemoveAllFacetsWithAndroidGradleFacets.
public void testRemoveAllFacetsWithAndroidGradleFacets() throws Exception {
createAndAddGradleFacet(myModule);
FacetManager facetManager = FacetManager.getInstance(myModule);
assertEquals(1, facetManager.getFacetsByType(GradleFacet.getFacetTypeId()).size());
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
ModifiableFacetModel facetModel = modelsProvider.getModifiableFacetModel(myModule);
Facets.removeAllFacets(facetModel, GradleFacet.getFacetTypeId());
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
assertEquals(0, facetManager.getFacetsByType(GradleFacet.getFacetTypeId()).size());
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class FacetsTest method testRemoveAllFacetsWithAndroidFacets.
public void testRemoveAllFacetsWithAndroidFacets() throws Exception {
createAndAddAndroidFacet(myModule);
FacetManager facetManager = FacetManager.getInstance(myModule);
assertEquals(1, facetManager.getFacetsByType(AndroidFacet.ID).size());
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
ModifiableFacetModel facetModel = modelsProvider.getModifiableFacetModel(myModule);
Facets.removeAllFacets(facetModel, AndroidFacet.ID);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
assertEquals(0, facetManager.getFacetsByType(AndroidFacet.ID).size());
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider 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);
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class ArtifactsByConfigurationModuleSetupStepTest method testDoSetUpModule.
public void testDoSetUpModule() throws IOException {
Module module = getModule();
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
File jarFilePath = createTempFile("fake.jar", "");
Map<String, Set<File>> artifactsByConfiguration = new HashMap<>();
artifactsByConfiguration.put("default", Collections.singleton(jarFilePath));
JavaModuleModel model = new JavaModuleModel(module.getName(), Collections.emptyList(), Collections.emptyList(), artifactsByConfiguration, null, null, null, true, false);
mySetupStep.doSetUpModule(module, modelsProvider, model, null, null);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
assertJarIsLibrary(jarFilePath);
// This is the first time we create the library, it shouldn't be marked as "used".
verify(myLibraryRegistry, never()).markAsUsed(any(), any());
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class ArtifactsByConfigurationModuleSetupStepTest method testDoSetUpModuleWithExistingLibrary.
public void testDoSetUpModuleWithExistingLibrary() throws IOException {
File jarFilePath = createTempFile("fake.jar", "");
// Create the library, to ensure that is marked as "used".
Library library = createLibrary(jarFilePath);
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
Map<String, Set<File>> artifactsByConfiguration = new HashMap<>();
artifactsByConfiguration.put("default", Collections.singleton(jarFilePath));
Module module = getModule();
JavaModuleModel model = new JavaModuleModel(module.getName(), Collections.emptyList(), Collections.emptyList(), artifactsByConfiguration, null, null, null, true, false);
mySetupStep.doSetUpModule(module, modelsProvider, model, null, null);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
assertJarIsLibrary(jarFilePath);
// This is an existing library, it should be marked as "used".
verify(myLibraryRegistry, times(1)).markAsUsed(library, jarFilePath);
}
Aggregations