]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9191 remove unused methods from DefaultRuleFinder 2152/head
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 6 Jun 2017 16:02:42 +0000 (18:02 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 9 Jun 2017 08:10:53 +0000 (10:10 +0200)
server/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java
server/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderTest.java

index d6a276acc5da1817f742fac5ecc3605a68cc8502..e96599002e2e51264e051bf028f413392171b163 100644 (file)
@@ -72,30 +72,6 @@ public class DefaultRuleFinder implements RuleFinder {
     }
   }
 
-  public Collection<org.sonar.api.rules.Rule> findByIds(Collection<Integer> ruleIds) {
-    List<org.sonar.api.rules.Rule> rules = newArrayList();
-    if (ruleIds.isEmpty()) {
-      return rules;
-    }
-
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      List<RuleDto> ruleDtos = ruleDao.selectByIds(dbSession, defaultOrganizationProvider.get().getUuid(), new ArrayList<>(ruleIds));
-      return convertToRuleApi(dbSession, ruleDtos);
-    }
-  }
-
-  public Collection<org.sonar.api.rules.Rule> findByKeys(Collection<RuleKey> ruleKeys) {
-    List<org.sonar.api.rules.Rule> rules = newArrayList();
-    if (ruleKeys.isEmpty()) {
-      return rules;
-    }
-
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      List<RuleDto> ruleDtos = ruleDao.selectByKeys(dbSession, defaultOrganizationProvider.get().getUuid(), new ArrayList<>(ruleKeys));
-      return convertToRuleApi(dbSession, ruleDtos);
-    }
-  }
-
   @Override
   @CheckForNull
   public org.sonar.api.rules.Rule findByKey(RuleKey key) {
index 2599ee695251ee63e3fba4da3bd2dcbc32d34744..7e3b86e489c3b3979675eb52614cf77819f6c8cc 100644 (file)
  */
 package org.sonar.server.rule;
 
-import java.util.Collections;
 import org.junit.Before;
 import org.junit.Test;
-import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rules.Rule;
 import org.sonar.api.rules.RuleQuery;
@@ -34,7 +32,6 @@ import org.sonar.db.rule.RuleDto;
 import org.sonar.server.organization.DefaultOrganizationProvider;
 import org.sonar.server.organization.TestDefaultOrganizationProvider;
 
-import static com.google.common.collect.Lists.newArrayList;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class DefaultRuleFinderTest {
@@ -100,9 +97,6 @@ public class DefaultRuleFinderTest {
     // should_not_find_disabled_rule_by_id
     assertThat(underTest.findById(rule2.getId())).isNull();
 
-    // should_find_by_ids
-    assertThat(underTest.findByIds(newArrayList(rule2.getId(), rule3.getId()))).hasSize(2);
-
     // should_find_by_key
     Rule rule = underTest.findByKey("checkstyle", "com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck");
     assertThat(rule).isNotNull();
@@ -127,22 +121,6 @@ public class DefaultRuleFinderTest {
     assertThat(underTest.findAll(RuleQuery.create().withRepositoryKey("unknown_repository"))).isEmpty();
   }
 
-  @Test
-  public void find_ids_including_removed_rule() {
-    // find rule with id 2 is REMOVED
-    assertThat(underTest.findByIds(newArrayList(rule2.getId()))).hasSize(1);
-  }
-
-  @Test
-  public void find_keys_including_removed_rule() {
-    assertThat(underTest.findByKeys(newArrayList(RuleKey.of("checkstyle", "DisabledCheck")))).hasSize(1);
-
-    // find rule with id 2 is REMOVED
-    assertThat(underTest.findByKeys(newArrayList(RuleKey.of("checkstyle", "com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck")))).hasSize(1);
-
-    assertThat(underTest.findByKeys(Collections.<RuleKey>emptyList())).isEmpty();
-  }
-
   @Test
   public void find_id_return_null_on_removed_rule() {
     // find rule with id 2 is REMOVED