]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11154 Remove parameters deprecated before 6.7 in Quality Profile WS
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 31 Oct 2019 15:54:42 +0000 (10:54 -0500)
committersonartech <sonartech@sonarsource.com>
Wed, 6 Nov 2019 09:04:33 +0000 (10:04 +0100)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java
sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfileWsParameters.java

index 2c2a1be92edcfa6fbe5703130ce66346736d3a2f..4dfac52d0a7b1410c0889b6944232771412b6d30 100644 (file)
@@ -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
index 48aaffc97a6d8b7ba225ded4878235af094e9871..198555525583d5ab15337352ce5c22f71f1eac59 100644 (file)
@@ -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");
index 691cc75743f487cf528623ca54e815830a5c5e10..5a06772162e8951f87343160795e60a9a0910b66 100644 (file)
@@ -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";