Search in sources :

Example 1 with PluginReferences

use of org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences in project sonarlint-core by SonarSource.

the class PluginReferencesDownloaderTest method filter_not_compatible.

@Test
public void filter_not_compatible() throws Exception {
    pluginList.add(new DefaultSonarAnalyzer("scmsvn", "sonar-scm-svn-plugin-1.3-SNAPSHOT.jar", "d0a68d150314d96d3469e0f2246f3537", "1.3-SNAPSHOT", false));
    pluginList.add(new DefaultSonarAnalyzer("javascript", "sonar-javascript-plugin-2.10.jar", "79dba9cab72d8d31767f47c03d169598", "2.10", true));
    pluginList.add(new DefaultSonarAnalyzer("csharp", "sonar-csharp-plugin-4.4.jar", "e78bc8ac2e376c4a7a2a2cae914bdc52", "4.4", false));
    pluginList.add(new DefaultSonarAnalyzer("groovy", "sonar-groovy-plugin-1.2.jar", "14908dd5f3a9b9d795dbc103f0af546f", "1.2", true));
    pluginList.add(new DefaultSonarAnalyzer("java", "sonar-java-plugin-3.12-SNAPSHOT.jar", "de5308f43260d357acc97712ce4c5475", "3.12-SNAPSHOT", true));
    PluginReferencesDownloader pluginUpdate = new PluginReferencesDownloader(wsClient, pluginCache);
    pluginUpdate.fetchPluginsTo(dest, pluginList);
    PluginReferences pluginReferences = ProtobufUtil.readFile(dest.resolve(StoragePaths.PLUGIN_REFERENCES_PB), PluginReferences.parser());
    assertThat(pluginReferences.getReferenceList()).extracting("key", "hash", "filename").containsOnly(tuple("java", "de5308f43260d357acc97712ce4c5475", "sonar-java-plugin-3.12-SNAPSHOT.jar"), tuple("groovy", "14908dd5f3a9b9d795dbc103f0af546f", "sonar-groovy-plugin-1.2.jar"), tuple("javascript", "79dba9cab72d8d31767f47c03d169598", "sonar-javascript-plugin-2.10.jar"));
    verify(pluginCache).get(eq("sonar-java-plugin-3.12-SNAPSHOT.jar"), eq("de5308f43260d357acc97712ce4c5475"), any(Copier.class));
}
Also used : PluginReferences(org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences) DefaultSonarAnalyzer(org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer) Copier(org.sonarsource.sonarlint.core.plugin.cache.PluginCache.Copier) Test(org.junit.Test)

Example 2 with PluginReferences

use of org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences in project sonarlint-core by SonarSource.

the class PluginReferencesDownloaderTest method filter_minimum_version.

@Test
public void filter_minimum_version() throws Exception {
    pluginList.add(new DefaultSonarAnalyzer("scmsvn", "sonar-scm-svn-plugin-1.3-SNAPSHOT.jar", "d0a68d150314d96d3469e0f2246f3537", "1.3-SNAPSHOT", true));
    pluginList.add(new DefaultSonarAnalyzer("javascript", "sonar-javascript-plugin-2.10.jar", "79dba9cab72d8d31767f47c03d169598", "2.10", true));
    pluginList.add(new DefaultSonarAnalyzer("csharp", "sonar-csharp-plugin-4.4.jar", "e78bc8ac2e376c4a7a2a2cae914bdc52", "4.4", true));
    pluginList.add(new DefaultSonarAnalyzer("groovy", "sonar-groovy-plugin-1.2.jar", "14908dd5f3a9b9d795dbc103f0af546f", "1.2", true));
    DefaultSonarAnalyzer java = new DefaultSonarAnalyzer("java", "sonar-java-plugin-3.12-SNAPSHOT.jar", "de5308f43260d357acc97712ce4c5475", "3.12-SNAPSHOT", true);
    java.minimumVersion("3.13");
    pluginList.add(java);
    pluginUpdate.fetchPluginsTo(dest, pluginList);
    PluginReferences pluginReferences = ProtobufUtil.readFile(dest.resolve(StoragePaths.PLUGIN_REFERENCES_PB), PluginReferences.parser());
    assertThat(pluginReferences.getReferenceList()).extracting("key", "hash", "filename").containsOnly(tuple("scmsvn", "d0a68d150314d96d3469e0f2246f3537", "sonar-scm-svn-plugin-1.3-SNAPSHOT.jar"), tuple("javascript", "79dba9cab72d8d31767f47c03d169598", "sonar-javascript-plugin-2.10.jar"), tuple("csharp", "e78bc8ac2e376c4a7a2a2cae914bdc52", "sonar-csharp-plugin-4.4.jar"), tuple("groovy", "14908dd5f3a9b9d795dbc103f0af546f", "sonar-groovy-plugin-1.2.jar"));
}
Also used : PluginReferences(org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences) DefaultSonarAnalyzer(org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer) Test(org.junit.Test)

Example 3 with PluginReferences

use of org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences in project sonarlint-core by SonarSource.

the class PluginReferencesDownloader method fetchPluginsTo.

public PluginReferences fetchPluginsTo(Path dest, List<SonarAnalyzer> analyzers) {
    PluginReferences refs = fetchPlugins(analyzers);
    for (PluginReference ref : refs.getReferenceList()) {
        pluginCache.get(ref.getFilename(), ref.getHash(), new SonarQubeServerPluginDownloader(ref.getKey()));
    }
    ProtobufUtil.writeToFile(refs, dest.resolve(StoragePaths.PLUGIN_REFERENCES_PB));
    return refs;
}
Also used : PluginReferences(org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences) PluginReference(org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences.PluginReference)

