use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class ModuleDisposalDataServiceTest method testImportDataWithAndroidStudioAndSuccessfulSync.
public void testImportDataWithAndroidStudioAndSuccessfulSync() {
when(myIdeInfo.isAndroidStudio()).thenReturn(true);
when(mySyncState.lastSyncFailedOrHasIssues()).thenReturn(false);
IdeaModule moduleModel = mock(IdeaModule.class);
when(moduleModel.getName()).thenReturn(getModule().getName());
ImportedModule importedModule = new ImportedModule(moduleModel);
// This module should be disposed.
Module libModule = createModule("lib");
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
Collection<DataNode<ImportedModule>> nodes = Collections.singleton(new DataNode<>(IMPORTED_MODULE, importedModule, null));
myDataService.importData(nodes, null, project, modelsProvider);
ApplicationManager.getApplication().runWriteAction(modelsProvider::dispose);
Collection<Module> modulesToDispose = Collections.singletonList(libModule);
verify(myModuleDisposer).disposeModulesAndMarkImlFilesForDeletion(modulesToDispose, getProject(), modelsProvider);
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class ModuleDisposalDataServiceTest method testImportDataWithIdeNotAndroidStudio.
public void testImportDataWithIdeNotAndroidStudio() {
when(myIdeInfo.isAndroidStudio()).thenReturn(false);
IdeModifiableModelsProvider modelsProvider = mock(IdeModifiableModelsProvider.class);
myDataService.importData(Collections.emptyList(), null, getProject(), modelsProvider);
//noinspection unchecked
verify(myModuleDisposer, never()).disposeModulesAndMarkImlFilesForDeletion(anyList(), same(getProject()), same(modelsProvider));
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class ModuleDisposalDataServiceTest method testImportDataWithAndroidStudioAndSyncFailed.
public void testImportDataWithAndroidStudioAndSyncFailed() {
when(myIdeInfo.isAndroidStudio()).thenReturn(true);
when(mySyncState.lastSyncFailedOrHasIssues()).thenReturn(true);
IdeModifiableModelsProvider modelsProvider = mock(IdeModifiableModelsProvider.class);
myDataService.importData(Collections.emptyList(), null, getProject(), modelsProvider);
//noinspection unchecked
verify(myModuleDisposer, never()).disposeModulesAndMarkImlFilesForDeletion(anyList(), same(getProject()), same(modelsProvider));
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class AndroidModuleDependenciesSetupTest method testSetUpLibraryWithNewLibrary.
public void testSetUpLibraryWithNewLibrary() throws IOException {
File binaryPath = createTempFile("fakeLibrary", "jar");
File sourcePath = createTempFile("fakeLibrary-src", "jar");
when(myLibraryFilePaths.findSourceJarPath(binaryPath)).thenReturn(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);
Library library = libraryOrderEntries.get(0).getLibrary();
assertNotNull(library);
assertEquals(libraryName, library.getName());
String[] binaryUrls = library.getUrls(CLASSES);
assertThat(binaryUrls).hasLength(1);
assertEquals(pathToIdeaUrl(binaryPath), binaryUrls[0]);
String[] sourceUrls = library.getUrls(SOURCES);
assertThat(sourceUrls).hasLength(1);
assertEquals(pathToIdeaUrl(sourcePath), sourceUrls[0]);
// Should not mark new libraries as "used"
verify(myLibraryRegistry, never()).markAsUsed(library, binaryPaths);
verify(myLibraryFilePaths).findSourceJarPath(binaryPath);
}
use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider in project android by JetBrains.
the class JavaModuleSetupTest method testSetUpModuleWithoutProgressIndicator.
public void testSetUpModuleWithoutProgressIndicator() {
when(myJavaModuleModel.isAndroidModuleWithoutVariants()).thenReturn(false);
IdeModifiableModelsProvider modelsProvider = mock(IdeModifiableModelsProvider.class);
Module module = getModule();
myModuleSetup.setUpModule(module, modelsProvider, myJavaModuleModel, myModuleModels, null);
verify(mySetupStep1, times(1)).setUpModule(module, modelsProvider, myJavaModuleModel, myModuleModels, null);
verify(mySetupStep2, times(1)).setUpModule(module, modelsProvider, myJavaModuleModel, myModuleModels, null);
verify(mySetupStep1, never()).displayDescription(same(module), any());
verify(mySetupStep2, never()).displayDescription(same(module), any());
}
Aggregations