Ignore:
Timestamp:
2016-01-24T15:06:37+01:00 (8 years ago)
Author:
Don-vip
Message:

update unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java

    r9078 r9611  
    8383        activePlugins.addAll(Main.pref.getCollection("plugins", activePlugins));
    8484        for (PluginInformation pi: availablePlugins) {
    85             if (selectedPluginsMap.get(pi) == null) {
    86                 if (activePlugins.contains(pi.name)) {
    87                     selectedPluginsMap.put(pi, Boolean.TRUE);
    88                 }
     85            if (selectedPluginsMap.get(pi) == null && activePlugins.contains(pi.name)) {
     86                selectedPluginsMap.put(pi, Boolean.TRUE);
    8987            }
    9088        }
     
    9492
    9593    protected void updateAvailablePlugin(PluginInformation other) {
    96         if (other == null) return;
    97         PluginInformation pi = getPluginInformation(other.name);
    98         if (pi == null) {
    99             availablePlugins.add(other);
    100             return;
    101         }
    102         pi.updateFromPluginSite(other);
     94        if (other != null) {
     95            PluginInformation pi = getPluginInformation(other.name);
     96            if (pi == null) {
     97                availablePlugins.add(other);
     98                return;
     99            }
     100            pi.updateFromPluginSite(other);
     101        }
    103102    }
    104103
     
    216215     */
    217216    public void clearPendingPlugins(Collection<PluginInformation> plugins) {
    218         if (plugins == null || plugins.isEmpty()) return;
    219         for (PluginInformation pi: plugins) {
    220             pendingDownloads.remove(pi.name);
     217        if (plugins != null) {
     218            for (PluginInformation pi: plugins) {
     219                pendingDownloads.remove(pi.name);
     220            }
    221221        }
    222222    }
     
    264264    public boolean isSelectedPlugin(String name) {
    265265        PluginInformation pi = getPluginInformation(name);
    266         if (pi == null) return false;
    267         if (selectedPluginsMap.get(pi) == null) return false;
     266        if (pi == null || selectedPluginsMap.get(pi) == null)
     267            return false;
    268268        return selectedPluginsMap.get(pi);
    269269    }
     
    273273     * the set of activated plugins.
    274274     *
    275      * @return the set of newly deactivated plugins
     275     * @return the set of newly activated plugins
    276276     */
    277277    public List<PluginInformation> getNewlyActivatedPlugins() {
     
    289289    /**
    290290     * Replies the set of plugins which have been removed by the user from
    291      * the set of activated plugins.
     291     * the set of deactivated plugins.
    292292     *
    293293     * @return the set of newly deactivated plugins
     
    349349     */
    350350    public void refreshLocalPluginVersion(Collection<PluginInformation> plugins) {
    351         if (plugins == null) return;
    352         for (PluginInformation pi : plugins) {
    353             File downloadedPluginFile = PluginHandler.findUpdatedJar(pi.name);
    354             if (downloadedPluginFile == null) {
    355                 continue;
    356             }
    357             try {
    358                 PluginInformation newinfo = new PluginInformation(downloadedPluginFile, pi.name);
    359                 PluginInformation oldinfo = getPluginInformation(pi.name);
    360                 if (oldinfo == null) {
    361                     // should not happen
     351        if (plugins != null) {
     352            for (PluginInformation pi : plugins) {
     353                File downloadedPluginFile = PluginHandler.findUpdatedJar(pi.name);
     354                if (downloadedPluginFile == null) {
    362355                    continue;
    363356                }
    364                 oldinfo.updateLocalInfo(newinfo);
    365             } catch (PluginException e) {
    366                 Main.error(e);
     357                try {
     358                    PluginInformation newinfo = new PluginInformation(downloadedPluginFile, pi.name);
     359                    PluginInformation oldinfo = getPluginInformation(pi.name);
     360                    if (oldinfo != null) {
     361                        oldinfo.updateLocalInfo(newinfo);
     362                    }
     363                } catch (PluginException e) {
     364                    Main.error(e);
     365                }
    367366            }
    368367        }
Note: See TracChangeset for help on using the changeset viewer.