From 2311fc452d9ea07308d45cd60f2b577c544a841b Mon Sep 17 00:00:00 2001 From: Benjamin Campomenosi Date: Fri, 30 Jun 2023 11:24:52 +0200 Subject: [PATCH] SONAR-19558 Refactor rest of test in webapi module --- .../sonar/db/component/ComponentDbTester.java | 6 + .../org/sonar/db/component/PortfolioData.java | 7 + .../org/sonar/db/component/ProjectData.java | 5 + .../ce/projectdump/ExportSubmitterImplIT.java | 11 +- .../ce/queue/BranchReportSubmitterIT.java | 2 +- .../server/ce/queue/CeQueueCleanerIT.java | 2 +- .../sonar/server/ce/ws/ActivityActionIT.java | 131 ++++++++++-------- .../server/ce/ws/ActivityStatusActionIT.java | 2 +- .../sonar/server/ce/ws/ComponentActionIT.java | 2 +- .../ce/ws/DismissAnalysisWarningActionIT.java | 2 +- .../ce/ws/IndexationStatusActionIT.java | 2 +- .../org/sonar/server/ce/ws/TaskActionIT.java | 2 +- .../sonar/server/hotspot/ws/ShowActionIT.java | 2 +- .../pull/PullTaintActionResponseWriterIT.java | 2 +- .../server/measure/ws/SearchActionIT.java | 2 +- .../DefaultTemplatesResolverImplIT.java | 2 +- .../permission/GroupPermissionChangerIT.java | 2 +- .../permission/UserPermissionChangerIT.java | 2 +- .../server/plugins/ws/InstalledActionIT.java | 2 +- .../server/project/ws/SearchActionIT.java | 64 ++++----- .../server/project/ws/UpdateKeyActionIT.java | 2 +- .../ws/DeleteEventActionIT.java | 2 +- .../ws/UpdateEventActionIT.java | 2 +- .../server/projectdump/ws/StatusActionIT.java | 2 +- .../server/projectlink/ws/CreateActionIT.java | 19 +-- .../server/qualitygate/ws/RenameActionIT.java | 2 +- .../QProfileBackuperImplIT.java | 2 +- .../qualityprofile/QProfileCopierIT.java | 2 +- .../qualityprofile/QProfileExportersIT.java | 2 +- .../qualityprofile/QProfileFactoryImplIT.java | 2 +- .../qualityprofile/QProfileRuleImplIT.java | 2 +- .../qualityprofile/QProfileTreeImplIT.java | 2 +- .../RegisterQualityProfilesIT.java | 2 +- ...RegisterQualityProfilesNotificationIT.java | 2 +- .../ws/ChangeParentActionIT.java | 2 +- .../qualityprofile/ws/ChangelogActionIT.java | 2 +- .../qualityprofile/ws/DeleteActionIT.java | 2 +- .../qualityprofile/ws/ExportActionIT.java | 2 +- .../qualityprofile/ws/RenameActionIT.java | 2 +- .../qualityprofile/ws/SearchActionIT.java | 2 +- .../org/sonar/server/rule/RuleCreatorIT.java | 2 +- .../org/sonar/server/rule/RuleUpdaterIT.java | 2 +- .../org/sonar/server/rule/ws/AppActionIT.java | 2 +- .../sonar/server/rule/ws/CreateActionIT.java | 2 +- .../sonar/server/rule/ws/ListActionIT.java | 2 +- .../server/rule/ws/RepositoriesActionIT.java | 2 +- .../server/rule/ws/RuleQueryFactoryIT.java | 2 +- .../sonar/server/rule/ws/SearchActionIT.java | 2 +- .../setting/ws/GenerateSecretKeyActionIT.java | 2 +- .../setting/ws/ListDefinitionsActionIT.java | 2 +- .../server/setting/ws/ResetActionIT.java | 2 +- .../sonar/server/setting/ws/SetActionIT.java | 2 +- .../server/setting/ws/SettingsUpdaterIT.java | 2 +- .../server/setting/ws/ValuesActionIT.java | 2 +- .../source/ws/IssueSnippetsActionIT.java | 2 +- .../sonar/server/source/ws/RawActionIT.java | 2 +- .../sonar/server/ui/ws/ComponentActionIT.java | 2 +- .../server/user/ws/AnonymizeActionIT.java | 2 +- .../sonar/server/user/ws/CreateActionIT.java | 2 +- .../server/user/ws/DeactivateActionIT.java | 2 +- .../server/user/ws/DismissNoticeActionIT.java | 2 +- .../sonar/server/user/ws/UpdateActionIT.java | 2 +- .../server/user/ws/UpdateLoginActionIT.java | 2 +- .../server/user/ws/UserAnonymizerIT.java | 2 +- .../server/usergroups/ws/CreateActionIT.java | 2 +- .../usergroups/ws/ExternalGroupServiceIT.java | 2 +- .../server/usergroups/ws/SearchActionIT.java | 2 +- .../server/usergroups/ws/UpdateActionIT.java | 2 +- .../server/usergroups/ws/UsersActionIT.java | 2 +- .../server/usertoken/ws/GenerateActionIT.java | 2 +- .../server/usertoken/ws/RevokeActionIT.java | 2 +- .../server/usertoken/ws/SearchActionIT.java | 2 +- .../sonar/server/ce/ws/ActivityAction.java | 6 +- .../sonar/server/project/ws/SearchAction.java | 13 +- .../sonar/server/ce/ws/TaskFormatterTest.java | 2 +- 75 files changed, 214 insertions(+), 180 deletions(-) diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java index 277cacdc820..1d3de422b56 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java @@ -235,6 +235,12 @@ public class ComponentDbTester { return new PortfolioData(portfolioDto, component); } + public final PortfolioData insertPrivatePortfolioData(Consumer dtoPopulator) { + ComponentDto component = insertComponentAndPortfolio(ComponentTesting.newPortfolio().setPrivate(true), true, dtoPopulator, defaults()); + PortfolioDto portfolioDto = getPortfolioDto(component); + return new PortfolioData(portfolioDto, component); + } + public final PortfolioDto insertPrivatePortfolioDto(Consumer dtoPopulator) { ComponentDto component = insertComponentAndPortfolio(ComponentTesting.newPortfolio().setPrivate(true), true, dtoPopulator, defaults()); return getPortfolioDto(component); diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/PortfolioData.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/PortfolioData.java index 9838f01c9f0..a76d4ba6adc 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/PortfolioData.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/PortfolioData.java @@ -39,4 +39,11 @@ public class PortfolioData { return portfolioDto; } + public String portfolioUuid(){ + return portfolioDto.getUuid(); + } + + public String rootComponentUuid(){ + return rootComponent.uuid(); + } } diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ProjectData.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ProjectData.java index 33c870a61b0..80392f266b0 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ProjectData.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ProjectData.java @@ -51,4 +51,9 @@ public class ProjectData { public String projectKey() { return projectDto.getKey(); } + + public String mainBranchUuid(){ + return mainBranchDto.getUuid(); + } + } diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/projectdump/ExportSubmitterImplIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/projectdump/ExportSubmitterImplIT.java index 1fca898ea2d..77af733c9c9 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/projectdump/ExportSubmitterImplIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/projectdump/ExportSubmitterImplIT.java @@ -29,6 +29,7 @@ import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.ce.CeQueueDto; import org.sonar.db.component.ComponentDto; +import org.sonar.db.project.ProjectDto; import org.sonar.server.platform.NodeInformation; import static org.assertj.core.api.Assertions.assertThat; @@ -42,7 +43,7 @@ public class ExportSubmitterImplIT { private final System2 system2 = System2.INSTANCE; @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); private final DbClient dbClient = db.getDbClient(); private final CeQueue ceQueue = new CeQueueImpl(system2, db.getDbClient(), UuidFactoryFast.getInstance(), mock(NodeInformation.class)); @@ -65,24 +66,24 @@ public class ExportSubmitterImplIT { @Test public void submitProjectExport_submits_task_with_project_uuid_and_submitterLogin_if_present() { - ComponentDto projectDto = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectDto projectDto = db.components().insertPrivateProject().getProjectDto(); underTest.submitProjectExport(projectDto.getKey(), SOME_SUBMITTER_UUID); assertThat(dbClient.ceQueueDao().selectAllInAscOrder(db.getSession())) .extracting(CeQueueDto::getComponentUuid, CeQueueDto::getTaskType, CeQueueDto::getSubmitterUuid) - .containsExactlyInAnyOrder(tuple(projectDto.uuid(), "PROJECT_EXPORT", SOME_SUBMITTER_UUID)); + .containsExactlyInAnyOrder(tuple(projectDto.getUuid(), "PROJECT_EXPORT", SOME_SUBMITTER_UUID)); } @Test public void submitProjectExport_submits_task_with_project_uuid_and_no_submitterLogin_if_null() { - ComponentDto projectDto = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectDto projectDto = db.components().insertPrivateProject().getProjectDto(); underTest.submitProjectExport(projectDto.getKey(), null); assertThat(dbClient.ceQueueDao().selectAllInAscOrder(db.getSession())) .extracting(CeQueueDto::getComponentUuid, CeQueueDto::getTaskType, CeQueueDto::getSubmitterUuid) - .containsExactlyInAnyOrder(tuple(projectDto.uuid(), "PROJECT_EXPORT", null)); + .containsExactlyInAnyOrder(tuple(projectDto.getUuid(), "PROJECT_EXPORT", null)); } } diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/queue/BranchReportSubmitterIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/queue/BranchReportSubmitterIT.java index 41626448af1..24358548f74 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/queue/BranchReportSubmitterIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/queue/BranchReportSubmitterIT.java @@ -85,7 +85,7 @@ public class BranchReportSubmitterIT { @Rule public final UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public final DbTester db = DbTester.create(System2.INSTANCE); + public final DbTester db = DbTester.create(System2.INSTANCE, true); private final ProjectDefaultVisibility projectDefaultVisibility = mock(ProjectDefaultVisibility.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/queue/CeQueueCleanerIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/queue/CeQueueCleanerIT.java index e033365e74a..15a207a14c1 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/queue/CeQueueCleanerIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/queue/CeQueueCleanerIT.java @@ -43,7 +43,7 @@ import static org.mockito.Mockito.when; public class CeQueueCleanerIT { @Rule - public final DbTester dbTester = DbTester.create(System2.INSTANCE); + public final DbTester dbTester = DbTester.create(System2.INSTANCE, true); private final ServerUpgradeStatus serverUpgradeStatus = mock(ServerUpgradeStatus.class); private final CeQueue queue = mock(CeQueue.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityActionIT.java index d75a0e76b26..6f5061df6c7 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityActionIT.java @@ -39,9 +39,14 @@ import org.sonar.db.ce.CeTaskCharacteristicDto; import org.sonar.db.ce.CeTaskMessageDto; import org.sonar.db.ce.CeTaskMessageType; import org.sonar.db.ce.CeTaskTypes; +import org.sonar.db.component.BranchDto; import org.sonar.db.component.BranchType; import org.sonar.db.component.ComponentDto; +import org.sonar.db.component.PortfolioData; +import org.sonar.db.component.ProjectData; import org.sonar.db.component.SnapshotDto; +import org.sonar.db.portfolio.PortfolioDto; +import org.sonar.db.project.ProjectDto; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; @@ -88,7 +93,7 @@ public class ActivityActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final TaskFormatter formatter = new TaskFormatter(db.getDbClient(), System2.INSTANCE); private final ActivityAction underTest = new ActivityAction(userSession, db.getDbClient(), formatter, new CeTaskProcessor[] {mock(CeTaskProcessor.class)}); @@ -97,11 +102,11 @@ public class ActivityActionIT { @Test public void get_all_past_activity() { logInAsSystemAdministrator(); - ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto project2 = db.components().insertPrivateProject().getMainBranchComponent(); - SnapshotDto analysisProject1 = db.components().insertSnapshot(project1); - insertActivity("T1", project1, SUCCESS, analysisProject1); - insertActivity("T2", project2, FAILED, null); + ProjectData project1 = db.components().insertPrivateProject(); + ProjectData project2 = db.components().insertPrivateProject(); + SnapshotDto analysisProject1 = db.components().insertSnapshot(project1.getMainBranchDto()); + insertActivity("T1", project1.projectUuid(), project1.mainBranchUuid(), SUCCESS, analysisProject1); + insertActivity("T2", project2.projectUuid(), project2.mainBranchUuid(), FAILED, null); ActivityResponse activityResponse = call(ws.newRequest() .setParam(PARAM_MAX_EXECUTED_AT, formatDateTime(EXECUTED_AT + 2_000))); @@ -112,7 +117,7 @@ public class ActivityActionIT { assertThat(task.getId()).isEqualTo("T2"); assertThat(task.getStatus()).isEqualTo(Ce.TaskStatus.FAILED); assertThat(task.getNodeName()).isEqualTo(NODE_NAME); - assertThat(task.getComponentId()).isEqualTo(project2.uuid()); + assertThat(task.getComponentId()).isEqualTo(project2.getMainBranchComponent().uuid()); assertThat(task.hasAnalysisId()).isFalse(); assertThat(task.getExecutionTimeMs()).isEqualTo(500L); assertThat(task.getWarningCount()).isZero(); @@ -121,15 +126,15 @@ public class ActivityActionIT { assertThat(task.getId()).isEqualTo("T1"); assertThat(task.getNodeName()).isEqualTo(NODE_NAME); assertThat(task.getStatus()).isEqualTo(Ce.TaskStatus.SUCCESS); - assertThat(task.getComponentId()).isEqualTo(project1.uuid()); + assertThat(task.getComponentId()).isEqualTo(project1.getMainBranchComponent().uuid()); assertThat(task.getWarningCount()).isZero(); } @Test public void filter_by_status() { logInAsSystemAdministrator(); - ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto project2 = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project1 = db.components().insertPrivateProject(); + ProjectData project2 = db.components().insertPrivateProject(); insertActivity("T1", project1, SUCCESS); insertActivity("T2", project2, FAILED); insertQueue("T3", project1, IN_PROGRESS); @@ -145,8 +150,8 @@ public class ActivityActionIT { @Test public void filter_by_max_executed_at_exclude() { logInAsSystemAdministrator(); - ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto project2 = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project1 = db.components().insertPrivateProject(); + ProjectData project2 = db.components().insertPrivateProject(); insertActivity("T1", project1, SUCCESS); insertActivity("T2", project2, FAILED); insertQueue("T3", project1, IN_PROGRESS); @@ -161,7 +166,7 @@ public class ActivityActionIT { @Test public void filter_by_min_submitted_and_max_executed_at_include_day() { logInAsSystemAdministrator(); - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project = db.components().insertPrivateProject(); insertActivity("T1", project, SUCCESS); String today = formatDate(new Date(EXECUTED_AT)); @@ -175,7 +180,7 @@ public class ActivityActionIT { @Test public void filter_on_current_activities() { logInAsSystemAdministrator(); - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project = db.components().insertPrivateProject(); // T2 is the current activity (the most recent one) insertActivity("T1", project, SUCCESS); insertActivity("T2", project, FAILED); @@ -203,8 +208,8 @@ public class ActivityActionIT { @Test public void limit_results() { logInAsSystemAdministrator(); - ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto project2 = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project1 = db.components().insertPrivateProject(); + ProjectData project2 = db.components().insertPrivateProject(); insertActivity("T1", project1, SUCCESS); insertActivity("T2", project2, FAILED); insertQueue("T3", project1, IN_PROGRESS); @@ -225,7 +230,7 @@ public class ActivityActionIT { @Test public void remove_queued_already_completed() { logInAsSystemAdministrator(); - ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project1 = db.components().insertPrivateProject(); insertActivity("T1", project1, SUCCESS); insertQueue("T1", project1, IN_PROGRESS); @@ -243,8 +248,8 @@ public class ActivityActionIT { @Test public void return_warnings_count_on_queue_and_activity_and_warnings_list() { logInAsSystemAdministrator(); - ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto project2 = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project1 = db.components().insertPrivateProject(); + ProjectData project2 = db.components().insertPrivateProject(); insertActivity("T1", project1, SUCCESS); insertActivity("T2", project2, FAILED); insertQueue("T3", project1, IN_PROGRESS); @@ -277,27 +282,27 @@ public class ActivityActionIT { @Test public void project_administrator_can_access_his_project_activity_using_component_key() { - ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto project2 = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project1 = db.components().insertPrivateProject(); + ProjectData project2 = db.components().insertPrivateProject(); // no need to be a system admin - userSession.logIn().addProjectPermission(UserRole.ADMIN, project1); + userSession.logIn().addProjectPermission(UserRole.ADMIN, project1.getProjectDto()); insertActivity("T1", project1, SUCCESS); insertActivity("T2", project2, FAILED); - ActivityResponse activityResponse = call(ws.newRequest().setParam("component", project1.getKey())); + ActivityResponse activityResponse = call(ws.newRequest().setParam("component", project1.projectKey())); assertThat(activityResponse.getTasksCount()).isOne(); assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T1"); assertThat(activityResponse.getTasks(0).getStatus()).isEqualTo(Ce.TaskStatus.SUCCESS); - assertThat(activityResponse.getTasks(0).getComponentId()).isEqualTo(project1.uuid()); + assertThat(activityResponse.getTasks(0).getComponentId()).isEqualTo(project1.getMainBranchComponent().uuid()); } @Test public void return_401_if_user_is_not_logged_in() { - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project = db.components().insertPrivateProject(); userSession.anonymous(); - TestRequest request = ws.newRequest().setParam("componentId", project.uuid()); + TestRequest request = ws.newRequest().setParam("componentId", project.projectUuid()); assertThatThrownBy(() -> call(request)) .isInstanceOf(UnauthorizedException.class) .hasMessage("Authentication is required"); @@ -305,12 +310,12 @@ public class ActivityActionIT { @Test public void search_activity_by_component_name() { - ComponentDto struts = db.components().insertPrivateProject(c -> c.setName("old apache struts")).getMainBranchComponent(); - ComponentDto zookeeper = db.components().insertPrivateProject(c -> c.setName("new apache zookeeper")).getMainBranchComponent(); - ComponentDto eclipse = db.components().insertPrivateProject(c -> c.setName("eclipse")).getMainBranchComponent(); - db.components().insertSnapshot(struts); - db.components().insertSnapshot(zookeeper); - db.components().insertSnapshot(eclipse); + ProjectData struts = db.components().insertPrivateProject(c -> c.setName("old apache struts")); + ProjectData zookeeper = db.components().insertPrivateProject(c -> c.setName("new apache zookeeper")); + ProjectData eclipse = db.components().insertPrivateProject(c -> c.setName("eclipse")); + db.components().insertSnapshot(struts.getMainBranchDto()); + db.components().insertSnapshot(zookeeper.getMainBranchDto()); + db.components().insertSnapshot(eclipse.getMainBranchDto()); logInAsSystemAdministrator(); insertActivity("T1", struts, SUCCESS); insertActivity("T2", zookeeper, SUCCESS); @@ -323,8 +328,8 @@ public class ActivityActionIT { @Test public void search_activity_returns_views() { - ComponentDto apacheView = db.components().insertPrivatePortfolio(v -> v.setName("Apache View")); - db.components().insertSnapshot(apacheView); + PortfolioData apacheView = db.components().insertPrivatePortfolioData(v -> v.setName("Apache View")); + db.components().insertSnapshot(apacheView.getPortfolioDto()); logInAsSystemAdministrator(); insertActivity("T2", apacheView, SUCCESS); @@ -335,8 +340,8 @@ public class ActivityActionIT { @Test public void search_activity_returns_application() { - ComponentDto apacheApp = db.components().insertPublicApplication(a -> a.setName("Apache App")).getMainBranchComponent(); - db.components().insertSnapshot(apacheApp); + ProjectData apacheApp = db.components().insertPublicApplication(a -> a.setName("Apache App")); + db.components().insertSnapshot(apacheApp.getMainBranchDto()); logInAsSystemAdministrator(); insertActivity("T2", apacheApp, SUCCESS); @@ -348,7 +353,7 @@ public class ActivityActionIT { @Test public void search_task_id_in_queue_ignoring_other_parameters() { logInAsSystemAdministrator(); - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project = db.components().insertPrivateProject(); insertQueue("T1", project, IN_PROGRESS); ActivityResponse result = call( @@ -363,7 +368,7 @@ public class ActivityActionIT { @Test public void search_task_id_in_activity() { logInAsSystemAdministrator(); - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project = db.components().insertPrivateProject(); insertActivity("T1", project, SUCCESS); ActivityResponse result = call(ws.newRequest().setParam(Param.TEXT_QUERY, "T1")); @@ -377,9 +382,9 @@ public class ActivityActionIT { // WS api/ce/task must be used in order to search by task id. // Here it's a convenient feature of search by text query, which // is reserved to roots - ComponentDto view = db.components().insertPrivatePortfolio(); + PortfolioData view = db.components().insertPrivatePortfolioData(); insertActivity("T1", view, SUCCESS); - userSession.logIn().addProjectPermission(UserRole.ADMIN, view); + userSession.logIn().addProjectPermission(UserRole.ADMIN, view.getRootComponent()); TestRequest request = ws.newRequest().setParam(TEXT_QUERY, "T1"); assertThatThrownBy(() -> call(request)) @@ -390,12 +395,12 @@ public class ActivityActionIT { @Test public void branch_in_past_activity() { logInAsSystemAdministrator(); - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); - userSession.addProjectPermission(UserRole.USER, project); + ProjectData project = db.components().insertPrivateProject(); + userSession.addProjectPermission(UserRole.USER, project.getProjectDto()); String branchName = "branch1"; - ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH).setKey(branchName)); + BranchDto branch = db.components().insertProjectBranch(project.getProjectDto(), b -> b.setBranchType(BRANCH).setKey(branchName)); SnapshotDto analysis = db.components().insertSnapshot(branch); - CeActivityDto activity = insertActivity("T1", project, SUCCESS, analysis); + CeActivityDto activity = insertActivity("T1", project.projectUuid(), project.mainBranchUuid(), SUCCESS, analysis); insertCharacteristic(activity, BRANCH_KEY, branchName); insertCharacteristic(activity, BRANCH_TYPE_KEY, BRANCH.name()); @@ -432,12 +437,12 @@ public class ActivityActionIT { @Test public void pull_request_in_past_activity() { logInAsSystemAdministrator(); - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); - userSession.addProjectPermission(UserRole.USER, project); + ProjectData project = db.components().insertPrivateProject(); + userSession.addProjectPermission(UserRole.USER, project.getProjectDto()); String pullRequestKey = RandomStringUtils.randomAlphanumeric(100); - ComponentDto pullRequest = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.PULL_REQUEST).setKey(pullRequestKey)); + BranchDto pullRequest = db.components().insertProjectBranch(project.getProjectDto(), b -> b.setBranchType(BranchType.PULL_REQUEST).setKey(pullRequestKey)); SnapshotDto analysis = db.components().insertSnapshot(pullRequest); - CeActivityDto activity = insertActivity("T1", project, SUCCESS, analysis); + CeActivityDto activity = insertActivity("T1", project.projectUuid(), project.getMainBranchComponent().uuid(), SUCCESS, analysis); insertCharacteristic(activity, PULL_REQUEST, pullRequestKey); ActivityResponse response = ws.newRequest().executeProtobuf(ActivityResponse.class); @@ -531,7 +536,7 @@ public class ActivityActionIT { @Test public void throws_IAE_if_page_is_higher_than_available() { logInAsSystemAdministrator(); - ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project1 = db.components().insertPrivateProject(); insertActivity("T1", project1, SUCCESS); insertActivity("T2", project1, SUCCESS); @@ -585,9 +590,9 @@ public class ActivityActionIT { @Test public void filter_out_duplicate_tasks_in_progress_and_success() { logInAsSystemAdministrator(); - ComponentDto project1 = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto project2 = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto project3 = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectData project1 = db.components().insertPrivateProject(); + ProjectData project2 = db.components().insertPrivateProject(); + ProjectData project3 = db.components().insertPrivateProject(); insertQueue("T2", project2, IN_PROGRESS); insertQueue("T3", project3, IN_PROGRESS); insertActivity("T1", project1, SUCCESS); @@ -604,12 +609,12 @@ public class ActivityActionIT { userSession.logIn().setSystemAdministrator(); } - private CeQueueDto insertQueue(String taskUuid, @Nullable ComponentDto project, CeQueueDto.Status status) { + private CeQueueDto insertQueue(String taskUuid, @Nullable ProjectData project, CeQueueDto.Status status) { CeQueueDto queueDto = new CeQueueDto(); queueDto.setTaskType(CeTaskTypes.REPORT); - if (project != null ) { - queueDto.setComponentUuid(project.uuid()); - queueDto.setEntityUuid(project.uuid()); + if (project != null) { + queueDto.setComponentUuid(project.mainBranchUuid()); + queueDto.setEntityUuid(project.projectUuid()); } queueDto.setUuid(taskUuid); queueDto.setStatus(status); @@ -618,15 +623,19 @@ public class ActivityActionIT { return queueDto; } - private CeActivityDto insertActivity(String taskUuid, ComponentDto project, Status status) { - return insertActivity(taskUuid, project, status, db.components().insertSnapshot(project)); + private CeActivityDto insertActivity(String taskUuid, ProjectData project, Status status) { + return insertActivity(taskUuid, project.projectUuid(), project.mainBranchUuid(), status, db.components().insertSnapshot(project.getMainBranchDto())); } - private CeActivityDto insertActivity(String taskUuid, ComponentDto project, Status status, @Nullable SnapshotDto analysis) { + private CeActivityDto insertActivity(String taskUuid, PortfolioData portfolio, Status status) { + return insertActivity(taskUuid, portfolio.portfolioUuid(), portfolio.rootComponentUuid(), status, db.components().insertSnapshot(portfolio.getPortfolioDto())); + } + + private CeActivityDto insertActivity(String taskUuid, String entityUuid, String rootCompomentUuid, Status status, @Nullable SnapshotDto analysis) { CeQueueDto queueDto = new CeQueueDto(); queueDto.setTaskType(CeTaskTypes.REPORT); - queueDto.setComponentUuid(project.uuid()); - queueDto.setEntityUuid(project.uuid()); + queueDto.setComponentUuid(rootCompomentUuid); + queueDto.setEntityUuid(entityUuid); queueDto.setUuid(taskUuid); queueDto.setCreatedAt(EXECUTED_AT); CeActivityDto activityDto = new CeActivityDto(queueDto); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityStatusActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityStatusActionIT.java index 8e7d053d05e..ca9f15cb5e5 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityStatusActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityStatusActionIT.java @@ -54,7 +54,7 @@ public class ActivityStatusActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone().logIn().setSystemAdministrator(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final System2 system2 = mock(System2.class); private final DbClient dbClient = db.getDbClient(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ComponentActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ComponentActionIT.java index 219ad666f72..abe94b0d7b8 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ComponentActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ComponentActionIT.java @@ -65,7 +65,7 @@ public class ComponentActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final TaskFormatter formatter = new TaskFormatter(db.getDbClient(), System2.INSTANCE); private final ComponentAction underTest = new ComponentAction(userSession, db.getDbClient(), formatter, TestComponentFinder.from(db)); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/DismissAnalysisWarningActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/DismissAnalysisWarningActionIT.java index e63ce21cfa7..09570010166 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/DismissAnalysisWarningActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/DismissAnalysisWarningActionIT.java @@ -55,7 +55,7 @@ public class DismissAnalysisWarningActionIT { public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private static int counter = 1; diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/IndexationStatusActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/IndexationStatusActionIT.java index 71a39a57f74..d0934f5a498 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/IndexationStatusActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/IndexationStatusActionIT.java @@ -46,7 +46,7 @@ public class IndexationStatusActionIT { public IssueIndexSyncProgressChecker issueIndexSyncProgressCheckerMock = mock(IssueIndexSyncProgressChecker.class); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private WsActionTester ws = new WsActionTester(new IndexationStatusAction(db.getDbClient(), issueIndexSyncProgressCheckerMock)); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/TaskActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/TaskActionIT.java index 425e40f5ceb..558b90a4447 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/TaskActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/TaskActionIT.java @@ -69,7 +69,7 @@ public class TaskActionIT { public final UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public final DbTester db = DbTester.create(System2.INSTANCE); + public final DbTester db = DbTester.create(System2.INSTANCE, true); private final TaskFormatter formatter = new TaskFormatter(db.getDbClient(), System2.INSTANCE); private final TaskAction underTest = new TaskAction(db.getDbClient(), formatter, userSession); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/hotspot/ws/ShowActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/hotspot/ws/ShowActionIT.java index 23829c26574..433a3298d24 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/hotspot/ws/ShowActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/hotspot/ws/ShowActionIT.java @@ -116,7 +116,7 @@ public class ShowActionIT { public static final DbIssues.MessageFormatting MESSAGE_FORMATTING = DbIssues.MessageFormatting.newBuilder().setStart(0).setEnd(4).setType(CODE).build(); @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); + public DbTester dbTester = DbTester.create(System2.INSTANCE, true); @Rule public EsTester es = EsTester.create(); @Rule diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/pull/PullTaintActionResponseWriterIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/pull/PullTaintActionResponseWriterIT.java index a2e3c3eb873..c5798d37fcd 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/pull/PullTaintActionResponseWriterIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/pull/PullTaintActionResponseWriterIT.java @@ -43,7 +43,7 @@ import static org.mockito.Mockito.when; public class PullTaintActionResponseWriterIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/SearchActionIT.java index 67e48d03ee0..97adb87a4cc 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/SearchActionIT.java @@ -62,7 +62,7 @@ public class SearchActionIT { public UserSessionRule userSession = UserSessionRule.standalone().logIn(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final WsActionTester ws = new WsActionTester(new SearchAction(userSession, db.getDbClient())); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/DefaultTemplatesResolverImplIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/DefaultTemplatesResolverImplIT.java index bf79fd10721..cc43b17e34b 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/DefaultTemplatesResolverImplIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/DefaultTemplatesResolverImplIT.java @@ -35,7 +35,7 @@ import static org.sonar.api.resources.Qualifiers.VIEW; public class DefaultTemplatesResolverImplIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private ResourceTypesRule resourceTypesWithPortfoliosInstalled = new ResourceTypesRule().setRootQualifiers(PROJECT, APP, VIEW); private ResourceTypesRule resourceTypesWithApplicationInstalled = new ResourceTypesRule().setRootQualifiers(PROJECT, APP); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/GroupPermissionChangerIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/GroupPermissionChangerIT.java index f192a7ee679..bca394ab9e4 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/GroupPermissionChangerIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/GroupPermissionChangerIT.java @@ -49,7 +49,7 @@ import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS; public class GroupPermissionChangerIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/UserPermissionChangerIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/UserPermissionChangerIT.java index d14cfee992b..d644e9a1eec 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/UserPermissionChangerIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/UserPermissionChangerIT.java @@ -45,7 +45,7 @@ import static org.sonar.server.permission.PermissionChange.Operation.REMOVE; public class UserPermissionChangerIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/plugins/ws/InstalledActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/plugins/ws/InstalledActionIT.java index c14fd46f10d..c8e057a0024 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/plugins/ws/InstalledActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/plugins/ws/InstalledActionIT.java @@ -74,7 +74,7 @@ public class InstalledActionIT { @Rule public TemporaryFolder temp = new TemporaryFolder(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone().logIn(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/SearchActionIT.java index 14c69602047..eac18e53ace 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/SearchActionIT.java @@ -33,7 +33,10 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.DateUtils; import org.sonar.db.DbTester; +import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; +import org.sonar.db.component.ProjectData; +import org.sonar.db.project.ProjectDto; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.TestRequest; @@ -77,7 +80,7 @@ public class SearchActionIT { public final UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public final DbTester db = DbTester.create(); + public final DbTester db = DbTester.create(true); private final WsActionTester ws = new WsActionTester(new SearchAction(db.getDbClient(), userSession)); @@ -129,11 +132,11 @@ public class SearchActionIT { @Test public void search_projects() { userSession.addPermission(ADMINISTER); - ComponentDto project = db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_1)).getMainBranchComponent(); - db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_2)).getMainBranchComponent(); + ProjectData project = db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_1)); + db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_2)); db.components().insertPublicPortfolio(); - ComponentDto directory = newDirectory(project, "dir"); + ComponentDto directory = newDirectory(project.getMainBranchComponent(), "dir"); ComponentDto file = newFileDto(directory); db.components().insertComponents(directory, file); @@ -145,7 +148,7 @@ public class SearchActionIT { @Test public void search_views() { userSession.addPermission(ADMINISTER); - db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_1)).getMainBranchComponent(); + db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_1)); db.components().insertPublicPortfolio(p -> p.setKey("view1")); SearchWsResponse response = call(SearchRequest.builder().setQualifiers(singletonList("VW")).build()); @@ -156,7 +159,7 @@ public class SearchActionIT { @Test public void search_projects_and_views() { userSession.addPermission(ADMINISTER); - db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_1)).getMainBranchComponent(); + db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_1)); db.components().insertPublicPortfolio(p -> p.setKey("view1")); SearchWsResponse response = call(SearchRequest.builder().setQualifiers(asList("TRK", "VW")).build()); @@ -167,9 +170,9 @@ public class SearchActionIT { @Test public void search_all() { userSession.addPermission(ADMINISTER); - db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_1)).getMainBranchComponent(); - db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_2)).getMainBranchComponent(); - db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_3)).getMainBranchComponent(); + db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_1)); + db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_2)); + db.components().insertPrivateProject(p -> p.setKey(PROJECT_KEY_3)); SearchWsResponse response = call(SearchRequest.builder().build()); assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(PROJECT_KEY_1, PROJECT_KEY_2, PROJECT_KEY_3); @@ -182,22 +185,22 @@ public class SearchActionIT { long inBetween = 2_000_000_000L; long recentTime = 3_000_000_000L; - ComponentDto oldProject = db.components().insertPublicProject().getMainBranchComponent(); - db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(oldProject).setCreatedAt(aLongTimeAgo)); - ComponentDto branch = db.components().insertProjectBranch(oldProject); + ProjectData oldProject = db.components().insertPublicProject(); + db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(oldProject.getMainBranchDto()).setCreatedAt(aLongTimeAgo)); + BranchDto branch = db.components().insertProjectBranch(oldProject.getProjectDto()); db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(branch).setCreatedAt(inBetween)); - ComponentDto recentProject = db.components().insertPublicProject().getMainBranchComponent(); - db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(recentProject).setCreatedAt(recentTime)); + ProjectData recentProject = db.components().insertPublicProject(); + db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(recentProject.getMainBranchDto()).setCreatedAt(recentTime)); db.commit(); SearchWsResponse result = call(SearchRequest.builder().setAnalyzedBefore(toStringAtUTC(new Date(recentTime + 1_000))).build()); assertThat(result.getComponentsList()).extracting(Component::getKey, Component::getLastAnalysisDate) - .containsExactlyInAnyOrder(tuple(oldProject.getKey(), formatDateTime(inBetween)), tuple(recentProject.getKey(), formatDateTime(recentTime))); + .containsExactlyInAnyOrder(tuple(oldProject.getProjectDto().getKey(), formatDateTime(inBetween)), tuple(recentProject.projectKey(), formatDateTime(recentTime))); result = call(SearchRequest.builder().setAnalyzedBefore(toStringAtUTC(new Date(recentTime))).build()); assertThat(result.getComponentsList()).extracting(Component::getKey, Component::getLastAnalysisDate) - .containsExactlyInAnyOrder(tuple(oldProject.getKey(), formatDateTime(inBetween))); + .containsExactlyInAnyOrder(tuple(oldProject.getProjectDto().getKey(), formatDateTime(inBetween))); result = call(SearchRequest.builder().setAnalyzedBefore(toStringAtUTC(new Date(aLongTimeAgo + 1_000L))).build()); assertThat(result.getComponentsList()).isEmpty(); @@ -210,8 +213,8 @@ public class SearchActionIT { @Test public void does_not_return_branches_when_searching_by_key() { - ComponentDto project = db.components().insertPublicProject().getMainBranchComponent(); - ComponentDto branch = db.components().insertProjectBranch(project); + ProjectDto project = db.components().insertPublicProject().getProjectDto(); + db.components().insertProjectBranch(project); userSession.addPermission(ADMINISTER); SearchWsResponse response = call(SearchRequest.builder().build()); @@ -222,10 +225,9 @@ public class SearchActionIT { @Test public void result_is_paginated() { userSession.addPermission(ADMINISTER); - List componentDtoList = new ArrayList<>(); for (int i = 1; i <= 9; i++) { int j = i; - componentDtoList.add(db.components().insertPrivateProject("project-uuid-" + i, p -> p.setKey("project-key-" + j).setName("Project Name " + j)).getMainBranchComponent()); + db.components().insertPrivateProject("project-uuid-" + i, p -> p.setKey("project-key-" + j).setName("Project Name " + j)); } SearchWsResponse response = call(SearchRequest.builder().setPage(2).setPageSize(3).build()); @@ -235,23 +237,23 @@ public class SearchActionIT { @Test public void provisioned_projects() { userSession.addPermission(ADMINISTER); - ComponentDto provisionedProject = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto analyzedProject = db.components().insertPrivateProject().getMainBranchComponent(); - db.components().insertSnapshot(newAnalysis(analyzedProject)); + ProjectDto provisionedProject = db.components().insertPrivateProject().getProjectDto(); + ProjectData analyzedProject = db.components().insertPrivateProject(); + db.components().insertSnapshot(newAnalysis(analyzedProject.getMainBranchDto())); SearchWsResponse response = call(SearchRequest.builder().setOnProvisionedOnly(true).build()); assertThat(response.getComponentsList()).extracting(Component::getKey) .containsExactlyInAnyOrder(provisionedProject.getKey()) - .doesNotContain(analyzedProject.getKey()); + .doesNotContain(analyzedProject.projectKey()); } @Test public void search_by_component_keys() { userSession.addPermission(ADMINISTER); - ComponentDto jdk = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto sonarqube = db.components().insertPrivateProject().getMainBranchComponent(); - ComponentDto sonarlint = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectDto jdk = db.components().insertPrivateProject().getProjectDto(); + ProjectDto sonarqube = db.components().insertPrivateProject().getProjectDto(); + ProjectDto sonarlint = db.components().insertPrivateProject().getProjectDto(); SearchWsResponse result = call(SearchRequest.builder() .setProjects(Arrays.asList(jdk.getKey(), sonarqube.getKey())) @@ -346,12 +348,12 @@ public class SearchActionIT { @Test public void json_example() { userSession.addPermission(ADMINISTER); - ComponentDto publicProject = db.components().insertPublicProject("project-uuid-1", p -> p.setName("Project Name 1").setKey("project-key-1").setPrivate(false)).getMainBranchComponent(); - ComponentDto privateProject = db.components().insertPrivateProject("project-uuid-2", p -> p.setName("Project Name 1").setKey("project-key-2")).getMainBranchComponent(); - db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(publicProject) + ProjectData publicProject = db.components().insertPublicProject("project-uuid-1", p -> p.setName("Project Name 1").setKey("project-key-1").setPrivate(false)); + ProjectData privateProject = db.components().insertPrivateProject("project-uuid-2", p -> p.setName("Project Name 1").setKey("project-key-2")); + db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(publicProject.getMainBranchDto()) .setCreatedAt(parseDateTime("2017-03-01T11:39:03+0300").getTime()) .setRevision("cfb82f55c6ef32e61828c4cb3db2da12795fd767")); - db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(privateProject) + db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(privateProject.getMainBranchDto()) .setCreatedAt(parseDateTime("2017-03-02T15:21:47+0300").getTime()) .setRevision("7be96a94ac0c95a61ee6ee0ef9c6f808d386a355")); db.commit(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateKeyActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateKeyActionIT.java index 0a17167a8e0..31beb14a029 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateKeyActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/project/ws/UpdateKeyActionIT.java @@ -50,7 +50,7 @@ public class UpdateKeyActionIT { private static final String ANOTHER_KEY = "another_key"; @Rule - public final DbTester db = DbTester.create(System2.INSTANCE); + public final DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public final UserSessionRule userSessionRule = UserSessionRule.standalone(); private final DbClient dbClient = db.getDbClient(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/DeleteEventActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/DeleteEventActionIT.java index d29a25e84c2..40c2b63e63d 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/DeleteEventActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/DeleteEventActionIT.java @@ -51,7 +51,7 @@ public class DeleteEventActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private DbClient dbClient = db.getDbClient(); private DbSession dbSession = db.getSession(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/UpdateEventActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/UpdateEventActionIT.java index 33e94ac67b5..6ca29006c93 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/UpdateEventActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/UpdateEventActionIT.java @@ -57,7 +57,7 @@ public class UpdateEventActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final DbClient dbClient = db.getDbClient(); private final DbSession dbSession = db.getSession(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/StatusActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/StatusActionIT.java index 27e43f5c6c8..47a0438e45d 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/StatusActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/StatusActionIT.java @@ -64,7 +64,7 @@ public class StatusActionIT { private static final String SOME_KEY = "some key"; @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectlink/ws/CreateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectlink/ws/CreateActionIT.java index 13542b31764..8b6cc14a048 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectlink/ws/CreateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectlink/ws/CreateActionIT.java @@ -33,6 +33,7 @@ import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.db.component.ProjectData; import org.sonar.db.component.ProjectLinkDto; +import org.sonar.db.project.ProjectDto; import org.sonar.server.component.TestComponentFinder; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; @@ -54,7 +55,7 @@ public class CreateActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final DbClient dbClient = db.getDbClient(); private final DbSession dbSession = db.getSession(); @@ -62,7 +63,7 @@ public class CreateActionIT { @Test public void example_with_key() { - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectDto project = db.components().insertPrivateProject().getProjectDto(); logInAsProjectAdministrator(project); String result = ws.newRequest() @@ -77,12 +78,12 @@ public class CreateActionIT { @Test public void example_with_id() { - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectDto project = db.components().insertPrivateProject().getProjectDto(); logInAsProjectAdministrator(project); String result = ws.newRequest() .setMethod("POST") - .setParam(PARAM_PROJECT_ID, project.uuid()) + .setParam(PARAM_PROJECT_ID, project.getUuid()) .setParam(PARAM_NAME, "Custom") .setParam(PARAM_URL, "http://example.org") .execute().getInput(); @@ -92,7 +93,7 @@ public class CreateActionIT { @Test public void require_project_admin() { - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectDto project = db.components().insertPrivateProject().getProjectDto(); logInAsProjectAdministrator(project); createAndTest(project); @@ -100,7 +101,7 @@ public class CreateActionIT { @Test public void with_long_name() { - ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent(); + ProjectDto project = db.components().insertPrivateProject().getProjectDto(); logInAsProjectAdministrator(project); String longName = StringUtils.leftPad("", 60, "a"); String expectedType = StringUtils.leftPad("", 20, "a"); @@ -259,7 +260,7 @@ public class CreateActionIT { .hasMessageContaining("Project '" + component.uuid() + "' not found"); } - private void createAndTest(ComponentDto project, String name, String url, String type) { + private void createAndTest(ProjectDto project, String name, String url, String type) { ProjectLinks.CreateWsResponse response = ws.newRequest() .setMethod("POST") .setParam(PARAM_PROJECT_KEY, project.getKey()) @@ -275,11 +276,11 @@ public class CreateActionIT { assertThat(link.getType()).isEqualTo(type); } - private void createAndTest(ComponentDto project) { + private void createAndTest(ProjectDto project) { createAndTest(project, "Custom", "http://example.org", "custom"); } - private void logInAsProjectAdministrator(ComponentDto project) { + private void logInAsProjectAdministrator(ProjectDto project) { userSession.logIn().addProjectPermission(UserRole.ADMIN, project); } } diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/RenameActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/RenameActionIT.java index 8a91ccf2a3a..33ffb00da2c 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/RenameActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/RenameActionIT.java @@ -46,7 +46,7 @@ public class RenameActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final WsActionTester ws = new WsActionTester( new RenameAction(db.getDbClient(), new QualityGatesWsSupport(db.getDbClient(), userSession, TestComponentFinder.from(db)))); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileBackuperImplIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileBackuperImplIT.java index 04e750e7501..ab96c656525 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileBackuperImplIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileBackuperImplIT.java @@ -70,7 +70,7 @@ public class QProfileBackuperImplIT { private final System2 system2 = new AlwaysIncreasingSystem2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); private final DummyReset reset = new DummyReset(); private final QProfileFactory profileFactory = new DummyProfileFactory(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileCopierIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileCopierIT.java index 7e31f55af42..22d667f6987 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileCopierIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileCopierIT.java @@ -46,7 +46,7 @@ public class QProfileCopierIT { private final System2 system2 = new AlwaysIncreasingSystem2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public JUnitTempFolder temp = new JUnitTempFolder(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileExportersIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileExportersIT.java index 8e9d98bc20c..6be92265788 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileExportersIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileExportersIT.java @@ -64,7 +64,7 @@ public class QProfileExportersIT { private final System2 system2 = new AlwaysIncreasingSystem2(); @org.junit.Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); private final RuleFinder ruleFinder = new DefaultRuleFinder(db.getDbClient(), mock(RuleDescriptionFormatter.class)); private final ProfileExporter[] exporters = new ProfileExporter[] { diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileFactoryImplIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileFactoryImplIT.java index 1af67ebf60b..0a7834c5a81 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileFactoryImplIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileFactoryImplIT.java @@ -64,7 +64,7 @@ public class QProfileFactoryImplIT { private System2 system2 = new AlwaysIncreasingSystem2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); private DbSession dbSession = db.getSession(); private ActiveRuleIndexer activeRuleIndexer = mock(ActiveRuleIndexer.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileRuleImplIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileRuleImplIT.java index b9ea7fcc91f..4c74e57bc4d 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileRuleImplIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileRuleImplIT.java @@ -79,7 +79,7 @@ public class QProfileRuleImplIT { private System2 system2 = new AlwaysIncreasingSystem2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public EsTester es = EsTester.create(); @Rule diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileTreeImplIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileTreeImplIT.java index d29c0f91b64..5b5bedfbb39 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileTreeImplIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileTreeImplIT.java @@ -62,7 +62,7 @@ public class QProfileTreeImplIT { private System2 system2 = new AlwaysIncreasingSystem2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public EsTester es = EsTester.create(); @Rule diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesIT.java index eac7cc3e7b5..84215ecc252 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesIT.java @@ -61,7 +61,7 @@ public class RegisterQualityProfilesIT { private final System2 system2 = new TestSystem2().setNow(1659510722633L); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public UserSessionRule userSessionRule = UserSessionRule.standalone(); @Rule diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationIT.java index f252d34add8..17d2992398a 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationIT.java @@ -89,7 +89,7 @@ public class RegisterQualityProfilesNotificationIT { private System2 system2 = mock(System2.class); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public UserSessionRule userSessionRule = UserSessionRule.standalone(); @Rule diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangeParentActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangeParentActionIT.java index 145ea3bc32f..ab87edacb8f 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangeParentActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangeParentActionIT.java @@ -74,7 +74,7 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. public class ChangeParentActionIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public EsTester es = EsTester.create(); @Rule diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java index 7d282d04319..abb80f78c76 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java @@ -54,7 +54,7 @@ public class ChangelogActionIT { private final TestSystem2 system2 = new TestSystem2().setNow(DateUtils.parseDateTime(DATE).getTime()); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/DeleteActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/DeleteActionIT.java index 352ff1bc8f0..ca0b4c25aa0 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/DeleteActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/DeleteActionIT.java @@ -58,7 +58,7 @@ public class DeleteActionIT { private static final String A_LANGUAGE = "xoo"; @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ExportActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ExportActionIT.java index 317b94ca6ae..65ef950cfce 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ExportActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ExportActionIT.java @@ -52,7 +52,7 @@ public class ExportActionIT { private static final String JAVA_LANGUAGE = "java"; @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/RenameActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/RenameActionIT.java index e6ec279fee9..f086be7dc05 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/RenameActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/RenameActionIT.java @@ -48,7 +48,7 @@ import static org.sonar.db.permission.GlobalPermission.SCAN; public class RenameActionIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/SearchActionIT.java index bb1fa77deb0..961924a3c73 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/SearchActionIT.java @@ -68,7 +68,7 @@ public class SearchActionIT { private static final Languages LANGUAGES = new Languages(XOO1, XOO2); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); private final QualityProfileDbTester qualityProfileDb = db.qualityProfiles(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleCreatorIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleCreatorIT.java index c3fba012fe3..3c1f81b6e9a 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleCreatorIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleCreatorIT.java @@ -65,7 +65,7 @@ public class RuleCreatorIT { private final System2 system2 = new TestSystem2().setNow(Instant.now().toEpochMilli()); @Rule - public DbTester dbTester = DbTester.create(system2); + public DbTester dbTester = DbTester.create(system2, true); @Rule public EsTester es = EsTester.create(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleUpdaterIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleUpdaterIT.java index 587fb83ac2a..dfe5c39634b 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleUpdaterIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleUpdaterIT.java @@ -73,7 +73,7 @@ public class RuleUpdaterIT { public UserSessionRule userSessionRule = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public EsTester es = EsTester.create(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/AppActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/AppActionIT.java index e4df4e339a0..05d0b7ae9be 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/AppActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/AppActionIT.java @@ -42,7 +42,7 @@ public class AppActionIT { private static final Language LANG2 = LanguageTesting.newLanguage("ws", "Whitespace"); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/CreateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/CreateActionIT.java index d69d779ba99..18750232872 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/CreateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/CreateActionIT.java @@ -66,7 +66,7 @@ public class CreateActionIT { public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public EsTester es = EsTester.create(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/ListActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/ListActionIT.java index c4cd5bb9773..490d35c0143 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/ListActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/ListActionIT.java @@ -38,7 +38,7 @@ public class ListActionIT { private static final String RULE_KEY_2 = "S002"; @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); + public DbTester dbTester = DbTester.create(System2.INSTANCE, true); ListAction underTest = new ListAction(dbTester.getDbClient()); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/RepositoriesActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/RepositoriesActionIT.java index e70c26a86db..b97822854c5 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/RepositoriesActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/RepositoriesActionIT.java @@ -36,7 +36,7 @@ public class RepositoriesActionIT { private static final String EMPTY_JSON_RESPONSE = "{\"repositories\":[]}"; @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); + public DbTester dbTester = DbTester.create(System2.INSTANCE, true); private RepositoriesAction underTest = new RepositoriesAction(dbTester.getDbClient()); private WsActionTester tester = new WsActionTester(underTest); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/RuleQueryFactoryIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/RuleQueryFactoryIT.java index 52df5617a90..f4177d92041 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/RuleQueryFactoryIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/RuleQueryFactoryIT.java @@ -71,7 +71,7 @@ import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TYPES; public class RuleQueryFactoryIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java index 0e6a06f7971..bbf8f70feba 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java @@ -114,7 +114,7 @@ public class SearchActionIT { private final System2 system2 = new AlwaysIncreasingSystem2(); @org.junit.Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @org.junit.Rule public EsTester es = EsTester.create(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/GenerateSecretKeyActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/GenerateSecretKeyActionIT.java index be15012b0ee..ab99b80b025 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/GenerateSecretKeyActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/GenerateSecretKeyActionIT.java @@ -47,7 +47,7 @@ public class GenerateSecretKeyActionIT { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private DbClient dbClient = db.getDbClient(); private MapSettings settings = new MapSettings(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java index 4fc97352a34..e400fa39ebf 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java @@ -68,7 +68,7 @@ public class ListDefinitionsActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final DbClient dbClient = db.getDbClient(); private ProjectDto project; diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java index 9e2d6411294..bbdbdb77fa0 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java @@ -67,7 +67,7 @@ public class ResetActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final I18nRule i18n = new I18nRule(); private final PropertyDbTester propertyDb = new PropertyDbTester(db); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java index 24510b7afc2..e196bbe4d28 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java @@ -80,7 +80,7 @@ public class SetActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone().logIn(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final PropertyDbTester propertyDb = new PropertyDbTester(db); private final DbClient dbClient = db.getDbClient(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SettingsUpdaterIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SettingsUpdaterIT.java index 681ef67f4cf..d370f9f4648 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SettingsUpdaterIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SettingsUpdaterIT.java @@ -48,7 +48,7 @@ public class SettingsUpdaterIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); DbClient dbClient = db.getDbClient(); DbSession dbSession = db.getSession(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ValuesActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ValuesActionIT.java index 58dd418deb8..80bcf38f408 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ValuesActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ValuesActionIT.java @@ -77,7 +77,7 @@ public class ValuesActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final DbClient dbClient = db.getDbClient(); private final PropertyDefinitions definitions = new PropertyDefinitions(System2.INSTANCE); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/IssueSnippetsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/IssueSnippetsActionIT.java index 05a5513b20b..7a04590fb54 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/IssueSnippetsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/IssueSnippetsActionIT.java @@ -67,7 +67,7 @@ import static org.sonar.db.component.ComponentTesting.newFileDto; public class IssueSnippetsActionIT { @Rule - public final DbTester db = DbTester.create(System2.INSTANCE); + public final DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public final UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/RawActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/RawActionIT.java index 5c49515e166..3bd9ec6969d 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/RawActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/source/ws/RawActionIT.java @@ -47,7 +47,7 @@ public class RawActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ui/ws/ComponentActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ui/ws/ComponentActionIT.java index dbb9df2c488..68d1b1f9810 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ui/ws/ComponentActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ui/ws/ComponentActionIT.java @@ -98,7 +98,7 @@ import static org.sonar.test.JsonAssert.assertJson; public class ComponentActionIT { @Rule - public final DbTester db = DbTester.create(System2.INSTANCE); + public final DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public final UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/AnonymizeActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/AnonymizeActionIT.java index a03f4399b57..22852b0f1a3 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/AnonymizeActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/AnonymizeActionIT.java @@ -48,7 +48,7 @@ public class AnonymizeActionIT { private final System2 system2 = new AlwaysIncreasingSystem2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CreateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CreateActionIT.java index 5af7f5a8c5e..96e5b27f69b 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CreateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/CreateActionIT.java @@ -64,7 +64,7 @@ public class CreateActionIT { private final System2 system2 = new AlwaysIncreasingSystem2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public UserSessionRule userSessionRule = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/DeactivateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/DeactivateActionIT.java index 665db995126..097371f5ceb 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/DeactivateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/DeactivateActionIT.java @@ -71,7 +71,7 @@ public class DeactivateActionIT { private final System2 system2 = new AlwaysIncreasingSystem2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/DismissNoticeActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/DismissNoticeActionIT.java index ef7427b9f58..219d8aca4c0 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/DismissNoticeActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/DismissNoticeActionIT.java @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; public class DismissNoticeActionIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSessionRule = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UpdateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UpdateActionIT.java index cf0f8bfee69..716ec175f9a 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UpdateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UpdateActionIT.java @@ -60,7 +60,7 @@ public class UpdateActionIT { private final System2 system2 = new System2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone().logIn().setSystemAdministrator(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UpdateLoginActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UpdateLoginActionIT.java index ef372d567d0..9874b303854 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UpdateLoginActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UpdateLoginActionIT.java @@ -52,7 +52,7 @@ public class UpdateLoginActionIT { private final System2 system2 = new System2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone().logIn().setSystemAdministrator(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UserAnonymizerIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UserAnonymizerIT.java index e10daea53a4..d54826d578a 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UserAnonymizerIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/user/ws/UserAnonymizerIT.java @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class UserAnonymizerIT { private final System2 system2 = new AlwaysIncreasingSystem2(); @Rule - public DbTester db = DbTester.create(system2); + public DbTester db = DbTester.create(system2, true); private final UserAnonymizer userAnonymizer = new UserAnonymizer(db.getDbClient()); @Test diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/CreateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/CreateActionIT.java index 42043b7af36..b440e2a158b 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/CreateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/CreateActionIT.java @@ -45,7 +45,7 @@ import static org.sonar.db.permission.GlobalPermission.ADMINISTER; public class CreateActionIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); private ManagedInstanceChecker managedInstanceChecker = mock(ManagedInstanceChecker.class); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/ExternalGroupServiceIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/ExternalGroupServiceIT.java index a355dbfd164..5d039607ba4 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/ExternalGroupServiceIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/ExternalGroupServiceIT.java @@ -39,7 +39,7 @@ public class ExternalGroupServiceIT { private static final String EXTERNAL_IDENTITY_PROVIDER = "EXTERNAL_IDENTITY_PROVIDER"; @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); + public DbTester dbTester = DbTester.create(System2.INSTANCE, true); private final DbClient dbClient = dbTester.getDbClient(); private final DbSession dbSession = dbTester.getSession(); private final GroupService groupService = new GroupService(dbClient, UuidFactoryFast.getInstance()); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/SearchActionIT.java index c8951c475cb..afd4f683982 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/SearchActionIT.java @@ -65,7 +65,7 @@ import static org.sonarqube.ws.UserGroups.SearchWsResponse; public class SearchActionIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UpdateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UpdateActionIT.java index c065b8e5300..6b72a31fb3c 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UpdateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UpdateActionIT.java @@ -50,7 +50,7 @@ import static org.sonar.test.JsonAssert.assertJson; public class UpdateActionIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UsersActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UsersActionIT.java index 3888e144b20..ac1645f2718 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UsersActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UsersActionIT.java @@ -54,7 +54,7 @@ import static org.sonar.test.JsonAssert.assertJson; public class UsersActionIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/GenerateActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/GenerateActionIT.java index 0911b363362..96fed1f8dff 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/GenerateActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/GenerateActionIT.java @@ -81,7 +81,7 @@ public class GenerateActionIT { private static final String TOKEN_NAME = "Third Party Application"; @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/RevokeActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/RevokeActionIT.java index c819e7bcf55..b01d3ebf449 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/RevokeActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/RevokeActionIT.java @@ -44,7 +44,7 @@ import static org.sonar.server.usertoken.ws.UserTokenSupport.PARAM_NAME; public class RevokeActionIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); @Rule public UserSessionRule userSession = UserSessionRule.standalone(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/SearchActionIT.java index 8107381c437..a90239f7b5d 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usertoken/ws/SearchActionIT.java @@ -50,7 +50,7 @@ public class SearchActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private DbClient dbClient = db.getDbClient(); private WsActionTester ws = new WsActionTester(new SearchAction(dbClient, new UserTokenSupport(db.getDbClient(), userSession))); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java index d5020e4663c..3a3c835f627 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java @@ -235,9 +235,9 @@ public class ActivityAction implements CeWsAction { String componentKey = request.getComponent(); if (componentKey != null) { - Optional foundComponent; - foundComponent = dbClient.entityDao().selectByKey(dbSession, componentKey); - return checkFoundWithOptional(foundComponent, "Component '%s' does not exist", componentKey); + Optional foundEntity; + foundEntity = dbClient.entityDao().selectByKey(dbSession, componentKey); + return checkFoundWithOptional(foundEntity, "Component '%s' does not exist", componentKey); } else { return null; } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchAction.java index 06bd4e41cf4..7a6ab621dbc 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/SearchAction.java @@ -35,6 +35,7 @@ import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DatabaseUtils; import org.sonar.db.DbClient; import org.sonar.db.DbSession; +import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentQuery; import org.sonar.db.component.ProjectLastAnalysisDateDto; @@ -102,7 +103,7 @@ public class SearchAction implements ProjectsWsAction { action.createParam(PARAM_VISIBILITY) .setDescription("Filter the projects that should be visible to everyone (%s), or only specific user/groups (%s).
" + - "If no visibility is specified, the default project visibility will be used.", + "If no visibility is specified, the default project visibility will be used.", Visibility.PUBLIC.getLabel(), Visibility.PRIVATE.getLabel()) .setRequired(false) .setInternal(true) @@ -159,13 +160,15 @@ public class SearchAction implements ProjectsWsAction { Paging paging = buildPaging(dbSession, request, query); List components = dbClient.componentDao().selectByQuery(dbSession, query, paging.offset(), paging.pageSize()); Set componentUuids = components.stream().map(ComponentDto::uuid).collect(MoreCollectors.toHashSet(components.size())); - Map lastAnalysisDateByComponentUuid = dbClient.snapshotDao().selectLastAnalysisDateByProjectUuids(dbSession, componentUuids).stream() + List branchDtos = dbClient.branchDao().selectByUuids(dbSession, componentUuids); + Map projectUuidByComponentUuid = branchDtos.stream().collect(Collectors.toMap(BranchDto::getUuid,BranchDto::getProjectUuid)); + Map lastAnalysisDateByComponentUuid = dbClient.snapshotDao().selectLastAnalysisDateByProjectUuids(dbSession, projectUuidByComponentUuid.values()).stream() .collect(Collectors.toMap(ProjectLastAnalysisDateDto::getProjectUuid, ProjectLastAnalysisDateDto::getDate)); Map snapshotsByComponentUuid = dbClient.snapshotDao() .selectLastAnalysesByRootComponentUuids(dbSession, componentUuids).stream() .collect(MoreCollectors.uniqueIndex(SnapshotDto::getRootComponentUuid, identity())); - return buildResponse(components, snapshotsByComponentUuid, lastAnalysisDateByComponentUuid, paging); + return buildResponse(components, snapshotsByComponentUuid, lastAnalysisDateByComponentUuid, projectUuidByComponentUuid, paging); } } @@ -194,7 +197,7 @@ public class SearchAction implements ProjectsWsAction { } private static SearchWsResponse buildResponse(List components, Map snapshotsByComponentUuid, - Map lastAnalysisDateByComponentUuid, Paging paging) { + Map lastAnalysisDateByComponentUuid, Map projectUuidByComponentUuid, Paging paging) { SearchWsResponse.Builder responseBuilder = newBuilder(); responseBuilder.getPagingBuilder() .setPageIndex(paging.pageIndex()) @@ -203,7 +206,7 @@ public class SearchAction implements ProjectsWsAction { .build(); components.stream() - .map(dto -> dtoToProject(dto, snapshotsByComponentUuid.get(dto.uuid()), lastAnalysisDateByComponentUuid.get(dto.uuid()))) + .map(dto -> dtoToProject(dto, snapshotsByComponentUuid.get(dto.uuid()), lastAnalysisDateByComponentUuid.get(projectUuidByComponentUuid.get(dto.uuid())))) .forEach(responseBuilder::addComponents); return responseBuilder.build(); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java index ed2da8ed38b..98acd6d07b7 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/TaskFormatterTest.java @@ -52,7 +52,7 @@ public class TaskFormatterTest { private static final int WARNING_COUNT = 5; @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final System2 system2 = mock(System2.class); private final TaskFormatter underTest = new TaskFormatter(db.getDbClient(), system2); -- 2.39.5