Search in sources :

Example 1 with RuleIndexer

use of org.sonar.server.rule.index.RuleIndexer 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();
}
Also used : ActiveRuleIndexer(org.sonar.server.qualityprofile.index.ActiveRuleIndexer) ActiveRuleIndex(org.sonar.server.qualityprofile.index.ActiveRuleIndex) DbClient(org.sonar.db.DbClient) ActiveRuleDto(org.sonar.db.qualityprofile.ActiveRuleDto) RuleDto(org.sonar.db.rule.RuleDto) ActiveRuleIndexer(org.sonar.server.qualityprofile.index.ActiveRuleIndexer) RuleIndexer(org.sonar.server.rule.index.RuleIndexer) Before(org.junit.Before)

Example 2 with RuleIndexer

use of org.sonar.server.rule.index.RuleIndexer in project sonarqube by SonarSource.

the class QProfileCopierMediumTest method before.

@Before
public void before() {
    tester.clearDbAndIndexes();
    db = tester.get(DbClient.class);
    dbSession = db.openSession(false);
    ruleActivator = tester.get(RuleActivator.class);
    index = tester.get(ActiveRuleIndex.class);
    copier = tester.get(QProfileCopier.class);
    ruleIndexer = tester.get(RuleIndexer.class);
    activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
    // create pre-defined rules
    RuleDto xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR");
    RuleDto xooRule2 = RuleTesting.newXooX2().setSeverity("MAJOR");
    db.ruleDao().insert(dbSession, xooRule1);
    db.ruleDao().insert(dbSession, xooRule2);
    db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1).setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type()));
    // create pre-defined profile
    db.qualityProfileDao().insert(dbSession, QProfileTesting.newXooP1("org-123"));
    dbSession.commit();
    dbSession.clearCache();
    ruleIndexer.index();
}
Also used : ActiveRuleIndexer(org.sonar.server.qualityprofile.index.ActiveRuleIndexer) ActiveRuleIndex(org.sonar.server.qualityprofile.index.ActiveRuleIndex) DbClient(org.sonar.db.DbClient) ActiveRuleDto(org.sonar.db.qualityprofile.ActiveRuleDto) RuleDto(org.sonar.db.rule.RuleDto) ActiveRuleIndexer(org.sonar.server.qualityprofile.index.ActiveRuleIndexer) RuleIndexer(org.sonar.server.rule.index.RuleIndexer) Before(org.junit.Before)

Example 3 with RuleIndexer

use of org.sonar.server.rule.index.RuleIndexer in project sonarqube by SonarSource.

the class QProfileBackuperMediumTest method before.

@Before
public void before() {
    tester.clearDbAndIndexes();
    db = tester.get(DbClient.class);
    dbSession = db.openSession(false);
    ruleIndexer = tester.get(RuleIndexer.class);
    activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
    // create pre-defined rules
    RuleDto xooRule1 = newXooX1().setSeverity("MINOR").setLanguage("xoo");
    RuleDto xooRule2 = newXooX2().setSeverity("MAJOR").setLanguage("xoo");
    db.ruleDao().insert(dbSession, xooRule1);
    db.ruleDao().insert(dbSession, xooRule2);
    db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1).setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type()));
    dbSession.commit();
    dbSession.clearCache();
    ruleIndexer.index();
}
Also used : ActiveRuleIndexer(org.sonar.server.qualityprofile.index.ActiveRuleIndexer) DbClient(org.sonar.db.DbClient) ActiveRuleDto(org.sonar.db.qualityprofile.ActiveRuleDto) RuleDto(org.sonar.db.rule.RuleDto) ActiveRuleIndexer(org.sonar.server.qualityprofile.index.ActiveRuleIndexer) RuleIndexer(org.sonar.server.rule.index.RuleIndexer) Before(org.junit.Before)

Example 4 with RuleIndexer

use of org.sonar.server.rule.index.RuleIndexer in project sonarqube by SonarSource.

the class InheritanceActionMediumTest method setUp.

@Before
public void setUp() {
    tester.clearDbAndIndexes();
    db = tester.get(DbClient.class);
    session = db.openSession(false);
    ruleIndexer = tester.get(RuleIndexer.class);
    activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
    wsTester = new WsTester(tester.get(QProfilesWs.class));
}
Also used : ActiveRuleIndexer(org.sonar.server.qualityprofile.index.ActiveRuleIndexer) DbClient(org.sonar.db.DbClient) WsTester(org.sonar.server.ws.WsTester) ActiveRuleIndexer(org.sonar.server.qualityprofile.index.ActiveRuleIndexer) RuleIndexer(org.sonar.server.rule.index.RuleIndexer) Before(org.junit.Before)

Example 5 with RuleIndexer

use of org.sonar.server.rule.index.RuleIndexer in project sonarqube by SonarSource.

the class ActiveRuleIndexTest method setUp.

@Before
public void setUp() {
    activeRuleIndexer = new ActiveRuleIndexer(system2, null, tester.client());
    ruleIndexer = new RuleIndexer(system2, null, tester.client());
    index = new ActiveRuleIndex(tester.client());
}
Also used : RuleIndexer(org.sonar.server.rule.index.RuleIndexer) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)6 RuleIndexer (org.sonar.server.rule.index.RuleIndexer)6 ActiveRuleIndexer (org.sonar.server.qualityprofile.index.ActiveRuleIndexer)5 DbClient (org.sonar.db.DbClient)4 ActiveRuleDto (org.sonar.db.qualityprofile.ActiveRuleDto)3 RuleDto (org.sonar.db.rule.RuleDto)3 ActiveRuleIndex (org.sonar.server.qualityprofile.index.ActiveRuleIndex)2 RuleIndex (org.sonar.server.rule.index.RuleIndex)1 WsTester (org.sonar.server.ws.WsTester)1