diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2020-04-22 13:26:47 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-05-25 20:05:20 +0000 |
commit | bde9afd00f1ee86a583892355a256b0d9250a57a (patch) | |
tree | dfbc0ef20c54086a4445aa20ed01535ed3f86523 /server/sonar-webserver-webapi | |
parent | ffd176a905d758ebcbf120a60e7bec1a96cdd559 (diff) | |
download | sonarqube-bde9afd00f1ee86a583892355a256b0d9250a57a.tar.gz sonarqube-bde9afd00f1ee86a583892355a256b0d9250a57a.zip |
SONAR-13221 Feedback from review and fix tests
Diffstat (limited to 'server/sonar-webserver-webapi')
27 files changed, 99 insertions, 54 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/WebIssueStorage.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/WebIssueStorage.java index 0e1c538ae80..d5d9467840b 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/WebIssueStorage.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/WebIssueStorage.java @@ -33,6 +33,7 @@ import org.sonar.api.rules.RuleFinder; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.System2; import org.sonar.core.issue.DefaultIssue; +import org.sonar.core.util.UuidFactory; import org.sonar.db.BatchSession; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -61,12 +62,14 @@ public class WebIssueStorage extends IssueStorage { private final RuleFinder ruleFinder; private final DbClient dbClient; private final IssueIndexer indexer; + private final UuidFactory uuidFactory; - public WebIssueStorage(System2 system2, DbClient dbClient, RuleFinder ruleFinder, IssueIndexer indexer) { + public WebIssueStorage(System2 system2, DbClient dbClient, RuleFinder ruleFinder, IssueIndexer indexer, UuidFactory uuidFactory) { this.system2 = system2; this.dbClient = dbClient; this.ruleFinder = ruleFinder; this.indexer = indexer; + this.uuidFactory = uuidFactory; } protected DbClient getDbClient() { @@ -106,7 +109,7 @@ public class WebIssueStorage extends IssueStorage { for (DefaultIssue issue : issuesToInsert) { IssueDto issueDto = doInsert(session, now, issue); inserted.add(issueDto); - insertChanges(issueChangeMapper, issue); + insertChanges(issueChangeMapper, issue, uuidFactory); if (count > BatchSession.MAX_BATCH_SIZE) { session.commit(); count = 0; @@ -146,7 +149,7 @@ public class WebIssueStorage extends IssueStorage { for (DefaultIssue issue : issuesToUpdate) { IssueDto issueDto = doUpdate(dbSession, now, issue); updated.add(issueDto); - insertChanges(issueChangeMapper, issue); + insertChanges(issueChangeMapper, issue, uuidFactory); } dbSession.commit(); } 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 e46ba28cc76..65f0d401556 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 @@ -21,6 +21,7 @@ package org.sonar.server.permission; import java.util.List; import org.sonar.core.permission.GlobalPermissions; +import org.sonar.core.util.UuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.permission.GroupPermissionDto; @@ -35,9 +36,11 @@ import static org.sonar.server.permission.PermissionChange.Operation.REMOVE; public class GroupPermissionChanger { private final DbClient dbClient; + private final UuidFactory uuidFactory; - public GroupPermissionChanger(DbClient dbClient) { + public GroupPermissionChanger(DbClient dbClient, UuidFactory uuidFactory) { this.dbClient = dbClient; + this.uuidFactory = uuidFactory; } public boolean apply(DbSession dbSession, GroupPermissionChange change) { @@ -109,6 +112,7 @@ public class GroupPermissionChanger { validateNotAnyoneAndAdminPermission(change.getPermission(), change.getGroupIdOrAnyone()); GroupPermissionDto addedDto = new GroupPermissionDto() + .setUuid(uuidFactory.create()) .setRole(change.getPermission()) .setOrganizationUuid(change.getOrganizationUuid()) .setGroupId(change.getGroupIdOrAnyone().getId()) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionTemplateService.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionTemplateService.java index 866ce7efd9e..30898ea5f1b 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionTemplateService.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionTemplateService.java @@ -30,7 +30,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.sonar.api.resources.Qualifiers; import org.sonar.api.server.ServerSide; -import org.sonar.core.util.Uuids; +import org.sonar.core.util.UuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; @@ -59,13 +59,15 @@ public class PermissionTemplateService { private final ProjectIndexers projectIndexers; private final UserSession userSession; private final DefaultTemplatesResolver defaultTemplatesResolver; + private final UuidFactory uuidFactory; public PermissionTemplateService(DbClient dbClient, ProjectIndexers projectIndexers, UserSession userSession, - DefaultTemplatesResolver defaultTemplatesResolver) { + DefaultTemplatesResolver defaultTemplatesResolver, UuidFactory uuidFactory) { this.dbClient = dbClient; this.projectIndexers = projectIndexers; this.userSession = userSession; this.defaultTemplatesResolver = defaultTemplatesResolver; + this.uuidFactory = uuidFactory; } public boolean wouldUserHaveScanPermissionWithDefaultTemplate(DbSession dbSession, String organizationUuid, @Nullable Integer userId, String projectKey) { @@ -130,7 +132,7 @@ public class PermissionTemplateService { .stream() .filter(up -> permissionValidForProject(project, up.getPermission())) .forEach(up -> { - UserPermissionDto dto = new UserPermissionDto(Uuids.create(), organizationUuid, up.getPermission(), up.getUserId(), project.uuid()); + UserPermissionDto dto = new UserPermissionDto(uuidFactory.create(), organizationUuid, up.getPermission(), up.getUserId(), project.uuid()); dbClient.userPermissionDao().insert(dbSession, dto); }); @@ -141,6 +143,7 @@ public class PermissionTemplateService { .filter(gp -> permissionValidForProject(project, gp.getPermission())) .forEach(gp -> { GroupPermissionDto dto = new GroupPermissionDto() + .setUuid(uuidFactory.create()) .setOrganizationUuid(organizationUuid) .setGroupId(isAnyone(gp.getGroupName()) ? null : gp.getGroupId()) .setRole(gp.getPermission()) @@ -159,7 +162,7 @@ public class PermissionTemplateService { .filter(up -> permissionValidForProject(project, up.getPermission())) .filter(characteristic -> !permissionsForCurrentUserAlreadyInDb.contains(characteristic.getPermission())) .forEach(c -> { - UserPermissionDto dto = new UserPermissionDto(Uuids.create(), organizationUuid, c.getPermission(), projectCreatorUserId, project.uuid()); + UserPermissionDto dto = new UserPermissionDto(uuidFactory.create(), organizationUuid, c.getPermission(), projectCreatorUserId, project.uuid()); dbClient.userPermissionDao().insert(dbSession, dto); }); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/UserPermissionChanger.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/UserPermissionChanger.java index 9e5d7a1abbc..a8c610a8cd6 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/UserPermissionChanger.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/UserPermissionChanger.java @@ -20,7 +20,7 @@ package org.sonar.server.permission; import java.util.List; -import org.sonar.core.util.Uuids; +import org.sonar.core.util.UuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.permission.UserPermissionDto; @@ -37,9 +37,11 @@ import static org.sonar.server.permission.PermissionChange.Operation.REMOVE; public class UserPermissionChanger { private final DbClient dbClient; + private final UuidFactory uuidFactory; - public UserPermissionChanger(DbClient dbClient) { + public UserPermissionChanger(DbClient dbClient, UuidFactory uuidFactory) { this.dbClient = dbClient; + this.uuidFactory = uuidFactory; } public boolean apply(DbSession dbSession, UserPermissionChange change) { @@ -91,7 +93,7 @@ public class UserPermissionChanger { if (loadExistingPermissions(dbSession, change).contains(change.getPermission())) { return false; } - UserPermissionDto dto = new UserPermissionDto(Uuids.create(), change.getOrganizationUuid(), change.getPermission(), change.getUserId().getId(), change.getProjectUuid()); + UserPermissionDto dto = new UserPermissionDto(uuidFactory.create(), change.getOrganizationUuid(), change.getPermission(), change.getUserId().getId(), change.getProjectUuid()); dbClient.userPermissionDao().insert(dbSession, dto); return true; } 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 c2b8e385142..ef16e285491 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 @@ -26,6 +26,7 @@ import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.web.UserRole; +import org.sonar.core.util.UuidFactory; import org.sonar.core.util.Uuids; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -58,14 +59,16 @@ public class UpdateVisibilityAction implements ProjectsWsAction { private final UserSession userSession; private final ProjectIndexers projectIndexers; private final ProjectsWsSupport projectsWsSupport; + private final UuidFactory uuidFactory; public UpdateVisibilityAction(DbClient dbClient, ComponentFinder componentFinder, UserSession userSession, - ProjectIndexers projectIndexers, ProjectsWsSupport projectsWsSupport) { + ProjectIndexers projectIndexers, ProjectsWsSupport projectsWsSupport, UuidFactory uuidFactory) { this.dbClient = dbClient; this.componentFinder = componentFinder; this.userSession = userSession; this.projectIndexers = projectIndexers; this.projectsWsSupport = projectsWsSupport; + this.uuidFactory = uuidFactory; } public void define(WebService.NewController context) { @@ -154,6 +157,7 @@ public class UpdateVisibilityAction implements ProjectsWsAction { private void insertProjectPermissionOnGroup(DbSession dbSession, ComponentDto component, String permission, Integer groupId) { dbClient.groupPermissionDao().insert(dbSession, new GroupPermissionDto() + .setUuid(uuidFactory.create()) .setOrganizationUuid(component.getOrganizationUuid()) .setComponentUuid(component.uuid()) .setGroupId(groupId) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/CreateConditionAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/CreateConditionAction.java index 16674d7b102..7931f60c019 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/CreateConditionAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/CreateConditionAction.java @@ -88,8 +88,7 @@ public class CreateConditionAction implements QualityGatesWsAction { wsSupport.checkCanEdit(qualityGate); QualityGateConditionDto condition = qualityGateConditionsUpdater.createCondition(dbSession, qualityGate, metric, operator, error); CreateConditionResponse.Builder createConditionResponse = CreateConditionResponse.newBuilder() - // TODO - //.setId(condition.getUuid()) + .setId(condition.getUuid()) .setMetric(condition.getMetricKey()) .setError(condition.getErrorThreshold()) .setOp(condition.getOperator()); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/DeleteConditionAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/DeleteConditionAction.java index 7060e275513..7c766d1ccdd 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/DeleteConditionAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/DeleteConditionAction.java @@ -53,7 +53,7 @@ public class DeleteConditionAction implements QualityGatesWsAction { createCondition .createParam(PARAM_ID) .setRequired(true) - .setDescription("Condition ID") + .setDescription("Condition UUID") .setExampleValue("2"); wsSupport.createOrganizationParam(createCondition); @@ -61,7 +61,6 @@ public class DeleteConditionAction implements QualityGatesWsAction { @Override public void handle(Request request, Response response) { - // TODO String conditionUuid = request.mandatoryParam(PARAM_ID); try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = wsSupport.getOrganization(dbSession, request); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java index ae96b03eca8..fa41487a015 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java @@ -140,8 +140,7 @@ public class ShowAction implements QualityGatesWsAction { MetricDto metric = metricsById.get(metricId); checkState(metric != null, "Could not find metric with id %s", metricId); ShowWsResponse.Condition.Builder builder = ShowWsResponse.Condition.newBuilder() - // TODO - //.setId(condition.getUuid()) + .setId(condition.getUuid()) .setMetric(metric.getKey()) .setOp(condition.getOperator()); ofNullable(condition.getErrorThreshold()).ifPresent(builder::setError); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/UpdateConditionAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/UpdateConditionAction.java index a6a34ba65c8..f52ba2346c6 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/UpdateConditionAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/UpdateConditionAction.java @@ -90,8 +90,7 @@ public class UpdateConditionAction implements QualityGatesWsAction { wsSupport.checkCanEdit(qualityGateDto); QualityGateConditionDto updatedCondition = qualityGateConditionsUpdater.updateCondition(dbSession, condition, metric, operator, error); UpdateConditionResponse.Builder updateConditionResponse = UpdateConditionResponse.newBuilder() - // TODO - // .setId(updatedCondition.getUuid()) + .setId(updatedCondition.getUuid()) .setMetric(updatedCondition.getMetricKey()) .setError(updatedCondition.getErrorThreshold()) .setOp(updatedCondition.getOperator()); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java index 818684e3b97..9ea07039ae1 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java @@ -32,6 +32,7 @@ import org.sonar.api.impl.utils.TestSystem2; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.DefaultIssueComment; import org.sonar.core.issue.IssueChangeContext; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; @@ -62,7 +63,8 @@ public class WebIssueStorageTest { private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); private IssueIndexer issueIndexer = mock(IssueIndexer.class); - private WebIssueStorage underTest = new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(db.getDbClient(), defaultOrganizationProvider), issueIndexer); + private WebIssueStorage underTest = new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(db.getDbClient(), defaultOrganizationProvider), issueIndexer, + new SequenceUuidFactory()); @Test public void load_component_id_from_db() { @@ -212,7 +214,7 @@ public class WebIssueStorageTest { .containsEntry("STATUS", updated.status()) .containsEntry("SEVERITY", updated.severity()); - List<Map<String, Object>> rows = db.select("select * from issue_changes order by id"); + List<Map<String, Object>> rows = db.select("select * from issue_changes order by uuid"); assertThat(rows).hasSize(2); assertThat(rows.get(0)) .extracting("CHANGE_DATA", "CHANGE_TYPE", "USER_LOGIN") diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java index 338fa2ee99d..35a94aea042 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java @@ -29,6 +29,7 @@ import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; @@ -94,9 +95,11 @@ public class AddCommentActionTest { private IssueDbTester issueDbTester = new IssueDbTester(dbTester); private IssueIndexer issueIndexer = new IssueIndexer(es.client(), dbClient, new IssueIteratorFactory(dbClient)); - private WebIssueStorage serverIssueStorage = new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer); + private WebIssueStorage serverIssueStorage = new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer, + new SequenceUuidFactory()); private TestIssueChangePostProcessor issueChangePostProcessor = new TestIssueChangePostProcessor(); - private IssueUpdater issueUpdater = new IssueUpdater(dbClient, serverIssueStorage, mock(NotificationManager.class), issueChangePostProcessor, new IssuesChangesNotificationSerializer()); + private IssueUpdater issueUpdater = new IssueUpdater(dbClient, serverIssueStorage, mock(NotificationManager.class), issueChangePostProcessor, + new IssuesChangesNotificationSerializer()); private OperationResponseWriter responseWriter = mock(OperationResponseWriter.class); private ArgumentCaptor<SearchResponseData> preloadedSearchResponseDataCaptor = ArgumentCaptor.forClass(SearchResponseData.class); @@ -225,8 +228,8 @@ public class AddCommentActionTest { UserDto user = dbTester.users().insertUser("john"); userSession.logIn(user) .addProjectPermission(permission, - dbClient.componentDao().selectByUuid(dbTester.getSession(), issueDto.getProjectUuid()).get(), - dbClient.componentDao().selectByUuid(dbTester.getSession(), issueDto.getComponentUuid()).get()); + dbClient.componentDao().selectByUuid(dbTester.getSession(), issueDto.getProjectUuid()).get(), + dbClient.componentDao().selectByUuid(dbTester.getSession(), issueDto.getComponentUuid()).get()); } } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java index 8824f5bff5e..59ed3bcaa39 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java @@ -26,6 +26,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.impl.utils.TestSystem2; import org.sonar.api.rules.RuleType; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -58,7 +59,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.sonar.api.rules.RuleType.CODE_SMELL; -import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT; import static org.sonar.api.web.UserRole.CODEVIEWER; import static org.sonar.api.web.UserRole.USER; import static org.sonar.server.tester.UserSessionRule.standalone; @@ -93,7 +93,7 @@ public class AssignActionTest { private IssuesChangesNotificationSerializer issuesChangesSerializer = new IssuesChangesNotificationSerializer(); private AssignAction underTest = new AssignAction(system2, userSession, dbClient, new IssueFinder(dbClient, userSession), new IssueFieldsSetter(), new IssueUpdater(dbClient, - new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer), + new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer, new SequenceUuidFactory()), notificationManager, issueChangePostProcessor, issuesChangesSerializer), responseWriter); private WsActionTester ws = new WsActionTester(underTest); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java index c428152f718..7b344d9a872 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java @@ -34,6 +34,7 @@ import org.sonar.api.impl.utils.TestSystem2; import org.sonar.api.rules.RuleType; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.BranchType; @@ -119,7 +120,7 @@ public class BulkChangeActionTest { private IssueWorkflow issueWorkflow = new IssueWorkflow(new FunctionExecutor(issueFieldsSetter), issueFieldsSetter); private WebIssueStorage issueStorage = new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, TestDefaultOrganizationProvider.from(db)), - new IssueIndexer(es.client(), dbClient, new IssueIteratorFactory(dbClient))); + new IssueIndexer(es.client(), dbClient, new IssueIteratorFactory(dbClient)), new SequenceUuidFactory()); private NotificationManager notificationManager = mock(NotificationManager.class); private TestIssueChangePostProcessor issueChangePostProcessor = new TestIssueChangePostProcessor(); private IssuesChangesNotificationSerializer issuesChangesSerializer = new IssuesChangesNotificationSerializer(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java index 78fe3209594..965c9639f77 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java @@ -30,6 +30,7 @@ import org.sonar.api.rules.RuleType; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.utils.System2; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; @@ -101,8 +102,8 @@ public class DoTransitionActionTest { private TestIssueChangePostProcessor issueChangePostProcessor = new TestIssueChangePostProcessor(); private IssuesChangesNotificationSerializer issuesChangesSerializer = new IssuesChangesNotificationSerializer(); private IssueUpdater issueUpdater = new IssueUpdater(dbClient, - new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer), mock(NotificationManager.class), - issueChangePostProcessor, issuesChangesSerializer); + new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer, new SequenceUuidFactory()), + mock(NotificationManager.class), issueChangePostProcessor, issuesChangesSerializer); private ArgumentCaptor<SearchResponseData> preloadedSearchResponseDataCaptor = ArgumentCaptor.forClass(SearchResponseData.class); private WsAction underTest = new DoTransitionAction(dbClient, userSession, new IssueFinder(dbClient, userSession), issueUpdater, transitionService, responseWriter, system2); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java index 6923a3b09d2..3eb6c835bae 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java @@ -28,6 +28,7 @@ import org.sonar.api.rule.RuleStatus; import org.sonar.api.utils.System2; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.IssueChangeContext; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.BranchType; @@ -89,8 +90,8 @@ public class IssueUpdaterTest { private TestIssueChangePostProcessor issueChangePostProcessor = new TestIssueChangePostProcessor(); private IssuesChangesNotificationSerializer issuesChangesSerializer = new IssuesChangesNotificationSerializer(); private IssueUpdater underTest = new IssueUpdater(dbClient, - new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer), notificationManager, issueChangePostProcessor, - issuesChangesSerializer); + new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer, new SequenceUuidFactory()), notificationManager, + issueChangePostProcessor, issuesChangesSerializer); @Test public void update_issue() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java index 3e19eb053d8..bfcf9261561 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java @@ -41,6 +41,7 @@ import org.sonar.api.rules.RuleType; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.Durations; import org.sonar.api.utils.System2; +import org.sonar.core.util.Uuids; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -283,14 +284,18 @@ public class SearchActionTest { RuleDefinitionDto rule = newIssueRule().getDefinition(); IssueDto issue = db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")); dbClient.issueChangeDao().insert(session, - new IssueChangeDto().setIssueKey(issue.getKey()) + new IssueChangeDto() + .setUuid(Uuids.createFast()) + .setIssueKey(issue.getKey()) .setKey("COMMENT-ABCD") .setChangeData("*My comment*") .setChangeType(IssueChangeDto.TYPE_COMMENT) .setUserUuid(john.getUuid()) .setIssueChangeCreationDate(parseDateTime("2014-09-09T12:00:00+0000").getTime())); dbClient.issueChangeDao().insert(session, - new IssueChangeDto().setIssueKey(issue.getKey()) + new IssueChangeDto() + .setUuid(Uuids.createFast()) + .setIssueKey(issue.getKey()) .setKey("COMMENT-ABCE") .setChangeData("Another comment") .setChangeType(IssueChangeDto.TYPE_COMMENT) @@ -316,14 +321,18 @@ public class SearchActionTest { RuleDefinitionDto rule = newIssueRule().getDefinition(); IssueDto issue = db.issues().insertIssue(rule, project, file, i -> i.setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2")); dbClient.issueChangeDao().insert(session, - new IssueChangeDto().setIssueKey(issue.getKey()) + new IssueChangeDto() + .setUuid(Uuids.createFast()) + .setIssueKey(issue.getKey()) .setKey("COMMENT-ABCD") .setChangeData("*My comment*") .setChangeType(IssueChangeDto.TYPE_COMMENT) .setUserUuid(john.getUuid()) .setCreatedAt(parseDateTime("2014-09-09T12:00:00+0000").getTime())); dbClient.issueChangeDao().insert(session, - new IssueChangeDto().setIssueKey(issue.getKey()) + new IssueChangeDto() + .setUuid(Uuids.createFast()) + .setIssueKey(issue.getKey()) .setKey("COMMENT-ABCE") .setChangeData("Another comment") .setChangeType(IssueChangeDto.TYPE_COMMENT) @@ -1146,6 +1155,7 @@ public class SearchActionTest { private void grantPermissionToAnyone(ComponentDto project, String permission) { dbClient.groupPermissionDao().insert(session, new GroupPermissionDto() + .setUuid(Uuids.createFast()) .setOrganizationUuid(project.getOrganizationUuid()) .setGroupId(null) .setComponentUuid(project.uuid()) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java index 2f3c2d358e9..02ce8ef49d0 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java @@ -30,6 +30,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.core.issue.FieldDiffs; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; @@ -93,8 +94,8 @@ public class SetSeverityActionTest { private IssuesChangesNotificationSerializer issuesChangesSerializer = new IssuesChangesNotificationSerializer(); private WsActionTester tester = new WsActionTester(new SetSeverityAction(userSession, dbClient, new IssueFinder(dbClient, userSession), new IssueFieldsSetter(), new IssueUpdater(dbClient, - new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer), mock(NotificationManager.class), issueChangePostProcessor, - issuesChangesSerializer), + new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer, new SequenceUuidFactory()), + mock(NotificationManager.class), issueChangePostProcessor, issuesChangesSerializer), responseWriter)); @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java index f7962b41382..4b03a24eba7 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTagsActionTest.java @@ -34,6 +34,7 @@ import org.sonar.api.server.ws.WebService.Action; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; import org.sonar.core.issue.FieldDiffs; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; @@ -94,9 +95,8 @@ public class SetTagsActionTest { private WsActionTester ws = new WsActionTester(new SetTagsAction(userSession, dbClient, new IssueFinder(dbClient, userSession), new IssueFieldsSetter(), new IssueUpdater(dbClient, - new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer), mock(NotificationManager.class), - issueChangePostProcessor, issuesChangesSerializer), - responseWriter)); + new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer, new SequenceUuidFactory()), + mock(NotificationManager.class), issueChangePostProcessor, issuesChangesSerializer), responseWriter)); @Test public void set_tags() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java index f55e37287f4..57a4d4edb7c 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java @@ -39,6 +39,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.core.issue.FieldDiffs; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; @@ -106,9 +107,8 @@ public class SetTypeActionTest { private IssuesChangesNotificationSerializer issuesChangesSerializer = new IssuesChangesNotificationSerializer(); private WsActionTester tester = new WsActionTester(new SetTypeAction(userSession, dbClient, new IssueFinder(dbClient, userSession), new IssueFieldsSetter(), new IssueUpdater(dbClient, - new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer), mock(NotificationManager.class), - issueChangePostProcessor, issuesChangesSerializer), - responseWriter, system2)); + new WebIssueStorage(system2, dbClient, new DefaultRuleFinder(dbClient, defaultOrganizationProvider), issueIndexer, new SequenceUuidFactory()), + mock(NotificationManager.class), issueChangePostProcessor, issuesChangesSerializer), responseWriter, system2)); @Test @UseDataProvider("allTypesFromToExceptHotspots") 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 a6cd4be7af0..e2e8a9558ac 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 @@ -29,6 +29,8 @@ import org.sonar.api.resources.ResourceTypes; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.core.permission.GlobalPermissions; +import org.sonar.core.util.SequenceUuidFactory; +import org.sonar.core.util.Uuids; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ResourceTypesRule; @@ -54,7 +56,7 @@ public class GroupPermissionChangerTest { private ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); private PermissionService permissionService = new PermissionServiceImpl(resourceTypes); - private GroupPermissionChanger underTest = new GroupPermissionChanger(db.getDbClient()); + private GroupPermissionChanger underTest = new GroupPermissionChanger(db.getDbClient(), new SequenceUuidFactory()); private OrganizationDto org; private GroupDto group; private ComponentDto privateProject; @@ -430,6 +432,7 @@ public class GroupPermissionChangerTest { private void unsafeInsertProjectPermissionOnAnyone(String perm) { GroupPermissionDto dto = new GroupPermissionDto() + .setUuid(Uuids.createFast()) .setOrganizationUuid(privateProject.getOrganizationUuid()) .setGroupId(null) .setRole(perm) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java index 47b4464b759..3e58bdc3420 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java @@ -28,6 +28,7 @@ import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.ResourceTypes; import org.sonar.api.web.UserRole; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; @@ -64,7 +65,8 @@ public class PermissionTemplateServiceTest { private DbSession session = dbTester.getSession(); private ProjectIndexers projectIndexers = new TestProjectIndexers(); - private PermissionTemplateService underTest = new PermissionTemplateService(dbTester.getDbClient(), projectIndexers, userSession, defaultTemplatesResolver); + private PermissionTemplateService underTest = new PermissionTemplateService(dbTester.getDbClient(), projectIndexers, userSession, defaultTemplatesResolver, + new SequenceUuidFactory()); @Test public void apply_does_not_insert_permission_to_group_AnyOne_when_applying_template_on_private_project() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/UserPermissionChangerTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/UserPermissionChangerTest.java index debbf6a23e3..ef51871f6bd 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/UserPermissionChangerTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/UserPermissionChangerTest.java @@ -27,6 +27,7 @@ import org.junit.rules.ExpectedException; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.ResourceTypes; import org.sonar.api.utils.System2; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ResourceTypesRule; @@ -59,7 +60,7 @@ public class UserPermissionChangerTest { private ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); private PermissionService permissionService = new PermissionServiceImpl(resourceTypes); - private UserPermissionChanger underTest = new UserPermissionChanger(db.getDbClient()); + private UserPermissionChanger underTest = new UserPermissionChanger(db.getDbClient(), new SequenceUuidFactory()); private OrganizationDto org1; private OrganizationDto org2; private UserDto user1; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/BasePermissionWsTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/BasePermissionWsTest.java index 764e1b23501..121fb7153f7 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/BasePermissionWsTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/BasePermissionWsTest.java @@ -24,6 +24,7 @@ import org.junit.Rule; import org.junit.rules.ExpectedException; import org.sonar.api.impl.utils.AlwaysIncreasingSystem2; import org.sonar.api.resources.Qualifiers; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ResourceTypesRule; @@ -85,8 +86,8 @@ public abstract class BasePermissionWsTest<A extends PermissionsWsAction> { protected PermissionUpdater newPermissionUpdater() { return new PermissionUpdater( new ProjectIndexersImpl(new PermissionIndexer(db.getDbClient(), es.client())), - new UserPermissionChanger(db.getDbClient()), - new GroupPermissionChanger(db.getDbClient())); + new UserPermissionChanger(db.getDbClient(), new SequenceUuidFactory()), + new GroupPermissionChanger(db.getDbClient(), new SequenceUuidFactory())); } protected TestRequest newRequest() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java index 36a2b9e980e..5e8bae5031c 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.ResourceTypes; import org.sonar.api.web.UserRole; +import org.sonar.core.util.Uuids; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.db.component.ResourceTypesRule; @@ -473,6 +474,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio private void unsafeInsertProjectPermissionOnAnyone(String perm, ComponentDto project) { GroupPermissionDto dto = new GroupPermissionDto() + .setUuid(Uuids.createFast()) .setOrganizationUuid(project.getOrganizationUuid()) .setGroupId(null) .setRole(perm) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java index 318749cd889..959329d04cc 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java @@ -25,6 +25,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.sonar.api.web.UserRole; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.component.ComponentDto; import org.sonar.db.permission.PermissionQuery; import org.sonar.db.permission.template.PermissionTemplateDto; @@ -59,7 +60,7 @@ public class ApplyTemplateActionTest extends BasePermissionWsTest<ApplyTemplateA private PermissionTemplateDto template2; private PermissionTemplateService permissionTemplateService = new PermissionTemplateService(db.getDbClient(), - new TestProjectIndexers(), userSession, defaultTemplatesResolver); + new TestProjectIndexers(), userSession, defaultTemplatesResolver, new SequenceUuidFactory()); @Override protected ApplyTemplateAction buildWsAction() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java index 14b885ffb3f..63a00a2d92d 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java @@ -27,6 +27,7 @@ import org.junit.Test; import org.sonar.api.resources.Qualifiers; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.web.UserRole; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.db.organization.OrganizationDto; @@ -74,7 +75,7 @@ public class BulkApplyTemplateActionTest extends BasePermissionWsTest<BulkApplyT @Override protected BulkApplyTemplateAction buildWsAction() { PermissionTemplateService permissionTemplateService = new PermissionTemplateService(db.getDbClient(), - projectIndexers, userSession, defaultTemplatesResolver); + projectIndexers, userSession, defaultTemplatesResolver, new SequenceUuidFactory()); return new BulkApplyTemplateAction(db.getDbClient(), userSession, permissionTemplateService, newPermissionWsSupport(), new I18nRule(), newRootResourceTypes()); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java index 18c7d1c33fb..44654eb54e4 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java @@ -32,6 +32,7 @@ import org.sonar.api.resources.ResourceTypes; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; +import org.sonar.core.util.SequenceUuidFactory; import org.sonar.core.util.Uuids; import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; @@ -107,7 +108,8 @@ public class UpdateVisibilityActionTest { private BillingValidationsProxy billingValidations = mock(BillingValidationsProxy.class); private ProjectsWsSupport wsSupport = new ProjectsWsSupport(dbClient, TestDefaultOrganizationProvider.from(dbTester), billingValidations); - private UpdateVisibilityAction underTest = new UpdateVisibilityAction(dbClient, TestComponentFinder.from(dbTester), userSessionRule, projectIndexers, wsSupport); + private UpdateVisibilityAction underTest = new UpdateVisibilityAction(dbClient, TestComponentFinder.from(dbTester), + userSessionRule, projectIndexers, wsSupport, new SequenceUuidFactory()); private WsActionTester ws = new WsActionTester(underTest); private final Random random = new Random(); @@ -593,7 +595,6 @@ public class UpdateVisibilityActionTest { .containsOnly(UserRole.ADMIN); } - @Test public void fail_to_update_visibility_to_private_when_organization_is_not_allowed_to_use_private_projects() { OrganizationDto organization = dbTester.organizations().insert(); @@ -656,6 +657,7 @@ public class UpdateVisibilityActionTest { private void unsafeInsertProjectPermissionOnAnyone(ComponentDto component, String permission) { GroupPermissionDto dto = new GroupPermissionDto() + .setUuid(Uuids.createFast()) .setOrganizationUuid(component.getOrganizationUuid()) .setGroupId(null) .setRole(permission) @@ -666,6 +668,7 @@ public class UpdateVisibilityActionTest { private void unsafeInsertProjectPermissionOnGroup(ComponentDto component, GroupDto group, String permission) { GroupPermissionDto dto = new GroupPermissionDto() + .setUuid(Uuids.createFast()) .setOrganizationUuid(group.getOrganizationUuid()) .setGroupId(group.getId()) .setRole(permission) |