use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class PortfolioDaoTest method add_and_delete_selected_branches.
@Test
public void add_and_delete_selected_branches() {
PortfolioDto portfolio1 = db.components().insertPrivatePortfolioDto("portfolio1");
ProjectDto project1 = db.components().insertPrivateProjectDto("project1");
db.components().addPortfolioProject(portfolio1, project1);
assertThat(db.countRowsOfTable(db.getSession(), "portfolio_proj_branches")).isZero();
assertThat(portfolioDao.selectPortfolioProjectOrFail(db.getSession(), portfolio1.getUuid(), project1.getUuid()).getBranchUuids()).isEmpty();
db.components().addPortfolioProjectBranch(portfolio1, project1, "branch1");
assertThat(db.countRowsOfTable(db.getSession(), "portfolio_proj_branches")).isOne();
PortfolioProjectDto portfolioProject = portfolioDao.selectPortfolioProjectOrFail(db.getSession(), portfolio1.getUuid(), project1.getUuid());
assertThat(portfolioProject.getBranchUuids()).containsOnly("branch1");
portfolioDao.deleteBranch(db.getSession(), portfolio1.getUuid(), project1.getUuid(), "branch1");
assertThat(db.countRowsOfTable(db.getSession(), "portfolio_proj_branches")).isZero();
assertThat(portfolioDao.selectPortfolioProjectOrFail(db.getSession(), portfolio1.getUuid(), project1.getUuid()).getBranchUuids()).isEmpty();
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class PortfolioDaoTest method select_reference_to_app_by_key.
@Test
public void select_reference_to_app_by_key() {
PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
db.components().addPortfolioReference(portfolio, app1.getUuid());
assertThat(portfolioDao.selectReferenceToApp(db.getSession(), portfolio.getUuid(), app1.getKey())).get().extracting(ReferenceDto::getTargetUuid).isEqualTo(app1.getUuid());
assertThat(portfolioDao.selectReference(db.getSession(), portfolio.getUuid(), app1.getKey())).extracting(ReferenceDto::getTargetUuid).isEqualTo(app1.getUuid());
assertThat(portfolioDao.selectReferenceToPortfolio(db.getSession(), portfolio.getUuid(), app1.getKey())).isEmpty();
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class PortfolioDaoTest method selectAllReferencesToApplicationsInHierarchy.
@Test
public void selectAllReferencesToApplicationsInHierarchy() {
var p1 = db.components().insertPrivatePortfolioDto("portfolio1");
var p2 = db.components().insertPrivatePortfolioDto("portfolio2", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
var p3 = db.components().insertPrivatePortfolioDto("portfolio3", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app2"));
ProjectDto app3 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app3"));
portfolioDao.addReference(session, "portfolio1", app1.getUuid());
portfolioDao.addReference(session, "portfolio2", app2.getUuid());
portfolioDao.addReference(session, "portfolio3", app3.getUuid());
assertThat(portfolioDao.selectAllReferencesToApplicationsInHierarchy(session, p1.getUuid())).extracting(ReferenceDto::getTargetUuid).containsExactlyInAnyOrder(app1.getUuid(), app2.getUuid(), app3.getUuid());
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class PortfolioDaoTest method select_reference_to_app_with_branches.
@Test
public void select_reference_to_app_with_branches() {
PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app").setName("app"));
BranchDto branch1 = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
BranchDto branch2 = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
db.components().addPortfolioReference(portfolio, app.getUuid());
db.components().addPortfolioApplicationBranch(portfolio.getUuid(), app.getUuid(), branch1.getUuid());
db.components().addPortfolioApplicationBranch(portfolio.getUuid(), app.getUuid(), branch2.getUuid());
var appFromDb = portfolioDao.selectReferenceToApp(db.getSession(), portfolio.getUuid(), app.getKey());
assertThat(appFromDb).isPresent();
assertThat(appFromDb.get()).extracting(ReferenceDto::getTargetKey, ReferenceDto::getTargetName, ReferenceDto::getBranchUuids).containsExactly("app", "app", Set.of(branch1.getUuid(), branch2.getUuid(), app.getUuid()));
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class WebhookDaoTest method cleanWebhooksOfAProject.
@Test
public void cleanWebhooksOfAProject() {
ProjectDto projectDto = componentDbTester.insertPrivateProjectDto();
webhookDbTester.insertWebhook(projectDto);
webhookDbTester.insertWebhook(projectDto);
webhookDbTester.insertWebhook(projectDto);
webhookDbTester.insertWebhook(projectDto);
underTest.deleteByProject(dbSession, projectDto);
Optional<WebhookDto> reloaded = underTest.selectByUuid(dbSession, projectDto.getUuid());
assertThat(reloaded).isEmpty();
}
Aggregations