use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ComponentDaoTest method selectComponentsFromBranchesThatHaveOpenIssues_returns_nothing_if_no_open_issues_in_sibling_branches.
@Test
public void selectComponentsFromBranchesThatHaveOpenIssues_returns_nothing_if_no_open_issues_in_sibling_branches() {
final ProjectDto project = db.components().insertPrivateProjectDto(b -> b.setName("foo"));
ComponentDto branch1 = db.components().insertProjectBranch(project, ComponentTesting.newBranchDto(project.getUuid(), BRANCH).setKey("branch1"));
ComponentDto fileBranch1 = db.components().insertComponent(ComponentTesting.newFileDto(branch1));
RuleDefinitionDto rule = db.rules().insert();
db.issues().insert(new IssueDto().setKee("i").setComponent(fileBranch1).setProject(branch1).setRule(rule).setStatus(STATUS_CLOSED));
List<KeyWithUuidDto> result = underTest.selectComponentsFromBranchesThatHaveOpenIssues(db.getSession(), singleton(branch1.uuid()));
assertThat(result).isEmpty();
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ProjectAlmSettingDaoTest method deleteByProject.
@Test
public void deleteByProject() {
when(uuidFactory.create()).thenReturn(A_UUID);
AlmSettingDto githubAlmSetting = db.almSettings().insertGitHubAlmSetting();
ProjectDto project = db.components().insertPrivateProjectDto();
db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting, project);
ProjectDto anotherProject = db.components().insertPrivateProjectDto();
db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting, anotherProject);
underTest.deleteByProject(dbSession, project);
assertThat(underTest.selectByProject(dbSession, project)).isEmpty();
assertThat(underTest.selectByProject(dbSession, anotherProject)).isNotEmpty();
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ProjectAlmSettingDaoWithPersisterTest method deleteByWithoutAffectedRowsProjectIsNotPersisted.
@Test
public void deleteByWithoutAffectedRowsProjectIsNotPersisted() {
ProjectDto project = db.components().insertPrivateProjectDto();
underTest.deleteByProject(dbSession, project);
verify(auditPersister).addComponent(any(), any());
verifyNoMoreInteractions(auditPersister);
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class CeActivityDaoTest method hasAnyFailedOrCancelledIssueSyncTask.
@Test
public void hasAnyFailedOrCancelledIssueSyncTask() {
assertThat(underTest.hasAnyFailedOrCancelledIssueSyncTask(db.getSession())).isFalse();
insert("TASK_1", REPORT, MAINCOMPONENT_1, SUCCESS);
insert("TASK_2", REPORT, MAINCOMPONENT_1, FAILED);
ProjectDto projectDto1 = db.components().insertPrivateProjectDto(branchDto -> branchDto.setNeedIssueSync(false), c -> {
}, p -> {
});
insert("TASK_3", CeTaskTypes.BRANCH_ISSUE_SYNC, projectDto1.getUuid(), projectDto1.getUuid(), SUCCESS);
ProjectDto projectDto2 = db.components().insertPrivateProjectDto(branchDto -> branchDto.setNeedIssueSync(false), c -> {
}, p -> {
});
insert("TASK_4", CeTaskTypes.BRANCH_ISSUE_SYNC, projectDto2.getUuid(), projectDto2.getUuid(), SUCCESS);
assertThat(underTest.hasAnyFailedOrCancelledIssueSyncTask(db.getSession())).isFalse();
ProjectDto projectDto3 = db.components().insertPrivateProjectDto(branchDto -> branchDto.setNeedIssueSync(false), c -> {
}, p -> {
});
insert("TASK_5", CeTaskTypes.BRANCH_ISSUE_SYNC, projectDto3.getUuid(), projectDto3.getUuid(), SUCCESS);
BranchDto projectBranch1 = db.components().insertProjectBranch(projectDto3, branchDto -> branchDto.setNeedIssueSync(true));
insert("TASK_6", CeTaskTypes.BRANCH_ISSUE_SYNC, projectBranch1.getUuid(), projectDto3.getUuid(), FAILED);
BranchDto projectBranch2 = db.components().insertProjectBranch(projectDto3, branchDto -> branchDto.setNeedIssueSync(true));
insert("TASK_7", CeTaskTypes.BRANCH_ISSUE_SYNC, projectBranch2.getUuid(), projectDto3.getUuid(), CANCELED);
// failed task and project branch still exists and need sync
assertThat(underTest.hasAnyFailedOrCancelledIssueSyncTask(db.getSession())).isTrue();
// assume branch has been re-analysed
db.getDbClient().branchDao().updateNeedIssueSync(db.getSession(), projectBranch1.getUuid(), false);
// assume branch has been re-analysed
db.getDbClient().branchDao().updateNeedIssueSync(db.getSession(), projectBranch2.getUuid(), false);
assertThat(underTest.hasAnyFailedOrCancelledIssueSyncTask(db.getSession())).isFalse();
// assume branch has been deleted
db.getDbClient().purgeDao().deleteBranch(db.getSession(), projectBranch1.getUuid());
db.getDbClient().purgeDao().deleteBranch(db.getSession(), projectBranch2.getUuid());
// associated branch does not exist, so there is no failures - either it has been deleted or purged or reanalysed
assertThat(underTest.hasAnyFailedOrCancelledIssueSyncTask(db.getSession())).isFalse();
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ProjectAlmSettingDaoTest method deleteByAlmSetting.
@Test
public void deleteByAlmSetting() {
when(uuidFactory.create()).thenReturn(A_UUID);
AlmSettingDto githubAlmSetting = db.almSettings().insertGitHubAlmSetting();
ProjectDto project1 = db.components().insertPrivateProjectDto();
ProjectDto project2 = db.components().insertPrivateProjectDto();
db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting, project1);
db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting, project2);
AlmSettingDto githubAlmSetting1 = db.almSettings().insertGitHubAlmSetting();
ProjectDto anotherProject = db.components().insertPrivateProjectDto();
db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting1, anotherProject);
underTest.deleteByAlmSetting(dbSession, githubAlmSetting);
assertThat(underTest.countByAlmSetting(dbSession, githubAlmSetting)).isZero();
assertThat(underTest.countByAlmSetting(dbSession, githubAlmSetting1)).isOne();
}
Aggregations