]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7330 Remove old RuleDao and ActiveRuleDao
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 26 Feb 2016 13:45:52 +0000 (14:45 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 29 Feb 2016 12:26:54 +0000 (13:26 +0100)
61 files changed:
server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java
server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/package-info.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
server/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/rule/db/package-info.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java
server/sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/rule/ws/CreateActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionMediumTest.java
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_from_profile-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_from_rule-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameter-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameters-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameters_from_profile_id-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameters_from_profile_id.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/empty.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/insert-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/insert_parameter-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/insert_parameter.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/shared.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/update-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/update_parameter-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/empty.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_all-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectAll.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectById.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectNonManual.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectParameters.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_name.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_rule_key.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_sub_characteristic_id.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_language.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_id.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_ids.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter.xml [deleted file]

index ea36495f8c2fb3be0440b37d98d358deff3e22cc..a47a99bb4f33e73ba6fa31f546344eb71c31021e 100644 (file)
@@ -23,8 +23,6 @@ import java.util.Map;
 import org.sonar.db.Dao;
 import org.sonar.db.Database;
 import org.sonar.db.MyBatis;
-import org.sonar.server.qualityprofile.db.ActiveRuleDao;
-import org.sonar.server.rule.db.RuleDao;
 
 /**
  * Should be replaced by {@link org.sonar.db.DbClient}, but some DAOs
@@ -34,24 +32,12 @@ import org.sonar.server.rule.db.RuleDao;
 @Deprecated
 public class DbClient extends org.sonar.db.DbClient {
 
-  private ActiveRuleDao activeRuleDao;
-  private RuleDao ruleDao;
-
   public DbClient(Database database, MyBatis myBatis, Dao... daos) {
     super(database, myBatis, daos);
   }
 
   @Override
   protected void doOnLoad(Map<Class, Dao> daoByClass) {
-    this.activeRuleDao = (ActiveRuleDao) daoByClass.get(ActiveRuleDao.class);
-    this.ruleDao = (RuleDao) daoByClass.get(RuleDao.class);
-  }
-
-  public ActiveRuleDao deprecatedActiveRuleDao() {
-    return activeRuleDao;
   }
 
-  public RuleDao deprecatedRuleDao() {
-    return ruleDao;
-  }
 }
index 0f73e6d850c043c5a244d94c773059340d4679da..aed342810d7e0c0655f9a805657af9d8ca57a2dc 100644 (file)
@@ -35,10 +35,10 @@ import org.sonar.api.utils.ValidationMessages;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.MyBatis;
 import org.sonar.db.rule.RuleDto;
-import org.sonar.server.db.DbClient;
 import org.sonar.server.debt.DebtModelXMLExporter.RuleDebt;
 import org.sonar.server.rule.RuleDefinitionsLoader;
 import org.sonar.server.rule.RuleOperations;
@@ -154,8 +154,8 @@ public class DebtModelBackup {
       rule.setRemediationFunction(null);
       rule.setRemediationCoefficient(null);
       rule.setRemediationOffset(null);
-      rule.setUpdatedAt(updateDate);
-      dbClient.deprecatedRuleDao().update(session, rule);
+      rule.setUpdatedAtInMs(updateDate.getTime());
+      dbClient.ruleDao().update(session, rule);
     }
   }
 
index cfbf3199350845b5502143718dc61de8f90d5a3a..b80f273298525f395b2024eaac8ee5b3ed11aacc 100644 (file)
@@ -42,11 +42,9 @@ import org.sonar.server.platform.Platform;
 import org.sonar.server.platform.ServerImpl;
 import org.sonar.server.platform.ServerSettings;
 import org.sonar.server.platform.TempFolderProvider;
-import org.sonar.server.qualityprofile.db.ActiveRuleDao;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndex2;
 import org.sonar.server.qualityprofile.index.ActiveRuleNormalizer;
 import org.sonar.server.ruby.PlatformRackBridge;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.rule.index.RuleIndex2;
 import org.sonar.server.rule.index.RuleNormalizer;
 import org.sonar.server.search.EsSearchModule;
@@ -103,10 +101,6 @@ public class PlatformLevel1 extends PlatformLevel {
       // Elasticsearch
       EsSearchModule.class,
 
-      // DAOs to be moved to sonar-db
-      RuleDao.class,
-      ActiveRuleDao.class,
-
       // rules/qprofiles
       RuleIndex2.class,
       ActiveRuleIndex2.class,
index 8ae46b3c39de016a5cfeb8efc228ed54bde5b0f9..17f0217d8c8dc0ae31ac28a0daa2252cbba27ed4 100644 (file)
@@ -76,13 +76,13 @@ public class RuleActivatorContextFactory {
   }
 
   private RuleDto initRule(RuleKey ruleKey, RuleActivatorContext context, DbSession dbSession) {
-    RuleDto rule = db.deprecatedRuleDao().getNullableByKey(dbSession, ruleKey);
-    if (rule == null) {
+    Optional<RuleDto> rule = db.ruleDao().selectByKey(dbSession, ruleKey);
+    if (!rule.isPresent()) {
       throw new BadRequestException("Rule not found: " + ruleKey);
     }
-    context.setRule(rule);
-    context.setRuleParams(db.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, rule.getKey()));
-    return rule;
+    context.setRule(rule.get());
+    context.setRuleParams(db.ruleDao().selectRuleParamsByRuleKey(dbSession, rule.get().getKey()));
+    return rule.get();
   }
 
   private void initActiveRules(String profileKey, RuleKey ruleKey, RuleActivatorContext context, DbSession session, boolean parent) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java
deleted file mode 100644 (file)
index a9b0656..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.qualityprofile.db;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import java.util.List;
-import javax.annotation.CheckForNull;
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DatabaseUtils;
-import org.sonar.db.DbSession;
-import org.sonar.db.qualityprofile.ActiveRuleDto;
-import org.sonar.db.qualityprofile.ActiveRuleKey;
-import org.sonar.db.qualityprofile.SqlActiveRuleKey;
-import org.sonar.db.qualityprofile.ActiveRuleMapper;
-import org.sonar.db.qualityprofile.ActiveRuleParamDto;
-import org.sonar.db.qualityprofile.QualityProfileDao;
-import org.sonar.db.qualityprofile.QualityProfileDto;
-import org.sonar.db.rule.RuleDto;
-import org.sonar.server.db.BaseDao;
-import org.sonar.server.rule.db.RuleDao;
-import org.sonar.server.search.IndexDefinition;
-
-import static java.util.Collections.emptyList;
-
-@Deprecated
-public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, ActiveRuleKey> {
-
-  private static final String QUALITY_PROFILE_IS_NOT_PERSISTED = "Quality profile is not persisted (missing id)";
-  private static final String RULE_IS_NOT_PERSISTED = "Rule is not persisted";
-  private static final String RULE_PARAM_IS_NOT_PERSISTED = "Rule param is not persisted";
-  private static final String ACTIVE_RULE_KEY_CANNOT_BE_NULL = "ActiveRuleKey cannot be null";
-  private static final String ACTIVE_RULE_IS_NOT_PERSISTED = "ActiveRule is not persisted";
-  private static final String ACTIVE_RULE_IS_ALREADY_PERSISTED = "ActiveRule is already persisted";
-  private static final String ACTIVE_RULE_PARAM_IS_NOT_PERSISTED = "ActiveRuleParam is not persisted";
-  private static final String ACTIVE_RULE_PARAM_IS_ALREADY_PERSISTED = "ActiveRuleParam is already persisted";
-  private static final String PARAMETER_NAME_CANNOT_BE_NULL = "ParameterName cannot be null";
-
-  // TODO remove once key is finalized (used only to get id for SQL statement)
-  private final RuleDao ruleDao;
-  private final QualityProfileDao profileDao;
-
-  public ActiveRuleDao(QualityProfileDao profileDao, RuleDao ruleDao, System2 system) {
-    super(IndexDefinition.ACTIVE_RULE, ActiveRuleMapper.class, system);
-    this.ruleDao = ruleDao;
-    this.profileDao = profileDao;
-  }
-
-  @CheckForNull
-  @Deprecated
-  public ActiveRuleDto selectById(DbSession session, int activeRuleId) {
-    ActiveRuleDto activeRule = mapper(session).selectById(activeRuleId);
-    if (activeRule != null) {
-      QualityProfileDto profile = profileDao.selectById(session, activeRule.getProfileId());
-      RuleDto rule = ruleDao.selectById(session, activeRule.getRuleId());
-      if (profile != null && rule != null) {
-        activeRule.setKey(ActiveRuleKey.of(profile.getKey(), rule.getKey()));
-        return activeRule;
-      }
-    }
-    return null;
-  }
-
-  @Override
-  protected ActiveRuleDto doGetNullableByKey(DbSession session, ActiveRuleKey key) {
-    return mapper(session).selectByKey(key.qProfile(), key.ruleKey().repository(), key.ruleKey().rule());
-  }
-
-  @Override
-  protected ActiveRuleDto doInsert(DbSession session, ActiveRuleDto item) {
-    Preconditions.checkArgument(item.getProfileId() != null, QUALITY_PROFILE_IS_NOT_PERSISTED);
-    Preconditions.checkArgument(item.getRuleId() != null, RULE_IS_NOT_PERSISTED);
-    Preconditions.checkArgument(item.getId() == null, ACTIVE_RULE_IS_ALREADY_PERSISTED);
-    mapper(session).insert(item);
-    return item;
-  }
-
-  @Override
-  protected ActiveRuleDto doUpdate(DbSession session, ActiveRuleDto item) {
-    Preconditions.checkArgument(item.getProfileId() != null, QUALITY_PROFILE_IS_NOT_PERSISTED);
-    Preconditions.checkArgument(item.getRuleId() != null, ActiveRuleDao.RULE_IS_NOT_PERSISTED);
-    Preconditions.checkArgument(item.getId() != null, ACTIVE_RULE_IS_NOT_PERSISTED);
-    mapper(session).update(item);
-    return item;
-  }
-
-  @Override
-  protected void doDeleteByKey(DbSession session, ActiveRuleKey key) {
-    ActiveRuleDto activeRule = getNullableByKey(session, key);
-    if (activeRule != null) {
-      mapper(session).deleteParameters(activeRule.getId());
-      mapper(session).delete(activeRule.getId());
-    }
-  }
-
-  /**
-   * Finder methods for Rules
-   */
-
-  public List<ActiveRuleDto> selectByRule(DbSession dbSession, RuleDto rule) {
-    Preconditions.checkNotNull(rule.getId(), RULE_IS_NOT_PERSISTED);
-    return mapper(dbSession).selectByRuleId(rule.getId());
-  }
-
-  public List<ActiveRuleDto> selectAll(DbSession dbSession) {
-    return mapper(dbSession).selectAll();
-  }
-
-  public List<ActiveRuleParamDto> selectAllParams(DbSession dbSession) {
-    return mapper(dbSession).selectAllParams();
-  }
-
-  public Optional<ActiveRuleDto> selectByActiveRuleKey(DbSession dbSession, ActiveRuleKey key) {
-    return Optional.fromNullable(mapper(dbSession).selectByKey(key.qProfile(), key.ruleKey().repository(), key.ruleKey().rule()));
-  }
-
-  public List<ActiveRuleDto> selectByActiveRuleKeys(final DbSession dbSession, final List<ActiveRuleKey> keys) {
-    if (keys.isEmpty()) {
-      return emptyList();
-    }
-
-    List<SqlActiveRuleKey> sqlKeys = new ArrayList<>();
-    for (ActiveRuleKey key : keys) {
-      sqlKeys.add(new SqlActiveRuleKey(key));
-    }
-
-    return DatabaseUtils.executeLargeInputs(sqlKeys, new Function<List<SqlActiveRuleKey>, List<ActiveRuleDto>>() {
-      @Override
-      public List<ActiveRuleDto> apply(@Nonnull List<SqlActiveRuleKey> input) {
-        return mapper(dbSession).selectByKeys(input);
-      }
-    });
-  }
-
-  /**
-   * Nested DTO ActiveRuleParams
-   */
-
-  public ActiveRuleParamDto insertParam(DbSession session, ActiveRuleDto activeRule, ActiveRuleParamDto activeRuleParam) {
-    Preconditions.checkArgument(activeRule.getId() != null, ACTIVE_RULE_IS_NOT_PERSISTED);
-    Preconditions.checkArgument(activeRuleParam.getId() == null, ACTIVE_RULE_PARAM_IS_ALREADY_PERSISTED);
-    Preconditions.checkNotNull(activeRuleParam.getRulesParameterId(), RULE_PARAM_IS_NOT_PERSISTED);
-
-    activeRuleParam.setActiveRuleId(activeRule.getId());
-    mapper(session).insertParameter(activeRuleParam);
-    this.enqueueInsert(activeRuleParam, activeRule.getKey(), session);
-    return activeRuleParam;
-  }
-
-  public void deleteParamByKeyAndName(DbSession session, ActiveRuleKey key, String param) {
-    // TODO SQL rewrite to delete by key
-    ActiveRuleDto activeRule = getNullableByKey(session, key);
-    if (activeRule != null) {
-      ActiveRuleParamDto activeRuleParam = mapper(session).selectParamByActiveRuleAndKey(activeRule.getId(), param);
-      if (activeRuleParam != null) {
-        mapper(session).deleteParameter(activeRuleParam.getId());
-      }
-    }
-  }
-
-  public void updateParam(DbSession session, ActiveRuleDto activeRule, ActiveRuleParamDto activeRuleParam) {
-    Preconditions.checkNotNull(activeRule.getId(), ACTIVE_RULE_IS_NOT_PERSISTED);
-    Preconditions.checkNotNull(activeRuleParam.getId(), ACTIVE_RULE_PARAM_IS_NOT_PERSISTED);
-    mapper(session).updateParameter(activeRuleParam);
-    this.enqueueUpdate(activeRuleParam, activeRule.getKey(), session);
-  }
-
-  public void deleteParam(DbSession session, ActiveRuleDto activeRule, ActiveRuleParamDto activeRuleParam) {
-    Preconditions.checkNotNull(activeRule.getId(), ACTIVE_RULE_IS_NOT_PERSISTED);
-    Preconditions.checkNotNull(activeRuleParam.getId(), ACTIVE_RULE_PARAM_IS_NOT_PERSISTED);
-    mapper(session).deleteParameter(activeRuleParam.getId());
-    this.enqueueDelete(activeRuleParam, activeRule.getKey(), session);
-  }
-
-  public void deleteByProfileKey(DbSession session, String profileKey) {
-    /** Functional cascade for params */
-    for (ActiveRuleDto activeRule : selectByProfileKey(session, profileKey)) {
-      delete(session, activeRule);
-    }
-  }
-
-  public List<ActiveRuleDto> selectByProfileKey(DbSession session, String profileKey) {
-    return mapper(session).selectByProfileKey(profileKey);
-  }
-
-  /**
-   * Finder methods for ActiveRuleParams
-   */
-
-  public List<ActiveRuleParamDto> selectParamsByActiveRuleKey(DbSession session, ActiveRuleKey key) {
-    Preconditions.checkNotNull(key, ACTIVE_RULE_KEY_CANNOT_BE_NULL);
-    ActiveRuleDto activeRule = this.getByKey(session, key);
-    return mapper(session).selectParamsByActiveRuleId(activeRule.getId());
-  }
-
-  public List<ActiveRuleParamDto> selectParamsByActiveRuleId(DbSession dbSession, Integer activeRuleId) {
-    return mapper(dbSession).selectParamsByActiveRuleId(activeRuleId);
-  }
-
-  public List<ActiveRuleParamDto> selectParamsByActiveRuleIds(final DbSession dbSession, List<Integer> activeRuleIds) {
-    if (activeRuleIds.isEmpty()) {
-      return emptyList();
-    }
-
-    return DatabaseUtils.executeLargeInputs(activeRuleIds, new Function<List<Integer>, List<ActiveRuleParamDto>>() {
-      @Override
-      public List<ActiveRuleParamDto> apply(@Nullable List<Integer> input) {
-        return mapper(dbSession).selectParamsByActiveRuleIds(input);
-      }
-    });
-  }
-
-  @CheckForNull
-  public ActiveRuleParamDto selectParamByKeyAndName(ActiveRuleKey key, String name, DbSession session) {
-    Preconditions.checkNotNull(key, ACTIVE_RULE_KEY_CANNOT_BE_NULL);
-    Preconditions.checkNotNull(name, PARAMETER_NAME_CANNOT_BE_NULL);
-    ActiveRuleDto activeRule = getNullableByKey(session, key);
-    if (activeRule != null) {
-      return mapper(session).selectParamByActiveRuleAndKey(activeRule.getId(), name);
-    }
-    return null;
-  }
-
-  public void deleteParamsByRuleParam(DbSession dbSession, RuleDto rule, String paramKey) {
-    List<ActiveRuleDto> activeRules = selectByRule(dbSession, rule);
-    for (ActiveRuleDto activeRule : activeRules) {
-      for (ActiveRuleParamDto activeParam : selectParamsByActiveRuleKey(dbSession, activeRule.getKey())) {
-        if (activeParam.getKey().equals(paramKey)) {
-          deleteParam(dbSession, activeRule, activeParam);
-        }
-      }
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/package-info.java
deleted file mode 100644 (file)
index f9e750d..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.server.qualityprofile.db;
-
-import javax.annotation.ParametersAreNonnullByDefault;
index bb57481a027f0641f414bd00ac26b84413343d70..df27cd9773bfd284349ff62fe089159030d75e50 100644 (file)
@@ -104,10 +104,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
       String parentKey = null;
       Integer parentId = activeRuleDto.getParentId();
       if (parentId != null) {
-        ActiveRuleDto parentDto = db.deprecatedActiveRuleDao().selectById(session, parentId);
-        if (parentDto != null) {
-          parentKey = parentDto.getKey().toString();
-        }
+
       }
 
       /* Creating updateRequest */
@@ -119,7 +116,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
         .upsert(getUpsertFor(ActiveRuleField.ALL_FIELDS, newRule)));
 
       // Get the RuleParameters
-      for (ActiveRuleParamDto param : db.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(session, key)) {
+      for (ActiveRuleParamDto param : db.activeRuleDao().selectParamsByActiveRuleKey(session, key)) {
         requests.addAll(normalizeNested(param, key));
       }
 
index 3bf7879ad8bec09197132c2db7514be367bebbe2..14e4704afc8af1ec3efc077e95b515b42b2d8101 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.qualityprofile.ws;
 
+import com.google.common.base.Optional;
 import java.util.Date;
 import java.util.Map.Entry;
 import org.elasticsearch.action.search.SearchResponse;
@@ -32,11 +33,11 @@ import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.Paging;
 import org.sonar.api.utils.text.JsonWriter;
+import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.activity.index.ActivityIndex;
-import org.sonar.server.db.DbClient;
 import org.sonar.server.es.SearchOptions;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.qualityprofile.QProfileActivity;
@@ -123,8 +124,8 @@ public class ChangelogAction implements QProfileWsAction {
       Result<QProfileActivity> result = new Result<>(response);
       for (SearchHit hit : response.getHits().getHits()) {
         QProfileActivity profileActivity = new QProfileActivity(hit.getSource());
-        RuleDto ruleDto = dbClient.deprecatedRuleDao().getNullableByKey(session, profileActivity.ruleKey());
-        profileActivity.ruleName(ruleDto != null ? ruleDto.getName() : null);
+        Optional<RuleDto> ruleDto = dbClient.ruleDao().selectByKey(session, profileActivity.ruleKey());
+        profileActivity.ruleName(ruleDto.isPresent() ? ruleDto.get().getName() : null);
 
         String login = profileActivity.getLogin();
         if (login != null) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java b/server/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java
deleted file mode 100644 (file)
index a9f830e..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.rule.db;
-
-import com.google.common.base.Preconditions;
-import java.util.List;
-import javax.annotation.CheckForNull;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbSession;
-import org.sonar.db.rule.RuleDto;
-import org.sonar.db.rule.RuleMapper;
-import org.sonar.db.rule.RuleParamDto;
-import org.sonar.server.db.BaseDao;
-import org.sonar.server.search.IndexDefinition;
-
-public class RuleDao extends BaseDao<RuleMapper, RuleDto, RuleKey> {
-
-  public RuleDao(System2 system) {
-    super(IndexDefinition.RULE, RuleMapper.class, system);
-  }
-
-  @Override
-  public RuleDto doGetNullableByKey(DbSession session, RuleKey key) {
-    return mapper(session).selectByKey(key);
-  }
-
-  public RuleDto getByName(String name, DbSession session) {
-    return mapper(session).selectByName(name);
-  }
-
-  @Override
-  protected RuleDto doInsert(DbSession session, RuleDto item) {
-    mapper(session).insert(item);
-    return item;
-  }
-
-  @Override
-  protected RuleDto doUpdate(DbSession session, RuleDto item) {
-    mapper(session).update(item);
-    return item;
-  }
-
-  @Override
-  protected void doDeleteByKey(DbSession session, RuleKey key) {
-    throw new UnsupportedOperationException("Rules cannot be deleted");
-  }
-
-  @CheckForNull
-  public RuleDto selectById(DbSession session, int id) {
-    return mapper(session).selectById(id);
-  }
-
-  @CheckForNull
-  public RuleDto selectTemplate(RuleDto rule, DbSession session) {
-    Preconditions.checkNotNull(rule.getTemplateId(), "Rule has no persisted template!");
-    return mapper(session).selectById(rule.getTemplateId());
-  }
-
-  /**
-   * Finder methods for Rules
-   */
-
-  public List<RuleDto> selectByNonManual(DbSession session) {
-    return mapper(session).selectNonManual();
-  }
-
-  public List<RuleDto> selectAll(DbSession session) {
-    return mapper(session).selectAll();
-  }
-
-  /**
-   * Nested DTO RuleParams
-   */
-
-  public void insertRuleParam(DbSession session, RuleDto rule, RuleParamDto param) {
-    Preconditions.checkNotNull(rule.getId(), "Rule id must be set");
-    param.setRuleId(rule.getId());
-    mapper(session).insertParameter(param);
-    this.enqueueInsert(param, rule.getKey(), session);
-  }
-
-  public RuleParamDto updateRuleParam(DbSession session, RuleDto rule, RuleParamDto param) {
-    Preconditions.checkNotNull(rule.getId(), "Rule id must be set");
-    Preconditions.checkNotNull(param.getId(), "Param is not yet persisted must be set");
-    param.setRuleId(rule.getId());
-    mapper(session).updateParameter(param);
-    this.enqueueUpdate(param, rule.getKey(), session);
-    return param;
-  }
-
-  public void deleteRuleParam(DbSession session, RuleDto rule, RuleParamDto param) {
-    Preconditions.checkNotNull(param.getId(), "Param is not persisted");
-    mapper(session).deleteParameter(param.getId());
-    this.enqueueDelete(param, rule.getKey(), session);
-  }
-
-  /**
-   * Finder methods for RuleParams
-   */
-
-  public List<RuleParamDto> selectAllRuleParams(DbSession session) {
-    return mapper(session).selectAllParams();
-  }
-
-  public List<RuleParamDto> selectRuleParamsByRuleKey(DbSession session, RuleKey key) {
-    return mapper(session).selectParamsByRuleKey(key);
-  }
-
-  public List<RuleDto> selectRulesByDebtSubCharacteristicId(DbSession session, int id) {
-    return mapper(session).selectBySubCharacteristicId(id);
-  }
-
-  public List<RuleDto> selectEnabledAndNonManual(DbSession session) {
-    return mapper(session).selectEnabledAndNonManual();
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/db/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/rule/db/package-info.java
deleted file mode 100644 (file)
index 82875a9..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.
- */
-@ParametersAreNonnullByDefault package org.sonar.server.rule.db;
-
-import javax.annotation.ParametersAreNonnullByDefault;
index 1ae6050a094b1655ccaa82d48dc9f152c054f3ba..1573785d7a128fcbb57bbd1299466f981b0d8979 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.rule.index;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
@@ -179,9 +180,9 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
       Integer templateId = rule.getTemplateId();
       String templateKeyFieldValue = null;
       if (templateId != null) {
-        RuleDto templateRule = db.deprecatedRuleDao().selectById(session, templateId);
-        if (templateRule != null) {
-          RuleKey templateKey = templateRule.getKey();
+        Optional<RuleDto> templateRule = db.ruleDao().selectById(templateId, session);
+        if (templateRule.isPresent()) {
+          RuleKey templateKey = templateRule.get().getKey();
           templateKeyFieldValue = templateKey != null ? templateKey.toString() : null;
         }
       }
@@ -223,7 +224,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
         .doc(update)
         .upsert(upsert));
 
-      for (RuleParamDto param : db.deprecatedRuleDao().selectRuleParamsByRuleKey(session, rule.getKey())) {
+      for (RuleParamDto param : db.ruleDao().selectRuleParamsByRuleKey(session, rule.getKey())) {
         requests.addAll(normalizeNested(param, rule.getKey()));
       }
 
diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java
deleted file mode 100644 (file)
index cdd1537..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.db;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbSession;
-import org.sonar.db.DbTester;
-import org.sonar.db.MyBatis;
-import org.sonar.db.qualityprofile.QualityProfileDao;
-import org.sonar.server.qualityprofile.db.ActiveRuleDao;
-import org.sonar.server.rule.db.RuleDao;
-import org.sonar.test.DbTests;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@Category(DbTests.class)
-public class DbClientTest {
-
-  @Rule
-  public DbTester db = DbTester.create(System2.INSTANCE);
-
-  @Test
-  public void get_daos() throws Exception {
-    MyBatis myBatis = db.myBatis();
-    RuleDao ruleDao = new RuleDao(System2.INSTANCE);
-    QualityProfileDao qualityProfileDao = new QualityProfileDao(myBatis, System2.INSTANCE);
-    ActiveRuleDao activeRuleDao = new ActiveRuleDao(qualityProfileDao, ruleDao, System2.INSTANCE);
-
-    DbClient client = new DbClient(db.database(), myBatis, ruleDao, activeRuleDao, qualityProfileDao);
-
-    assertThat(client.getDatabase()).isSameAs(db.database());
-    DbSession dbSession = client.openSession(true);
-    assertThat(dbSession).isNotNull();
-    assertThat(dbSession.getConnection().isClosed()).isFalse();
-    dbSession.close();
-
-    // DAO
-    assertThat(client.qualityProfileDao()).isSameAs(qualityProfileDao);
-    assertThat(client.deprecatedActiveRuleDao()).isSameAs(activeRuleDao);
-    assertThat(client.deprecatedRuleDao()).isSameAs(ruleDao);
-  }
-}
index b75c45c2a04ce3f49283aa19e628b4c936587402..5a0db3f71c93b205c9469d6142a6becc1feb7104 100644 (file)
@@ -40,10 +40,10 @@ import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.ValidationMessages;
 import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
-import org.sonar.server.db.DbClient;
 import org.sonar.server.debt.DebtModelXMLExporter.RuleDebt;
 import org.sonar.server.rule.RuleDefinitionsLoader;
 import org.sonar.server.rule.RuleOperations;
@@ -75,8 +75,6 @@ public class DebtModelBackupTest {
   @Mock
   RuleDao ruleDao;
   @Mock
-  org.sonar.server.rule.db.RuleDao deprecatedRuleDao;
-  @Mock
   RuleOperations ruleOperations;
   @Mock
   DebtRulesXMLImporter rulesXMLImporter;
@@ -106,7 +104,6 @@ public class DebtModelBackupTest {
     currentId = 10;
     when(dbClient.openSession(false)).thenReturn(session);
     when(dbClient.ruleDao()).thenReturn(ruleDao);
-    when(dbClient.deprecatedRuleDao()).thenReturn(deprecatedRuleDao);
 
     underTest = new DebtModelBackup(dbClient, ruleOperations, rulesXMLImporter,
       debtModelXMLExporter, defLoader, system2, userSessionRule);
@@ -246,7 +243,7 @@ public class DebtModelBackupTest {
     underTest.reset();
 
     verify(ruleDao).selectEnabledAndNonManual(session);
-    verify(deprecatedRuleDao).update(eq(session), ruleCaptor.capture());
+    verify(ruleDao).update(eq(session), ruleCaptor.capture());
     verifyNoMoreInteractions(ruleDao);
 
     verify(session).commit();
@@ -256,12 +253,12 @@ public class DebtModelBackupTest {
     assertThat(rule.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET");
     assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("4h");
     assertThat(rule.getDefaultRemediationOffset()).isEqualTo("20min");
-    assertThat(rule.getUpdatedAt()).isEqualTo(now);
+    assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime());
 
     assertThat(rule.getRemediationFunction()).isNull();
     assertThat(rule.getRemediationCoefficient()).isNull();
     assertThat(rule.getRemediationOffset()).isNull();
-    assertThat(rule.getUpdatedAt()).isEqualTo(now);
+    assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime());
   }
 
   @Test
@@ -288,7 +285,7 @@ public class DebtModelBackupTest {
     underTest.reset();
 
     verify(ruleDao).selectEnabledAndNonManual(session);
-    verify(deprecatedRuleDao).update(eq(session), ruleCaptor.capture());
+    verify(ruleDao).update(eq(session), ruleCaptor.capture());
     verifyNoMoreInteractions(ruleDao);
 
     verify(session).commit();
@@ -297,7 +294,7 @@ public class DebtModelBackupTest {
     assertThat(rule.getDefaultRemediationFunction()).isNull();
     assertThat(rule.getDefaultRemediationCoefficient()).isNull();
     assertThat(rule.getDefaultRemediationOffset()).isNull();
-    assertThat(rule.getUpdatedAt()).isEqualTo(now);
+    assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime());
   }
 
   @Test
@@ -330,7 +327,7 @@ public class DebtModelBackupTest {
     underTest.reset();
 
     verify(ruleDao).selectEnabledAndNonManual(session);
-    verify(deprecatedRuleDao, times(2)).update(eq(session), ruleCaptor.capture());
+    verify(ruleDao, times(2)).update(eq(session), ruleCaptor.capture());
     verifyNoMoreInteractions(ruleDao);
     verify(session).commit();
 
@@ -340,12 +337,12 @@ public class DebtModelBackupTest {
     assertThat(rule.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET");
     assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("4h");
     assertThat(rule.getDefaultRemediationOffset()).isEqualTo("20min");
-    assertThat(rule.getUpdatedAt()).isEqualTo(now);
+    assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime());
 
     assertThat(rule.getRemediationFunction()).isNull();
     assertThat(rule.getRemediationCoefficient()).isNull();
     assertThat(rule.getRemediationOffset()).isNull();
-    assertThat(rule.getUpdatedAt()).isEqualTo(now);
+    assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime());
   }
 
   @Test
@@ -355,7 +352,7 @@ public class DebtModelBackupTest {
     underTest.reset();
 
     verify(ruleDao).selectEnabledAndNonManual(session);
-    verify(deprecatedRuleDao, never()).update(eq(session), any(RuleDto.class));
+    verify(ruleDao, never()).update(eq(session), any(RuleDto.class));
     verifyZeroInteractions(defLoader);
 
     verify(session).commit();
index db8abe137055a1578773c9ea88c4e94b4768e5cb..ce3f9e2c3b21f899f6ab8e572ab812143b5d5fff 100644 (file)
@@ -36,19 +36,19 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDao;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDao;
 import org.sonar.db.component.SnapshotDto;
+import org.sonar.db.component.SnapshotTesting;
 import org.sonar.db.issue.IssueDao;
 import org.sonar.db.issue.IssueDto;
+import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.db.user.UserDto;
-import org.sonar.db.component.ComponentTesting;
-import org.sonar.db.component.SnapshotTesting;
 import org.sonar.server.issue.index.IssueIndexer;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.user.UserSession;
index 791dfac1c1600d9d045421d5e82822262e0ee662..7188ae8b0d0a54c8e9727967a7b8f279016c51dc 100644 (file)
@@ -36,18 +36,18 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDao;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.component.SnapshotDao;
 import org.sonar.db.component.SnapshotDto;
+import org.sonar.db.component.SnapshotTesting;
 import org.sonar.db.issue.IssueDao;
 import org.sonar.db.issue.IssueDto;
+import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleTesting;
-import org.sonar.db.component.ComponentTesting;
-import org.sonar.db.component.SnapshotTesting;
 import org.sonar.server.issue.index.IssueIndexer;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.search.IndexClient;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
index 2658a61b4279402d6ea255c69b2d4a9d6358672d..2913daeb75dedde0b1064f9ba24098090e80ecfd 100644 (file)
@@ -36,7 +36,6 @@ import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.security.DefaultGroups;
 import org.sonar.api.web.UserRole;
-import org.sonar.server.issue.workflow.Transition;
 import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
@@ -47,6 +46,7 @@ import org.sonar.db.issue.ActionPlanDto;
 import org.sonar.db.issue.IssueDao;
 import org.sonar.db.issue.IssueDto;
 import org.sonar.db.protobuf.DbFileSources;
+import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.db.source.FileSourceDao;
@@ -62,9 +62,9 @@ import org.sonar.server.issue.index.IssueDoc;
 import org.sonar.server.issue.index.IssueIndex;
 import org.sonar.server.issue.index.IssueIndexDefinition;
 import org.sonar.server.issue.index.IssueIndexer;
+import org.sonar.server.issue.workflow.Transition;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.rule.index.RuleIndexer;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
index 43438a7c7dded846d696a00c345be3aad72775f1..c1c808e871255bc476ad3b883ac29412daad33d8 100644 (file)
@@ -36,17 +36,15 @@ import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
+import org.sonar.db.component.ComponentTesting;
 import org.sonar.db.issue.IssueDto;
+import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleTesting;
-import org.sonar.db.component.ComponentTesting;
 import org.sonar.server.issue.IssueTesting;
-import org.sonarqube.ws.client.issue.IssueFilterParameters;
 import org.sonar.server.issue.index.IssueIndexer;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonarqube.ws.MediaTypes;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.view.index.ViewDoc;
@@ -56,6 +54,8 @@ import org.sonar.server.ws.WsActionTester;
 import org.sonar.server.ws.WsTester;
 import org.sonar.server.ws.WsTester.Result;
 import org.sonarqube.ws.Issues;
+import org.sonarqube.ws.MediaTypes;
+import org.sonarqube.ws.client.issue.IssueFilterParameters;
 
 import static com.google.common.collect.Lists.newArrayList;
 import static org.assertj.core.api.Assertions.assertThat;
index f6f196f17fef949ac663c08491496b96093ec74b..1d357708df297c1db45a0d73b097a5c61eca26e7 100644 (file)
@@ -41,20 +41,20 @@ import org.sonar.db.issue.IssueChangeDao;
 import org.sonar.db.issue.IssueChangeDto;
 import org.sonar.db.issue.IssueDao;
 import org.sonar.db.issue.IssueDto;
+import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.issue.IssueQuery;
 import org.sonar.server.issue.IssueTesting;
-import org.sonarqube.ws.client.issue.IssueFilterParameters;
 import org.sonar.server.issue.index.IssueIndexer;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.search.QueryContext;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.WsTester;
+import org.sonarqube.ws.client.issue.IssueFilterParameters;
 
 import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
index da71a05384b8a33d7b6c09e221507bb47bc8be60..394408c8fe61a732d73c25e86c86d0296fb4e33a 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.project.ws;
 
 import com.google.common.collect.ImmutableMap;
 import java.util.Arrays;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
@@ -36,30 +35,24 @@ import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.System2;
 import org.sonar.api.web.UserRole;
 import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
-import org.sonar.db.component.ComponentDao;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
-import org.sonar.db.component.ResourceDao;
-import org.sonar.db.component.SnapshotDao;
 import org.sonar.db.component.SnapshotDto;
-import org.sonar.db.issue.IssueDao;
+import org.sonar.db.component.SnapshotTesting;
 import org.sonar.db.issue.IssueDto;
-import org.sonar.db.purge.PurgeDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.server.component.ComponentCleanerService;
 import org.sonar.server.component.ComponentFinder;
-import org.sonar.db.component.SnapshotTesting;
-import org.sonar.server.db.DbClient;
 import org.sonar.server.es.EsTester;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.issue.IssueTesting;
 import org.sonar.server.issue.index.IssueAuthorizationIndexer;
 import org.sonar.server.issue.index.IssueIndexDefinition;
 import org.sonar.server.issue.index.IssueIndexer;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.test.index.TestDoc;
 import org.sonar.server.test.index.TestIndexDefinition;
 import org.sonar.server.test.index.TestIndexer;
@@ -92,17 +85,12 @@ public class BulkDeleteActionTest {
   public ExpectedException expectedException = ExpectedException.none();
 
   WsTester ws;
-  DbClient dbClient;
-  DbSession dbSession;
+  DbClient dbClient = db.getDbClient();
+  DbSession dbSession = db.getSession();
   ResourceType resourceType;
 
   @Before
   public void setUp() {
-    ComponentDao componentDao = new ComponentDao();
-    ResourceDao resourceDao = new ResourceDao(db.myBatis(), System2.INSTANCE);
-    PurgeDao purgeDao = new PurgeDao(db.myBatis(), resourceDao, System2.INSTANCE);
-    dbClient = new DbClient(db.database(), db.myBatis(), componentDao, purgeDao, new RuleDao(System2.INSTANCE), new IssueDao(db.myBatis()), new SnapshotDao());
-    dbSession = dbClient.openSession(false);
     resourceType = mock(ResourceType.class);
     when(resourceType.getBooleanProperty(anyString())).thenReturn(true);
     ResourceTypes mockResourceTypes = mock(ResourceTypes.class);
@@ -120,11 +108,6 @@ public class BulkDeleteActionTest {
     es.truncateIndices();
   }
 
-  @After
-  public void tearDown() {
-    dbSession.close();
-  }
-
   @Test
   public void delete_projects_and_data_in_db_by_uuids() throws Exception {
     long snapshotId1 = insertNewProjectInDbAndReturnSnapshotId(1);
@@ -222,7 +205,7 @@ public class BulkDeleteActionTest {
       .newProjectDto("project-uuid-" + suffix)
       .setKey("project-key-" + suffix);
     RuleDto rule = RuleTesting.newDto(RuleKey.of("sonarqube", "rule-" + suffix));
-    dbClient.deprecatedRuleDao().insert(dbSession, rule);
+    dbClient.ruleDao().insert(dbSession, rule);
     IssueDto issue = IssueTesting.newDto(rule, project, project).setKee("issue-key-" + suffix);
     dbClient.componentDao().insert(dbSession, project);
     SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newSnapshotForProject(project));
index f7c2d04efdd4c61cce9e22afc8231fcbff233b09..d36cae4fe8f92136828760ed97ed8e0a34347048 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.project.ws;
 
 import com.google.common.collect.ImmutableMap;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
@@ -34,30 +33,24 @@ import org.sonar.api.resources.ResourceTypes;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.System2;
 import org.sonar.api.web.UserRole;
+import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
-import org.sonar.db.component.ComponentDao;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
-import org.sonar.db.component.ResourceDao;
-import org.sonar.db.component.SnapshotDao;
 import org.sonar.db.component.SnapshotDto;
-import org.sonar.db.issue.IssueDao;
+import org.sonar.db.component.SnapshotTesting;
 import org.sonar.db.issue.IssueDto;
-import org.sonar.db.purge.PurgeDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.server.component.ComponentCleanerService;
 import org.sonar.server.component.ComponentFinder;
-import org.sonar.db.component.SnapshotTesting;
-import org.sonar.server.db.DbClient;
 import org.sonar.server.es.EsTester;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.issue.IssueTesting;
 import org.sonar.server.issue.index.IssueAuthorizationIndexer;
 import org.sonar.server.issue.index.IssueIndexDefinition;
 import org.sonar.server.issue.index.IssueIndexer;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.test.index.TestDoc;
 import org.sonar.server.test.index.TestIndexDefinition;
 import org.sonar.server.test.index.TestIndexer;
@@ -93,19 +86,14 @@ public class DeleteActionTest {
 
   WsTester ws;
 
-  DbClient dbClient;
+  DbClient dbClient = db.getDbClient();
 
-  DbSession dbSession;
+  DbSession dbSession = db.getSession();
 
   ResourceType resourceType;
 
   @Before
   public void setUp() {
-    ComponentDao componentDao = new ComponentDao();
-    ResourceDao resourceDao = new ResourceDao(db.myBatis(), System2.INSTANCE);
-    PurgeDao purgeDao = new PurgeDao(db.myBatis(), resourceDao, System2.INSTANCE);
-    dbClient = new DbClient(db.database(), db.myBatis(), componentDao, purgeDao, new RuleDao(System2.INSTANCE), new IssueDao(db.myBatis()), new SnapshotDao());
-    dbSession = dbClient.openSession(false);
     resourceType = mock(ResourceType.class);
     when(resourceType.getBooleanProperty(anyString())).thenReturn(true);
     ResourceTypes mockResourceTypes = mock(ResourceTypes.class);
@@ -127,11 +115,6 @@ public class DeleteActionTest {
     es.truncateIndices();
   }
 
-  @After
-  public void tearDown() {
-    dbSession.close();
-  }
-
   @Test
   public void delete_project_and_data_in_db_by_uuid() throws Exception {
     long snapshotId1 = insertNewProjectInDbAndReturnSnapshotId(1);
@@ -244,7 +227,7 @@ public class DeleteActionTest {
       .newProjectDto("project-uuid-" + suffix)
       .setKey("project-key-" + suffix);
     RuleDto rule = RuleTesting.newDto(RuleKey.of("sonarqube", "rule-" + suffix));
-    dbClient.deprecatedRuleDao().insert(dbSession, rule);
+    dbClient.ruleDao().insert(dbSession, rule);
     IssueDto issue = IssueTesting.newDto(rule, project, project).setKee("issue-key-" + suffix);
     dbClient.componentDao().insert(dbSession, project);
     SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, SnapshotTesting.newSnapshotForProject(project));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleTest.java
deleted file mode 100644 (file)
index 069366b..0000000
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.qualityprofile;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rule.Severity;
-import org.sonar.api.server.debt.DebtRemediationFunction;
-import org.sonar.db.DbSession;
-import org.sonar.db.qualityprofile.ActiveRuleDto;
-import org.sonar.db.qualityprofile.ActiveRuleParamDto;
-import org.sonar.db.qualityprofile.QualityProfileDto;
-import org.sonar.db.rule.RuleDto;
-import org.sonar.db.rule.RuleParamDto;
-import org.sonar.db.rule.RuleTesting;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.platform.Platform;
-import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
-import org.sonar.server.qualityprofile.index.ActiveRuleNormalizer;
-import org.sonar.server.rule.db.RuleDao;
-import org.sonar.server.search.FacetValue;
-import org.sonar.server.search.IndexClient;
-import org.sonar.server.tester.ServerTester;
-import org.sonar.server.tester.UserSessionRule;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.assertj.core.api.Assertions.assertThat;
-
-// TODO To be removed when dao v2 is removed
-@Ignore
-public class ActiveRuleTest {
-
-  @ClassRule
-  public static ServerTester tester = new ServerTester();
-
-  @Rule
-  public UserSessionRule userSessionRule = UserSessionRule.forServerTester(tester);
-
-  DbClient db;
-  RuleDao dao;
-  IndexClient index;
-  DbSession dbSession;
-
-  @Before
-  public void before() {
-    dao = tester.get(RuleDao.class);
-    tester.clearDbAndIndexes();
-    db = tester.get(DbClient.class);
-    index = tester.get(IndexClient.class);
-    dbSession = tester.get(DbClient.class).openSession(false);
-  }
-
-  @After
-  public void after() {
-    if (dbSession != null) {
-      dbSession.close();
-    }
-  }
-
-  @Test
-  public void synchronize_index() {
-    Date beginning = new Date();
-
-    QualityProfileDto profile1 = QProfileTesting.newXooP1();
-    db.qualityProfileDao().insert(dbSession, profile1);
-
-    RuleDto rule1 = RuleDto.createFor(RuleTesting.XOO_X1).setSeverity(Severity.MAJOR);
-    db.deprecatedRuleDao().insert(dbSession, rule1);
-
-    ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile1, rule1).setSeverity("BLOCKER");
-    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
-    dbSession.commit();
-
-    // 1. Synchronize since 0
-    tester.clearIndexes();
-    assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNull();
-    db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, new Date(0L));
-    dbSession.commit();
-    assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNotNull();
-
-    // 2. Synchronize since beginning
-    tester.clearIndexes();
-    assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNull();
-    db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, beginning);
-    dbSession.commit();
-    assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNotNull();
-
-    // 3. Assert startup picks it up
-    tester.clearIndexes();
-    assertThat(index.get(ActiveRuleIndex.class).getLastSynchronization()).isNull();
-    tester.get(Platform.class).executeStartupTasks();
-    assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNotNull();
-    assertThat(index.get(ActiveRuleIndex.class).getLastSynchronization()).isNotNull();
-  }
-
-  /**
-   * SONAR-6540
-   */
-  @Test
-  public void active_rule_linked_to_not_existing_rule_should_be_ignored() throws SQLException {
-    QualityProfileDto profile = QProfileTesting.newXooP1();
-    db.qualityProfileDao().insert(dbSession, profile);
-
-    RuleDto rule = RuleDto.createFor(RuleTesting.XOO_X1).setSeverity(Severity.MAJOR);
-    db.deprecatedRuleDao().insert(dbSession, rule);
-
-    ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
-    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
-    dbSession.commit();
-
-    // Remove rule -> Active rule is now linked to a not existing rule
-    executeSql(String.format("DELETE FROM rules WHERE id=%s", rule.getId()));
-    dbSession.commit();
-
-    // Synchronize index from start
-    tester.clearIndexes();
-    db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, new Date(0L));
-    dbSession.commit();
-
-    // Active does not exist in the index
-    assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNull();
-  }
-
-  /**
-   * SONAR-6540
-   */
-  @Test
-  public void active_rule_linked_to_not_existing_profile_should_be_ignored() throws SQLException {
-    QualityProfileDto profile = QProfileTesting.newXooP1();
-    db.qualityProfileDao().insert(dbSession, profile);
-
-    RuleDto rule = RuleDto.createFor(RuleTesting.XOO_X1).setSeverity(Severity.MAJOR);
-    db.deprecatedRuleDao().insert(dbSession, rule);
-
-    ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
-    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
-    dbSession.commit();
-
-    // Remove quality profile -> active rule is now linked to a not existing quality profile
-    executeSql(String.format("DELETE FROM rules_profiles WHERE id=%s", profile.getId()));
-    dbSession.commit();
-
-    // Synchronize index from start
-    tester.clearIndexes();
-    db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, new Date(0L));
-    dbSession.commit();
-
-    // Active does not exist in the index
-    assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNull();
-  }
-
-  @Test
-  public void insert_and_index_active_rule() {
-    QualityProfileDto profileDto = QProfileTesting.newXooP1();
-    db.qualityProfileDao().insert(dbSession, profileDto);
-    RuleKey ruleKey = RuleTesting.XOO_X1;
-    RuleDto ruleDto = newRuleDto(ruleKey);
-    db.deprecatedRuleDao().insert(dbSession, ruleDto);
-
-    ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, ruleDto)
-      .setInheritance(ActiveRule.Inheritance.INHERITED.name())
-      .setSeverity(Severity.BLOCKER);
-    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
-    dbSession.commit();
-
-    // verify db
-    assertThat(db.deprecatedActiveRuleDao().getByKey(dbSession, activeRule.getKey())).isNotNull();
-    List<ActiveRuleDto> persistedDtos = db.deprecatedActiveRuleDao().selectByRule(dbSession, ruleDto);
-    assertThat(persistedDtos).hasSize(1);
-
-    // verify es
-    ActiveRule hit = index.get(ActiveRuleIndex.class).getByKey(activeRule.getKey());
-    assertThat(hit).isNotNull();
-    assertThat(hit.key()).isEqualTo(activeRule.getKey());
-    assertThat(hit.inheritance().name()).isEqualTo(activeRule.getInheritance());
-    assertThat(hit.parentKey()).isNull();
-    assertThat(hit.severity()).isEqualTo(activeRule.getSeverityString());
-  }
-
-  @Test
-  public void insert_and_index_active_rule_param() {
-    // insert and index
-    QualityProfileDto profileDto = QProfileTesting.newXooP1();
-    db.qualityProfileDao().insert(dbSession, profileDto);
-    RuleKey ruleKey = RuleTesting.XOO_X1;
-    RuleDto ruleDto = newRuleDto(ruleKey);
-    db.deprecatedRuleDao().insert(dbSession, ruleDto);
-
-    RuleParamDto minParam = new RuleParamDto()
-      .setName("min")
-      .setType("STRING");
-    db.deprecatedRuleDao().insertRuleParam(dbSession, ruleDto, minParam);
-
-    RuleParamDto maxParam = new RuleParamDto()
-      .setName("max")
-      .setType("STRING");
-    db.deprecatedRuleDao().insertRuleParam(dbSession, ruleDto, maxParam);
-
-    ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, ruleDto)
-      .setInheritance(ActiveRule.Inheritance.INHERITED.name())
-      .setSeverity(Severity.BLOCKER);
-    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
-
-    ActiveRuleParamDto activeRuleMinParam = ActiveRuleParamDto.createFor(minParam)
-      .setValue("minimum");
-    db.deprecatedActiveRuleDao().insertParam(dbSession, activeRule, activeRuleMinParam);
-
-    ActiveRuleParamDto activeRuleMaxParam = ActiveRuleParamDto.createFor(maxParam)
-      .setValue("maximum");
-    db.deprecatedActiveRuleDao().insertParam(dbSession, activeRule, activeRuleMaxParam);
-
-    dbSession.commit();
-
-    // verify db
-    List<ActiveRuleParamDto> persistedDtos = db.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(dbSession, activeRule.getKey());
-    assertThat(persistedDtos).hasSize(2);
-
-    // verify es
-    ActiveRule rule = index.get(ActiveRuleIndex.class).getByKey(activeRule.getKey());
-    assertThat(rule).isNotNull();
-    assertThat(rule.params()).hasSize(2);
-    assertThat(rule.params().keySet()).containsOnly("min", "max");
-    assertThat(rule.params().values()).containsOnly("minimum", "maximum");
-    assertThat(rule.params().get("min")).isEqualTo("minimum");
-  }
-
-  @Test
-  public void find_active_rules() {
-    QualityProfileDto profile1 = QProfileTesting.newXooP1();
-    QualityProfileDto profile2 = QProfileTesting.newXooP2();
-    db.qualityProfileDao().insert(dbSession, profile1, profile2);
-
-    RuleDto rule1 = RuleTesting.newXooX1().setSeverity(Severity.MAJOR);
-    RuleDto rule2 = RuleTesting.newXooX2().setSeverity(Severity.MAJOR);
-    RuleDto removedRule = RuleTesting.newDto(RuleKey.of("xoo", "removed")).setSeverity(Severity.MAJOR).setStatus(RuleStatus.REMOVED);
-    db.deprecatedRuleDao().insert(dbSession, rule1, rule2, removedRule);
-
-    db.deprecatedActiveRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile1, rule1).setSeverity(Severity.MINOR));
-    db.deprecatedActiveRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile1, rule2).setSeverity(Severity.BLOCKER));
-    db.deprecatedActiveRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile2, rule2).setSeverity(Severity.CRITICAL));
-    // Removed rule can still be activated for instance when removing the checkstyle plugin, active rules related on checkstyle are not
-    // removed
-    // because if the plugin is re-install, quality profiles using these rule are not changed.
-    db.deprecatedActiveRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile2, removedRule).setSeverity(Severity.MAJOR));
-    dbSession.commit();
-
-    // 1. find by rule key
-
-    // in db
-    dbSession.clearCache();
-    assertThat(db.deprecatedActiveRuleDao().selectByRule(dbSession, rule1)).hasSize(1);
-    assertThat(db.deprecatedActiveRuleDao().selectByRule(dbSession, rule2)).hasSize(2);
-
-    // in es
-    List<ActiveRule> activeRules = index.get(ActiveRuleIndex.class).findByRule(RuleTesting.XOO_X1);
-    assertThat(activeRules).hasSize(1);
-    assertThat(activeRules.get(0).key().ruleKey()).isEqualTo(RuleTesting.XOO_X1);
-
-    activeRules = index.get(ActiveRuleIndex.class).findByRule(RuleTesting.XOO_X2);
-    assertThat(activeRules).hasSize(2);
-    assertThat(activeRules.get(0).key().ruleKey()).isEqualTo(RuleTesting.XOO_X2);
-
-    activeRules = index.get(ActiveRuleIndex.class).findByRule(RuleTesting.XOO_X3);
-    assertThat(activeRules).isEmpty();
-
-    // 2. find by profile
-    activeRules = Lists.newArrayList(index.get(ActiveRuleIndex.class).findByProfile(profile1.getKey()));
-    assertThat(activeRules).hasSize(2);
-    assertThat(activeRules.get(0).key().qProfile()).isEqualTo(profile1.getKey());
-    assertThat(activeRules.get(1).key().qProfile()).isEqualTo(profile1.getKey());
-
-    activeRules = Lists.newArrayList(index.get(ActiveRuleIndex.class).findByProfile(profile2.getKey()));
-    assertThat(activeRules).hasSize(1);
-    assertThat(activeRules.get(0).key().qProfile()).isEqualTo(profile2.getKey());
-
-    activeRules = Lists.newArrayList(index.get(ActiveRuleIndex.class).findByProfile("unknown"));
-    assertThat(activeRules).isEmpty();
-  }
-
-  @Test
-  public void find_many_active_rules_by_profile() {
-    // insert and index
-    QualityProfileDto profileDto = QProfileTesting.newXooP1();
-    db.qualityProfileDao().insert(dbSession, profileDto);
-    int nb = 100;
-    for (int i = 0; i < nb; i++) {
-      RuleDto rule = newRuleDto(RuleKey.of("xoo", "S00" + i));
-      db.deprecatedRuleDao().insert(dbSession, rule);
-
-      ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, rule).setSeverity(Severity.MAJOR);
-      db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
-    }
-    dbSession.commit();
-    dbSession.clearCache();
-
-    // verify index
-    Collection<ActiveRule> activeRules = Lists.newArrayList(index.get(ActiveRuleIndex.class).findByProfile(profileDto.getKey()));
-    assertThat(activeRules).hasSize(nb);
-  }
-
-  @Test
-  public void count_by_profile() {
-    QualityProfileDto profileDto1 = QProfileTesting.newXooP1();
-    QualityProfileDto profileDto2 = QProfileTesting.newXooP2();
-    db.qualityProfileDao().insert(dbSession, profileDto1, profileDto2);
-
-    RuleKey ruleKey = RuleTesting.XOO_X1;
-    RuleDto ruleDto = newRuleDto(ruleKey);
-    db.deprecatedRuleDao().insert(dbSession, ruleDto);
-
-    ActiveRuleDto activeRule1 = ActiveRuleDto.createFor(profileDto1, ruleDto).setSeverity(Severity.MAJOR);
-    ActiveRuleDto activeRule2 = ActiveRuleDto.createFor(profileDto2, ruleDto).setSeverity(Severity.MAJOR);
-    db.deprecatedActiveRuleDao().insert(dbSession, activeRule1, activeRule2);
-    dbSession.commit();
-
-    // 0. Test base case
-    assertThat(index.get(ActiveRuleIndex.class).countAll()).isEqualTo(2);
-
-    // 1. Assert by profileKey
-    assertThat(index.get(ActiveRuleIndex.class).countByQualityProfileKey(profileDto1.getKey())).isEqualTo(1);
-
-    // 2. Assert by term aggregation;
-    Map<String, Long> counts = index.get(ActiveRuleIndex.class).countByField(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY);
-    assertThat(counts).hasSize(2);
-    assertThat(counts.values()).containsOnly(1L, 1L);
-    assertThat(counts.keySet()).containsOnly(profileDto1.getKey().toString(), profileDto2.getKey().toString());
-  }
-
-  @Test
-  public void count_all_by_index_field() {
-    QualityProfileDto profileDto1 = QProfileTesting.newXooP1();
-    QualityProfileDto profileDto2 = QProfileTesting.newXooP2();
-    db.qualityProfileDao().insert(dbSession, profileDto1, profileDto2);
-
-    RuleKey ruleKey = RuleTesting.XOO_X1;
-    RuleDto ruleDto = newRuleDto(ruleKey);
-    db.deprecatedRuleDao().insert(dbSession, ruleDto);
-
-    ActiveRuleDto activeRule1 = ActiveRuleDto.createFor(profileDto1, ruleDto).setSeverity(Severity.MAJOR);
-    ActiveRuleDto activeRule2 = ActiveRuleDto.createFor(profileDto2, ruleDto).setSeverity(Severity.MAJOR);
-    db.deprecatedActiveRuleDao().insert(dbSession, activeRule1, activeRule2);
-    dbSession.commit();
-
-    // 0. Test base case
-    assertThat(index.get(ActiveRuleIndex.class).countAll()).isEqualTo(2);
-
-    // 1. Assert by term aggregation;
-    Map<String, Long> counts = index.get(ActiveRuleIndex.class).countByField(ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY);
-    assertThat(counts).hasSize(2);
-    assertThat(counts.values()).containsOnly(1L, 1L);
-    assertThat(counts.keySet()).containsOnly(profileDto1.getKey(), profileDto2.getKey());
-  }
-
-  @Test
-  public void stats_for_all() {
-    QualityProfileDto profileDto1 = QProfileTesting.newXooP1();
-    QualityProfileDto profileDto2 = QProfileTesting.newXooP2();
-    db.qualityProfileDao().insert(dbSession, profileDto1, profileDto2);
-
-    RuleDto ruleDto1 = newRuleDto(RuleTesting.XOO_X1);
-    RuleDto ruleDto2 = newRuleDto(RuleTesting.XOO_X2);
-    db.deprecatedRuleDao().insert(dbSession, ruleDto1, ruleDto2);
-
-    db.deprecatedActiveRuleDao().insert(dbSession,
-      ActiveRuleDto.createFor(profileDto1, ruleDto1)
-        .setInheritance(ActiveRule.Inheritance.INHERITED.name())
-        .setSeverity(Severity.BLOCKER),
-      ActiveRuleDto.createFor(profileDto2, ruleDto1)
-        .setInheritance(ActiveRule.Inheritance.INHERITED.name())
-        .setSeverity(Severity.MINOR),
-      ActiveRuleDto.createFor(profileDto1, ruleDto2)
-        .setInheritance(ActiveRule.Inheritance.OVERRIDES.name())
-        .setSeverity(Severity.MAJOR),
-      ActiveRuleDto.createFor(profileDto2, ruleDto2)
-        .setInheritance(ActiveRule.Inheritance.INHERITED.name())
-        .setSeverity(Severity.BLOCKER));
-    dbSession.commit();
-    dbSession.clearCache();
-
-    // 0. Test base case
-    assertThat(index.get(ActiveRuleIndex.class).countAll()).isEqualTo(4);
-
-    // 1. Assert by term aggregation;
-    Map<String, Multimap<String, FacetValue>> stats = index.get(ActiveRuleIndex.class).getStatsByProfileKeys(
-      ImmutableList.of(profileDto1.getKey(),
-        profileDto2.getKey()));
-
-    assertThat(stats).hasSize(2);
-  }
-
-  /**
-   * SONAR-5844
-   */
-  @Test
-  public void stats_for_all_with_lof_of_profiles() {
-    RuleDto ruleDto1 = newRuleDto(RuleTesting.XOO_X1);
-    RuleDto ruleDto2 = newRuleDto(RuleTesting.XOO_X2);
-    db.deprecatedRuleDao().insert(dbSession, ruleDto1, ruleDto2);
-
-    List<String> profileKeys = newArrayList();
-    for (int i = 0; i < 30; i++) {
-      QualityProfileDto profileDto = QProfileTesting.newQProfileDto(QProfileName.createFor("xoo", "profile-" + i), "profile-" + i);
-      profileKeys.add(profileDto.getKey());
-      db.qualityProfileDao().insert(dbSession, profileDto);
-
-      db.deprecatedActiveRuleDao().insert(dbSession,
-        ActiveRuleDto.createFor(profileDto, ruleDto1)
-          .setSeverity(Severity.BLOCKER),
-        ActiveRuleDto.createFor(profileDto, ruleDto2)
-          .setSeverity(Severity.MAJOR));
-    }
-    dbSession.commit();
-    dbSession.clearCache();
-
-    Map<String, Multimap<String, FacetValue>> stats = index.get(ActiveRuleIndex.class).getStatsByProfileKeys(profileKeys);
-    assertThat(stats).hasSize(30);
-  }
-
-  @Test
-  public void select_by_id() throws Exception {
-    QualityProfileDto profile = QProfileTesting.newXooP1();
-    db.qualityProfileDao().insert(dbSession, profile);
-
-    RuleDto rule = RuleDto.createFor(RuleTesting.XOO_X1).setSeverity(Severity.MAJOR);
-    db.deprecatedRuleDao().insert(dbSession, rule);
-
-    ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
-    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
-    dbSession.commit();
-
-    assertThat(db.deprecatedActiveRuleDao().selectById(dbSession, activeRule.getId()).getId()).isEqualTo(activeRule.getId());
-  }
-
-  @Test
-  public void select_by_id_return_nothing_when_rule_does_not_exist() throws Exception {
-    QualityProfileDto profile = QProfileTesting.newXooP1();
-    db.qualityProfileDao().insert(dbSession, profile);
-
-    RuleDto rule = RuleDto.createFor(RuleTesting.XOO_X1).setSeverity(Severity.MAJOR);
-    db.deprecatedRuleDao().insert(dbSession, rule);
-
-    ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
-    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
-    dbSession.commit();
-
-    // Remove rule -> Active rule is now linked to a not existing rule
-    executeSql(String.format("DELETE FROM rules WHERE id=%s", rule.getId()));
-    dbSession.commit();
-
-    assertThat(db.deprecatedActiveRuleDao().selectById(dbSession, activeRule.getId())).isNull();
-  }
-
-  @Test
-  public void select_by_id_return_nothing_when_profile_does_not_exist() throws Exception {
-    QualityProfileDto profile = QProfileTesting.newXooP1();
-    db.qualityProfileDao().insert(dbSession, profile);
-
-    RuleDto rule = RuleDto.createFor(RuleTesting.XOO_X1).setSeverity(Severity.MAJOR);
-    db.deprecatedRuleDao().insert(dbSession, rule);
-
-    ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
-    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
-    dbSession.commit();
-
-    // Remove quality profile -> active rule is now linked to a not existing quality profile
-    executeSql(String.format("DELETE FROM rules_profiles WHERE id=%s", profile.getId()));
-    dbSession.commit();
-
-    assertThat(db.deprecatedActiveRuleDao().selectById(dbSession, activeRule.getId())).isNull();
-  }
-
-  private RuleDto newRuleDto(RuleKey ruleKey) {
-    return new RuleDto()
-      .setRuleKey(ruleKey.rule())
-      .setRepositoryKey(ruleKey.repository())
-      .setName("Rule " + ruleKey.rule())
-      .setDescription("Description " + ruleKey.rule())
-      .setStatus(RuleStatus.READY)
-      .setConfigKey("InternalKey" + ruleKey.rule())
-      .setSeverity(Severity.INFO)
-      .setIsTemplate(false)
-      .setLanguage("js")
-      .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString())
-      .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString())
-      .setRemediationCoefficient("1h")
-      .setDefaultRemediationCoefficient("5d")
-      .setRemediationOffset("5min")
-      .setDefaultRemediationOffset("10h")
-      .setEffortToFixDescription(ruleKey.repository() + "." + ruleKey.rule() + ".effortToFix");
-  }
-
-  private void executeSql(String sql) throws SQLException {
-    PreparedStatement stmt = db.getDatabase().getDataSource().getConnection().prepareStatement(sql);
-    stmt.executeUpdate();
-  }
-
-}
index a91fd5ff8edf647aa84ad2225f109dde2f848c10..57048a50f583565a88934cdc318286bb3d606a89 100644 (file)
@@ -23,7 +23,6 @@ import com.google.common.collect.Maps;
 import java.util.Date;
 import java.util.Map;
 import org.joda.time.DateTime;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