Example 4 with PluginReferences

use of org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences in project sonarlint-core by SonarSource.

the class PluginsUpdateChecker method checkForUpdates.

public void checkForUpdates(DefaultStorageUpdateCheckResult result, List<SonarAnalyzer> pluginList) {
    PluginReferences serverPluginReferences = pluginReferenceDownloader.fetchPlugins(pluginList);
    PluginReferences storagePluginReferences = storageReader.readPluginReferences();
    Map<String, String> serverPluginHashes = serverPluginReferences.getReferenceList().stream().collect(Collectors.toMap(PluginReference::getKey, PluginReference::getHash));
    Map<String, String> storagePluginHashes = storagePluginReferences.getReferenceList().stream().collect(Collectors.toMap(PluginReference::getKey, PluginReference::getHash));
    MapDifference<String, String> pluginDiff = Maps.difference(storagePluginHashes, serverPluginHashes);
    if (!pluginDiff.areEqual()) {
        for (Map.Entry<String, String> entry : pluginDiff.entriesOnlyOnLeft().entrySet()) {
            result.appendToChangelog(String.format("Plugin '%s' removed", entry.getKey()));
        }
        for (Map.Entry<String, String> entry : pluginDiff.entriesOnlyOnRight().entrySet()) {
            result.appendToChangelog("Plugin '" + entry.getKey() + "' added");
        }
        for (Map.Entry<String, ValueDifference<String>> entry : pluginDiff.entriesDiffering().entrySet()) {
            result.appendToChangelog("Plugin '" + entry.getKey() + "' updated");
        }
    }
}
Also used : PluginReferences(org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences) ValueDifference(com.google.common.collect.MapDifference.ValueDifference) Map(java.util.Map)

Example 5 with PluginReferences

use of org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences in project sonarlint-core by SonarSource.

the class PluginReferencesDownloaderTest method update_all_plugins_before_6_0.

@Test
public void update_all_plugins_before_6_0() throws Exception {
    pluginList.add(new DefaultSonarAnalyzer("scmsvn", "sonar-scm-svn-plugin-1.3-SNAPSHOT.jar", "d0a68d150314d96d3469e0f2246f3537", "1.3-SNAPSHOT", true));
    pluginList.add(new DefaultSonarAnalyzer("javascript", "sonar-javascript-plugin-2.10.jar", "79dba9cab72d8d31767f47c03d169598", "2.10", true));
    pluginList.add(new DefaultSonarAnalyzer("csharp", "sonar-csharp-plugin-4.4.jar", "e78bc8ac2e376c4a7a2a2cae914bdc52", "4.4", true));
    pluginList.add(new DefaultSonarAnalyzer("groovy", "sonar-groovy-plugin-1.2.jar", "14908dd5f3a9b9d795dbc103f0af546f", "1.2", true));
    pluginList.add(new DefaultSonarAnalyzer("java", "sonar-java-plugin-3.12-SNAPSHOT.jar", "de5308f43260d357acc97712ce4c5475", "3.12-SNAPSHOT", true));
    pluginUpdate.fetchPluginsTo(dest, pluginList);
    PluginReferences pluginReferences = ProtobufUtil.readFile(dest.resolve(StoragePaths.PLUGIN_REFERENCES_PB), PluginReferences.parser());
    assertThat(pluginReferences.getReferenceList()).extracting("key", "hash", "filename").containsOnly(tuple("scmsvn", "d0a68d150314d96d3469e0f2246f3537", "sonar-scm-svn-plugin-1.3-SNAPSHOT.jar"), tuple("javascript", "79dba9cab72d8d31767f47c03d169598", "sonar-javascript-plugin-2.10.jar"), tuple("csharp", "e78bc8ac2e376c4a7a2a2cae914bdc52", "sonar-csharp-plugin-4.4.jar"), tuple("groovy", "14908dd5f3a9b9d795dbc103f0af546f", "sonar-groovy-plugin-1.2.jar"), tuple("java", "de5308f43260d357acc97712ce4c5475", "sonar-java-plugin-3.12-SNAPSHOT.jar"));
    verify(pluginCache).get(eq("sonar-java-plugin-3.12-SNAPSHOT.jar"), eq("de5308f43260d357acc97712ce4c5475"), any(Copier.class));
    ArgumentCaptor<Copier> downloaderCaptor = ArgumentCaptor.forClass(Copier.class);
    verify(pluginCache).get(eq("sonar-java-plugin-3.12-SNAPSHOT.jar"), eq("de5308f43260d357acc97712ce4c5475"), downloaderCaptor.capture());
    Copier downloader = downloaderCaptor.getValue();
    WsClientTestUtils.addResponse(wsClient, "/deploy/plugins/java/test.jar", "content");
    Path testFile = temp.newFile().toPath();
    downloader.copy("test.jar", testFile);
    assertThat(testFile).hasContent("content");
}
Also used : PluginReferences(org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences) Path(java.nio.file.Path) DefaultSonarAnalyzer(org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer) Copier(org.sonarsource.sonarlint.core.plugin.cache.PluginCache.Copier) Test(org.junit.Test)

Aggregations

PluginReferences (org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences)5 Test (org.junit.Test)3 DefaultSonarAnalyzer (org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer)3 Copier (org.sonarsource.sonarlint.core.plugin.cache.PluginCache.Copier)2 ValueDifference (com.google.common.collect.MapDifference.ValueDifference)1 Path (java.nio.file.Path)1 Map (java.util.Map)1 PluginReference (org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences.PluginReference)1