Search in sources :

Example 16 with ComponentDto

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

Example 17 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 18 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 19 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 20 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)

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