@@ -34,10 +33,10 @@ import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.util.Uuids;
+import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.qualityprofile.ActiveRuleKey;
-import org.sonar.db.qualityprofile.QualityProfileDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.db.user.UserDto;
@@ -45,7 +44,6 @@ import org.sonar.server.activity.Activity;
 import org.sonar.server.activity.index.ActivityDoc;
 import org.sonar.server.activity.index.ActivityIndex;
 import org.sonar.server.activity.index.ActivityIndexDefinition;
-import org.sonar.server.db.DbClient;
 import org.sonar.server.es.EsTester;
 import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.language.LanguageTesting;
@@ -53,8 +51,6 @@ import org.sonar.server.qualityprofile.ActiveRuleChange;
 import org.sonar.server.qualityprofile.ActiveRuleChange.Type;
 import org.sonar.server.qualityprofile.QProfileFactory;
 import org.sonar.server.qualityprofile.QProfileTesting;
-import org.sonar.server.rule.db.RuleDao;
-import org.sonar.db.user.UserDao;
 import org.sonar.server.ws.WsTester;
 
 import static org.mockito.Mockito.mock;
@@ -68,8 +64,8 @@ public class ChangelogActionTest {
   @ClassRule
   public static EsTester esTester = new EsTester().addDefinitions(new ActivityIndexDefinition(new Settings()));
 
-  private DbClient db;
-  private DbSession dbSession;
+  private DbClient db = dbTester.getDbClient();
+  private DbSession dbSession = dbTester.getSession();
   private WsTester wsTester;
   private String login;
 
@@ -80,12 +76,9 @@ public class ChangelogActionTest {
 
     System2 system = mock(System2.class);
 
-    db = new DbClient(dbTester.database(), dbTester.myBatis(), new RuleDao(system), new QualityProfileDao(dbTester.myBatis(), system), new UserDao(dbTester.myBatis(), system));
-    dbSession = db.openSession(false);
-
     // create pre-defined rules
     RuleDto xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR");
-    db.deprecatedRuleDao().insert(dbSession, xooRule1);
+    db.ruleDao().insert(dbSession, xooRule1);
 
     // create pre-defined profiles P1 and P2
     db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1(), QProfileTesting.newXooP2());
@@ -101,11 +94,6 @@ public class ChangelogActionTest {
       new ChangelogAction(db, new ActivityIndex(esTester.client()), new QProfileFactory(db), LanguageTesting.newLanguages("xoo"))));
   }
 
