use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class AuthorizationDaoTest method selectProjectPermissions_returns_empty_set_when_logged_in_user_and_project_does_not_exist.
@Test
public void selectProjectPermissions_returns_empty_set_when_logged_in_user_and_project_does_not_exist() {
ComponentDto project = db.components().insertProject(org);
db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project);
assertThat(underTest.selectProjectPermissions(dbSession, "does_not_exist", user.getId())).isEmpty();
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class GroupPermissionDaoTest method delete_project_permission_from_anybody.
@Test
public void delete_project_permission_from_anybody() {
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, "perm4", group1.getOrganizationUuid(), null, project1.getId());
dbSession.commit();
assertThatNoPermission("perm4");
assertThat(db.countRowsOfTable("group_roles")).isEqualTo(3);
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class UserPermissionDaoTest method selectProjectPermissionsOfUser.
@Test
public void selectProjectPermissionsOfUser() {
OrganizationDto org = dbTester.organizations().insert();
ComponentDto project3 = dbTester.components().insertProject(org);
addGlobalPermission(organizationDto, "perm1", user1);
addProjectPermission(organizationDto, "perm2", user1, project1);
addProjectPermission(organizationDto, "perm3", user1, project1);
addProjectPermission(organizationDto, "perm4", user1, project2);
addProjectPermission(organizationDto, "perm5", user2, project1);
assertThat(underTest.selectProjectPermissionsOfUser(dbSession, user1.getId(), project1.getId())).containsOnly("perm2", "perm3");
assertThat(underTest.selectProjectPermissionsOfUser(dbSession, user1.getId(), project2.getId())).containsOnly("perm4");
assertThat(underTest.selectProjectPermissionsOfUser(dbSession, user1.getId(), project3.getId())).isEmpty();
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ProjectMeasuresIndexerIteratorTest method return_project_without_analysis.
@Test
public void return_project_without_analysis() throws Exception {
ComponentDto project = dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert()));
dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setLast(false));
dbSession.commit();
Map<String, ProjectMeasures> docsById = createResultSetAndReturnDocsById();
assertThat(docsById).hasSize(1);
ProjectMeasures doc = docsById.get(project.uuid());
assertThat(doc.getProject().getAnalysisDate()).isNull();
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class IssueDaoTest method prepareTables.
private void prepareTables() {
dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RULE);
OrganizationDto organizationDto = dbTester.organizations().insert();
ComponentDto projectDto = dbTester.components().insertProject(organizationDto, (t) -> t.setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
dbTester.components().insertComponent(ComponentTesting.newFileDto(projectDto).setUuid(FILE_UUID).setKey(FILE_KEY));
underTest.insert(dbTester.getSession(), newIssueDto(ISSUE_KEY1).setMessage("the message").setRuleId(RULE.getId()).setComponentUuid(FILE_UUID).setProjectUuid(PROJECT_UUID));
underTest.insert(dbTester.getSession(), newIssueDto(ISSUE_KEY2).setRuleId(RULE.getId()).setComponentUuid(FILE_UUID).setProjectUuid(PROJECT_UUID));
dbTester.getSession().commit();
}
Aggregations