From: Duarte Meneses Date: Thu, 31 Oct 2019 15:54:42 +0000 (-0500) Subject: SONAR-11154 Remove parameters deprecated before 6.7 in Quality Profile WS X-Git-Tag: 8.1.0.31237~109 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a24a5da046e76d34acbac4721161db569b20751d;p=sonarqube.git SONAR-11154 Remove parameters deprecated before 6.7 in Quality Profile WS --- diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java index 2c2a1be92ed..4dfac52d0a7 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java @@ -48,8 +48,8 @@ import org.sonar.db.qualityprofile.QProfileDto; import org.sonar.db.user.UserDto; import org.sonar.server.component.ComponentFinder; import org.sonar.server.exceptions.NotFoundException; -import org.sonar.server.user.UserSession; import org.sonar.server.language.LanguageParamUtils; +import org.sonar.server.user.UserSession; import org.sonarqube.ws.Qualityprofiles.SearchWsResponse; import org.sonarqube.ws.Qualityprofiles.SearchWsResponse.QualityProfile; @@ -69,6 +69,7 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; public class SearchAction implements QProfileWsAction { @@ -114,6 +115,8 @@ public class SearchAction implements QProfileWsAction { action.createParam(PARAM_PROJECT) .setDescription("Project key") + // still used by Scanner for MSBuild 4.7.1 + .setDeprecatedKey(PARAM_PROJECT_KEY, "6.5") .setExampleValue(KEY_PROJECT_EXAMPLE_001); action diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java index 48aaffc97a6..19855552558 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java @@ -68,6 +68,7 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT; +import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; public class SearchActionTest { @@ -274,6 +275,26 @@ public class SearchActionTest { .doesNotContain(defaultProfileOnXoo1.getKee(), profileOnXoo1.getKee()); } + @Test + public void filter_on_deprecated_project_key_and_default() { + ComponentDto project = db.components().insertPrivateProject(); + QProfileDto profileOnXoo1 = db.qualityProfiles().insert(db.getDefaultOrganization(), q -> q.setLanguage(XOO1.getKey())); + QProfileDto defaultProfileOnXoo1 = db.qualityProfiles().insert(db.getDefaultOrganization(), q -> q.setLanguage(XOO1.getKey())); + QProfileDto defaultProfileOnXoo2 = db.qualityProfiles().insert(db.getDefaultOrganization(), q -> q.setLanguage(XOO2.getKey())); + db.qualityProfiles().associateWithProject(project, profileOnXoo1); + db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2); + + SearchWsResponse result = call(ws.newRequest() + .setParam(PARAM_PROJECT_KEY, project.getDbKey()) + .setParam(PARAM_DEFAULTS, "true")); + + assertThat(result.getProfilesList()) + .extracting(QualityProfile::getKey) + .containsExactlyInAnyOrder(defaultProfileOnXoo2.getKee()) + .doesNotContain(defaultProfileOnXoo1.getKee(), profileOnXoo1.getKee()); + } + + @Test public void empty_when_filtering_on_project_and_no_language_installed() { WsActionTester ws = new WsActionTester(new SearchAction(userSession, new Languages(), dbClient, qProfileWsSupport, new ComponentFinder(dbClient, null))); @@ -562,6 +583,7 @@ public class SearchActionTest { WebService.Param projectKey = definition.param("project"); assertThat(projectKey.description()).isEqualTo("Project key"); + assertThat(projectKey.deprecatedKey()).isEqualTo("projectKey"); WebService.Param language = definition.param("language"); assertThat(language.possibleValues()).containsExactly("xoo1", "xoo2"); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java index 691cc75743f..5a06772162e 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java @@ -60,6 +60,7 @@ public class QualityProfileWsParameters { public static final String PARAM_KEY = "key"; public static final String PARAM_QUALITY_PROFILE = "qualityProfile"; public static final String PARAM_PROJECT = "project"; + public static final String PARAM_PROJECT_KEY = "projectKey"; public static final String PARAM_QUERY = "q"; public static final String PARAM_RESET = "reset"; public static final String PARAM_RULE = "rule";