this.ruleDao = (RuleDao) daoByClass.get(RuleDao.class);
}
- public ActiveRuleDao activeRuleDao() {
+ public ActiveRuleDao deprecatedActiveRuleDao() {
return activeRuleDao;
}
private void doDelete(DbSession session, QualityProfileDto profile) {
db.qualityProfileDao().deleteAllProjectProfileAssociation(profile.getKey(), session);
- db.activeRuleDao().deleteByProfileKey(session, profile.getKey());
+ db.deprecatedActiveRuleDao().deleteByProfileKey(session, profile.getKey());
db.qualityProfileDao().delete(session, profile);
}
BulkChangeResult result = new BulkChangeResult(profile);
Set<RuleKey> ruleToBeDeactivated = Sets.newHashSet();
// Keep reference to all the activated rules before backup restore
- for (ActiveRuleDto activeRuleDto : db.activeRuleDao().selectByProfileKey(dbSession, profile.getKee())) {
+ for (ActiveRuleDto activeRuleDto : db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, profile.getKee())) {
if (activeRuleDto.getInheritance() == null) {
// inherited rules can't be deactivated
ruleToBeDeactivated.add(activeRuleDto.getKey().ruleKey());
activeRule = doInsert(change, context, dbSession);
} else if (change.getType() == ActiveRuleChange.Type.DEACTIVATED) {
- ActiveRuleDao dao = db.activeRuleDao();
+ ActiveRuleDao dao = db.deprecatedActiveRuleDao();
dao.deleteByKey(dbSession, change.getKey());
} else if (change.getType() == ActiveRuleChange.Type.UPDATED) {
private ActiveRuleDto doInsert(ActiveRuleChange change, RuleActivatorContext context, DbSession dbSession) {
ActiveRuleDto activeRule;
- ActiveRuleDao dao = db.activeRuleDao();
+ ActiveRuleDao dao = db.deprecatedActiveRuleDao();
activeRule = ActiveRuleDto.createFor(context.profile(), context.rule());
String severity = change.getSeverity();
if (severity != null) {
}
private ActiveRuleDto doUpdate(ActiveRuleChange change, RuleActivatorContext context, DbSession dbSession) {
- ActiveRuleDao dao = db.activeRuleDao();
+ ActiveRuleDao dao = db.deprecatedActiveRuleDao();
ActiveRuleDto activeRule = context.activeRule();
if (activeRule != null) {
String severity = change.getSeverity();
*/
public List<ActiveRuleChange> deactivate(DbSession dbSession, RuleDto ruleDto) {
List<ActiveRuleChange> changes = Lists.newArrayList();
- List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByRule(dbSession, ruleDto);
+ List<ActiveRuleDto> activeRules = db.deprecatedActiveRuleDao().selectByRule(dbSession, ruleDto);
for (ActiveRuleDto activeRule : activeRules) {
changes.addAll(deactivate(dbSession, activeRule.getKey(), true));
}
// set new parent
profile.setParentKee(parentKey);
db.qualityProfileDao().update(dbSession, profile);
- for (ActiveRuleDto parentActiveRule : db.activeRuleDao().selectByProfileKey(dbSession, parentKey)) {
+ for (ActiveRuleDto parentActiveRule : db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, parentKey)) {
try {
RuleActivation activation = new RuleActivation(parentActiveRule.getKey().ruleKey());
activate(dbSession, activation, profileKey);
if (profileDto.getParentKee() != null) {
profileDto.setParentKee(null);
db.qualityProfileDao().update(dbSession, profileDto);
- for (ActiveRuleDto activeRule : db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKey())) {
+ for (ActiveRuleDto activeRule : db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, profileDto.getKey())) {
if (ActiveRuleDto.INHERITED.equals(activeRule.getInheritance())) {
deactivate(dbSession, activeRule.getKey(), true);
} else if (ActiveRuleDto.OVERRIDES.equals(activeRule.getInheritance())) {
activeRule.setInheritance(null);
- db.activeRuleDao().update(dbSession, activeRule);
+ db.deprecatedActiveRuleDao().update(dbSession, activeRule);
}
}
}
*/
package org.sonar.server.qualityprofile;
-import org.sonar.api.server.ServerSide;
+import java.util.Collection;
import org.sonar.api.rule.RuleKey;
+import org.sonar.api.server.ServerSide;
import org.sonar.db.DbSession;
import org.sonar.db.qualityprofile.ActiveRuleDto;
import org.sonar.db.qualityprofile.ActiveRuleKey;
import org.sonar.server.db.DbClient;
import org.sonar.server.exceptions.BadRequestException;
-import java.util.Collection;
-
@ServerSide
public class RuleActivatorContextFactory {
private void initActiveRules(String profileKey, RuleKey ruleKey, RuleActivatorContext context, DbSession session, boolean parent) {
ActiveRuleKey key = ActiveRuleKey.of(profileKey, ruleKey);
- ActiveRuleDto activeRule = db.activeRuleDao().getNullableByKey(session, key);
+ ActiveRuleDto activeRule = db.deprecatedActiveRuleDao().getNullableByKey(session, key);
Collection<ActiveRuleParamDto> activeRuleParams = null;
if (activeRule != null) {
- activeRuleParams = db.activeRuleDao().selectParamsByActiveRuleKey(session, key);
+ activeRuleParams = db.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(session, key);
}
if (parent) {
context.setParentActiveRule(activeRule);
String parentKey = null;
Integer parentId = activeRuleDto.getParentId();
if (parentId != null) {
- ActiveRuleDto parentDto = db.activeRuleDao().selectById(session, parentId);
+ ActiveRuleDto parentDto = db.deprecatedActiveRuleDao().selectById(session, parentId);
if (parentDto != null) {
parentKey = parentDto.getKey().toString();
}
.upsert(getUpsertFor(ActiveRuleField.ALL_FIELDS, newRule)));
// Get the RuleParameters
- for (ActiveRuleParamDto param : db.activeRuleDao().selectParamsByActiveRuleKey(session, key)) {
+ for (ActiveRuleParamDto param : db.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(session, key)) {
requests.addAll(normalizeNested(param, key));
}
for (RuleParamDto paramDto : paramDtos) {
RulesDefinition.Param paramDef = ruleDef.param(paramDto.getName());
if (paramDef == null) {
- dbClient.activeRuleDao().deleteParamsByRuleParam(session, rule, paramDto.getName());
+ dbClient.deprecatedActiveRuleDao().deleteParamsByRuleParam(session, rule, paramDto.getName());
dbClient.ruleDao().deleteRuleParam(session, paramDto.getId());
} else {
if (mergeParam(paramDto, paramDef)) {
dbClient.ruleDao().insertRuleParam(session, rule, paramDto);
if (!StringUtils.isEmpty(param.defaultValue())) {
// Propagate the default value to existing active rules
- for (ActiveRuleDto activeRule : dbClient.activeRuleDao().selectByRule(session, rule)) {
+ for (ActiveRuleDto activeRule : dbClient.deprecatedActiveRuleDao().selectByRule(session, rule)) {
ActiveRuleParamDto activeParam = ActiveRuleParamDto.createFor(paramDto).setValue(param.defaultValue());
- dbClient.activeRuleDao().insertParam(session, activeRule, activeParam);
+ dbClient.deprecatedActiveRuleDao().insertParam(session, activeRule, activeParam);
}
}
}
// Load active rules and its parameters in cache
Multimap<RuleDto, ActiveRuleDto> activeRules = ArrayListMultimap.create();
Multimap<ActiveRuleDto, ActiveRuleParamDto> activeRuleParams = ArrayListMultimap.create();
- for (ActiveRuleDto activeRuleDto : dbClient.activeRuleDao().selectByRule(dbSession, customRule)) {
+ for (ActiveRuleDto activeRuleDto : dbClient.deprecatedActiveRuleDao().selectByRule(dbSession, customRule)) {
activeRules.put(customRule, activeRuleDto);
- for (ActiveRuleParamDto activeRuleParamDto : dbClient.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey())) {
+ for (ActiveRuleParamDto activeRuleParamDto : dbClient.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey())) {
activeRuleParams.put(activeRuleDto, activeRuleParamDto);
}
}
for (ActiveRuleDto activeRuleDto : activeRules.get(customRule)) {
for (ActiveRuleParamDto activeRuleParamDto : activeRuleParams.get(activeRuleDto)) {
if (activeRuleParamDto.getKey().equals(key)) {
- dbClient.activeRuleDao().updateParam(dbSession, activeRuleDto, activeRuleParamDto.setValue(value));
+ dbClient.deprecatedActiveRuleDao().updateParam(dbSession, activeRuleDto, activeRuleParamDto.setValue(value));
} else {
- dbClient.activeRuleDao().insertParam(dbSession, activeRuleDto, ActiveRuleParamDto.createFor(ruleParamDto).setValue(value));
+ dbClient.deprecatedActiveRuleDao().insertParam(dbSession, activeRuleDto, ActiveRuleParamDto.createFor(ruleParamDto).setValue(value));
}
}
}
for (ActiveRuleDto activeRuleDto : activeRules.get(customRule)) {
for (ActiveRuleParamDto activeRuleParamDto : activeRuleParams.get(activeRuleDto)) {
if (activeRuleParamDto.getKey().equals(key)) {
- dbClient.activeRuleDao().deleteParam(dbSession, activeRuleDto, activeRuleParamDto);
+ dbClient.deprecatedActiveRuleDao().deleteParam(dbSession, activeRuleDto, activeRuleParamDto);
}
}
}
// DAO
assertThat(client.qualityProfileDao()).isSameAs(qualityProfileDao);
- assertThat(client.activeRuleDao()).isSameAs(activeRuleDao);
+ assertThat(client.deprecatedActiveRuleDao()).isSameAs(activeRuleDao);
assertThat(client.deprecatedRuleDao()).isSameAs(ruleDao);
}
}
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.rule.RuleKey;
import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.assertThat;
+// TODO To be removed when dao v2 is removed
+@Ignore
public class ActiveRuleTest {
@ClassRule
db.deprecatedRuleDao().insert(dbSession, rule1);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile1, rule1).setSeverity("BLOCKER");
- db.activeRuleDao().insert(dbSession, activeRule);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
dbSession.commit();
// 1. Synchronize since 0
tester.clearIndexes();
assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNull();
- db.activeRuleDao().synchronizeAfter(dbSession, new Date(0L));
+ db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, new Date(0L));
dbSession.commit();
assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNotNull();
// 2. Synchronize since beginning
tester.clearIndexes();
assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNull();
- db.activeRuleDao().synchronizeAfter(dbSession, beginning);
+ db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, beginning);
dbSession.commit();
assertThat(index.get(ActiveRuleIndex.class).getNullableByKey(activeRule.getKey())).isNotNull();
db.deprecatedRuleDao().insert(dbSession, rule);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
- db.activeRuleDao().insert(dbSession, activeRule);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
dbSession.commit();
// Remove rule -> Active rule is now linked to a not existing rule
// Synchronize index from start
tester.clearIndexes();
- db.activeRuleDao().synchronizeAfter(dbSession, new Date(0L));
+ db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, new Date(0L));
dbSession.commit();
// Active does not exist in the index
db.deprecatedRuleDao().insert(dbSession, rule);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
- db.activeRuleDao().insert(dbSession, activeRule);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
dbSession.commit();
// Remove quality profile -> active rule is now linked to a not existing quality profile
// Synchronize index from start
tester.clearIndexes();
- db.activeRuleDao().synchronizeAfter(dbSession, new Date(0L));
+ db.deprecatedActiveRuleDao().synchronizeAfter(dbSession, new Date(0L));
dbSession.commit();
// Active does not exist in the index
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, ruleDto)
.setInheritance(ActiveRule.Inheritance.INHERITED.name())
.setSeverity(Severity.BLOCKER);
- db.activeRuleDao().insert(dbSession, activeRule);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
dbSession.commit();
// verify db
- assertThat(db.activeRuleDao().getByKey(dbSession, activeRule.getKey())).isNotNull();
- List<ActiveRuleDto> persistedDtos = db.activeRuleDao().selectByRule(dbSession, ruleDto);
+ assertThat(db.deprecatedActiveRuleDao().getByKey(dbSession, activeRule.getKey())).isNotNull();
+ List<ActiveRuleDto> persistedDtos = db.deprecatedActiveRuleDao().selectByRule(dbSession, ruleDto);
assertThat(persistedDtos).hasSize(1);
// verify es
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, ruleDto)
.setInheritance(ActiveRule.Inheritance.INHERITED.name())
.setSeverity(Severity.BLOCKER);
- db.activeRuleDao().insert(dbSession, activeRule);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
ActiveRuleParamDto activeRuleMinParam = ActiveRuleParamDto.createFor(minParam)
.setValue("minimum");
- db.activeRuleDao().insertParam(dbSession, activeRule, activeRuleMinParam);
+ db.deprecatedActiveRuleDao().insertParam(dbSession, activeRule, activeRuleMinParam);
ActiveRuleParamDto activeRuleMaxParam = ActiveRuleParamDto.createFor(maxParam)
.setValue("maximum");
- db.activeRuleDao().insertParam(dbSession, activeRule, activeRuleMaxParam);
+ db.deprecatedActiveRuleDao().insertParam(dbSession, activeRule, activeRuleMaxParam);
dbSession.commit();
// verify db
- List<ActiveRuleParamDto> persistedDtos = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRule.getKey());
+ List<ActiveRuleParamDto> persistedDtos = db.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(dbSession, activeRule.getKey());
assertThat(persistedDtos).hasSize(2);
// verify es
RuleDto removedRule = RuleTesting.newDto(RuleKey.of("xoo", "removed")).setSeverity(Severity.MAJOR).setStatus(RuleStatus.REMOVED);
db.deprecatedRuleDao().insert(dbSession, rule1, rule2, removedRule);
- db.activeRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile1, rule1).setSeverity(Severity.MINOR));
- db.activeRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile1, rule2).setSeverity(Severity.BLOCKER));
- db.activeRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile2, rule2).setSeverity(Severity.CRITICAL));
+ db.deprecatedActiveRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile1, rule1).setSeverity(Severity.MINOR));
+ db.deprecatedActiveRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile1, rule2).setSeverity(Severity.BLOCKER));
+ db.deprecatedActiveRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile2, rule2).setSeverity(Severity.CRITICAL));
// Removed rule can still be activated for instance when removing the checkstyle plugin, active rules related on checkstyle are not
// removed
// because if the plugin is re-install, quality profiles using these rule are not changed.
- db.activeRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile2, removedRule).setSeverity(Severity.MAJOR));
+ db.deprecatedActiveRuleDao().insert(dbSession, ActiveRuleDto.createFor(profile2, removedRule).setSeverity(Severity.MAJOR));
dbSession.commit();
// 1. find by rule key
// in db
dbSession.clearCache();
- assertThat(db.activeRuleDao().selectByRule(dbSession, rule1)).hasSize(1);
- assertThat(db.activeRuleDao().selectByRule(dbSession, rule2)).hasSize(2);
+ assertThat(db.deprecatedActiveRuleDao().selectByRule(dbSession, rule1)).hasSize(1);
+ assertThat(db.deprecatedActiveRuleDao().selectByRule(dbSession, rule2)).hasSize(2);
// in es
List<ActiveRule> activeRules = index.get(ActiveRuleIndex.class).findByRule(RuleTesting.XOO_X1);
db.deprecatedRuleDao().insert(dbSession, rule);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, rule).setSeverity(Severity.MAJOR);
- db.activeRuleDao().insert(dbSession, activeRule);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
}
dbSession.commit();
dbSession.clearCache();
ActiveRuleDto activeRule1 = ActiveRuleDto.createFor(profileDto1, ruleDto).setSeverity(Severity.MAJOR);
ActiveRuleDto activeRule2 = ActiveRuleDto.createFor(profileDto2, ruleDto).setSeverity(Severity.MAJOR);
- db.activeRuleDao().insert(dbSession, activeRule1, activeRule2);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule1, activeRule2);
dbSession.commit();
// 0. Test base case
ActiveRuleDto activeRule1 = ActiveRuleDto.createFor(profileDto1, ruleDto).setSeverity(Severity.MAJOR);
ActiveRuleDto activeRule2 = ActiveRuleDto.createFor(profileDto2, ruleDto).setSeverity(Severity.MAJOR);
- db.activeRuleDao().insert(dbSession, activeRule1, activeRule2);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule1, activeRule2);
dbSession.commit();
// 0. Test base case
RuleDto ruleDto2 = newRuleDto(RuleTesting.XOO_X2);
db.deprecatedRuleDao().insert(dbSession, ruleDto1, ruleDto2);
- db.activeRuleDao().insert(dbSession,
+ db.deprecatedActiveRuleDao().insert(dbSession,
ActiveRuleDto.createFor(profileDto1, ruleDto1)
.setInheritance(ActiveRule.Inheritance.INHERITED.name())
.setSeverity(Severity.BLOCKER),
profileKeys.add(profileDto.getKey());
db.qualityProfileDao().insert(dbSession, profileDto);
- db.activeRuleDao().insert(dbSession,
+ db.deprecatedActiveRuleDao().insert(dbSession,
ActiveRuleDto.createFor(profileDto, ruleDto1)
.setSeverity(Severity.BLOCKER),
ActiveRuleDto.createFor(profileDto, ruleDto2)
db.deprecatedRuleDao().insert(dbSession, rule);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
- db.activeRuleDao().insert(dbSession, activeRule);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
dbSession.commit();
- assertThat(db.activeRuleDao().selectById(dbSession, activeRule.getId()).getId()).isEqualTo(activeRule.getId());
+ assertThat(db.deprecatedActiveRuleDao().selectById(dbSession, activeRule.getId()).getId()).isEqualTo(activeRule.getId());
}
@Test
db.deprecatedRuleDao().insert(dbSession, rule);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
- db.activeRuleDao().insert(dbSession, activeRule);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
dbSession.commit();
// Remove rule -> Active rule is now linked to a not existing rule
executeSql(String.format("DELETE FROM rules WHERE id=%s", rule.getId()));
dbSession.commit();
- assertThat(db.activeRuleDao().selectById(dbSession, activeRule.getId())).isNull();
+ assertThat(db.deprecatedActiveRuleDao().selectById(dbSession, activeRule.getId())).isNull();
}
@Test
db.deprecatedRuleDao().insert(dbSession, rule);
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
- db.activeRuleDao().insert(dbSession, activeRule);
+ db.deprecatedActiveRuleDao().insert(dbSession, activeRule);
dbSession.commit();
// Remove quality profile -> active rule is now linked to a not existing quality profile
executeSql(String.format("DELETE FROM rules_profiles WHERE id=%s", profile.getId()));
dbSession.commit();
- assertThat(db.activeRuleDao().selectById(dbSession, activeRule.getId())).isNull();
+ assertThat(db.deprecatedActiveRuleDao().selectById(dbSession, activeRule.getId())).isNull();
}
private RuleDto newRuleDto(RuleKey ruleKey) {
null);
dbSession.clearCache();
- assertThat(db.activeRuleDao().selectAll(dbSession)).hasSize(0);
+ assertThat(db.deprecatedActiveRuleDao().selectAll(dbSession)).hasSize(0);
List<QualityProfileDto> profiles = db.qualityProfileDao().selectAll(dbSession);
assertThat(profiles).hasSize(1);
assertThat(profiles.get(0).getName()).isEqualTo("P1");
dbSession.clearCache();
assertThat(db.qualityProfileDao().selectAll(dbSession)).isEmpty();
- assertThat(db.activeRuleDao().selectAll(dbSession)).isEmpty();
- assertThat(db.activeRuleDao().selectAllParams(dbSession)).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectAll(dbSession)).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectAllParams(dbSession)).isEmpty();
assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P1_KEY)).isEmpty();
}
dbSession.commit();
dbSession.clearCache();
assertThat(db.qualityProfileDao().selectAll(dbSession)).hasSize(3);
- assertThat(db.activeRuleDao().selectAll(dbSession)).hasSize(3);
+ assertThat(db.deprecatedActiveRuleDao().selectAll(dbSession)).hasSize(3);
factory.delete(XOO_P1_KEY);
dbSession.clearCache();
assertThat(db.qualityProfileDao().selectAll(dbSession)).isEmpty();
- assertThat(db.activeRuleDao().selectAll(dbSession)).isEmpty();
- assertThat(db.activeRuleDao().selectAllParams(dbSession)).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectAll(dbSession)).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectAllParams(dbSession)).isEmpty();
assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P1_KEY)).isEmpty();
assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P2_KEY)).isEmpty();
assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P3_KEY)).isEmpty();
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.utils.ValidationMessages;
import org.sonar.db.DbSession;
+import org.sonar.db.loadedtemplate.LoadedTemplateDto;
import org.sonar.db.qualityprofile.ActiveRuleDto;
import org.sonar.db.qualityprofile.ActiveRuleKey;
import org.sonar.db.qualityprofile.ActiveRuleParamDto;
import org.sonar.db.qualityprofile.QualityProfileDao;
import org.sonar.db.qualityprofile.QualityProfileDto;
-import org.sonar.db.loadedtemplate.LoadedTemplateDto;
import org.sonar.server.db.DbClient;
import org.sonar.server.platform.Platform;
import org.sonar.server.qualityprofile.db.ActiveRuleDao;
assertThat(profile).isNotNull();
// Check ActiveRules in DB
- ActiveRuleDao activeRuleDao = dbClient().activeRuleDao();
+ ActiveRuleDao activeRuleDao = dbClient().deprecatedActiveRuleDao();
assertThat(activeRuleDao.selectByProfileKey(dbSession, profile.getKey())).hasSize(2);
RuleKey ruleKey = RuleKey.of("xoo", "x1");
ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), ruleKey);
verifyDefaultProfile("xoo", "Basic");
// Check ActiveRules in DB
- ActiveRuleDao activeRuleDao = dbClient().activeRuleDao();
+ ActiveRuleDao activeRuleDao = dbClient().deprecatedActiveRuleDao();
assertThat(activeRuleDao.selectByProfileKey(dbSession, profile.getKey())).hasSize(2);
RuleKey ruleKey = RuleKey.of("xoo", "x1");
import org.sonar.db.qualityprofile.QualityProfileDto;
import org.sonar.db.rule.RuleDto;
import org.sonar.db.rule.RuleParamDto;
+import org.sonar.db.rule.RuleTesting;
import org.sonar.server.db.DbClient;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.Message;
import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
-import org.sonar.db.rule.RuleTesting;
import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.rule.index.RuleQuery;
import org.sonar.server.search.QueryContext;
activation.setSeverity(Severity.BLOCKER);
activate(activation, XOO_P1_KEY);
- assertThat(db.activeRuleDao().selectParamByKeyAndName(activeRuleKey, "max", dbSession)).isNotNull();
- db.activeRuleDao().deleteParamByKeyAndName(dbSession, activeRuleKey, "max");
+ assertThat(db.deprecatedActiveRuleDao().selectParamByKeyAndName(activeRuleKey, "max", dbSession)).isNotNull();
+ db.deprecatedActiveRuleDao().deleteParamByKeyAndName(dbSession, activeRuleKey, "max");
dbSession.commit();
- assertThat(db.activeRuleDao().selectParamByKeyAndName(activeRuleKey, "max", dbSession)).isNull();
+ assertThat(db.deprecatedActiveRuleDao().selectParamByKeyAndName(activeRuleKey, "max", dbSession)).isNull();
dbSession.clearCache();
// update
// 2. assert that all activation has been commit to DB and ES
dbSession.clearCache();
- assertThat(db.activeRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).hasSize(bulkSize);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).hasSize(bulkSize);
assertThat(index.findByProfile(XOO_P1_KEY)).hasSize(bulkSize);
assertThat(result.countSucceeded()).isEqualTo(bulkSize);
assertThat(result.countFailed()).isEqualTo(0);
// 2. assert that all activations have been commit to DB and ES
// -> xoo rules x1, x2 and custom1
dbSession.clearCache();
- assertThat(db.activeRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).hasSize(3);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).hasSize(3);
assertThat(index.findByProfile(XOO_P1_KEY)).hasSize(3);
assertThat(result.countSucceeded()).isEqualTo(3);
assertThat(result.countFailed()).isGreaterThan(0);
}
private int countActiveRules(String profileKey) {
- List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().selectByProfileKey(dbSession, profileKey);
+ List<ActiveRuleDto> activeRuleDtos = db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, profileKey);
List<ActiveRule> activeRules = Lists.newArrayList(index.findByProfile(profileKey));
assertThat(activeRuleDtos.size()).as("Not same active rules between db and index").isEqualTo(activeRules.size());
return activeRuleDtos.size();
@Nullable String expectedInheritance, Map<String, String> expectedParams) {
// verify db
boolean found = false;
- List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().selectByProfileKey(dbSession, activeRuleKey.qProfile());
+ List<ActiveRuleDto> activeRuleDtos = db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, activeRuleKey.qProfile());
for (ActiveRuleDto activeRuleDto : activeRuleDtos) {
if (activeRuleDto.getKey().equals(activeRuleKey)) {
found = true;
assertThat(activeRuleDto.getCreatedAt()).isNotNull();
assertThat(activeRuleDto.getUpdatedAt()).isNotNull();
- List<ActiveRuleParamDto> paramDtos = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey());
+ List<ActiveRuleParamDto> paramDtos = db.deprecatedActiveRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey());
assertThat(paramDtos).hasSize(expectedParams.size());
for (Map.Entry<String, String> entry : expectedParams.entrySet()) {
- ActiveRuleParamDto paramDto = db.activeRuleDao().selectParamByKeyAndName(activeRuleDto.getKey(), entry.getKey(), dbSession);
+ ActiveRuleParamDto paramDto = db.deprecatedActiveRuleDao().selectParamByKeyAndName(activeRuleDto.getKey(), entry.getKey(), dbSession);
assertThat(paramDto).isNotNull();
assertThat(paramDto.getValue()).isEqualTo(entry.getValue());
}
private void verifyZeroActiveRules(String key) {
// verify db
dbSession.clearCache();
- List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().selectByProfileKey(dbSession, key);
+ List<ActiveRuleDto> activeRuleDtos = db.deprecatedActiveRuleDao().selectByProfileKey(dbSession, key);
assertThat(activeRuleDtos).isEmpty();
// verify es
*/
package org.sonar.server.qualityprofile.ws;
+import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsTester;
-import java.util.List;
-
import static org.assertj.core.api.Assertions.assertThat;
public class ChangeParentActionMediumTest {
createActiveRule(rule1, parent1);
session.commit();
- assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
// Set parent
wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent")
session.clearCache();
// Check rule 1 enabled
- List<ActiveRuleDto> activeRules1 = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+ List<ActiveRuleDto> activeRules1 = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
assertThat(activeRules1).hasSize(1);
assertThat(activeRules1.get(0).getKey().ruleKey().rule()).isEqualTo("rule1");
}
session.clearCache();
// Check rule 2 enabled
- List<ActiveRuleDto> activeRules2 = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+ List<ActiveRuleDto> activeRules2 = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
assertThat(activeRules2).hasSize(1);
assertThat(activeRules2.get(0).getKey().ruleKey().rule()).isEqualTo("rule2");
}
session.clearCache();
// Check no rule enabled
- List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+ List<ActiveRuleDto> activeRules = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
assertThat(activeRules).isEmpty();
}
createActiveRule(rule2, parent2);
session.commit();
- assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
// 1. Set parent 1
wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent")
session.clearCache();
// 1. check rule 1 enabled
- List<ActiveRuleDto> activeRules1 = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+ List<ActiveRuleDto> activeRules1 = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
assertThat(activeRules1).hasSize(1);
assertThat(activeRules1.get(0).getKey().ruleKey().rule()).isEqualTo("rule1");
session.clearCache();
// 2. check rule 2 enabled
- List<ActiveRuleDto> activeRules2 = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+ List<ActiveRuleDto> activeRules2 = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
assertThat(activeRules2).hasSize(1);
assertThat(activeRules2.get(0).getKey().ruleKey().rule()).isEqualTo("rule2");
session.clearCache();
// 3. check no rule enabled
- List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+ List<ActiveRuleDto> activeRules = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
assertThat(activeRules).isEmpty();
}
createActiveRule(rule1, parent);
session.commit();
- assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
// Set parent
tester.get(RuleActivator.class).setParent(child.getKey(), parent.getKey());
session.clearCache();
// Check no rule enabled
- List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(session, child.getKey());
+ List<ActiveRuleDto> activeRules = db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey());
assertThat(activeRules).isEmpty();
}
QualityProfileDto child = createProfile("xoo", "Child");
session.commit();
- assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent")
.setParam(QProfileIdentificationParamUtils.PARAM_PROFILE_KEY, child.getKee())
QualityProfileDto child = createProfile("xoo", "Child");
session.commit();
- assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent")
.setParam(QProfileIdentificationParamUtils.PARAM_PROFILE_KEY, child.getKee())
private ActiveRuleDto createActiveRule(RuleDto rule, QualityProfileDto profile) {
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
.setSeverity(rule.getSeverityString());
- db.activeRuleDao().insert(session, activeRule);
+ db.deprecatedActiveRuleDao().insert(session, activeRule);
return activeRule;
}
}
private ActiveRuleDto createActiveRule(RuleDto rule, QualityProfileDto profile) {
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
.setSeverity(rule.getSeverityString());
- db.activeRuleDao().insert(session, activeRule);
+ db.deprecatedActiveRuleDao().insert(session, activeRule);
return activeRule;
}
ActiveRuleDto activeRule = createActiveRule(rule, profile);
RuleParamDto paramDto = db.deprecatedRuleDao().selectRuleParamsByRuleKey(session, rule.getKey()).get(0);
ActiveRuleParamDto activeRuleParam = ActiveRuleParamDto.createFor(paramDto).setValue(value);
- db.activeRuleDao().insertParam(session, activeRule, activeRuleParam);
+ db.deprecatedActiveRuleDao().insertParam(session, activeRule, activeRuleParam);
return activeRule;
}
private ActiveRuleDto createActiveRuleWithSeverity(RuleDto rule, QualityProfileDto profile, String severity) {
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
.setSeverity(severity);
- db.activeRuleDao().insert(session, activeRule);
+ db.deprecatedActiveRuleDao().insert(session, activeRule);
return activeRule;
}
}
private ActiveRuleDto createActiveRule(RuleDto rule, QualityProfileDto profile) {
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
.setSeverity(rule.getSeverityString());
- db.activeRuleDao().insert(session, activeRule);
+ db.deprecatedActiveRuleDao().insert(session, activeRule);
return activeRule;
}
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
import org.sonar.api.server.ws.WebService;
-import org.sonar.db.component.ComponentDto;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.db.DbSession;
+import org.sonar.db.component.ComponentDto;
import org.sonar.db.qualityprofile.ActiveRuleDto;
import org.sonar.db.qualityprofile.ActiveRuleKey;
import org.sonar.db.qualityprofile.QualityProfileDto;
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
// 1. Deactivate Rule
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.DEACTIVATE_ACTION);
session.clearCache();
// 2. Assert ActiveRule in DAO
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
}
@Test
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4);
// 1. Deactivate Rule
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_DEACTIVATE_ACTION);
session.clearCache();
// 2. Assert ActiveRule in DAO
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
}
@Test
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2);
// 1. Deactivate Rule
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_DEACTIVATE_ACTION);
session.clearCache();
// 2. Assert ActiveRule in DAO
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
- assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2);
}
@Test
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2);
// 1. Deactivate Rule
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_DEACTIVATE_ACTION);
session.clearCache();
// 2. Assert ActiveRule in DAO
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
}
@Test
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
// 1. Activate Rule
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.ACTIVATE_ACTION);
session.clearCache();
// 2. Assert ActiveRule in DAO
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
}
@Test
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
try {
// 1. Activate Rule
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
// 1. Activate Rule
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.ACTIVATE_ACTION);
// 2. Assert ActiveRule in DAO
ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), rule.getKey());
- assertThat(db.activeRuleDao().getNullableByKey(session, activeRuleKey).getSeverityString())
+ assertThat(db.deprecatedActiveRuleDao().getNullableByKey(session, activeRuleKey).getSeverityString())
.isEqualTo("MINOR");
}
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
// 1. Activate Rule
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION);
session.clearCache();
// 2. Assert ActiveRule in DAO
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4);
}
@Test
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, php.getKey())).isEmpty();
// 1. Activate Rule
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION);
session.clearCache();
// 2. Assert ActiveRule in DAO
- assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2);
}
@Test
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
// 1. Activate Rule with query returning 0 hits
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION);
session.clearCache();
// 2. Assert ActiveRule in DAO
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
// 1. Activate Rule with query returning 1 hits
request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION);
session.commit();
// 2. Assert ActiveRule in DAO
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1);
}
@Test
session.commit();
// 0. Assert No Active Rule for profile
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
- assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty();
+ assertThat(db.deprecatedActiveRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0);
// 2. Assert ActiveRule with BLOCKER severity
assertThat(tester.get(RuleIndex.class).search(
.setSeverity(rule.getSeverityString());
ActiveRuleDto active2 = ActiveRuleDto.createFor(subProfile, rule)
.setSeverity("MINOR");
- db.activeRuleDao().insert(session, active1, active2);
+ db.deprecatedActiveRuleDao().insert(session, active1, active2);
session.commit();
// 0. assert rule child rule is minor
- assertThat(db.activeRuleDao().getByKey(session, active2.getKey()).getSeverityString()).isEqualTo("MINOR");
+ assertThat(db.deprecatedActiveRuleDao().getByKey(session, active2.getKey()).getSeverityString()).isEqualTo("MINOR");
// 1. reset child rule
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.ACTIVATE_ACTION);
session.clearCache();
// 2. assert rule child rule is NOT minor
- assertThat(db.activeRuleDao().getByKey(session, active2.getKey()).getSeverityString()).isNotEqualTo("MINOR");
+ assertThat(db.deprecatedActiveRuleDao().getByKey(session, active2.getKey()).getSeverityString()).isNotEqualTo("MINOR");
}
@Test
private ActiveRuleDto createActiveRule(RuleDto rule, QualityProfileDto profile) {
ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
.setSeverity(rule.getSeverityString());
- db.activeRuleDao().insert(session, activeRule);
+ db.deprecatedActiveRuleDao().insert(session, activeRule);
return activeRule;
}
}
import org.sonar.db.qualitygate.ProjectQgateAssociationDao;
import org.sonar.db.qualitygate.QualityGateConditionDao;
import org.sonar.db.qualitygate.QualityGateDao;
+import org.sonar.db.qualityprofile.ActiveRuleDao;
import org.sonar.db.qualityprofile.QualityProfileDao;
import org.sonar.db.rule.RuleDao;
import org.sonar.db.source.FileSourceDao;
QualityProfileDao.class,
PurgeDao.class,
RuleDao.class,
+ ActiveRuleDao.class,
ResourceIndexDao.class,
ResourceDao.class,
ResourceKeyUpdaterDao.class,
import org.sonar.db.qualitygate.ProjectQgateAssociationDao;
import org.sonar.db.qualitygate.QualityGateConditionDao;
import org.sonar.db.qualitygate.QualityGateDao;
+import org.sonar.db.qualityprofile.ActiveRuleDao;
import org.sonar.db.qualityprofile.QualityProfileDao;
import org.sonar.db.rule.RuleDao;
import org.sonar.db.source.FileSourceDao;
private final MetricDao metricDao;
private final GroupDao groupDao;
private final RuleDao ruleDao;
+ private final ActiveRuleDao activeRuleDao;
public DbClient(Database database, MyBatis myBatis, Dao... daos) {
this.database = database;
metricDao = getDao(map, MetricDao.class);
groupDao = getDao(map, GroupDao.class);
ruleDao = getDao(map, RuleDao.class);
+ activeRuleDao = getDao(map, ActiveRuleDao.class);
doOnLoad(map);
}
return ruleDao;
}
+ public ActiveRuleDao activeRuleDao() {
+ return activeRuleDao;
+ }
+
protected <K extends Dao> K getDao(Map<Class, Dao> map, Class<K> clazz) {
return (K) map.get(clazz);
}
public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new DaoModule().configure(container);
- assertThat(container.size()).isEqualTo(48);
+ assertThat(container.size()).isEqualTo(49);
}
}