use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class JavaLanguageLevelModuleSetupStepTest method testSetUpModuleWithLanguageLevelComingFromAndroidModules.
public void testSetUpModuleWithLanguageLevelComingFromAndroidModules() {
createAndroidModule("app", JDK_1_7);
createAndroidModule("androidLib", JDK_1_8);
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
when(myJavaModuleModel.getJavaLanguageLevel()).thenReturn(null);
Module module = getModule();
mySetupStep.setUpModule(module, modelsProvider, myJavaModuleModel, null, null);
// Commit changes to verify results.
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
verifyLanguageLevel(module, JDK_1_7);
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class AndroidModuleModelDataServiceTest method testImportData.
public void testImportData() throws Exception {
loadSimpleApplication();
Module appModule = myModules.getAppModule();
AndroidModuleModel androidModel = AndroidModuleModel.get(appModule);
assertNotNull(androidModel);
DataNode<AndroidModuleModel> dataNode = new DataNode<>(ANDROID_MODEL, androidModel, null);
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
myService.importData(Lists.newArrayList(dataNode), mock(ProjectData.class), project, modelsProvider);
verify(myModuleSetup).setUpModule(appModule, modelsProvider, androidModel, null, null);
verify(myValidator).validate(appModule, androidModel);
verify(myValidator).fixAndReportFoundIssues();
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider 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();
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class ModuleDisposerTest method testDisposeModulesAndMarkImlFilesForDeletion.
public void testDisposeModulesAndMarkImlFilesForDeletion() {
// This module should be disposed.
Module libModule = createModule("lib");
File libImlFilePath = new File(toSystemDependentName(libModule.getModuleFilePath()));
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
myModuleDisposer.disposeModulesAndMarkImlFilesForDeletion(Collections.singletonList(libModule), project, modelsProvider);
// Apply changes
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
// Make sure module "lib" was disposed and its .iml file was deleted.
assertTrue(Disposer.isDisposed(libModule));
verify(myDisposedModules, times(1)).markImlFilesForDeletion(Collections.singletonList(libImlFilePath));
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class ModuleDisposerTest method testDisposeModulesAndMarkImlFilesForDeletionWithNoModules.
public void testDisposeModulesAndMarkImlFilesForDeletionWithNoModules() {
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
myModuleDisposer.disposeModulesAndMarkImlFilesForDeletion(Collections.emptyList(), project, modelsProvider);
// Apply changes
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
//noinspection unchecked
verify(myDisposedModules, never()).markImlFilesForDeletion(anyList());
}
Aggregations