Search in sources :

Example 1 with PortfolioProjectDto

use of org.sonar.db.portfolio.PortfolioProjectDto in project sonarqube by SonarSource.

the class PurgeCommandsTest method deleteProjectInPortfolios_deletes_branch_from_portfolios_if_root_is_branch.

@Test
public void deleteProjectInPortfolios_deletes_branch_from_portfolios_if_root_is_branch() {
    var portfolio1 = dbTester.components().insertPrivatePortfolioDto();
    ProjectDto project = dbTester.components().insertPrivateProjectDto();
    dbTester.components().addPortfolioProject(portfolio1, project);
    dbTester.components().addPortfolioProjectBranch(portfolio1, project, "projectBranch");
    dbTester.components().addPortfolioProjectBranch(portfolio1, project, "anotherBranch");
    PurgeCommands purgeCommands = new PurgeCommands(dbTester.getSession(), profiler, system2);
    purgeCommands.deleteProjectInPortfolios("projectBranch");
    assertThat(dbTester.getDbClient().portfolioDao().selectAllPortfolioProjects(dbTester.getSession())).extracting(PortfolioProjectDto::getPortfolioUuid, PortfolioProjectDto::getProjectUuid, PortfolioProjectDto::getBranchUuids).containsExactlyInAnyOrder(tuple(portfolio1.getUuid(), project.getUuid(), Set.of("anotherBranch")));
}
Also used : PortfolioProjectDto(org.sonar.db.portfolio.PortfolioProjectDto) ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 2 with PortfolioProjectDto

use of org.sonar.db.portfolio.PortfolioProjectDto in project sonarqube by SonarSource.

the class PurgeCommandsTest method deleteProjectInPortfolios_deletes_project_and_branch_from_portfolios_if_root_is_branch.

@Test
public void deleteProjectInPortfolios_deletes_project_and_branch_from_portfolios_if_root_is_branch() {
    var portfolio1 = dbTester.components().insertPrivatePortfolioDto();
    var portfolio2 = dbTester.components().insertPrivatePortfolioDto();
    dbTester.components().insertPrivatePortfolio();
    ProjectDto project = dbTester.components().insertPrivateProjectDto();
    ProjectDto anotherProject = dbTester.components().insertPrivateProjectDto();
    dbTester.components().addPortfolioProject(portfolio1, project, anotherProject);
    dbTester.components().addPortfolioProjectBranch(portfolio1, project, "projectBranch");
    dbTester.components().addPortfolioProjectBranch(portfolio1, anotherProject, "anotherProjectBranch");
    dbTester.components().addPortfolioProject(portfolio2, project);
    PurgeCommands purgeCommands = new PurgeCommands(dbTester.getSession(), profiler, system2);
    purgeCommands.deleteProjectInPortfolios(project.getUuid());
    assertThat(dbTester.getDbClient().portfolioDao().selectAllPortfolioProjects(dbTester.getSession())).extracting(PortfolioProjectDto::getPortfolioUuid, PortfolioProjectDto::getProjectUuid, PortfolioProjectDto::getBranchUuids).containsExactlyInAnyOrder(tuple(portfolio1.getUuid(), anotherProject.getUuid(), singleton("anotherProjectBranch")));
}
Also used : PortfolioProjectDto(org.sonar.db.portfolio.PortfolioProjectDto) ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 3 with PortfolioProjectDto

use of org.sonar.db.portfolio.PortfolioProjectDto in project sonarqube by SonarSource.

the class PurgeDaoTest method deleteProject_deletes_portfolio_projects.

@Test
public void deleteProject_deletes_portfolio_projects() {
    ComponentDto portfolio1 = db.components().insertPrivatePortfolio();
    ComponentDto portfolio2 = db.components().insertPrivatePortfolio();
    ProjectDto project = db.components().insertPublicProjectDto();
    ProjectDto otherProject = db.components().insertPublicProjectDto();
    db.components().addPortfolioProject(portfolio1, project.getUuid(), otherProject.getUuid());
    db.components().addPortfolioProject(portfolio2, project.getUuid());
    underTest.deleteProject(dbSession, project.getUuid(), project.getQualifier(), project.getName(), project.getKey());
    assertThat(dbClient.portfolioDao().selectAllPortfolioProjects(dbSession)).extracting(PortfolioProjectDto::getPortfolioUuid, PortfolioProjectDto::getProjectUuid).containsExactlyInAnyOrder(tuple(portfolio1.uuid(), otherProject.getUuid()));
}
Also used : PortfolioProjectDto(org.sonar.db.portfolio.PortfolioProjectDto) ProjectDto(org.sonar.db.project.ProjectDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 4 with PortfolioProjectDto

use of org.sonar.db.portfolio.PortfolioProjectDto in project sonarqube by SonarSource.

the class ComponentDbTester method addPortfolioProjectBranch.

public void addPortfolioProjectBranch(String portfolioUuid, String projectUuid, String branchUuid) {
    PortfolioProjectDto portfolioProject = dbClient.portfolioDao().selectPortfolioProjectOrFail(dbSession, portfolioUuid, projectUuid);
    dbClient.portfolioDao().addBranch(db.getSession(), portfolioProject.getUuid(), branchUuid);
    db.commit();
}
Also used : PortfolioProjectDto(org.sonar.db.portfolio.PortfolioProjectDto)

Aggregations

PortfolioProjectDto (org.sonar.db.portfolio.PortfolioProjectDto)4 Test (org.junit.Test)3 ProjectDto (org.sonar.db.project.ProjectDto)3 ComponentDto (org.sonar.db.component.ComponentDto)1