Search in sources :

Example 1 with DefaultSonarAnalyzer

use of org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer 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 DefaultSonarAnalyzer

use of org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer 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 DefaultSonarAnalyzer

use of org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer 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)

Example 4 with DefaultSonarAnalyzer

use of org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer in project sonarlint-core by SonarSource.

the class PluginListDownloader method downloadPluginListBefore66.

public List<SonarAnalyzer> downloadPluginListBefore66(Version serverVersion) {
    List<SonarAnalyzer> analyzers = new LinkedList<>();
    boolean compatibleFlagPresent = serverVersion.compareToIgnoreQualifier(Version.create("6.0")) >= 0;
    String responseStr;
    try (WsResponse response = wsClient.get(WS_PATH_LTS)) {
        responseStr = response.content();
    }
    Scanner scanner = new Scanner(responseStr);
    while (scanner.hasNextLine()) {
        String line = scanner.nextLine();
        String[] fields = StringUtils.split(line, ",");
        String[] nameAndHash = StringUtils.split(fields[fields.length - 1], "|");
        String key = fields[0];
        String filename = nameAndHash[0];
        String hash = nameAndHash[1];
        String version = VersionUtils.getJarVersion(filename);
        String minVersion = pluginVersionChecker.getMinimumVersion(key);
        boolean sonarlintCompatible = PluginCacheLoader.isWhitelisted(key) || !compatibleFlagPresent || "true".equals(fields[1]);
        DefaultSonarAnalyzer analyzer = new DefaultSonarAnalyzer(key, filename, hash, version, sonarlintCompatible, minVersion);
        analyzers.add(analyzer);
    }
    scanner.close();
    return analyzers;
}
Also used : Scanner(java.util.Scanner) DefaultSonarAnalyzer(org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer) SonarAnalyzer(org.sonarsource.sonarlint.core.client.api.connected.SonarAnalyzer) DefaultSonarAnalyzer(org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer) WsResponse(org.sonarsource.sonarlint.core.util.ws.WsResponse) LinkedList(java.util.LinkedList)

Aggregations

DefaultSonarAnalyzer (org.sonarsource.sonarlint.core.container.model.DefaultSonarAnalyzer)4 Test (org.junit.Test)3 PluginReferences (org.sonarsource.sonarlint.core.proto.Sonarlint.PluginReferences)3 Copier (org.sonarsource.sonarlint.core.plugin.cache.PluginCache.Copier)2 Path (java.nio.file.Path)1 LinkedList (java.util.LinkedList)1 Scanner (java.util.Scanner)1 SonarAnalyzer (org.sonarsource.sonarlint.core.client.api.connected.SonarAnalyzer)1 WsResponse (org.sonarsource.sonarlint.core.util.ws.WsResponse)1