use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class CompareActionMediumTest method compare_param_on_right.
@Test
public void compare_param_on_right() throws Exception {
RuleDto rule1 = createRuleWithParam("xoo", "rule1");
createRepository("blah", "xoo", "Blah");
QualityProfileDto profile1 = createProfile("xoo", "Profile 1", "xoo-profile-1-01234");
createActiveRule(rule1, profile1);
QualityProfileDto profile2 = createProfile("xoo", "Profile 2", "xoo-profile-2-12345");
createActiveRuleWithParam(rule1, profile2, "polop");
session.commit();
wsTester.newGetRequest("api/qualityprofiles", "compare").setParam("leftKey", profile1.getKey()).setParam("rightKey", profile2.getKey()).execute().assertJson(this.getClass(), "compare_param_on_right.json");
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class CompareActionMediumTest method compare_param_on_left.
@Test
public void compare_param_on_left() throws Exception {
RuleDto rule1 = createRuleWithParam("xoo", "rule1");
createRepository("blah", "xoo", "Blah");
QualityProfileDto profile1 = createProfile("xoo", "Profile 1", "xoo-profile-1-01234");
createActiveRuleWithParam(rule1, profile1, "polop");
QualityProfileDto profile2 = createProfile("xoo", "Profile 2", "xoo-profile-2-12345");
createActiveRule(rule1, profile2);
session.commit();
wsTester.newGetRequest("api/qualityprofiles", "compare").setParam("leftKey", profile1.getKey()).setParam("rightKey", profile2.getKey()).execute().assertJson(this.getClass(), "compare_param_on_left.json");
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class CompareActionMediumTest method compare_nominal.
@Test
public void compare_nominal() throws Exception {
createRepository("blah", "xoo", "Blah");
RuleDto rule1 = createRule("xoo", "rule1");
RuleDto rule2 = createRule("xoo", "rule2");
RuleDto rule3 = createRule("xoo", "rule3");
RuleDto rule4 = createRuleWithParam("xoo", "rule4");
RuleDto rule5 = createRule("xoo", "rule5");
/*
* Profile 1:
* - rule 1 active (on both profiles) => "same"
* - rule 2 active (only in this profile) => "inLeft"
* - rule 4 active with different parameters => "modified"
* - rule 5 active with different severity => "modified"
*/
QualityProfileDto profile1 = createProfile("xoo", "Profile 1", "xoo-profile-1-01234");
createActiveRule(rule1, profile1);
createActiveRule(rule2, profile1);
createActiveRuleWithParam(rule4, profile1, "polop");
createActiveRuleWithSeverity(rule5, profile1, Severity.MINOR);
session.commit();
/*
* Profile 1:
* - rule 1 active (on both profiles) => "same"
* - rule 3 active (only in this profile) => "inRight"
* - rule 4 active with different parameters => "modified"
*/
QualityProfileDto profile2 = createProfile("xoo", "Profile 2", "xoo-profile-2-12345");
createActiveRule(rule1, profile2);
createActiveRule(rule3, profile2);
createActiveRuleWithParam(rule4, profile2, "palap");
createActiveRuleWithSeverity(rule5, profile2, Severity.MAJOR);
session.commit();
wsTester.newGetRequest("api/qualityprofiles", "compare").setParam("leftKey", profile1.getKey()).setParam("rightKey", profile2.getKey()).execute().assertJson(this.getClass(), "compare_nominal.json");
}
use of org.sonar.db.rule.RuleDto 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();
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class InheritanceActionMediumTest method createRule.
private RuleDto createRule(String lang, String id) {
long now = new Date().getTime();
RuleDto rule = RuleTesting.newDto(RuleKey.of("blah", id)).setLanguage(lang).setSeverity(Severity.BLOCKER).setStatus(RuleStatus.READY).setUpdatedAt(now).setCreatedAt(now);
db.ruleDao().insert(session, rule);
return rule;
}
Aggregations