diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-07-01 13:45:42 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-07-01 13:45:42 +0200 |
commit | cbe3819ae9e045049816761ff598ae5e74eac2e2 (patch) | |
tree | 7337e308e2ba4b52431c00007a7db029ddc7c726 /sonar-server | |
parent | 1f47755b387c6b9df30dfa9ef9fb9aee8b2fb900 (diff) | |
download | sonarqube-cbe3819ae9e045049816761ff598ae5e74eac2e2.tar.gz sonarqube-cbe3819ae9e045049816761ff598ae5e74eac2e2.zip |
SONAR-5007 Revert find ids to rule finder logic (removed rules are returned)
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java | 5 | ||||
-rw-r--r-- | sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java | 23 |
2 files changed, 21 insertions, 7 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java b/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java index a7374945361..4939964bf25 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java @@ -39,7 +39,6 @@ import java.util.List; import static com.google.common.collect.Lists.newArrayList; -@Deprecated /** * Will be removed in the future. Please use {@link org.sonar.server.rule.RuleService} */ @@ -68,9 +67,7 @@ public class DefaultRuleFinder implements RuleFinder { return rules; } for (Rule rule : index.getByIds(ruleIds)) { - if (rule.status() != RuleStatus.REMOVED) { - rules.add(toRule(rule)); - } + rules.add(toRule(rule)); } return rules; } diff --git a/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java b/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java index 92875e0c3c5..d014dbbe1b6 100644 --- a/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java +++ b/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java @@ -111,8 +111,7 @@ public class DefaultRuleFinderMediumTest { Assertions.assertThat(finder.findById(2)).isNull(); // should_find_by_ids - // 2 is returned even its status is REMOVED !!! Conflicts with IMPL. //TODO check with @Simon - assertThat(finder.findByIds(newArrayList(2, 3))).hasSize(1); + assertThat(finder.findByIds(newArrayList(2, 3))).hasSize(2); // should_find_by_key Rule rule = finder.findByKey("checkstyle", "com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"); @@ -128,7 +127,7 @@ public class DefaultRuleFinderMediumTest { Assertions.assertThat(finder.findAll(RuleQuery.create().withRepositoryKey("checkstyle"))).hasSize(2); // find_all_enabled - //Assertions.assertThat(finder.findAll(RuleQuery.create())).onProperty("id").containsOnly(1, 3, 4); + Assertions.assertThat(finder.findAll(RuleQuery.create())).onProperty("id").containsOnly(1, 3, 4, 5); Assertions.assertThat(finder.findAll(RuleQuery.create())).hasSize(4); // do_not_find_disabled_rules @@ -143,6 +142,24 @@ public class DefaultRuleFinderMediumTest { } @Test + public void find_ids_including_removed_rule() { + // find rule with id 2 is REMOVED + assertThat(finder.findByIds(newArrayList(2))).hasSize(1); + } + + @Test + public void find_id_return_null_on_removed_rule() { + // find rule with id 2 is REMOVED + assertThat(finder.findById(2)).isNull(); + } + + @Test + public void find_all_not_include_removed_rule() { + // find rule with id 2 is REMOVED + Assertions.assertThat(finder.findAll(RuleQuery.create())).onProperty("id").containsOnly(1, 3, 4, 5); + } + + @Test public void find_manual_rule() { // find by id Assertions.assertThat(finder.findById(5)).isNotNull(); |