use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ProjectQgateAssociationDaoTest method select_qgate_id_is_absent.
@Test
public void select_qgate_id_is_absent() {
ComponentDto project = db.components().insertProject();
Optional<Long> result = underTest.selectQGateIdByComponentId(dbSession, project.getId());
assertThat(result.isPresent()).isFalse();
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class QualityProfileDaoTest method select_selected_projects.
@Test
public void select_selected_projects() throws Exception {
ComponentDto project1 = dbTester.components().insertProject((t) -> t.setName("Project1 name"));
ComponentDto project2 = dbTester.components().insertProject((t) -> t.setName("Project2 name"));
ComponentDto project3 = dbTester.components().insertProject((t) -> t.setName("Project3 name"));
QualityProfileDto profile1 = newQualityProfileDto();
qualityProfileDb.insertQualityProfiles(profile1);
qualityProfileDb.associateProjectWithQualityProfile(project1, profile1);
qualityProfileDb.associateProjectWithQualityProfile(project2, profile1);
QualityProfileDto profile2 = newQualityProfileDto();
qualityProfileDb.insertQualityProfiles(profile2);
qualityProfileDb.associateProjectWithQualityProfile(project3, profile2);
assertThat(underTest.selectSelectedProjects(profile1.getKey(), null, dbSession)).extracting("projectId", "projectUuid", "projectKey", "projectName", "profileKey").containsOnly(tuple(project1.getId(), project1.uuid(), project1.key(), project1.name(), profile1.getKey()), tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), profile1.getKey()));
assertThat(underTest.selectSelectedProjects(profile1.getKey(), "ect1", dbSession)).hasSize(1);
assertThat(underTest.selectSelectedProjects("unknown", null, dbSession)).isEmpty();
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class QualityProfileDaoTest method select_deselected_projects.
@Test
public void select_deselected_projects() throws Exception {
ComponentDto project1 = dbTester.components().insertProject((t) -> t.setName("Project1 name"));
ComponentDto project2 = dbTester.components().insertProject((t) -> t.setName("Project2 name"));
ComponentDto project3 = dbTester.components().insertProject((t) -> t.setName("Project3 name"));
QualityProfileDto profile1 = newQualityProfileDto();
qualityProfileDb.insertQualityProfiles(profile1);
qualityProfileDb.associateProjectWithQualityProfile(project1, profile1);
QualityProfileDto profile2 = newQualityProfileDto();
qualityProfileDb.insertQualityProfiles(profile2);
qualityProfileDb.associateProjectWithQualityProfile(project2, profile2);
assertThat(underTest.selectDeselectedProjects(profile1.getKey(), null, dbSession)).extracting("projectId", "projectUuid", "projectKey", "projectName", "profileKey").containsOnly(tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), null), tuple(project3.getId(), project3.uuid(), project3.key(), project3.name(), null));
assertThat(underTest.selectDeselectedProjects(profile1.getKey(), "ect2", dbSession)).hasSize(1);
assertThat(underTest.selectDeselectedProjects("unknown", null, dbSession)).hasSize(3);
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class AuthorizationDaoTest method selectProjectPermissionsOfAnonymous_returns_permissions_of_anonymous_user_on_specified_project.
@Test
public void selectProjectPermissionsOfAnonymous_returns_permissions_of_anonymous_user_on_specified_project() {
ComponentDto project = db.components().insertProject(org);
db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project);
db.users().insertProjectPermissionOnUser(db.users().insertUser(), UserRole.USER, project);
ComponentDto otherProject = db.components().insertProject();
db.users().insertProjectPermissionOnAnyone(UserRole.ISSUE_ADMIN, otherProject);
assertThat(underTest.selectProjectPermissionsOfAnonymous(dbSession, project.uuid())).containsOnly(UserRole.CODEVIEWER);
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class AuthorizationDaoTest method selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project.
@Test
public void selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project() {
ComponentDto project = db.components().insertProject(org);
db.users().insertProjectPermissionOnUser(user, UserRole.CODEVIEWER, project);
db.users().insertProjectPermissionOnUser(db.users().insertUser(), UserRole.ISSUE_ADMIN, project);
assertThat(underTest.selectProjectPermissions(dbSession, project.uuid(), user.getId())).containsOnly(UserRole.CODEVIEWER);
}
Aggregations