use of org.sonar.server.qualityprofile.index.ActiveRuleIndex in project sonarqube by SonarSource.
the class RuleActivatorMediumTest method before.
@Before
public void before() {
tester.clearDbAndIndexes();
db = tester.get(DbClient.class);
dbSession = db.openSession(false);
ruleActivator = tester.get(RuleActivator.class);
activeRuleIndex = tester.get(ActiveRuleIndex.class);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
ruleIndexer = tester.get(RuleIndexer.class);
// create pre-defined rules
RuleDto javaRule = newDto(RuleKey.of("squid", "j1")).setSeverity("MAJOR").setLanguage("java");
RuleDto xooRule1 = newXooX1().setSeverity("MINOR");
RuleDto xooRule2 = newXooX2().setSeverity("INFO");
RuleDto xooTemplateRule1 = newTemplateRule(TEMPLATE_RULE_KEY).setSeverity("MINOR").setLanguage("xoo");
db.ruleDao().insert(dbSession, javaRule);
db.ruleDao().insert(dbSession, xooRule1);
db.ruleDao().insert(dbSession, xooRule2);
db.ruleDao().insert(dbSession, xooTemplateRule1);
db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1).setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type()));
db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1).setName("min").setType(RuleParamType.INTEGER.type()));
db.ruleDao().insertRuleParam(dbSession, xooTemplateRule1, RuleParamDto.createFor(xooTemplateRule1).setName("format").setType(RuleParamType.STRING.type()));
RuleDto xooCustomRule1 = newCustomRule(xooTemplateRule1).setRuleKey(CUSTOM_RULE_KEY.rule()).setSeverity("MINOR").setLanguage("xoo");
db.ruleDao().insert(dbSession, xooCustomRule1);
db.ruleDao().insertRuleParam(dbSession, xooCustomRule1, RuleParamDto.createFor(xooTemplateRule1).setName("format").setDefaultValue("txt").setType(RuleParamType.STRING.type()));
// create pre-defined profile P1
profileDto = QProfileTesting.newXooP1("org-123");
db.qualityProfileDao().insert(dbSession, profileDto);
dbSession.commit();
dbSession.clearCache();
ruleIndexer.index();
}
Aggregations