diff options
author | Benjamin Campomenosi <109955405+benjamin-campomenosi-sonarsource@users.noreply.github.com> | 2023-05-11 18:14:53 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-05-11 20:03:13 +0000 |
commit | cb1d70c98d5f7baf58aa9170c37d93df4a245ee6 (patch) | |
tree | 45b35ffdd8c2873f1b722fef127e3a6902da2669 | |
parent | 166b757598f82842941ef85b360cef70254f6519 (diff) | |
download | sonarqube-cb1d70c98d5f7baf58aa9170c37d93df4a245ee6.tar.gz sonarqube-cb1d70c98d5f7baf58aa9170c37d93df4a245ee6.zip |
NO_JIRA fix PurgeDaoIt with new ProjectData structure
-rw-r--r-- | server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java index 041874927e6..7f4bdeb425a 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeDaoIT.java @@ -119,7 +119,7 @@ public class PurgeDaoIT { private final System2 system2 = mock(System2.class); @Rule - public DbTester db = DbTester.create(system2, true); + public DbTester db = DbTester.create(system2); private final DbClient dbClient = db.getDbClient(); private final DbSession dbSession = db.getSession(); @@ -1084,32 +1084,33 @@ public class PurgeDaoIT { return EventComponentChangeDto.ChangeCategory.values()[new Random().nextInt(EventComponentChangeDto.ChangeCategory.values().length)]; } - private ComponentDto insertProjectWithBranchAndRelatedData() { + private ProjectDto insertProjectWithBranchAndRelatedData() { RuleDto rule = db.rules().insert(); - ComponentDto project = db.components().insertPublicProject().getMainBranchComponent(); - ComponentDto branch = db.components().insertProjectBranch(project); - ComponentDto dir = db.components().insertComponent(newDirectory(branch, "path")); - ComponentDto file = db.components().insertComponent(newFileDto(branch, dir)); - db.issues().insert(rule, branch, file); - db.issues().insert(rule, branch, dir); - return project; + ProjectData project = db.components().insertPublicProject(); + BranchDto branch = db.components().insertProjectBranch(project.getProjectDto()); + ComponentDto branchComponent = db.components().getComponentDto(branch); + ComponentDto dir = db.components().insertComponent(newDirectory(branchComponent, "path")); + ComponentDto file = db.components().insertComponent(newFileDto(branchComponent, dir)); + db.issues().insert(rule, branchComponent, file); + db.issues().insert(rule, branchComponent, dir); + return project.getProjectDto(); } @Test public void delete_branch_content_when_deleting_project() { - ComponentDto anotherLivingProject = insertProjectWithBranchAndRelatedData(); + ProjectDto anotherLivingProject = insertProjectWithBranchAndRelatedData(); int projectEntryCount = db.countRowsOfTable("components"); int issueCount = db.countRowsOfTable("issues"); int branchCount = db.countRowsOfTable("project_branches"); Collection<BranchDto> anotherLivingProjectBranches = db.getDbClient().branchDao() - .selectByComponent(db.getSession(), anotherLivingProject); + .selectByProject(db.getSession(), anotherLivingProject); insertPropertyFor(anotherLivingProjectBranches); assertThat(db.countRowsOfTable("properties")).isEqualTo(anotherLivingProjectBranches.size()); - ComponentDto projectToDelete = insertProjectWithBranchAndRelatedData(); + ProjectDto projectToDelete = insertProjectWithBranchAndRelatedData(); Collection<BranchDto> projectToDeleteBranches = db.getDbClient().branchDao() - .selectByComponent(db.getSession(), projectToDelete); + .selectByProject(db.getSession(), projectToDelete); insertPropertyFor(projectToDeleteBranches); assertThat(db.countRowsOfTable("properties")).isEqualTo(anotherLivingProjectBranches.size() + projectToDeleteBranches.size()); @@ -1117,7 +1118,7 @@ public class PurgeDaoIT { assertThat(db.countRowsOfTable("issues")).isGreaterThan(issueCount); assertThat(db.countRowsOfTable("project_branches")).isGreaterThan(branchCount); - underTest.deleteProject(dbSession, projectToDelete.uuid(), projectToDelete.qualifier(), projectToDelete.name(), projectToDelete.getKey()); + underTest.deleteProject(dbSession, projectToDelete.getUuid(), projectToDelete.getQualifier(), projectToDelete.getName(), projectToDelete.getKey()); dbSession.commit(); assertThat(db.countRowsOfTable("components")).isEqualTo(projectEntryCount); |