From: Léo Geoffroy Date: Fri, 27 Jan 2023 10:40:35 +0000 (+0100) Subject: SONAR-17705 Remove deprecated param 'sinceLeakPeriod' from issues/search endpoint X-Git-Tag: 10.0.0.68432~272 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0a81fcc56fea35acbb5c09d186924a9ba2266ea5;p=sonarqube.git SONAR-17705 Remove deprecated param 'sinceLeakPeriod' from issues/search endpoint --- 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 d66a74905c8..40c9182facc 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 @@ -55,7 +55,6 @@ public class SearchRequest { private List resolutions; private Boolean resolved; private List rules; - private Boolean sinceLeakPeriod; private String sort; private List severities; private List statuses; @@ -305,24 +304,6 @@ public class SearchRequest { return this; } - /** - * @deprecated since 9.4 - replaced by getInNewCodePeriod() - */ - @Deprecated(since = "9.4") - @CheckForNull - public Boolean getSinceLeakPeriod() { - return sinceLeakPeriod; - } - - /** - * @deprecated since 9.4 - replaced by setInNewCodePeriod() - */ - @Deprecated(since = "9.4") - public SearchRequest setSinceLeakPeriod(@Nullable Boolean sinceLeakPeriod) { - this.sinceLeakPeriod = sinceLeakPeriod; - return this; - } - @CheckForNull public String getSort() { return sort; 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 c2ebee547f2..b550cb4a6e0 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 @@ -82,7 +82,6 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_U import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AFTER; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_IN_LAST; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IN_NEW_CODE_PERIOD; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SINCE_LEAK_PERIOD; /** * This component is used to create an IssueQuery, in order to transform the component and component roots keys into uuid. @@ -199,9 +198,9 @@ public class IssueQueryFactory { setCreatedAfterFromDates(builder, createdAfter, createdInLast, true); } else { // If the filter is on leak period - checkArgument(createdAfter == null, "Parameters '%s' and '%s' or '%s' cannot be set simultaneously", PARAM_CREATED_AFTER, PARAM_IN_NEW_CODE_PERIOD, PARAM_SINCE_LEAK_PERIOD); + checkArgument(createdAfter == null, "Parameters '%s' and '%s' cannot be set simultaneously", PARAM_CREATED_AFTER, PARAM_IN_NEW_CODE_PERIOD); checkArgument(createdInLast == null, - format("Parameters '%s' and '%s' or '%s' cannot be set simultaneously", PARAM_CREATED_IN_LAST, PARAM_IN_NEW_CODE_PERIOD, PARAM_SINCE_LEAK_PERIOD)); + format("Parameters '%s' and '%s' cannot be set simultaneously", PARAM_CREATED_IN_LAST, PARAM_IN_NEW_CODE_PERIOD)); checkArgument(componentUuids.size() == 1, "One and only one component must be provided when searching in new code period"); ComponentDto component = componentUuids.iterator().next(); @@ -220,20 +219,9 @@ public class IssueQueryFactory { } private static boolean notInNewCodePeriod(SearchRequest request) { - Boolean sinceLeakPeriod = request.getSinceLeakPeriod(); Boolean inNewCodePeriod = request.getInNewCodePeriod(); - - checkArgument(validPeriodParameterValues(sinceLeakPeriod, inNewCodePeriod), - "If both provided, the following parameters %s and %s must match.", PARAM_SINCE_LEAK_PERIOD, PARAM_IN_NEW_CODE_PERIOD); - - sinceLeakPeriod = Boolean.TRUE.equals(sinceLeakPeriod); inNewCodePeriod = Boolean.TRUE.equals(inNewCodePeriod); - - return !sinceLeakPeriod && !inNewCodePeriod; - } - - private static boolean validPeriodParameterValues(@Nullable Boolean sinceLeakPeriod, @Nullable Boolean inNewCodePeriod) { - return atMostOneNonNullElement(sinceLeakPeriod, inNewCodePeriod) || !Boolean.logicalXor(sinceLeakPeriod, inNewCodePeriod); + return !inNewCodePeriod; } private Date findCreatedAfterFromComponentUuid(Optional snapshot) { 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 a48fe2ae93c..7f0c3568a45 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 @@ -147,28 +147,6 @@ public class IssueQueryFactoryTest { assertThat(query.ruleUuids()).containsExactly("non-existing-uuid"); } - @Test - public void leak_period_start_date_is_exclusive() { - long leakPeriodStart = addDays(new Date(), -14).getTime(); - - ComponentDto project = db.components().insertPublicProject(); - ComponentDto file = db.components().insertComponent(newFileDto(project)); - - SnapshotDto analysis = db.components().insertSnapshot(project, s -> s.setPeriodDate(leakPeriodStart)); - - SearchRequest request = new SearchRequest() - .setComponentUuids(Collections.singletonList(file.uuid())) - .setOnComponentOnly(true) - .setSinceLeakPeriod(true); - - IssueQuery query = underTest.create(request); - - assertThat(query.componentUuids()).containsOnly(file.uuid()); - assertThat(query.createdAfter().date()).isEqualTo(new Date(leakPeriodStart)); - assertThat(query.createdAfter().inclusive()).isFalse(); - assertThat(query.newCodeOnReference()).isNull(); - } - @Test public void in_new_code_period_start_date_is_exclusive() { long newCodePeriodStart = addDays(new Date(), -14).getTime(); @@ -191,30 +169,6 @@ public class IssueQueryFactoryTest { assertThat(query.newCodeOnReference()).isNull(); } - @Test - public void leak_period_relies_on_date_for_reference_branch_with_analysis_after_sonarqube_94() { - long leakPeriodStart = addDays(new Date(), -14).getTime(); - - ComponentDto project = db.components().insertPublicProject(); - ComponentDto file = db.components().insertComponent(newFileDto(project)); - - SnapshotDto analysis = db.components().insertSnapshot(project, s -> s.setPeriodMode(REFERENCE_BRANCH.name()) - .setPeriodParam("master")); - - MetricDto analysisMetric = db.measures().insertMetric(m -> m.setKey(ANALYSIS_FROM_SONARQUBE_9_4_KEY)); - db.measures().insertLiveMeasure(project, analysisMetric, measure -> measure.setData("true")); - - SearchRequest request = new SearchRequest() - .setComponentUuids(Collections.singletonList(file.uuid())) - .setOnComponentOnly(true) - .setSinceLeakPeriod(true); - - IssueQuery query = underTest.create(request); - - assertThat(query.componentUuids()).containsOnly(file.uuid()); - assertThat(query.newCodeOnReference()).isTrue(); - assertThat(query.createdAfter()).isNull(); - } @Test public void new_code_period_does_not_rely_on_date_for_reference_branch_with_analysis_after_sonarqube_94() { ComponentDto project = db.components().insertPublicProject(); @@ -380,43 +334,6 @@ public class IssueQueryFactoryTest { assertThat(result.viewUuids()).containsOnly(""); } - @Test - public void application_search_project_issues_on_leak_with_and_without_analysis_after_sonarqube_94() { - Date now = new Date(); - when(clock.millis()).thenReturn(now.getTime()); - ComponentDto project1 = db.components().insertPublicProject(); - SnapshotDto analysis1 = db.components().insertSnapshot(project1, s -> s.setPeriodDate(addDays(now, -14).getTime())); - ComponentDto project2 = db.components().insertPublicProject(); - db.components().insertSnapshot(project2, s -> s.setPeriodDate(null)); - ComponentDto project3 = db.components().insertPublicProject(); - ComponentDto project4 = db.components().insertPublicProject(); - SnapshotDto analysis3 =db.components().insertSnapshot(project3, - s -> s.setPeriodMode(REFERENCE_BRANCH.name()).setPeriodParam("master") - .setPeriodDate(addDays(now, -14).getTime())); - db.components().insertSnapshot(project4, - s -> s.setPeriodMode(REFERENCE_BRANCH.name()).setPeriodParam("master")); - ComponentDto application = db.components().insertPublicApplication(); - MetricDto analysisMetric = db.measures().insertMetric(m -> m.setKey(ANALYSIS_FROM_SONARQUBE_9_4_KEY)); - db.measures().insertLiveMeasure(project4, analysisMetric, measure -> measure.setData("true")); - db.components().insertComponents(newProjectCopy("PC1", project1, application)); - db.components().insertComponents(newProjectCopy("PC2", project2, application)); - db.components().insertComponents(newProjectCopy("PC3", project3, application)); - db.components().insertComponents(newProjectCopy("PC4", project4, application)); - userSession.registerApplication(application, project1, project2, project3, project4); - - IssueQuery result = underTest.create(new SearchRequest() - .setComponentUuids(singletonList(application.uuid())) - .setSinceLeakPeriod(true)); - - assertThat(result.createdAfterByProjectUuids()).hasSize(2); - assertThat(result.createdAfterByProjectUuids().entrySet()).extracting(Map.Entry::getKey, e -> e.getValue().date(), e -> e.getValue().inclusive()).containsOnly( - tuple(project1.uuid(), new Date(analysis1.getPeriodDate()), false), - tuple(project3.uuid(), new Date(analysis3.getPeriodDate()), false)); - assertThat(result.newCodeOnReferenceByProjectUuids()).hasSize(1); - assertThat(result.newCodeOnReferenceByProjectUuids()).containsOnly(project4.uuid()); - assertThat(result.viewUuids()).containsExactlyInAnyOrder(application.uuid()); - } - @Test public void application_search_project_issues_in_new_code_with_and_without_analysis_after_sonarqube_94() { Date now = new Date(); @@ -678,15 +595,6 @@ public class IssueQueryFactoryTest { } - @Test - public void fail_if_since_leak_period_and_created_after_set_at_the_same_time() { - assertThatThrownBy(() -> underTest.create(new SearchRequest() - .setSinceLeakPeriod(true) - .setCreatedAfter("2013-07-25T07:35:00+0100"))) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Parameters 'createdAfter' and 'inNewCodePeriod' or 'sinceLeakPeriod' cannot be set simultaneously"); - } - @Test public void fail_if_in_new_code_period_and_created_after_set_at_the_same_time() { SearchRequest searchRequest = new SearchRequest() @@ -695,18 +603,7 @@ public class IssueQueryFactoryTest { assertThatThrownBy(() -> underTest.create(searchRequest)) .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Parameters 'createdAfter' and 'inNewCodePeriod' or 'sinceLeakPeriod' cannot be set simultaneously"); - } - - @Test - public void fail_if_since_leak_period_and_created_in_last_set_at_the_same_time() { - SearchRequest searchRequest = new SearchRequest() - .setSinceLeakPeriod(true) - .setCreatedInLast("1y2m3w4d"); - - assertThatThrownBy(() -> underTest.create(searchRequest)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Parameters 'createdInLast' and 'inNewCodePeriod' or 'sinceLeakPeriod' cannot be set simultaneously"); + .hasMessageContaining("Parameters 'createdAfter' and 'inNewCodePeriod' cannot be set simultaneously"); } @Test @@ -717,7 +614,7 @@ public class IssueQueryFactoryTest { assertThatThrownBy(() -> underTest.create(searchRequest)) .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Parameters 'createdInLast' and 'inNewCodePeriod' or 'sinceLeakPeriod' cannot be set simultaneously"); + .hasMessageContaining("Parameters 'createdInLast' and 'inNewCodePeriod' cannot be set simultaneously"); } @Test @@ -736,18 +633,6 @@ public class IssueQueryFactoryTest { .hasMessageContaining("One and only one component must be provided when searching in new code period"); } - @Test - public void fail_if_several_components_provided_with_since_leak_period() { - ComponentDto project1 = db.components().insertPrivateProject(); - ComponentDto project2 = db.components().insertPrivateProject(); - - assertThatThrownBy(() -> underTest.create(new SearchRequest() - .setSinceLeakPeriod(true) - .setComponents(asList(project1.getKey(), project2.getKey())))) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("One and only one component must be provided when searching in new code period"); - } - @Test public void fail_if_several_components_provided_with_in_new_code_period() { ComponentDto project1 = db.components().insertPrivateProject(); 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 94514468038..865ff04bb01 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 @@ -123,7 +123,6 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RULES; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SANS_TOP_25; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SCOPES; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SEVERITIES; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SINCE_LEAK_PERIOD; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SONARSOURCE_SECURITY; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_STATUSES; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TAGS; @@ -195,6 +194,7 @@ public class SearchAction implements IssuesWsAction { + "
When issue indexation is in progress returns 503 service unavailable HTTP code.") .setSince("3.6") .setChangelog( + new Change("10.0", format("Parameter 'sinceLeakPeriod' is removed, please use '%s' instead", PARAM_IN_NEW_CODE_PERIOD)), new Change("9.8", "Add message formatting to issue and locations response"), new Change("9.8", "response fields 'total', 's', 'ps' have been deprecated, please use 'paging' object instead"), new Change("9.7", "Issues flows in the response may contain a description and a type"), @@ -204,7 +204,7 @@ public class SearchAction implements IssuesWsAction { new Change("9.6", "Response field 'ruleDescriptionContextKey' added"), new Change("9.6", "New possible value for 'additionalFields' parameter: 'ruleDescriptionContextKey'"), new Change("9.6", "Facet 'moduleUuids' is dropped."), - new Change("9.4", format("Parameter '%s' is deprecated, please use '%s' instead", PARAM_SINCE_LEAK_PERIOD, PARAM_IN_NEW_CODE_PERIOD)), + new Change("9.4", format("Parameter 'sinceLeakPeriod' is deprecated, please use '%s' instead", PARAM_IN_NEW_CODE_PERIOD)), new Change("9.2", "Response field 'quickFixAvailable' added"), new Change("9.1", "Deprecated parameters 'authors', 'facetMode' and 'moduleUuids' were dropped"), new Change("8.6", "Parameter 'timeZone' added"), @@ -342,11 +342,6 @@ public class SearchAction implements IssuesWsAction { "Accepted units are 'y' for year, 'm' for month, 'w' for week and 'd' for day. " + "If this parameter is set, createdAfter must not be set") .setExampleValue("1m2w (1 month 2 weeks)"); - action.createParam(PARAM_SINCE_LEAK_PERIOD) - .setDescription("To retrieve issues created since the leak period.
" + - "If this parameter is set to a truthy value, createdAfter must not be set and one component uuid or key must be provided.") - .setDeprecatedSince("9.4") - .setBooleanPossibleValues(); action.createParam(PARAM_IN_NEW_CODE_PERIOD) .setDescription("To retrieve issues created in the new code period.
" + "If this parameter is set to a truthy value, createdAfter must not be set and one component uuid or key must be provided.") @@ -565,7 +560,6 @@ public class SearchAction implements IssuesWsAction { .setResolutions(request.paramAsStrings(PARAM_RESOLUTIONS)) .setResolved(request.paramAsBoolean(PARAM_RESOLVED)) .setRules(request.paramAsStrings(PARAM_RULES)) - .setSinceLeakPeriod(request.paramAsBoolean(PARAM_SINCE_LEAK_PERIOD)) .setSort(request.param(Param.SORT)) .setSeverities(request.paramAsStrings(PARAM_SEVERITIES)) .setStatuses(request.paramAsStrings(PARAM_STATUSES)) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java index 53927524835..ff1890d72db 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java @@ -76,9 +76,9 @@ import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BRA import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_DIRECTORIES; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILES; +import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IN_NEW_CODE_PERIOD; 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_SINCE_LEAK_PERIOD; public class SearchActionComponentsTest { @@ -148,7 +148,7 @@ public class SearchActionComponentsTest { } @Test - public void search_since_leak_period_on_project() { + public void search_since_in_new_code_period_on_project() { ComponentDto project = db.components().insertPublicProject(p -> p.setKey("PK1")); ComponentDto file = db.components().insertComponent(newFileDto(project, null, "F1").setKey("FK1")); db.components().insertSnapshot(project, a -> a.setPeriodDate(parseDateTime("2015-09-03T00:00:00+0100").getTime())); @@ -164,7 +164,7 @@ public class SearchActionComponentsTest { ws.newRequest() .setParam(PARAM_COMPONENT_KEYS, project.getKey()) - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") + .setParam(PARAM_IN_NEW_CODE_PERIOD, "true") .execute() .assertJson(this.getClass(), "search_since_leak_period.json"); } @@ -406,7 +406,7 @@ public class SearchActionComponentsTest { } @Test - public void search_by_application_and_by_leak() { + public void search_by_application_and_by_new_code_period() { Date now = new Date(); RuleDto rule = db.rules().insertIssueRule(); ComponentDto application = db.components().insertPublicApplication(); @@ -428,7 +428,7 @@ public class SearchActionComponentsTest { SearchWsResponse result = ws.newRequest() .setParam(PARAM_COMPONENT_KEYS, application.getKey()) - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") + .setParam(PARAM_IN_NEW_CODE_PERIOD, "true") .executeProtobuf(SearchWsResponse.class); assertThat(result.getIssuesList()).extracting(Issue::getKey) @@ -460,7 +460,7 @@ public class SearchActionComponentsTest { } @Test - public void search_by_application_and_project_and_leak() { + public void search_by_application_and_project_and_new_code_period() { Date now = new Date(); RuleDto rule = db.rules().insertIssueRule(); ComponentDto application = db.components().insertPublicApplication(); @@ -483,7 +483,7 @@ public class SearchActionComponentsTest { SearchWsResponse result = ws.newRequest() .setParam(PARAM_COMPONENT_KEYS, application.getKey()) .setParam(PARAM_PROJECTS, project1.getKey()) - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") + .setParam(PARAM_IN_NEW_CODE_PERIOD, "true") .executeProtobuf(SearchWsResponse.class); assertThat(result.getIssuesList()).extracting(Issue::getKey) @@ -492,7 +492,7 @@ public class SearchActionComponentsTest { } @Test - public void search_by_application_and_by_leak_when_one_project_has_no_leak() { + public void search_by_application_and_by_new_code_period_when_one_project_has_no_leak() { Date now = new Date(); RuleDto rule = db.rules().insertIssueRule(); ComponentDto application = db.components().insertPublicApplication(); @@ -514,7 +514,7 @@ public class SearchActionComponentsTest { SearchWsResponse result = ws.newRequest() .setParam(PARAM_COMPONENT_KEYS, application.getKey()) - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") + .setParam(PARAM_IN_NEW_CODE_PERIOD, "true") .executeProtobuf(SearchWsResponse.class); assertThat(result.getIssuesList()).extracting(Issue::getKey) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java index 637df388b5a..5e0e0b0aaaf 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java @@ -123,7 +123,6 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_HIDE_COMMEN import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IN_NEW_CODE_PERIOD; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PULL_REQUEST; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RULES; -import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SINCE_LEAK_PERIOD; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_STATUSES; public class SearchActionTest { @@ -674,24 +673,12 @@ public class SearchActionTest { userSession.logIn(john); - ws.newRequest() - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") - .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY") - .execute() - .assertJson(this.getClass(), "filter_by_leak_period.json"); - ws.newRequest() .setParam(PARAM_IN_NEW_CODE_PERIOD, "true") .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY") .execute() .assertJson(this.getClass(), "filter_by_leak_period.json"); - ws.newRequest() - .setParam(PARAM_IN_NEW_CODE_PERIOD, "true") - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") - .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY") - .execute() - .assertJson(this.getClass(), "filter_by_leak_period.json"); } @Test @@ -700,17 +687,6 @@ public class SearchActionTest { .setParam(PARAM_IN_NEW_CODE_PERIOD, "false") .execute() .assertJson(this.getClass(), "default_page_size_is_100.json"); - - ws.newRequest() - .setParam(PARAM_SINCE_LEAK_PERIOD, "false") - .execute() - .assertJson(this.getClass(), "default_page_size_is_100.json"); - - ws.newRequest() - .setParam(PARAM_IN_NEW_CODE_PERIOD, "false") - .setParam(PARAM_SINCE_LEAK_PERIOD, "false") - .execute() - .assertJson(this.getClass(), "default_page_size_is_100.json"); } @Test @@ -746,19 +722,6 @@ public class SearchActionTest { ws.newRequest() .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY") - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") - .execute() - .assertJson(this.getClass(), "empty_result.json"); - - ws.newRequest() - .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY") - .setParam(PARAM_IN_NEW_CODE_PERIOD, "true") - .execute() - .assertJson(this.getClass(), "empty_result.json"); - - ws.newRequest() - .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY") - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") .setParam(PARAM_IN_NEW_CODE_PERIOD, "true") .execute() .assertJson(this.getClass(), "empty_result.json"); @@ -799,21 +762,6 @@ public class SearchActionTest { ws.newRequest() .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY") .setParam(PARAM_PULL_REQUEST, "pr") - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") - .execute() - .assertJson(this.getClass(), "filter_by_leak_period_has_no_effect_on_prs.json"); - - ws.newRequest() - .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY") - .setParam(PARAM_PULL_REQUEST, "pr") - .setParam(PARAM_IN_NEW_CODE_PERIOD, "true") - .execute() - .assertJson(this.getClass(), "filter_by_leak_period_has_no_effect_on_prs.json"); - - ws.newRequest() - .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY") - .setParam(PARAM_PULL_REQUEST, "pr") - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") .setParam(PARAM_IN_NEW_CODE_PERIOD, "true") .execute() .assertJson(this.getClass(), "filter_by_leak_period_has_no_effect_on_prs.json"); @@ -1798,7 +1746,7 @@ public class SearchActionTest { assertThat(def.params()).extracting("key").containsExactlyInAnyOrder( "additionalFields", "asc", "assigned", "assignees", "author", "componentKeys", "branch", "pullRequest", "createdAfter", "createdAt", "createdBefore", "createdInLast", "directories", "facets", "files", "issues", "scopes", "languages", "onComponentOnly", - "p", "projects", "ps", "resolutions", "resolved", "rules", "s", "severities", "sinceLeakPeriod", "statuses", "tags", "types", "pciDss-3.2", "pciDss-4.0", "owaspAsvs-4.0", + "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"); @@ -1812,26 +1760,6 @@ public class SearchActionTest { "This parameter is mostly used by the Issues page, please prefer usage of the componentKeys parameter. If this parameter is set, projectUuids must not be set."); } - @Test - public void fail_when_mismatching_sinceLeakPeriod_and_inNewCodePeriod() { - - TestRequest requestLeakTrueNewCodeFalse = ws.newRequest() - .setParam(PARAM_SINCE_LEAK_PERIOD, "true") - .setParam(PARAM_IN_NEW_CODE_PERIOD, "false"); - - assertThatThrownBy(requestLeakTrueNewCodeFalse::execute) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("If both provided, the following parameters sinceLeakPeriod and inNewCodePeriod must match."); - - TestRequest requestLeakFalseNewCodeTrue = ws.newRequest() - .setParam(PARAM_SINCE_LEAK_PERIOD, "false") - .setParam(PARAM_IN_NEW_CODE_PERIOD, "true"); - - assertThatThrownBy(requestLeakFalseNewCodeTrue::execute) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("If both provided, the following parameters sinceLeakPeriod and inNewCodePeriod must match."); - } - @Test public void search_when_additional_field_set_return_context_key() { insertIssues(issue -> issue.setRuleDescriptionContextKey("spring")); 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 2429dbd5857..b9f417bc9b8 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 @@ -98,8 +98,6 @@ public class IssuesWsParameters { public static final String PARAM_CREATED_AT = "createdAt"; public static final String PARAM_CREATED_BEFORE = "createdBefore"; public static final String PARAM_CREATED_IN_LAST = "createdInLast"; - @Deprecated - public static final String PARAM_SINCE_LEAK_PERIOD = "sinceLeakPeriod"; public static final String PARAM_IN_NEW_CODE_PERIOD = "inNewCodePeriod"; public static final String PARAM_ASC = "asc"; public static final String PARAM_ADDITIONAL_FIELDS = "additionalFields"; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/IssuesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/IssuesService.java index 0dba523d2be..c648deeb239 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/IssuesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/IssuesService.java @@ -246,7 +246,7 @@ public class IssuesService extends BaseService { .setParam("sansTop25", request.getSansTop25() == null ? null : request.getSansTop25().stream().collect(Collectors.joining(","))) .setParam("sonarsourceSecurity", request.getSonarsourceSecurity() == null ? null : request.getSonarsourceSecurity().stream().collect(Collectors.joining(","))) .setParam("severities", request.getSeverities() == null ? null : request.getSeverities().stream().collect(Collectors.joining(","))) - .setParam("sinceLeakPeriod", request.getSinceLeakPeriod()) + .setParam("inNewCodePeriod", request.isInNewCodePeriod()) .setParam("statuses", request.getStatuses() == null ? null : request.getStatuses().stream().collect(Collectors.joining(","))) .setParam("tags", request.getTags() == null ? null : request.getTags().stream().collect(Collectors.joining(","))) .setParam("types", request.getTypes() == null ? null : request.getTypes().stream().collect(Collectors.joining(","))), diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/SearchRequest.java index 88570cad9c3..47cc8d0a06c 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/SearchRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issues/SearchRequest.java @@ -62,7 +62,7 @@ public class SearchRequest { private String s; private List sansTop25; private List severities; - private String sinceLeakPeriod; + private String inNewCodePeriod; private List sonarsourceSecurity; private List statuses; private List tags; @@ -543,13 +543,13 @@ public class SearchRequest { *
  • "no"
  • * */ - public SearchRequest setSinceLeakPeriod(String sinceLeakPeriod) { - this.sinceLeakPeriod = sinceLeakPeriod; + public SearchRequest setInNewCodePeriod(String inNewCodePeriod) { + this.inNewCodePeriod = inNewCodePeriod; return this; } - public String getSinceLeakPeriod() { - return sinceLeakPeriod; + public String isInNewCodePeriod() { + return inNewCodePeriod; } /**