]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6599 ws api/projects/delete update description and error message with ids inste...
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 3 Jun 2015 08:18:12 +0000 (10:18 +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/DeleteAction.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java

index 4665a53ff2dbeabd5d40905d7fc11f003597b312..46a8659d7818162c80f94f5abfe1b64bf02723da 100644 (file)
@@ -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");
   }
 }
index 37d48248a46e99cb0df4d002893ef1a8162e83ac..404e52eba116a62f7c6c1d46501f19cee212edaa 100644 (file)
@@ -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) {