]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7330 Rename activeRuleDao to deprecatedActiveRuleDao in DbClient
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 23 Feb 2016 15:15:35 +0000 (16:15 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 29 Feb 2016 12:26:54 +0000 (13:26 +0100)
21 files changed:
server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileReset.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java
server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
server/sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
sonar-db/src/main/java/org/sonar/db/DaoModule.java
sonar-db/src/main/java/org/sonar/db/DbClient.java
sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java

index 29443523e0c529c4ef42284f16758c168b4421b7..ea36495f8c2fb3be0440b37d98d358deff3e22cc 100644 (file)
@@ -47,7 +47,7 @@ public class DbClient extends org.sonar.db.DbClient {
     this.ruleDao = (RuleDao) daoByClass.get(RuleDao.class);
   }
 
-  public ActiveRuleDao activeRuleDao() {
+  public ActiveRuleDao deprecatedActiveRuleDao() {
     return activeRuleDao;
   }
 
index ecb01928244028c7f796f97aa97d63773ff8c12c..07e88d83649dcdd075513f6e5946d8044dd4a5e5 100644 (file)
@@ -116,7 +116,7 @@ public class QProfileFactory {
 
   private void doDelete(DbSession session, QualityProfileDto profile) {
     db.qualityProfileDao().deleteAllProjectProfileAssociation(profile.getKey(), session);
-    db.activeRuleDao().deleteByProfileKey(session, profile.getKey());
+    db.deprecatedActiveRuleDao().deleteByProfileKey(session, profile.getKey());
     db.qualityProfileDao().delete(session, profile);
   }
 
index 9b9bbc64297f81cb86143f98c36f12b4394a3a69..d598028dbca133d76b8e092e028acbed5a34401f 100644 (file)
@@ -128,7 +128,7 @@ public class QProfileReset {
     BulkChangeResult result = new BulkChangeResult(profile);
     Set<RuleKey> ruleToBeDeactivated = Sets.newHashSet();
     // Keep reference to all the activated rules before backup restore
-    for (ActiveRuleDto activeRuleDto : db.activeRuleDao().selectByProfileKey(dbSession, profile.getKee())) {
+    for (ActiveRuleDto activeRuleDto : db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, profile.getKee())) {
       if (activeRuleDto.getInheritance() == null) {
         // inherited rules can't be deactivated
         ruleToBeDeactivated.add(activeRuleDto.getKey().ruleKey());
index fa02ee1d9e1e55f1da72f8670856cd691ec1b3c6..84902c83c39e44d6997bb4ffdf053670eacd57cf 100644 (file)
@@ -235,7 +235,7 @@ public class RuleActivator {
       activeRule = doInsert(change, context, dbSession);
 
     } else if (change.getType() == ActiveRuleChange.Type.DEACTIVATED) {
-      ActiveRuleDao dao = db.activeRuleDao();
+      ActiveRuleDao dao = db.deprecatedActiveRuleDao();
       dao.deleteByKey(dbSession, change.getKey());
 
     } else if (change.getType() == ActiveRuleChange.Type.UPDATED) {
@@ -247,7 +247,7 @@ public class RuleActivator {
 
   private ActiveRuleDto doInsert(ActiveRuleChange change, RuleActivatorContext context, DbSession dbSession) {
     ActiveRuleDto activeRule;
-    ActiveRuleDao dao = db.activeRuleDao();
+    ActiveRuleDao dao = db.deprecatedActiveRuleDao();
     activeRule = ActiveRuleDto.createFor(context.profile(), context.rule());
     String severity = change.getSeverity();
     if (severity != null) {
@@ -269,7 +269,7 @@ public class RuleActivator {
   }
 
   private ActiveRuleDto doUpdate(ActiveRuleChange change, RuleActivatorContext context, DbSession dbSession) {
-    ActiveRuleDao dao = db.activeRuleDao();
+    ActiveRuleDao dao = db.deprecatedActiveRuleDao();
     ActiveRuleDto activeRule = context.activeRule();
     if (activeRule != null) {
       String severity = change.getSeverity();
@@ -331,7 +331,7 @@ public class RuleActivator {
    */
   public List<ActiveRuleChange> deactivate(DbSession dbSession, RuleDto ruleDto) {
     List<ActiveRuleChange> changes = Lists.newArrayList();
-    List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByRule(dbSession, ruleDto);
+    List<ActiveRuleDto> activeRules = db.deprecatedActiveRuleDao().selectByRule(dbSession, ruleDto);
     for (ActiveRuleDto activeRule : activeRules) {
       changes.addAll(deactivate(dbSession, activeRule.getKey(), true));
     }
@@ -478,7 +478,7 @@ public class RuleActivator {
       // set new parent
       profile.setParentKee(parentKey);
       db.qualityProfileDao().update(dbSession, profile);
-      for (ActiveRuleDto parentActiveRule : db.activeRuleDao().selectByProfileKey(dbSession, parentKey)) {
+      for (ActiveRuleDto parentActiveRule : db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, parentKey)) {
         try {
           RuleActivation activation = new RuleActivation(parentActiveRule.getKey().ruleKey());
           activate(dbSession, activation, profileKey);
@@ -497,12 +497,12 @@ public class RuleActivator {
     if (profileDto.getParentKee() != null) {
       profileDto.setParentKee(null);
       db.qualityProfileDao().update(dbSession, profileDto);
-      for (ActiveRuleDto activeRule : db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKey())) {
+      for (ActiveRuleDto activeRule : db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, profileDto.getKey())) {
         if (ActiveRuleDto.INHERITED.equals(activeRule.getInheritance())) {
           deactivate(dbSession, activeRule.getKey(), true);
         } else if (ActiveRuleDto.OVERRIDES.equals(activeRule.getInheritance())) {
           activeRule.setInheritance(null);
-          db.activeRuleDao().update(dbSession, activeRule);
+          db.deprecatedActiveRuleDao().update(dbSession, activeRule);
         }
       }
     }
index 103fa438e28276e67c8f16493896f4678124bb44..b981461b834008405f4f1c368bad6aa8115a0d04 100644 (file)
@@ -19,8 +19,9 @@
  */
 package org.sonar.server.qualityprofile;
 
-import org.sonar.api.server.ServerSide;
+import java.util.Collection;
 import org.sonar.api.rule.RuleKey;
+import org.sonar.api.server.ServerSide;
 import org.sonar.db.DbSession;
 import org.sonar.db.qualityprofile.ActiveRuleDto;
 import org.sonar.db.qualityprofile.ActiveRuleKey;
@@ -30,8 +31,6 @@ import org.sonar.db.rule.RuleDto;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.exceptions.BadRequestException;
 
-import java.util.Collection;
-
 @ServerSide
 public class RuleActivatorContextFactory {
 
@@ -87,10 +86,10 @@ public class RuleActivatorContextFactory {
 
   private void initActiveRules(String profileKey, RuleKey ruleKey, RuleActivatorContext context, DbSession session, boolean parent) {
     ActiveRuleKey key = ActiveRuleKey.of(profileKey, ruleKey);
-    ActiveRuleDto activeRule = db.activeRuleDao().getNullableByKey(session, key);
+    ActiveRuleDto activeRule = db.deprecatedActiveRuleDao().getNullableByKey(session, key);
     Collection<ActiveRuleParamDto> activeRuleParams = null;
     if (activeRule != null) {
-      activeRuleParams = db.activeRuleDao().selectParamsByActiveRuleKey(session, key);
+      activeRuleParams = db.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(session, key);
     }
     if (parent) {
       context.setParentActiveRule(activeRule);
index d9b09806d84017e863ce75313e15f50df9ef84a7..bb57481a027f0641f414bd00ac26b84413343d70 100644 (file)
@@ -104,7 +104,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
       String parentKey = null;
       Integer parentId = activeRuleDto.getParentId();
       if (parentId != null) {
-        ActiveRuleDto parentDto = db.activeRuleDao().selectById(session, parentId);
+        ActiveRuleDto parentDto = db.deprecatedActiveRuleDao().selectById(session, parentId);
         if (parentDto != null) {
           parentKey = parentDto.getKey().toString();
         }
@@ -119,7 +119,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
         .upsert(getUpsertFor(ActiveRuleField.ALL_FIELDS, newRule)));
 
       // Get the RuleParameters
-      for (ActiveRuleParamDto param : db.activeRuleDao().selectParamsByActiveRuleKey(session, key)) {
+      for (ActiveRuleParamDto param : db.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(session, key)) {
         requests.addAll(normalizeNested(param, key));
       }
 
index 68ab98c2b857bd904e6cc943f717fc4a4d8c104b..e76bfee84b5adc75c832ec939be2fb150d257045 100644 (file)
@@ -284,7 +284,7 @@ public class RegisterRules implements Startable {
     for (RuleParamDto paramDto : paramDtos) {
       RulesDefinition.Param paramDef = ruleDef.param(paramDto.getName());
       if (paramDef == null) {
-        dbClient.activeRuleDao().deleteParamsByRuleParam(session, rule, paramDto.getName());
+        dbClient.deprecatedActiveRuleDao().deleteParamsByRuleParam(session, rule, paramDto.getName());
         dbClient.ruleDao().deleteRuleParam(session, paramDto.getId());
       } else {
         if (mergeParam(paramDto, paramDef)) {
@@ -306,9 +306,9 @@ public class RegisterRules implements Startable {
         dbClient.ruleDao().insertRuleParam(session, rule, paramDto);
         if (!StringUtils.isEmpty(param.defaultValue())) {
           // Propagate the default value to existing active rules
-          for (ActiveRuleDto activeRule : dbClient.activeRuleDao().selectByRule(session, rule)) {
+          for (ActiveRuleDto activeRule : dbClient.deprecatedActiveRuleDao().selectByRule(session, rule)) {
             ActiveRuleParamDto activeParam = ActiveRuleParamDto.createFor(paramDto).setValue(param.defaultValue());
-            dbClient.activeRuleDao().insertParam(session, activeRule, activeParam);
+            dbClient.deprecatedActiveRuleDao().insertParam(session, activeRule, activeParam);
           }
         }
       }
index 0acc2497660cf87361f988db123a5293754ab0b5..8152cab7337e3b32b0ae5972a698b367f5537edd 100644 (file)
@@ -251,9 +251,9 @@ public class RuleUpdater {
       // Load active rules and its parameters in cache
       Multimap<RuleDto, ActiveRuleDto> activeRules = ArrayListMultimap.create();
       Multimap<ActiveRuleDto, ActiveRuleParamDto> activeRuleParams = ArrayListMultimap.create();
-      for (ActiveRuleDto activeRuleDto : dbClient.activeRuleDao().selectByRule(dbSession, customRule)) {
+      for (ActiveRuleDto activeRuleDto : dbClient.deprecatedActiveRuleDao().selectByRule(dbSession, customRule)) {
         activeRules.put(customRule, activeRuleDto);
-        for (ActiveRuleParamDto activeRuleParamDto : dbClient.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey())) {
+        for (ActiveRuleParamDto activeRuleParamDto : dbClient.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey())) {
           activeRuleParams.put(activeRuleDto, activeRuleParamDto);
         }
       }
@@ -278,9 +278,9 @@ public class RuleUpdater {
         for (ActiveRuleDto activeRuleDto : activeRules.get(customRule)) {
           for (ActiveRuleParamDto activeRuleParamDto : activeRuleParams.get(activeRuleDto)) {
             if (activeRuleParamDto.getKey().equals(key)) {
-              dbClient.activeRuleDao().updateParam(dbSession, activeRuleDto, activeRuleParamDto.setValue(value));
+              dbClient.deprecatedActiveRuleDao().updateParam(dbSession, activeRuleDto, activeRuleParamDto.setValue(value));
             } else {
-              dbClient.activeRuleDao().insertParam(dbSession, activeRuleDto, ActiveRuleParamDto.createFor(ruleParamDto).setValue(value));
+              dbClient.deprecatedActiveRuleDao().insertParam(dbSession, activeRuleDto, ActiveRuleParamDto.createFor(ruleParamDto).setValue(value));
             }
           }
         }
@@ -289,7 +289,7 @@ public class RuleUpdater {
         for (ActiveRuleDto activeRuleDto : activeRules.get(customRule)) {
           for (ActiveRuleParamDto activeRuleParamDto : activeRuleParams.get(activeRuleDto)) {
             if (activeRuleParamDto.getKey().equals(key)) {
-              dbClient.activeRuleDao().deleteParam(dbSession, activeRuleDto, activeRuleParamDto);
+              dbClient.deprecatedActiveRuleDao().deleteParam(dbSession, activeRuleDto, activeRuleParamDto);
             }
           }
         }
index b4e945b6df08092291f3046fc699eb4dcd188219..cdd1537afa5623406d86fbfa7ab43d5d962d941c 100644 (file)
@@ -56,7 +56,7 @@ public class DbClientTest {
 
     // DAO
     assertThat(client.qualityProfileDao()).isSameAs(qualityProfileDao);
-    assertThat(client.activeRuleDao()).isSameAs(activeRuleDao);
+    assertThat(client.deprecatedActiveRuleDao()).isSameAs(activeRuleDao);
     assertThat(client.deprecatedRuleDao()).isSameAs(ruleDao);
   }
 }
index 71935e970f87162afa86346c6dc92ad119973db8..069366b9559eecf61c7c304a34d8d4b4e973cfcb 100644 (file)
@@ -31,6 +31,7 @@ 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;
@@ -57,6 +58,8 @@ 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
@@ -97,20 +100,20 @@ public class ActiveRuleTest {
     db.deprecatedRuleDao().insert(dbSession, rule1);
 
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile1, rule1).setSeverity("BLOCKER");
-    db.activeRuleDao().insert(dbSession, activeRule);
+    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
     dbSession.commit();
 
     // 1. Synchronize since 0
     tester.clearIndexes();
     assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNull();
-    db.activeRuleDao().synchronizeAfter(dbSession, new Date(0L));
+    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.activeRuleDao().synchronizeAfter(dbSession, beginning);
+    db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, beginning);
     dbSession.commit();
     assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNotNull();
 
@@ -134,7 +137,7 @@ public class ActiveRuleTest {
     db.deprecatedRuleDao().insert(dbSession, rule);
 
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
-    db.activeRuleDao().insert(dbSession, activeRule);
+    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
     dbSession.commit();
 
     // Remove rule -> Active rule is now linked to a not existing rule
@@ -143,7 +146,7 @@ public class ActiveRuleTest {
 
     // Synchronize index from start
     tester.clearIndexes();
-    db.activeRuleDao().synchronizeAfter(dbSession, new Date(0L));
+    db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, new Date(0L));
     dbSession.commit();
 
     // Active does not exist in the index
@@ -162,7 +165,7 @@ public class ActiveRuleTest {
     db.deprecatedRuleDao().insert(dbSession, rule);
 
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
-    db.activeRuleDao().insert(dbSession, activeRule);
+    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
     dbSession.commit();
 
     // Remove quality profile -> active rule is now linked to a not existing quality profile
@@ -171,7 +174,7 @@ public class ActiveRuleTest {
 
     // Synchronize index from start
     tester.clearIndexes();
-    db.activeRuleDao().synchronizeAfter(dbSession, new Date(0L));
+    db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, new Date(0L));
     dbSession.commit();
 
     // Active does not exist in the index
@@ -189,12 +192,12 @@ public class ActiveRuleTest {
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, ruleDto)
       .setInheritance(ActiveRule.Inheritance.INHERITED.name())
       .setSeverity(Severity.BLOCKER);
-    db.activeRuleDao().insert(dbSession, activeRule);
+    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
     dbSession.commit();
 
     // verify db
-    assertThat(db.activeRuleDao().getByKey(dbSession, activeRule.getKey())).isNotNull();
-    List<ActiveRuleDto> persistedDtos = db.activeRuleDao().selectByRule(dbSession, ruleDto);
+    assertThat(db.deprecatedActiveRuleDao().getByKey(dbSession, activeRule.getKey())).isNotNull();
+    List<ActiveRuleDto> persistedDtos = db.deprecatedActiveRuleDao().selectByRule(dbSession, ruleDto);
     assertThat(persistedDtos).hasSize(1);
 
     // verify es
@@ -228,20 +231,20 @@ public class ActiveRuleTest {
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, ruleDto)
       .setInheritance(ActiveRule.Inheritance.INHERITED.name())
       .setSeverity(Severity.BLOCKER);
-    db.activeRuleDao().insert(dbSession, activeRule);
+    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
 
     ActiveRuleParamDto activeRuleMinParam = ActiveRuleParamDto.createFor(minParam)
       .setValue("minimum");
-    db.activeRuleDao().insertParam(dbSession, activeRule, activeRuleMinParam);
+    db.deprecatedActiveRuleDao().insertParam(dbSession, activeRule, activeRuleMinParam);
 
     ActiveRuleParamDto activeRuleMaxParam = ActiveRuleParamDto.createFor(maxParam)
       .setValue("maximum");
-    db.activeRuleDao().insertParam(dbSession, activeRule, activeRuleMaxParam);
+    db.deprecatedActiveRuleDao().insertParam(dbSession, activeRule, activeRuleMaxParam);
 
     dbSession.commit();
 
     // verify db
-    List<ActiveRuleParamDto> persistedDtos = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRule.getKey());
+    List<ActiveRuleParamDto> persistedDtos = db.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(dbSession, activeRule.getKey());
     assertThat(persistedDtos).hasSize(2);
 
     // verify es
@@ -264,21 +267,21 @@ public class ActiveRuleTest {
     RuleDto removedRule = RuleTesting.newDto(RuleKey.of("xoo", "removed")).setSeverity(Severity.MAJOR).setStatus(RuleStatus.REMOVED);
     db.deprecatedRuleDao().insert(dbSession, rule1, rule2, removedRule);
 
-    db.activeRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile1, rule1).setSeverity(Severity.MINOR));
-    db.activeRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile1, rule2).setSeverity(Severity.BLOCKER));
-    db.activeRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile2, rule2).setSeverity(Severity.CRITICAL));
+    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.activeRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile2, removedRule).setSeverity(Severity.MAJOR));
+    db.deprecatedActiveRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile2, removedRule).setSeverity(Severity.MAJOR));
     dbSession.commit();
 
     // 1. find by rule key
 
     // in db
     dbSession.clearCache();
-    assertThat(db.activeRuleDao().selectByRule(dbSession, rule1)).hasSize(1);
-    assertThat(db.activeRuleDao().selectByRule(dbSession, rule2)).hasSize(2);
+    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);
@@ -317,7 +320,7 @@ public class ActiveRuleTest {
       db.deprecatedRuleDao().insert(dbSession, rule);
 
       ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, rule).setSeverity(Severity.MAJOR);
-      db.activeRuleDao().insert(dbSession, activeRule);
+      db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
     }
     dbSession.commit();
     dbSession.clearCache();
@@ -339,7 +342,7 @@ public class ActiveRuleTest {
 
     ActiveRuleDto activeRule1 = ActiveRuleDto.createFor(profileDto1, ruleDto).setSeverity(Severity.MAJOR);
     ActiveRuleDto activeRule2 = ActiveRuleDto.createFor(profileDto2, ruleDto).setSeverity(Severity.MAJOR);
-    db.activeRuleDao().insert(dbSession, activeRule1, activeRule2);
+    db.deprecatedActiveRuleDao().insert(dbSession, activeRule1, activeRule2);
     dbSession.commit();
 
     // 0. Test base case
@@ -367,7 +370,7 @@ public class ActiveRuleTest {
 
     ActiveRuleDto activeRule1 = ActiveRuleDto.createFor(profileDto1, ruleDto).setSeverity(Severity.MAJOR);
     ActiveRuleDto activeRule2 = ActiveRuleDto.createFor(profileDto2, ruleDto).setSeverity(Severity.MAJOR);
-    db.activeRuleDao().insert(dbSession, activeRule1, activeRule2);
+    db.deprecatedActiveRuleDao().insert(dbSession, activeRule1, activeRule2);
     dbSession.commit();
 
     // 0. Test base case
@@ -390,7 +393,7 @@ public class ActiveRuleTest {
     RuleDto ruleDto2 = newRuleDto(RuleTesting.XOO_X2);
     db.deprecatedRuleDao().insert(dbSession, ruleDto1, ruleDto2);
 
-    db.activeRuleDao().insert(dbSession,
+    db.deprecatedActiveRuleDao().insert(dbSession,
       ActiveRuleDto.createFor(profileDto1, ruleDto1)
         .setInheritance(ActiveRule.Inheritance.INHERITED.name())
         .setSeverity(Severity.BLOCKER),
@@ -432,7 +435,7 @@ public class ActiveRuleTest {
       profileKeys.add(profileDto.getKey());
       db.qualityProfileDao().insert(dbSession, profileDto);
 
-      db.activeRuleDao().insert(dbSession,
+      db.deprecatedActiveRuleDao().insert(dbSession,
         ActiveRuleDto.createFor(profileDto, ruleDto1)
           .setSeverity(Severity.BLOCKER),
         ActiveRuleDto.createFor(profileDto, ruleDto2)
@@ -454,10 +457,10 @@ public class ActiveRuleTest {
     db.deprecatedRuleDao().insert(dbSession, rule);
 
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
-    db.activeRuleDao().insert(dbSession, activeRule);
+    db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
     dbSession.commit();
 
-    assertThat(db.activeRuleDao().selectById(dbSession, activeRule.getId()).getId()).isEqualTo(activeRule.getId());
+    assertThat(db.deprecatedActiveRuleDao().selectById(dbSession, activeRule.getId()).getId()).isEqualTo(activeRule.getId());
   }
 
   @Test
@@ -469,14 +472,14 @@ public class ActiveRuleTest {
     db.deprecatedRuleDao().insert(dbSession, rule);
 
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
-    db.activeRuleDao().insert(dbSession, activeRule);
+    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.activeRuleDao().selectById(dbSession, activeRule.getId())).isNull();
+    assertThat(db.deprecatedActiveRuleDao().selectById(dbSession, activeRule.getId())).isNull();
   }
 
   @Test
@@ -488,14 +491,14 @@ public class ActiveRuleTest {
     db.deprecatedRuleDao().insert(dbSession, rule);
 
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
-    db.activeRuleDao().insert(dbSession, activeRule);
+    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.activeRuleDao().selectById(dbSession, activeRule.getId())).isNull();
+    assertThat(db.deprecatedActiveRuleDao().selectById(dbSession, activeRule.getId())).isNull();
   }
 
   private RuleDto newRuleDto(RuleKey ruleKey) {
index ee7c0633a5e9d599b976a72b48632ff6bfffe8d4..1adb893bb524e5fc68a3e6c713a6e6be66583172 100644 (file)
@@ -318,7 +318,7 @@ public class QProfileBackuperMediumTest {
       null);
 
     dbSession.clearCache();
-    assertThat(db.activeRuleDao().selectAll(dbSession)).hasSize(0);
+    assertThat(db.deprecatedActiveRuleDao().selectAll(dbSession)).hasSize(0);
     List<QualityProfileDto> profiles = db.qualityProfileDao().selectAll(dbSession);
     assertThat(profiles).hasSize(1);
     assertThat(profiles.get(0).getName()).isEqualTo("P1");
index 5ea5d7c6ebbc6b279a260a1bae91c93071db95d8..d94a6bd6abafa73b87821f9ea41819024b1f5afa 100644 (file)
@@ -212,8 +212,8 @@ public class QProfileFactoryMediumTest {
 
     dbSession.clearCache();
     assertThat(db.qualityProfileDao().selectAll(dbSession)).isEmpty();
-    assertThat(db.activeRuleDao().selectAll(dbSession)).isEmpty();
-    assertThat(db.activeRuleDao().selectAllParams(dbSession)).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectAll(dbSession)).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectAllParams(dbSession)).isEmpty();
     assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P1_KEY)).isEmpty();
   }
 
@@ -229,14 +229,14 @@ public class QProfileFactoryMediumTest {
     dbSession.commit();
     dbSession.clearCache();
     assertThat(db.qualityProfileDao().selectAll(dbSession)).hasSize(3);
-    assertThat(db.activeRuleDao().selectAll(dbSession)).hasSize(3);
+    assertThat(db.deprecatedActiveRuleDao().selectAll(dbSession)).hasSize(3);
 
     factory.delete(XOO_P1_KEY);
 
     dbSession.clearCache();
     assertThat(db.qualityProfileDao().selectAll(dbSession)).isEmpty();
-    assertThat(db.activeRuleDao().selectAll(dbSession)).isEmpty();
-    assertThat(db.activeRuleDao().selectAllParams(dbSession)).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectAll(dbSession)).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectAllParams(dbSession)).isEmpty();
     assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P1_KEY)).isEmpty();
     assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P2_KEY)).isEmpty();
     assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P3_KEY)).isEmpty();
index 70e8382e096972877a38030af1bcf1719d4d680a..9a192525ece3904da463d060af5cb8ce77ae40f1 100644 (file)
@@ -33,12 +33,12 @@ import org.sonar.api.server.rule.RuleParamType;
 import org.sonar.api.server.rule.RulesDefinition;
 import org.sonar.api.utils.ValidationMessages;
 import org.sonar.db.DbSession;
+import org.sonar.db.loadedtemplate.LoadedTemplateDto;
 import org.sonar.db.qualityprofile.ActiveRuleDto;
 import org.sonar.db.qualityprofile.ActiveRuleKey;
 import org.sonar.db.qualityprofile.ActiveRuleParamDto;
 import org.sonar.db.qualityprofile.QualityProfileDao;
 import org.sonar.db.qualityprofile.QualityProfileDto;
-import org.sonar.db.loadedtemplate.LoadedTemplateDto;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.platform.Platform;
 import org.sonar.server.qualityprofile.db.ActiveRuleDao;
@@ -76,7 +76,7 @@ public class RegisterQualityProfilesMediumTest {
     assertThat(profile).isNotNull();
 
     // Check ActiveRules in DB
-    ActiveRuleDao activeRuleDao = dbClient().activeRuleDao();
+    ActiveRuleDao activeRuleDao = dbClient().deprecatedActiveRuleDao();
     assertThat(activeRuleDao.selectByProfileKey(dbSession, profile.getKey())).hasSize(2);
     RuleKey ruleKey = RuleKey.of("xoo", "x1");
     ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), ruleKey);
@@ -122,7 +122,7 @@ public class RegisterQualityProfilesMediumTest {
     verifyDefaultProfile("xoo", "Basic");
 
     // Check ActiveRules in DB
-    ActiveRuleDao activeRuleDao = dbClient().activeRuleDao();
+    ActiveRuleDao activeRuleDao = dbClient().deprecatedActiveRuleDao();
     assertThat(activeRuleDao.selectByProfileKey(dbSession, profile.getKey())).hasSize(2);
     RuleKey ruleKey = RuleKey.of("xoo", "x1");
 
index b3da4cb487a0a8e80a8072b970788f8713c3dd12..8bda831464f5e965068ca4ab4bf52f9dc85ae994 100644 (file)
@@ -42,11 +42,11 @@ 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.exceptions.BadRequestException;
 import org.sonar.server.exceptions.Message;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
-import org.sonar.db.rule.RuleTesting;
 import org.sonar.server.rule.index.RuleIndex;
 import org.sonar.server.rule.index.RuleQuery;
 import org.sonar.server.search.QueryContext;
@@ -264,10 +264,10 @@ public class RuleActivatorMediumTest {
     activation.setSeverity(Severity.BLOCKER);
     activate(activation, XOO_P1_KEY);
 
-    assertThat(db.activeRuleDao().selectParamByKeyAndName(activeRuleKey, "max", dbSession)).isNotNull();
-    db.activeRuleDao().deleteParamByKeyAndName(dbSession, activeRuleKey, "max");
+    assertThat(db.deprecatedActiveRuleDao().selectParamByKeyAndName(activeRuleKey, "max", dbSession)).isNotNull();
+    db.deprecatedActiveRuleDao().deleteParamByKeyAndName(dbSession, activeRuleKey, "max");
     dbSession.commit();
-    assertThat(db.activeRuleDao().selectParamByKeyAndName(activeRuleKey, "max", dbSession)).isNull();
+    assertThat(db.deprecatedActiveRuleDao().selectParamByKeyAndName(activeRuleKey, "max", dbSession)).isNull();
     dbSession.clearCache();
 
     // update
@@ -853,7 +853,7 @@ public class RuleActivatorMediumTest {
 
     // 2. assert that all activation has been commit to DB and ES
     dbSession.clearCache();
-    assertThat(db.activeRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).hasSize(bulkSize);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).hasSize(bulkSize);
     assertThat(index.findByProfile(XOO_P1_KEY)).hasSize(bulkSize);
     assertThat(result.countSucceeded()).isEqualTo(bulkSize);
     assertThat(result.countFailed()).isEqualTo(0);
@@ -867,7 +867,7 @@ public class RuleActivatorMediumTest {
     // 2. assert that all activations have been commit to DB and ES
     // -> xoo rules x1, x2 and custom1
     dbSession.clearCache();
-    assertThat(db.activeRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).hasSize(3);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).hasSize(3);
     assertThat(index.findByProfile(XOO_P1_KEY)).hasSize(3);
     assertThat(result.countSucceeded()).isEqualTo(3);
     assertThat(result.countFailed()).isGreaterThan(0);
@@ -1035,7 +1035,7 @@ public class RuleActivatorMediumTest {
   }
 
   private int countActiveRules(String profileKey) {
-    List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().selectByProfileKey(dbSession, profileKey);
+    List<ActiveRuleDto> activeRuleDtos = db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, profileKey);
     List<ActiveRule> activeRules = Lists.newArrayList(index.findByProfile(profileKey));
     assertThat(activeRuleDtos.size()).as("Not same active rules between db and index").isEqualTo(activeRules.size());
     return activeRuleDtos.size();
@@ -1056,7 +1056,7 @@ public class RuleActivatorMediumTest {
     @Nullable String expectedInheritance, Map<String, String> expectedParams) {
     // verify db
     boolean found = false;
-    List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().selectByProfileKey(dbSession, activeRuleKey.qProfile());
+    List<ActiveRuleDto> activeRuleDtos = db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, activeRuleKey.qProfile());
     for (ActiveRuleDto activeRuleDto : activeRuleDtos) {
       if (activeRuleDto.getKey().equals(activeRuleKey)) {
         found = true;
@@ -1066,10 +1066,10 @@ public class RuleActivatorMediumTest {
         assertThat(activeRuleDto.getCreatedAt()).isNotNull();
         assertThat(activeRuleDto.getUpdatedAt()).isNotNull();
 
-        List<ActiveRuleParamDto> paramDtos = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey());
+        List<ActiveRuleParamDto> paramDtos = db.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey());
         assertThat(paramDtos).hasSize(expectedParams.size());
         for (Map.Entry<String, String> entry : expectedParams.entrySet()) {
-          ActiveRuleParamDto paramDto = db.activeRuleDao().selectParamByKeyAndName(activeRuleDto.getKey(), entry.getKey(), dbSession);
+          ActiveRuleParamDto paramDto = db.deprecatedActiveRuleDao().selectParamByKeyAndName(activeRuleDto.getKey(), entry.getKey(), dbSession);
           assertThat(paramDto).isNotNull();
           assertThat(paramDto.getValue()).isEqualTo(entry.getValue());
         }
@@ -1117,7 +1117,7 @@ public class RuleActivatorMediumTest {
   private void verifyZeroActiveRules(String key) {
     // verify db
     dbSession.clearCache();
-    List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().selectByProfileKey(dbSession, key);
+    List<ActiveRuleDto> activeRuleDtos = db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, key);
     assertThat(activeRuleDtos).isEmpty();
 
     // verify es
index abf7293d8d8b0cf78196a8da993ac84e2ae84f6d..b1f5ddb536133b516403cf45061ac7fa082ea2f5 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.qualityprofile.ws;
 
+import java.util.List;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -42,8 +43,6 @@ import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.WsTester;
 
-import java.util.List;
-
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class ChangeParentActionMediumTest {
@@ -83,7 +82,7 @@ public class ChangeParentActionMediumTest {
     createActiveRule(rule1, parent1);
     session.commit();
 
-    assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
 
     // Set parent
     wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent")
@@ -93,7 +92,7 @@ public class ChangeParentActionMediumTest {
     session.clearCache();
 
     // Check rule 1 enabled
-    List<ActiveRuleDto> activeRules1 = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+    List<ActiveRuleDto> activeRules1 = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
     assertThat(activeRules1).hasSize(1);
     assertThat(activeRules1.get(0).getKey().ruleKey().rule()).isEqualTo("rule1");
   }
@@ -122,7 +121,7 @@ public class ChangeParentActionMediumTest {
     session.clearCache();
 
     // Check rule 2 enabled
-    List<ActiveRuleDto> activeRules2 = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+    List<ActiveRuleDto> activeRules2 = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
     assertThat(activeRules2).hasSize(1);
     assertThat(activeRules2.get(0).getKey().ruleKey().rule()).isEqualTo("rule2");
   }
@@ -147,7 +146,7 @@ public class ChangeParentActionMediumTest {
     session.clearCache();
 
     // Check no rule enabled
-    List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+    List<ActiveRuleDto> activeRules = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
     assertThat(activeRules).isEmpty();
   }
 
@@ -163,7 +162,7 @@ public class ChangeParentActionMediumTest {
     createActiveRule(rule2, parent2);
     session.commit();
 
-    assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
 
     // 1. Set parent 1
     wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent")
@@ -174,7 +173,7 @@ public class ChangeParentActionMediumTest {
     session.clearCache();
 
     // 1. check rule 1 enabled
-    List<ActiveRuleDto> activeRules1 = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+    List<ActiveRuleDto> activeRules1 = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
     assertThat(activeRules1).hasSize(1);
     assertThat(activeRules1.get(0).getKey().ruleKey().rule()).isEqualTo("rule1");
 
@@ -187,7 +186,7 @@ public class ChangeParentActionMediumTest {
     session.clearCache();
 
     // 2. check rule 2 enabled
-    List<ActiveRuleDto> activeRules2 = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+    List<ActiveRuleDto> activeRules2 = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
     assertThat(activeRules2).hasSize(1);
     assertThat(activeRules2.get(0).getKey().ruleKey().rule()).isEqualTo("rule2");
 
@@ -200,7 +199,7 @@ public class ChangeParentActionMediumTest {
     session.clearCache();
 
     // 3. check no rule enabled
-    List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+    List<ActiveRuleDto> activeRules = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
     assertThat(activeRules).isEmpty();
   }
 
@@ -213,7 +212,7 @@ public class ChangeParentActionMediumTest {
     createActiveRule(rule1, parent);
     session.commit();
 
-    assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
 
     // Set parent
     tester.get(RuleActivator.class).setParent(child.getKey(), parent.getKey());
@@ -227,7 +226,7 @@ public class ChangeParentActionMediumTest {
     session.clearCache();
 
     // Check no rule enabled
-    List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+    List<ActiveRuleDto> activeRules = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
     assertThat(activeRules).isEmpty();
   }
 
@@ -236,7 +235,7 @@ public class ChangeParentActionMediumTest {
     QualityProfileDto child = createProfile("xoo", "Child");
     session.commit();
 
-    assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
 
     wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent")
       .setParam(QProfileIdentificationParamUtils.PARAM_PROFILE_KEY, child.getKee())
@@ -250,7 +249,7 @@ public class ChangeParentActionMediumTest {
     QualityProfileDto child = createProfile("xoo", "Child");
     session.commit();
 
-    assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
 
     wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent")
       .setParam(QProfileIdentificationParamUtils.PARAM_PROFILE_KEY, child.getKee())
@@ -286,7 +285,7 @@ public class ChangeParentActionMediumTest {
   private ActiveRuleDto createActiveRule(RuleDto rule, QualityProfileDto profile) {
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
       .setSeverity(rule.getSeverityString());
-    db.activeRuleDao().insert(session, activeRule);
+    db.deprecatedActiveRuleDao().insert(session, activeRule);
     return activeRule;
   }
 }
index f2d2ef622756954259d43af1c00dc620169e276b..6eb039a765aeb987c5af1792e01ca1889f290562 100644 (file)
@@ -216,7 +216,7 @@ public class CompareActionMediumTest {
   private ActiveRuleDto createActiveRule(RuleDto rule, QualityProfileDto profile) {
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
       .setSeverity(rule.getSeverityString());
-    db.activeRuleDao().insert(session, activeRule);
+    db.deprecatedActiveRuleDao().insert(session, activeRule);
     return activeRule;
   }
 
@@ -224,14 +224,14 @@ public class CompareActionMediumTest {
     ActiveRuleDto activeRule = createActiveRule(rule, profile);
     RuleParamDto paramDto = db.deprecatedRuleDao().selectRuleParamsByRuleKey(session, rule.getKey()).get(0);
     ActiveRuleParamDto activeRuleParam = ActiveRuleParamDto.createFor(paramDto).setValue(value);
-    db.activeRuleDao().insertParam(session, activeRule, activeRuleParam);
+    db.deprecatedActiveRuleDao().insertParam(session, activeRule, activeRuleParam);
     return activeRule;
   }
 
   private ActiveRuleDto createActiveRuleWithSeverity(RuleDto rule, QualityProfileDto profile, String severity) {
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
       .setSeverity(severity);
-    db.activeRuleDao().insert(session, activeRule);
+    db.deprecatedActiveRuleDao().insert(session, activeRule);
     return activeRule;
   }
 }
index 6ea4b0e667776bc89e7034606f14fdb85b661664..54547ff4b6772b78e6d40dfe2c46d07a7cfb52c8 100644 (file)
@@ -137,7 +137,7 @@ public class InheritanceActionMediumTest {
   private ActiveRuleDto createActiveRule(RuleDto rule, QualityProfileDto profile) {
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
       .setSeverity(rule.getSeverityString());
-    db.activeRuleDao().insert(session, activeRule);
+    db.deprecatedActiveRuleDao().insert(session, activeRule);
     return activeRule;
   }
 
index 0d6ba1e97fa2a3619dfb2030ae7e8c9ed72b02ad..842b38fb94abcf125679f1f0d72994b8f5287f7e 100644 (file)
@@ -29,9 +29,9 @@ import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.server.ws.WebService;
-import org.sonar.db.component.ComponentDto;
 import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.db.DbSession;
+import org.sonar.db.component.ComponentDto;
 import org.sonar.db.qualityprofile.ActiveRuleDto;
 import org.sonar.db.qualityprofile.ActiveRuleKey;
 import org.sonar.db.qualityprofile.QualityProfileDto;
@@ -89,7 +89,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
 
     // 1. Deactivate Rule
     WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.DEACTIVATE_ACTION);
@@ -99,7 +99,7 @@ public class QProfilesWsMediumTest {
     session.clearCache();
 
     // 2. Assert ActiveRule in DAO
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
   }
 
   @Test
@@ -116,7 +116,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4);
 
     // 1. Deactivate Rule
     WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_DEACTIVATE_ACTION);
@@ -125,7 +125,7 @@ public class QProfilesWsMediumTest {
     session.clearCache();
 
     // 2. Assert ActiveRule in DAO
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
   }
 
   @Test
@@ -141,7 +141,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2);
 
     // 1. Deactivate Rule
     WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_DEACTIVATE_ACTION);
@@ -150,8 +150,8 @@ public class QProfilesWsMediumTest {
     session.clearCache();
 
     // 2. Assert ActiveRule in DAO
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
-    assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2);
   }
 
   @Test
@@ -164,7 +164,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2);
 
     // 1. Deactivate Rule
     WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_DEACTIVATE_ACTION);
@@ -174,7 +174,7 @@ public class QProfilesWsMediumTest {
     session.clearCache();
 
     // 2. Assert ActiveRule in DAO
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
   }
 
   @Test
@@ -184,7 +184,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
 
     // 1. Activate Rule
     WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.ACTIVATE_ACTION);
@@ -194,7 +194,7 @@ public class QProfilesWsMediumTest {
     session.clearCache();
 
     // 2. Assert ActiveRule in DAO
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
   }
 
   @Test
@@ -204,7 +204,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
 
     try {
       // 1. Activate Rule
@@ -226,7 +226,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
 
     // 1. Activate Rule
     WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.ACTIVATE_ACTION);
@@ -239,7 +239,7 @@ public class QProfilesWsMediumTest {
     // 2. Assert ActiveRule in DAO
     ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), rule.getKey());
 
-    assertThat(db.activeRuleDao().getNullableByKey(session, activeRuleKey).getSeverityString())
+    assertThat(db.deprecatedActiveRuleDao().getNullableByKey(session, activeRuleKey).getSeverityString())
       .isEqualTo("MINOR");
   }
 
@@ -253,7 +253,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
 
     // 1. Activate Rule
     WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION);
@@ -263,7 +263,7 @@ public class QProfilesWsMediumTest {
     session.clearCache();
 
     // 2. Assert ActiveRule in DAO
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4);
   }
 
   @Test
@@ -277,7 +277,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, php.getKey())).isEmpty();
 
     // 1. Activate Rule
     WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION);
@@ -287,7 +287,7 @@ public class QProfilesWsMediumTest {
     session.clearCache();
 
     // 2. Assert ActiveRule in DAO
-    assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2);
   }
 
   @Test
@@ -300,7 +300,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
 
     // 1. Activate Rule with query returning 0 hits
     WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION);
@@ -310,7 +310,7 @@ public class QProfilesWsMediumTest {
     session.clearCache();
 
     // 2. Assert ActiveRule in DAO
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
 
     // 1. Activate Rule with query returning 1 hits
     request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION);
@@ -320,7 +320,7 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 2. Assert ActiveRule in DAO
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
   }
 
   @Test
@@ -331,8 +331,8 @@ public class QProfilesWsMediumTest {
     session.commit();
 
     // 0. Assert No Active Rule for profile
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
-    assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+    assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
 
     // 2. Assert ActiveRule with BLOCKER severity
     assertThat(tester.get(RuleIndex.class).search(
@@ -362,12 +362,12 @@ public class QProfilesWsMediumTest {
       .setSeverity(rule.getSeverityString());
     ActiveRuleDto active2 = ActiveRuleDto.createFor(subProfile, rule)
       .setSeverity("MINOR");
-    db.activeRuleDao().insert(session, active1, active2);
+    db.deprecatedActiveRuleDao().insert(session, active1, active2);
 
     session.commit();
 
     // 0. assert rule child rule is minor
-    assertThat(db.activeRuleDao().getByKey(session, active2.getKey()).getSeverityString()).isEqualTo("MINOR");
+    assertThat(db.deprecatedActiveRuleDao().getByKey(session, active2.getKey()).getSeverityString()).isEqualTo("MINOR");
 
     // 1. reset child rule
     WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.ACTIVATE_ACTION);
@@ -378,7 +378,7 @@ public class QProfilesWsMediumTest {
     session.clearCache();
 
     // 2. assert rule child rule is NOT minor
-    assertThat(db.activeRuleDao().getByKey(session, active2.getKey()).getSeverityString()).isNotEqualTo("MINOR");
+    assertThat(db.deprecatedActiveRuleDao().getByKey(session, active2.getKey()).getSeverityString()).isNotEqualTo("MINOR");
   }
 
   @Test
@@ -566,7 +566,7 @@ public class QProfilesWsMediumTest {
   private ActiveRuleDto createActiveRule(RuleDto rule, QualityProfileDto profile) {
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
       .setSeverity(rule.getSeverityString());
-    db.activeRuleDao().insert(session, activeRule);
+    db.deprecatedActiveRuleDao().insert(session, activeRule);
     return activeRule;
   }
 }
index 96c1d3f644915a4ffa5952c619f54f91e5215e12..ef2eb59fdabf476d48519cf410bf8796b80a00cd 100644 (file)
@@ -57,6 +57,7 @@ import org.sonar.db.purge.PurgeDao;
 import org.sonar.db.qualitygate.ProjectQgateAssociationDao;
 import org.sonar.db.qualitygate.QualityGateConditionDao;
 import org.sonar.db.qualitygate.QualityGateDao;
+import org.sonar.db.qualityprofile.ActiveRuleDao;
 import org.sonar.db.qualityprofile.QualityProfileDao;
 import org.sonar.db.rule.RuleDao;
 import org.sonar.db.source.FileSourceDao;
@@ -107,6 +108,7 @@ public class DaoModule extends Module {
     QualityProfileDao.class,
     PurgeDao.class,
     RuleDao.class,
+    ActiveRuleDao.class,
     ResourceIndexDao.class,
     ResourceDao.class,
     ResourceKeyUpdaterDao.class,
index 601a45322676f53cf631271262cf5ee2a6393f7a..1927db7cace7adf60bc0194101501b7695b5f61c 100644 (file)
@@ -57,6 +57,7 @@ import org.sonar.db.purge.PurgeDao;
 import org.sonar.db.qualitygate.ProjectQgateAssociationDao;
 import org.sonar.db.qualitygate.QualityGateConditionDao;
 import org.sonar.db.qualitygate.QualityGateDao;
+import org.sonar.db.qualityprofile.ActiveRuleDao;
 import org.sonar.db.qualityprofile.QualityProfileDao;
 import org.sonar.db.rule.RuleDao;
 import org.sonar.db.source.FileSourceDao;
@@ -119,6 +120,7 @@ public class DbClient {
   private final MetricDao metricDao;
   private final GroupDao groupDao;
   private final RuleDao ruleDao;
+  private final ActiveRuleDao activeRuleDao;
 
   public DbClient(Database database, MyBatis myBatis, Dao... daos) {
     this.database = database;
@@ -174,6 +176,7 @@ public class DbClient {
     metricDao = getDao(map, MetricDao.class);
     groupDao = getDao(map, GroupDao.class);
     ruleDao = getDao(map, RuleDao.class);
+    activeRuleDao = getDao(map, ActiveRuleDao.class);
     doOnLoad(map);
   }
 
@@ -378,6 +381,10 @@ public class DbClient {
     return ruleDao;
   }
 
+  public ActiveRuleDao activeRuleDao() {
+    return activeRuleDao;
+  }
+
   protected <K extends Dao> K getDao(Map<Class, Dao> map, Class<K> clazz) {
     return (K) map.get(clazz);
   }
index 61215aa8b3a7389497f2efef008a7cd41cbce4fb..7e5f79e1d2257195e8a9b5adbfb2f11590548a23 100644 (file)
@@ -29,6 +29,6 @@ public class DaoModuleTest {
   public void verify_count_of_added_components() {
     ComponentContainer container = new ComponentContainer();
     new DaoModule().configure(container);
-    assertThat(container.size()).isEqualTo(48);
+    assertThat(container.size()).isEqualTo(49);
   }
 }