Search in sources :

Example 21 with ServerApi

use of org.sonarsource.sonarlint.core.serverapi.ServerApi 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 22 with ServerApi

use of org.sonarsource.sonarlint.core.serverapi.ServerApi 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 23 with ServerApi

use of org.sonarsource.sonarlint.core.serverapi.ServerApi 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

ServerApi (org.sonarsource.sonarlint.core.serverapi.ServerApi)23 Test (org.junit.jupiter.api.Test)13 ProgressMonitor (org.sonarsource.sonarlint.core.commons.progress.ProgressMonitor)13 Test (org.junit.Test)5 HashMap (java.util.HashMap)3 ServerApiHelper (org.sonarsource.sonarlint.core.serverapi.ServerApiHelper)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Optional (java.util.Optional)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Set (java.util.Set)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1