aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-24 10:32:34 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-07-24 11:04:32 +0200
commit40f40f2432bcf0874f264d605ef210d05c89bc74 (patch)
tree2d5dcae2e13a91c4ed02a4d249f818b719bdd4f7 /server
parent85272d930b2bfdf1fc8e1be42bc27378be880b17 (diff)
downloadsonarqube-40f40f2432bcf0874f264d605ef210d05c89bc74.tar.gz
sonarqube-40f40f2432bcf0874f264d605ef210d05c89bc74.zip
Improve some DAOs with conventions and DatabaseUtils.executeLargeInputs()
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileReset.java13
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java20
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java16
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RuleDeleter.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryLoaderMediumTest.java14
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/db/DbClientTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java42
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileServiceMediumTest.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java26
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java40
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java22
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java14
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java2
41 files changed, 160 insertions, 171 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java
index 2a3ac48b822..f2111a61b6d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/RuleCacheLoader.java
@@ -40,7 +40,7 @@ public class RuleCacheLoader implements CacheLoader<RuleKey, Rule> {
public Rule load(RuleKey key) {
DbSession session = dbClient.openSession(false);
try {
- RuleDto dto = dbClient.ruleDao().getNullableByKey(session, key);
+ RuleDto dto = dbClient.deprecatedRuleDao().getNullableByKey(session, key);
if (dto != null) {
return new RuleImpl(dto);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java b/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java
index 06a92b144eb..08d7040f257 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java
@@ -51,7 +51,7 @@ public class DbClient extends org.sonar.db.DbClient {
return activeRuleDao;
}
- public RuleDao ruleDao() {
+ public RuleDao deprecatedRuleDao() {
return ruleDao;
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
index 22c88c4f80b..a16ea010fba 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
@@ -113,7 +113,7 @@ public class DebtModelBackup {
}
List<RuleDebt> rules = newArrayList();
- for (RuleDto rule : dbClient.ruleDao().selectEnabledAndNonManual(session)) {
+ for (RuleDto rule : dbClient.deprecatedRuleDao().selectEnabledAndNonManual(session)) {
if (languageKey == null || languageKey.equals(rule.getLanguage())) {
RuleDebt ruleDebt = toRuleDebt(rule, debtModel);
if (ruleDebt != null) {
@@ -140,7 +140,7 @@ public class DebtModelBackup {
List<CharacteristicDto> allCharacteristicDtos = restoreCharacteristics(session, loadModelFromPlugin(DebtModelPluginRepository.DEFAULT_MODEL), updateDate);
// Restore rules
- List<RuleDto> ruleDtos = dbClient.ruleDao().selectEnabledAndNonManual(session);
+ List<RuleDto> ruleDtos = dbClient.deprecatedRuleDao().selectEnabledAndNonManual(session);
if (!ruleDtos.isEmpty()) {
// Load default rule definitions
@@ -190,7 +190,7 @@ public class DebtModelBackup {
rule.setRemediationCoefficient(null);
rule.setRemediationOffset(null);
rule.setUpdatedAt(updateDate);
- dbClient.ruleDao().update(session, rule);
+ dbClient.deprecatedRuleDao().update(session, rule);
}
}
@@ -303,7 +303,7 @@ public class DebtModelBackup {
}
private List<RuleDto> rules(@Nullable String languageKey, DbSession session) {
- List<RuleDto> rules = dbClient.ruleDao().selectEnabledAndNonManual(session);
+ List<RuleDto> rules = dbClient.deprecatedRuleDao().selectEnabledAndNonManual(session);
if (languageKey == null) {
return rules;
} else {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java
index 9839d2cf71d..a9e0d3013ec 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java
@@ -207,7 +207,7 @@ public class DebtModelOperations {
private void disableSubCharacteristic(CharacteristicDto subCharacteristic, Date updateDate, DbSession session) {
// Disable debt on all rules (even REMOVED ones, in order to have no issue if they are reactivated) linked to the sub characteristic
- disableRulesDebt(dbClient.ruleDao().selectRulesByDebtSubCharacteristicId(session, subCharacteristic.getId()), subCharacteristic.getId(), updateDate, session);
+ disableRulesDebt(dbClient.deprecatedRuleDao().selectRulesByDebtSubCharacteristicId(session, subCharacteristic.getId()), subCharacteristic.getId(), updateDate, session);
disableCharacteristic(subCharacteristic, updateDate, session);
}
@@ -232,7 +232,7 @@ public class DebtModelOperations {
ruleDto.setDefaultRemediationCoefficient(null);
ruleDto.setDefaultRemediationOffset(null);
}
- dbClient.ruleDao().update(session, ruleDto);
+ dbClient.deprecatedRuleDao().update(session, ruleDto);
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
index 291f5ccf08b..64faa57caad 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
@@ -289,7 +289,7 @@ public class IssueService {
IssueDto getByKeyForUpdate(DbSession session, String key) {
// Load from index to check permission : if the user has no permission to see the issue an exception will be generated
Issue authorizedIssueIndex = getByKey(key);
- return dbClient.issueDao().selectByKeyOrFail(session, authorizedIssueIndex.key());
+ return dbClient.issueDao().selectOrFailByKey(session, authorizedIssueIndex.key());
}
void saveIssue(DbSession session, DefaultIssue issue, IssueChangeContext context, @Nullable String comment) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileReset.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileReset.java
index 5db1b1b1b3e..6fb813a770f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileReset.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileReset.java
@@ -24,12 +24,16 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import org.sonar.api.server.ServerSide;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.sonar.api.profiles.ProfileDefinition;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.ActiveRule;
import org.sonar.api.rules.ActiveRuleParam;
+import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.ValidationMessages;
import org.sonar.db.DbSession;
import org.sonar.db.qualityprofile.ActiveRuleDto;
@@ -39,11 +43,6 @@ import org.sonar.db.rule.RuleParamDto;
import org.sonar.server.db.DbClient;
import org.sonar.server.exceptions.BadRequestException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
@ServerSide
public class QProfileReset {
@@ -90,7 +89,7 @@ public class QProfileReset {
activation.setParameter(param.getParamKey(), param.getValue());
}
} else {
- for (RuleParamDto param : db.ruleDao().selectRuleParamsByRuleKey(dbSession, activeRule.getRule().ruleKey())) {
+ for (RuleParamDto param : db.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, activeRule.getRule().ruleKey())) {
activation.setParameter(param.getName(), param.getDefaultValue());
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
index 1609e2b3a98..8b7cc38cd39 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
@@ -221,7 +221,7 @@ public class QProfileService {
Result<QProfileActivity> result = new Result<>(response);
for (SearchHit hit : response.getHits().getHits()) {
QProfileActivity profileActivity = new QProfileActivity(hit.getSource());
- RuleDto ruleDto = db.ruleDao().getNullableByKey(session, profileActivity.ruleKey());
+ RuleDto ruleDto = db.deprecatedRuleDao().getNullableByKey(session, profileActivity.ruleKey());
profileActivity.ruleName(ruleDto != null ? ruleDto.getName() : null);
String login = profileActivity.getLogin();
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 580b7b7f59e..315a9cd4f4a 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
@@ -76,12 +76,12 @@ public class RuleActivatorContextFactory {
}
private RuleDto initRule(RuleKey ruleKey, RuleActivatorContext context, DbSession dbSession) {
- RuleDto rule = db.ruleDao().getNullableByKey(dbSession, ruleKey);
+ RuleDto rule = db.deprecatedRuleDao().getNullableByKey(dbSession, ruleKey);
if (rule == null) {
throw new BadRequestException("Rule not found: " + ruleKey);
}
context.setRule(rule);
- context.setRuleParams(db.ruleDao().selectRuleParamsByRuleKey(dbSession, rule.getKey()));
+ context.setRuleParams(db.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, rule.getKey()));
return rule;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
index 39c451edace..ae764529f76 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
@@ -121,7 +121,7 @@ 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.ruleDao().getNullableByKey(session, profileActivity.ruleKey());
+ RuleDto ruleDto = dbClient.deprecatedRuleDao().getNullableByKey(session, profileActivity.ruleKey());
profileActivity.ruleName(ruleDto != null ? ruleDto.getName() : null);
String login = profileActivity.getLogin();
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
index 09abc179429..076206d4c04 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
@@ -140,7 +140,7 @@ public class RegisterRules implements Startable {
}
if (executeUpdate) {
- dbClient.ruleDao().update(session, rule);
+ dbClient.deprecatedRuleDao().update(session, rule);
}
mergeParams(ruleDef, rule, session);
@@ -148,7 +148,7 @@ public class RegisterRules implements Startable {
private Map<RuleKey, RuleDto> loadRules(DbSession session) {
Map<RuleKey, RuleDto> rules = new HashMap<>();
- for (RuleDto rule : dbClient.ruleDao().selectByNonManual(session)) {
+ for (RuleDto rule : dbClient.deprecatedRuleDao().selectByNonManual(session)) {
rules.put(rule.getKey(), rule);
}
return rules;
@@ -217,7 +217,7 @@ public class RegisterRules implements Startable {
ruleDto.setDescriptionFormat(Format.MARKDOWN);
}
- dbClient.ruleDao().insert(session, ruleDto);
+ dbClient.deprecatedRuleDao().insert(session, ruleDto);
return ruleDto;
}
@@ -316,17 +316,17 @@ public class RegisterRules implements Startable {
}
private void mergeParams(RulesDefinition.Rule ruleDef, RuleDto rule, DbSession session) {
- List<RuleParamDto> paramDtos = dbClient.ruleDao().selectRuleParamsByRuleKey(session, rule.getKey());
+ List<RuleParamDto> paramDtos = dbClient.deprecatedRuleDao().selectRuleParamsByRuleKey(session, rule.getKey());
Map<String, RuleParamDto> existingParamsByName = Maps.newHashMap();
for (RuleParamDto paramDto : paramDtos) {
RulesDefinition.Param paramDef = ruleDef.param(paramDto.getName());
if (paramDef == null) {
dbClient.activeRuleDao().deleteParamsByRuleParam(session, rule, paramDto.getName());
- dbClient.ruleDao().deleteRuleParam(session, rule, paramDto);
+ dbClient.deprecatedRuleDao().deleteRuleParam(session, rule, paramDto);
} else {
if (mergeParam(paramDto, paramDef)) {
- dbClient.ruleDao().updateRuleParam(session, rule, paramDto);
+ dbClient.deprecatedRuleDao().updateRuleParam(session, rule, paramDto);
}
existingParamsByName.put(paramDto.getName(), paramDto);
}
@@ -341,7 +341,7 @@ public class RegisterRules implements Startable {
.setDescription(param.description())
.setDefaultValue(param.defaultValue())
.setType(param.type().toString());
- dbClient.ruleDao().insertRuleParam(session, rule, paramDto);
+ dbClient.deprecatedRuleDao().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)) {
@@ -400,10 +400,10 @@ public class RegisterRules implements Startable {
}
for (RuleDto customRule : customRules) {
- RuleDto template = dbClient.ruleDao().selectTemplate(customRule, session);
+ RuleDto template = dbClient.deprecatedRuleDao().selectTemplate(customRule, session);
if (template != null && template.getStatus() != RuleStatus.REMOVED) {
if (updateCustomRuleFromTemplateRule(customRule, template)) {
- dbClient.ruleDao().update(session, customRule);
+ dbClient.deprecatedRuleDao().update(session, customRule);
}
} else {
removeRule(session, removedRules, customRule);
@@ -419,7 +419,7 @@ public class RegisterRules implements Startable {
rule.setStatus(RuleStatus.REMOVED);
rule.setSystemTags(Collections.<String>emptySet());
rule.setTags(Collections.<String>emptySet());
- dbClient.ruleDao().update(session, rule);
+ dbClient.deprecatedRuleDao().update(session, rule);
removedRules.add(rule);
if (removedRules.size() % 100 == 0) {
session.commit();
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java
index 204e8e913ba..2a7aac6e629 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java
@@ -78,7 +78,7 @@ public class RuleCreator {
if (templateKey == null) {
throw new IllegalArgumentException("Rule template key should not be null");
}
- RuleDto templateRule = dbClient.ruleDao().getByKey(dbSession, templateKey);
+ RuleDto templateRule = dbClient.deprecatedRuleDao().getByKey(dbSession, templateKey);
if (!templateRule.isTemplate()) {
throw new IllegalArgumentException("This rule is not a template rule: " + templateKey.toString());
}
@@ -129,7 +129,7 @@ public class RuleCreator {
errors.add(Message.of("coding_rules.validation.missing_status"));
}
- for (RuleParamDto ruleParam : dbClient.ruleDao().selectRuleParamsByRuleKey(dbSession, templateKey)) {
+ for (RuleParamDto ruleParam : dbClient.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, templateKey)) {
try {
validateParam(ruleParam, newRule.parameter(ruleParam.getName()));
} catch (BadRequestException validationError) {
@@ -190,7 +190,7 @@ public class RuleCreator {
@CheckForNull
private RuleDto loadRule(RuleKey ruleKey, DbSession dbSession) {
- return dbClient.ruleDao().getNullableByKey(dbSession, ruleKey);
+ return dbClient.deprecatedRuleDao().getNullableByKey(dbSession, ruleKey);
}
private RuleKey createCustomRule(RuleKey ruleKey, NewRule newRule, RuleDto templateRuleDto, DbSession dbSession) {
@@ -210,9 +210,9 @@ public class RuleCreator {
.setEffortToFixDescription(templateRuleDto.getEffortToFixDescription())
.setTags(templateRuleDto.getTags())
.setSystemTags(templateRuleDto.getSystemTags());
- dbClient.ruleDao().insert(dbSession, ruleDto);
+ dbClient.deprecatedRuleDao().insert(dbSession, ruleDto);
- for (RuleParamDto templateRuleParamDto : dbClient.ruleDao().selectRuleParamsByRuleKey(dbSession, templateRuleDto.getKey())) {
+ for (RuleParamDto templateRuleParamDto : dbClient.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, templateRuleDto.getKey())) {
String customRuleParamValue = Strings.emptyToNull(newRule.parameter(templateRuleParamDto.getName()));
createCustomRuleParams(customRuleParamValue, ruleDto, templateRuleParamDto, dbSession);
}
@@ -225,7 +225,7 @@ public class RuleCreator {
.setType(templateRuleParam.getType())
.setDescription(templateRuleParam.getDescription())
.setDefaultValue(paramValue);
- dbClient.ruleDao().insertRuleParam(dbSession, ruleDto, ruleParamDto);
+ dbClient.deprecatedRuleDao().insertRuleParam(dbSession, ruleDto, ruleParamDto);
}
private RuleKey createManualRule(RuleKey ruleKey, NewRule newRule, DbSession dbSession) {
@@ -235,7 +235,7 @@ public class RuleCreator {
.setDescriptionFormat(Format.MARKDOWN)
.setSeverity(newRule.severity())
.setStatus(RuleStatus.READY);
- dbClient.ruleDao().insert(dbSession, ruleDto);
+ dbClient.deprecatedRuleDao().insert(dbSession, ruleDto);
return ruleKey;
}
@@ -245,7 +245,7 @@ public class RuleCreator {
throw new ReactivationException(String.format("A removed rule with the key '%s' already exists", ruleDto.getKey().rule()), ruleDto.getKey());
} else {
ruleDto.setStatus(RuleStatus.READY);
- dbClient.ruleDao().update(dbSession, ruleDto);
+ dbClient.deprecatedRuleDao().update(dbSession, ruleDto);
}
} else {
throw new IllegalArgumentException(String.format("A rule with the key '%s' already exists", ruleDto.getKey().rule()));
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleDeleter.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleDeleter.java
index 26aaad5755a..183f81b9a86 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleDeleter.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleDeleter.java
@@ -43,7 +43,7 @@ public class RuleDeleter {
public void delete(RuleKey ruleKey) {
DbSession dbSession = dbClient.openSession(false);
try {
- RuleDto rule = dbClient.ruleDao().getByKey(dbSession, ruleKey);
+ RuleDto rule = dbClient.deprecatedRuleDao().getByKey(dbSession, ruleKey);
if (rule.getTemplateId() == null && !rule.getRepositoryKey().equals(RuleDoc.MANUAL_REPOSITORY)) {
throw new IllegalStateException("Only custom rules and manual rules can be deleted");
}
@@ -54,7 +54,7 @@ public class RuleDeleter {
}
rule.setStatus(RuleStatus.REMOVED);
- dbClient.ruleDao().update(dbSession, rule);
+ dbClient.deprecatedRuleDao().update(dbSession, rule);
dbSession.commit();
} finally {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java
index ea89d894af7..8bbc7521acb 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java
@@ -55,7 +55,7 @@ public class RuleOperations {
checkPermission(userSession);
DbSession session = dbClient.openSession(false);
try {
- RuleDto ruleDto = dbClient.ruleDao().getNullableByKey(session, ruleChange.ruleKey());
+ RuleDto ruleDto = dbClient.deprecatedRuleDao().getNullableByKey(session, ruleChange.ruleKey());
if (ruleDto == null) {
throw new NotFoundException(String.format("Unknown rule '%s'", ruleChange.ruleKey()));
}
@@ -123,7 +123,7 @@ public class RuleOperations {
}
if (needUpdate) {
- dbClient.ruleDao().update(session, ruleDto);
+ dbClient.deprecatedRuleDao().update(session, ruleDto);
}
return needUpdate;
}
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 10fac8658e1..c84d071a477 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
@@ -69,7 +69,7 @@ public class RuleUpdater {
Context context = newContext(update);
// validate only the changes, not all the rule fields
apply(update, context, userSession);
- dbClient.ruleDao().update(dbSession, context.rule);
+ dbClient.deprecatedRuleDao().update(dbSession, context.rule);
updateParameters(dbSession, update, context);
dbSession.commit();
return true;
@@ -86,7 +86,7 @@ public class RuleUpdater {
DbSession dbSession = dbClient.openSession(false);
try {
Context context = new Context();
- context.rule = dbClient.ruleDao().getByKey(dbSession, change.getRuleKey());
+ context.rule = dbClient.deprecatedRuleDao().getByKey(dbSession, change.getRuleKey());
if (RuleStatus.REMOVED == context.rule.getStatus()) {
throw new IllegalArgumentException("Rule with REMOVED status cannot be updated: " + change.getRuleKey());
}
@@ -266,7 +266,7 @@ public class RuleUpdater {
private void updateParameters(DbSession dbSession, RuleUpdate update, Context context) {
if (update.isChangeParameters() && update.isCustomRule()) {
RuleDto customRule = context.rule;
- RuleDto templateRule = dbClient.ruleDao().selectTemplate(customRule, dbSession);
+ RuleDto templateRule = dbClient.deprecatedRuleDao().selectTemplate(customRule, dbSession);
if (templateRule == null) {
throw new IllegalStateException(String.format("Template %s of rule %s does not exist",
customRule.getTemplateId(), customRule.getKey()));
@@ -290,13 +290,13 @@ public class RuleUpdater {
private void deleteOrUpdateParameters(DbSession dbSession, RuleUpdate update, RuleDto customRule, List<String> paramKeys,
Multimap<RuleDto, ActiveRuleDto> activeRules, Multimap<ActiveRuleDto, ActiveRuleParamDto> activeRuleParams) {
- for (RuleParamDto ruleParamDto : dbClient.ruleDao().selectRuleParamsByRuleKey(dbSession, update.getRuleKey())) {
+ for (RuleParamDto ruleParamDto : dbClient.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, update.getRuleKey())) {
String key = ruleParamDto.getName();
String value = Strings.emptyToNull(update.parameter(key));
// Update rule param
ruleParamDto.setDefaultValue(value);
- dbClient.ruleDao().updateRuleParam(dbSession, customRule, ruleParamDto);
+ dbClient.deprecatedRuleDao().updateRuleParam(dbSession, customRule, ruleParamDto);
if (value != null) {
// Update linked active rule params or create new one
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java
index 981c6351d8c..cd354581a7c 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java
@@ -182,7 +182,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
Integer templateId = rule.getTemplateId();
String templateKeyFieldValue = null;
if (templateId != null) {
- RuleDto templateRule = db.ruleDao().selectById(session, templateId);
+ RuleDto templateRule = db.deprecatedRuleDao().selectById(session, templateId);
if (templateRule != null) {
RuleKey templateKey = templateRule.getKey();
templateKeyFieldValue = templateKey != null ? templateKey.toString() : null;
@@ -282,7 +282,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
.doc(update)
.upsert(upsert));
- for (RuleParamDto param : db.ruleDao().selectRuleParamsByRuleKey(session, rule.getKey())) {
+ for (RuleParamDto param : db.deprecatedRuleDao().selectRuleParamsByRuleKey(session, rule.getKey())) {
requests.addAll(normalizeNested(param, rule.getKey()));
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java b/server/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java
index 5e79fcb0318..76c521b2e1a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java
@@ -74,7 +74,7 @@ public class IndexSynchronizer {
public void executeDeprecated() {
DbSession session = db.openSession(false);
try {
- synchronize(session, db.ruleDao(), index.get(RuleIndex.class));
+ synchronize(session, db.deprecatedRuleDao(), index.get(RuleIndex.class));
synchronize(session, db.activeRuleDao(), index.get(ActiveRuleIndex.class));
session.commit();
} finally {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryLoaderMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryLoaderMediumTest.java
index 395b883d98e..2aba3fa71c1 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryLoaderMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryLoaderMediumTest.java
@@ -588,8 +588,8 @@ public class ProjectRepositoryLoaderMediumTest {
RuleKey ruleKey = RuleKey.of("squid", "AvoidCycle");
RuleDto rule = RuleTesting.newDto(ruleKey).setName("Avoid Cycle").setConfigKey("squid-1").setLanguage(ServerTester.Xoo.KEY);
- tester.get(DbClient.class).ruleDao().insert(dbSession, rule);
- tester.get(DbClient.class).ruleDao().insertRuleParam(dbSession, rule, RuleParamDto.createFor(rule)
+ tester.get(DbClient.class).deprecatedRuleDao().insert(dbSession, rule);
+ tester.get(DbClient.class).deprecatedRuleDao().insertRuleParam(dbSession, rule, RuleParamDto.createFor(rule)
.setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type()));
RuleActivation activation = new RuleActivation(ruleKey);
@@ -619,7 +619,7 @@ public class ProjectRepositoryLoaderMediumTest {
RuleKey ruleKey1 = RuleKey.of("squid", "AvoidCycle");
RuleKey ruleKey2 = RuleKey.of("squid", "AvoidNPE");
- tester.get(DbClient.class).ruleDao().insert(dbSession,
+ tester.get(DbClient.class).deprecatedRuleDao().insert(dbSession,
RuleTesting.newDto(ruleKey1).setName("Avoid Cycle").setLanguage(ServerTester.Xoo.KEY),
RuleTesting.newDto(ruleKey2).setName("Avoid NPE").setLanguage(ServerTester.Xoo.KEY)
);
@@ -661,7 +661,7 @@ public class ProjectRepositoryLoaderMediumTest {
for (int i = 0; i < 20; i++) {
RuleKey ruleKey = RuleKey.of("squid", "Rule" + i);
- tester.get(DbClient.class).ruleDao().insert(dbSession, RuleTesting.newDto(ruleKey).setName("Rule" + i).setLanguage(ServerTester.Xoo.KEY));
+ tester.get(DbClient.class).deprecatedRuleDao().insert(dbSession, RuleTesting.newDto(ruleKey).setName("Rule" + i).setLanguage(ServerTester.Xoo.KEY));
tester.get(RuleActivator.class).activate(dbSession, new RuleActivation(ruleKey).setSeverity(Severity.MINOR), profileDto.getKey());
}
@@ -685,10 +685,10 @@ public class ProjectRepositoryLoaderMediumTest {
RuleKey ruleKey = RuleKey.of("squid", "ArchitecturalConstraint");
RuleDto templateRule = RuleTesting.newTemplateRule(ruleKey).setName("Architectural Constraint").setLanguage(ServerTester.Xoo.KEY);
- tester.get(DbClient.class).ruleDao().insert(dbSession, templateRule);
+ tester.get(DbClient.class).deprecatedRuleDao().insert(dbSession, templateRule);
RuleDto customRule = RuleTesting.newCustomRule(templateRule);
- tester.get(DbClient.class).ruleDao().insert(dbSession, customRule);
+ tester.get(DbClient.class).deprecatedRuleDao().insert(dbSession, customRule);
tester.get(RuleActivator.class).activate(dbSession, new RuleActivation(customRule.getKey()).setSeverity(Severity.MINOR), profileDto.getKey());
dbSession.commit();
@@ -711,7 +711,7 @@ public class ProjectRepositoryLoaderMediumTest {
addDefaultProfile();
RuleDto rule = RuleTesting.newManualRule("manualRuleKey").setName("Name manualRuleKey");
- tester.get(DbClient.class).ruleDao().insert(dbSession, rule);
+ tester.get(DbClient.class).deprecatedRuleDao().insert(dbSession, rule);
dbSession.commit();
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
index 476ad8831c0..1993c935f9b 100644
--- 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
@@ -57,6 +57,6 @@ public class DbClientTest {
// DAO
assertThat(client.qualityProfileDao()).isSameAs(qualityProfileDao);
assertThat(client.activeRuleDao()).isSameAs(activeRuleDao);
- assertThat(client.ruleDao()).isSameAs(ruleDao);
+ assertThat(client.deprecatedRuleDao()).isSameAs(ruleDao);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
index 514a035558f..f9a9b7dcf18 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
@@ -135,7 +135,7 @@ public class DebtModelBackupTest {
}).when(dao).insert(any(DbSession.class), any(CharacteristicDto.class));
when(dbClient.openSession(false)).thenReturn(session);
- when(dbClient.ruleDao()).thenReturn(ruleDao);
+ when(dbClient.deprecatedRuleDao()).thenReturn(ruleDao);
when(dbClient.debtCharacteristicDao()).thenReturn(dao);
Reader defaultModelReader = mock(Reader.class);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java
index 89d229ec6ba..ce72cc9757a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java
@@ -129,7 +129,7 @@ public class DebtModelOperationsTest {
}).when(dao).insert(any(SqlSession.class), any(CharacteristicDto.class));
when(dbClient.openSession(false)).thenReturn(session);
- when(dbClient.ruleDao()).thenReturn(ruleDao);
+ when(dbClient.deprecatedRuleDao()).thenReturn(ruleDao);
when(dbClient.debtCharacteristicDao()).thenReturn(dao);
service = new DebtModelOperations(dbClient, system2, userSessionRule);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
index efe9cb14bac..7eec116d26d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java
@@ -150,7 +150,7 @@ public class BulkDeleteActionTest {
assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId4)).isNull();
assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId2)).isNotNull();
assertThat(dbClient.issueDao().selectByKeys(dbSession, Arrays.asList("issue-key-1", "issue-key-3", "issue-key-4"))).isEmpty();
- assertThat(dbClient.issueDao().selectByKeyOrFail(dbSession, "issue-key-2")).isNotNull();
+ assertThat(dbClient.issueDao().selectOrFailByKey(dbSession, "issue-key-2")).isNotNull();
}
@Test
@@ -231,7 +231,7 @@ public class BulkDeleteActionTest {
.newProjectDto("project-uuid-" + suffix)
.setKey("project-key-" + suffix);
RuleDto rule = RuleTesting.newDto(RuleKey.of("sonarqube", "rule-" + suffix));
- dbClient.ruleDao().insert(dbSession, rule);
+ dbClient.deprecatedRuleDao().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.createForProject(project));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
index a8ae4d057d8..057254ff2b5 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java
@@ -151,7 +151,7 @@ public class DeleteActionTest {
assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId1)).isNull();
assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId2)).isNotNull();
assertThat(dbClient.issueDao().selectByKey(dbSession, "issue-key-1").isPresent()).isFalse();
- assertThat(dbClient.issueDao().selectByKeyOrFail(dbSession, "issue-key-2")).isNotNull();
+ assertThat(dbClient.issueDao().selectOrFailByKey(dbSession, "issue-key-2")).isNotNull();
}
@Test
@@ -251,7 +251,7 @@ public class DeleteActionTest {
.newProjectDto("project-uuid-" + suffix)
.setKey("project-key-" + suffix);
RuleDto rule = RuleTesting.newDto(RuleKey.of("sonarqube", "rule-" + suffix));
- dbClient.ruleDao().insert(dbSession, rule);
+ dbClient.deprecatedRuleDao().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.createForProject(project));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java
index ddf519bd604..4f679064967 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java
@@ -22,6 +22,10 @@ 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.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;
@@ -37,20 +41,15 @@ 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.db.rule.RuleTesting;
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 java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
import org.sonar.server.tester.UserSessionRule;
import static com.google.common.collect.Lists.newArrayList;
@@ -94,7 +93,7 @@ public class ActiveRuleBackendMediumTest {
db.qualityProfileDao().insert(dbSession, profile1);
RuleDto rule1 = RuleDto.createFor(RuleTesting.XOO_X1).setSeverity(Severity.MAJOR);
- db.ruleDao().insert(dbSession, rule1);
+ db.deprecatedRuleDao().insert(dbSession, rule1);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile1, rule1).setSeverity("BLOCKER");
db.activeRuleDao().insert(dbSession, activeRule);
@@ -128,7 +127,7 @@ public class ActiveRuleBackendMediumTest {
db.qualityProfileDao().insert(dbSession, profileDto);
RuleKey ruleKey = RuleTesting.XOO_X1;
RuleDto ruleDto = newRuleDto(ruleKey);
- db.ruleDao().insert(dbSession, ruleDto);
+ db.deprecatedRuleDao().insert(dbSession, ruleDto);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, ruleDto)
.setInheritance(ActiveRule.Inheritance.INHERITED.name())
@@ -157,17 +156,17 @@ public class ActiveRuleBackendMediumTest {
db.qualityProfileDao().insert(dbSession, profileDto);
RuleKey ruleKey = RuleTesting.XOO_X1;
RuleDto ruleDto = newRuleDto(ruleKey);
- db.ruleDao().insert(dbSession, ruleDto);
+ db.deprecatedRuleDao().insert(dbSession, ruleDto);
RuleParamDto minParam = new RuleParamDto()
.setName("min")
.setType("STRING");
- db.ruleDao().insertRuleParam(dbSession, ruleDto, minParam);
+ db.deprecatedRuleDao().insertRuleParam(dbSession, ruleDto, minParam);
RuleParamDto maxParam = new RuleParamDto()
.setName("max")
.setType("STRING");
- db.ruleDao().insertRuleParam(dbSession, ruleDto, maxParam);
+ db.deprecatedRuleDao().insertRuleParam(dbSession, ruleDto, maxParam);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, ruleDto)
.setInheritance(ActiveRule.Inheritance.INHERITED.name())
@@ -185,8 +184,7 @@ public class ActiveRuleBackendMediumTest {
dbSession.commit();
// verify db
- List<ActiveRuleParamDto> persistedDtos =
- db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRule.getKey());
+ List<ActiveRuleParamDto> persistedDtos = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRule.getKey());
assertThat(persistedDtos).hasSize(2);
// verify es
@@ -207,7 +205,7 @@ public class ActiveRuleBackendMediumTest {
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.ruleDao().insert(dbSession, rule1, rule2, removedRule);
+ 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));
@@ -259,7 +257,7 @@ public class ActiveRuleBackendMediumTest {
int nb = 100;
for (int i = 0; i < nb; i++) {
RuleDto rule = newRuleDto(RuleKey.of("xoo", "S00" + i));
- db.ruleDao().insert(dbSession, rule);
+ db.deprecatedRuleDao().insert(dbSession, rule);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, rule).setSeverity(Severity.MAJOR);
db.activeRuleDao().insert(dbSession, activeRule);
@@ -280,7 +278,7 @@ public class ActiveRuleBackendMediumTest {
RuleKey ruleKey = RuleTesting.XOO_X1;
RuleDto ruleDto = newRuleDto(ruleKey);
- db.ruleDao().insert(dbSession, ruleDto);
+ db.deprecatedRuleDao().insert(dbSession, ruleDto);
ActiveRuleDto activeRule1 = ActiveRuleDto.createFor(profileDto1, ruleDto).setSeverity(Severity.MAJOR);
ActiveRuleDto activeRule2 = ActiveRuleDto.createFor(profileDto2, ruleDto).setSeverity(Severity.MAJOR);
@@ -308,7 +306,7 @@ public class ActiveRuleBackendMediumTest {
RuleKey ruleKey = RuleTesting.XOO_X1;
RuleDto ruleDto = newRuleDto(ruleKey);
- db.ruleDao().insert(dbSession, ruleDto);
+ db.deprecatedRuleDao().insert(dbSession, ruleDto);
ActiveRuleDto activeRule1 = ActiveRuleDto.createFor(profileDto1, ruleDto).setSeverity(Severity.MAJOR);
ActiveRuleDto activeRule2 = ActiveRuleDto.createFor(profileDto2, ruleDto).setSeverity(Severity.MAJOR);
@@ -333,7 +331,7 @@ public class ActiveRuleBackendMediumTest {
RuleDto ruleDto1 = newRuleDto(RuleTesting.XOO_X1);
RuleDto ruleDto2 = newRuleDto(RuleTesting.XOO_X2);
- db.ruleDao().insert(dbSession, ruleDto1, ruleDto2);
+ db.deprecatedRuleDao().insert(dbSession, ruleDto1, ruleDto2);
db.activeRuleDao().insert(dbSession,
ActiveRuleDto.createFor(profileDto1, ruleDto1)
@@ -347,8 +345,7 @@ public class ActiveRuleBackendMediumTest {
.setSeverity(Severity.MAJOR),
ActiveRuleDto.createFor(profileDto2, ruleDto2)
.setInheritance(ActiveRule.Inheritance.INHERITED.name())
- .setSeverity(Severity.BLOCKER)
- );
+ .setSeverity(Severity.BLOCKER));
dbSession.commit();
dbSession.clearCache();
@@ -370,7 +367,7 @@ public class ActiveRuleBackendMediumTest {
public void stats_for_all_with_lof_of_profiles() {
RuleDto ruleDto1 = newRuleDto(RuleTesting.XOO_X1);
RuleDto ruleDto2 = newRuleDto(RuleTesting.XOO_X2);
- db.ruleDao().insert(dbSession, ruleDto1, ruleDto2);
+ db.deprecatedRuleDao().insert(dbSession, ruleDto1, ruleDto2);
List<String> profileKeys = newArrayList();
for (int i = 0; i < 30; i++) {
@@ -382,8 +379,7 @@ public class ActiveRuleBackendMediumTest {
ActiveRuleDto.createFor(profileDto, ruleDto1)
.setSeverity(Severity.BLOCKER),
ActiveRuleDto.createFor(profileDto, ruleDto2)
- .setSeverity(Severity.MAJOR)
- );
+ .setSeverity(Severity.MAJOR));
}
dbSession.commit();
dbSession.clearCache();
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 8c79f28307f..cd371ea2e11 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
@@ -71,8 +71,8 @@ public class QProfileBackuperMediumTest {
// create pre-defined rules
RuleDto xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR").setLanguage("xoo");
RuleDto xooRule2 = RuleTesting.newXooX2().setSeverity("MAJOR").setLanguage("xoo");
- db.ruleDao().insert(dbSession, xooRule1, xooRule2);
- db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
+ db.deprecatedRuleDao().insert(dbSession, xooRule1, xooRule2);
+ db.deprecatedRuleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
.setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type()));
dbSession.commit();
dbSession.clearCache();
@@ -87,7 +87,7 @@ public class QProfileBackuperMediumTest {
public void backup() throws Exception {
RuleKey blahRuleKey = RuleKey.of("blah", "my-rule");
RuleDto blahRule = RuleTesting.newDto(blahRuleKey).setSeverity("INFO").setLanguage("xoo");
- db.ruleDao().insert(dbSession, blahRule);
+ db.deprecatedRuleDao().insert(dbSession, blahRule);
dbSession.commit();
dbSession.clearCache();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java
index 4db018b3a9a..df71521a3a0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java
@@ -70,10 +70,10 @@ public class QProfileComparisonMediumTest {
xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR");
xooRule2 = RuleTesting.newXooX2().setSeverity("MAJOR");
- db.ruleDao().insert(dbSession, xooRule1, xooRule2);
- db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
+ db.deprecatedRuleDao().insert(dbSession, xooRule1, xooRule2);
+ db.deprecatedRuleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
.setName("max").setType(RuleParamType.INTEGER.type()));
- db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
+ db.deprecatedRuleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
.setName("min").setType(RuleParamType.INTEGER.type()));
left = QProfileTesting.newXooP1();
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 d503d38166f..f0be8e694af 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
@@ -70,8 +70,8 @@ public class QProfileCopierMediumTest {
// create pre-defined rules
RuleDto xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR");
RuleDto xooRule2 = RuleTesting.newXooX2().setSeverity("MAJOR");
- db.ruleDao().insert(dbSession, xooRule1, xooRule2);
- db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
+ db.deprecatedRuleDao().insert(dbSession, xooRule1, xooRule2);
+ db.deprecatedRuleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
.setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type()));
// create pre-defined profile
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java
index 2c19b0df97d..f204c850702 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java
@@ -348,8 +348,8 @@ public class QProfileFactoryMediumTest {
// create pre-defined rules
RuleDto xooRule1 = RuleTesting.newXooX1();
RuleDto xooRule2 = RuleTesting.newXooX2();
- db.ruleDao().insert(dbSession, xooRule1, xooRule2);
- db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
+ db.deprecatedRuleDao().insert(dbSession, xooRule1, xooRule2);
+ db.deprecatedRuleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
.setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type()));
dbSession.commit();
dbSession.clearCache();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileServiceMediumTest.java
index 51f79e99c98..1d21f8ec07a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileServiceMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileServiceMediumTest.java
@@ -85,7 +85,7 @@ public class QProfileServiceMediumTest {
// create pre-defined rules
RuleDto xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR");
- db.ruleDao().insert(dbSession, xooRule1);
+ db.deprecatedRuleDao().insert(dbSession, xooRule1);
// create pre-defined profiles P1 and P2
db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1(), QProfileTesting.newXooP2());
@@ -113,7 +113,7 @@ public class QProfileServiceMediumTest {
public void create_profile_with_xml() {
userSessionRule.login().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
- db.ruleDao().insert(dbSession, RuleTesting.newDto(RuleKey.of("xoo", "R1")).setLanguage("xoo").setSeverity("MINOR"));
+ db.deprecatedRuleDao().insert(dbSession, RuleTesting.newDto(RuleKey.of("xoo", "R1")).setLanguage("xoo").setSeverity("MINOR"));
dbSession.commit();
QProfileResult result = service.create(QProfileName.createFor("xoo", "New Profile"), ImmutableMap.of("XooProfileImporter", "<xml/>"));
@@ -166,7 +166,7 @@ public class QProfileServiceMediumTest {
// create deprecated rule
RuleDto deprecatedXooRule = RuleTesting.newDto(RuleKey.of("xoo", "deprecated1"))
.setSeverity("MINOR").setLanguage("xoo").setStatus(RuleStatus.DEPRECATED);
- db.ruleDao().insert(dbSession, deprecatedXooRule);
+ db.deprecatedRuleDao().insert(dbSession, deprecatedXooRule);
dbSession.commit();
// active some rules
@@ -185,7 +185,7 @@ public class QProfileServiceMediumTest {
db.userDao().insert(dbSession, user);
// We need an actual rule in DB to test RuleName in Activity
- RuleDto rule = db.ruleDao().getByKey(dbSession, RuleTesting.XOO_X1);
+ RuleDto rule = db.deprecatedRuleDao().getByKey(dbSession, RuleTesting.XOO_X1);
dbSession.commit();
@@ -234,7 +234,7 @@ public class QProfileServiceMediumTest {
userSessionRule.login("david").setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
// We need an actual rule in DB to test RuleName in Activity
- db.ruleDao().getByKey(dbSession, RuleTesting.XOO_X1);
+ db.deprecatedRuleDao().getByKey(dbSession, RuleTesting.XOO_X1);
dbSession.commit();
tester.get(ActivityService.class).save(
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 d11edaedcf2..46d7256c900 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
@@ -93,18 +93,18 @@ public class RuleActivatorMediumTest {
RuleDto xooTemplateRule1 = RuleTesting.newTemplateRule(TEMPLATE_RULE_KEY)
.setSeverity("MINOR").setLanguage("xoo");
RuleDto manualRule = RuleTesting.newDto(MANUAL_RULE_KEY);
- db.ruleDao().insert(dbSession, javaRule, xooRule1, xooRule2, xooTemplateRule1, manualRule);
- db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
+ db.deprecatedRuleDao().insert(dbSession, javaRule, xooRule1, xooRule2, xooTemplateRule1, manualRule);
+ db.deprecatedRuleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
.setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type()));
- db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
+ db.deprecatedRuleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1)
.setName("min").setType(RuleParamType.INTEGER.type()));
- db.ruleDao().insertRuleParam(dbSession, xooTemplateRule1, RuleParamDto.createFor(xooTemplateRule1)
+ db.deprecatedRuleDao().insertRuleParam(dbSession, xooTemplateRule1, RuleParamDto.createFor(xooTemplateRule1)
.setName("format").setType(RuleParamType.STRING.type()));
RuleDto xooCustomRule1 = RuleTesting.newCustomRule(xooTemplateRule1).setRuleKey(CUSTOM_RULE_KEY.rule())
.setSeverity("MINOR").setLanguage("xoo");
- db.ruleDao().insert(dbSession, xooCustomRule1);
- db.ruleDao().insertRuleParam(dbSession, xooCustomRule1, RuleParamDto.createFor(xooTemplateRule1)
+ db.deprecatedRuleDao().insert(dbSession, xooCustomRule1);
+ db.deprecatedRuleDao().insertRuleParam(dbSession, xooCustomRule1, RuleParamDto.createFor(xooTemplateRule1)
.setName("format").setDefaultValue("txt").setType(RuleParamType.STRING.type()));
// create pre-defined profile P1
@@ -390,9 +390,9 @@ public class RuleActivatorMediumTest {
@Test
public void fail_to_activate_if_rule_with_removed_status() {
- RuleDto ruleDto = db.ruleDao().getByKey(dbSession, RuleTesting.XOO_X1);
+ RuleDto ruleDto = db.deprecatedRuleDao().getByKey(dbSession, RuleTesting.XOO_X1);
ruleDto.setStatus(RuleStatus.REMOVED);
- db.ruleDao().update(dbSession, ruleDto);
+ db.deprecatedRuleDao().update(dbSession, ruleDto);
dbSession.commit();
dbSession.clearCache();
@@ -498,9 +498,9 @@ public class RuleActivatorMediumTest {
activate(activation, XOO_P1_KEY);
// set rule as removed
- RuleDto rule = db.ruleDao().getByKey(dbSession, RuleTesting.XOO_X1);
+ RuleDto rule = db.deprecatedRuleDao().getByKey(dbSession, RuleTesting.XOO_X1);
rule.setStatus(RuleStatus.REMOVED);
- db.ruleDao().update(dbSession, rule);
+ db.deprecatedRuleDao().update(dbSession, rule);
dbSession.commit();
dbSession.clearCache();
@@ -837,7 +837,7 @@ public class RuleActivatorMediumTest {
// Generate more rules than the search's max limit
int bulkSize = QueryContext.MAX_LIMIT + 10;
for (int i = 0; i < bulkSize; i++) {
- db.ruleDao().insert(dbSession, RuleTesting.newDto(RuleKey.of("bulk", "r_" + i)).setLanguage("xoo"));
+ db.deprecatedRuleDao().insert(dbSession, RuleTesting.newDto(RuleKey.of("bulk", "r_" + i)).setLanguage("xoo"));
}
dbSession.commit();
@@ -964,9 +964,9 @@ public class RuleActivatorMediumTest {
db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP2());
// mark rule x1 as REMOVED
- RuleDto rule = db.ruleDao().getByKey(dbSession, RuleTesting.XOO_X1);
+ RuleDto rule = db.deprecatedRuleDao().getByKey(dbSession, RuleTesting.XOO_X1);
rule.setStatus(RuleStatus.REMOVED);
- db.ruleDao().update(dbSession, rule);
+ db.deprecatedRuleDao().update(dbSession, rule);
dbSession.commit();
dbSession.clearCache();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java
index a4fd86d203c..4754961c4ce 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java
@@ -279,7 +279,7 @@ public class ChangeParentActionMediumTest {
.setLanguage(lang)
.setSeverity(Severity.BLOCKER)
.setStatus(RuleStatus.READY);
- db.ruleDao().insert(session, rule);
+ db.deprecatedRuleDao().insert(session, rule);
return rule;
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
index 1f20960febc..0857b4db299 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java
@@ -85,7 +85,7 @@ public class ChangelogActionTest {
// create pre-defined rules
RuleDto xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR");
- db.ruleDao().insert(dbSession, xooRule1);
+ db.deprecatedRuleDao().insert(dbSession, xooRule1);
// create pre-defined profiles P1 and P2
db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1(), QProfileTesting.newXooP2());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java
index bd2e631a4f5..56df66cbde7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java
@@ -200,16 +200,16 @@ public class CompareActionMediumTest {
.setLanguage(lang)
.setSeverity(Severity.BLOCKER)
.setStatus(RuleStatus.READY);
- db.ruleDao().insert(session, rule);
+ db.deprecatedRuleDao().insert(session, rule);
RuleParamDto param = RuleParamDto.createFor(rule).setName("param_" + id).setType(RuleParamType.STRING.toString());
- db.ruleDao().insertRuleParam(session, rule, param);
+ db.deprecatedRuleDao().insertRuleParam(session, rule, param);
return rule;
}
private RuleDto createRuleWithParam(String lang, String id) {
RuleDto rule = createRule(lang, id);
RuleParamDto param = RuleParamDto.createFor(rule).setName("param_" + id).setType(RuleParamType.STRING.toString());
- db.ruleDao().insertRuleParam(session, rule, param);
+ db.deprecatedRuleDao().insertRuleParam(session, rule, param);
return rule;
}
@@ -222,7 +222,7 @@ public class CompareActionMediumTest {
private ActiveRuleDto createActiveRuleWithParam(RuleDto rule, QualityProfileDto profile, String value) {
ActiveRuleDto activeRule = createActiveRule(rule, profile);
- RuleParamDto paramDto = db.ruleDao().selectRuleParamsByRuleKey(session, rule.getKey()).get(0);
+ RuleParamDto paramDto = db.deprecatedRuleDao().selectRuleParamsByRuleKey(session, rule.getKey()).get(0);
ActiveRuleParamDto activeRuleParam = ActiveRuleParamDto.createFor(paramDto).setValue(value);
db.activeRuleDao().insertParam(session, activeRule, activeRuleParam);
return activeRule;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java
index b3115f83737..5583e65f88b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java
@@ -130,7 +130,7 @@ public class InheritanceActionMediumTest {
.setLanguage(lang)
.setSeverity(Severity.BLOCKER)
.setStatus(RuleStatus.READY);
- db.ruleDao().insert(session, rule);
+ db.deprecatedRuleDao().insert(session, rule);
return rule;
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
index 1185ca1296c..8b9a2c94f96 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
@@ -559,7 +559,7 @@ public class QProfilesWsMediumTest {
.setLanguage(lang)
.setSeverity(Severity.BLOCKER)
.setStatus(RuleStatus.READY);
- db.ruleDao().insert(session, rule);
+ db.deprecatedRuleDao().insert(session, rule);
return rule;
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java
index c512eda67be..3a5ddb6f4ff 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/DefaultRuleFinderMediumTest.java
@@ -65,7 +65,7 @@ public class DefaultRuleFinderMediumTest {
public static void setupClass() {
tester.clearDbAndIndexes();
DbSession session = tester.get(DbClient.class).openSession(false);
- tester.get(DbClient.class).ruleDao().insert(session,
+ tester.get(DbClient.class).deprecatedRuleDao().insert(session,
new RuleDto()
.setName("Check Header")
.setConfigKey("Checker/Treewalker/HeaderCheck")
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 acf991bb941..0aec87f3c59 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
@@ -129,10 +129,10 @@ public class RegisterRulesMediumTest {
});
// verify db : rule x1 + 6 common rules
- List<RuleDto> rules = db.ruleDao().selectAll(dbSession);
+ List<RuleDto> rules = db.deprecatedRuleDao().selectAll(dbSession);
assertThat(rules).hasSize(7);
assertThat(rules).extracting("key").contains(X1_KEY);
- List<RuleParamDto> ruleParams = db.ruleDao().selectRuleParamsByRuleKey(dbSession, X1_KEY);
+ List<RuleParamDto> ruleParams = db.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, X1_KEY);
assertThat(ruleParams).hasSize(2);
// verify es : rule x1 + 6 common rules
@@ -336,14 +336,14 @@ public class RegisterRulesMediumTest {
// Uninstall plugin
register(null);
- RuleDto rule = db.ruleDao().getByKey(dbSession, RuleTesting.XOO_X1);
+ RuleDto rule = db.deprecatedRuleDao().getByKey(dbSession, RuleTesting.XOO_X1);
assertThat(rule.getStatus()).isEqualTo(RuleStatus.REMOVED);
Rule indexedRule = ruleIndex.getByKey(RuleTesting.XOO_X1);
assertThat(indexedRule.status()).isEqualTo(RuleStatus.REMOVED);
// Re-install plugin
register(rules);
- rule = db.ruleDao().getByKey(dbSession, RuleTesting.XOO_X1);
+ rule = db.deprecatedRuleDao().getByKey(dbSession, RuleTesting.XOO_X1);
assertThat(rule.getStatus()).isEqualTo(RuleStatus.READY);
indexedRule = ruleIndex.getByKey(RuleTesting.XOO_X1);
assertThat(indexedRule.status()).isEqualTo(RuleStatus.READY);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
index 373e0eca5e2..f4d9ee2e97b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
@@ -79,9 +79,9 @@ public class RegisterRulesTest {
execute(new FakeRepositoryV1());
// verify db
- assertThat(dbClient.ruleDao().selectAll(dbTester.getSession())).hasSize(2);
+ assertThat(dbClient.deprecatedRuleDao().selectAll(dbTester.getSession())).hasSize(2);
RuleKey ruleKey1 = RuleKey.of("fake", "rule1");
- RuleDto rule1 = dbClient.ruleDao().getNullableByKey(dbTester.getSession(), ruleKey1);
+ RuleDto rule1 = dbClient.deprecatedRuleDao().getNullableByKey(dbTester.getSession(), ruleKey1);
assertThat(rule1.getName()).isEqualTo("One");
assertThat(rule1.getDescription()).isEqualTo("Description of One");
assertThat(rule1.getSeverityString()).isEqualTo(Severity.BLOCKER);
@@ -93,7 +93,7 @@ public class RegisterRulesTest {
assertThat(rule1.getUpdatedAt()).isEqualTo(DATE1);
// TODO check characteristic and remediation function
- List<RuleParamDto> params = dbClient.ruleDao().selectRuleParamsByRuleKey(dbTester.getSession(), ruleKey1);
+ List<RuleParamDto> params = dbClient.deprecatedRuleDao().selectRuleParamsByRuleKey(dbTester.getSession(), ruleKey1);
assertThat(params).hasSize(2);
RuleParamDto param = getParam(params, "param1");
assertThat(param.getDescription()).isEqualTo("parameter one");
@@ -103,13 +103,13 @@ public class RegisterRulesTest {
@Test
public void do_not_update_rules_when_no_changes() {
execute(new FakeRepositoryV1());
- assertThat(dbClient.ruleDao().selectAll(dbTester.getSession())).hasSize(2);
+ assertThat(dbClient.deprecatedRuleDao().selectAll(dbTester.getSession())).hasSize(2);
when(system.now()).thenReturn(DATE2.getTime());
execute(new FakeRepositoryV1());
RuleKey ruleKey1 = RuleKey.of("fake", "rule1");
- RuleDto rule1 = dbClient.ruleDao().getNullableByKey(dbTester.getSession(), ruleKey1);
+ RuleDto rule1 = dbClient.deprecatedRuleDao().getNullableByKey(dbTester.getSession(), ruleKey1);
assertThat(rule1.getCreatedAt()).isEqualTo(DATE1);
assertThat(rule1.getUpdatedAt()).isEqualTo(DATE1);
}
@@ -117,22 +117,22 @@ public class RegisterRulesTest {
@Test
public void update_and_remove_rules_on_changes() {
execute(new FakeRepositoryV1());
- assertThat(dbClient.ruleDao().selectAll(dbTester.getSession())).hasSize(2);
+ assertThat(dbClient.deprecatedRuleDao().selectAll(dbTester.getSession())).hasSize(2);
// user adds tags and sets markdown note
RuleKey ruleKey1 = RuleKey.of("fake", "rule1");
- RuleDto rule1 = dbClient.ruleDao().getNullableByKey(dbTester.getSession(), ruleKey1);
+ RuleDto rule1 = dbClient.deprecatedRuleDao().getNullableByKey(dbTester.getSession(), ruleKey1);
rule1.setTags(Sets.newHashSet("usertag1", "usertag2"));
rule1.setNoteData("user *note*");
rule1.setNoteUserLogin("marius");
- dbClient.ruleDao().update(dbTester.getSession(), rule1);
+ dbClient.deprecatedRuleDao().update(dbTester.getSession(), rule1);
dbTester.getSession().commit();
when(system.now()).thenReturn(DATE2.getTime());
execute(new FakeRepositoryV2());
// rule1 has been updated
- rule1 = dbClient.ruleDao().getNullableByKey(dbTester.getSession(), ruleKey1);
+ rule1 = dbClient.deprecatedRuleDao().getNullableByKey(dbTester.getSession(), ruleKey1);
assertThat(rule1.getName()).isEqualTo("One v2");
assertThat(rule1.getDescription()).isEqualTo("Description of One v2");
assertThat(rule1.getSeverityString()).isEqualTo(Severity.INFO);
@@ -146,19 +146,19 @@ public class RegisterRulesTest {
assertThat(rule1.getUpdatedAt()).isEqualTo(DATE2);
// TODO check characteristic and remediation function
- List<RuleParamDto> params = dbClient.ruleDao().selectRuleParamsByRuleKey(dbTester.getSession(), ruleKey1);
+ List<RuleParamDto> params = dbClient.deprecatedRuleDao().selectRuleParamsByRuleKey(dbTester.getSession(), ruleKey1);
assertThat(params).hasSize(2);
RuleParamDto param = getParam(params, "param1");
assertThat(param.getDescription()).isEqualTo("parameter one v2");
assertThat(param.getDefaultValue()).isEqualTo("default1 v2");
// rule2 has been removed -> status set to REMOVED but db row is not deleted
- RuleDto rule2 = dbClient.ruleDao().getNullableByKey(dbTester.getSession(), RuleKey.of("fake", "rule2"));
+ RuleDto rule2 = dbClient.deprecatedRuleDao().getNullableByKey(dbTester.getSession(), RuleKey.of("fake", "rule2"));
assertThat(rule2.getStatus()).isEqualTo(RuleStatus.REMOVED);
assertThat(rule2.getUpdatedAt()).isEqualTo(DATE2);
// rule3 has been created
- RuleDto rule3 = dbClient.ruleDao().getNullableByKey(dbTester.getSession(), RuleKey.of("fake", "rule3"));
+ RuleDto rule3 = dbClient.deprecatedRuleDao().getNullableByKey(dbTester.getSession(), RuleKey.of("fake", "rule3"));
assertThat(rule3).isNotNull();
assertThat(rule3.getStatus()).isEqualTo(RuleStatus.READY);
}
@@ -166,20 +166,20 @@ public class RegisterRulesTest {
@Test
public void do_not_update_already_removed_rules() {
execute(new FakeRepositoryV1());
- assertThat(dbClient.ruleDao().selectAll(dbTester.getSession())).hasSize(2);
+ assertThat(dbClient.deprecatedRuleDao().selectAll(dbTester.getSession())).hasSize(2);
- RuleDto rule2 = dbClient.ruleDao().getByKey(dbTester.getSession(), RuleKey.of("fake", "rule2"));
+ RuleDto rule2 = dbClient.deprecatedRuleDao().getByKey(dbTester.getSession(), RuleKey.of("fake", "rule2"));
assertThat(rule2.getStatus()).isEqualTo(RuleStatus.READY);
when(system.now()).thenReturn(DATE2.getTime());
execute(new FakeRepositoryV2());
// On MySQL, need to update a rule otherwise rule2 will be seen as READY, but why ???
- dbClient.ruleDao().update(dbTester.getSession(), dbClient.ruleDao().getByKey(dbTester.getSession(), RuleKey.of("fake", "rule1")));
+ dbClient.deprecatedRuleDao().update(dbTester.getSession(), dbClient.deprecatedRuleDao().getByKey(dbTester.getSession(), RuleKey.of("fake", "rule1")));
dbTester.getSession().commit();
// rule2 is removed
- rule2 = dbClient.ruleDao().getNullableByKey(dbTester.getSession(), RuleKey.of("fake", "rule2"));
+ rule2 = dbClient.deprecatedRuleDao().getNullableByKey(dbTester.getSession(), RuleKey.of("fake", "rule2"));
assertThat(rule2.getStatus()).isEqualTo(RuleStatus.REMOVED);
when(system.now()).thenReturn(DATE3.getTime());
@@ -187,7 +187,7 @@ public class RegisterRulesTest {
dbTester.getSession().commit();
// -> rule2 is still removed, but not update at DATE3
- rule2 = dbClient.ruleDao().getNullableByKey(dbTester.getSession(), RuleKey.of("fake", "rule2"));
+ rule2 = dbClient.deprecatedRuleDao().getNullableByKey(dbTester.getSession(), RuleKey.of("fake", "rule2"));
assertThat(rule2.getStatus()).isEqualTo(RuleStatus.REMOVED);
assertThat(rule2.getUpdatedAt()).isEqualTo(DATE2);
}
@@ -195,14 +195,14 @@ public class RegisterRulesTest {
@Test
public void mass_insert() {
execute(new BigRepository());
- assertThat(dbClient.ruleDao().selectAll(dbTester.getSession())).hasSize(BigRepository.SIZE);
- assertThat(dbClient.ruleDao().selectAllRuleParams(dbTester.getSession())).hasSize(BigRepository.SIZE * 20);
+ assertThat(dbClient.deprecatedRuleDao().selectAll(dbTester.getSession())).hasSize(BigRepository.SIZE);
+ assertThat(dbClient.deprecatedRuleDao().selectAllRuleParams(dbTester.getSession())).hasSize(BigRepository.SIZE * 20);
}
@Test
public void manage_repository_extensions() {
execute(new FindbugsRepository(), new FbContribRepository());
- List<RuleDto> rules = dbClient.ruleDao().selectAll(dbTester.getSession());
+ List<RuleDto> rules = dbClient.deprecatedRuleDao().selectAll(dbTester.getSession());
assertThat(rules).hasSize(2);
for (RuleDto rule : rules) {
assertThat(rule.getRepositoryKey()).isEqualTo("findbugs");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java
index 20de347d78c..18595296638 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java
@@ -21,6 +21,8 @@ package org.sonar.server.rule;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
+import java.util.Collection;
+import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
@@ -28,9 +30,9 @@ import org.junit.Test;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.server.rule.RuleParamType;
import org.sonar.db.DbSession;
+import org.sonar.db.debt.CharacteristicDto;
import org.sonar.db.rule.RuleDto;
import org.sonar.db.rule.RuleParamDto;
-import org.sonar.db.debt.CharacteristicDto;
import org.sonar.db.rule.RuleTesting;
import org.sonar.server.db.DbClient;
import org.sonar.server.debt.DebtTesting;
@@ -41,9 +43,6 @@ import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.rule.index.RuleQuery;
import org.sonar.server.search.QueryContext;
import org.sonar.server.tester.ServerTester;
-
-import java.util.Collection;
-import java.util.List;
import org.sonar.server.tester.UserSessionRule;
import static org.assertj.core.api.Assertions.assertThat;
@@ -168,7 +167,7 @@ public class RuleBackendMediumTest {
dao.insertRuleParam(dbSession, ruleDto, maxParamDto);
dbSession.commit();
- //Verify that RuleDto has date from insertion
+ // Verify that RuleDto has date from insertion
RuleDto theRule = dao.getNullableByKey(dbSession, RuleTesting.XOO_X1);
assertThat(theRule.getCreatedAt()).isNotNull();
assertThat(theRule.getUpdatedAt()).isNotNull();
@@ -224,7 +223,6 @@ public class RuleBackendMediumTest {
assertThat(index.getByKey(RuleTesting.XOO_X1).params()).hasSize(1);
}
-
@Test
public void insert_and_update_rule() {
// insert db
@@ -240,7 +238,7 @@ public class RuleBackendMediumTest {
assertThat(hit.tags()).containsExactly("hello");
assertThat(hit.name()).isEqualTo("first name");
- //Update in DB
+ // Update in DB
ruleDto.setTags(ImmutableSet.of("world"))
.setName("second name");
dao.update(dbSession, ruleDto);
@@ -286,8 +284,7 @@ public class RuleBackendMediumTest {
assertThat(param.defaultValue()).isEqualTo("2");
assertThat(param.description()).isEqualTo("Minimum");
-
- //Update in DB
+ // Update in DB
minParamDto
.setDefaultValue("0.5")
.setDescription("new description");
@@ -322,7 +319,6 @@ public class RuleBackendMediumTest {
assertThat(((RuleDoc) index.getByKey(RuleTesting.XOO_X1)).id()).isEqualTo(ruleDto.getId());
}
-
@Test
public void insert_update_characteristics() {
@@ -342,7 +338,6 @@ public class RuleBackendMediumTest {
.setRemediationOffset(null));
dbSession.commit();
-
// 0. assert chars in DB
assertThat(db.debtCharacteristicDao().selectByKey("c1", dbSession)).isNotNull();
assertThat(db.debtCharacteristicDao().selectByKey("c1", dbSession).getParentId()).isNull();
@@ -355,9 +350,8 @@ public class RuleBackendMediumTest {
assertThat(rule.debtSubCharacteristicKey()).isEqualTo(char11.getKey());
assertThat(rule.debtOverloaded()).isFalse();
-
// 3. set Non-default characteristics
- RuleDto ruleDto = db.ruleDao().getByKey(dbSession, RuleTesting.XOO_X1);
+ RuleDto ruleDto = db.deprecatedRuleDao().getByKey(dbSession, RuleTesting.XOO_X1);
CharacteristicDto char2 = DebtTesting.newCharacteristicDto("c2");
db.debtCharacteristicDao().insert(dbSession, char2);
@@ -378,7 +372,7 @@ public class RuleBackendMediumTest {
assertThat(rule.debtCharacteristicKey()).isEqualTo(char2.getKey());
assertThat(rule.debtSubCharacteristicKey()).isEqualTo(char21.getKey());
- // 5 Assert still get the default one
+ // 5 Assert still get the default one
assertThat(rule.debtOverloaded()).isTrue();
assertThat(rule.defaultDebtCharacteristicKey()).isEqualTo(char1.getKey());
assertThat(rule.defaultDebtSubCharacteristicKey()).isEqualTo(char11.getKey());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java
index 5bb4bb50e92..332b8b28e8a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java
@@ -89,7 +89,7 @@ public class RuleCreatorMediumTest {
dbSession.clearCache();
- RuleDto rule = db.ruleDao().getNullableByKey(dbSession, customRuleKey);
+ RuleDto rule = db.deprecatedRuleDao().getNullableByKey(dbSession, customRuleKey);
assertThat(rule).isNotNull();
assertThat(rule.getKey()).isEqualTo(RuleKey.of("java", "CUSTOM_RULE"));
assertThat(rule.getTemplateId()).isEqualTo(templateRule.getId());
@@ -107,7 +107,7 @@ public class RuleCreatorMediumTest {
assertThat(rule.getTags()).containsOnly("usertag1", "usertag2");
assertThat(rule.getSystemTags()).containsOnly("tag1", "tag4");
- List<RuleParamDto> params = db.ruleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey);
+ List<RuleParamDto> params = db.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey);
assertThat(params).hasSize(1);
RuleParamDto param = params.get(0);
@@ -134,7 +134,7 @@ public class RuleCreatorMediumTest {
RuleKey customRuleKey = creator.create(newRule);
dbSession.clearCache();
- List<RuleParamDto> params = db.ruleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey);
+ List<RuleParamDto> params = db.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey);
assertThat(params).hasSize(1);
RuleParamDto param = params.get(0);
@@ -158,7 +158,7 @@ public class RuleCreatorMediumTest {
RuleKey customRuleKey = creator.create(newRule);
dbSession.clearCache();
- List<RuleParamDto> params = db.ruleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey);
+ List<RuleParamDto> params = db.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey);
assertThat(params).hasSize(1);
RuleParamDto param = params.get(0);
@@ -183,7 +183,7 @@ public class RuleCreatorMediumTest {
RuleKey customRuleKey = creator.create(newRule);
dbSession.clearCache();
- List<RuleParamDto> params = db.ruleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey);
+ List<RuleParamDto> params = db.deprecatedRuleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey);
assertThat(params).hasSize(1);
RuleParamDto param = params.get(0);
@@ -279,7 +279,7 @@ public class RuleCreatorMediumTest {
assertThat(result.param("regex").defaultValue()).isEqualTo("a.*");
// Check that the id is the same
- assertThat(db.ruleDao().getByKey(dbSession, result.key()).getId()).isEqualTo(rule.getId());
+ assertThat(db.deprecatedRuleDao().getByKey(dbSession, result.key()).getId()).isEqualTo(rule.getId());
}
@Test
@@ -569,7 +569,7 @@ public class RuleCreatorMediumTest {
assertThat(result.severity()).isEqualTo(Severity.INFO);
// Check that the id is the same
- assertThat(db.ruleDao().getByKey(dbSession, result.key()).getId()).isEqualTo(rule.getId());
+ assertThat(db.deprecatedRuleDao().getByKey(dbSession, result.key()).getId()).isEqualTo(rule.getId());
}
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java
index 5f35a88dd02..ee290602c72 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java
@@ -72,7 +72,7 @@ public class RuleOperationsTest {
@Before
public void setUp() {
when(dbClient.openSession(false)).thenReturn(session);
- when(dbClient.ruleDao()).thenReturn(ruleDao);
+ when(dbClient.deprecatedRuleDao()).thenReturn(ruleDao);
when(dbClient.debtCharacteristicDao()).thenReturn(characteristicDao);
operations = new RuleOperations(dbClient);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
index e2f8d534bf1..c989b76e8c8 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
@@ -178,7 +178,7 @@ public class ViewIndexerTest {
String viewUuid = "ABCD";
RuleDto rule = RuleTesting.newXooX1();
- dbClient.ruleDao().insert(dbSession, rule);
+ dbClient.deprecatedRuleDao().insert(dbSession, rule);
ComponentDto project1 = addProjectWithIssue(rule);
issueIndexer.indexAll();
issueAuthorizationIndexer.index();