diff options
author | lukasz-jarocki-sonarsource <lukasz.jarocki@sonarsource.com> | 2023-08-21 16:37:34 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-08-22 20:03:05 +0000 |
commit | d4c3bbb1e8303d87260fc046841a84483711b7d3 (patch) | |
tree | 06d5d89461591281193c77f6496da449de25691a /server/sonar-db-dao/src/test | |
parent | 04fc6db186342232be36c9f1b682ed218e210f9f (diff) | |
download | sonarqube-d4c3bbb1e8303d87260fc046841a84483711b7d3.tar.gz sonarqube-d4c3bbb1e8303d87260fc046841a84483711b7d3.zip |
SONAR-20198 Added rules data to elasticsearch indexes
Diffstat (limited to 'server/sonar-db-dao/src/test')
-rw-r--r-- | server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleForIndexingDtoTest.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleForIndexingDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleForIndexingDtoTest.java new file mode 100644 index 00000000000..995b26d195b --- /dev/null +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleForIndexingDtoTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.rule; + +import java.util.List; +import org.junit.Test; +import org.sonar.api.issue.impact.Severity; +import org.sonar.api.issue.impact.SoftwareQuality; +import org.sonar.api.rules.CleanCodeAttribute; +import org.sonar.api.rules.CleanCodeAttributeCategory; +import org.sonar.db.issue.ImpactDto; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RuleForIndexingDtoTest { + + @Test + public void fromRuleDto_whenCleanCodeAttributeSet_setCleanCodeCategory() { + RuleDto ruleDto = RuleTesting.newRuleWithoutDescriptionSection(); + ruleDto.setCleanCodeAttribute(CleanCodeAttribute.FOCUSED); + ImpactDto impactDto = new ImpactDto().setSeverity(Severity.HIGH).setSoftwareQuality(SoftwareQuality.SECURITY); + ruleDto.replaceAllDefaultImpacts(List.of(impactDto)); + + RuleForIndexingDto ruleForIndexingDto = RuleForIndexingDto.fromRuleDto(ruleDto); + + assertThat(ruleForIndexingDto.getCleanCodeAttributeCategory()).isEqualTo(CleanCodeAttributeCategory.ADAPTABLE.name()); + ImpactDto impact = ruleForIndexingDto.getImpacts().iterator().next(); + + assertThat(impact.getSeverity()).isEqualTo(Severity.HIGH); + assertThat(impact.getSoftwareQuality()).isEqualTo(SoftwareQuality.SECURITY); + } + +}
\ No newline at end of file |