Search in sources :

Example 36 with ComponentDto

use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.

the class ProjectQgateAssociationDaoTest method select_qgate_id_is_absent.

@Test
public void select_qgate_id_is_absent() {
    ComponentDto project = db.components().insertProject();
    Optional<Long> result = underTest.selectQGateIdByComponentId(dbSession, project.getId());
    assertThat(result.isPresent()).isFalse();
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 37 with ComponentDto

use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.

the class QualityProfileDaoTest method select_selected_projects.

@Test
public void select_selected_projects() throws Exception {
    ComponentDto project1 = dbTester.components().insertProject((t) -> t.setName("Project1 name"));
    ComponentDto project2 = dbTester.components().insertProject((t) -> t.setName("Project2 name"));
    ComponentDto project3 = dbTester.components().insertProject((t) -> t.setName("Project3 name"));
    QualityProfileDto profile1 = newQualityProfileDto();
    qualityProfileDb.insertQualityProfiles(profile1);
    qualityProfileDb.associateProjectWithQualityProfile(project1, profile1);
    qualityProfileDb.associateProjectWithQualityProfile(project2, profile1);
    QualityProfileDto profile2 = newQualityProfileDto();
    qualityProfileDb.insertQualityProfiles(profile2);
    qualityProfileDb.associateProjectWithQualityProfile(project3, profile2);
    assertThat(underTest.selectSelectedProjects(profile1.getKey(), null, dbSession)).extracting("projectId", "projectUuid", "projectKey", "projectName", "profileKey").containsOnly(tuple(project1.getId(), project1.uuid(), project1.key(), project1.name(), profile1.getKey()), tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), profile1.getKey()));
    assertThat(underTest.selectSelectedProjects(profile1.getKey(), "ect1", dbSession)).hasSize(1);
    assertThat(underTest.selectSelectedProjects("unknown", null, dbSession)).isEmpty();
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) QualityProfileTesting.newQualityProfileDto(org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfileDto) Test(org.junit.Test)

Example 38 with ComponentDto

use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.

the class QualityProfileDaoTest method select_deselected_projects.

@Test
public void select_deselected_projects() throws Exception {
    ComponentDto project1 = dbTester.components().insertProject((t) -> t.setName("Project1 name"));
    ComponentDto project2 = dbTester.components().insertProject((t) -> t.setName("Project2 name"));
    ComponentDto project3 = dbTester.components().insertProject((t) -> t.setName("Project3 name"));
    QualityProfileDto profile1 = newQualityProfileDto();
    qualityProfileDb.insertQualityProfiles(profile1);
    qualityProfileDb.associateProjectWithQualityProfile(project1, profile1);
    QualityProfileDto profile2 = newQualityProfileDto();
    qualityProfileDb.insertQualityProfiles(profile2);
    qualityProfileDb.associateProjectWithQualityProfile(project2, profile2);
    assertThat(underTest.selectDeselectedProjects(profile1.getKey(), null, dbSession)).extracting("projectId", "projectUuid", "projectKey", "projectName", "profileKey").containsOnly(tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), null), tuple(project3.getId(), project3.uuid(), project3.key(), project3.name(), null));
    assertThat(underTest.selectDeselectedProjects(profile1.getKey(), "ect2", dbSession)).hasSize(1);
    assertThat(underTest.selectDeselectedProjects("unknown", null, dbSession)).hasSize(3);
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) QualityProfileTesting.newQualityProfileDto(org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfileDto) Test(org.junit.Test)

Example 39 with ComponentDto

use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.

the class AuthorizationDaoTest method selectProjectPermissionsOfAnonymous_returns_permissions_of_anonymous_user_on_specified_project.

@Test
public void selectProjectPermissionsOfAnonymous_returns_permissions_of_anonymous_user_on_specified_project() {
    ComponentDto project = db.components().insertProject(org);
    db.users().insertProjectPermissionOnAnyone(UserRole.CODEVIEWER, project);
    db.users().insertProjectPermissionOnUser(db.users().insertUser(), UserRole.USER, project);
    ComponentDto otherProject = db.components().insertProject();
    db.users().insertProjectPermissionOnAnyone(UserRole.ISSUE_ADMIN, otherProject);
    assertThat(underTest.selectProjectPermissionsOfAnonymous(dbSession, project.uuid())).containsOnly(UserRole.CODEVIEWER);
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 40 with ComponentDto

use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.

the class AuthorizationDaoTest method selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project.

@Test
public void selectProjectPermissions_returns_permissions_of_logged_in_user_on_specified_project() {
    ComponentDto project = db.components().insertProject(org);
    db.users().insertProjectPermissionOnUser(user, UserRole.CODEVIEWER, project);
    db.users().insertProjectPermissionOnUser(db.users().insertUser(), UserRole.ISSUE_ADMIN, project);
    assertThat(underTest.selectProjectPermissions(dbSession, project.uuid(), user.getId())).containsOnly(UserRole.CODEVIEWER);
}
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