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;
.setHandler(this);
action
- .createParam(PARAM_UUID)
- .setDescription("Project UUID")
+ .createParam(PARAM_ID)
+ .setDescription("Project id")
.setExampleValue("ce4c03d6-430f-40a9-b777-ad877c00aa4d");
action
@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);
return dbClient.componentDao().selectByKey(dbSession, key);
}
- throw new IllegalArgumentException("UUID or key must be provided");
+ throw new IllegalArgumentException("Id or key must be provided");
}
}
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 {
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();
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();
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();
}
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
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
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) {