From: DDMili <130993898+dejan-milisavljevic-sonarsource@users.noreply.github.com> Date: Fri, 31 May 2024 07:54:16 +0000 (+0200) Subject: SONAR-22224 Add prioritizedRule to issue/search api X-Git-Tag: 10.6.0.92116~69 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5f96967d771ff120340a5562acddbe03bcb61185;p=sonarqube.git SONAR-22224 Add prioritizedRule to issue/search api --- diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/PrioritizedRulesFeature.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/PrioritizedRulesFeature.java new file mode 100644 index 00000000000..7b35d5c4ff9 --- /dev/null +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/PrioritizedRulesFeature.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 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.server.issue; + +import org.sonar.api.SonarRuntime; +import org.sonar.api.ce.ComputeEngineSide; +import org.sonar.api.server.ServerSide; +import org.sonar.server.feature.SonarQubeFeature; + +import static org.sonar.api.SonarEdition.DATACENTER; +import static org.sonar.api.SonarEdition.ENTERPRISE; + +@ServerSide +@ComputeEngineSide +public class PrioritizedRulesFeature implements SonarQubeFeature { + + private final SonarRuntime sonarRuntime; + + public PrioritizedRulesFeature (SonarRuntime sonarRuntime) { + this.sonarRuntime = sonarRuntime; + } + + @Override + public String getName() { + return "prioritized-rules"; + } + + @Override + public boolean isAvailable() { + return sonarRuntime.getEdition() == ENTERPRISE || sonarRuntime.getEdition() == DATACENTER; + } + +} diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/SearchRequest.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/SearchRequest.java index 1fde6968035..543e2f225d6 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/SearchRequest.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/SearchRequest.java @@ -57,6 +57,7 @@ public class SearchRequest { private List projectKeys; private List resolutions; private Boolean resolved; + private Boolean prioritizedRule; private List rules; private String sort; private List severities; @@ -305,6 +306,16 @@ public class SearchRequest { return this; } + @CheckForNull + public Boolean getPrioritizedRule() { + return prioritizedRule; + } + + public SearchRequest setPrioritizedRule(@Nullable Boolean prioritizedRule) { + this.prioritizedRule = prioritizedRule; + return this; + } + @CheckForNull public List getRules() { return rules; diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/PrioritizedRulesFeatureTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/PrioritizedRulesFeatureTest.java new file mode 100644 index 00000000000..77afb3ed3cf --- /dev/null +++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/PrioritizedRulesFeatureTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 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.server.issue; + +import org.junit.jupiter.api.Test; +import org.sonar.api.SonarEdition; +import org.sonar.api.SonarRuntime; + +import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +class PrioritizedRulesFeatureTest { + SonarRuntime sonarRuntime = mock(); + private final PrioritizedRulesFeature underTest = new PrioritizedRulesFeature(sonarRuntime); + + @Test + void isAvailable_shouldOnlyBeEnabledInEnterpriseEditionPlus() { + testForEdition(SonarEdition.COMMUNITY, false); + testForEdition(SonarEdition.DEVELOPER, false); + testForEdition(SonarEdition.ENTERPRISE, true); + testForEdition(SonarEdition.DATACENTER, true); + } + + private void testForEdition(SonarEdition edition, boolean expectedResult) { + doReturn(edition).when(sonarRuntime).getEdition(); + assertThat(underTest.isAvailable()).isEqualTo(expectedResult); + } + + @Test + void getName_ShouldReturn_Announcement() { + assertEquals("prioritized-rules", underTest.getName()); + } + +} diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java index ca890e63e49..e2230d914c0 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java @@ -39,6 +39,7 @@ import java.util.stream.IntStream; import java.util.stream.Stream; import javax.annotation.CheckForNull; import javax.annotation.Nullable; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.lucene.search.join.ScoreMode; import org.elasticsearch.action.search.SearchRequest; @@ -140,6 +141,7 @@ import static org.sonar.server.issue.index.IssueIndex.Facet.OWASP_TOP_10; import static org.sonar.server.issue.index.IssueIndex.Facet.OWASP_TOP_10_2021; import static org.sonar.server.issue.index.IssueIndex.Facet.PCI_DSS_32; import static org.sonar.server.issue.index.IssueIndex.Facet.PCI_DSS_40; +import static org.sonar.server.issue.index.IssueIndex.Facet.PRIORITIZED_RULE; import static org.sonar.server.issue.index.IssueIndex.Facet.PROJECT_UUIDS; import static org.sonar.server.issue.index.IssueIndex.Facet.RESOLUTIONS; import static org.sonar.server.issue.index.IssueIndex.Facet.RULES; @@ -189,6 +191,7 @@ import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_STAT import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_TAGS; import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_TYPE; import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_VULNERABILITY_PROBABILITY; +import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_PRIORITIZED_RULE; import static org.sonar.server.issue.index.IssueIndexDefinition.TYPE_ISSUE; import static org.sonar.server.security.SecurityReviewRating.computePercent; import static org.sonar.server.security.SecurityReviewRating.computeRating; @@ -213,6 +216,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_OWASP_TOP_1 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_OWASP_TOP_10_2021; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PCI_DSS_32; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PCI_DSS_40; +import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PRIORITIZED_RULE; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RESOLUTIONS; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RULES; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SANS_TOP_25; @@ -288,7 +292,8 @@ public class IssueIndex { CWE(PARAM_CWE, FIELD_ISSUE_CWE, STICKY, DEFAULT_FACET_SIZE), CREATED_AT(PARAM_CREATED_AT, FIELD_ISSUE_FUNC_CREATED_AT, NON_STICKY), SONARSOURCE_SECURITY(PARAM_SONARSOURCE_SECURITY, FIELD_ISSUE_SQ_SECURITY_CATEGORY, STICKY, DEFAULT_FACET_SIZE), - CODE_VARIANTS(PARAM_CODE_VARIANTS, FIELD_ISSUE_CODE_VARIANTS, STICKY, MAX_FACET_SIZE); + CODE_VARIANTS(PARAM_CODE_VARIANTS, FIELD_ISSUE_CODE_VARIANTS, STICKY, MAX_FACET_SIZE), + PRIORITIZED_RULE(PARAM_PRIORITIZED_RULE, FIELD_PRIORITIZED_RULE, STICKY, 2); private final String name; private final TopAggregationDefinition topAggregation; @@ -488,6 +493,7 @@ public class IssueIndex { filters.addFilter(FIELD_ISSUE_STATUS, STATUSES.getFilterScope(), createTermsFilter(FIELD_ISSUE_STATUS, query.statuses())); filters.addFilter(FIELD_ISSUE_NEW_STATUS, ISSUE_STATUSES.getFilterScope(), createTermsFilter(FIELD_ISSUE_NEW_STATUS, query.issueStatuses())); filters.addFilter(FIELD_ISSUE_CODE_VARIANTS, CODE_VARIANTS.getFilterScope(), createTermsFilter(FIELD_ISSUE_CODE_VARIANTS, query.codeVariants())); + filters.addFilter(FIELD_PRIORITIZED_RULE, PRIORITIZED_RULE.getFilterScope(), createTermFilter(FIELD_PRIORITIZED_RULE, query.prioritizedRule())); // security category addSecurityCategoryPrefixFilter(FIELD_ISSUE_PCI_DSS_32, PCI_DSS_32, query.pciDss32(), filters); @@ -764,6 +770,11 @@ public class IssueIndex { return value == null ? null : termQuery(field, value); } + @CheckForNull + private static QueryBuilder createTermFilter(String field, @Nullable Boolean value) { + return value == null ? null : termQuery(field, value); + } + private static QueryBuilder createPrefixFilter(String field, String value) { return prefixQuery(field, value); } @@ -870,6 +881,7 @@ public class IssueIndex { addFacetIfNeeded(options, aggregationHelper, esRequest, TYPES, query.types().toArray()); addFacetIfNeeded(options, aggregationHelper, esRequest, CODE_VARIANTS, query.codeVariants().toArray()); addFacetIfNeeded(options, aggregationHelper, esRequest, CLEAN_CODE_ATTRIBUTE_CATEGORY, query.cleanCodeAttributesCategories().toArray()); + addFacetIfNeeded(options, aggregationHelper, esRequest, PRIORITIZED_RULE, ArrayUtils.EMPTY_OBJECT_ARRAY); addSecurityCategoryFacetIfNeeded(PARAM_PCI_DSS_32, PCI_DSS_32, options, aggregationHelper, esRequest, query.pciDss32().toArray()); addSecurityCategoryFacetIfNeeded(PARAM_PCI_DSS_40, PCI_DSS_40, options, aggregationHelper, esRequest, query.pciDss40().toArray()); diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java index 2a9816cace7..233aa77bdd0 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java @@ -87,6 +87,7 @@ public class IssueQuery { private final Boolean onComponentOnly; private final Boolean assigned; private final Boolean resolved; + private final Boolean prioritizedRule; private final Date createdAt; private final PeriodStart createdAfter; private final Date createdBefore; @@ -135,6 +136,7 @@ public class IssueQuery { this.onComponentOnly = builder.onComponentOnly; this.assigned = builder.assigned; this.resolved = builder.resolved; + this.prioritizedRule = builder.prioritizedRule; this.createdAt = builder.createdAt; this.createdAfter = builder.createdAfter; this.createdBefore = builder.createdBefore; @@ -289,6 +291,11 @@ public class IssueQuery { return resolved; } + @CheckForNull + public Boolean prioritizedRule() { + return prioritizedRule; + } + @CheckForNull public PeriodStart createdAfter() { return createdAfter; @@ -392,6 +399,7 @@ public class IssueQuery { private Boolean onComponentOnly = false; private Boolean assigned = null; private Boolean resolved = null; + private Boolean prioritizedRule = null; private Date createdAt; private PeriodStart createdAfter; private Date createdBefore; @@ -591,6 +599,12 @@ public class IssueQuery { return this; } + public Builder prioritizedRule(@Nullable Boolean prioritizedRule) { + this.prioritizedRule = prioritizedRule; + return this; + } + + public Builder createdAt(@Nullable Date d) { this.createdAt = d == null ? null : new Date(d.getTime()); return this; diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java index 4671118117d..7e4a69a5ea3 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java @@ -137,6 +137,7 @@ public class IssueQueryFactory { .resolutions(request.getResolutions()) .issueStatuses(request.getIssueStatuses()) .resolved(request.getResolved()) + .prioritizedRule(request.getPrioritizedRule()) .rules(ruleDtos) .ruleUuids(ruleUuids) .assigneeUuids(request.getAssigneeUuids()) diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java index dba880869fc..9c5223d09c0 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java @@ -20,7 +20,7 @@ package org.sonar.server.issue.index; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonar.api.issue.Issue; import org.sonar.api.rule.Severity; import org.sonar.db.component.ComponentDto; @@ -38,10 +38,10 @@ import static org.sonar.api.issue.Issue.STATUS_OPEN; import static org.sonar.api.utils.DateUtils.parseDateTime; import static org.sonarqube.ws.client.issue.IssuesWsParameters.FACET_MODE_EFFORT; -public class IssueIndexDebtTest extends IssueIndexTestCommon { +class IssueIndexDebtTest extends IssueIndexTestCommon { @Test - public void facets_on_projects() { + void facets_on_projects() { ComponentDto project = ComponentTesting.newPrivateProjectDto("ABCD"); ComponentDto project2 = ComponentTesting.newPrivateProjectDto("EFGH"); @@ -57,7 +57,7 @@ public class IssueIndexDebtTest extends IssueIndexTestCommon { } @Test - public void facets_on_components() { + void facets_on_components() { ComponentDto project = ComponentTesting.newPrivateProjectDto("A"); ComponentDto file1 = ComponentTesting.newFileDto(project, null, "ABCD"); ComponentDto file2 = ComponentTesting.newFileDto(project, null, "BCDE"); @@ -78,7 +78,7 @@ public class IssueIndexDebtTest extends IssueIndexTestCommon { } @Test - public void facets_on_directories() { + void facets_on_directories() { ComponentDto project = ComponentTesting.newPrivateProjectDto(); ComponentDto file1 = ComponentTesting.newFileDto(project).setPath("src/main/xoo/F1.xoo"); ComponentDto file2 = ComponentTesting.newFileDto(project).setPath("F2.xoo"); @@ -94,7 +94,7 @@ public class IssueIndexDebtTest extends IssueIndexTestCommon { } @Test - public void facets_on_severities() { + void facets_on_severities() { ComponentDto project = ComponentTesting.newPrivateProjectDto(); ComponentDto file = ComponentTesting.newFileDto(project); @@ -110,7 +110,7 @@ public class IssueIndexDebtTest extends IssueIndexTestCommon { } @Test - public void facets_on_statuses() { + void facets_on_statuses() { ComponentDto project = ComponentTesting.newPrivateProjectDto(); ComponentDto file = ComponentTesting.newFileDto(project); @@ -126,7 +126,7 @@ public class IssueIndexDebtTest extends IssueIndexTestCommon { } @Test - public void facets_on_resolutions() { + void facets_on_resolutions() { ComponentDto project = ComponentTesting.newPrivateProjectDto(); ComponentDto file = ComponentTesting.newFileDto(project); @@ -142,7 +142,7 @@ public class IssueIndexDebtTest extends IssueIndexTestCommon { } @Test - public void facets_on_languages() { + void facets_on_languages() { ComponentDto project = ComponentTesting.newPrivateProjectDto(); ComponentDto file = ComponentTesting.newFileDto(project); @@ -155,7 +155,7 @@ public class IssueIndexDebtTest extends IssueIndexTestCommon { } @Test - public void facets_on_assignees() { + void facets_on_assignees() { ComponentDto project = ComponentTesting.newPrivateProjectDto(); ComponentDto file = ComponentTesting.newFileDto(project); @@ -172,7 +172,7 @@ public class IssueIndexDebtTest extends IssueIndexTestCommon { } @Test - public void facets_on_author() { + void facets_on_author() { ComponentDto project = ComponentTesting.newPrivateProjectDto(); ComponentDto file = ComponentTesting.newFileDto(project); @@ -189,7 +189,7 @@ public class IssueIndexDebtTest extends IssueIndexTestCommon { } @Test - public void facet_on_created_at() { + void facet_on_created_at() { SearchOptions searchOptions = fixtureForCreatedAtFacet(); Builder query = newQueryBuilder().createdBefore(parseDateTime("2016-01-01T00:00:00+0100")); 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 9827027c6e0..40a8403f089 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 @@ -25,7 +25,7 @@ import java.util.Date; import java.util.Map; import java.util.Set; import org.elasticsearch.action.search.SearchResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonar.api.issue.IssueStatus; import org.sonar.api.issue.impact.Severity; import org.sonar.api.rules.RuleType; @@ -73,10 +73,10 @@ import static org.sonar.db.rule.RuleTesting.newRule; import static org.sonar.server.issue.IssueDocTesting.newDoc; import static org.sonar.server.issue.IssueDocTesting.newDocForProject; -public class IssueIndexFacetsTest extends IssueIndexTestCommon { +class IssueIndexFacetsTest extends IssueIndexTestCommon { @Test - public void facet_on_projectUuids() { + void facet_on_projectUuids() { ComponentDto project = newPrivateProjectDto("ABCD"); ComponentDto project2 = newPrivateProjectDto("EFGH"); @@ -89,7 +89,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_projectUuids_return_100_entries_plus_selected_values() { + void facet_on_projectUuids_return_100_entries_plus_selected_values() { indexIssues(rangeClosed(1, 110).mapToObj(i -> newDocForProject(newPrivateProjectDto("a" + i))).toArray(IssueDoc[]::new)); IssueDoc issue1 = newDocForProject(newPrivateProjectDto("project1")); @@ -101,7 +101,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_files() { + void facets_on_files() { ComponentDto project = newPrivateProjectDto("A"); ComponentDto dir = newDirectory(project, "src"); ComponentDto file1 = newFileDto(project, dir, "ABCD"); @@ -119,7 +119,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_files_return_100_entries_plus_selected_values() { + void facet_on_files_return_100_entries_plus_selected_values() { ComponentDto project = newPrivateProjectDto(); indexIssues(rangeClosed(1, 110).mapToObj(i -> newDoc(newFileDto(project, null, "a" + i), project.uuid())).toArray(IssueDoc[]::new)); IssueDoc issue1 = newDoc(newFileDto(project, null, "file1"), project.uuid()); @@ -131,7 +131,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_directories() { + void facets_on_directories() { ComponentDto project = newPrivateProjectDto(); ComponentDto file1 = newFileDto(project).setPath("src/main/xoo/F1.xoo"); ComponentDto file2 = newFileDto(project).setPath("F2.xoo"); @@ -144,7 +144,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_directories_return_100_entries_plus_selected_values() { + void facet_on_directories_return_100_entries_plus_selected_values() { ComponentDto project = newPrivateProjectDto(); indexIssues( rangeClosed(1, 110).mapToObj(i -> newDoc(newFileDto(project, newDirectory(project, "dir" + i)), project.uuid()).setDirectoryPath("a" + i)).toArray(IssueDoc[]::new)); @@ -157,7 +157,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_cwe() { + void facets_on_cwe() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -174,7 +174,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_pciDss32() { + void facets_on_pciDss32() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -190,7 +190,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_pciDss40() { + void facets_on_pciDss40() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -206,7 +206,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_owaspAsvs40() { + void facets_on_owaspAsvs40() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -222,7 +222,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_owaspTop10() { + void facets_on_owaspTop10() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -238,7 +238,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_owaspTop10_2021() { + void facets_on_owaspTop10_2021() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -254,7 +254,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_owaspTop10_2021_stay_ordered() { + void facets_on_owaspTop10_2021_stay_ordered() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -270,7 +270,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_sansTop25() { + void facets_on_sansTop25() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -286,7 +286,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_sonarSourceSecurity() { + void facets_on_sonarSourceSecurity() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -301,7 +301,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_severities() { + void facets_on_severities() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -314,7 +314,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_severities_return_5_entries_max() { + void facet_on_severities_return_5_entries_max() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -330,7 +330,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_statuses() { + void facets_on_statuses() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -343,7 +343,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_statuses_return_5_entries_max() { + void facet_on_statuses_return_5_entries_max() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -359,7 +359,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_resolutions() { + void facets_on_resolutions() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -372,7 +372,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void search_shouldReturnIssueStatusesFacet() { + void search_shouldReturnIssueStatusesFacet() { ComponentDto mainBranch = newPrivateProjectDto(); ComponentDto file = newFileDto(mainBranch); @@ -397,7 +397,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_resolutions_return_5_entries_max() { + void facets_on_resolutions_return_5_entries_max() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -412,7 +412,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_languages() { + void facets_on_languages() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); RuleDto ruleDefinitionDto = newRule(); @@ -424,7 +424,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_languages_return_100_entries_plus_selected_values() { + void facets_on_languages_return_100_entries_plus_selected_values() { ComponentDto project = newPrivateProjectDto(); indexIssues(rangeClosed(1, 100).mapToObj(i -> newDoc(newFileDto(project), project.uuid()).setLanguage("a" + i)).toArray(IssueDoc[]::new)); IssueDoc issue1 = newDoc(newFileDto(project), project.uuid()).setLanguage("language1"); @@ -436,7 +436,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_assignees() { + void facets_on_assignees() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -450,7 +450,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_assignees_return_only_100_entries_plus_selected_values() { + void facets_on_assignees_return_only_100_entries_plus_selected_values() { ComponentDto project = newPrivateProjectDto(); indexIssues(rangeClosed(1, 110).mapToObj(i -> newDoc(newFileDto(project), project.uuid()).setAssigneeUuid("a" + i)).toArray(IssueDoc[]::new)); IssueDoc issue1 = newDoc(newFileDto(project), project.uuid()).setAssigneeUuid("user1"); @@ -462,7 +462,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_assignees_supports_dashes() { + void facets_on_assignees_supports_dashes() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -477,7 +477,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_author() { + void facets_on_author() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -491,7 +491,21 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facets_on_authors_return_100_entries_plus_selected_values() { + void facets_on_prioritized_rule() { + ComponentDto project = newPrivateProjectDto(); + ComponentDto file = newFileDto(project); + + indexIssues( + newDoc("I1", project.uuid(), file).setPrioritizedRule(false), + newDoc("I2", project.uuid(), file).setPrioritizedRule(true), + newDoc("I3", project.uuid(), file).setPrioritizedRule(true) + ); + + assertThatFacetHasOnly(IssueQuery.builder(), "prioritizedRule", entry("true", 2L), entry("false", 1L)); + } + + @Test + void facets_on_authors_return_100_entries_plus_selected_values() { ComponentDto project = newPrivateProjectDto(); indexIssues(rangeClosed(1, 110).mapToObj(i -> newDoc(newFileDto(project), project.uuid()).setAuthorLogin("a" + i)).toArray(IssueDoc[]::new)); IssueDoc issue1 = newDoc(newFileDto(project), project.uuid()).setAuthorLogin("user1"); @@ -503,7 +517,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_created_at_with_less_than_20_days_use_system_timezone_by_default() { + void facet_on_created_at_with_less_than_20_days_use_system_timezone_by_default() { SearchOptions options = fixtureForCreatedAtFacet(); IssueQuery query = IssueQuery.builder() @@ -524,7 +538,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_created_at_with_less_than_20_days_use_user_timezone_if_provided() { + void facet_on_created_at_with_less_than_20_days_use_user_timezone_if_provided() { // Use timezones very far from each other in order to see some issues moving to a different calendar day final ZoneId plus14 = ZoneId.of("Pacific/Kiritimati"); final ZoneId minus11 = ZoneId.of("Pacific/Pago_Pago"); @@ -570,7 +584,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_created_at_with_less_than_20_weeks() { + void facet_on_created_at_with_less_than_20_weeks() { SearchOptions options = fixtureForCreatedAtFacet(); SearchResponse result = underTest.search(IssueQuery.builder() @@ -586,7 +600,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_created_at_with_less_than_20_months() { + void facet_on_created_at_with_less_than_20_months() { SearchOptions options = fixtureForCreatedAtFacet(); SearchResponse result = underTest.search(IssueQuery.builder() @@ -604,7 +618,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_created_at_with_more_than_20_months() { + void facet_on_created_at_with_more_than_20_months() { SearchOptions options = fixtureForCreatedAtFacet(); SearchResponse result = underTest.search(IssueQuery.builder() @@ -622,7 +636,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_created_at_with_one_day() { + void facet_on_created_at_with_one_day() { SearchOptions options = fixtureForCreatedAtFacet(); SearchResponse result = underTest.search(IssueQuery.builder() @@ -635,7 +649,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_created_at_with_bounds_outside_of_data() { + void facet_on_created_at_with_bounds_outside_of_data() { SearchOptions options = fixtureForCreatedAtFacet(); SearchResponse result = underTest.search(IssueQuery.builder() @@ -655,7 +669,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_created_at_without_start_bound() { + void facet_on_created_at_without_start_bound() { SearchOptions searchOptions = fixtureForCreatedAtFacet(); SearchResponse result = underTest.search(IssueQuery.builder() @@ -671,7 +685,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void facet_on_created_at_without_issues() { + void facet_on_created_at_without_issues() { SearchOptions searchOptions = new SearchOptions().addFacets("createdAt"); SearchResponse result = underTest.search(IssueQuery.builder().build(), searchOptions); @@ -680,7 +694,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void search_shouldReturnCodeVariantsFacet() { + void search_shouldReturnCodeVariantsFacet() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -697,7 +711,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void search_shouldReturnImpactSoftwareQualitiesFacet() { + void search_shouldReturnImpactSoftwareQualitiesFacet() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -719,7 +733,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void search_whenFilteredOnSeverity_shouldReturnImpactSoftwareQualitiesFacet() { + void search_whenFilteredOnSeverity_shouldReturnImpactSoftwareQualitiesFacet() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -765,7 +779,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void search_whenFilteredOnSeverityAndSoftwareQuality_shouldReturnImpactFacets() { + void search_whenFilteredOnSeverityAndSoftwareQuality_shouldReturnImpactFacets() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -792,7 +806,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void search_shouldReturnImpactSeverityFacet() { + void search_shouldReturnImpactSeverityFacet() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -814,7 +828,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void search_whenFilteredOnSoftwareQuality_shouldReturnImpactSeverityFacet() { + void search_whenFilteredOnSoftwareQuality_shouldReturnImpactSeverityFacet() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -836,7 +850,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void search_shouldReturnCleanCodeAttributeCategoryFacet() { + void search_shouldReturnCleanCodeAttributeCategoryFacet() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -858,7 +872,7 @@ public class IssueIndexFacetsTest extends IssueIndexTestCommon { } @Test - public void search_whenFilteredByTags_shouldReturnCleanCodeAttributeCategoryFacet() { + void search_whenFilteredByTags_shouldReturnCleanCodeAttributeCategoryFacet() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java index 66113bbf80b..1e1fa395751 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import org.assertj.core.api.Fail; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonar.api.issue.Issue; import org.sonar.api.issue.IssueStatus; import org.sonar.api.rule.Severity; @@ -57,10 +57,10 @@ import static org.sonar.db.rule.RuleTesting.newRule; import static org.sonar.server.issue.IssueDocTesting.newDoc; import static org.sonar.server.issue.IssueDocTesting.newDocForProject; -public class IssueIndexFiltersTest extends IssueIndexTestCommon { +class IssueIndexFiltersTest extends IssueIndexTestCommon { @Test - public void filter_by_keys() { + void filter_by_keys() { ComponentDto project = newPrivateProjectDto(); indexIssues( @@ -73,7 +73,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_projects() { + void filter_by_projects() { ComponentDto project = newPrivateProjectDto(); indexIssues( @@ -85,7 +85,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_components_on_contextualized_search() { + void filter_by_components_on_contextualized_search() { ComponentDto project = newPrivateProjectDto(); ComponentDto file1 = newFileDto(project); String view = "ABCD"; @@ -103,7 +103,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_components_on_non_contextualized_search() { + void filter_by_components_on_non_contextualized_search() { ComponentDto project = newPrivateProjectDto("project"); ComponentDto file1 = newFileDto(project, null, "file1"); String view = "ABCD"; @@ -121,7 +121,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_directories() { + void filter_by_directories() { ComponentDto project = newPrivateProjectDto(); ComponentDto file1 = newFileDto(project).setPath("src/main/xoo/F1.xoo"); ComponentDto file2 = newFileDto(project).setPath("F2.xoo"); @@ -136,7 +136,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_portfolios() { + void filter_by_portfolios() { ComponentDto portfolio1 = db.components().insertPrivateApplication().getMainBranchComponent(); ComponentDto portfolio2 = db.components().insertPrivateApplication().getMainBranchComponent(); ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); @@ -161,7 +161,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_portfolios_not_having_projects() { + void filter_by_portfolios_not_having_projects() { ComponentDto project1 = newPrivateProjectDto(); ComponentDto file1 = newFileDto(project1); indexIssues(newDoc("I2", project1.uuid(), file1)); @@ -172,7 +172,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void do_not_return_issues_from_project_branch_when_filtering_by_portfolios() { + void do_not_return_issues_from_project_branch_when_filtering_by_portfolios() { ComponentDto portfolio = db.components().insertPrivateApplication().getMainBranchComponent(); ComponentDto project = db.components().insertPublicProject().getMainBranchComponent(); ComponentDto projectBranch = db.components().insertProjectBranch(project); @@ -191,7 +191,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_one_issue_by_project_and_branch() { + void filter_one_issue_by_project_and_branch() { ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); ComponentDto branch = db.components().insertProjectBranch(project); ComponentDto anotherbBranch = db.components().insertProjectBranch(project); @@ -213,7 +213,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void issues_from_branch_component_children() { + void issues_from_branch_component_children() { ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); ComponentDto projectFile = db.components().insertComponent(newFileDto(project)); ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch")); @@ -231,7 +231,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void issues_from_main_branch() { + void issues_from_main_branch() { ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); ComponentDto branch = db.components().insertProjectBranch(project); @@ -248,7 +248,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void branch_issues_are_ignored_when_no_branch_param() { + void branch_issues_are_ignored_when_no_branch_param() { ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch")); @@ -260,7 +260,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_main_application() { + void filter_by_main_application() { ComponentDto application1 = db.components().insertPrivateApplication().getMainBranchComponent(); ComponentDto application2 = db.components().insertPrivateApplication().getMainBranchComponent(); ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); @@ -284,7 +284,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_application_branch() { + void filter_by_application_branch() { ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP)).getMainBranchComponent(); ComponentDto branch1 = db.components().insertProjectBranch(application); ComponentDto branch2 = db.components().insertProjectBranch(application); @@ -310,7 +310,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_application_branch_having_project_branches() { + void filter_by_application_branch_having_project_branches() { ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setKey("app")).getMainBranchComponent(); ComponentDto applicationBranch1 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch1")); ComponentDto applicationBranch2 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch2")); @@ -343,7 +343,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_created_after_by_projects() { + void filter_by_created_after_by_projects() { Date now = new Date(); ComponentDto project1 = newPrivateProjectDto(); IssueDoc project1Issue1 = newDocForProject(project1).setFuncCreationDate(addDays(now, -10)); @@ -379,7 +379,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_created_after_by_project_branches() { + void filter_by_created_after_by_project_branches() { Date now = new Date(); ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); @@ -432,7 +432,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_new_code_reference_by_projects() { + void filter_by_new_code_reference_by_projects() { ComponentDto project1 = newPrivateProjectDto(); IssueDoc project1Issue1 = newDocForProject(project1).setIsNewCodeReference(true); IssueDoc project1Issue2 = newDocForProject(project1).setIsNewCodeReference(false); @@ -448,7 +448,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_new_code_reference_branches() { + void filter_by_new_code_reference_branches() { ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); IssueDoc project1Issue1 = newDocForProject(project1).setIsNewCodeReference(true); IssueDoc project1Issue2 = newDocForProject(project1).setIsNewCodeReference(false); @@ -477,7 +477,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_severities() { + void filter_by_severities() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -491,7 +491,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_statuses() { + void filter_by_statuses() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -505,7 +505,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_resolutions() { + void filter_by_resolutions() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -519,7 +519,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_resolved() { + void filter_by_resolved() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -534,7 +534,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_rules() { + void filter_by_rules() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); RuleDto ruleDefinitionDto = newRule(); @@ -547,7 +547,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_languages() { + void filter_by_languages() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); RuleDto ruleDefinitionDto = newRule(); @@ -560,7 +560,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_assignees() { + void filter_by_assignees() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -575,7 +575,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_assigned() { + void filter_by_assigned() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -590,7 +590,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_authors() { + void filter_by_authors() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -605,7 +605,22 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_created_after() { + void filter_by_prioritized_rule() { + ComponentDto project = newPrivateProjectDto(); + ComponentDto file = newFileDto(project); + + indexIssues( + newDoc("I1", project.uuid(), file).setPrioritizedRule(true), + newDoc("I2", project.uuid(), file).setPrioritizedRule(true), + newDoc("I3", project.uuid(), file).setPrioritizedRule(false)); + + assertThatSearchReturnsOnly(IssueQuery.builder().prioritizedRule(null), "I1", "I2", "I3"); + assertThatSearchReturnsOnly(IssueQuery.builder().prioritizedRule(true), "I1", "I2"); + assertThatSearchReturnsOnly(IssueQuery.builder().prioritizedRule(false), "I3"); + } + + @Test + void filter_by_created_after() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -621,7 +636,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_created_before() { + void filter_by_created_before() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -637,7 +652,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_created_after_and_before() { + void filter_by_created_after_and_before() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -677,7 +692,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_created_after_and_before_take_into_account_timezone() { + void filter_by_created_after_and_before_take_into_account_timezone() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -692,7 +707,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_created_before_must_be_lower_than_after() { + void filter_by_created_before_must_be_lower_than_after() { try { underTest.search(IssueQuery.builder().createdAfter(parseDate("2014-09-20")).createdBefore(parseDate("2014-09-19")).build(), new SearchOptions()); @@ -703,7 +718,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void fail_if_created_before_equals_created_after() { + void fail_if_created_before_equals_created_after() { assertThatThrownBy(() -> underTest.search(IssueQuery.builder().createdAfter(parseDate("2014-09-20")) .createdBefore(parseDate("2014-09-20")).build(), new SearchOptions())) .isInstanceOf(IllegalArgumentException.class) @@ -711,7 +726,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_created_after_must_not_be_in_future() { + void filter_by_created_after_must_not_be_in_future() { try { underTest.search(IssueQuery.builder().createdAfter(new Date(Long.MAX_VALUE)).build(), new SearchOptions()); Fail.failBecauseExceptionWasNotThrown(IllegalArgumentException.class); @@ -721,7 +736,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_created_at() { + void filter_by_created_at() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -732,7 +747,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_new_code_reference() { + void filter_by_new_code_reference() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -743,7 +758,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_cwe() { + void filter_by_cwe() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -756,7 +771,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_owaspAsvs40_category() { + void filter_by_owaspAsvs40_category() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -771,7 +786,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_owaspAsvs40_specific_requirement() { + void filter_by_owaspAsvs40_specific_requirement() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -786,7 +801,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_owaspAsvs40_level() { + void filter_by_owaspAsvs40_level() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -808,7 +823,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_owaspTop10() { + void filter_by_owaspTop10() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -821,7 +836,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_sansTop25() { + void filter_by_sansTop25() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -834,7 +849,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void filter_by_sonarSecurity() { + void filter_by_sonarSecurity() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -847,7 +862,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void search_whenFilteringByCodeVariants_shouldReturnRelevantIssues() { + void search_whenFilteringByCodeVariants_shouldReturnRelevantIssues() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -861,7 +876,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void search_whenFilteringBySoftwareQualities_shouldReturnRelevantIssues() { + void search_whenFilteringBySoftwareQualities_shouldReturnRelevantIssues() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -899,7 +914,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void search_whenFilteringByCleanCodeAttributeCategory_shouldReturnRelevantIssues() { + void search_whenFilteringByCleanCodeAttributeCategory_shouldReturnRelevantIssues() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -925,7 +940,7 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon { } @Test - public void search_whenFilteringByIssueStatus_shouldReturnRelevantIssues() { + void search_whenFilteringByIssueStatus_shouldReturnRelevantIssues() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexProjectStatisticsTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexProjectStatisticsTest.java index e505cc35042..a41947f8cb9 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexProjectStatisticsTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexProjectStatisticsTest.java @@ -21,7 +21,7 @@ package org.sonar.server.issue.index; import java.util.Date; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonar.api.issue.Issue; import org.sonar.db.component.ComponentDto; @@ -37,34 +37,22 @@ import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; import static org.sonar.server.issue.IssueDocTesting.newDoc; import static org.sonar.server.issue.IssueDocTesting.newDocForProject; -public class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { +class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { @Test - public void searchProjectStatistics_returns_empty_list_if_no_input() { + void searchProjectStatistics_returns_empty_list_if_no_input() { List result = underTest.searchProjectStatistics(emptyList(), emptyList(), "unknownUser"); assertThat(result).isEmpty(); } @Test - public void searchProjectStatistics_returns_empty_list_if_the_input_does_not_match_anything() { + void searchProjectStatistics_returns_empty_list_if_the_input_does_not_match_anything() { List result = underTest.searchProjectStatistics(singletonList("unknownProjectUuid"), singletonList(1_111_234_567_890L), "unknownUser"); assertThat(result).isEmpty(); } @Test - public void searchProjectStatistics_returns_something() { - ComponentDto project = newPrivateProjectDto(); - String userUuid = randomAlphanumeric(40); - long from = 1_111_234_567_890L; - indexIssues(newDocForProject("issue1", project).setAssigneeUuid(userUuid).setFuncCreationDate(new Date(from + 1L))); - - List result = underTest.searchProjectStatistics(singletonList(project.uuid()), singletonList(from), userUuid); - - assertThat(result).extracting(ProjectStatistics::getProjectUuid).containsExactly(project.uuid()); - } - - @Test - public void searchProjectStatistics_does_not_return_results_if_assignee_does_not_match() { + void searchProjectStatistics_does_not_return_results_if_assignee_does_not_match() { ComponentDto project = newPrivateProjectDto(); String user1Uuid = randomAlphanumeric(40); String user2Uuid = randomAlphanumeric(40); @@ -77,7 +65,7 @@ public class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { } @Test - public void searchProjectStatistics_returns_results_if_assignee_matches() { + void searchProjectStatistics_returns_results_if_assignee_matches() { ComponentDto project = newPrivateProjectDto(); String user1Uuid = randomAlphanumeric(40); long from = 1_111_234_567_890L; @@ -89,7 +77,7 @@ public class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { } @Test - public void searchProjectStatistics_returns_results_if_functional_date_is_strictly_after_from_date() { + void searchProjectStatistics_returns_results_if_functional_date_is_strictly_after_from_date() { ComponentDto project = newPrivateProjectDto(); String userUuid = randomAlphanumeric(40); long from = 1_111_234_567_890L; @@ -101,7 +89,7 @@ public class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { } @Test - public void searchProjectStatistics_does_not_return_results_if_functional_date_is_same_as_from_date() { + void searchProjectStatistics_does_not_return_results_if_functional_date_is_same_as_from_date() { ComponentDto project = newPrivateProjectDto(); String userUuid = randomAlphanumeric(40); long from = 1_111_234_567_890L; @@ -113,7 +101,7 @@ public class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { } @Test - public void searchProjectStatistics_does_not_return_resolved_issues() { + void searchProjectStatistics_does_not_return_resolved_issues() { ComponentDto project = newPrivateProjectDto(); String userUuid = randomAlphanumeric(40); long from = 1_111_234_567_890L; @@ -129,7 +117,7 @@ public class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { } @Test - public void searchProjectStatistics_does_not_return_results_if_functional_date_is_before_from_date() { + void searchProjectStatistics_does_not_return_results_if_functional_date_is_before_from_date() { ComponentDto project = newPrivateProjectDto(); String userUuid = randomAlphanumeric(40); long from = 1_111_234_567_890L; @@ -141,7 +129,7 @@ public class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { } @Test - public void searchProjectStatistics_returns_issue_count() { + void searchProjectStatistics_returns_issue_count() { ComponentDto project = newPrivateProjectDto(); String userUuid = randomAlphanumeric(40); long from = 1_111_234_567_890L; @@ -156,7 +144,7 @@ public class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { } @Test - public void searchProjectStatistics_returns_issue_count_for_multiple_projects() { + void searchProjectStatistics_returns_issue_count_for_multiple_projects() { ComponentDto project1 = newPrivateProjectDto(); ComponentDto project2 = newPrivateProjectDto(); ComponentDto project3 = newPrivateProjectDto(); @@ -183,7 +171,7 @@ public class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { } @Test - public void searchProjectStatistics_returns_max_date_for_multiple_projects() { + void searchProjectStatistics_returns_max_date_for_multiple_projects() { ComponentDto project1 = newPrivateProjectDto(); ComponentDto project2 = newPrivateProjectDto(); ComponentDto project3 = newPrivateProjectDto(); @@ -210,7 +198,7 @@ public class IssueIndexProjectStatisticsTest extends IssueIndexTestCommon { } @Test - public void searchProjectStatistics_return_branch_issues() { + void searchProjectStatistics_return_branch_issues() { ComponentDto project = newPrivateProjectDto(); ComponentDto branch = newBranchComponent(project, newBranchDto(project).setKey("branch")); String userUuid = randomAlphanumeric(40); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityCategoriesTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityCategoriesTest.java index 7066358bc61..04990f9dc7d 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityCategoriesTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityCategoriesTest.java @@ -20,7 +20,7 @@ package org.sonar.server.issue.index; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonar.api.issue.Issue; import org.sonar.api.rule.Severity; import org.sonar.api.rules.RuleType; @@ -32,10 +32,10 @@ import static java.util.stream.Collectors.toList; import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; import static org.sonar.server.issue.IssueDocTesting.newDocForProject; -public class IssueIndexSecurityCategoriesTest extends IssueIndexTestCommon { +class IssueIndexSecurityCategoriesTest extends IssueIndexTestCommon { @Test - public void searchSinglePciDss32Category() { + void searchSinglePciDss32Category() { ComponentDto project = newPrivateProjectDto(); indexIssues( @@ -51,7 +51,7 @@ public class IssueIndexSecurityCategoriesTest extends IssueIndexTestCommon { } @Test - public void searchMultiplePciDss32Categories() { + void searchMultiplePciDss32Categories() { ComponentDto project = newPrivateProjectDto(); indexIssues( @@ -69,7 +69,7 @@ public class IssueIndexSecurityCategoriesTest extends IssueIndexTestCommon { } @Test - public void searchSinglePciDss40Category() { + void searchSinglePciDss40Category() { ComponentDto project = newPrivateProjectDto(); indexIssues( @@ -85,7 +85,7 @@ public class IssueIndexSecurityCategoriesTest extends IssueIndexTestCommon { } @Test - public void searchMultiplePciDss40Categories() { + void searchMultiplePciDss40Categories() { ComponentDto project = newPrivateProjectDto(); indexIssues( @@ -103,7 +103,7 @@ public class IssueIndexSecurityCategoriesTest extends IssueIndexTestCommon { } @Test - public void searchMixedPciDssCategories() { + void searchMixedPciDssCategories() { ComponentDto project = newPrivateProjectDto(); indexIssues( diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityHotspotsTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityHotspotsTest.java index b281f795613..7b8465a668d 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityHotspotsTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityHotspotsTest.java @@ -21,7 +21,7 @@ package org.sonar.server.issue.index; import java.util.Map; import org.elasticsearch.action.search.SearchResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonar.api.rule.Severity; import org.sonar.db.component.ComponentDto; import org.sonar.server.es.Facets; @@ -41,10 +41,10 @@ import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; import static org.sonar.server.issue.IssueDocTesting.newDoc; -public class IssueIndexSecurityHotspotsTest extends IssueIndexTestCommon { +class IssueIndexSecurityHotspotsTest extends IssueIndexTestCommon { @Test - public void filter_by_security_hotspots_type() { + void filter_by_security_hotspots_type() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -62,7 +62,7 @@ public class IssueIndexSecurityHotspotsTest extends IssueIndexTestCommon { } @Test - public void filter_by_severities_ignore_hotspots() { + void filter_by_severities_ignore_hotspots() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -80,7 +80,7 @@ public class IssueIndexSecurityHotspotsTest extends IssueIndexTestCommon { } @Test - public void facet_on_severities_ignore_hotspots() { + void facet_on_severities_ignore_hotspots() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityReportsTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityReportsTest.java index 1257a57832d..59b3abc0dc3 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityReportsTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSecurityReportsTest.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.OptionalInt; import java.util.stream.Collectors; import org.jetbrains.annotations.NotNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonar.api.issue.Issue; import org.sonar.api.rule.Severity; import org.sonar.api.rules.RuleType; @@ -47,10 +47,10 @@ import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; import static org.sonar.server.issue.IssueDocTesting.newDocForProject; import static org.sonar.server.security.SecurityStandards.UNKNOWN_STANDARD; -public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { +class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { @Test - public void getOwaspTop10Report_dont_count_vulnerabilities_from_other_projects() { + void getOwaspTop10Report_dont_count_vulnerabilities_from_other_projects() { ComponentDto project = newPrivateProjectDto(); ComponentDto another = newPrivateProjectDto(); @@ -79,7 +79,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getOwaspTop10Report_dont_count_closed_vulnerabilities() { + void getOwaspTop10Report_dont_count_closed_vulnerabilities() { ComponentDto project = newPrivateProjectDto(); indexIssues( newDocForProject("openvul1", project).setOwaspTop10(List.of("a1")).setType(RuleType.VULNERABILITY).setStatus(Issue.STATUS_OPEN).setSeverity(Severity.MAJOR), @@ -105,7 +105,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getOwaspTop10Report_dont_count_old_vulnerabilities() { + void getOwaspTop10Report_dont_count_old_vulnerabilities() { ComponentDto project = newPrivateProjectDto(); indexIssues( // Previous vulnerabilities in projects that are not reanalyzed will have no owasp nor cwe attributes (not even 'unknown') @@ -127,7 +127,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getOwaspTop10Report_dont_count_hotspots_from_other_projects() { + void getOwaspTop10Report_dont_count_hotspots_from_other_projects() { ComponentDto project = newPrivateProjectDto(); ComponentDto another = newPrivateProjectDto(); indexIssues( @@ -150,7 +150,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getOwaspTop10Report_dont_count_closed_hotspots() { + void getOwaspTop10Report_dont_count_closed_hotspots() { ComponentDto project = newPrivateProjectDto(); indexIssues( newDocForProject("openhotspot1", project).setOwaspTop10(List.of("a1")).setType(RuleType.SECURITY_HOTSPOT).setStatus(Issue.STATUS_TO_REVIEW), @@ -174,7 +174,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getOwaspTop10Report_aggregation_no_cwe() { + void getOwaspTop10Report_aggregation_no_cwe() { List owaspTop10Report = indexIssuesAndAssertOwaspReport(false); assertThat(owaspTop10Report) @@ -183,7 +183,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getPciDss32Report_aggregation() { + void getPciDss32Report_aggregation() { List pciDss32Report = indexIssuesAndAssertPciDss32Report(); assertThat(pciDss32Report) @@ -204,7 +204,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getOwaspAsvs40Report_aggregation() { + void getOwaspAsvs40Report_aggregation() { List owaspAsvsReport = indexIssuesAndAssertOwaspAsvsReport(); assertThat(owaspAsvsReport) @@ -227,7 +227,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getOwaspAsvs40ReportGroupedByLevel_aggregation() { + void getOwaspAsvs40ReportGroupedByLevel_aggregation() { List owaspAsvsReportGroupedByLevel = indexIssuesAndAssertOwaspAsvsReportGroupedByLevel(); assertThat(owaspAsvsReportGroupedByLevel) @@ -239,7 +239,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getOwaspTop10Report_aggregation_with_cwe() { + void getOwaspTop10Report_aggregation_with_cwe() { List owaspTop10Report = indexIssuesAndAssertOwaspReport(true); Map> cweByOwasp = owaspTop10Report.stream() @@ -262,7 +262,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getOwaspTop10For2021Report_aggregation_with_cwe() { + void getOwaspTop10For2021Report_aggregation_with_cwe() { List owaspTop10Report = indexIssuesAndAssertOwasp2021Report(true); Map> cweByOwasp = owaspTop10Report.stream() @@ -469,7 +469,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getPciDssReport_aggregation_on_portfolio() { + void getPciDssReport_aggregation_on_portfolio() { ComponentDto portfolio1 = db.components().insertPrivateApplication().getMainBranchComponent(); ComponentDto portfolio2 = db.components().insertPrivateApplication().getMainBranchComponent(); ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); @@ -516,7 +516,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getOwaspAsvsReport_aggregation_on_portfolio() { + void getOwaspAsvsReport_aggregation_on_portfolio() { ComponentDto portfolio1 = db.components().insertPrivateApplication().getMainBranchComponent(); ComponentDto portfolio2 = db.components().insertPrivateApplication().getMainBranchComponent(); ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); @@ -565,7 +565,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getCWETop25Report_aggregation() { + void getCWETop25Report_aggregation() { ComponentDto project = newPrivateProjectDto(); indexIssues( newDocForProject("openvul", project).setCwe(List.of("119")).setType(RuleType.VULNERABILITY).setStatus(Issue.STATUS_OPEN) @@ -645,7 +645,7 @@ public class IssueIndexSecurityReportsTest extends IssueIndexTestCommon { } @Test - public void getCWETop25Report_aggregation_on_portfolio() { + void getCWETop25Report_aggregation_on_portfolio() { ComponentDto application = db.components().insertPrivateApplication().getMainBranchComponent(); ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); ComponentDto project2 = db.components().insertPrivateProject().getMainBranchComponent(); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSortTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSortTest.java index 2d62a812f0a..9118501634c 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSortTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSortTest.java @@ -20,7 +20,7 @@ package org.sonar.server.issue.index; import org.elasticsearch.action.search.SearchResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonar.api.issue.Issue; import org.sonar.api.rule.Severity; import org.sonar.db.component.ComponentDto; @@ -31,10 +31,10 @@ import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; import static org.sonar.server.issue.IssueDocTesting.newDoc; -public class IssueIndexSortTest extends IssueIndexTestCommon { +class IssueIndexSortTest extends IssueIndexTestCommon { @Test - public void sort_by_status() { + void sort_by_status() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -51,7 +51,7 @@ public class IssueIndexSortTest extends IssueIndexTestCommon { } @Test - public void sort_by_severity() { + void sort_by_severity() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -70,7 +70,7 @@ public class IssueIndexSortTest extends IssueIndexTestCommon { } @Test - public void sort_by_creation_date() { + void sort_by_creation_date() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -87,7 +87,7 @@ public class IssueIndexSortTest extends IssueIndexTestCommon { } @Test - public void sort_by_update_date() { + void sort_by_update_date() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -104,7 +104,7 @@ public class IssueIndexSortTest extends IssueIndexTestCommon { } @Test - public void sort_by_close_date() { + void sort_by_close_date() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); @@ -122,7 +122,7 @@ public class IssueIndexSortTest extends IssueIndexTestCommon { } @Test - public void sort_by_file_and_line() { + void sort_by_file_and_line() { ComponentDto project = newPrivateProjectDto(); ComponentDto file1 = newFileDto(project, null, "F1").setPath("src/main/xoo/org/sonar/samples/File.xoo"); ComponentDto file2 = newFileDto(project, null, "F2").setPath("src/main/xoo/org/sonar/samples/File2.xoo"); @@ -149,7 +149,7 @@ public class IssueIndexSortTest extends IssueIndexTestCommon { } @Test - public void default_sort_is_by_creation_date_then_project_then_file_then_line_then_issue_key() { + void default_sort_is_by_creation_date_then_project_then_file_then_line_then_issue_key() { ComponentDto project1 = newPrivateProjectDto("P1"); ComponentDto file1 = newFileDto(project1, null, "F1").setPath("src/main/xoo/org/sonar/samples/File.xoo"); ComponentDto file2 = newFileDto(project1, null, "F2").setPath("src/main/xoo/org/sonar/samples/File2.xoo"); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java index 68570c4c652..2f5ed1b8b12 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java @@ -19,15 +19,15 @@ */ package org.sonar.server.issue.index; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterators; import java.util.ArrayList; import java.util.List; +import java.util.Set; import org.apache.lucene.search.TotalHits; import org.apache.lucene.search.TotalHits.Relation; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.search.SearchHit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonar.api.issue.Issue; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ProjectData; @@ -49,10 +49,10 @@ import static org.sonar.db.user.UserTesting.newUserDto; import static org.sonar.server.issue.IssueDocTesting.newDoc; import static org.sonar.server.issue.IssueDocTesting.newDocForProject; -public class IssueIndexTest extends IssueIndexTestCommon { +class IssueIndexTest extends IssueIndexTestCommon { @Test - public void paging() { + void paging() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); for (int i = 0; i < 12; i++) { @@ -75,7 +75,7 @@ public class IssueIndexTest extends IssueIndexTestCommon { } @Test - public void search_with_max_limit() { + void search_with_max_limit() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); List issues = new ArrayList<>(); @@ -92,7 +92,7 @@ public class IssueIndexTest extends IssueIndexTestCommon { // SONAR-14224 @Test - public void search_exceeding_default_index_max_window() { + void search_exceeding_default_index_max_window() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); List issues = new ArrayList<>(); @@ -110,7 +110,7 @@ public class IssueIndexTest extends IssueIndexTestCommon { } @Test - public void search_nine_issues_with_same_creation_date_sorted_by_creation_date_order_is_sorted_also_by_key() { + void search_nine_issues_with_same_creation_date_sorted_by_creation_date_order_is_sorted_also_by_key() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); List issues = new ArrayList<>(); @@ -131,7 +131,7 @@ public class IssueIndexTest extends IssueIndexTestCommon { } @Test - public void search_nine_issues_5_times_with_same_creation_date_sorted_by_creation_date_returned_issues_same_order() { + void search_nine_issues_5_times_with_same_creation_date_sorted_by_creation_date_returned_issues_same_order() { ComponentDto project = newPrivateProjectDto(); ComponentDto file = newFileDto(project); List issues = new ArrayList<>(); @@ -157,7 +157,7 @@ public class IssueIndexTest extends IssueIndexTestCommon { } @Test - public void authorized_issues_on_groups() { + void authorized_issues_on_groups() { ProjectData project1 = db.components().insertPublicProject(); ProjectData project2 = db.components().insertPublicProject(); ProjectData project3 = db.components().insertPublicProject(); @@ -194,7 +194,7 @@ public class IssueIndexTest extends IssueIndexTestCommon { } @Test - public void authorized_issues_on_user() { + void authorized_issues_on_user() { ProjectData project1 = db.components().insertPublicProject(); ProjectData project2 = db.components().insertPublicProject(); ProjectData project3 = db.components().insertPublicProject(); @@ -224,7 +224,7 @@ public class IssueIndexTest extends IssueIndexTestCommon { } @Test - public void list_tags() { + void list_tags() { RuleDto r1 = db.rules().insert(); RuleDto r2 = db.rules().insert(); ruleIndexer.commitAndIndex(db.getSession(), asList(r1.getUuid(), r2.getUuid())); @@ -245,7 +245,7 @@ public class IssueIndexTest extends IssueIndexTestCommon { } @Test - public void list_authors() { + void list_authors() { ComponentDto project = newPrivateProjectDto(); indexIssues( newDocForProject("issue1", project).setAuthorLogin("luke.skywalker"), @@ -262,7 +262,19 @@ public class IssueIndexTest extends IssueIndexTestCommon { } @Test - public void list_authors_escapes_regexp_special_characters() { + void prioritized_rules() { + ComponentDto project = newPrivateProjectDto(); + indexIssues( + newDocForProject("issue1", project).setPrioritizedRule(true), + newDocForProject("issue2", project).setPrioritizedRule(false)); + + assertThatSearchReturnsOnly(IssueQuery.builder(), "issue1", "issue2"); + assertThatSearchReturnsOnly(IssueQuery.builder().prioritizedRule(true), "issue1"); + assertThatSearchReturnsOnly(IssueQuery.builder().prioritizedRule(false), "issue2"); + } + + @Test + void list_authors_escapes_regexp_special_characters() { ComponentDto project = newPrivateProjectDto(); indexIssues( newDocForProject("issue1", project).setAuthorLogin("name++")); @@ -275,14 +287,14 @@ public class IssueIndexTest extends IssueIndexTestCommon { } @Test - public void countTags() { + void countTags() { ComponentDto project = newPrivateProjectDto(); indexIssues( - newDocForProject("issue1", project).setTags(ImmutableSet.of("convention", "java8", "bug")), - newDocForProject("issue2", project).setTags(ImmutableSet.of("convention", "bug")), + newDocForProject("issue1", project).setTags(Set.of("convention", "java8", "bug")), + newDocForProject("issue2", project).setTags(Set.of("convention", "bug")), newDocForProject("issue3", project).setTags(emptyList()), - newDocForProject("issue4", project).setTags(ImmutableSet.of("convention", "java8", "bug")).setResolution(Issue.RESOLUTION_FIXED), - newDocForProject("issue5", project).setTags(ImmutableSet.of("convention"))); + newDocForProject("issue4", project).setTags(Set.of("convention", "java8", "bug")).setResolution(Issue.RESOLUTION_FIXED), + newDocForProject("issue5", project).setTags(Set.of("convention"))); assertThat(underTest.countTags(projectQuery(project.uuid()), 5)).containsOnly(entry("convention", 3L), entry("bug", 2L), entry("java8", 1L)); assertThat(underTest.countTags(projectQuery(project.uuid()), 2)).contains(entry("convention", 3L), entry("bug", 2L)).doesNotContainEntry("java8", 1L); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTestCommon.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTestCommon.java index c259849daa4..8fe1e27dcc5 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTestCommon.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTestCommon.java @@ -22,7 +22,7 @@ package org.sonar.server.issue.index; import java.util.Arrays; import java.util.List; import org.elasticsearch.search.SearchHit; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.sonar.api.impl.utils.TestSystem2; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; @@ -45,12 +45,12 @@ import static org.sonar.api.resources.Qualifiers.PROJECT; public class IssueIndexTestCommon { - @Rule + @RegisterExtension public EsTester es = EsTester.create(); - @Rule + @RegisterExtension public UserSessionRule userSessionRule = UserSessionRule.standalone(); protected final System2 system2 = new TestSystem2().setNow(1_500_000_000_000L).setDefaultTimeZone(getTimeZone("GMT-01:00")); - @Rule + @RegisterExtension public DbTester db = DbTester.create(system2); private final AsyncIssueIndexing asyncIssueIndexing = mock(AsyncIssueIndexing.class); diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java index 89f9d590007..6380d72f222 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java @@ -107,7 +107,8 @@ public class IssueQueryFactoryTest { .setRules(asList(rule1.getKey().toString(), rule2.getKey().toString())) .setSort("CREATION_DATE") .setAsc(true) - .setCodeVariants(asList("variant1", "variant2")); + .setCodeVariants(asList("variant1", "variant2")) + .setPrioritizedRule(true); IssueQuery query = underTest.create(request); @@ -133,6 +134,7 @@ public class IssueQueryFactoryTest { assertThat(query.sort()).isEqualTo(IssueQuery.SORT_BY_CREATION_DATE); assertThat(query.asc()).isTrue(); assertThat(query.codeVariants()).containsOnly("variant1", "variant2"); + assertThat(query.prioritizedRule()).isTrue(); } @Test @@ -165,7 +167,8 @@ public class IssueQueryFactoryTest { .setRules(asList(rule1.getKey().toString(), rule2.getKey().toString())) .setSort("CREATION_DATE") .setAsc(true) - .setCodeVariants(asList("variant1", "variant2")); + .setCodeVariants(asList("variant1", "variant2")) + .setPrioritizedRule(false); IssueQuery query = underTest.create(request); @@ -191,6 +194,7 @@ public class IssueQueryFactoryTest { assertThat(query.sort()).isEqualTo(IssueQuery.SORT_BY_CREATION_DATE); assertThat(query.asc()).isTrue(); assertThat(query.codeVariants()).containsOnly("variant1", "variant2"); + assertThat(query.prioritizedRule()).isFalse(); } @Test diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryTest.java index d50061f65f8..5b33aae4067 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryTest.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryTest.java @@ -22,7 +22,7 @@ package org.sonar.server.issue.index; import com.google.common.collect.ImmutableMap; import java.util.Date; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.sonar.api.issue.Issue; import org.sonar.api.rule.Severity; import org.sonar.core.util.Uuids; @@ -32,10 +32,10 @@ import org.sonar.server.issue.index.IssueQuery.PeriodStart; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; -public class IssueQueryTest { +class IssueQueryTest { @Test - public void build_query() { + void build_query() { RuleDto rule = new RuleDto().setUuid(Uuids.createFast()); PeriodStart filterDate = new IssueQuery.PeriodStart(new Date(10_000_000_000L), false); IssueQuery query = IssueQuery.builder() @@ -64,6 +64,7 @@ public class IssueQueryTest { .sort(IssueQuery.SORT_BY_CREATION_DATE) .asc(true) .codeVariants(List.of("codeVariant1", "codeVariant2")) + .prioritizedRule(true) .build(); assertThat(query.issueKeys()).containsOnly("ABCDE"); assertThat(query.severities()).containsOnly(Severity.BLOCKER); @@ -90,10 +91,11 @@ public class IssueQueryTest { assertThat(query.sort()).isEqualTo(IssueQuery.SORT_BY_CREATION_DATE); assertThat(query.asc()).isTrue(); assertThat(query.codeVariants()).containsOnly("codeVariant1", "codeVariant2"); + assertThat(query.prioritizedRule()).isTrue(); } @Test - public void build_pci_dss_query() { + void build_pci_dss_query() { IssueQuery query = IssueQuery.builder() .pciDss32(List.of("1.2.3", "3.2.1")) .pciDss40(List.of("3.4.5", "5.6")) @@ -104,7 +106,7 @@ public class IssueQueryTest { } @Test - public void build_owasp_asvs_query() { + void build_owasp_asvs_query() { IssueQuery query = IssueQuery.builder() .owaspAsvs40(List.of("1.2.3", "3.2.1")) .owaspAsvsLevel(2) @@ -115,7 +117,7 @@ public class IssueQueryTest { } @Test - public void build_owasp_query() { + void build_owasp_query() { IssueQuery query = IssueQuery.builder() .owaspTop10(List.of("a1", "a2")) .owaspTop10For2021(List.of("a3", "a4")) @@ -127,7 +129,7 @@ public class IssueQueryTest { @Test - public void build_query_without_dates() { + void build_query_without_dates() { IssueQuery query = IssueQuery.builder() .issueKeys(List.of("ABCDE")) .createdAfter(null) @@ -142,7 +144,7 @@ public class IssueQueryTest { } @Test - public void throw_exception_if_sort_is_not_valid() { + void throw_exception_if_sort_is_not_valid() { try { IssueQuery.builder() .sort("UNKNOWN") @@ -153,7 +155,7 @@ public class IssueQueryTest { } @Test - public void collection_params_should_not_be_null_but_empty_except_issue_keys() { + void collection_params_should_not_be_null_but_empty_except_issue_keys() { IssueQuery query = IssueQuery.builder() .issueKeys(null) .projectUuids(null) @@ -189,7 +191,7 @@ public class IssueQueryTest { } @Test - public void test_default_query() { + void test_default_query() { IssueQuery query = IssueQuery.builder().build(); assertThat(query.projectUuids()).isEmpty(); assertThat(query.componentUuids()).isEmpty(); @@ -209,10 +211,11 @@ public class IssueQueryTest { assertThat(query.resolved()).isNull(); assertThat(query.sort()).isNull(); assertThat(query.createdAfterByProjectUuids()).isEmpty(); + assertThat(query.prioritizedRule()).isNull(); } @Test - public void should_accept_null_sort() { + void should_accept_null_sort() { IssueQuery query = IssueQuery.builder().sort(null).build(); assertThat(query.sort()).isNull(); } diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java index 85340b82b7e..12d0a67628b 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java @@ -2084,7 +2084,8 @@ public class SearchActionIT { "createdBefore", "createdInLast", "directories", "facets", "files", "issues", "scopes", "languages", "onComponentOnly", "p", "projects", "ps", "resolutions", "resolved", "rules", "s", "severities", "statuses", "tags", "types", "pciDss-3.2", "pciDss-4.0", "owaspAsvs-4.0", "owaspAsvsLevel", "owaspTop10", "owaspTop10-2021", "sansTop25", "cwe", "sonarsourceSecurity", "timeZone", "inNewCodePeriod", "codeVariants", - "cleanCodeAttributeCategories", "impactSeverities", "impactSoftwareQualities", "issueStatuses", "fixedInPullRequest"); + "cleanCodeAttributeCategories", "impactSeverities", "impactSoftwareQualities", "issueStatuses", "fixedInPullRequest", + "prioritizedRule"); WebService.Param branch = def.param(PARAM_BRANCH); assertThat(branch.isInternal()).isFalse(); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java index 8e6f747604c..1e3f3c083cb 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java @@ -124,6 +124,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_OWASP_TOP_1 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_OWASP_TOP_10_2021; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PCI_DSS_32; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PCI_DSS_40; +import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PRIORITIZED_RULE; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PROJECTS; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PULL_REQUEST; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RESOLUTIONS; @@ -212,6 +213,8 @@ public class SearchAction implements IssuesWsAction { + "
When issue indexing is in progress returns 503 service unavailable HTTP code.") .setSince("3.6") .setChangelog( + new Change("10.6", format(NEW_FACET_ADDED_MESSAGE, PARAM_PRIORITIZED_RULE)), + new Change("10.6", format(NEW_PARAM_ADDED_MESSAGE, PARAM_PRIORITIZED_RULE)), new Change("10.4", "Added new param '%s'".formatted(PARAM_FIXED_IN_PULL_REQUEST)), new Change("10.4", "Value '%s' for 'transition' response field is deprecated, use '%s' instead".formatted(DefaultTransitions.WONT_FIX, @@ -329,6 +332,9 @@ public class SearchAction implements IssuesWsAction { action.createParam(PARAM_RESOLVED) .setDescription("To match resolved or unresolved issues") .setBooleanPossibleValues(); + action.createParam(PARAM_PRIORITIZED_RULE) + .setDescription("To match issues with prioritized rule or not") + .setBooleanPossibleValues(); action.createParam(PARAM_RULES) .setDescription("Comma-separated list of coding rule keys. Format is <repository>:<rule>") .setExampleValue("java:S1144"); @@ -658,6 +664,7 @@ public class SearchAction implements IssuesWsAction { .setProjectKeys(request.paramAsStrings(PARAM_PROJECTS)) .setResolutions(request.paramAsStrings(PARAM_RESOLUTIONS)) .setResolved(request.paramAsBoolean(PARAM_RESOLVED)) + .setPrioritizedRule(request.paramAsBoolean(PARAM_PRIORITIZED_RULE)) .setRules(request.paramAsStrings(PARAM_RULES)) .setSort(request.param(Param.SORT)) .setSeverities(request.paramAsStrings(PARAM_SEVERITIES)) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java index 5db49b6cff6..318ff72b1f6 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java @@ -229,6 +229,7 @@ public class SearchResponseFormat { .ifPresentOrElse(issueBuilder::setQuickFixAvailable, () -> issueBuilder.setQuickFixAvailable(false)); issueBuilder.setScope(UNIT_TEST_FILE.equals(component.qualifier()) ? IssueScope.TEST.name() : IssueScope.MAIN.name()); + issueBuilder.setPrioritizedRule(dto.isPrioritizedRule()); } private static void addAdditionalFieldsToIssueBuilder(Collection fields, SearchResponseData data, IssueDto dto, Issue.Builder issueBuilder) { diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/search-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/search-example.json index 14f91242668..245f6c06909 100644 --- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/search-example.json +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/issue/ws/search-example.json @@ -13,6 +13,7 @@ "cleanCodeAttribute": "CLEAR", "cleanCodeAttributeCategory": "INTENTIONAL", "issueStatus": "ACCEPTED", + "prioritizedRule": false, "impacts": [ { "softwareQuality": "SECURITY", diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 8d56e9bac23..6ce6eb3bbe6 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -132,6 +132,7 @@ import org.sonar.server.issue.AddTagsAction; import org.sonar.server.issue.AssignAction; import org.sonar.server.issue.CommentAction; import org.sonar.server.issue.IssueChangePostProcessorImpl; +import org.sonar.server.issue.PrioritizedRulesFeature; import org.sonar.server.issue.RemoveTagsAction; import org.sonar.server.issue.SetSeverityAction; import org.sonar.server.issue.SetTypeAction; @@ -472,6 +473,7 @@ public class PlatformLevel4 extends PlatformLevel { IssueIndexer.class, IssueIteratorFactory.class, PermissionIndexer.class, + PrioritizedRulesFeature.class, new IssueWsModule(), NewIssuesEmailTemplate.class, MyNewIssuesEmailTemplate.class, diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java index 3c557ffe473..2192d46a89d 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java @@ -61,6 +61,7 @@ public class IssuesWsParameters { public static final String PARAM_RESOLUTIONS = "resolutions"; public static final String PARAM_ISSUE_STATUSES = "issueStatuses"; public static final String PARAM_RESOLVED = "resolved"; + public static final String PARAM_PRIORITIZED_RULE = "prioritizedRule"; public static final String PARAM_COMPONENTS = "components"; public static final String PARAM_COMPONENT_KEYS = "componentKeys"; public static final String PARAM_COMPONENT_UUIDS = "componentUuids"; diff --git a/sonar-ws/src/main/protobuf/ws-issues.proto b/sonar-ws/src/main/protobuf/ws-issues.proto index 46f4e9a299b..dcc65a70ee4 100644 --- a/sonar-ws/src/main/protobuf/ws-issues.proto +++ b/sonar-ws/src/main/protobuf/ws-issues.proto @@ -167,6 +167,7 @@ message Issue { optional sonarqube.ws.commons.CleanCodeAttributeCategory cleanCodeAttributeCategory = 41; repeated sonarqube.ws.commons.Impact impacts = 42; optional string issueStatus = 43; + optional bool prioritizedRule = 44; } message Transitions {