Search in sources :

Example 1 with RemotePlugin

use of org.sonar.core.platform.RemotePlugin in project sonarqube by SonarSource.

the class ScannerPluginInstaller method loadPlugins.

private Map<String, PluginInfo> loadPlugins(List<RemotePlugin> remotePlugins) {
    Map<String, PluginInfo> infosByKey = new HashMap<>(remotePlugins.size());
    Profiler profiler = Profiler.create(LOG).startDebug("Load plugins");
    for (RemotePlugin remotePlugin : remotePlugins) {
        if (pluginPredicate.apply(remotePlugin.getKey())) {
            File jarFile = download(remotePlugin);
            PluginInfo info = PluginInfo.create(jarFile);
            infosByKey.put(info.getKey(), info);
        }
    }
    profiler.stopDebug();
    return infosByKey;
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) HashMap(java.util.HashMap) RemotePlugin(org.sonar.core.platform.RemotePlugin) PluginInfo(org.sonar.core.platform.PluginInfo) RemotePluginFile(org.sonar.core.platform.RemotePluginFile) File(java.io.File)

Example 2 with RemotePlugin

use of org.sonar.core.platform.RemotePlugin in project sonarqube by SonarSource.

the class ScannerPluginInstallerTest method listRemotePlugins.

@Test
public void listRemotePlugins() {
    WsTestUtil.mockReader(wsClient, "/deploy/plugins/index.txt", new StringReader("checkstyle\nsqale"));
    ScannerPluginInstaller underTest = new ScannerPluginInstaller(wsClient, fileCache, pluginPredicate);
    List<RemotePlugin> remotePlugins = underTest.listRemotePlugins();
    assertThat(remotePlugins).extracting("key").containsOnly("checkstyle", "sqale");
}
Also used : RemotePlugin(org.sonar.core.platform.RemotePlugin) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 3 with RemotePlugin

use of org.sonar.core.platform.RemotePlugin in project sonarqube by SonarSource.

the class ScannerPluginInstallerTest method should_download_plugin.

@Test
public void should_download_plugin() throws Exception {
    File pluginJar = temp.newFile();
    when(fileCache.get(eq("checkstyle-plugin.jar"), eq("fakemd5_1"), any(FileCache.Downloader.class))).thenReturn(pluginJar);
    ScannerPluginInstaller underTest = new ScannerPluginInstaller(wsClient, fileCache, pluginPredicate);
    RemotePlugin remote = new RemotePlugin("checkstyle").setFile("checkstyle-plugin.jar", "fakemd5_1");
    File file = underTest.download(remote);
    assertThat(file).isEqualTo(pluginJar);
}
Also used : RemotePlugin(org.sonar.core.platform.RemotePlugin) File(java.io.File) Test(org.junit.Test)

Aggregations

RemotePlugin (org.sonar.core.platform.RemotePlugin)3 File (java.io.File)2 Test (org.junit.Test)2 StringReader (java.io.StringReader)1 HashMap (java.util.HashMap)1 Profiler (org.sonar.api.utils.log.Profiler)1 PluginInfo (org.sonar.core.platform.PluginInfo)1 RemotePluginFile (org.sonar.core.platform.RemotePluginFile)1