-  @After
-  public void after() {
-    dbSession.close();
-  }
-
   @Test
   public void changelog_empty() throws Exception {
     wsTester.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam("profileKey", XOO_P1_KEY)
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java
deleted file mode 100644 (file)
index 11b8065..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.rule.db;
-
-import com.google.common.collect.Iterables;
-import java.util.List;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rule.RuleStatus;
-import org.sonar.api.rule.Severity;
-import org.sonar.api.server.debt.DebtRemediationFunction;
-import org.sonar.api.utils.DateUtils;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-import org.sonar.db.rule.RuleDto;
-import org.sonar.db.rule.RuleDto.Format;
-import org.sonar.db.rule.RuleParamDto;
-import org.sonar.test.DbTests;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@Category(DbTests.class)
-public class RuleDaoTest {
-
-  private System2 system2 = mock(System2.class);
-
-  @org.junit.Rule
-  public DbTester dbTester = DbTester.create(system2);
-
-  private RuleDao dao = new RuleDao(system2);
-
-  @Test
-  public void select_all() {
-    dbTester.prepareDbUnit(getClass(), "selectAll.xml");
-    List<RuleDto> ruleDtos = dao.selectAll(dbTester.getSession());
-
-    assertThat(ruleDtos).hasSize(1);
-
-    RuleDto ruleDto = ruleDtos.get(0);
-    assertThat(ruleDto.getId()).isEqualTo(1);
-    assertThat(ruleDto.getName()).isEqualTo("Avoid Null");
-    assertThat(ruleDto.getDescription()).isEqualTo("Should avoid NULL");
-    assertThat(ruleDto.getDescriptionFormat()).isEqualTo(Format.HTML);
-    assertThat(ruleDto.getStatus()).isEqualTo(RuleStatus.READY);
-    assertThat(ruleDto.getRepositoryKey()).isEqualTo("checkstyle");
-    assertThat(ruleDto.getNoteData()).isEqualTo("Rule note with accents \u00e9\u00e8\u00e0");
-    assertThat(ruleDto.getSubCharacteristicId()).isEqualTo(100);
-    assertThat(ruleDto.getDefaultSubCharacteristicId()).isEqualTo(101);
-    assertThat(ruleDto.getRemediationFunction()).isEqualTo("linear");
-    assertThat(ruleDto.getDefaultRemediationFunction()).isEqualTo("linear_offset");
-    assertThat(ruleDto.getRemediationCoefficient()).isEqualTo("1h");
-    assertThat(ruleDto.getDefaultRemediationCoefficient()).isEqualTo("5d");
-    assertThat(ruleDto.getRemediationOffset()).isEqualTo("5min");
-    assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("10h");
-    assertThat(ruleDto.getEffortToFixDescription()).isEqualTo("squid.S115.effortToFix");
-  }
-
-  @Test
-  public void select_by_id() {
-    dbTester.prepareDbUnit(getClass(), "selectById.xml");
-    RuleDto ruleDto = dao.selectById(dbTester.getSession(), 2);
-
-    assertThat(ruleDto.getId()).isEqualTo(2);
-    assertThat(ruleDto.getName()).isEqualTo("Avoid Null");
-    assertThat(ruleDto.getDescription()).isEqualTo("Should avoid NULL");
-    assertThat(ruleDto.getDescriptionFormat()).isEqualTo(Format.HTML);
-    assertThat(ruleDto.getStatus()).isEqualTo(RuleStatus.READY);
-    assertThat(ruleDto.getRepositoryKey()).isEqualTo("checkstyle");
-  }
-
-  @Test
-  public void select_by_rule_key() {
-    dbTester.prepareDbUnit(getClass(), "select_by_rule_key.xml");
-    assertThat(dao.getNullableByKey(dbTester.getSession(), RuleKey.of("checkstyle", "AvoidComparison"))).isNotNull();
-    assertThat(dao.getNullableByKey(dbTester.getSession(), RuleKey.of("checkstyle", "Unknown"))).isNull();
-    assertThat(dao.getNullableByKey(dbTester.getSession(), RuleKey.of("Unknown", "AvoidComparison"))).isNull();
-  }
-
-  @Test
-  public void select_by_name() {
-    dbTester.prepareDbUnit(getClass(), "select_by_name.xml");
-    RuleDto ruleDto = dao.getByName("Avoid Null", dbTester.getSession());
-
-    assertThat(ruleDto).isNotNull();
-
-    assertThat(ruleDto.getId()).isEqualTo(2);
-    assertThat(ruleDto.getName()).isEqualTo("Avoid Null");
-    assertThat(ruleDto.getDescription()).isEqualTo("Should avoid NULL");
-    assertThat(ruleDto.getStatus()).isEqualTo(RuleStatus.READY);
-    assertThat(ruleDto.getRepositoryKey()).isEqualTo("checkstyle");
-  }
-
-  @Test
-  public void select_non_manual() {
-    dbTester.prepareDbUnit(getClass(), "selectNonManual.xml");
-    List<RuleDto> ruleDtos = dao.selectByNonManual(dbTester.getSession());
-    dbTester.getSession().commit();
-    dbTester.getSession().close();
-
-    assertThat(ruleDtos.size()).isEqualTo(1);
-    RuleDto ruleDto = ruleDtos.get(0);
-    assertThat(ruleDto.getId()).isEqualTo(1);
-    assertThat(ruleDto.getName()).isEqualTo("Avoid Null");
-    assertThat(ruleDto.getDescription()).isEqualTo("Should avoid NULL");
-    assertThat(ruleDto.getStatus()).isEqualTo(RuleStatus.READY);
-    assertThat(ruleDto.getRepositoryKey()).isEqualTo("checkstyle");
-  }
-
-  @Test
-  public void update() {
-    when(system2.now()).thenReturn(DateUtils.parseDate("2014-01-01").getTime());
-
-    dbTester.prepareDbUnit(getClass(), "update.xml");
-
-    RuleDto ruleToUpdate = new RuleDto()
-      .setId(1)
-      .setRuleKey("NewRuleKey")
-      .setRepositoryKey("plugin")
-      .setName("new name")
-      .setDescription("new description")
-      .setDescriptionFormat(Format.MARKDOWN)
-      .setStatus(RuleStatus.DEPRECATED)
-      .setConfigKey("NewConfigKey")
-      .setSeverity(Severity.INFO)
-      .setIsTemplate(true)
-      .setLanguage("dart")
-      .setTemplateId(3)
-      .setNoteData("My note")
-      .setNoteUserLogin("admin")
-      .setNoteCreatedAt(DateUtils.parseDate("2013-12-19"))
-      .setNoteUpdatedAt(DateUtils.parseDate("2013-12-20"))
-      .setSubCharacteristicId(100)
-      .setDefaultSubCharacteristicId(101)
-      .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString())
-      .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString())
-      .setRemediationCoefficient("1h")
-      .setDefaultRemediationCoefficient("5d")
-      .setRemediationOffset("5min")
-      .setDefaultRemediationOffset("10h")
-      .setEffortToFixDescription("squid.S115.effortToFix");
-
-
-    dao.update(dbTester.getSession(), ruleToUpdate);
-    dbTester.getSession().commit();
-
-    dbTester.assertDbUnit(getClass(), "update-result.xml", "rules");
-  }
-
-  @Test
-  public void insert() {
-    when(system2.now()).thenReturn(DateUtils.parseDate("2013-12-16").getTime());
-
-    dbTester.prepareDbUnit(getClass(), "empty.xml");
-
-    RuleDto ruleToInsert = new RuleDto()
-      .setId(1)
-      .setRuleKey("NewRuleKey")
-      .setRepositoryKey("plugin")
-      .setName("new name")
-      .setDescription("new description")
-      .setDescriptionFormat(Format.MARKDOWN)
-      .setStatus(RuleStatus.DEPRECATED)
-      .setConfigKey("NewConfigKey")
-      .setSeverity(Severity.INFO)
-      .setIsTemplate(true)
-      .setLanguage("dart")
-      .setTemplateId(3)
-      .setSubCharacteristicId(100)
-      .setDefaultSubCharacteristicId(101)
-      .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString())
-      .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString())
-      .setRemediationCoefficient("1h")
-      .setDefaultRemediationCoefficient("5d")
-      .setRemediationOffset("5min")
-      .setDefaultRemediationOffset("10h")
-      .setEffortToFixDescription("squid.S115.effortToFix");
-
-    dao.insert(dbTester.getSession(), ruleToInsert);
-    dbTester.getSession().commit();
-
-    dbTester.assertDbUnit(getClass(), "insert-result.xml", "rules");
-  }
-
-  @Test
-  public void insert_all() {
-    when(system2.now()).thenReturn(DateUtils.parseDate("2013-12-16").getTime());
-
-    dbTester.prepareDbUnit(getClass(), "empty.xml");
-
-    RuleDto ruleToInsert1 = new RuleDto()
-      .setId(1)
-      .setRuleKey("NewRuleKey")
-      .setRepositoryKey("plugin")
-      .setName("new name")
-      .setDescription("new description")
-      .setDescriptionFormat(Format.HTML)
-      .setStatus(RuleStatus.DEPRECATED)
-      .setConfigKey("NewConfigKey")
-      .setSeverity(Severity.INFO)
-      .setIsTemplate(true)
-      .setLanguage("dart")
-      .setTemplateId(3)
-      .setSubCharacteristicId(100)
-      .setDefaultSubCharacteristicId(101)
-      .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString())
-      .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString())
-      .setRemediationCoefficient("1h")
-      .setDefaultRemediationCoefficient("5d")
-      .setRemediationOffset("5min")
-      .setDefaultRemediationOffset("10h")
-      .setEffortToFixDescription("squid.S115.effortToFix");
-
-    RuleDto ruleToInsert2 = new RuleDto()
-      .setId(2)
-      .setRuleKey("NewRuleKey2")
-      .setRepositoryKey("plugin2")
-      .setName("new name2")
-      .setDescription("new description2")
-      .setDescriptionFormat(Format.MARKDOWN)
-      .setStatus(RuleStatus.BETA)
-      .setConfigKey("NewConfigKey2")
-      .setSeverity(Severity.MAJOR)
-      .setIsTemplate(false)
-      .setLanguage("js")
-      .setTemplateId(null)
-      .setSubCharacteristicId(102)
-      .setDefaultSubCharacteristicId(103)
-      .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString())
-      .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString())
-      .setRemediationCoefficient("5d")
-      .setDefaultRemediationCoefficient("1h")
-      .setRemediationOffset("10h")
-      .setDefaultRemediationOffset("5min")
-      .setEffortToFixDescription("squid.S115.effortToFix2");
-
-    dao.insert(dbTester.getSession(), ruleToInsert1, ruleToInsert2);
-    dbTester.getSession().commit();
-
-    dbTester.assertDbUnit(getClass(), "insert_all-result.xml", "rules");
-  }
-
-  @Test
-  public void select_parameters() {
-    dbTester.prepareDbUnit(getClass(), "selectParameters.xml");
-    List<RuleParamDto> ruleDtos = dao.selectAllRuleParams(dbTester.getSession());
-
-    assertThat(ruleDtos.size()).isEqualTo(1);
-    RuleParamDto ruleDto = ruleDtos.get(0);
-    assertThat(ruleDto.getId()).isEqualTo(1);
-    assertThat(ruleDto.getName()).isEqualTo("myParameter");
-    assertThat(ruleDto.getDescription()).isEqualTo("My Parameter");
-    assertThat(ruleDto.getType()).isEqualTo("plop");
-    assertThat(ruleDto.getDefaultValue()).isEqualTo("plouf");
-  }
-
-  @Test
-  public void select_parameters_by_rule_id() {
-    dbTester.prepareDbUnit(getClass(), "select_parameters_by_rule_id.xml");
-    RuleDto rule = dao.selectById(dbTester.getSession(), 1);
-    List<RuleParamDto> ruleDtos = dao.selectRuleParamsByRuleKey(dbTester.getSession(), rule.getKey());
-
-    assertThat(ruleDtos.size()).isEqualTo(1);
-    RuleParamDto ruleDto = ruleDtos.get(0);
-    assertThat(ruleDto.getId()).isEqualTo(1);
-    assertThat(ruleDto.getName()).isEqualTo("myParameter");
-    assertThat(ruleDto.getDescription()).isEqualTo("My Parameter");
-    assertThat(ruleDto.getType()).isEqualTo("plop");
-    assertThat(ruleDto.getRuleId()).isEqualTo(1);
-  }
-
-  @Test
-  public void insert_parameter() {
-    dbTester.prepareDbUnit(getClass(), "insert_parameter.xml");
-
-    RuleDto rule1 = dao.selectById(dbTester.getSession(), 1);
-
-    RuleParamDto param = RuleParamDto.createFor(rule1)
-      .setName("max")
-      .setType("INTEGER")
-      .setDefaultValue("30")
-      .setDescription("My Parameter");
-
-    dao.insertRuleParam(dbTester.getSession(), rule1, param);
-    dbTester.getSession().commit();
-
-    dbTester.assertDbUnit(getClass(), "insert_parameter-result.xml", "rules_parameters");
-  }
-
-  @Test
-  public void update_parameter() {
-    dbTester.prepareDbUnit(getClass(), "update_parameter.xml");
-
-    RuleDto rule1 = dao.selectById(dbTester.getSession(), 1);
-
-    List<RuleParamDto> params = dao.selectRuleParamsByRuleKey(dbTester.getSession(), rule1.getKey());
-    assertThat(params).hasSize(1);
-
-    RuleParamDto param = Iterables.getFirst(params, null);
-
-    param
-      // Name will not be changed
-      .setName("format")
-      .setType("STRING")
-      .setDefaultValue("^[a-z]+(\\.[a-z][a-z0-9]*)*$")
-      .setDescription("Regular expression used to check the package names against.");
-
-    dao.updateRuleParam(dbTester.getSession(), rule1, param);
-    dbTester.getSession().commit();
-
-    dbTester.assertDbUnit(getClass(), "update_parameter-result.xml", "rules_parameters");
-  }
-}
index b084bd63be16a6ec3cdfac15764a039554227725..1837c789357ecf42f8586048fda693949589de23 100644 (file)
@@ -32,11 +32,11 @@ import org.sonar.api.rule.Severity;
 import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
