use of org.sonar.db.component.BranchDto in project sonarqube by SonarSource.
the class ExportBranchesStepTest method setUp.
@Before
public void setUp() {
Date createdAt = new Date();
ComponentDto projectDto = dbTester.components().insertPublicProject(PROJECT).setCreatedAt(createdAt);
for (BranchDto branch : branches) {
createdAt = DateUtils.addMinutes(createdAt, 10);
dbTester.components().insertProjectBranch(PROJECT, branch).setCreatedAt(createdAt);
}
dbTester.commit();
when(projectHolder.projectDto()).thenReturn(dbTester.components().getProjectDto(projectDto));
}
use of org.sonar.db.component.BranchDto in project sonarqube by SonarSource.
the class ExportIssuesChangelogStepTest method setUp.
@Before
public void setUp() {
ComponentDto projectDto = dbTester.components().insertPublicProject(p -> p.setUuid(PROJECT_UUID));
when(projectHolder.projectDto()).thenReturn(dbTester.components().getProjectDto(projectDto));
when(projectHolder.branches()).thenReturn(newArrayList(new BranchDto().setBranchType(BranchType.BRANCH).setKey("master").setProjectUuid(PROJECT_UUID).setUuid(PROJECT_UUID)));
insertIssue(PROJECT_UUID, ISSUE_OPEN_UUID, STATUS_OPEN);
insertIssue(PROJECT_UUID, ISSUE_CONFIRMED_UUID, STATUS_CONFIRMED);
insertIssue(PROJECT_UUID, ISSUE_REOPENED_UUID, STATUS_REOPENED);
insertIssue(PROJECT_UUID, ISSUE_RESOLVED_UUID, STATUS_RESOLVED);
insertIssue(PROJECT_UUID, ISSUE_CLOSED_UUID, STATUS_CLOSED);
}
use of org.sonar.db.component.BranchDto in project sonarqube by SonarSource.
the class PurgeCommandsTest method deleteNewCodePeriodsByRootUuid_deletes_branch_new_code_periods.
@Test
public void deleteNewCodePeriodsByRootUuid_deletes_branch_new_code_periods() {
ComponentDto project = dbTester.components().insertPrivateProject();
BranchDto branch = newBranchDto(project);
dbTester.components().insertProjectBranch(project, branch);
// global settings
dbTester.newCodePeriods().insert(NewCodePeriodType.PREVIOUS_VERSION, null);
// project settings
dbTester.newCodePeriods().insert(project.uuid(), NewCodePeriodType.NUMBER_OF_DAYS, "20");
// branch settings
dbTester.newCodePeriods().insert(project.uuid(), branch.getUuid(), NewCodePeriodType.NUMBER_OF_DAYS, "1");
PurgeCommands purgeCommands = new PurgeCommands(dbTester.getSession(), profiler, system2);
purgeCommands.deleteNewCodePeriods(branch.getUuid());
// should delete branch settings only
assertThat(dbTester.countRowsOfTable("new_code_periods")).isEqualTo(2);
}
use of org.sonar.db.component.BranchDto in project sonarqube by SonarSource.
the class PortfolioDaoTest method select_root_reference_to_app_with_branches.
@Test
public void select_root_reference_to_app_with_branches() {
PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app").setName("app"));
BranchDto branch = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
db.components().addPortfolioApplicationBranch(portfolio.getUuid(), app.getUuid(), branch.getUuid());
assertThat(portfolioDao.selectRootOfReferencersToAppBranch(db.getSession(), app.getUuid(), branch.getKey())).extracting(PortfolioDto::getKey).containsExactly(portfolio.getKey());
}
use of org.sonar.db.component.BranchDto in project sonarqube by SonarSource.
the class PortfolioDaoTest method deleteReferenceBranch.
@Test
public void deleteReferenceBranch() {
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());
assertThat(portfolioDao.selectReferenceToApp(db.getSession(), portfolio.getUuid(), app.getKey())).isPresent().map(ReferenceDto::getBranchUuids).contains(Set.of(branch1.getUuid(), branch2.getUuid(), app.getUuid()));
portfolioDao.deleteReferenceBranch(db.getSession(), portfolio.getUuid(), app.getUuid(), branch1.getUuid());
assertThat(portfolioDao.selectReferenceToApp(db.getSession(), portfolio.getUuid(), app.getKey())).isPresent().map(ReferenceDto::getBranchUuids).contains(Set.of(branch2.getUuid(), app.getUuid()));
}
Aggregations