diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-06-03 10:18:12 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-06-03 10:18:46 +0200 |
commit | 7be0e5c0c17eba998061c5bae8bda85aeac7fdb6 (patch) | |
tree | caefd66f1450ca2160dbf898adaff0821b5c9a2b | |
parent | fc83fa0377c95e54e21e961032a31a73d68e8df0 (diff) | |
download | sonarqube-7be0e5c0c17eba998061c5bae8bda85aeac7fdb6.tar.gz sonarqube-7be0e5c0c17eba998061c5bae8bda85aeac7fdb6.zip |
SONAR-6599 ws api/projects/delete update description and error message with ids instead of uuids
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/project/ws/DeleteAction.java | 10 | ||||
-rw-r--r-- | server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java | 14 |
2 files changed, 12 insertions, 12 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/DeleteAction.java index 4665a53ff2d..46a8659d781 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/DeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/DeleteAction.java @@ -37,7 +37,7 @@ import org.sonar.server.user.UserSession; public class DeleteAction implements ProjectsWsAction { private static final String ACTION = "delete"; - public static final String PARAM_UUID = "id"; + public static final String PARAM_ID = "id"; public static final String PARAM_KEY = "key"; private final ComponentCleanerService componentCleanerService; @@ -60,8 +60,8 @@ public class DeleteAction implements ProjectsWsAction { .setHandler(this); action - .createParam(PARAM_UUID) - .setDescription("Project UUID") + .createParam(PARAM_ID) + .setDescription("Project id") .setExampleValue("ce4c03d6-430f-40a9-b777-ad877c00aa4d"); action @@ -72,7 +72,7 @@ public class DeleteAction implements ProjectsWsAction { @Override public void handle(Request request, Response response) throws Exception { - String uuid = request.param(PARAM_UUID); + String uuid = request.param(PARAM_ID); String key = request.param(PARAM_KEY); checkPermissions(uuid, key); @@ -109,6 +109,6 @@ public class DeleteAction implements ProjectsWsAction { return dbClient.componentDao().selectByKey(dbSession, key); } - throw new IllegalArgumentException("UUID or key must be provided"); + throw new IllegalArgumentException("Id or key must be provided"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java index 37d48248a46..404e52eba11 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java @@ -74,7 +74,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.DeleteAction.PARAM_KEY; -import static org.sonar.server.project.ws.DeleteAction.PARAM_UUID; +import static org.sonar.server.project.ws.DeleteAction.PARAM_ID; @Category(DbTests.class) public class DeleteActionTest { @@ -123,7 +123,7 @@ public class DeleteActionTest { long snapshotId2 = insertNewProjectInDbAndReturnSnapshotId(2); newRequest() - .setParam(PARAM_UUID, "project-uuid-1").execute(); + .setParam(PARAM_ID, "project-uuid-1").execute(); dbSession.commit(); assertThat(dbClient.componentDao().selectNullableByUuid(dbSession, "project-uuid-1")).isNull(); @@ -152,7 +152,7 @@ public class DeleteActionTest { insertNewProjectInDbAndReturnSnapshotId(1); userSessionRule.login("login").addProjectUuidPermissions(UserRole.ADMIN, "project-uuid-1"); - newRequest().setParam(PARAM_UUID, "project-uuid-1").execute(); + newRequest().setParam(PARAM_ID, "project-uuid-1").execute(); dbSession.commit(); assertThat(dbClient.componentDao().selectNullableByUuid(dbSession, "project-uuid-1")).isNull(); @@ -193,7 +193,7 @@ public class DeleteActionTest { public void web_service_returns_204() throws Exception { insertNewProjectInDbAndReturnSnapshotId(1); - WsTester.Result result = newRequest().setParam(PARAM_UUID, "project-uuid-1").execute(); + WsTester.Result result = newRequest().setParam(PARAM_ID, "project-uuid-1").execute(); result.assertNoContent(); } @@ -203,7 +203,7 @@ public class DeleteActionTest { userSessionRule.setGlobalPermissions(UserRole.CODEVIEWER, UserRole.ISSUE_ADMIN, UserRole.USER); expectedException.expect(ForbiddenException.class); - newRequest().setParam(PARAM_UUID, "whatever-the-uuid").execute(); + newRequest().setParam(PARAM_ID, "whatever-the-uuid").execute(); } @Test @@ -212,7 +212,7 @@ public class DeleteActionTest { dbClient.componentDao().insert(dbSession, ComponentTesting.newFileDto(ComponentTesting.newProjectDto(), "file-uuid")); dbSession.commit(); - newRequest().setParam(PARAM_UUID, "file-uuid").execute(); + newRequest().setParam(PARAM_ID, "file-uuid").execute(); } @Test @@ -222,7 +222,7 @@ public class DeleteActionTest { dbSession.commit(); when(resourceType.getBooleanProperty(anyString())).thenReturn(false); - newRequest().setParam(PARAM_UUID, "project-uuid").execute(); + newRequest().setParam(PARAM_ID, "project-uuid").execute(); } private long insertNewProjectInDbAndReturnSnapshotId(int id) { |