|
|
@@ -27,6 +27,7 @@ import org.sonar.db.rule.RuleDto; |
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.sonar.api.server.rule.RuleDescriptionSection.RuleDescriptionSectionKeys.ASSESS_THE_PROBLEM_SECTION_KEY; |
|
|
|
import static org.sonar.api.server.rule.RuleDescriptionSection.RuleDescriptionSectionKeys.HOW_TO_FIX_SECTION_KEY; |
|
|
|
import static org.sonar.api.server.rule.RuleDescriptionSection.RuleDescriptionSectionKeys.INTRODUCTION_SECTION_KEY; |
|
|
|
import static org.sonar.api.server.rule.RuleDescriptionSection.RuleDescriptionSectionKeys.ROOT_CAUSE_SECTION_KEY; |
|
|
|
import static org.sonar.db.rule.RuleDescriptionSectionDto.createDefaultRuleDescriptionSection; |
|
|
|
|
|
|
@@ -55,15 +56,18 @@ public class RuleDescriptionFormatterTest { |
|
|
|
var section1 = createRuleDescriptionSection(ROOT_CAUSE_SECTION_KEY, "<div>Root is Root</div>"); |
|
|
|
var section2 = createRuleDescriptionSection(ASSESS_THE_PROBLEM_SECTION_KEY, "<div>This is not a problem</div>"); |
|
|
|
var section3 = createRuleDescriptionSection(HOW_TO_FIX_SECTION_KEY, "<div>I don't want to fix</div>"); |
|
|
|
var section4 = createRuleDescriptionSection(INTRODUCTION_SECTION_KEY, "<div>Introduction with no title</div>"); |
|
|
|
RuleDto rule = new RuleDto().setDescriptionFormat(RuleDto.Format.HTML) |
|
|
|
.setType(RuleType.SECURITY_HOTSPOT) |
|
|
|
.addRuleDescriptionSectionDto(section1) |
|
|
|
.addRuleDescriptionSectionDto(section2) |
|
|
|
.addRuleDescriptionSectionDto(section3); |
|
|
|
.addRuleDescriptionSectionDto(section3) |
|
|
|
.addRuleDescriptionSectionDto(section4); |
|
|
|
String html = ruleDescriptionFormatter.getDescriptionAsHtml(rule); |
|
|
|
assertThat(html) |
|
|
|
.contains( |
|
|
|
"<h2>What is the risk?</h2>" |
|
|
|
"<div>Introduction with no title</div><br/>" |
|
|
|
+ "<h2>What is the risk?</h2>" |
|
|
|
+ "<div>Root is Root</div><br/>" |
|
|
|
+ "<h2>Assess the risk</h2>" |
|
|
|
+ "<div>This is not a problem</div><br/>" |