]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6528 ws api/projects/bulk_delete update description and error message with...
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 3 Jun 2015 08:15:14 +0000 (10:15 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 3 Jun 2015 08:18:46 +0000 (10:18 +0200)
server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java

index 52293fdc6c856d251df0231e76282d2e86ffca34..8c36a26c2c7e3d085d8b9ca9197a600e69b95743 100644 (file)
@@ -38,7 +38,7 @@ import java.util.List;
 public class BulkDeleteAction implements ProjectsWsAction {
   private static final String ACTION = "bulk_delete";
 
-  public static final String PARAM_UUIDS = "ids";
+  public static final String PARAM_IDS = "ids";
   public static final String PARAM_KEYS = "keys";
 
   private final ComponentCleanerService componentCleanerService;
@@ -61,8 +61,8 @@ public class BulkDeleteAction implements ProjectsWsAction {
       .setHandler(this);
 
     action
-      .createParam(PARAM_UUIDS)
-      .setDescription("List of project UUIDs to delete")
+      .createParam(PARAM_IDS)
+      .setDescription("List of project ids to delete")
       .setExampleValue("ce4c03d6-430f-40a9-b777-ad877c00aa4d,c526ef20-131b-4486-9357-063fa64b5079");
 
     action
@@ -74,7 +74,7 @@ public class BulkDeleteAction implements ProjectsWsAction {
   @Override
   public void handle(Request request, Response response) throws Exception {
     userSession.checkGlobalPermission(UserRole.ADMIN);
-    List<String> uuids = request.paramAsStrings(PARAM_UUIDS);
+    List<String> uuids = request.paramAsStrings(PARAM_IDS);
     List<String> keys = request.paramAsStrings(PARAM_KEYS);
 
     DbSession dbSession = dbClient.openSession(false);
@@ -96,6 +96,6 @@ public class BulkDeleteAction implements ProjectsWsAction {
       return dbClient.componentDao().selectByKeys(dbSession, keys);
     }
 
-    throw new IllegalArgumentException("UUIDs or keys must be provided");
+    throw new IllegalArgumentException("ids or keys must be provided");
   }
 }
index c447745f4e0a76d59d0316fde202597b72d1e037..40385f5e2e622cefff16fe9e9e203f1ede38e222 100644 (file)
@@ -76,7 +76,7 @@ import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.sonar.server.project.ws.BulkDeleteAction.PARAM_KEYS;
-import static org.sonar.server.project.ws.BulkDeleteAction.PARAM_UUIDS;
+import static org.sonar.server.project.ws.BulkDeleteAction.PARAM_IDS;
 
 @Category(DbTests.class)
 public class BulkDeleteActionTest {
@@ -127,7 +127,7 @@ public class BulkDeleteActionTest {
     long snapshotId4 = insertNewProjectInDbAndReturnSnapshotId(4);
 
     ws.newPostRequest("api/projects", ACTION)
-      .setParam(PARAM_UUIDS, "project-uuid-1, project-uuid-3, project-uuid-4").execute();
+      .setParam(PARAM_IDS, "project-uuid-1, project-uuid-3, project-uuid-4").execute();
     dbSession.commit();
 
     assertThat(dbClient.componentDao().selectByUuids(dbSession, Arrays.asList("project-uuid-1", "project-uuid-3", "project-uuid-4"))).isEmpty();
@@ -180,7 +180,7 @@ public class BulkDeleteActionTest {
   public void web_service_returns_204() throws Exception {
     insertNewProjectInDbAndReturnSnapshotId(1);
 
-    WsTester.Result result = ws.newPostRequest("api/projects", ACTION).setParam(PARAM_UUIDS, "project-uuid-1").execute();
+    WsTester.Result result = ws.newPostRequest("api/projects", ACTION).setParam(PARAM_IDS, "project-uuid-1").execute();
 
     result.assertNoContent();
   }
@@ -190,7 +190,7 @@ public class BulkDeleteActionTest {
     userSessionRule.setGlobalPermissions(UserRole.CODEVIEWER, UserRole.ISSUE_ADMIN, UserRole.USER);
     expectedException.expect(ForbiddenException.class);
 
-    ws.newPostRequest("api/projects", ACTION).setParam(PARAM_UUIDS, "whatever-the-uuid").execute();
+    ws.newPostRequest("api/projects", ACTION).setParam(PARAM_IDS, "whatever-the-uuid").execute();
   }
 
   @Test
@@ -199,7 +199,7 @@ public class BulkDeleteActionTest {
     dbClient.componentDao().insert(dbSession, ComponentTesting.newFileDto(ComponentTesting.newProjectDto(), "file-uuid"));
     dbSession.commit();
 
-    ws.newPostRequest("api/projects", ACTION).setParam(PARAM_UUIDS, "file-uuid").execute();
+    ws.newPostRequest("api/projects", ACTION).setParam(PARAM_IDS, "file-uuid").execute();
   }
 
   @Test
@@ -209,7 +209,7 @@ public class BulkDeleteActionTest {
     dbSession.commit();
     when(resourceType.getBooleanProperty(anyString())).thenReturn(false);
 
-    ws.newPostRequest("api/projects", ACTION).setParam(PARAM_UUIDS, "project-uuid").execute();
+    ws.newPostRequest("api/projects", ACTION).setParam(PARAM_IDS, "project-uuid").execute();
   }
 
   private long insertNewProjectInDbAndReturnSnapshotId(int id) {