Search in sources :

Example 41 with ProjectDto

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();
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 42 with ProjectDto

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());
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Map(java.util.Map) Test(org.junit.Test)

Example 43 with ProjectDto

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();
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 44 with ProjectDto

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());
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Example 45 with ProjectDto

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();
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) Test(org.junit.Test)

Aggregations

ProjectDto (org.sonar.db.project.ProjectDto)283 Test (org.junit.Test)215 DbSession (org.sonar.db.DbSession)49 BranchDto (org.sonar.db.component.BranchDto)42 UserDto (org.sonar.db.user.UserDto)39 AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)38 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)31 SnapshotDto (org.sonar.db.component.SnapshotDto)27 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)26 ComponentDto (org.sonar.db.component.ComponentDto)23 ComponentTesting.newPrivateProjectDto (org.sonar.db.component.ComponentTesting.newPrivateProjectDto)20 NotFoundException (org.sonar.server.exceptions.NotFoundException)17 WebhookDto (org.sonar.db.webhook.WebhookDto)15 ApplicationProjectDto (org.sonar.db.project.ApplicationProjectDto)14 WebService (org.sonar.api.server.ws.WebService)13 DbClient (org.sonar.db.DbClient)12 PortfolioProjectDto (org.sonar.db.portfolio.PortfolioProjectDto)12 TestRequest (org.sonar.server.ws.TestRequest)11 TestResponse (org.sonar.server.ws.TestResponse)10 Projects (org.sonarqube.ws.Projects)10