From 51e6a276a3ab5b3538b469d75c8afea8bb4a581d Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Mon, 1 Nov 2010 18:25:45 +0000 Subject: [PATCH] improve layout of update center --- .../org/sonar/server/platform/Platform.java | 2 +- .../server/plugins/UpdateCenterClient.java | 13 +- ...ateFinder.java => UpdateCenterMatrix.java} | 41 ++-- ...ry.java => UpdateCenterMatrixFactory.java} | 21 +- .../java/org/sonar/server/ui/JRubyFacade.java | 18 +- .../controllers/updatecenter_controller.rb | 23 +-- .../app/helpers/updatecenter_helper.rb | 2 +- .../app/views/layouts/_layout.html.erb | 4 +- .../app/views/updatecenter/_list.html.erb | 45 ----- .../views/updatecenter/_operations.html.erb | 11 +- .../app/views/updatecenter/_status.html.erb | 14 +- .../app/views/updatecenter/available.html.erb | 40 ++-- .../app/views/updatecenter/index.html.erb | 2 +- .../app/views/updatecenter/updates.html.erb | 180 +++++++++++------- ...rTest.java => UpdateCenterMatrixTest.java} | 54 +++--- 15 files changed, 252 insertions(+), 218 deletions(-) rename sonar-server/src/main/java/org/sonar/server/plugins/{UpdateFinder.java => UpdateCenterMatrix.java} (78%) rename sonar-server/src/main/java/org/sonar/server/plugins/{UpdateFinderFactory.java => UpdateCenterMatrixFactory.java} (74%) rename sonar-server/src/test/java/org/sonar/server/plugins/{UpdateFinderTest.java => UpdateCenterMatrixTest.java} (74%) diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index a268efc3766..9cec2e85564 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -135,7 +135,7 @@ public final class Platform { coreContainer.as(Characteristics.CACHE).addComponent(ThreadLocalDatabaseSessionFactory.class); coreContainer.as(Characteristics.CACHE).addComponent(HttpDownloader.class); coreContainer.as(Characteristics.CACHE).addComponent(UpdateCenterClient.class); - coreContainer.as(Characteristics.CACHE).addComponent(UpdateFinderFactory.class); + coreContainer.as(Characteristics.CACHE).addComponent(UpdateCenterMatrixFactory.class); coreContainer.as(Characteristics.CACHE).addComponent(PluginDownloader.class); coreContainer.as(Characteristics.NO_CACHE).addComponent(FilterExecutor.class); coreContainer.as(Characteristics.NO_CACHE).addAdapter(new DatabaseSessionProvider()); diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java index 575ba0799c7..f46baa4f42c 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java @@ -30,11 +30,12 @@ import org.sonar.updatecenter.common.UpdateCenterDeserializer; import java.io.InputStream; import java.net.URI; +import java.util.Date; import java.util.Properties; /** * HTTP client to load data from the remote update center hosted at http://update.sonarsource.org. - * @since 2.2 + * @since 2.4 */ public class UpdateCenterClient implements ServerComponent { @@ -44,7 +45,7 @@ public class UpdateCenterClient implements ServerComponent { private String url; private UpdateCenter center = null; - private long downloadDate = 0; + private long lastRefreshDate = 0; private HttpDownloader downloader; /** @@ -67,13 +68,17 @@ public class UpdateCenterClient implements ServerComponent { public UpdateCenter getCenter(boolean forceRefresh) { if (center == null || forceRefresh || needsRefresh()) { center = download(); - downloadDate = System.currentTimeMillis(); + lastRefreshDate = System.currentTimeMillis(); } return center; } + public Date getLastRefreshDate() { + return lastRefreshDate >0 ? new Date(lastRefreshDate) : null; + } + private boolean needsRefresh() { - return downloadDate + PERIOD_IN_MILLISECONDS < System.currentTimeMillis(); + return lastRefreshDate + PERIOD_IN_MILLISECONDS < System.currentTimeMillis(); } private UpdateCenter download() { diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinder.java b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java similarity index 78% rename from sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinder.java rename to sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java index c18c94b5a32..a5c698539c3 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinder.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java @@ -19,23 +19,29 @@ */ package org.sonar.server.plugins; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.sonar.updatecenter.common.*; -import java.util.*; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; -public final class UpdateFinder { +public final class UpdateCenterMatrix { private UpdateCenter center; private Version installedSonarVersion; - private Map installedPlugins = new HashMap(); - private List pendingPluginFilenames = new ArrayList(); + private Map installedPlugins = Maps.newHashMap(); + private List pendingPluginFilenames = Lists.newArrayList(); + private Date date; - public UpdateFinder(UpdateCenter center, Version installedSonarVersion) { + public UpdateCenterMatrix(UpdateCenter center, Version installedSonarVersion) { this.center = center; this.installedSonarVersion = installedSonarVersion; } - public UpdateFinder(UpdateCenter center, String installedSonarVersion) { + public UpdateCenterMatrix(UpdateCenter center, String installedSonarVersion) { this(center, Version.create(installedSonarVersion)); } @@ -47,7 +53,7 @@ public final class UpdateFinder { return installedSonarVersion; } - public UpdateFinder registerInstalledPlugin(String pluginKey, Version pluginVersion) { + public UpdateCenterMatrix registerInstalledPlugin(String pluginKey, Version pluginVersion) { Plugin plugin = center.getPlugin(pluginKey); if (plugin != null) { installedPlugins.put(plugin, pluginVersion); @@ -55,15 +61,15 @@ public final class UpdateFinder { return this; } - public UpdateFinder registerPendingPluginsByFilename(String filename) { + public UpdateCenterMatrix registerPendingPluginsByFilename(String filename) { pendingPluginFilenames.add(filename); return this; } public List findAvailablePlugins() { - List availables = new ArrayList(); + List availables = Lists.newArrayList(); for (Plugin plugin : center.getPlugins()) { - if ( !installedPlugins.containsKey(plugin) && !isAlreadyDownloaded(plugin)) { + if (!installedPlugins.containsKey(plugin) && !isAlreadyDownloaded(plugin)) { Release release = plugin.getLastCompatibleRelease(installedSonarVersion); if (release != null) { availables.add(PluginUpdate.createWithStatus(release, PluginUpdate.Status.COMPATIBLE)); @@ -90,10 +96,10 @@ public final class UpdateFinder { } public List findPluginUpdates() { - List updates = new ArrayList(); + List updates = Lists.newArrayList(); for (Map.Entry entry : installedPlugins.entrySet()) { Plugin plugin = entry.getKey(); - if ( !isAlreadyDownloaded(plugin)) { + if (!isAlreadyDownloaded(plugin)) { Version pluginVersion = entry.getValue(); for (Release release : plugin.getReleasesGreaterThan(pluginVersion)) { updates.add(PluginUpdate.createForPluginRelease(release, installedSonarVersion)); @@ -104,7 +110,7 @@ public final class UpdateFinder { } public List findSonarUpdates() { - List updates = new ArrayList(); + List updates = Lists.newArrayList(); SortedSet releases = center.getSonar().getReleasesGreaterThan(installedSonarVersion); for (Release release : releases) { updates.add(createSonarUpdate(release)); @@ -144,4 +150,13 @@ public final class UpdateFinder { } return update; } + + public Date getDate() { + return date; + } + + public UpdateCenterMatrix setDate(Date d) { + this.date = d; + return this; + } } diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinderFactory.java b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java similarity index 74% rename from sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinderFactory.java rename to sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java index 0963112fb25..6e33ace2d42 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinderFactory.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java @@ -26,33 +26,38 @@ import org.sonar.api.platform.Server; import org.sonar.updatecenter.common.UpdateCenter; import org.sonar.updatecenter.common.Version; -public final class UpdateFinderFactory implements ServerComponent { +/** + * @since 2.4 + */ +public final class UpdateCenterMatrixFactory implements ServerComponent { private UpdateCenterClient centerClient; private JpaPluginDao dao; private Version sonarVersion; private PluginDownloader downloader; - public UpdateFinderFactory(UpdateCenterClient centerClient, JpaPluginDao dao, Server server, PluginDownloader downloader) { + public UpdateCenterMatrixFactory(UpdateCenterClient centerClient, JpaPluginDao dao, Server server, PluginDownloader downloader) { this.centerClient = centerClient; this.dao = dao; this.sonarVersion = Version.create(server.getVersion()); this.downloader = downloader; } - public UpdateFinder getFinder(boolean refresh) { + public UpdateCenterMatrix getMatrix(boolean refresh) { UpdateCenter center = centerClient.getCenter(refresh); - UpdateFinder finder = null; + UpdateCenterMatrix matrix = null; if (center != null) { - finder = new UpdateFinder(center, sonarVersion); + matrix = new UpdateCenterMatrix(center, sonarVersion); + matrix.setDate(centerClient.getLastRefreshDate()); + for (JpaPlugin plugin : dao.getPlugins()) { - finder.registerInstalledPlugin(plugin.getKey(), Version.create(plugin.getVersion())); + matrix.registerInstalledPlugin(plugin.getKey(), Version.create(plugin.getVersion())); } for (String filename : downloader.getDownloads()) { - finder.registerPendingPluginsByFilename(filename); + matrix.registerPendingPluginsByFilename(filename); } } - return finder; + return matrix; } } diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index f5dc477cd43..883f5e34b63 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -47,11 +47,8 @@ import org.sonar.server.filters.Filter; import org.sonar.server.filters.FilterExecutor; import org.sonar.server.filters.FilterResult; import org.sonar.server.platform.Platform; -import org.sonar.server.plugins.PluginClassLoaders; -import org.sonar.server.plugins.PluginDeployer; -import org.sonar.server.plugins.PluginDownloader; -import org.sonar.server.plugins.UpdateFinder; -import org.sonar.server.plugins.UpdateFinderFactory; +import org.sonar.server.plugins.*; +import org.sonar.server.plugins.UpdateCenterMatrix; import org.sonar.server.rules.ProfilesConsole; import org.sonar.server.rules.RulesConsole; import org.sonar.updatecenter.common.Version; @@ -65,7 +62,8 @@ public final class JRubyFacade implements ServerComponent { return getContainer().getComponent(FilterExecutor.class).execute(filter); } - /* PLUGINS */ + /* UPDATE CENTER */ + public void downloadPlugin(String pluginKey, String pluginVersion) { getContainer().getComponent(PluginDownloader.class).download(pluginKey, Version.create(pluginVersion)); } @@ -90,10 +88,14 @@ public final class JRubyFacade implements ServerComponent { return getContainer().getComponent(PluginDeployer.class).getUninstalls(); } - public UpdateFinder getUpdateFinder(boolean forceReload) { - return getContainer().getComponent(UpdateFinderFactory.class).getFinder(forceReload); + public UpdateCenterMatrix getUpdateCenterMatrix(boolean forceReload) { + return getContainer().getComponent(UpdateCenterMatrixFactory.class).getMatrix(forceReload); } + + + + public String colorizeCode(String code, String language) { try { return getContainer().getComponent(CodeColorizers.class).toHtml(code, language); diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb index 6a84b0fa634..429602cc5fb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb @@ -38,6 +38,7 @@ class UpdatecenterController < ApplicationController @downloads=java_facade.getPluginDownloads() @center=nil + @matrix=nil @sonar_updates=[] @updates_by_plugin={} @user_plugins={} @@ -47,12 +48,12 @@ class UpdatecenterController < ApplicationController @user_plugins[plugin.plugin_key]=plugin.version end - finder=load_update_finder() - if finder - @center=finder.getCenter() - @sonar_updates=finder.findSonarUpdates() + load_matrix() + if @matrix + @center=@matrix.getCenter() + @sonar_updates=@matrix.findSonarUpdates() - @finder.findPluginUpdates().each do |update| + @matrix.findPluginUpdates().each do |update| plugin=update.getPlugin() @updates_by_plugin[plugin]||=[] @updates_by_plugin[plugin]<System
  • Settings
  • Backup
  • -
  • System info
  • +
  • System Info
  • <% update_center_activated = controller.java_facade.getConfigurationValue('sonar.updatecenter.activate') || 'true'; if update_center_activated=='true' %> -
  • Upgrades (BETA)
  • +
  • Update Center
  • <% end %> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb index ec8a5b7efa2..e69de29bb2d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb @@ -1,45 +0,0 @@ -<% updates.each do |update| - release=update.getRelease() -%> - - <%= 'Sonar' if !plugin -%> <%= release.getVersion() -%> - <%= release_date(release.getDate()) if release.getDate() -%> - <%= release.getDescription() -%> - - <%= link_to 'Release Notes', release.getChangelogUrl(), :class => 'external' if release.getChangelogUrl() %>   - <%= link_to 'Download', release.getDownloadUrl(), :class => 'external' if !plugin && release.getDownloadUrl() %> - - <% if plugin %> - - <% if update.isIncompatible() %> - not compatible - <% elsif update.requiresSonarUpgrade %> - not compatible, needs Sonar upgrade - <% end %> - - <% else %> - - <% if update.hasWarnings() %> - <% if update.isIncompatible() %> - Those plugins not compatible and must be uninstalled before Sonar upgrade: -
      - <% update.getIncompatiblePlugins().each do |plugin| %> -
    • <%= plugin.getName() -%>
    • - <% end %> -
    - <% end %> - <% if update.requiresPluginUpgrades() %> - Those plugins must be upgraded: -
      - <% update.getPluginsToUpgrade().each do |plugin| %> -
    • <%= plugin.getArtifact().getName() -%> to <%= plugin.getVersion() -%>
    • - <% end %> -
    - <% end %> - <% else %> - All installed plugins are compatible - <% end %> - - <% end %> - -<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb index 2a72d44f3f7..a46d5e60fa6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb @@ -7,15 +7,6 @@ } return false; } - - function checkTermsConditions(key) { - var tc=$('tc-' + key) - if (tc!=null && !tc.checked) { - alert('Please accept the Terms and Conditions'); - return false; - } - return true; - } <% if @uninstalls.size > 0 %> @@ -37,7 +28,7 @@
  • <%= download -%>
  • <% end %> - +

    <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_status.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_status.html.erb index a6defc2d88b..00f473ee3a1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_status.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_status.html.erb @@ -1,7 +1,7 @@ -

    - <% if @center.nil? %> -

    Not connected to update center. Please check your internet connection and logs.

    - <% else %> - Updated on <%= @center.getDate() %>. <%= link_to 'Refresh', :action => action, :reload => true %> - <% end %> -

    +<% if @center.nil? %> +

    Not connected to update center. Please check your internet connection and logs.

    +<% else %> +

    + Updated on <%= @matrix.getDate() -%>. <%= link_to 'Refresh', :action => action, :reload => true %> +

    +<% end %> \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb index 3b17d550e92..e4ccf1b0b5a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb @@ -1,3 +1,18 @@ + +
    • Installed @@ -13,22 +28,22 @@ <%= render :partial => 'updatecenter/operations' -%> - - - - <% if @center %> <% @updates_by_category.keys.sort_by{|c| c.downcase }.each do |category| updates=@updates_by_category[category] %> - - - +

      <%= category -%>

      + + + + + + <% updates.sort_by{|c| c.getPlugin().getName()}.each do |update| plugin=update.getPlugin() %> - <% end %> + +

      <%= category -%>

      + <%= h(plugin.getName()) -%> @@ -64,8 +79,8 @@ <% if plugin.getTermsConditionsUrl() %> I accept the <%= link_to 'Terms and Conditions', plugin.getTermsConditionsUrl(), :class => 'external' %> <% end %> -
      - + +
      <% elsif update.requiresSonarUpgrade @@ -80,10 +95,11 @@
      +
      <% end %> <% end %> - -
      <%= render :partial => 'updatecenter/status', :locals => {:action => 'available' } %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb index 71996d7453f..ff599694e49 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb @@ -15,7 +15,7 @@ - + diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb index b9f9d636f51..58f7fca5504 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb @@ -1,72 +1,116 @@ - -
      + +
      -<%= render :partial => 'updatecenter/operations' -%> + <%= render :partial => 'updatecenter/operations' -%> -<% if @center %> -

      User-installed plugins

      Plugins

      Plugin Version
      - - - - - <% if @updates_by_plugin.empty? %> - - - - <% end %> - <% @updates_by_plugin.keys.each do |plugin| - updates=@updates_by_plugin[plugin] - %> - - - - - <% end %> - -

      User-installed plugins

      No updates
      - <%= h(plugin.getName()) -%> - - Current version: <%= @user_plugins[plugin.getKey()] -%>, - last compatible: <%= @last_compatible[plugin.getKey()] -%>, - latest: <%= updates.last.getRelease().getVersion() -%> - -
      + <% if @center %> + + + + + + <% if @updates_by_plugin.empty? %> + + + + <% end %> + <% @updates_by_plugin.keys.each do |plugin| + css=cycle('even','odd', :name => 'user-plugins') + updates=@updates_by_plugin[plugin] + updates.each_with_index do |update, index| + release=update.getRelease() + %> + + + + + + + + + <% + end + %> + + + + + <% + end + %> + +

      Plugins

      No updates
      <% if index==0 %><%= h(plugin.getName()) -%> <%= @user_plugins[plugin.getKey()] -%> -> <% end %><%= release.getVersion() -%><%= release_date(release.getDate()) if release.getDate() -%><%= release.getDescription() -%><%= link_to 'Release Notes', release.getChangelogUrl(), :class => 'external' if release.getChangelogUrl() %> + <% if update.isIncompatible() %> + <%= image_tag 'warning.png' -%> Not compatible + <% elsif update.requiresSonarUpgrade %> + <%= image_tag 'warning.png' -%> Not compatible, requires to upgrade system + <% end %> +
      +
      + +
      +
      -
      +
      - - - - - - <% if @sonar_updates.empty? %> - - - - <% end %> - <%= render :partial => 'updatecenter/list', :locals => {:updates => @sonar_updates, :plugin => false } %> - -

      System

      No updates
      -
      -<% end %> -<%= render :partial => 'updatecenter/status', :locals => {:action => 'updates' } %> - + + + + + + <% if @sonar_updates.empty? %> + + + + <% end %> + + + + <% @sonar_updates.each do |update| + css=cycle('even','odd', :name => 'system') + release=update.getRelease() + %> + + + + + + + <% if update.hasWarnings() %> + + + + + <% end %> + <% end %> + +

      System

      No updates
      Sonar <%= release.getVersion() -%><%= release_date(release.getDate()) if release.getDate() -%><%= release.getDescription() -%> + <%= link_to 'Release Notes', release.getChangelogUrl(), :class => 'external' if release.getChangelogUrl() %>   + <%= link_to 'Download', release.getDownloadUrl(), :class => 'external' if release.getDownloadUrl() %> +
      + <% if update.isIncompatible() %> + <%= image_tag 'warning.png' -%> Not compatible plugins must be uninstalled before upgrading system: + <%= update.getIncompatiblePlugins().map{|plugin| plugin.getName()}.sort.join(',') -%> + <% end %> + <% if update.requiresPluginUpgrades() %> + <%= image_tag 'warning.png' -%> Following plugins must be upgraded before upgrading system: +
        + <% update.getPluginsToUpgrade().each do |plugin| %> +
      • <%= plugin.getArtifact().getName() -%> to <%= plugin.getVersion() -%>
      • + <% end %> +
      + <% end %> +
      + <% end %> + <%= render :partial => 'updatecenter/status', :locals => {:action => 'updates' } %> + diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/UpdateFinderTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterMatrixTest.java similarity index 74% rename from sonar-server/src/test/java/org/sonar/server/plugins/UpdateFinderTest.java rename to sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterMatrixTest.java index db453d1b515..b8c162acdc8 100644 --- a/sonar-server/src/test/java/org/sonar/server/plugins/UpdateFinderTest.java +++ b/sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterMatrixTest.java @@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -public class UpdateFinderTest { +public class UpdateCenterMatrixTest { private UpdateCenter center; private Plugin foo; @@ -66,9 +66,9 @@ public class UpdateFinderTest { @Test public void findPluginUpdates() { - UpdateFinder finder = new UpdateFinder(center, "2.1"); - finder.registerInstalledPlugin("foo", Version.create("1.0")); - List updates = finder.findPluginUpdates(); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.1"); + matrix.registerInstalledPlugin("foo", Version.create("1.0")); + List updates = matrix.findPluginUpdates(); assertThat(updates.size(), is(2)); assertThat(updates.get(0).getRelease(), is(foo11)); @@ -81,17 +81,17 @@ public class UpdateFinderTest { @Test public void noPluginUpdatesIfLastReleaseIsInstalled() { - UpdateFinder finder = new UpdateFinder(center, "2.3"); - finder.registerInstalledPlugin("foo", Version.create("1.2")); - assertTrue(finder.findPluginUpdates().isEmpty()); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.3"); + matrix.registerInstalledPlugin("foo", Version.create("1.2")); + assertTrue(matrix.findPluginUpdates().isEmpty()); } @Test public void availablePluginsAreOnlyTheBestReleases() { - UpdateFinder finder = new UpdateFinder(center, "2.2"); - finder.registerInstalledPlugin("foo", Version.create("1.0")); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.2"); + matrix.registerInstalledPlugin("foo", Version.create("1.0")); - List availables = finder.findAvailablePlugins(); + List availables = matrix.findAvailablePlugins(); // bar 1.0 is compatible with the installed sonar // bar 1.1 requires sonar to be upgraded to 2.2.2 or 2.3 @@ -103,10 +103,10 @@ public class UpdateFinderTest { @Test public void availablePluginsRequireSonarUpgrade() { - UpdateFinder finder = new UpdateFinder(center, "2.2.1"); - finder.registerInstalledPlugin("foo", Version.create("1.0")); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.2.1"); + matrix.registerInstalledPlugin("foo", Version.create("1.0")); - List availables = finder.findAvailablePlugins(); + List availables = matrix.findAvailablePlugins(); // bar 1.0 is not compatible with the installed sonar // bar 1.1 requires sonar to be upgraded to 2.2.2 or 2.3 @@ -121,8 +121,8 @@ public class UpdateFinderTest { center.getSonar().addRelease(Version.create("2.3")); center.getSonar().addRelease(Version.create("2.4")); - UpdateFinder finder = new UpdateFinder(center, "2.2"); - List updates = finder.findSonarUpdates(); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.2"); + List updates = matrix.findSonarUpdates(); // no plugins are installed, so both sonar versions are compatible assertThat(updates.size(), is(2)); @@ -135,10 +135,10 @@ public class UpdateFinderTest { center.getSonar().addRelease(Version.create("2.3")); center.getSonar().addRelease(Version.create("2.4")); - UpdateFinder finder = new UpdateFinder(center, "2.2"); - finder.registerInstalledPlugin("foo", Version.create("1.0")); - finder.registerInstalledPlugin("bar", Version.create("1.0")); - List updates = finder.findSonarUpdates(); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.2"); + matrix.registerInstalledPlugin("foo", Version.create("1.0")); + matrix.registerInstalledPlugin("bar", Version.create("1.0")); + List updates = matrix.findSonarUpdates(); assertThat(updates.size(), is(2)); @@ -156,19 +156,19 @@ public class UpdateFinderTest { @Test public void excludePendingDownloadsFromPluginUpdates() { - UpdateFinder finder = new UpdateFinder(center, "2.1"); - finder.registerInstalledPlugin("foo", Version.create("1.0")); - finder.registerPendingPluginsByFilename("foo-1.0.jar"); - List updates = finder.findPluginUpdates(); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.1"); + matrix.registerInstalledPlugin("foo", Version.create("1.0")); + matrix.registerPendingPluginsByFilename("foo-1.0.jar"); + List updates = matrix.findPluginUpdates(); assertThat(updates.size(), is(0)); } @Test public void excludePendingDownloadsFromAvailablePlugins() { - UpdateFinder finder = new UpdateFinder(center, "2.1"); - finder.registerPendingPluginsByFilename("foo-1.0.jar"); - finder.registerPendingPluginsByFilename("bar-1.1.jar"); - List updates = finder.findAvailablePlugins(); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.1"); + matrix.registerPendingPluginsByFilename("foo-1.0.jar"); + matrix.registerPendingPluginsByFilename("bar-1.1.jar"); + List updates = matrix.findAvailablePlugins(); assertThat(updates.size(), is(0)); } } -- 2.39.5