"key": "how_to_fix",
"content": "<h2>Recommended Secure Coding Practices</h2><ul><li> activate Spring Security's CSRF protection. </li></ul>",
"context": {
- "displayName": "Spring"
+ "displayName": "Spring",
+ "key": "spring"
}
},
{
"key": "how_to_fix",
"content": "<h2>Recommended Secure Coding Practices</h2><ul><li> activate hibernate protection. </li></ul>",
"context": {
- "displayName": "Hibernate"
+ "displayName": "Hibernate",
+ "key": "hibernate"
}
}
],
"key": "how_to_fix",
"content": "<h2>Recommended Secure Coding Practices</h2><ul><li> activate Spring Security's CSRF protection. </li></ul>",
"context": {
- "displayName": "Spring"
+ "displayName": "Spring",
+ "key": "spring"
}
},
{
"key": "how_to_fix",
"content": "<h2>Recommended Secure Coding Practices</h2><ul><li> activate hibernate protection. </li></ul>",
"context": {
- "displayName": "Hibernate"
+ "displayName": "Hibernate",
+ "key": "hibernate"
}
}
],
import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_QPROFILE;
import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_RULE_KEY;
+import static org.sonarqube.ws.Rules.Rule.DescriptionSection.Context.newBuilder;
public class SearchActionTest {
.build();
}
- private static Rule.DescriptionSection toProtobufDto(RuleDescriptionSectionDto s) {
- Rule.DescriptionSection.Builder builder = Rule.DescriptionSection.newBuilder().setKey(s.getKey()).setContent(s.getContent());
- if (s.getContext() != null) {
- builder.setContext(Rule.DescriptionSection.Context.newBuilder().setDisplayName(s.getContext().getDisplayName()).build());
+ private static Rule.DescriptionSection toProtobufDto(RuleDescriptionSectionDto section) {
+ Rule.DescriptionSection.Builder builder = Rule.DescriptionSection.newBuilder().setKey(section.getKey()).setContent(section.getContent());
+ if (section.getContext() != null) {
+ RuleDescriptionSectionContextDto context = section.getContext();
+ builder.setContext(newBuilder().setKey(context.getKey()).setDisplayName(context.getDisplayName()).build());
}
return builder.build();
}
assertThat(resultRule.getMdDesc()).isEqualTo(resultRule.getHtmlDesc());
assertThat(resultRule.getDescriptionSections().getDescriptionSectionsList())
- .extracting(Rule.DescriptionSection::getKey, Rule.DescriptionSection::getContent, section -> section.getContext().getDisplayName())
+ .extracting(Rule.DescriptionSection::getKey, Rule.DescriptionSection::getContent, section -> section.getContext().getKey(), section -> section.getContext().getDisplayName())
.containsExactlyInAnyOrder(
- tuple(ROOT_CAUSE_SECTION_KEY, "<div>Root is Root</div>", ""),
- tuple(ASSESS_THE_PROBLEM_SECTION_KEY, "<div>This is not a problem</div>", ""),
- tuple(HOW_TO_FIX_SECTION_KEY, "<div>I don't want to fix</div>", ""),
- tuple(RESOURCES_SECTION_KEY, "<div>I want to fix with Spring</div>", section4context1.getContext().getDisplayName()),
- tuple(RESOURCES_SECTION_KEY, "<div>I want to fix with Servlet</div>", section4context2.getContext().getDisplayName())
+ tuple(ROOT_CAUSE_SECTION_KEY, "<div>Root is Root</div>", "", ""),
+ tuple(ASSESS_THE_PROBLEM_SECTION_KEY, "<div>This is not a problem</div>", "", ""),
+ tuple(HOW_TO_FIX_SECTION_KEY, "<div>I don't want to fix</div>", "", ""),
+ tuple(RESOURCES_SECTION_KEY, "<div>I want to fix with Spring</div>", section4context1.getContext().getKey(), section4context1.getContext().getDisplayName()),
+ tuple(RESOURCES_SECTION_KEY, "<div>I want to fix with Servlet</div>", section4context2.getContext().getKey(), section4context2.getContext().getDisplayName())
);
}