From aef2286bf00aca219862aa62ef5dcac4bb9d2e9a Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Mon, 6 Sep 2010 17:22:57 +0000 Subject: SONAR-1229 Export/Import a given Sonar quality profile --- .../org/sonar/api/rules/DefaultRulesManager.java | 47 ---------------------- .../sonar/api/rules/DefaultRulesManagerTest.java | 18 --------- 2 files changed, 65 deletions(-) (limited to 'sonar-deprecated') diff --git a/sonar-deprecated/src/main/java/org/sonar/api/rules/DefaultRulesManager.java b/sonar-deprecated/src/main/java/org/sonar/api/rules/DefaultRulesManager.java index dce362a38a6..26b917b9329 100644 --- a/sonar-deprecated/src/main/java/org/sonar/api/rules/DefaultRulesManager.java +++ b/sonar-deprecated/src/main/java/org/sonar/api/rules/DefaultRulesManager.java @@ -137,53 +137,6 @@ public class DefaultRulesManager extends RulesManager { return Collections.emptyList(); } - /** - * Gets count of rules by categories defined for a given language - * - * @param language the language - * @return a Map with the category as key and the count as value - */ - public Map countRulesByCategory(Language language) { - return countRulesByCategory(language, rulesDao); - } - - protected Map countRulesByCategory(Language language, RulesDao rulesDao) { - Map countByCategory = new HashMap(); - List result = getPlugins(language); - if (!CollectionUtils.isEmpty(result)) { - List keys = getPluginKeys(getPlugins(language)); - for (RulesCategory rulesCategory : rulesDao.getCategories()) { - Long rulesCount = rulesDao.countRules(keys, rulesCategory.getName()); - countByCategory.put(rulesCategory.getName(), rulesCount); - } - } - return countByCategory; - } - - private List getPluginKeys(List plugins) { - ArrayList keys = new ArrayList(); - for (Plugin plugin : plugins) { - keys.add(plugin.getKey()); - } - return keys; - } - - /** - * Get the list of rules plugin that implement a mechanism of export for a given language - * - * @param language the language - * @return the list of plugins - */ - public List getExportablePlugins(Language language) { - List targets = new ArrayList(); - List> rulesRepositories = getRulesRepositories(language); - for (RulesRepository repository : rulesRepositories) { - if (repository instanceof ConfigurationExportable) { - targets.add(plugins.getPluginByExtension(repository)); - } - } - return targets; - } /** * Get the list of rules plugin that implement a mechanism of import for a given language diff --git a/sonar-deprecated/src/test/java/org/sonar/api/rules/DefaultRulesManagerTest.java b/sonar-deprecated/src/test/java/org/sonar/api/rules/DefaultRulesManagerTest.java index 62aa2a3a077..7aec32d575e 100644 --- a/sonar-deprecated/src/test/java/org/sonar/api/rules/DefaultRulesManagerTest.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/rules/DefaultRulesManagerTest.java @@ -37,24 +37,6 @@ import static org.mockito.Mockito.when; public class DefaultRulesManagerTest { - @Test - public void shouldReturnsZeroRulesByCategoryWhenNoPluginsForALanguage() { - DefaultRulesManager rulesManager = createRulesManagerForAlanguageWithNoPlugins(); - - Language language = mock(Language.class); - Map result = rulesManager.countRulesByCategory(language); - assertThat(result.size(), is(0)); - } - - @Test - public void shouldReturnsZeroExportablePluginsWhenLanguageHasNoRulesPlugin() { - DefaultRulesManager rulesManager = createRulesManagerForAlanguageWithNoPlugins(); - - Language language = mock(Language.class); - List result = rulesManager.getExportablePlugins(language); - assertThat(result.size(), is(0)); - } - @Test public void shouldReturnsZeroImportablePluginsWhenLanguageHasNoRulesPlugin() { DefaultRulesManager rulesManager = createRulesManagerForAlanguageWithNoPlugins(); -- cgit v1.2.3