From 6e2ed638eeb353c4048575e9ba16c968455d3142 Mon Sep 17 00:00:00 2001 From: Léo Geoffroy <99647462+leo-geoffroy-sonarsource@users.noreply.github.com> Date: Fri, 22 Apr 2022 14:13:59 +0200 Subject: SONAR-16302 adapt RuleDto, RuleDefinitionDto and introduce RuleSectionDescriptionDto to prepare for multiple section support --- .../java/org/sonar/db/rule/RuleTesting.java | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'server/sonar-db-dao/src/testFixtures') diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java index b86f5ddb33d..b544afa6379 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java @@ -32,7 +32,6 @@ import org.sonar.api.server.rule.RuleParamType; import org.sonar.core.util.UuidFactory; import org.sonar.core.util.UuidFactoryFast; import org.sonar.core.util.Uuids; -import org.sonar.db.rule.RuleDto.Format; import org.sonar.db.rule.RuleDto.Scope; import org.sonar.db.user.UserDto; @@ -43,6 +42,7 @@ import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.apache.commons.lang.math.RandomUtils.nextInt; import static org.sonar.api.rule.RuleKey.EXTERNAL_RULE_REPO_PREFIX; +import static org.sonar.db.rule.RuleDescriptionSectionDto.createDefaultRuleDescriptionSection; /** * Utility class for tests involving rules @@ -65,13 +65,22 @@ public class RuleTesting { } public static RuleDefinitionDto newRule(RuleKey key) { + RuleDefinitionDto ruleDefinitionDto = newRuleWithoutSection(key); + ruleDefinitionDto.addRuleDescriptionSectionDto(createDefaultRuleDescriptionSection("description_" + randomAlphabetic(5))); + return ruleDefinitionDto; + } + + public static RuleDefinitionDto newRuleWithoutSection() { + return newRuleWithoutSection(randomRuleKey()); + } + + public static RuleDefinitionDto newRuleWithoutSection(RuleKey ruleKey) { return new RuleDefinitionDto() - .setRepositoryKey(key.repository()) - .setRuleKey(key.rule()) + .setRepositoryKey(ruleKey.repository()) + .setRuleKey(ruleKey.rule()) .setUuid("rule_uuid_" + randomAlphanumeric(5)) .setName("name_" + randomAlphanumeric(5)) - .setDescription("description_" + randomAlphanumeric(5)) - .setDescriptionFormat(Format.HTML) + .setDescriptionFormat(RuleDto.Format.HTML) .setType(RuleType.values()[nextInt(RuleType.values().length)]) .setStatus(RuleStatus.READY) .setConfigKey("configKey_" + randomAlphanumeric(5)) @@ -171,8 +180,8 @@ public class RuleTesting { .setRuleKey(ruleKey.rule()) .setRepositoryKey(ruleKey.repository()) .setName("Rule " + ruleKey.rule()) - .setDescription("Description " + ruleKey.rule()) - .setDescriptionFormat(Format.HTML) + .setDescriptionFormat(RuleDto.Format.HTML) + .addRuleDescriptionSectionDto(createDefaultRuleDescriptionSection("Description" + ruleKey.rule())) .setStatus(RuleStatus.READY) .setConfigKey("InternalKey" + ruleKey.rule()) .setSeverity(Severity.INFO) -- cgit v1.2.3