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);
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class GroupPermissionDaoTest method delete_global_permission_from_group.
@Test
public void delete_global_permission_from_group() {
OrganizationDto org = db.organizations().insert();
GroupDto group1 = db.users().insertGroup(org);
ComponentDto project1 = db.components().insertProject(org);
db.users().insertPermissionOnAnyone(org, "perm1");
db.users().insertPermissionOnGroup(group1, "perm2");
db.users().insertProjectPermissionOnGroup(group1, "perm3", project1);
db.users().insertProjectPermissionOnAnyone("perm4", project1);
underTest.delete(dbSession, "perm2", group1.getOrganizationUuid(), group1.getId(), null);
dbSession.commit();
assertThatNoPermission("perm2");
assertThat(db.countRowsOfTable("group_roles")).isEqualTo(3);
}
Aggregations