use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.
the class NdkModuleModelDataServiceTest method testOnModelsNotFound.
// See: https://code.google.com/p/android/issues/detail?id=229806
public void testOnModelsNotFound() {
createAndAddNdkFacet(myModule);
myModelsProvider = new IdeModifiableModelsProviderImpl(getProject());
myDataService.onModelsNotFound(myModelsProvider);
ApplicationManager.getApplication().runWriteAction(() -> myModelsProvider.commit());
assertNull(NdkFacet.getInstance(myModule));
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl 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.IdeModifiableModelsProviderImpl 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);
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.
the class DependenciesModuleSetupStepTest method testUpdateLibraryDependencyWithLibraryInModule.
public void testUpdateLibraryDependencyWithLibraryInModule() throws IOException {
Module module = getModule();
createContentRoot(module);
VirtualFile moduleFolder = getModuleFolder(module);
// Create "build" folder inside the module.
String name = "build";
VirtualFile buildFolder = createFolder(moduleFolder, name);
AndroidProject androidProject = mock(AndroidProject.class);
when(androidProject.getBuildFolder()).thenReturn(virtualToIoFile(buildFolder));
// Create "jars" folder inside the module's "build" folder.
VirtualFile jarsFolder = createFolder(buildFolder, "jars");
File jarsFolderPath = virtualToIoFile(jarsFolder);
// We simulate the dependency to set up being inside the "jars" folder. We expect the "jars" folder to be excluded to avoid unnecessary
// indexing of the jar files.
LibraryDependency dependency = createFakeLibraryDependency(jarsFolderPath);
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
mySetupStep.updateLibraryDependency(module, modelsProvider, dependency, androidProject);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
// Make sure DependenciesSetup#setUpLibraryDependency was invoked.
verify(myDependenciesSetup).setUpLibraryDependency(module, modelsProvider, "myLibrary", COMPILE, dependency.getArtifactPath(), dependency.getPaths(BINARY), dependency.getPaths(DOCUMENTATION));
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.
the class JavaModuleSetupTest method testSetUpAndroidModuleWithoutVariants.
public void testSetUpAndroidModuleWithoutVariants() {
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
when(myJavaModuleModel.isAndroidModuleWithoutVariants()).thenReturn(true);
Module module = getModule();
// Add AndroidFacet to verify that is removed.
createAndAddAndroidFacet(module);
ApplicationManager.getApplication().runWriteAction(() -> {
// Add source folders and excluded folders to verify that they are removed.
ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
ContentEntry contentEntry = modifiableModel.addContentEntry("file://fakePath");
contentEntry.addSourceFolder("file://fakePath/sourceFolder", false);
contentEntry.addExcludeFolder("file://fakePath/excludedFolder");
modifiableModel.commit();
});
myModuleSetup.setUpModule(module, modelsProvider, myJavaModuleModel, myModuleModels, null);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
// Verify AndroidFacet was removed.
assertNull(AndroidFacet.getInstance(module));
// Verify source folders and excluded folders were removed.
ContentEntry[] contentEntries = ModuleRootManager.getInstance(module).getContentEntries();
assertThat(contentEntries).hasLength(1);
ContentEntry contentEntry = contentEntries[0];
assertThat(contentEntry.getSourceFolders()).isEmpty();
assertThat(contentEntry.getExcludeFolderUrls()).isEmpty();
}
Aggregations