aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-02-26 16:54:43 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-02-29 13:26:54 +0100
commit5398bad124d6160f84822236cb651fec548d8738 (patch)
treef4d6bc7aa70059cafaa63a77544171ce74f9a8a0 /server
parent14afcfa29577ad02ab85f176ca507a9a4b11964d (diff)
downloadsonarqube-5398bad124d6160f84822236cb651fec548d8738.tar.gz
sonarqube-5398bad124d6160f84822236cb651fec548d8738.zip
SONAR-7330 Replace usage of selectParamsByActiveRuleKey by selectParamsByActiveRuleId
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java23
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java7
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java2
11 files changed, 35 insertions, 20 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java
index b227872fc61..6a3566435aa 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java
@@ -88,7 +88,7 @@ public class QProfileBackuper {
xml.prop("key", activeRule.getKey().ruleKey().rule());
xml.prop("priority", activeRule.getSeverityString());
xml.begin("parameters");
- for (ActiveRuleParamDto param : db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRule.getKey())) {
+ for (ActiveRuleParamDto param : db.activeRuleDao().selectParamsByActiveRuleId(dbSession, activeRule.getId())) {
xml
.begin("parameter")
.prop("key", param.getKey())
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java
index 057b1dfb5e5..afe1620aa94 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java
@@ -85,8 +85,8 @@ public class QProfileComparison {
private void compareActivationParams(DbSession session, ActiveRuleDto leftRule, ActiveRuleDto rightRule, QProfileComparisonResult result) {
RuleKey key = leftRule.getKey().ruleKey();
- Map<String, String> leftParams = paramDtoToMap(dbClient.activeRuleDao().selectParamsByActiveRuleKey(session, leftRule.getKey()));
- Map<String, String> rightParams = paramDtoToMap(dbClient.activeRuleDao().selectParamsByActiveRuleKey(session, rightRule.getKey()));
+ Map<String, String> leftParams = paramDtoToMap(dbClient.activeRuleDao().selectParamsByActiveRuleId(session, leftRule.getId()));
+ Map<String, String> rightParams = paramDtoToMap(dbClient.activeRuleDao().selectParamsByActiveRuleId(session, rightRule.getId()));
if (leftParams.equals(rightParams) && leftRule.getSeverityString().equals(rightRule.getSeverityString())) {
result.same.put(key, leftRule);
} else {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java
index 17f0217d8c8..02b8bcd808d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java
@@ -90,7 +90,7 @@ public class RuleActivatorContextFactory {
Optional<ActiveRuleDto> activeRule = db.activeRuleDao().selectByKey(session, key);
Collection<ActiveRuleParamDto> activeRuleParams = null;
if (activeRule.isPresent()) {
- activeRuleParams = db.activeRuleDao().selectParamsByActiveRuleKey(session, key);
+ activeRuleParams = db.activeRuleDao().selectParamsByActiveRuleId(session, activeRule.get().getId());
}
if (parent) {
context.setParentActiveRule(activeRule.orNull());
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
index 38a58b16d6a..acaf6988523 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
@@ -253,7 +253,7 @@ public class RuleUpdater {
Multimap<ActiveRuleDto, ActiveRuleParamDto> activeRuleParams = ArrayListMultimap.create();
for (ActiveRuleDto activeRuleDto : dbClient.activeRuleDao().selectByRule(dbSession, customRule)) {
activeRules.put(customRule, activeRuleDto);
- for (ActiveRuleParamDto activeRuleParamDto : dbClient.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey())) {
+ for (ActiveRuleParamDto activeRuleParamDto : dbClient.activeRuleDao().selectParamsByActiveRuleId(dbSession, activeRuleDto.getId())) {
activeRuleParams.put(activeRuleDto, activeRuleParamDto);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
index c3a0ac2ee1c..b7cd2593804 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
@@ -41,6 +41,7 @@ import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.RowNotFoundException;
import org.sonar.db.qualityprofile.ActiveRuleDao;
+import org.sonar.db.qualityprofile.ActiveRuleDto;
import org.sonar.db.qualityprofile.ActiveRuleParamDto;
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.db.rule.RuleDto;
@@ -154,7 +155,8 @@ public class QProfileBackuperMediumTest {
assertThat(activeRuleDoc.severity()).isEqualTo("BLOCKER");
assertThat(activeRuleDoc.inheritance()).isEqualTo(ActiveRule.Inheritance.NONE);
- List<ActiveRuleParamDto> params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleKey(dbSession, activeRuleDoc.key());
+ ActiveRuleDto activeRuleDto = db.activeRuleDao().selectOrFailByKey(dbSession, activeRuleDoc.key());
+ List<ActiveRuleParamDto> params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(params).hasSize(1);
assertThat(params.get(0).getKey()).isEqualTo("max");
assertThat(params.get(0).getValue()).isEqualTo("7");
@@ -187,7 +189,8 @@ public class QProfileBackuperMediumTest {
assertThat(activeRuleDoc.severity()).isEqualTo("BLOCKER");
assertThat(activeRuleDoc.inheritance()).isEqualTo(ActiveRule.Inheritance.NONE);
- List<ActiveRuleParamDto> params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleKey(dbSession, activeRuleDoc.key());
+ ActiveRuleDto activeRuleDto = db.activeRuleDao().selectOrFailByKey(dbSession, activeRuleDoc.key());
+ List<ActiveRuleParamDto> params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(params).hasSize(1);
assertThat(params.get(0).getKey()).isEqualTo("max");
assertThat(params.get(0).getValue()).isEqualTo("7");
@@ -220,7 +223,9 @@ public class QProfileBackuperMediumTest {
ActiveRuleDoc activeRuleDoc = activeRules.get(0);
assertThat(activeRuleDoc.severity()).isEqualTo("INFO");
assertThat(activeRuleDoc.inheritance()).isEqualTo(ActiveRule.Inheritance.NONE);
- List<ActiveRuleParamDto> params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleKey(dbSession, activeRuleDoc.key());
+
+ ActiveRuleDto activeRuleDto = db.activeRuleDao().selectOrFailByKey(dbSession, activeRuleDoc.key());
+ List<ActiveRuleParamDto> params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(params).hasSize(1);
assertThat(params.get(0).getKey()).isEqualTo("max");
assertThat(params.get(0).getValue()).isEqualTo("10");
@@ -231,7 +236,9 @@ public class QProfileBackuperMediumTest {
activeRuleDoc = activeRules.get(0);
assertThat(activeRuleDoc.severity()).isEqualTo("BLOCKER");
assertThat(activeRuleDoc.inheritance()).isEqualTo(ActiveRule.Inheritance.OVERRIDES);
- params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleKey(dbSession, activeRuleDoc.key());
+
+ activeRuleDto = db.activeRuleDao().selectOrFailByKey(dbSession, activeRuleDoc.key());
+ params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(params).hasSize(1);
assertThat(params.get(0).getKey()).isEqualTo("max");
assertThat(params.get(0).getValue()).isEqualTo("7");
@@ -265,7 +272,9 @@ public class QProfileBackuperMediumTest {
ActiveRuleDoc activeRuleDoc = activeRules.get(0);
assertThat(activeRuleDoc.severity()).isEqualTo("BLOCKER");
assertThat(activeRuleDoc.inheritance()).isEqualTo(ActiveRule.Inheritance.NONE);
- List<ActiveRuleParamDto> params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleKey(dbSession, activeRuleDoc.key());
+
+ ActiveRuleDto activeRuleDto = db.activeRuleDao().selectOrFailByKey(dbSession, activeRuleDoc.key());
+ List<ActiveRuleParamDto> params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(params).hasSize(1);
assertThat(params.get(0).getKey()).isEqualTo("max");
assertThat(params.get(0).getValue()).isEqualTo("7");
@@ -276,7 +285,9 @@ public class QProfileBackuperMediumTest {
activeRuleDoc = activeRules.get(0);
assertThat(activeRuleDoc.severity()).isEqualTo("BLOCKER");
assertThat(activeRuleDoc.inheritance()).isEqualTo(ActiveRule.Inheritance.INHERITED);
- params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleKey(dbSession, activeRuleDoc.key());
+
+ activeRuleDto = db.activeRuleDao().selectOrFailByKey(dbSession, activeRuleDoc.key());
+ params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(params).hasSize(1);
assertThat(params.get(0).getKey()).isEqualTo("max");
assertThat(params.get(0).getValue()).isEqualTo("7");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java
index 9c130568ebc..3ea8a2477d0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java
@@ -201,7 +201,8 @@ public class QProfileCopierMediumTest {
assertThat(activeRule.inheritance()).isEqualTo(expectedInheritance == null ? ActiveRule.Inheritance.NONE : ActiveRule.Inheritance.valueOf(expectedInheritance));
// verify parameters
- List<ActiveRuleParamDto> params = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRule.key());
+ ActiveRuleDto activeRuleDto = db.activeRuleDao().selectOrFailByKey(dbSession, activeRule.key());
+ List<ActiveRuleParamDto> params = db.activeRuleDao().selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(params).hasSize(expectedParams.size());
Map<String, ActiveRuleParamDto> paramsByKey = ActiveRuleParamDto.groupByKey(params);
for (Map.Entry<String, String> entry : expectedParams.entrySet()) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java
index 41fbdb61e78..10a537d8ee0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java
@@ -139,7 +139,7 @@ public class QProfileResetMediumTest {
// Verify severity and param has changed
ActiveRuleDto activeRuleDto = tester.get(ActiveRuleDao.class).selectOrFailByKey(dbSession, activeRuleKey);
assertThat(activeRuleDto.getSeverityString()).isEqualTo(BLOCKER);
- List<ActiveRuleParamDto> activeRuleParamDtos = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleKey(dbSession, activeRuleKey);
+ List<ActiveRuleParamDto> activeRuleParamDtos = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(activeRuleParamDtos.get(0).getKey()).isEqualTo("acceptWhitespace");
assertThat(activeRuleParamDtos.get(0).getValue()).isEqualTo("false");
@@ -152,7 +152,7 @@ public class QProfileResetMediumTest {
ActiveRule activeRule = tester.get(ActiveRuleIndex.class).getNullableByKey(activeRuleKey);
assertThat(activeRule.severity()).isEqualTo(CRITICAL);
- activeRuleParamDtos = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleKey(dbSession, activeRuleKey);
+ activeRuleParamDtos = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(activeRuleParamDtos.get(0).getKey()).isEqualTo("acceptWhitespace");
assertThat(activeRuleParamDtos.get(0).getValue()).isEqualTo("true");
}
@@ -195,7 +195,8 @@ public class QProfileResetMediumTest {
reset.resetLanguage(ServerTester.Xoo.KEY);
// Parameter value come back to origin after reset
- List<ActiveRuleParamDto> params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleKey(dbSession, activeRuleKey);
+ ActiveRuleDto activeRuleDto = tester.get(ActiveRuleDao.class).selectOrFailByKey(dbSession, activeRuleKey);
+ List<ActiveRuleParamDto> params = tester.get(ActiveRuleDao.class).selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(params).hasSize(1);
assertThat(params.get(0).getKey()).isEqualTo("acceptWhitespace");
assertThat(params.get(0).getValue()).isEqualTo("true");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java
index 9977ea4288b..89ef4f7aaae 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java
@@ -105,7 +105,7 @@ public class RegisterQualityProfilesMediumTest {
// TODO
// Check ActiveRuleParameters in DB
- Map<String, ActiveRuleParamDto> params = ActiveRuleParamDto.groupByKey(activeRuleDao.selectParamsByActiveRuleKey(dbSession, activeRule.getKey()));
+ Map<String, ActiveRuleParamDto> params = ActiveRuleParamDto.groupByKey(activeRuleDao.selectParamsByActiveRuleId(dbSession, activeRule.getId()));
assertThat(params).hasSize(2);
// set by profile
assertThat(params.get("acceptWhitespace").getValue()).isEqualTo("true");
@@ -140,7 +140,7 @@ public class RegisterQualityProfilesMediumTest {
// Check ActiveRuleParameters in DB
Map<String, ActiveRuleParamDto> params =
- ActiveRuleParamDto.groupByKey(activeRuleDao.selectParamsByActiveRuleKey(dbSession, activeRule.getKey()));
+ ActiveRuleParamDto.groupByKey(activeRuleDao.selectParamsByActiveRuleId(dbSession, activeRule.getId()));
assertThat(params).hasSize(2);
// set by profile
assertThat(params.get("acceptWhitespace").getValue()).isEqualTo("true");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java
index 3f4c4fcd16f..be82422bbaa 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java
@@ -1098,7 +1098,7 @@ public class RuleActivatorMediumTest {
assertThat(activeRuleDto.getCreatedAt()).isNotNull();
assertThat(activeRuleDto.getUpdatedAt()).isNotNull();
- List<ActiveRuleParamDto> paramDtos = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey());
+ List<ActiveRuleParamDto> paramDtos = db.activeRuleDao().selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(paramDtos).hasSize(expectedParams.size());
for (Map.Entry<String, String> entry : expectedParams.entrySet()) {
ActiveRuleParamDto paramDto = db.activeRuleDao().selectParamByKeyAndName(activeRuleDto.getKey(), entry.getKey(), dbSession);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java
index bc2cdff1e47..ade56882e96 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java
@@ -39,6 +39,7 @@ import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
+import org.sonar.db.qualityprofile.ActiveRuleDto;
import org.sonar.db.qualityprofile.ActiveRuleKey;
import org.sonar.db.qualityprofile.ActiveRuleParamDto;
import org.sonar.db.rule.RuleDao;
@@ -197,7 +198,8 @@ public class RegisterRulesMediumTest {
}
});
- List<ActiveRuleParamDto> params = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, ActiveRuleKey.of(QProfileTesting.XOO_P1_KEY, RuleTesting.XOO_X1));
+ ActiveRuleDto activeRuleDto = db.activeRuleDao().selectOrFailByKey(dbSession, ActiveRuleKey.of(QProfileTesting.XOO_P1_KEY, RuleTesting.XOO_X1));
+ List<ActiveRuleParamDto> params = db.activeRuleDao().selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
assertThat(params).hasSize(2);
Map<String, ActiveRuleParamDto> parmsByKey = FluentIterable.from(params).uniqueIndex(ActiveRuleParamToKey.INSTANCE);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java
index 9cbc02b16a1..b8a7327131e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java
@@ -469,7 +469,7 @@ public class RuleUpdaterMediumTest {
assertThat(activeRuleDto.getSeverityString()).isEqualTo(Severity.BLOCKER);
// Verify active rule parameters has been updated
- List<ActiveRuleParamDto> activeRuleParams = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey());
+ List<ActiveRuleParamDto> activeRuleParams = db.activeRuleDao().selectParamsByActiveRuleId(dbSession, activeRuleDto.getId());
// FIXME why 4 parameters are returned ??? (This issue already exists in 5.4)
//assertThat(activeRuleParams).hasSize(2);