From 2aa46faae4e27b4c1a6bbfb521fed9e5ce584158 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Mon, 8 May 2023 15:03:15 -0500 Subject: [PATCH] SONAR-18856 Refactor 'new_code_periods' --- .../org/sonar/db/newcodeperiod/NewCodePeriodDaoIT.java | 9 ++++++--- .../org/sonar/server/newcodeperiod/ws/ListActionIT.java | 2 +- .../org/sonar/server/newcodeperiod/ws/SetActionIT.java | 2 +- .../org/sonar/server/newcodeperiod/ws/ShowActionIT.java | 2 +- .../org/sonar/server/newcodeperiod/ws/UnsetActionIT.java | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/newcodeperiod/NewCodePeriodDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/newcodeperiod/NewCodePeriodDaoIT.java index 52c731dbaf0..208f8d9c664 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/newcodeperiod/NewCodePeriodDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/newcodeperiod/NewCodePeriodDaoIT.java @@ -29,6 +29,8 @@ import org.sonar.core.util.UuidFactory; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.component.BranchDto; +import org.sonar.db.component.ComponentDbTester; +import org.sonar.db.component.ProjectData; import org.sonar.db.project.ProjectDto; import static org.assertj.core.api.Assertions.assertThat; @@ -42,7 +44,7 @@ import static org.sonar.db.newcodeperiod.NewCodePeriodType.SPECIFIC_ANALYSIS; public class NewCodePeriodDaoIT { @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private final DbSession dbSession = db.getSession(); private final UuidFactory uuidFactory = new SequenceUuidFactory(); @@ -191,8 +193,9 @@ public class NewCodePeriodDaoIT { @Test public void select_branches_referencing() { - ProjectDto project = db.components().insertPrivateProject().getProjectDto(); - BranchDto mainBranch = db.getDbClient().branchDao().selectByUuid(dbSession, project.getUuid()).get(); + ProjectData projectData = db.components().insertPrivateProject(); + ProjectDto project = projectData.getProjectDto(); + BranchDto mainBranch = projectData.getMainBranchDto(); BranchDto branch1 = db.components().insertProjectBranch(project); BranchDto branch2 = db.components().insertProjectBranch(project); BranchDto branch3 = db.components().insertProjectBranch(project); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/ListActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/ListActionIT.java index 040bf225dcd..68867b8bc10 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/ListActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/ListActionIT.java @@ -81,7 +81,7 @@ import static org.sonar.db.component.SnapshotTesting.newAnalysis; @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private ComponentDbTester componentDb = new ComponentDbTester(db); private DbClient dbClient = db.getDbClient(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/SetActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/SetActionIT.java index 20baefcfb20..ce442e615ef 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/SetActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/SetActionIT.java @@ -64,7 +64,7 @@ public class SetActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private ComponentDbTester componentDb = new ComponentDbTester(db); private DbClient dbClient = db.getDbClient(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/ShowActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/ShowActionIT.java index 930e9fde621..9a073dc3959 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/ShowActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/ShowActionIT.java @@ -53,7 +53,7 @@ public class ShowActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private ComponentDbTester componentDb = new ComponentDbTester(db); private DbClient dbClient = db.getDbClient(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/UnsetActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/UnsetActionIT.java index c6e73d9de37..934d6f2ec0c 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/UnsetActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/newcodeperiod/ws/UnsetActionIT.java @@ -56,7 +56,7 @@ public class UnsetActionIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @Rule - public DbTester db = DbTester.create(System2.INSTANCE); + public DbTester db = DbTester.create(System2.INSTANCE, true); private ComponentDbTester componentDb = new ComponentDbTester(db); private DbClient dbClient = db.getDbClient(); -- 2.39.5