aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--sonar-db/src/main/java/org/sonar/core/user/DefaultUserFinder.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/DaoModule.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/DatabaseUtils.java3
-rw-r--r--sonar-db/src/main/java/org/sonar/db/DbClient.java7
-rw-r--r--sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDao.java38
-rw-r--r--sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDao.java50
-rw-r--r--sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java6
-rw-r--r--sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java3
-rw-r--r--sonar-db/src/main/java/org/sonar/db/rule/RuleDao.java58
-rw-r--r--sonar-db/src/main/java/org/sonar/db/rule/RuleMapper.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/user/UserDao.java38
-rw-r--r--sonar-db/src/main/java/org/sonar/db/user/UserMapper.java3
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml10
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml10
-rw-r--r--sonar-db/src/test/java/org/sonar/core/user/DefaultUserFinderTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java58
-rw-r--r--sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java5
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml12
61 files changed, 416 insertions, 230 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();
diff --git a/sonar-db/src/main/java/org/sonar/core/user/DefaultUserFinder.java b/sonar-db/src/main/java/org/sonar/core/user/DefaultUserFinder.java
index 16d2867c6c0..428d7b27918 100644
--- a/sonar-db/src/main/java/org/sonar/core/user/DefaultUserFinder.java
+++ b/sonar-db/src/main/java/org/sonar/core/user/DefaultUserFinder.java
@@ -49,7 +49,7 @@ public class DefaultUserFinder implements UserFinder {
@Override
public List<User> findByLogins(List<String> logins) {
- List<UserDto> dtos = userDao.selectUsersByLogins(logins);
+ List<UserDto> dtos = userDao.selectByLogins(logins);
return toUsers(dtos);
}
diff --git a/sonar-db/src/main/java/org/sonar/db/DaoModule.java b/sonar-db/src/main/java/org/sonar/db/DaoModule.java
index 6300c253adf..dde96831544 100644
--- a/sonar-db/src/main/java/org/sonar/db/DaoModule.java
+++ b/sonar-db/src/main/java/org/sonar/db/DaoModule.java
@@ -58,6 +58,7 @@ import org.sonar.db.qualitygate.ProjectQgateAssociationDao;
import org.sonar.db.qualitygate.QualityGateConditionDao;
import org.sonar.db.qualitygate.QualityGateDao;
import org.sonar.db.qualityprofile.QualityProfileDao;
+import org.sonar.db.rule.RuleDao;
import org.sonar.db.source.FileSourceDao;
import org.sonar.db.user.AuthorDao;
import org.sonar.db.user.AuthorizationDao;
@@ -102,6 +103,7 @@ public class DaoModule extends Module {
ProjectQgateAssociationDao.class,
QualityProfileDao.class,
PurgeDao.class,
+ RuleDao.class,
CharacteristicDao.class,
ResourceIndexDao.class,
ResourceDao.class,
diff --git a/sonar-db/src/main/java/org/sonar/db/DatabaseUtils.java b/sonar-db/src/main/java/org/sonar/db/DatabaseUtils.java
index a42de7dcafd..df9fbc98739 100644
--- a/sonar-db/src/main/java/org/sonar/db/DatabaseUtils.java
+++ b/sonar-db/src/main/java/org/sonar/db/DatabaseUtils.java
@@ -26,6 +26,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -84,7 +85,7 @@ public class DatabaseUtils {
if (input.isEmpty()) {
return Collections.emptyList();
}
- List<OUTPUT> results = newArrayList();
+ List<OUTPUT> results = new ArrayList<>();
List<List<INPUT>> partitionList = Lists.partition(newArrayList(input), PARTITION_SIZE_FOR_ORACLE);
for (List<INPUT> partition : partitionList) {
List<OUTPUT> subResults = function.apply(partition);
diff --git a/sonar-db/src/main/java/org/sonar/db/DbClient.java b/sonar-db/src/main/java/org/sonar/db/DbClient.java
index 6ff2e99fdd6..f6471e7388e 100644
--- a/sonar-db/src/main/java/org/sonar/db/DbClient.java
+++ b/sonar-db/src/main/java/org/sonar/db/DbClient.java
@@ -57,6 +57,7 @@ import org.sonar.db.qualitygate.ProjectQgateAssociationDao;
import org.sonar.db.qualitygate.QualityGateConditionDao;
import org.sonar.db.qualitygate.QualityGateDao;
import org.sonar.db.qualityprofile.QualityProfileDao;
+import org.sonar.db.rule.RuleDao;
import org.sonar.db.source.FileSourceDao;
import org.sonar.db.user.AuthorDao;
import org.sonar.db.user.AuthorizationDao;
@@ -113,6 +114,7 @@ public class DbClient {
private final CustomMeasureDao customMeasureDao;
private final MetricDao metricDao;
private final GroupDao groupDao;
+ private final RuleDao ruleDao;
public DbClient(Database database, MyBatis myBatis, Dao... daos) {
this.database = database;
@@ -165,6 +167,7 @@ public class DbClient {
customMeasureDao = getDao(map, CustomMeasureDao.class);
metricDao = getDao(map, MetricDao.class);
groupDao = getDao(map, GroupDao.class);
+ ruleDao = getDao(map, RuleDao.class);
doOnLoad(map);
}
@@ -357,6 +360,10 @@ public class DbClient {
return groupDao;
}
+ public RuleDao ruleDao() {
+ return ruleDao;
+ }
+
protected <K extends Dao> K getDao(Map<Class, Dao> map, Class<K> clazz) {
return (K) map.get(clazz);
}
diff --git a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDao.java b/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDao.java
index b925c34b6ae..fed8d421950 100644
--- a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDao.java
@@ -20,16 +20,16 @@
package org.sonar.db.issue;
-import com.google.common.collect.Lists;
+import com.google.common.base.Function;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
+import javax.annotation.Nonnull;
import org.apache.ibatis.session.SqlSession;
import org.sonar.db.Dao;
+import org.sonar.db.DatabaseUtils;
+import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
-import static com.google.common.collect.Lists.newArrayList;
-
public class ActionPlanDao implements Dao {
private final MyBatis mybatis;
@@ -78,23 +78,31 @@ public class ActionPlanDao implements Dao {
}
public List<ActionPlanDto> selectByKeys(Collection<String> keys) {
- if (keys.isEmpty()) {
- return Collections.emptyList();
- }
- SqlSession session = mybatis.openSession(false);
+ DbSession session = mybatis.openSession(false);
try {
- List<ActionPlanDto> dtosList = newArrayList();
- List<List<String>> keysPartition = Lists.partition(newArrayList(keys), 1000);
- for (List<String> partition : keysPartition) {
- List<ActionPlanDto> dtos = session.getMapper(ActionPlanMapper.class).findByKeys(partition);
- dtosList.addAll(dtos);
- }
- return dtosList;
+ return selectByKeys(session, keys);
} finally {
MyBatis.closeQuietly(session);
}
}
+ public List<ActionPlanDto> selectByKeys(DbSession dbSession, Collection<String> keys) {
+ return DatabaseUtils.executeLargeInputs(keys, new SelectByKeys(dbSession.getMapper(ActionPlanMapper.class)));
+ }
+
+ private static class SelectByKeys implements Function<List<String>, List<ActionPlanDto>> {
+ private final ActionPlanMapper mapper;
+
+ private SelectByKeys(ActionPlanMapper mapper) {
+ this.mapper = mapper;
+ }
+
+ @Override
+ public List<ActionPlanDto> apply(@Nonnull List<String> partitionOfKeys) {
+ return mapper.findByKeys(partitionOfKeys);
+ }
+ }
+
public List<ActionPlanDto> selectOpenByProjectId(Long projectId) {
SqlSession session = mybatis.openSession(false);
try {
diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDao.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDao.java
index 076681365eb..7a3f7bc686d 100644
--- a/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueChangeDao.java
@@ -20,19 +20,20 @@
package org.sonar.db.issue;
+import com.google.common.base.Function;
import com.google.common.collect.Lists;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
import org.sonar.api.server.ServerSide;
import org.sonar.core.issue.DefaultIssueComment;
import org.sonar.core.issue.FieldDiffs;
import org.sonar.db.Dao;
+import org.sonar.db.DatabaseUtils;
import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
-import static com.google.common.collect.Lists.newArrayList;
import static java.util.Arrays.asList;
@ServerSide
@@ -46,7 +47,7 @@ public class IssueChangeDao implements Dao {
public List<DefaultIssueComment> selectCommentsByIssues(DbSession session, Collection<String> issueKeys) {
List<DefaultIssueComment> comments = Lists.newArrayList();
- for (IssueChangeDto dto : selectByIssuesAndType(session, issueKeys, IssueChangeDto.TYPE_COMMENT)) {
+ for (IssueChangeDto dto : selectByTypeAndIssueKeys(session, issueKeys, IssueChangeDto.TYPE_COMMENT)) {
comments.add(dto.toComment());
}
return comments;
@@ -56,7 +57,7 @@ public class IssueChangeDao implements Dao {
DbSession session = mybatis.openSession(false);
try {
List<FieldDiffs> result = Lists.newArrayList();
- for (IssueChangeDto dto : selectByIssuesAndType(session, asList(issueKey), IssueChangeDto.TYPE_FIELD_CHANGE)) {
+ for (IssueChangeDto dto : selectByTypeAndIssueKeys(session, asList(issueKey), IssueChangeDto.TYPE_FIELD_CHANGE)) {
result.add(dto.toFieldDiffs());
}
return result;
@@ -68,7 +69,7 @@ public class IssueChangeDao implements Dao {
public List<IssueChangeDto> selectChangelogOfNonClosedIssuesByComponent(String componentUuid) {
DbSession session = mybatis.openSession(false);
try {
- IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class);
+ IssueChangeMapper mapper = mapper(session);
return mapper.selectChangelogOfNonClosedIssuesByComponent(componentUuid, IssueChangeDto.TYPE_FIELD_CHANGE);
} finally {
@@ -80,7 +81,7 @@ public class IssueChangeDao implements Dao {
public DefaultIssueComment selectCommentByKey(String commentKey) {
DbSession session = mybatis.openSession(false);
try {
- IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class);
+ IssueChangeMapper mapper = mapper(session);
IssueChangeDto dto = mapper.selectByKeyAndType(commentKey, IssueChangeDto.TYPE_COMMENT);
return dto != null ? dto.toComment() : null;
@@ -89,28 +90,35 @@ public class IssueChangeDao implements Dao {
}
}
- List<IssueChangeDto> selectByIssuesAndType(DbSession session, Collection<String> issueKeys, String changeType) {
- if (issueKeys.isEmpty()) {
- return Collections.emptyList();
+ public List<IssueChangeDto> selectByTypeAndIssueKeys(DbSession session, Collection<String> issueKeys, String changeType) {
+ return DatabaseUtils.executeLargeInputs(issueKeys, new SelectByIssueKeys(mapper(session), changeType));
+ }
+
+ private static class SelectByIssueKeys implements Function<List<String>, List<IssueChangeDto>> {
+
+ private final IssueChangeMapper mapper;
+ private final String changeType;
+
+ private SelectByIssueKeys(IssueChangeMapper mapper, String changeType) {
+ this.mapper = mapper;
+ this.changeType = changeType;
}
- IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class);
- List<IssueChangeDto> dtosList = newArrayList();
- List<List<String>> keysPartition = Lists.partition(newArrayList(issueKeys), 1000);
- for (List<String> partition : keysPartition) {
- List<IssueChangeDto> dtos = mapper.selectByIssuesAndType(partition, changeType);
- dtosList.addAll(dtos);
+
+ @Override
+ public List<IssueChangeDto> apply(@Nonnull List<String> issueKeys) {
+ return mapper.selectByIssuesAndType(issueKeys, changeType);
}
- return dtosList;
+
}
public void insert(DbSession session, IssueChangeDto change) {
- session.getMapper(IssueChangeMapper.class).insert(change);
+ mapper(session).insert(change);
}
public boolean delete(String key) {
DbSession session = mybatis.openSession(false);
try {
- IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class);
+ IssueChangeMapper mapper = mapper(session);
int count = mapper.delete(key);
session.commit();
return count == 1;
@@ -123,7 +131,7 @@ public class IssueChangeDao implements Dao {
public boolean update(IssueChangeDto change) {
DbSession session = mybatis.openSession(false);
try {
- IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class);
+ IssueChangeMapper mapper = mapper(session);
int count = mapper.update(change);
session.commit();
return count == 1;
@@ -132,4 +140,8 @@ public class IssueChangeDao implements Dao {
MyBatis.closeQuietly(session);
}
}
+
+ private IssueChangeMapper mapper(DbSession session) {
+ return session.getMapper(IssueChangeMapper.class);
+ }
}
diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java
index 42583413a09..36dbf668650 100644
--- a/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java
@@ -62,7 +62,7 @@ public class IssueDao implements Dao {
return Optional.fromNullable(mapper(session).selectByKey(key));
}
- public IssueDto selectByKeyOrFail(DbSession session, String key) {
+ public IssueDto selectOrFailByKey(DbSession session, String key) {
Optional<IssueDto> issue = selectByKey(session, key);
if (!issue.isPresent()) {
throw new RowNotFoundException(String.format("Issue with key '%s' does not exist", key));
@@ -103,9 +103,9 @@ public class IssueDao implements Dao {
* if input keys contain multiple occurrences of a key.
* <p>Contrary to {@link #selectByKeys(DbSession, List)}, results are in the same order as input keys.</p>
*/
- public Iterable<IssueDto> selectByOrderedKeys(DbSession session, List<String> keys) {
+ public List<IssueDto> selectByOrderedKeys(DbSession session, List<String> keys) {
List<IssueDto> unordered = selectByKeys(session, keys);
- return from(keys).transform(new KeyToIssue(unordered)).filter(Predicates.notNull());
+ return from(keys).transform(new KeyToIssue(unordered)).filter(Predicates.notNull()).toList();
}
private static class KeyToIssue implements Function<String, IssueDto> {
diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java
index ede94b1f5e2..51518fb1dc9 100644
--- a/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java
@@ -341,6 +341,7 @@ public final class IssueDto implements Serializable {
return this;
}
+ @CheckForNull
public String getAssignee() {
return assignee;
}
@@ -350,6 +351,7 @@ public final class IssueDto implements Serializable {
return this;
}
+ @CheckForNull
public String getAuthorLogin() {
return authorLogin;
}
@@ -359,6 +361,7 @@ public final class IssueDto implements Serializable {
return this;
}
+ @CheckForNull
public String getIssueAttributes() {
return issueAttributes;
}
diff --git a/sonar-db/src/main/java/org/sonar/db/rule/RuleDao.java b/sonar-db/src/main/java/org/sonar/db/rule/RuleDao.java
new file mode 100644
index 00000000000..b20552a3b62
--- /dev/null
+++ b/sonar-db/src/main/java/org/sonar/db/rule/RuleDao.java
@@ -0,0 +1,58 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.rule;
+
+import com.google.common.base.Function;
+import java.util.List;
+import javax.annotation.Nonnull;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.db.Dao;
+import org.sonar.db.DbSession;
+
+import static org.sonar.db.DatabaseUtils.executeLargeInputs;
+
+public class RuleDao implements Dao {
+
+ /**
+ * Select rules by keys, whatever their status. Returns an empty list
+ * if the list of {@code keys} is empty, without any db round trip.
+ */
+ public List<RuleDto> selectByKeys(final DbSession session, List<RuleKey> keys) {
+ return executeLargeInputs(keys, new KeyToDto(mapper(session)));
+ }
+
+ private RuleMapper mapper(DbSession session) {
+ return session.getMapper(RuleMapper.class);
+ }
+
+ private static class KeyToDto implements Function<List<RuleKey>, List<RuleDto>> {
+ private final RuleMapper mapper;
+
+ private KeyToDto(RuleMapper mapper) {
+ this.mapper = mapper;
+ }
+
+ @Override
+ public List<RuleDto> apply(@Nonnull List<RuleKey> partitionOfKeys) {
+ return mapper.selectByKeys(partitionOfKeys);
+ }
+ }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/rule/RuleMapper.java b/sonar-db/src/main/java/org/sonar/db/rule/RuleMapper.java
index 5074160a11c..79a1eebfe42 100644
--- a/sonar-db/src/main/java/org/sonar/db/rule/RuleMapper.java
+++ b/sonar-db/src/main/java/org/sonar/db/rule/RuleMapper.java
@@ -39,6 +39,8 @@ public interface RuleMapper {
RuleDto selectByKey(RuleKey ruleKey);
+ List<RuleDto> selectByKeys(@Param("ruleKeys") List<RuleKey> keys);
+
RuleDto selectByName(String name);
void update(RuleDto rule);
diff --git a/sonar-db/src/main/java/org/sonar/db/user/UserDao.java b/sonar-db/src/main/java/org/sonar/db/user/UserDao.java
index 108fa563892..5c1e52d5f8c 100644
--- a/sonar-db/src/main/java/org/sonar/db/user/UserDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/user/UserDao.java
@@ -19,13 +19,16 @@
*/
package org.sonar.db.user;
-import com.google.common.collect.Lists;
+import com.google.common.base.Function;
+import java.util.Collection;
import java.util.List;
import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
import org.apache.ibatis.session.SqlSession;
import org.sonar.api.user.UserQuery;
import org.sonar.api.utils.System2;
import org.sonar.db.Dao;
+import org.sonar.db.DatabaseUtils;
import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
import org.sonar.db.RowNotFoundException;
@@ -74,27 +77,34 @@ public class UserDao implements Dao {
return mapper.selectUserByLogin(login);
}
- public List<UserDto> selectUsersByLogins(List<String> logins) {
- List<UserDto> users = Lists.newArrayList();
+ /**
+ * Select users by logins, including disabled users. An empty list is returned
+ * if list of logins is empty, without any db round trips.
+ */
+ public List<UserDto> selectByLogins(DbSession session, Collection<String> logins) {
+ return DatabaseUtils.executeLargeInputs(logins, new SelectByLogins(mapper(session)));
+ }
+
+ public List<UserDto> selectByLogins(Collection<String> logins) {
DbSession session = mybatis.openSession(false);
try {
- users.addAll(selectUsersByLogins(session, logins));
+ return selectByLogins(session, logins);
} finally {
MyBatis.closeQuietly(session);
}
- return users;
}
- public List<UserDto> selectUsersByLogins(DbSession session, List<String> logins) {
- List<UserDto> users = Lists.newArrayList();
- if (!logins.isEmpty()) {
- UserMapper mapper = session.getMapper(UserMapper.class);
- List<List<String>> partitions = Lists.partition(logins, 1000);
- for (List<String> partition : partitions) {
- users.addAll(mapper.selectUsersByLogins(partition));
- }
+ private static class SelectByLogins implements Function<List<String>, List<UserDto>> {
+ private final UserMapper mapper;
+
+ private SelectByLogins(UserMapper mapper) {
+ this.mapper = mapper;
+ }
+
+ @Override
+ public List<UserDto> apply(@Nonnull List<String> partitionOfLogins) {
+ return mapper.selectByLogins(partitionOfLogins);
}
- return users;
}
public List<UserDto> selectUsers(UserQuery query) {
diff --git a/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java b/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java
index e387210942a..bef663e87d1 100644
--- a/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java
+++ b/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java
@@ -49,6 +49,8 @@ public interface UserMapper {
List<UserDto> selectUsers(UserQuery query);
+ List<UserDto> selectByLogins(List<String> logins);
+
@CheckForNull
GroupDto selectGroupByName(String name);
@@ -76,4 +78,5 @@ public interface UserMapper {
void deactivateUser(@Param("id") long userId, @Param("now") long now);
+
}
diff --git a/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml b/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml
index fd93ba7b0a5..4651984855a 100644
--- a/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml
@@ -71,6 +71,16 @@
FROM rules r WHERE r.plugin_name=#{repository} AND r.plugin_rule_key=#{rule}
</select>
+ <select id="selectByKeys" parameterType="map" resultType="Rule">
+ SELECT
+ <include refid="selectColumns"/>
+ FROM rules r
+ WHERE
+ <foreach collection="ruleKeys" index="index" item="ruleKey" open="" separator=" or " close="">
+ (r.plugin_name=#{ruleKey.repository} and r.plugin_rule_key=#{ruleKey.rule})
+ </foreach>
+ </select>
+
<select id="selectByName" parameterType="String" resultType="Rule">
select
<include refid="selectColumns"/>
diff --git a/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml b/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml
index d46d44f2eaa..14e57dcd5df 100644
--- a/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml
@@ -47,6 +47,16 @@
WHERE u.login=#{id} AND u.active=${_true}
</select>
+ <select id="selectByLogins" parameterType="string" resultType="User">
+ SELECT
+ <include refid="userColumns"/>
+ FROM users u
+ WHERE u.login in
+ <foreach collection="list" open="(" close=")" item="login" separator=",">
+ #{login}
+ </foreach>
+ </select>
+
<select id="selectUsersByLogins" parameterType="map" resultType="User">
SELECT
<include refid="userColumns"/>
diff --git a/sonar-db/src/test/java/org/sonar/core/user/DefaultUserFinderTest.java b/sonar-db/src/test/java/org/sonar/core/user/DefaultUserFinderTest.java
index 2a97bef0a21..cc67e416c6d 100644
--- a/sonar-db/src/test/java/org/sonar/core/user/DefaultUserFinderTest.java
+++ b/sonar-db/src/test/java/org/sonar/core/user/DefaultUserFinderTest.java
@@ -48,7 +48,7 @@ public class DefaultUserFinderTest {
public void findByLogins() {
UserDto david = new UserDto().setLogin("david").setName("David").setEmail("dav@id.com");
UserDto john = new UserDto().setLogin("john").setName("John").setEmail("jo@hn.com");
- when(dao.selectUsersByLogins(Arrays.asList("david", "john"))).thenReturn(Arrays.asList(david, john));
+ when(dao.selectByLogins(Arrays.asList("david", "john"))).thenReturn(Arrays.asList(david, john));
Collection<User> users = finder.findByLogins(Arrays.asList("david", "john"));
assertThat(users).hasSize(2);
diff --git a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java
index a99a08aa856..eb4d016d162 100644
--- a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java
@@ -30,6 +30,6 @@ public class DaoModuleTest {
public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new DaoModule().configure(container);
- assertThat(container.size()).isEqualTo(45);
+ assertThat(container.size()).isEqualTo(46);
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java b/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java
index c13d873d510..f1fc842061a 100644
--- a/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java
@@ -98,7 +98,7 @@ public class IssueDaoTest {
public void selectByKeyOrFail() {
dbTester.prepareDbUnit(getClass(), "shared.xml", "get_by_key.xml");
- IssueDto issue = dao.selectByKeyOrFail(dbTester.getSession(), "I1");
+ IssueDto issue = dao.selectOrFailByKey(dbTester.getSession(), "I1");
assertThat(issue.getKee()).isEqualTo("I1");
assertThat(issue.getId()).isEqualTo(1L);
assertThat(issue.getComponentUuid()).isEqualTo("CDEF");
@@ -135,7 +135,7 @@ public class IssueDaoTest {
dbTester.prepareDbUnit(getClass(), "shared.xml", "get_by_key.xml");
- dao.selectByKeyOrFail(dbTester.getSession(), "DOES_NOT_EXIST");
+ dao.selectOrFailByKey(dbTester.getSession(), "DOES_NOT_EXIST");
}
@Test
diff --git a/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java b/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java
new file mode 100644
index 00000000000..80de551b89f
--- /dev/null
+++ b/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java
@@ -0,0 +1,58 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.rule;
+
+import java.util.Collections;
+import java.util.List;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+import org.sonar.test.DbTests;
+
+import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
+
+@Category(DbTests.class)
+public class RuleDaoTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Rule
+ public DbTester dbTester = DbTester.create(System2.INSTANCE);
+
+ RuleDao underTest = dbTester.getDbClient().ruleDao();
+
+ @Test
+ public void selectByKeys() {
+ dbTester.prepareDbUnit(getClass(), "shared.xml");
+
+ assertThat(underTest.selectByKeys(dbTester.getSession(), Collections.<RuleKey>emptyList())).isEmpty();
+ assertThat(underTest.selectByKeys(dbTester.getSession(), asList(RuleKey.of("NOT", "FOUND"))).isEmpty());
+
+ List<RuleDto> rules = underTest.selectByKeys(dbTester.getSession(), asList(RuleKey.of("java", "S001"), RuleKey.of("java", "OTHER")));
+ assertThat(rules).hasSize(1);
+ assertThat(rules.get(0).getId()).isEqualTo(1);
+ }
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java
index 2602ba47394..07fea9e3c47 100644
--- a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java
@@ -36,6 +36,7 @@ import org.sonar.db.DbTester;
import org.sonar.db.RowNotFoundException;
import org.sonar.test.DbTests;
+import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
@@ -87,7 +88,7 @@ public class UserDaoTest {
public void selectUsersByLogins() {
db.prepareDbUnit(getClass(), "selectUsersByLogins.xml");
- Collection<UserDto> users = underTest.selectUsersByLogins(Arrays.asList("marius", "inactive_user", "other"));
+ Collection<UserDto> users = underTest.selectByLogins(asList("marius", "inactive_user", "other"));
assertThat(users).hasSize(2);
assertThat(users).extracting("login").containsOnly("marius", "inactive_user");
}
@@ -97,7 +98,7 @@ public class UserDaoTest {
db.truncateTables();
// no need to access db
- Collection<UserDto> users = underTest.selectUsersByLogins(Collections.<String>emptyList());
+ Collection<UserDto> users = underTest.selectByLogins(Collections.<String>emptyList());
assertThat(users).isEmpty();
}
diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml
new file mode 100644
index 00000000000..d7d86c81a35
--- /dev/null
+++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml
@@ -0,0 +1,12 @@
+<dataset>
+
+ <rules id="1" name="Null Pointer" plugin_rule_key="S001"
+ plugin_config_key="S1" plugin_name="java" description="[null]" priority="4" status="READY"
+ is_template="[false]" template_id="[null]"
+ tags="bug,performance" system_tags="cwe" />
+
+ <rules id="2" name="Slow" plugin_rule_key="S002"
+ plugin_config_key="S2" plugin_name="java" description="[null]" priority="4" status="BETA"
+ is_template="[false]" template_id="[null]"
+ tags="[null]" system_tags="[null]" />
+</dataset>