+import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleParamDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.WsTester;
@@ -52,7 +52,7 @@ public class CreateActionMediumTest {
 
   @Rule
   public UserSessionRule userSessionRule = UserSessionRule.forServerTester(tester).login()
-      .setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
+    .setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
 
   WsTester wsTester;
   RuleDao ruleDao;
@@ -74,7 +74,8 @@ public class CreateActionMediumTest {
   @Test
   public void create_custom_rule() throws Exception {
     // Template rule
-    RuleDto templateRule = ruleDao.insert(session, RuleTesting.newTemplateRule(RuleKey.of("java", "S001")));
+    RuleDto templateRule = RuleTesting.newTemplateRule(RuleKey.of("java", "S001"));
+    ruleDao.insert(session, templateRule);
     RuleParamDto param = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*");
     ruleDao.insertRuleParam(session, templateRule, param);
     session.commit();
index 6c74a0fdd1ef51afee1ec656217219b4bcc26834..b2363717888e84e2e9a4894d13fe0a1d4739f2a5 100644 (file)
@@ -33,11 +33,11 @@ import org.sonar.db.qualityprofile.ActiveRuleDao;
 import org.sonar.db.qualityprofile.ActiveRuleDto;
 import org.sonar.db.qualityprofile.QualityProfileDao;
 import org.sonar.db.qualityprofile.QualityProfileDto;
+import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.server.qualityprofile.QProfileTesting;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.rule.index.RuleIndexer;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
index 989a5e311efb750ccf28f940830f4c028ffa4d5a..a50e3f9564347b720c7c33b5ecb2a6474b6caa46 100644 (file)
@@ -41,12 +41,12 @@ import org.sonar.db.qualityprofile.ActiveRuleDto;
 import org.sonar.db.qualityprofile.ActiveRuleParamDto;
 import org.sonar.db.qualityprofile.QualityProfileDao;
 import org.sonar.db.qualityprofile.QualityProfileDto;
+import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleParamDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.server.qualityprofile.QProfileTesting;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndexer;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.rule.index.RuleIndexDefinition;
 import org.sonar.server.rule.index.RuleIndexer;
 import org.sonar.server.rule.index.RuleNormalizer;
@@ -247,7 +247,9 @@ public class SearchActionMediumTest {
   public void search_template_rules() throws Exception {
     RuleDto templateRule = RuleTesting.newXooX1().setIsTemplate(true);
     ruleDao.insert(dbSession, templateRule);
-    ruleDao.insert(dbSession, RuleTesting.newXooX2()).setTemplateId(templateRule.getId());
+    RuleDto rule = RuleTesting.newXooX2();
+    rule.setTemplateId(templateRule.getId());
+    ruleDao.insert(dbSession, rule);
     dbSession.commit();
     ruleIndexer.index();
 
index 45bbd1b7aa97b1a1fb9065d09fa5a34e564deea7..371c7b172fbb93f603bf0011d8fd2b9cb5facc5e 100644 (file)
@@ -30,13 +30,13 @@ import org.sonar.api.rule.Severity;
 import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
+import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleDto.Format;
 import org.sonar.db.rule.RuleParamDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.server.rule.NewRule;
 import org.sonar.server.rule.RuleService;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.WsTester;
@@ -74,18 +74,17 @@ public class ShowActionMediumTest {
 
   @Test
   public void show_rule() throws Exception {
-    RuleDto ruleDto = ruleDao.insert(session,
-      RuleTesting.newDto(RuleKey.of("java", "S001"))
-        .setName("Rule S001")
-        .setDescription("Rule S001 <b>description</b>")
-        .setDescriptionFormat(Format.HTML)
-        .setSeverity(Severity.MINOR)
-        .setStatus(RuleStatus.BETA)
-        .setConfigKey("InternalKeyS001")
-        .setLanguage("xoo")
-        .setTags(newHashSet("tag1", "tag2"))
-        .setSystemTags(newHashSet("systag1", "systag2"))
-      );
+    RuleDto ruleDto = RuleTesting.newDto(RuleKey.of("java", "S001"))
+      .setName("Rule S001")
+      .setDescription("Rule S001 <b>description</b>")
+      .setDescriptionFormat(Format.HTML)
+      .setSeverity(Severity.MINOR)
+      .setStatus(RuleStatus.BETA)
+      .setConfigKey("InternalKeyS001")
+      .setLanguage("xoo")
+      .setTags(newHashSet("tag1", "tag2"))
+      .setSystemTags(newHashSet("systag1", "systag2"));
+    ruleDao.insert(session, ruleDto);
     RuleParamDto param = RuleParamDto.createFor(ruleDto).setName("regex").setType("STRING").setDescription("Reg *exp*").setDefaultValue(".*");
     ruleDao.insertRuleParam(session, ruleDto, param);
     session.commit();
@@ -98,21 +97,20 @@ public class ShowActionMediumTest {
 
   @Test
   public void show_rule_with_default_debt_infos() throws Exception {
-    RuleDto ruleDto = ruleDao.insert(session,
-      RuleTesting.newDto(RuleKey.of("java", "S001"))
-        .setName("Rule S001")
-        .setDescription("Rule S001 <b>description</b>")
-        .setSeverity(Severity.MINOR)
-        .setStatus(RuleStatus.BETA)
-        .setConfigKey("InternalKeyS001")
-        .setLanguage("xoo")
-        .setDefaultRemediationFunction("LINEAR_OFFSET")
-        .setDefaultRemediationCoefficient("5d")
-        .setDefaultRemediationOffset("10h")
-        .setRemediationFunction(null)
-        .setRemediationCoefficient(null)
-        .setRemediationOffset(null)
-      );
+    RuleDto ruleDto = RuleTesting.newDto(RuleKey.of("java", "S001"))
+      .setName("Rule S001")
+      .setDescription("Rule S001 <b>description</b>")
+      .setSeverity(Severity.MINOR)
+      .setStatus(RuleStatus.BETA)
+      .setConfigKey("InternalKeyS001")
+      .setLanguage("xoo")
+      .setDefaultRemediationFunction("LINEAR_OFFSET")
+      .setDefaultRemediationCoefficient("5d")
+      .setDefaultRemediationOffset("10h")
+      .setRemediationFunction(null)
+      .setRemediationCoefficient(null)
+      .setRemediationOffset(null);
+    ruleDao.insert(session, ruleDto);
     session.commit();
     session.clearCache();
 
@@ -125,7 +123,7 @@ public class ShowActionMediumTest {
 
   @Test
   public void show_rule_with_overridden_debt() throws Exception {
-    RuleDto ruleDto = ruleDao.insert(session,
+    RuleDto ruleDto =
       RuleTesting.newDto(RuleKey.of("java", "S001"))
         .setName("Rule S001")
         .setDescription("Rule S001 <b>description</b>")
@@ -138,8 +136,8 @@ public class ShowActionMediumTest {
         .setDefaultRemediationOffset(null)
         .setRemediationFunction("LINEAR_OFFSET")
         .setRemediationCoefficient("5d")
-        .setRemediationOffset("10h")
-      );
+        .setRemediationOffset("10h");
+    ruleDao.insert(session, ruleDto);
     session.commit();
     session.clearCache();
 
@@ -150,21 +148,20 @@ public class ShowActionMediumTest {
 
   @Test
   public void show_rule_with_default_and_overridden_debt_infos() throws Exception {
-    RuleDto ruleDto = ruleDao.insert(session,
-      RuleTesting.newDto(RuleKey.of("java", "S001"))
-        .setName("Rule S001")
-        .setDescription("Rule S001 <b>description</b>")
-        .setSeverity(Severity.MINOR)
-        .setStatus(RuleStatus.BETA)
-        .setConfigKey("InternalKeyS001")
-        .setLanguage("xoo")
-        .setDefaultRemediationFunction("LINEAR")
-        .setDefaultRemediationCoefficient("5min")
-        .setDefaultRemediationOffset(null)
-        .setRemediationFunction("LINEAR_OFFSET")
-        .setRemediationCoefficient("5d")
-        .setRemediationOffset("10h")
-      );
+    RuleDto ruleDto = RuleTesting.newDto(RuleKey.of("java", "S001"))
+      .setName("Rule S001")
+      .setDescription("Rule S001 <b>description</b>")
+      .setSeverity(Severity.MINOR)
+      .setStatus(RuleStatus.BETA)
+      .setConfigKey("InternalKeyS001")
+      .setLanguage("xoo")
+      .setDefaultRemediationFunction("LINEAR")
+      .setDefaultRemediationCoefficient("5min")
+      .setDefaultRemediationOffset(null)
+      .setRemediationFunction("LINEAR_OFFSET")
+      .setRemediationCoefficient("5d")
+      .setRemediationOffset("10h");
+    ruleDao.insert(session, ruleDto);
     session.commit();
     session.clearCache();
 
@@ -175,22 +172,21 @@ public class ShowActionMediumTest {
 
   @Test
   public void show_rule_with_no_default_and_no_overridden_debt() throws Exception {
-    RuleDto ruleDto = ruleDao.insert(session,
-      RuleTesting.newDto(RuleKey.of("java", "S001"))
-        .setName("Rule S001")
-        .setDescription("Rule S001 <b>description</b>")
-        .setDescriptionFormat(Format.HTML)
-        .setSeverity(Severity.MINOR)
-        .setStatus(RuleStatus.BETA)
-        .setConfigKey("InternalKeyS001")
-        .setLanguage("xoo")
-        .setDefaultRemediationFunction(null)
-        .setDefaultRemediationCoefficient(null)
-        .setDefaultRemediationOffset(null)
-        .setRemediationFunction(null)
-        .setRemediationCoefficient(null)
-        .setRemediationOffset(null)
-      );
+    RuleDto ruleDto = RuleTesting.newDto(RuleKey.of("java", "S001"))
+      .setName("Rule S001")
+      .setDescription("Rule S001 <b>description</b>")
+      .setDescriptionFormat(Format.HTML)
+      .setSeverity(Severity.MINOR)
+      .setStatus(RuleStatus.BETA)
+      .setConfigKey("InternalKeyS001")
+      .setLanguage("xoo")
+      .setDefaultRemediationFunction(null)
+      .setDefaultRemediationCoefficient(null)
+      .setDefaultRemediationOffset(null)
+      .setRemediationFunction(null)
+      .setRemediationCoefficient(null)
+      .setRemediationOffset(null);
+    ruleDao.insert(session, ruleDto);
     session.commit();
     session.clearCache();
 
@@ -202,7 +198,8 @@ public class ShowActionMediumTest {
   @Test
   public void encode_html_description_of_custom_rule() throws Exception {
     // Template rule
-    RuleDto templateRule = ruleDao.insert(session, RuleTesting.newTemplateRule(RuleKey.of("java", "S001")));
+    RuleDto templateRule = RuleTesting.newTemplateRule(RuleKey.of("java", "S001"));
+    ruleDao.insert(session, templateRule);
     session.commit();
 
     // Custom rule
index 7cd7fbbecffabe631f8bfa0d0a15f1240fbd16a9..d5a7c481057d49cf3a9fb120983fe3816da27cc5 100644 (file)
@@ -31,12 +31,12 @@ import org.sonar.api.rule.Severity;
 import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
+import org.sonar.db.rule.RuleDao;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleParamDto;
 import org.sonar.db.rule.RuleTesting;
 import org.sonar.server.rule.NewRule;
 import org.sonar.server.rule.RuleService;
-import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.WsTester;
@@ -51,7 +51,7 @@ public class UpdateActionMediumTest {
 
   @Rule
   public UserSessionRule userSessionRule = UserSessionRule.forServerTester(tester).
-      login().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
+    login().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
 
   WsTester wsTester;
 
@@ -76,7 +76,8 @@ public class UpdateActionMediumTest {
   @Test
   public void update_custom_rule() throws Exception {
     // Template rule
-    RuleDto templateRule = ruleDao.insert(session, RuleTesting.newTemplateRule(RuleKey.of("java", "S001")));
+    RuleDto templateRule = RuleTesting.newTemplateRule(RuleKey.of("java", "S001"));
+    ruleDao.insert(session, templateRule);
     RuleParamDto param = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*");
     ruleDao.insertRuleParam(session, templateRule, param);
     session.commit();
@@ -104,7 +105,8 @@ public class UpdateActionMediumTest {
   @Test
   public void fail_to_update_custom_when_description_is_empty() {
     // Template rule
-    RuleDto templateRule = ruleDao.insert(session, RuleTesting.newTemplateRule(RuleKey.of("java", "S001")));
+    RuleDto templateRule = RuleTesting.newTemplateRule(RuleKey.of("java", "S001"));
+    ruleDao.insert(session, templateRule);
 
     // Custom rule
     RuleDto customRule = RuleTesting.newCustomRule(templateRule);
@@ -112,7 +114,7 @@ public class UpdateActionMediumTest {
     session.commit();
     session.clearCache();
 
-  WsTester.TestRequest request = wsTester.newPostRequest("api/rules", "update")
+    WsTester.TestRequest request = wsTester.newPostRequest("api/rules", "update")
       .setParam("key", customRule.getKey().toString())
       .setParam("name", "My custom rule")
       .setParam("markdown_description", "");
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete-result.xml
deleted file mode 100644 (file)
index 1fb8fab..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <!--<active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"-->
-
-  <active_rules created_at="[null]" updated_at="[null]" id="2" profile_id="2" rule_id="10" failure_level="0" inheritance="[null]" />
-
-  <active_rules created_at="[null]" updated_at="[null]" id="3" profile_id="2" rule_id="11" failure_level="1" inheritance="[null]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_from_profile-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_from_profile-result.xml
deleted file mode 100644 (file)
index 7c678e3..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"/>
-
-  <!--<active_rules created_at="[null]" updated_at="[null]" id="2" profile_id="2" rule_id="10" failure_level="0" inheritance="[null]"-->
-
-  <!--<active_rules created_at="[null]" updated_at="[null]" id="3" profile_id="2" rule_id="11" failure_level="1" inheritance="[null]"-->
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_from_rule-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_from_rule-result.xml
deleted file mode 100644 (file)
index 281f14a..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"/>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="2" profile_id="2" rule_id="10" failure_level="0" inheritance="[null]"/>
-
-  <!--<active_rules created_at="[null]" updated_at="[null]" id="3" profile_id="2" rule_id="11" failure_level="1" inheritance="[null]"-->
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameter-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameter-result.xml
deleted file mode 100644 (file)
index 2fda189..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<dataset>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"/>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="2" profile_id="2" rule_id="10" failure_level="0" inheritance="[null]"/>
-
-  <!--<active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" rules_parameter_key="max" value="20"/>-->
-  <active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" rules_parameter_key="format" value="html"/>
-
-  <active_rule_parameters id="3" active_rule_id="2" rules_parameter_id="1" rules_parameter_key="max" value="15"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameters-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameters-result.xml
deleted file mode 100644 (file)
index 21b52c9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<dataset>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"/>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="2" profile_id="2" rule_id="10" failure_level="0" inheritance="[null]"/>
-
-  <!--<active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" rules_parameter_key="max" value="20"/>-->
-  <!--<active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" rules_parameter_key="format" value="html"/>-->
-
-  <active_rule_parameters id="3" active_rule_id="2" rules_parameter_id="1" rules_parameter_key="max" value="15"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameters_from_profile_id-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameters_from_profile_id-result.xml
deleted file mode 100644 (file)
index 843e245..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<dataset>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"/>
-
-  <!-- Parent of Active rule 1 -->
-  <active_rules created_at="[null]" updated_at="[null]" id="2" profile_id="2" rule_id="10" failure_level="0" inheritance="[null]"/>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="3" profile_id="2" rule_id="11" failure_level="1" inheritance="[null]"/>
-
-  <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" rules_parameter_key="max" value="20"/>
-  <active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" rules_parameter_key="format" value="html"/>
-
-  <!--<active_rule_parameters id="3" active_rule_id="2" rules_parameter_id="1" rules_parameter_key="max" value="15"/>-->
-  <!--<active_rule_parameters id="4" active_rule_id="3" rules_parameter_id="2" rules_parameter_key="format" value="text"/>-->
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameters_from_profile_id.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/delete_parameters_from_profile_id.xml
deleted file mode 100644 (file)
index 8e12efd..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<dataset>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"/>
-
-  <!-- Parent of Active rule 1 -->
-  <active_rules created_at="[null]" updated_at="[null]" id="2" profile_id="2" rule_id="10" failure_level="0" inheritance="[null]"/>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="3" profile_id="2" rule_id="11" failure_level="1" inheritance="[null]"/>
-
-  <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" rules_parameter_key="max" value="20"/>
-  <active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" rules_parameter_key="format" value="html"/>
-
-  <active_rule_parameters id="3" active_rule_id="2" rules_parameter_id="1" rules_parameter_key="max" value="15"/>
-  <active_rule_parameters id="4" active_rule_id="3" rules_parameter_id="2" rules_parameter_key="format" value="text"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/empty.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/empty.xml
deleted file mode 100644 (file)
index af2060c..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-    <rules_parameters id="1" rule_id="10" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
-
-    <rules tags="[null]" system_tags="[null]" id="10" plugin_rule_key="Parent1" plugin_name="checkstyle" name="Parent Rule 1" description="Parent Rule 1" status="READY"
-           plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00" />
-
-    <rules_profiles id="1" name="Child" language="java" parent_name="Parent" version="1"
-                    used_profile="[false]" is_default="[false]"/>
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/insert-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/insert-result.xml
deleted file mode 100644 (file)
index b2e0835..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<dataset>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/insert_parameter-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/insert_parameter-result.xml
deleted file mode 100644 (file)
index ed2e17d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<dataset>
-
-  <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" rules_parameter_key="max" value="20"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/insert_parameter.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/insert_parameter.xml
deleted file mode 100644 (file)
index 780a93b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<dataset>
-    <rules_parameters id="1" rule_id="10" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
-
-    <active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"/>
-
-    <rules tags="[null]" system_tags="[null]" id="10" plugin_rule_key="Parent1" plugin_name="checkstyle" name="Parent Rule 1" description="Parent Rule 1" status="READY"
-           plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00" />
-
-    <rules_profiles id="1" name="Child" language="java" parent_name="Parent" version="1"
-                    used_profile="[false]" is_default="[false]"/>
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/shared.xml
deleted file mode 100644 (file)
index 67a66c3..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<dataset>
-    <rules tags="[null]" system_tags="[null]" id="10" plugin_rule_key="Parent1" plugin_name="checkstyle" name="Parent Rule 1" description="Parent Rule 1" status="READY"
-           plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00" />
-
-    <rules tags="[null]" system_tags="[null]" id="11" plugin_rule_key="Parent2" plugin_name="checkstyle" name="Parent Rule 2" description="Parent Rule 2" status="READY"
-           plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00" />
-
-    <active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"/>
-
-  <!-- Parent of Active rule 1 -->
-  <active_rules created_at="[null]" updated_at="[null]" id="2" profile_id="2" rule_id="10" failure_level="0" inheritance="[null]"/>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="3" profile_id="2" rule_id="11" failure_level="1" inheritance="[null]"/>
-
-  <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" rules_parameter_key="max" value="20"/>
-  <active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" rules_parameter_key="format" value="html"/>
-
-  <active_rule_parameters id="3" active_rule_id="2" rules_parameter_id="1" rules_parameter_key="max" value="15"/>
-
-  <rules_profiles id="1" name="Child" language="java" parent_name="Parent" version="1"
-                  used_profile="[false]" is_default="[false]"/>
-
-  <rules_profiles id="2" name="Parent" language="java" parent_name="[null]" version="1"
-                  used_profile="[false]" is_default="[false]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/update-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/update-result.xml
deleted file mode 100644 (file)
index 99f81d6..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="1" profile_id="1" rule_id="10" failure_level="4" inheritance="[null]"/>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="2" profile_id="2" rule_id="10" failure_level="0" inheritance="[null]"/>
-
-  <active_rules created_at="[null]" updated_at="[null]" id="3" profile_id="2" rule_id="11" failure_level="1" inheritance="[null]"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/update_parameter-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/db/ActiveRuleDaoTest/update_parameter-result.xml
deleted file mode 100644 (file)
index 289da2f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<dataset>
-
-  <active_rule_parameters id="1" active_rule_id="2" rules_parameter_id="3" rules_parameter_key="newMax" value="30"/>
-  <active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" rules_parameter_key="format" value="html"/>
-
-  <active_rule_parameters id="3" active_rule_id="2" rules_parameter_id="1" rules_parameter_key="max" value="15"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/empty.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/empty.xml
deleted file mode 100644 (file)
index 871dedc..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<dataset>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert-result.xml
deleted file mode 100644 (file)
index 4baf0a8..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
-         plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" template_id="3"
-         note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
-         characteristic_id="100" default_characteristic_id="101"
-         remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET"
-         remediation_coeff="1h" default_remediation_coeff="5d"
-         remediation_offset="5min" default_remediation_offset="10h"
-         effort_to_fix_description="squid.S115.effortToFix" description_format="MARKDOWN"
-         created_at="2013-12-16" updated_at="2013-12-16"
-         created_at_ms="0" updated_at_ms="0"
-  />
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_all-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_all-result.xml
deleted file mode 100644 (file)
index ce6e8da..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
-         plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" created_at="2013-12-16" updated_at="2013-12-16" template_id="3"
-         note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
-         characteristic_id="100" default_characteristic_id="101"
-         remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET"
-         remediation_coeff="1h" default_remediation_coeff="5d"
-         remediation_offset="5min" default_remediation_offset="10h"
-         effort_to_fix_description="squid.S115.effortToFix" description_format="HTML"
-         created_at_ms="0" updated_at_ms="0"
-      />
-
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="NewRuleKey2" plugin_name="plugin2" name="new name2" description="new description2" status="BETA"
-         plugin_config_key="NewConfigKey2" priority="2" is_template="[false]" language="js" created_at="2013-12-16" updated_at="2013-12-16" template_id="[null]"
-         note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
-         characteristic_id="102" default_characteristic_id="103"
-         remediation_function="LINEAR_OFFSET" default_remediation_function="LINEAR"
-         remediation_coeff="5d" default_remediation_coeff="1h"
-         remediation_offset="10h" default_remediation_offset="5min"
-         effort_to_fix_description="squid.S115.effortToFix2" description_format="MARKDOWN"
-         created_at_ms="0" updated_at_ms="0"
-      />
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter-result.xml
deleted file mode 100644 (file)
index 423fc21..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<dataset>
-    <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
-           plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" created_at="2013-12-16" updated_at="2013-12-17" template_id="3"
-           note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
-           characteristic_id="100" default_characteristic_id="101"
-           remediation_function="linear" default_remediation_function="linear_offset"
-           remediation_coeff="1h" default_remediation_coeff="5d"
-           remediation_offset="5min" default_remediation_offset="10h"
-           effort_to_fix_description="squid.S115.effortToFix"
-           created_at_ms="[null]" updated_at_ms="[null]"
-            />
-  <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter.xml
deleted file mode 100644 (file)
index de4e4e9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<dataset>
-    <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
-           plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" created_at="2013-12-16" updated_at="2013-12-17" template_id="3"
-           note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
-           characteristic_id="100" default_characteristic_id="101"
-           remediation_function="linear" default_remediation_function="linear_offset"
-           remediation_coeff="1h" default_remediation_coeff="5d"
-           remediation_offset="5min" default_remediation_offset="10h"
-           effort_to_fix_description="squid.S115.effortToFix"
-           created_at_ms="[null]" updated_at_ms="[null]"
-            />
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectAll.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectAll.xml
deleted file mode 100644 (file)
index 7d870c0..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY"
-    note_data="Rule note with accents éèà" note_user_login="polop.palap" note_created_at="2013-12-25" description_format="HTML"
-    characteristic_id="100" default_characteristic_id="101"
-    remediation_function="linear" default_remediation_function="linear_offset"
-    remediation_coeff="1h" default_remediation_coeff="5d"
-    remediation_offset="5min" default_remediation_offset="10h"
-    effort_to_fix_description="squid.S115.effortToFix"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
-  />
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectById.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectById.xml
deleted file mode 100644 (file)
index 90c57a6..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle"
-         name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectNonManual.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectNonManual.xml
deleted file mode 100644 (file)
index f76ce5c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="manual" name="Manual Rule"
-         description="Should not appear" status="READY" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectParameters.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectParameters.xml
deleted file mode 100644 (file)
index 6e32ecd..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-  <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf"
-                    description="My Parameter"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_name.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_name.xml
deleted file mode 100644 (file)
index 90c57a6..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle"
-         name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_rule_key.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_rule_key.xml
deleted file mode 100644 (file)
index 90c57a6..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle"
-         name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_sub_characteristic_id.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_sub_characteristic_id.xml
deleted file mode 100644 (file)
index e897bb6..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<dataset>
-
-  <!-- Rule linked to a sub characteristic -->
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="UselessImportCheck" plugin_name="squid" name="UselessImportCheck" description="Useless imports should be removed" status="READY"
-         characteristic_id="2" default_characteristic_id="50"
-         remediation_function="LINEAR_OFFSET" default_remediation_function="LINEAR_OFFSET"
-         remediation_coeff="5d" default_remediation_coeff="5d"
-         remediation_offset="10h" default_remediation_offset="10h" updated_at="2014-02-19"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-  <!-- Rule linked to a sub characteristic -->
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="LeftCurlyBraceStartLineCheck" plugin_name="squid" name="LeftCurlyBraceStartLineCheck" description="Left curly braces should be located at the beginning of lines of code" status="READY"
-         characteristic_id="3" default_characteristic_id="50"
-         remediation_function="LINEAR_OFFSET" default_remediation_function="LINEAR_OFFSET"
-         remediation_coeff="5d" default_remediation_coeff="5d"
-         remediation_offset="10h" default_remediation_offset="10h" updated_at="2014-02-19"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-  <!-- Rule linked to a disabled sub characteristic -> should never be returned -->
-  <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="CallToFileDeleteOnExitMethod" plugin_name="squid" name="CallToFileDeleteOnExitMethod" description="CallToFileDeleteOnExitMethod" status="READY"
-         characteristic_id="11" default_characteristic_id="50"
-         remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET"
-         remediation_coeff="5d" default_remediation_coeff="5d"
-         remediation_offset="[null]" default_remediation_offset="10h" updated_at="2014-02-19"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-  <!-- Removed rule linked to one enable sub characteristic -->
-  <rules tags="[null]" system_tags="[null]" id="4" plugin_rule_key="ObjectFinalizeOverridenCallsSuperFinalizeCheck" plugin_name="squid" name="ObjectFinalizeOverridenCallsSuperFinalizeCheck" description="super.finalize() should be called at the end of Object.finalize() implementations" status="REMOVED"
-         characteristic_id="3" default_characteristic_id="50"
-         remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET"
-         remediation_coeff="5d" default_remediation_coeff="5min"
-         remediation_offset="[null]" default_remediation_offset="10h" updated_at="2014-02-19"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-  <!-- Rule linked to a sub characteristic, but only default characteristic is linked  -->
-  <rules tags="[null]" system_tags="[null]" id="5" plugin_rule_key="RightCurlyBraceStartLineCheck" plugin_name="squid" name="RightCurlyBraceStartLineCheck" description="Right curly braces should be located at the beginning of lines of code" status="READY"
-         characteristic_id="[null]" default_characteristic_id="3"
-         remediation_function="[null]" default_remediation_function="LINEAR"
-         remediation_coeff="[null]" default_remediation_coeff="5d"
-         remediation_offset="[null]" default_remediation_offset="[null]" updated_at="2014-02-19"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_language.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_language.xml
deleted file mode 100644 (file)
index 1514ed3..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY"
-         language="xoo"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
-  />
-  <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf"
-                    description="My Parameter"/>
-
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule"
-         description="Not used" status="READY" language="java"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
-  />
-  <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf"
-                    description="Other Parameter"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_id.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_id.xml
deleted file mode 100644 (file)
index 079e238..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-  <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf"
-                    description="My Parameter"/>
-
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule"
-         description="Not used" status="REMOVED"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-  <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf"
-                    description="Other Parameter"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_ids.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_ids.xml
deleted file mode 100644 (file)
index daa28d7..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule"
-         description="Not used" status="REMOVED"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-  <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf"
-                    description="My Parameter"/>
-
-  <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf"
-                    description="Other Parameter"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update-result.xml
deleted file mode 100644 (file)
index 11fadab..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name"
-         description="new description" status="DEPRECATED"
-         plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart"
-         created_at="2011-04-25 01:05:00" updated_at="2014-01-01" template_id="3"
-         note_data="My note" note_user_login="admin" note_created_at="2013-12-19" note_updated_at="2013-12-20"
-         characteristic_id="100" default_characteristic_id="101"
-         remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET"
-         remediation_coeff="1h" default_remediation_coeff="5d"
-         remediation_offset="5min" default_remediation_offset="10h"
-         effort_to_fix_description="squid.S115.effortToFix" description_format="MARKDOWN"
-         created_at_ms="1500000000000" updated_at_ms="0"
-  />
-
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Parent1" plugin_name="checkstyle"
-         name="Parent Rule 1" description="Parent Rule 1" status="READY"
-         plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00"
-         updated_at="[null]" template_id="[null]"
-         note_created_at="[null]" note_data="[null]" note_updated_at="[null]" note_user_login="[null]"
-         description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-  <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="Parent2" plugin_name="checkstyle"
-         name="Parent Rule 2" description="Parent Rule 2" status="READY"
-         plugin_config_key="Parent2" priority="2" is_template="[false]" language="dart" created_at="1982-12-14 03:15:00"
-         updated_at="[null]" template_id="[null]"
-         note_created_at="[null]" note_data="[null]" note_updated_at="[null]" note_user_login="[null]"
-         description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update.xml
deleted file mode 100644 (file)
index 95e5f4c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<dataset>
-
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY"
-         plugin_config_key="AvoidNull" priority="2" is_template="[false]" language="golo"
-         created_at="2011-04-25 01:05:00" template_id="2" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Parent1" plugin_name="checkstyle"
-         name="Parent Rule 1" description="Parent Rule 1" status="READY"
-         plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00"
-         description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-  <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="Parent2" plugin_name="checkstyle"
-         name="Parent Rule 2" description="Parent Rule 2" status="READY"
-         plugin_config_key="Parent2" priority="2" is_template="[false]" language="dart" created_at="1982-12-14 03:15:00"
-         description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter-result.xml
deleted file mode 100644 (file)
index e60f87e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<dataset>
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-  <rules_parameters id="1" rule_id="1" name="max" param_type="STRING" default_value="^[a-z]+(\.[a-z][a-z0-9]*)*$"
-                    description="Regular expression used to check the package names against."/>
-</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter.xml
deleted file mode 100644 (file)
index 8ac1921..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<dataset>
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
-         name="Avoid Null" description="Should avoid NULL" status="READY"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
-
-  <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
-</dataset>