use of org.sonar.server.qualityprofile.RuleActivation in project sonarqube by SonarSource.
the class RegisterRulesMediumTest method do_not_deactivate_removed_rules_if_repository_accidentally_uninstalled.
@Test
public void do_not_deactivate_removed_rules_if_repository_accidentally_uninstalled() {
Rules rules = new Rules() {
@Override
public void init(RulesDefinition.NewRepository repository) {
repository.createRule("x1").setName("x1 name").setHtmlDescription("x1 desc");
}
};
register(rules);
// create a profile and activate rule
logInAsQProfileAdministrator();
db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"));
dbSession.commit();
dbSession.clearCache();
RuleActivation activation = new RuleActivation(RuleTesting.XOO_X1);
TESTER.get(QProfileService.class).activate(QProfileTesting.XOO_P1_KEY, activation);
// Restart without xoo
register(null);
dbSession.commit();
dbSession.clearCache();
assertThat(ruleIndex.search(new RuleQuery().setKey(RuleTesting.XOO_X1.toString()), new SearchOptions()).getTotal()).isEqualTo(0);
assertThat(db.activeRuleDao().selectByProfileKey(dbSession, QProfileTesting.XOO_P1_KEY)).isEmpty();
// Re-install
register(rules);
assertThat(ruleIndex.search(new RuleQuery().setKey(RuleTesting.XOO_X1.toString()), new SearchOptions()).getTotal()).isEqualTo(1);
assertThat(db.activeRuleDao().selectByProfileKey(dbSession, QProfileTesting.XOO_P1_KEY)).hasSize(1);
}
Aggregations