diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2020-05-01 11:17:38 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-05-25 20:05:21 +0000 |
commit | 16b2b85fc200856e65175663bbe2477012be9275 (patch) | |
tree | fb11f07b89e3c20da338cfa980d70b4a8d716609 /server/sonar-webserver-webapi | |
parent | 85b940dd935f57860f26dff7f1bfaa9de1ba8af2 (diff) | |
download | sonarqube-16b2b85fc200856e65175663bbe2477012be9275.tar.gz sonarqube-16b2b85fc200856e65175663bbe2477012be9275.zip |
SONAR-13221 Update method and var names
Diffstat (limited to 'server/sonar-webserver-webapi')
10 files changed, 85 insertions, 85 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java index 7af1096bf34..faae9d77150 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java @@ -89,7 +89,7 @@ public class CreateAction implements CustomMeasuresWsAction { .setExampleValue(KEY_PROJECT_EXAMPLE_001); action.createParam(PARAM_METRIC_ID) - .setDescription("Metric id") + .setDescription("Metric uuid") .setExampleValue("16"); action.createParam(PARAM_METRIC_KEY) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChange.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChange.java index ef1e94e77e9..a2e8c6ed841 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChange.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChange.java @@ -23,15 +23,15 @@ import javax.annotation.Nullable; public class GroupPermissionChange extends PermissionChange { - private final GroupUuidOrAnyone groupId; + private final GroupUuidOrAnyone group; public GroupPermissionChange(Operation operation, String permission, @Nullable ProjectUuid projectUuid, - GroupUuidOrAnyone groupId, PermissionService permissionService) { - super(operation, groupId.getOrganizationUuid(), permission, projectUuid, permissionService); - this.groupId = groupId; + GroupUuidOrAnyone group, PermissionService permissionService) { + super(operation, group.getOrganizationUuid(), permission, projectUuid, permissionService); + this.group = group; } - public GroupUuidOrAnyone getGroupIdOrAnyone() { - return groupId; + public GroupUuidOrAnyone getGroupUuidOrAnyone() { + return group; } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java index 90049daf441..ee5eb869f2f 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java @@ -79,7 +79,7 @@ public class GroupPermissionChanger { private static boolean isAttemptToRemovePermissionFromAnyoneOnPrivateComponent(GroupPermissionChange change, ProjectUuid project) { return project.isPrivate() && change.getOperation() == REMOVE - && change.getGroupIdOrAnyone().isAnyone(); + && change.getGroupUuidOrAnyone().isAnyone(); } private static void ensureConsistencyWithVisibility(GroupPermissionChange change) { @@ -96,7 +96,7 @@ public class GroupPermissionChanger { private static boolean isAttemptToAddPermissionToAnyoneOnPrivateComponent(GroupPermissionChange change, ProjectUuid project) { return project.isPrivate() && change.getOperation() == ADD - && change.getGroupIdOrAnyone().isAnyone(); + && change.getGroupUuidOrAnyone().isAnyone(); } private static boolean isAttemptToRemovePublicPermissionFromPublicComponent(GroupPermissionChange change, ProjectUuid project) { @@ -110,12 +110,12 @@ public class GroupPermissionChanger { return false; } - validateNotAnyoneAndAdminPermission(change.getPermission(), change.getGroupIdOrAnyone()); + validateNotAnyoneAndAdminPermission(change.getPermission(), change.getGroupUuidOrAnyone()); GroupPermissionDto addedDto = new GroupPermissionDto() .setUuid(uuidFactory.create()) .setRole(change.getPermission()) .setOrganizationUuid(change.getOrganizationUuid()) - .setGroupUuid(change.getGroupIdOrAnyone().getUuid()) + .setGroupUuid(change.getGroupUuidOrAnyone().getUuid()) .setComponentUuid(change.getProjectUuid()); dbClient.groupPermissionDao().insert(dbSession, addedDto); return true; @@ -134,7 +134,7 @@ public class GroupPermissionChanger { dbClient.groupPermissionDao().delete(dbSession, change.getPermission(), change.getOrganizationUuid(), - change.getGroupIdOrAnyone().getUuid(), + change.getGroupUuidOrAnyone().getUuid(), change.getProjectUuid()); return true; } @@ -144,21 +144,21 @@ public class GroupPermissionChanger { if (projectUuid != null) { return dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, change.getOrganizationUuid(), - change.getGroupIdOrAnyone().getUuid(), + change.getGroupUuidOrAnyone().getUuid(), projectUuid); } return dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, change.getOrganizationUuid(), - change.getGroupIdOrAnyone().getUuid()); + change.getGroupUuidOrAnyone().getUuid()); } private void checkIfRemainingGlobalAdministrators(DbSession dbSession, GroupPermissionChange change) { if (SYSTEM_ADMIN.equals(change.getPermission()) && - !change.getGroupIdOrAnyone().isAnyone() && + !change.getGroupUuidOrAnyone().isAnyone() && change.getProjectUuid() == null) { // removing global admin permission from group int remaining = dbClient.authorizationDao().countUsersWithGlobalPermissionExcludingGroup(dbSession, - change.getOrganizationUuid(), SYSTEM_ADMIN, change.getGroupIdOrAnyone().getUuid()); + change.getOrganizationUuid(), SYSTEM_ADMIN, change.getGroupUuidOrAnyone().getUuid()); checkRequest(remaining > 0, "Last group with permission '%s'. Permission cannot be removed.", SYSTEM_ADMIN); } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java index e26bd27d765..19394220cfa 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java @@ -75,15 +75,15 @@ public class AddGroupToTemplateAction implements PermissionsWsAction { public void handle(Request request, Response response) { try (DbSession dbSession = dbClient.openSession(false)) { String permission = request.mandatoryParam(PARAM_PERMISSION); - GroupUuidOrAnyone groupId = support.findGroup(dbSession, request); - checkRequest(!SYSTEM_ADMIN.equals(permission) || !groupId.isAnyone(), + GroupUuidOrAnyone group = support.findGroup(dbSession, request); + checkRequest(!SYSTEM_ADMIN.equals(permission) || !group.isAnyone(), format("It is not possible to add the '%s' permission to the group 'Anyone'.", permission)); PermissionTemplateDto template = support.findTemplate(dbSession, fromRequest(request)); checkGlobalAdmin(userSession, template.getOrganizationUuid()); - if (!groupAlreadyAdded(dbSession, template.getUuid(), permission, groupId)) { - dbClient.permissionTemplateDao().insertGroupPermission(dbSession, template.getUuid(), groupId.getUuid(), permission); + if (!groupAlreadyAdded(dbSession, template.getUuid(), permission, group)) { + dbClient.permissionTemplateDao().insertGroupPermission(dbSession, template.getUuid(), group.getUuid(), permission); dbSession.commit(); } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java index 3c2de719d2d..3556ebd2618 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java @@ -74,10 +74,10 @@ public class RemoveGroupFromTemplateAction implements PermissionsWsAction { String permission = request.mandatoryParam(PARAM_PERMISSION); PermissionTemplateDto template = wsSupport.findTemplate(dbSession, WsTemplateRef.fromRequest(request)); checkGlobalAdmin(userSession, template.getOrganizationUuid()); - GroupUuidOrAnyone groupId = wsSupport.findGroup(dbSession, request); - checkArgument(groupId.getOrganizationUuid().equals(template.getOrganizationUuid()), "Group and template are on different organizations"); + GroupUuidOrAnyone group = wsSupport.findGroup(dbSession, request); + checkArgument(group.getOrganizationUuid().equals(template.getOrganizationUuid()), "Group and template are on different organizations"); - dbClient.permissionTemplateDao().deleteGroupPermission(dbSession, template.getUuid(), groupId.getUuid(), permission); + dbClient.permissionTemplateDao().deleteGroupPermission(dbSession, template.getUuid(), group.getUuid(), permission); dbSession.commit(); } response.noContent(); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/UpdateVisibilityAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/UpdateVisibilityAction.java index 77afd13dcc3..5c6130790fe 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/UpdateVisibilityAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/UpdateVisibilityAction.java @@ -145,7 +145,7 @@ public class UpdateVisibilityAction implements ProjectsWsAction { // grant UserRole.CODEVIEWER and UserRole.USER to any group or user with at least one permission on project PUBLIC_PERMISSIONS.forEach(permission -> { dbClient.groupPermissionDao().selectGroupUuidsWithPermissionOnProjectBut(dbSession, component.uuid(), permission) - .forEach(groupId -> insertProjectPermissionOnGroup(dbSession, component, permission, groupId)); + .forEach(group -> insertProjectPermissionOnGroup(dbSession, component, permission, group)); dbClient.userPermissionDao().selectUserIdsWithPermissionOnProjectBut(dbSession, component.uuid(), permission) .forEach(userId -> insertProjectPermissionOnUser(dbSession, component, permission, userId)); }); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java index 3335565ebb1..42dc1e5f7ab 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java @@ -94,8 +94,8 @@ public class AddUserAction implements UserGroupsWsAction { } } - private boolean isMemberOf(DbSession dbSession, UserDto user, GroupDto groupId) { - return dbClient.groupMembershipDao().selectGroupUuidsByUserId(dbSession, user.getId()).contains(groupId.getUuid()); + private boolean isMemberOf(DbSession dbSession, UserDto user, GroupDto group) { + return dbClient.groupMembershipDao().selectGroupUuidsByUserId(dbSession, user.getId()).contains(group.getUuid()); } private void checkMembership(DbSession dbSession, OrganizationDto organization, UserDto user) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java index 976a43162a4..a892c57e898 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java @@ -87,15 +87,15 @@ public class DeleteAction implements UserGroupsWsAction { checkArgument(remaining > 0, "The last system admin group cannot be deleted"); } - private void removeGroupPermissions(DbSession dbSession, GroupDto groupId) { - dbClient.roleDao().deleteGroupRolesByGroupUuid(dbSession, groupId.getUuid()); + private void removeGroupPermissions(DbSession dbSession, GroupDto group) { + dbClient.roleDao().deleteGroupRolesByGroupUuid(dbSession, group.getUuid()); } - private void removeFromPermissionTemplates(DbSession dbSession, GroupDto groupId) { - dbClient.permissionTemplateDao().deleteByGroup(dbSession, groupId.getUuid()); + private void removeFromPermissionTemplates(DbSession dbSession, GroupDto group) { + dbClient.permissionTemplateDao().deleteByGroup(dbSession, group.getUuid()); } - private void removeGroupMembers(DbSession dbSession, GroupDto groupId) { - dbClient.userGroupDao().deleteByGroupUuid(dbSession, groupId.getUuid()); + private void removeGroupMembers(DbSession dbSession, GroupDto group) { + dbClient.userGroupDao().deleteByGroupUuid(dbSession, group.getUuid()); } } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java index d9f392873ad..0d1e98af366 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java @@ -72,29 +72,29 @@ public class GroupPermissionChangerTest { @Test public void apply_adds_organization_permission_to_group() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupUuid, permissionService)); assertThat(db.users().selectGroupPermissions(group, null)).containsOnly(GlobalPermissions.QUALITY_GATE_ADMIN); } @Test public void apply_adds_organization_permission_to_group_AnyOne() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.forAnyone(org.getUuid()); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupUuid, permissionService)); assertThat(db.users().selectAnyonePermissions(org, null)).containsOnly(GlobalPermissions.QUALITY_GATE_ADMIN); } @Test public void apply_fails_with_BadRequestException_when_adding_any_permission_to_group_AnyOne_on_private_project() { - GroupUuidOrAnyone anyOneGroupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone anyOneGroup = GroupUuidOrAnyone.forAnyone(org.getUuid()); permissionService.getAllProjectPermissions() .forEach(perm -> { try { - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, perm, new ProjectUuid(privateProject), anyOneGroupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, perm, new ProjectUuid(privateProject), anyOneGroup, permissionService)); fail("a BadRequestException should have been thrown"); } catch (BadRequestException e) { assertThat(e).hasMessage("No permission can be granted to Anyone on a private component"); @@ -107,10 +107,10 @@ public class GroupPermissionChangerTest { permissionService.getAllProjectPermissions() .forEach(this::unsafeInsertProjectPermissionOnAnyone); - GroupUuidOrAnyone anyOneGroupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone anyOneGroup = GroupUuidOrAnyone.forAnyone(org.getUuid()); permissionService.getAllProjectPermissions() .forEach(perm -> { - apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, perm, new ProjectUuid(privateProject), anyOneGroupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, perm, new ProjectUuid(privateProject), anyOneGroup, permissionService)); assertThat(db.users().selectAnyonePermissions(org, privateProject)).contains(perm); }); @@ -142,9 +142,9 @@ public class GroupPermissionChangerTest { } private void applyAddsPermissionToGroupOnPrivateProject(String permission) { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, permission, new ProjectUuid(privateProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, permission, new ProjectUuid(privateProject), groupUuid, permissionService)); assertThat(db.users().selectGroupPermissions(group, null)).isEmpty(); assertThat(db.users().selectGroupPermissions(group, privateProject)).containsOnly(permission); @@ -176,78 +176,78 @@ public class GroupPermissionChangerTest { } private void applyRemovesPermissionFromGroupOnPrivateProject(String permission) { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); db.users().insertProjectPermissionOnGroup(group, permission, privateProject); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, permission, new ProjectUuid(privateProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, permission, new ProjectUuid(privateProject), groupUuid, permissionService)); assertThat(db.users().selectGroupPermissions(group, privateProject)).containsOnly(permission); } @Test public void apply_has_no_effect_when_adding_USER_permission_to_group_AnyOne_on_a_public_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.forAnyone(org.getUuid()); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.USER, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.USER, new ProjectUuid(publicProject), groupUuid, permissionService)); assertThat(db.users().selectAnyonePermissions(org, publicProject)).isEmpty(); } @Test public void apply_has_no_effect_when_adding_CODEVIEWER_permission_to_group_AnyOne_on_a_public_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.forAnyone(org.getUuid()); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.CODEVIEWER, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.CODEVIEWER, new ProjectUuid(publicProject), groupUuid, permissionService)); assertThat(db.users().selectAnyonePermissions(org, publicProject)).isEmpty(); } @Test public void apply_fails_with_BadRequestException_when_adding_permission_ADMIN_to_group_AnyOne_on_a_public_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.forAnyone(org.getUuid()); expectedException.expect(BadRequestException.class); expectedException.expectMessage("It is not possible to add the 'admin' permission to group 'Anyone'"); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ADMIN, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ADMIN, new ProjectUuid(publicProject), groupUuid, permissionService)); } @Test public void apply_adds_permission_ISSUE_ADMIN_to_group_AnyOne_on_a_public_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.forAnyone(org.getUuid()); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectUuid(publicProject), groupUuid, permissionService)); assertThat(db.users().selectAnyonePermissions(org, publicProject)).containsOnly(UserRole.ISSUE_ADMIN); } @Test public void apply_adds_permission_SCAN_EXECUTION_to_group_AnyOne_on_a_public_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.forAnyone(org.getUuid()); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.SCAN_EXECUTION, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.SCAN_EXECUTION, new ProjectUuid(publicProject), groupUuid, permissionService)); assertThat(db.users().selectAnyonePermissions(org, publicProject)).containsOnly(GlobalPermissions.SCAN_EXECUTION); } @Test public void apply_fails_with_BadRequestException_when_removing_USER_permission_from_group_AnyOne_on_a_public_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.forAnyone(org.getUuid()); expectedException.expect(BadRequestException.class); expectedException.expectMessage("Permission user can't be removed from a public component"); - apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.USER, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.USER, new ProjectUuid(publicProject), groupUuid, permissionService)); } @Test public void apply_fails_with_BadRequestException_when_removing_CODEVIEWER_permission_from_group_AnyOne_on_a_public_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.forAnyone(org.getUuid()); expectedException.expect(BadRequestException.class); expectedException.expectMessage("Permission codeviewer can't be removed from a public component"); - apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.CODEVIEWER, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.CODEVIEWER, new ProjectUuid(publicProject), groupUuid, permissionService)); } @Test @@ -266,40 +266,40 @@ public class GroupPermissionChangerTest { } private void applyRemovesPermissionFromGroupAnyOneOnAPublicProject(String permission) { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid()); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.forAnyone(org.getUuid()); db.users().insertProjectPermissionOnAnyone(permission, publicProject); - apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, permission, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, permission, new ProjectUuid(publicProject), groupUuid, permissionService)); assertThat(db.users().selectAnyonePermissions(org, publicProject)).isEmpty(); } @Test public void apply_fails_with_BadRequestException_when_removing_USER_permission_from_a_group_on_a_public_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); expectedException.expect(BadRequestException.class); expectedException.expectMessage("Permission user can't be removed from a public component"); - apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.USER, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.USER, new ProjectUuid(publicProject), groupUuid, permissionService)); } @Test public void apply_fails_with_BadRequestException_when_removing_CODEVIEWER_permission_from_a_group_on_a_public_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); expectedException.expect(BadRequestException.class); expectedException.expectMessage("Permission codeviewer can't be removed from a public component"); - apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.CODEVIEWER, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.CODEVIEWER, new ProjectUuid(publicProject), groupUuid, permissionService)); } @Test public void add_permission_to_anyone() { OrganizationDto defaultOrganization = db.getDefaultOrganization(); - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(defaultOrganization.getUuid()); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.forAnyone(defaultOrganization.getUuid()); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupUuid, permissionService)); assertThat(db.users().selectGroupPermissions(group, null)).isEmpty(); assertThat(db.users().selectAnyonePermissions(defaultOrganization, null)).containsOnly(GlobalPermissions.QUALITY_GATE_ADMIN); @@ -307,24 +307,24 @@ public class GroupPermissionChangerTest { @Test public void do_nothing_when_adding_permission_that_already_exists() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); db.users().insertPermissionOnGroup(group, ADMINISTER_QUALITY_GATES); - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, ADMINISTER_QUALITY_GATES.getKey(), null, groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, ADMINISTER_QUALITY_GATES.getKey(), null, groupUuid, permissionService)); assertThat(db.users().selectGroupPermissions(group, null)).containsOnly(ADMINISTER_QUALITY_GATES.getKey()); } @Test public void fail_to_add_global_permission_but_SCAN_and_ADMIN_on_private_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); permissionService.getAllOrganizationPermissions().stream() .map(OrganizationPermission::getKey) .filter(perm -> !UserRole.ADMIN.equals(perm) && !GlobalPermissions.SCAN_EXECUTION.equals(perm)) .forEach(perm -> { try { - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, perm, new ProjectUuid(privateProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, perm, new ProjectUuid(privateProject), groupUuid, permissionService)); fail("a BadRequestException should have been thrown for permission " + perm); } catch (BadRequestException e) { assertThat(e).hasMessage("Invalid project permission '" + perm + @@ -335,14 +335,14 @@ public class GroupPermissionChangerTest { @Test public void fail_to_add_global_permission_but_SCAN_and_ADMIN_on_public_project() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); permissionService.getAllOrganizationPermissions().stream() .map(OrganizationPermission::getKey) .filter(perm -> !UserRole.ADMIN.equals(perm) && !GlobalPermissions.SCAN_EXECUTION.equals(perm)) .forEach(perm -> { try { - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, perm, new ProjectUuid(publicProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, perm, new ProjectUuid(publicProject), groupUuid, permissionService)); fail("a BadRequestException should have been thrown for permission " + perm); } catch (BadRequestException e) { assertThat(e).hasMessage("Invalid project permission '" + perm + @@ -353,14 +353,14 @@ public class GroupPermissionChangerTest { @Test public void fail_to_add_project_permission_but_SCAN_and_ADMIN_on_global_group() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); permissionService.getAllProjectPermissions() .stream() .filter(perm -> !GlobalPermissions.SCAN_EXECUTION.equals(perm) && !OrganizationPermission.ADMINISTER.getKey().equals(perm)) .forEach(permission -> { try { - apply(new GroupPermissionChange(PermissionChange.Operation.ADD, permission, null, groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.ADD, permission, null, groupUuid, permissionService)); fail("a BadRequestException should have been thrown for permission " + permission); } catch (BadRequestException e) { assertThat(e).hasMessage("Invalid global permission '" + permission + "'. Valid values are [admin, gateadmin, profileadmin, provisioning, scan]"); @@ -370,23 +370,23 @@ public class GroupPermissionChangerTest { @Test public void remove_permission_from_group() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); db.users().insertPermissionOnGroup(group, ADMINISTER_QUALITY_GATES); db.users().insertPermissionOnGroup(group, PROVISION_PROJECTS); - apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, ADMINISTER_QUALITY_GATES.getKey(), null, groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, ADMINISTER_QUALITY_GATES.getKey(), null, groupUuid, permissionService)); assertThat(db.users().selectGroupPermissions(group, null)).containsOnly(PROVISION_PROJECTS.getKey()); } @Test public void remove_project_permission_from_group() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); db.users().insertPermissionOnGroup(group, ADMINISTER_QUALITY_GATES); db.users().insertProjectPermissionOnGroup(group, UserRole.ISSUE_ADMIN, privateProject); db.users().insertProjectPermissionOnGroup(group, UserRole.CODEVIEWER, privateProject); - apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectUuid(privateProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectUuid(privateProject), groupUuid, permissionService)); assertThat(db.users().selectGroupPermissions(group, null)).containsOnly(ADMINISTER_QUALITY_GATES.getKey()); assertThat(db.users().selectGroupPermissions(group, privateProject)).containsOnly(UserRole.CODEVIEWER); @@ -394,9 +394,9 @@ public class GroupPermissionChangerTest { @Test public void do_not_fail_if_removing_a_permission_that_does_not_exist() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); - apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectUuid(privateProject), groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectUuid(privateProject), groupUuid, permissionService)); assertThat(db.users().selectGroupPermissions(group, null)).isEmpty(); assertThat(db.users().selectGroupPermissions(group, privateProject)).isEmpty(); @@ -404,23 +404,23 @@ public class GroupPermissionChangerTest { @Test public void fail_to_remove_admin_permission_if_no_more_admins() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); db.users().insertPermissionOnGroup(group, ADMINISTER); expectedException.expect(BadRequestException.class); expectedException.expectMessage("Last group with permission 'admin'. Permission cannot be removed."); - underTest.apply(db.getSession(), new GroupPermissionChange(PermissionChange.Operation.REMOVE, ADMINISTER.getKey(), null, groupId, permissionService)); + underTest.apply(db.getSession(), new GroupPermissionChange(PermissionChange.Operation.REMOVE, ADMINISTER.getKey(), null, groupUuid, permissionService)); } @Test public void remove_admin_group_if_still_other_admins() { - GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group); + GroupUuidOrAnyone groupUuid = GroupUuidOrAnyone.from(group); db.users().insertPermissionOnGroup(group, ADMINISTER); UserDto admin = db.users().insertUser(); db.users().insertPermissionOnUser(org, admin, ADMINISTER); - apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, ADMINISTER.getKey(), null, groupId, permissionService)); + apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, ADMINISTER.getKey(), null, groupUuid, permissionService)); assertThat(db.users().selectGroupPermissions(group, null)).isEmpty(); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/RegisterQualityGatesTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/RegisterQualityGatesTest.java index 730a3f00104..8afbcc0d844 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/RegisterQualityGatesTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualitygate/RegisterQualityGatesTest.java @@ -211,7 +211,7 @@ public class RegisterQualityGatesTest { } @Test - public void builtin_quality_gate_with_incorrect_metricId_should_not_throw_an_exception() { + public void builtin_quality_gate_with_incorrect_metricuuid_should_not_throw_an_exception() { insertMetrics(); QualityGateConditionDto conditionDto = new QualityGateConditionDto() .setUuid(Uuids.createFast()) |