profiler.stop();
}
+ void deleteApplicationProjectsByProject(String projectUuid) {
+ profiler.start("deleteApplicationProjectsByProject (app_projects)");
+ purgeMapper.deleteAppBranchProjectBranchesByProjectUuid(projectUuid);
+ purgeMapper.deleteAppProjectsByProjectUuid(projectUuid);
+ session.commit();
+ profiler.stop();
+ }
+
void deleteApplicationProjects(String applicationUuid) {
profiler.start("deleteApplicationProjects (app_projects)");
- purgeMapper.deleteApplicationBranchProjectBranchesByApplicationUuid(applicationUuid);
- purgeMapper.deleteApplicationProjectsByApplicationUuid(applicationUuid);
+ purgeMapper.deleteAppBranchProjectBranchesByAppUuid(applicationUuid);
+ purgeMapper.deleteAppProjectsByAppUuid(applicationUuid);
session.commit();
profiler.stop();
}
void deleteApplicationBranchProjects(String applicationBranchUuid) {
profiler.start("deleteApplicationBranchProjects (app_branch_project_branch)");
- purgeMapper.deleteApplicationBranchProjects(applicationBranchUuid);
+ purgeMapper.deleteAppBranchProjectsByAppBranchUuid(applicationBranchUuid);
session.commit();
profiler.stop();
}
void deleteBranch(String rootUuid) {
profiler.start("deleteBranch (project_branches)");
- purgeMapper.deleteApplicationBranchProjectBranchesByProjectBranchUuid(rootUuid);
+ purgeMapper.deleteAppBranchProjectBranchesByProjectBranchUuid(rootUuid);
purgeMapper.deleteBranchByUuid(rootUuid);
session.commit();
profiler.stop();
commands.deleteBranch(rootUuid);
commands.deleteApplicationBranchProjects(rootUuid);
commands.deleteApplicationProjects(rootUuid);
+ commands.deleteApplicationProjectsByProject(rootUuid);
commands.deleteProjectInPortfolios(rootUuid);
commands.deleteComponents(rootUuid);
commands.deleteComponentsByMainBranchProjectUuid(rootUuid);
void deleteProjectMappingsByProjectUuid(@Param("projectUuid") String projectUuid);
- void deleteApplicationProjectsByApplicationUuid(@Param("applicationUuid") String applicationUuid);
+ void deleteAppProjectsByAppUuid(@Param("applicationUuid") String applicationUuid);
- void deleteApplicationBranchProjectBranchesByApplicationUuid(@Param("applicationUuid") String applicationUuid);
+ void deleteAppProjectsByProjectUuid(@Param("projectUuid") String projectUuid);
- void deleteApplicationBranchProjects(@Param("branchUuid") String applicationBranchUuid);
+ void deleteAppBranchProjectBranchesByAppUuid(@Param("applicationUuid") String applicationUuid);
- void deleteApplicationBranchProjectBranchesByProjectBranchUuid(@Param("projectBranchUuid") String projectBranchUuid);
+ void deleteAppBranchProjectBranchesByProjectUuid(@Param("projectUuid") String projectUuid);
+
+ void deleteAppBranchProjectsByAppBranchUuid(@Param("branchUuid") String applicationBranchUuid);
+
+ void deleteAppBranchProjectBranchesByProjectBranchUuid(@Param("projectBranchUuid") String projectBranchUuid);
void deletePortfolioProjectsByBranchUuid(@Param("branchUuid") String branchUuid);
</foreach>
</delete>
- <delete id="deleteApplicationProjectsByApplicationUuid" parameterType="map">
+ <delete id="deleteAppProjectsByAppUuid" parameterType="map">
DELETE
FROM app_projects
WHERE
application_uuid=#{applicationUuid,jdbcType=VARCHAR}
</delete>
- <delete id="deleteApplicationBranchProjectBranchesByApplicationUuid" parameterType="map">
+ <delete id="deleteAppProjectsByProjectUuid" parameterType="map">
+ DELETE
+ FROM app_projects
+ WHERE
+ project_uuid=#{projectUuid,jdbcType=VARCHAR}
+ </delete>
+
+ <delete id="deleteAppBranchProjectBranchesByAppUuid" parameterType="map">
DELETE
FROM app_branch_project_branch
WHERE
application_uuid=#{applicationUuid,jdbcType=VARCHAR}
</delete>
- <delete id="deleteApplicationBranchProjects" parameterType="String">
+ <delete id="deleteAppBranchProjectBranchesByProjectUuid" parameterType="map">
+ DELETE
+ FROM app_branch_project_branch
+ WHERE
+ project_uuid=#{projectUuid,jdbcType=VARCHAR}
+ </delete>
+
+ <delete id="deleteAppBranchProjectsByAppBranchUuid" parameterType="String">
DELETE
FROM app_branch_project_branch
WHERE
application_branch_uuid=#{branchUuid,jdbcType=VARCHAR}
</delete>
- <delete id="deleteApplicationBranchProjectBranchesByProjectBranchUuid" parameterType="String">
+ <delete id="deleteAppBranchProjectBranchesByProjectBranchUuid" parameterType="String">
DELETE
FROM app_branch_project_branch
WHERE project_branch_uuid=#{projectBranchUuid,jdbcType=VARCHAR}
assertThat(uuidsIn("app_projects", "application_uuid")).containsOnly(app.uuid(), otherApp.uuid());
assertThat(uuidsIn("app_branch_project_branch", "application_branch_uuid")).containsOnly(otherAppBranch.uuid());
assertThat(componentUuidsIn("properties")).containsOnly(otherAppBranch.uuid());
-
}
@Test
.containsExactlyInAnyOrder(tuple(portfolio1.uuid(), otherProject.getUuid()));
}
+ @Test
+ public void deleteProject_deletes_app_projects() {
+ ProjectDto app = db.components().insertPrivateApplicationDto();
+ BranchDto appBranch = db.components().insertProjectBranch(app);
+
+ ProjectDto project = db.components().insertPublicProjectDto();
+ BranchDto projectBranch = db.components().insertProjectBranch(project);
+
+ ProjectDto otherProject = db.components().insertPublicProjectDto();
+
+ db.components().addApplicationProject(app, project, otherProject);
+ db.components().addProjectBranchToApplicationBranch(appBranch, projectBranch);
+
+ assertThat(db.countRowsOfTable("app_branch_project_branch")).isOne();
+
+ underTest.deleteProject(dbSession, project.getUuid(), project.getQualifier(), project.getName(), project.getKey());
+
+ assertThat(dbClient.applicationProjectsDao().selectProjects(dbSession, app.getUuid()))
+ .extracting(ProjectDto::getUuid)
+ .containsExactlyInAnyOrder(otherProject.getUuid());
+ assertThat(db.countRowsOfTable("app_branch_project_branch")).isZero();
+ }
+
@Test
public void deleteNonRootComponents_has_no_effect_when_parameter_is_empty() {
DbSession dbSession = mock(DbSession.class);