use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ViewIndexerTest method addProjectWithIssue.
private ComponentDto addProjectWithIssue(RuleDto rule, OrganizationDto org) {
ComponentDto project = ComponentTesting.newProjectDto(org);
ComponentDto file = ComponentTesting.newFileDto(project, null);
dbTester.components().insertComponents(project, file);
dbTester.users().insertProjectPermissionOnAnyone(UserRole.USER, project);
IssueDto issue = IssueTesting.newDto(rule, file, project);
dbClient.issueDao().insert(dbSession, issue);
dbSession.commit();
return project;
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class PropertiesDaoTest method selectEnabledDescendantModuleProperties_supports_all_values.
@Test
@UseDataProvider("allValuesForSelect")
public void selectEnabledDescendantModuleProperties_supports_all_values(String dbValue, String expected) throws SQLException {
String projectUuid = "A";
ComponentDto project = ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid);
dbClient.componentDao().insert(session, project);
long projectId = project.getId();
insertProperty("project.one", dbValue, projectId, null);
List<PropertyDto> dtos = underTest.selectEnabledDescendantModuleProperties(projectUuid, dbTester.getSession());
assertThat(dtos).hasSize(1);
assertThatDto(dtos.iterator().next()).hasKey("project.one").hasResourceId(projectId).hasNoUserId().hasValue(expected);
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class PropertiesDaoTest method select_component_properties_by_ids.
@Test
public void select_component_properties_by_ids() throws Exception {
ComponentDto project = dbTester.components().insertProject();
ComponentDto project2 = dbTester.components().insertProject();
UserDto user = UserTesting.newUserDto();
dbClient.userDao().insert(session, user);
String key = "key";
String anotherKey = "anotherKey";
insertProperties(newGlobalPropertyDto().setKey(key), newComponentPropertyDto(project).setKey(key), newComponentPropertyDto(project2).setKey(key), newComponentPropertyDto(project2).setKey(anotherKey), newUserPropertyDto(user).setKey(key));
assertThat(underTest.selectPropertiesByComponentIds(session, newHashSet(project.getId()))).extracting("key", "resourceId").containsOnly(tuple(key, project.getId()));
assertThat(underTest.selectPropertiesByComponentIds(session, newHashSet(project.getId(), project2.getId()))).extracting("key", "resourceId").containsOnly(tuple(key, project.getId()), tuple(key, project2.getId()), tuple(anotherKey, project2.getId()));
assertThat(underTest.selectPropertiesByComponentIds(session, newHashSet(123456789L))).isEmpty();
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class AuthorizationDaoTest method selectOrganizationPermissions_for_logged_in_user.
/**
* Union of the permissions granted to:
* - the user
* - the groups which user is member
* - anyone
*/
@Test
public void selectOrganizationPermissions_for_logged_in_user() {
ComponentDto project = db.components().insertProject(org);
db.users().insertMember(group1, user);
db.users().insertPermissionOnUser(org, user, "perm1");
db.users().insertProjectPermissionOnUser(user, "perm42", project);
db.users().insertPermissionOnGroup(group1, "perm2");
db.users().insertPermissionOnAnyone(org, "perm3");
// ignored permissions, user is not member of this group
db.users().insertPermissionOnGroup(group2, "ignored");
Set<String> permissions = underTest.selectOrganizationPermissions(dbSession, org.getUuid(), user.getId());
assertThat(permissions).containsOnly("perm1", "perm2", "perm3");
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class AuthorizationDaoTest method selectProjectPermissionsOfAnonymous_returns_empty_set_when_project_does_not_exist.
@Test
public void selectProjectPermissionsOfAnonymous_returns_empty_set_when_project_does_not_exist() {
ComponentDto project = db.components().insertProject(org);
db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project);
assertThat(underTest.selectProjectPermissionsOfAnonymous(dbSession, "does_not_exist")).isEmpty();
}
Aggregations