diff options
author | Aurelien Poscia <aurelien.poscia@sonarsource.com> | 2022-04-23 14:21:23 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-05-06 20:02:43 +0000 |
commit | c333b3ae6984bf1b402d3398fa71de7f0a75b817 (patch) | |
tree | 7f7746ef734959e0c73c94b405fb1dec7d93eb0c /server/sonar-webserver-core/src | |
parent | c063d9205ddfbca5ebd6136e1506d8dc6974ff35 (diff) | |
download | sonarqube-c333b3ae6984bf1b402d3398fa71de7f0a75b817.tar.gz sonarqube-c333b3ae6984bf1b402d3398fa71de7f0a75b817.zip |
SONAR-16302 persist and fetch rules with new DB structure
Diffstat (limited to 'server/sonar-webserver-core/src')
-rw-r--r-- | server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java | 12 | ||||
-rw-r--r-- | server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java index fb4e08ec15a..5540f8f376c 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -401,10 +401,10 @@ public class RegisterRules implements Startable { .setCreatedAt(system2.now()) .setUpdatedAt(system2.now()); if (isNotEmpty(ruleDef.htmlDescription())) { - ruleDto.addRuleDescriptionSectionDto(createDefaultRuleDescriptionSection(ruleDef.htmlDescription())); + ruleDto.addRuleDescriptionSectionDto(createDefaultRuleDescriptionSection(uuidFactory.create(), ruleDef.htmlDescription())); ruleDto.setDescriptionFormat(Format.HTML); } else if (isNotEmpty(ruleDef.markdownDescription())) { - ruleDto.addRuleDescriptionSectionDto(createDefaultRuleDescriptionSection(ruleDef.markdownDescription())); + ruleDto.addRuleDescriptionSectionDto(createDefaultRuleDescriptionSection(uuidFactory.create(), ruleDef.markdownDescription())); ruleDto.setDescriptionFormat(Format.MARKDOWN); } @@ -433,7 +433,7 @@ public class RegisterRules implements Startable { } } - private static boolean mergeRule(RulesDefinition.Rule def, RuleDefinitionDto dto) { + private boolean mergeRule(RulesDefinition.Rule def, RuleDefinitionDto dto) { boolean changed = false; if (!Objects.equals(dto.getName(), def.name())) { dto.setName(def.name()); @@ -484,16 +484,16 @@ public class RegisterRules implements Startable { return changed; } - private static boolean mergeDescription(RulesDefinition.Rule rule, RuleDefinitionDto ruleDefinitionDto) { + private boolean mergeDescription(RulesDefinition.Rule rule, RuleDefinitionDto ruleDefinitionDto) { boolean changed = false; String currentDescription = ruleDefinitionDto.getDefaultRuleDescriptionSectionDto() != null ? ruleDefinitionDto.getDefaultRuleDescriptionSectionDto().getDescription() : null; if (isHtmlDescriptionUpdated(rule, currentDescription)) { - ruleDefinitionDto.addOrReplaceRuleDescriptionSectionDto(createDefaultRuleDescriptionSection(rule.htmlDescription())); + ruleDefinitionDto.addOrReplaceRuleDescriptionSectionDto(createDefaultRuleDescriptionSection(uuidFactory.create(), rule.htmlDescription())); ruleDefinitionDto.setDescriptionFormat(Format.HTML); changed = true; } else if (isMarkdownDescriptionUpdated(rule, currentDescription)) { - ruleDefinitionDto.addOrReplaceRuleDescriptionSectionDto(createDefaultRuleDescriptionSection(rule.markdownDescription())); + ruleDefinitionDto.addOrReplaceRuleDescriptionSectionDto(createDefaultRuleDescriptionSection(uuidFactory.create(), rule.markdownDescription())); ruleDefinitionDto.setDescriptionFormat(Format.MARKDOWN); changed = true; } diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java index e9cbb4ebbc7..34d1c8deaad 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java @@ -836,7 +836,7 @@ public class RegisterRulesTest { .setRepositoryKey("findbugs") .setName("Rule One") .setScope(Scope.ALL) - .addRuleDescriptionSectionDto(createDefaultRuleDescriptionSection("Rule one description")) + .addRuleDescriptionSectionDto(createDefaultRuleDescriptionSection(uuidFactory.create(), "Rule one description")) .setDescriptionFormat(RuleDto.Format.HTML) .setSystemTags(newHashSet("tag1", "tag2"))); db.getSession().commit(); |