]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 delete unused class RulesDao
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 12 Jun 2014 16:20:59 +0000 (18:20 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 12 Jun 2014 16:21:09 +0000 (18:21 +0200)
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java
sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java [deleted file]
sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java [deleted file]
sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java

index 0e954b0fe194c5a750d13392ca01fafa16bb674a..693be2183a2753e764e9c008a0c184602f67d369 100644 (file)
@@ -55,7 +55,6 @@ import org.sonar.core.purge.PurgeProfiler;
 import org.sonar.core.rule.CacheRuleFinder;
 import org.sonar.core.user.HibernateUserFinder;
 import org.sonar.jpa.dao.MeasuresDao;
-import org.sonar.jpa.dao.RulesDao;
 import org.sonar.jpa.session.DefaultDatabaseConnector;
 import org.sonar.jpa.session.JpaDatabaseSession;
 
@@ -147,7 +146,6 @@ public class BootstrapContainer extends ComponentContainer {
       DefaultI18n.class,
       RuleI18nManager.class,
       MeasuresDao.class,
-      RulesDao.class,
       HibernateUserFinder.class,
       SemaphoreUpdater.class,
       SemaphoresImpl.class,
diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/RulesDao.java
deleted file mode 100644 (file)
index 1a47b33..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.jpa.dao;
-
-import org.sonar.api.database.DatabaseSession;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RuleParam;
-
-public class RulesDao extends BaseDao {
-
-  public RulesDao(DatabaseSession session) {
-    super(session);
-  }
-
-  public Rule getRuleByKey(String repositoryKey, String ruleKey) {
-    DatabaseSession session = getSession();
-    return (Rule) session.getSingleResult(
-        session.createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.key=:key and r.pluginName=:pluginName and r.status<>:status")
-            .setParameter("key", ruleKey)
-            .setParameter("pluginName", repositoryKey)
-            .setParameter("status", Rule.STATUS_REMOVED
-        ),
-        null);
-  }
-
-  public RuleParam getRuleParam(Rule rule, String paramKey) {
-    return getSession().getSingleResult(RuleParam.class, "rule", rule, "key", paramKey);
-  }
-
-}
diff --git a/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java b/sonar-core/src/test/java/org/sonar/jpa/dao/RulesDaoTest.java
deleted file mode 100644 (file)
index e825633..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.jpa.dao;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.rules.Rule;
-import org.sonar.jpa.test.AbstractDbUnitTestCase;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-public class RulesDaoTest extends AbstractDbUnitTestCase {
-
-  private RulesDao rulesDao;
-
-  @Before
-  public void setup() {
-    rulesDao = new RulesDao(getSession());
-  }
-
-  @Test
-  public void shouldGetRuleWithRuleKeyAndPluginKey() {
-    setupData("shouldGetRuleWithRuleKeyAndPluginKey");
-
-    Rule rule = rulesDao.getRuleByKey("plugin", "checkstyle.rule1");
-    assertThat(rule, notNullValue());
-    assertThat(rule.getId(), notNullValue());
-
-    Rule rule2 = rulesDao.getRuleByKey("plugin", "key not found");
-    assertThat(rule2, nullValue());
-  }
-
-}
index ba51176ec2c0c90492bab11b585a53363cca978f..4cd1601e59ad8b5fa6100fa17edae9501fdd0d8b 100644 (file)
@@ -73,7 +73,6 @@ import org.sonar.core.timemachine.Periods;
 import org.sonar.core.user.DefaultUserFinder;
 import org.sonar.core.user.HibernateUserFinder;
 import org.sonar.jpa.dao.MeasuresDao;
-import org.sonar.jpa.dao.RulesDao;
 import org.sonar.jpa.session.DatabaseSessionFactory;
 import org.sonar.jpa.session.DatabaseSessionProvider;
 import org.sonar.jpa.session.DefaultDatabaseConnector;
@@ -445,7 +444,6 @@ class ServerComponents {
     // rule
     pico.addSingleton(AnnotationRuleParser.class);
     pico.addSingleton(XMLRuleParser.class);
-    pico.addComponent(RulesDao.class, false);
     pico.addSingleton(DefaultRuleFinder.class);
     pico.addSingleton(RuleOperations.class);
     pico.addSingleton(RubyRuleService.class);