use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.
the class ProjectListDownloaderTests method update_modules_with_org.
@Test
void update_modules_with_org(@TempDir Path tempDir) {
var serverProjectsStore = new ServerProjectsStore(new StorageFolder.Default(tempDir));
mockServer.addResponseFromResource("/api/components/search.protobuf?qualifiers=TRK&organization=myOrg&ps=500&p=1", "/update/searchmodulesp1.pb");
var moduleListUpdate = new ProjectListDownloader(mockServer.serverApiHelper("myOrg"), serverProjectsStore);
moduleListUpdate.fetch(new ProgressMonitor(null));
var moduleList = ProtobufUtil.readFile(tempDir.resolve(ServerProjectsStore.PROJECT_LIST_PB), ProjectList.parser());
assertThat(moduleList.getProjectsByKeyMap()).hasSize(282);
}
use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.
the class ProjectListDownloaderTests method update_modules.
@Test
void update_modules(@TempDir Path tempDir) {
var serverProjectsStore = new ServerProjectsStore(new StorageFolder.Default(tempDir));
mockServer.addResponseFromResource("/api/components/search.protobuf?qualifiers=TRK&ps=500&p=1", "/update/searchmodulesp1.pb");
var moduleListUpdate = new ProjectListDownloader(mockServer.serverApiHelper(), serverProjectsStore);
moduleListUpdate.fetch(new ProgressMonitor(null));
var moduleList = ProtobufUtil.readFile(tempDir.resolve(ServerProjectsStore.PROJECT_LIST_PB), ProjectList.parser());
assertThat(moduleList.getProjectsByKeyMap()).hasSize(282);
}
use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.
the class PluginsSynchronizerTests method should_not_synchronize_an_up_to_date_plugin.
@Test
void should_not_synchronize_an_up_to_date_plugin(@TempDir Path tmp) throws Exception {
var dest = tmp.resolve("destDir");
Files.createDirectory(dest);
mockServer.addStringResponse("/api/plugins/installed", "{\"plugins\": [" + "{\"key\": \"java\", \"hash\": \"de5308f43260d357acc97712ce4c5475\", \"filename\": \"sonar-java-plugin-5.13.1.18282.jar\", \"sonarLintSupported\": true}" + "]}");
mockServer.addStringResponse("/api/plugins/download?plugin=java", "content-java");
underTest = new PluginsSynchronizer(Set.of(Language.JAVA), new PluginsStorage(dest), emptySet());
underTest.synchronize(new ServerApi(mockServer.serverApiHelper()), new ProgressMonitor(null));
mockServer.removeResponse("/api/plugins/download?plugin=java");
var anyPluginUpdated = underTest.synchronize(new ServerApi(mockServer.serverApiHelper()), new ProgressMonitor(null));
assertThat(anyPluginUpdated).isFalse();
}
use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.
the class PluginsSynchronizerTests method should_not_synchronize_plugins_that_do_not_support_sonarlint.
@Test
void should_not_synchronize_plugins_that_do_not_support_sonarlint(@TempDir Path dest) {
mockServer.addStringResponse("/api/plugins/installed", "{\"plugins\": [" + "{\"key\": \"java\", \"hash\": \"de5308f43260d357acc97712ce4c5475\", \"filename\": \"sonar-java-plugin-5.13.1.18282.jar\", \"sonarLintSupported\": false}" + "]}");
underTest = new PluginsSynchronizer(Set.of(Language.JAVA), new PluginsStorage(dest), Set.of());
var anyPluginUpdated = underTest.synchronize(new ServerApi(mockServer.serverApiHelper()), new ProgressMonitor(null));
assertThat(dest.resolve("plugin_references.pb")).doesNotExist();
assertThat(dest.resolve("sonar-java-plugin-5.13.1.18282.jar")).doesNotExist();
assertThat(anyPluginUpdated).isFalse();
}
use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.
the class PluginsSynchronizerTests method should_synchronize_unknown_plugins_for_custom_rules.
@Test
void should_synchronize_unknown_plugins_for_custom_rules(@TempDir Path tmp) {
var dest = tmp.resolve("destDir");
mockServer.addStringResponse("/api/plugins/installed", "{\"plugins\": [" + "{\"key\": \"java-custom\", \"hash\": \"de5308f43260d357acc97712ce4c5475\", \"filename\": \"java-custom-plugin-4.3.0.1456.jar\", \"sonarLintSupported\": true}" + "]}");
mockServer.addStringResponse("/api/plugins/download?plugin=java-custom", "content-java-custom");
underTest = new PluginsSynchronizer(Set.of(Language.JS), new PluginsStorage(dest), emptySet());
var anyPluginUpdated = underTest.synchronize(new ServerApi(mockServer.serverApiHelper()), new ProgressMonitor(null));
var references = ProtobufUtil.readFile(dest.resolve("plugin_references.pb"), PluginReferences.parser());
assertThat(references.getPluginsByKeyMap().values()).extracting("key", "hash", "filename").containsOnly(tuple("java-custom", "de5308f43260d357acc97712ce4c5475", "java-custom-plugin-4.3.0.1456.jar"));
assertThat(dest.resolve("java-custom-plugin-4.3.0.1456.jar")).hasContent("content-java-custom");
assertThat(anyPluginUpdated).isTrue();
}
Aggregations