diff options
author | Matteo Mara <matteo.mara@sonarsource.com> | 2022-03-22 17:39:03 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-03-23 20:02:45 +0000 |
commit | f6a29b92cafe474d5ea62619aef7d7ffa6453d96 (patch) | |
tree | ee8ff747855758cef3366f9cab1835eae2b00e63 /server/sonar-webserver-es | |
parent | 15bf48aa6f306d9185bfeda978e37811dbf771ff (diff) | |
download | sonarqube-f6a29b92cafe474d5ea62619aef7d7ffa6453d96.tar.gz sonarqube-f6a29b92cafe474d5ea62619aef7d7ffa6453d96.zip |
SONAR-16129 Handle Owasp Top 10 2021 facet ordering
Diffstat (limited to 'server/sonar-webserver-es')
-rw-r--r-- | server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFacetsTest.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFacetsTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFacetsTest.java index 02bb642ca0a..16585ecd707 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFacetsTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFacetsTest.java @@ -20,6 +20,7 @@ package org.sonar.server.issue.index; import java.time.ZoneId; +import java.util.Collections; import java.util.Date; import java.util.Map; import java.util.TimeZone; @@ -64,6 +65,8 @@ import static org.sonar.api.rule.Severity.CRITICAL; import static org.sonar.api.rule.Severity.INFO; import static org.sonar.api.rule.Severity.MAJOR; import static org.sonar.api.rule.Severity.MINOR; +import static org.sonar.api.server.rule.RulesDefinition.OwaspTop10Version.Y2017; +import static org.sonar.api.server.rule.RulesDefinition.OwaspTop10Version.Y2021; import static org.sonar.api.utils.DateUtils.parseDateTime; import static org.sonar.db.component.ComponentTesting.newDirectory; import static org.sonar.db.component.ComponentTesting.newFileDto; @@ -194,7 +197,39 @@ public class IssueIndexFacetsTest { newDoc("I2", file).setType(RuleType.VULNERABILITY).setOwaspTop10(singletonList("a3")), newDoc("I3", file)); - assertThatFacetHasOnly(IssueQuery.builder(), "owaspTop10", + assertThatFacetHasOnly(IssueQuery.builder(), Y2017.prefix(), + entry("a1", 1L), + entry("a2", 1L), + entry("a3", 1L)); + } + + @Test + public void facets_on_owaspTop10_2021() { + ComponentDto project = newPrivateProjectDto(); + ComponentDto file = newFileDto(project, null); + + indexIssues( + newDoc("I1", file).setType(RuleType.VULNERABILITY).setOwaspTop10For2021(asList("a1", "a2")), + newDoc("I2", file).setType(RuleType.VULNERABILITY).setOwaspTop10For2021(singletonList("a3")), + newDoc("I3", file)); + + assertThatFacetHasExactly(IssueQuery.builder(), Y2021.prefix(), + entry("a1", 1L), + entry("a2", 1L), + entry("a3", 1L)); + } + + @Test + public void facets_on_owaspTop10_2021_stay_ordered() { + ComponentDto project = newPrivateProjectDto(); + ComponentDto file = newFileDto(project, null); + + indexIssues( + newDoc("I1", file).setType(RuleType.VULNERABILITY).setOwaspTop10For2021(asList("a1", "a2")), + newDoc("I2", file).setType(RuleType.VULNERABILITY).setOwaspTop10For2021(singletonList("a3")), + newDoc("I3", file)); + + assertThatFacetHasExactly(IssueQuery.builder().owaspTop10For2021(Collections.singletonList("a3")), Y2021.prefix(), entry("a1", 1L), entry("a2", 1L), entry("a3", 1L)); |