From fc83fa0377c95e54e21e961032a31a73d68e8df0 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Wed, 3 Jun 2015 10:15:14 +0200 Subject: [PATCH] SONAR-6528 ws api/projects/bulk_delete update description and error message with ids instead of uuids --- .../sonar/server/project/ws/BulkDeleteAction.java | 10 +++++----- .../server/project/ws/BulkDeleteActionTest.java | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java index 52293fdc6c8..8c36a26c2c7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java @@ -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 uuids = request.paramAsStrings(PARAM_UUIDS); + List uuids = request.paramAsStrings(PARAM_IDS); List 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"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java index c447745f4e0..40385f5e2e6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java @@ -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) { -- 2.39.5