Search in sources :

Example 11 with ProgressMonitor

use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.

the class PluginsSynchronizerTests method should_not_synchronize_the_old_typescript_plugin_if_language_not_enabled.

@Test
void should_not_synchronize_the_old_typescript_plugin_if_language_not_enabled(@TempDir Path tmp) throws Exception {
    var dest = tmp.resolve("destDir");
    Files.createDirectory(dest);
    mockServer.addStringResponse("/api/plugins/installed", "{\"plugins\": [" + "{\"key\": \"typescript\", \"hash\": \"de5308f43260d357acc97712ce4c5475\", \"filename\": \"sonar-typescript-plugin-1.9.0.3766.jar\", \"sonarLintSupported\": true}" + "]}");
    underTest = new PluginsSynchronizer(Set.of(Language.JAVA), new PluginsStorage(dest), emptySet());
    var anyPluginUpdated = underTest.synchronize(new ServerApi(mockServer.serverApiHelper()), new ProgressMonitor(null));
    assertThat(dest.resolve("plugin_references.pb")).doesNotExist();
    assertThat(dest.resolve("sonar-typescript-plugin-1.9.0.3766.jar")).doesNotExist();
    assertThat(anyPluginUpdated).isFalse();
}
Also used : ProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor) ServerApi(org.sonarsource.sonarlint.core.serverapi.ServerApi) Test(org.junit.jupiter.api.Test)

Example 12 with ProgressMonitor

use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.

the class PluginsSynchronizerTests method should_synchronize_the_old_typescript_plugin_if_language_enabled.

@Test
void should_synchronize_the_old_typescript_plugin_if_language_enabled(@TempDir Path tmp) throws Exception {
    var dest = tmp.resolve("destDir");
    Files.createDirectory(dest);
    mockServer.addStringResponse("/api/plugins/installed", "{\"plugins\": [" + "{\"key\": \"typescript\", \"hash\": \"de5308f43260d357acc97712ce4c5475\", \"filename\": \"sonar-typescript-plugin-1.9.0.3766.jar\", \"sonarLintSupported\": true}" + "]}");
    mockServer.addStringResponse("/api/plugins/download?plugin=typescript", "content-ts");
    underTest = new PluginsSynchronizer(Set.of(Language.TS), 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("typescript", "de5308f43260d357acc97712ce4c5475", "sonar-typescript-plugin-1.9.0.3766.jar"));
    assertThat(dest.resolve("sonar-typescript-plugin-1.9.0.3766.jar")).hasContent("content-ts");
    assertThat(anyPluginUpdated).isTrue();
}
Also used : ProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor) ServerApi(org.sonarsource.sonarlint.core.serverapi.ServerApi) Test(org.junit.jupiter.api.Test)

Example 13 with ProgressMonitor

use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.

the class PluginsSynchronizerTests method should_not_synchronize_plugins_with_unsupported_version.

@Test
void should_not_synchronize_plugins_with_unsupported_version(@TempDir Path dest) {
    mockServer.addStringResponse("/api/plugins/installed", "{\"plugins\": [" + "{\"key\": \"java\", \"hash\": \"de5308f43260d357acc97712ce4c5475\", \"filename\": \"sonar-java-plugin-5.12.0.jar\", \"sonarLintSupported\": true}" + "]}");
    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.12.0.jar")).doesNotExist();
    assertThat(anyPluginUpdated).isFalse();
}
Also used : ProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor) ServerApi(org.sonarsource.sonarlint.core.serverapi.ServerApi) Test(org.junit.jupiter.api.Test)

Example 14 with ProgressMonitor

use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.

the class PluginsSynchronizerTests method should_not_synchronize_plugins_for_not_enabled_languages.

@Test
void should_not_synchronize_plugins_for_not_enabled_languages(@TempDir Path tmp) {
    var dest = tmp.resolve("destDir");
    mockServer.addStringResponse("/api/plugins/installed", "{\"plugins\": [" + "{\"key\": \"java\", \"hash\": \"de5308f43260d357acc97712ce4c5475\", \"filename\": \"sonar-java-plugin-5.13.1.18282.jar\", \"sonarLintSupported\": true}" + "]}");
    underTest = new PluginsSynchronizer(Set.of(Language.JS), new PluginsStorage(dest), emptySet());
    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();
}
Also used : ProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor) ServerApi(org.sonarsource.sonarlint.core.serverapi.ServerApi) Test(org.junit.jupiter.api.Test)

Example 15 with ProgressMonitor

use of org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor in project sonarlint-core by SonarSource.

the class PluginsSynchronizerTests method should_not_synchronize_embedded_plugins.

@Test
void should_not_synchronize_embedded_plugins(@TempDir Path dest) {
    mockServer.addStringResponse("/api/plugins/installed", "{\"plugins\": [" + "{\"key\": \"java\", \"hash\": \"de5308f43260d357acc97712ce4c5475\", \"filename\": \"sonar-java-plugin-5.13.1.18282.jar\", \"sonarLintSupported\": true}" + "]}");
    underTest = new PluginsSynchronizer(Set.of(Language.JAVA), new PluginsStorage(dest), Set.of("java"));
    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();
}
Also used : ProgressMonitor(org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor) ServerApi(org.sonarsource.sonarlint.core.serverapi.ServerApi) Test(org.junit.jupiter.api.Test)

Aggregations

ProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor)20 Test (org.junit.jupiter.api.Test)14 ServerApi (org.sonarsource.sonarlint.core.serverapi.ServerApi)12 ClientProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor)5 ServerApiHelper (org.sonarsource.sonarlint.core.serverapi.ServerApiHelper)4 AnalysisResults (org.sonarsource.sonarlint.core.analysis.api.AnalysisResults)2 AnalyzeCommand (org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand)2 SonarLintWrappedException (org.sonarsource.sonarlint.core.client.api.exceptions.SonarLintWrappedException)2 StorageException (org.sonarsource.sonarlint.core.client.api.exceptions.StorageException)2 ServerProjectsStore (org.sonarsource.sonarlint.core.container.storage.ServerProjectsStore)2 StorageFolder (org.sonarsource.sonarlint.core.container.storage.StorageFolder)2 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 DefaultClientIssue (org.sonarsource.sonarlint.core.client.api.common.analysis.DefaultClientIssue)1 UpdateResult (org.sonarsource.sonarlint.core.client.api.connected.UpdateResult)1 DownloadException (org.sonarsource.sonarlint.core.client.api.exceptions.DownloadException)1 AuthenticationChecker (org.sonarsource.sonarlint.core.serverapi.authentication.AuthenticationChecker)1 ServerOrganization (org.sonarsource.sonarlint.core.serverapi.organization.ServerOrganization)1 DefaultValidationResult (org.sonarsource.sonarlint.core.serverapi.system.DefaultValidationResult)1 ServerVersionAndStatusChecker (org.sonarsource.sonarlint.core.serverapi.system.ServerVersionAndStatusChecker)1