Search in sources :

Example 6 with ComponentDto

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);
}
Also used : GroupDto(org.sonar.db.user.GroupDto) ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 7 with ComponentDto

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();
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 8 with ComponentDto

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();
}
Also used : ProjectMeasures(org.sonar.db.measure.ProjectMeasuresIndexerIterator.ProjectMeasures) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 9 with ComponentDto

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();
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto)

Example 10 with ComponentDto

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());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Aggregations

ComponentDto (org.sonar.db.component.ComponentDto)836 Test (org.junit.Test)661 OrganizationDto (org.sonar.db.organization.OrganizationDto)151 SnapshotDto (org.sonar.db.component.SnapshotDto)94 DbSession (org.sonar.db.DbSession)70 SearchOptions (org.sonar.server.es.SearchOptions)62 MetricDto (org.sonar.db.metric.MetricDto)49 IssueDto (org.sonar.db.issue.IssueDto)48 RuleDto (org.sonar.db.rule.RuleDto)47 GroupDto (org.sonar.db.user.GroupDto)39 UserDto (org.sonar.db.user.UserDto)38 WsTester (org.sonar.server.ws.WsTester)33 MetricTesting.newMetricDto (org.sonar.db.metric.MetricTesting.newMetricDto)25 PropertyDto (org.sonar.db.property.PropertyDto)23 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)21 ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)18 Date (java.util.Date)16 ComponentLinkDto (org.sonar.db.component.ComponentLinkDto)14 RuleTesting.newRuleDto (org.sonar.db.rule.RuleTesting.newRuleDto)14 ComponentTreeWsResponse (org.sonarqube.ws.WsMeasures.ComponentTreeWsResponse)13