use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class ClearRulesOverloadedDebtTest method verifyRuleHasNotOverriddenDebt.
private void verifyRuleHasNotOverriddenDebt(RuleKey ruleKey) {
// Refresh session
dbSession.commit(true);
RuleDto ruleDto = ruleDao.selectOrFailByKey(dbSession, ruleKey);
assertThat(ruleDto.getRemediationFunction()).isNull();
assertThat(ruleDto.getRemediationGapMultiplier()).isNull();
assertThat(ruleDto.getRemediationBaseEffort()).isNull();
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class ShowActionMediumTest method show_rule.
@Test
public void show_rule() throws Exception {
RuleDto ruleDto = RuleTesting.newDto(RuleKey.of("java", "S001")).setName("Rule S001").setDescription("Rule S001 <b>description</b>").setDescriptionFormat(Format.HTML).setSeverity(MINOR).setStatus(RuleStatus.BETA).setConfigKey("InternalKeyS001").setLanguage("xoo").setTags(newHashSet("tag1", "tag2")).setSystemTags(newHashSet("systag1", "systag2")).setType(RuleType.BUG);
ruleDao.insert(session, ruleDto);
RuleParamDto param = RuleParamDto.createFor(ruleDto).setName("regex").setType("STRING").setDescription("Reg *exp*").setDefaultValue(".*");
ruleDao.insertRuleParam(session, ruleDto, param);
session.commit();
session.clearCache();
WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show").setParam("key", ruleDto.getKey().toString());
request.execute().assertJson(getClass(), "show_rule.json");
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class ShowActionMediumTest method show_rule_with_default_and_overridden_debt_infos.
@Test
public void show_rule_with_default_and_overridden_debt_infos() throws Exception {
RuleDto ruleDto = RuleTesting.newDto(RuleKey.of("java", "S001")).setName("Rule S001").setDescription("Rule S001 <b>description</b>").setSeverity(MINOR).setStatus(RuleStatus.BETA).setConfigKey("InternalKeyS001").setLanguage("xoo").setDefaultRemediationFunction("LINEAR").setDefaultRemediationGapMultiplier("5min").setDefaultRemediationBaseEffort(null).setRemediationFunction("LINEAR_OFFSET").setRemediationGapMultiplier("5d").setRemediationBaseEffort("10h");
ruleDao.insert(session, ruleDto);
session.commit();
session.clearCache();
WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show").setParam("key", ruleDto.getKey().toString());
request.execute().assertJson(getClass(), "show_rule_with_default_and_overridden_debt_infos.json");
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class ShowActionMediumTest method encode_html_description_of_custom_rule.
@Test
public void encode_html_description_of_custom_rule() throws Exception {
// Template rule
RuleDto templateRule = RuleTesting.newTemplateRule(RuleKey.of("java", "S001"));
ruleDao.insert(session, templateRule);
session.commit();
// Custom rule
NewCustomRule customRule = NewCustomRule.createForCustomRule("MY_CUSTOM", templateRule.getKey()).setName("My custom").setSeverity(MINOR).setStatus(RuleStatus.READY).setMarkdownDescription("<div>line1\nline2</div>");
RuleKey customRuleKey = tester.get(RuleCreator.class).create(customRule);
session.clearCache();
WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show").setParam("key", customRuleKey.toString());
request.execute().assertJson(getClass(), "encode_html_description_of_custom_rule.json");
}
use of org.sonar.db.rule.RuleDto in project sonarqube by SonarSource.
the class IssueDbTester method insertIssue.
public IssueDto insertIssue() {
RuleDto rule = db.rules().insertRule(newRuleDto());
ComponentDto project = db.components().insertProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
return insertIssue(newDto(rule, file, project));
}
Aggregations