use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class QualityProfileDaoTest method deleteProjectAssociationsByProfileUuids_does_nothing_if_empty_uuids.
@Test
public void deleteProjectAssociationsByProfileUuids_does_nothing_if_empty_uuids() {
QProfileDto profile = db.qualityProfiles().insert();
ProjectDto project = db.components().insertPrivateProjectDto();
db.qualityProfiles().associateWithProject(project, profile);
underTest.deleteProjectAssociationsByProfileUuids(dbSession, Collections.emptyList());
assertThat(db.countRowsOfTable(dbSession, "project_qprofiles")).isOne();
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class QualityProfileDaoTest method test_deleteProjectAssociationsByProfileUuids.
@Test
public void test_deleteProjectAssociationsByProfileUuids() {
QProfileDto profile1 = db.qualityProfiles().insert();
QProfileDto profile2 = db.qualityProfiles().insert();
ProjectDto project1 = db.components().insertPrivateProjectDto();
ProjectDto project2 = db.components().insertPrivateProjectDto();
ProjectDto project3 = db.components().insertPrivateProjectDto();
db.getDbClient().projectDao().selectByUuid(dbSession, project1.getUuid()).get();
db.qualityProfiles().associateWithProject(project1, profile1);
db.qualityProfiles().associateWithProject(project2, profile1);
db.qualityProfiles().associateWithProject(project3, profile2);
underTest.deleteProjectAssociationsByProfileUuids(dbSession, asList(profile1.getKee(), "does_not_exist"));
List<Map<String, Object>> rows = db.select(dbSession, "select project_uuid as \"projectUuid\", profile_key as \"profileKey\" from project_qprofiles");
assertThat(rows).hasSize(1);
assertThat(rows.get(0)).containsEntry("projectUuid", project3.getUuid());
assertThat(rows.get(0)).containsEntry("profileKey", profile2.getKee());
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ProjectQgateAssociationDaoTest method delete_by_qgate_uuid.
@Test
public void delete_by_qgate_uuid() {
QualityGateDto qualityGate = db.qualityGates().insertQualityGate();
ProjectDto project = db.components().insertPrivateProjectDto();
db.qualityGates().associateProjectToQualityGate(project, qualityGate);
underTest.deleteByQGateUuid(dbSession, qualityGate.getUuid());
Optional<String> deletedQualityGate = db.qualityGates().selectQGateUuidByComponentUuid(project.getUuid());
assertThat(deletedQualityGate).isEmpty();
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class ProjectQgateAssociationDaoTest method update_project_qgate_association.
@Test
public void update_project_qgate_association() {
QualityGateDto firstQualityGate = db.qualityGates().insertQualityGate();
QualityGateDto secondQualityGate = db.qualityGates().insertQualityGate();
ProjectDto project = db.components().insertPrivateProjectDto();
db.qualityGates().associateProjectToQualityGate(project, firstQualityGate);
underTest.updateProjectQGateAssociation(dbSession, project.getUuid(), secondQualityGate.getUuid());
Optional<String> updatedQualityGateUuid = db.qualityGates().selectQGateUuidByComponentUuid(project.getUuid());
assertThat(updatedQualityGateUuid).contains(secondQualityGate.getUuid());
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class QualityGateDaoTest method select_by_project_uuid.
@Test
public void select_by_project_uuid() {
ProjectDto project = db.components().insertPrivateProjectDto();
QualityGateDto qualityGate1 = db.qualityGates().insertQualityGate();
QualityGateDto qualityGate2 = db.qualityGates().insertQualityGate();
QualityGateDto qualityGate3 = db.qualityGates().insertQualityGate();
db.qualityGates().associateProjectToQualityGate(project, qualityGate1);
assertThat(underTest.selectByProjectUuid(dbSession, project.getUuid()).getUuid()).isEqualTo(qualityGate1.getUuid());
assertThat(underTest.selectByProjectUuid(dbSession, "not-existing-uuid")).isNull();
}
Aggregations