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();
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class MeasureDaoTest method test_inserted_and_selected_columns.
@Test
public void test_inserted_and_selected_columns() {
ComponentDto project = db.components().insertProject();
insertAnalysis(LAST_ANALYSIS_UUID, project.uuid(), true);
db.components().insertComponent(newFileDto(project).setUuid("C4"));
MeasureDto inserted = new MeasureDto().setAnalysisUuid(LAST_ANALYSIS_UUID).setMetricId(2).setDeveloperId(3L).setComponentUuid("C4").setValue(5.0d).setData("data").setVariation(1d).setAlertStatus("alert").setAlertText("alert-text").setDescription("measure-description");
underTest.insert(db.getSession(), inserted);
db.commit();
MeasureDto selected = underTest.selectSingle(db.getSession(), MeasureQuery.builder().setComponentUuid(inserted.getComponentUuid()).setPersonId(inserted.getDeveloperId()).build()).get();
assertThat(selected.getAnalysisUuid()).isEqualTo(inserted.getAnalysisUuid());
assertThat(selected.getMetricId()).isEqualTo(inserted.getMetricId());
assertThat(selected.getDeveloperId()).isEqualTo(inserted.getDeveloperId());
assertThat(selected.getComponentUuid()).isEqualTo(inserted.getComponentUuid());
assertThat(selected.getValue()).isEqualTo(inserted.getValue());
assertThat(selected.getData()).isEqualTo(inserted.getData());
assertThat(selected.getVariation()).isEqualTo(inserted.getVariation());
assertThat(selected.getAlertStatus()).isEqualTo(inserted.getAlertStatus());
assertThat(selected.getAlertText()).isEqualTo(inserted.getAlertText());
}
Aggregations