Search in sources :

Example 11 with ProjectRepositories

use of org.sonar.scanner.protocol.input.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectDataLoaderMediumTest method return_file_data_from_multi_modules.

@Test
public void return_file_data_from_multi_modules() {
    OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
    dbClient.organizationDao().insert(dbSession, organizationDto);
    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
    userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid());
    dbClient.componentDao().insert(dbSession, project);
    addDefaultProfile();
    // File on project
    ComponentDto projectFile = ComponentTesting.newFileDto(project, null, "projectFile");
    dbClient.componentDao().insert(dbSession, projectFile);
    tester.get(FileSourceDao.class).insert(dbSession, newFileSourceDto(projectFile).setSrcHash("123456"));
    ComponentDto module = ComponentTesting.newModuleDto(project);
    dbClient.componentDao().insert(dbSession, module);
    // File on module
    ComponentDto moduleFile = ComponentTesting.newFileDto(module, null, "moduleFile");
    dbClient.componentDao().insert(dbSession, moduleFile);
    tester.get(FileSourceDao.class).insert(dbSession, newFileSourceDto(moduleFile).setSrcHash("789456"));
    dbSession.commit();
    ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
    assertThat(ref.fileData(project.key(), projectFile.path()).hash()).isEqualTo("123456");
    assertThat(ref.fileData(module.key(), moduleFile.path()).hash()).isEqualTo("789456");
}
Also used : FileSourceDao(org.sonar.db.source.FileSourceDao) ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) ProjectRepositories(org.sonar.scanner.protocol.input.ProjectRepositories) Test(org.junit.Test)

Example 12 with ProjectRepositories

use of org.sonar.scanner.protocol.input.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectDataLoaderMediumTest method return_provisioned_project_settings.

@Test
public void return_provisioned_project_settings() {
    OrganizationDto organizationDto = OrganizationTesting.newOrganizationDto();
    dbClient.organizationDao().insert(dbSession, organizationDto);
    // No snapshot attached on the project -> provisioned project
    ComponentDto project = ComponentTesting.newProjectDto(organizationDto);
    userSessionRule.logIn().addProjectUuidPermissions(SCAN_EXECUTION, project.uuid());
    dbClient.componentDao().insert(dbSession, project);
    addDefaultProfile();
    // Project properties
    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()));
    dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()));
    dbSession.commit();
    ProjectRepositories ref = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()));
    assertThat(ref.settings(project.key())).isEqualTo(ImmutableMap.of("sonar.jira.project.key", "SONAR", "sonar.jira.login.secured", "john"));
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) PropertyDto(org.sonar.db.property.PropertyDto) ProjectRepositories(org.sonar.scanner.protocol.input.ProjectRepositories) Test(org.junit.Test)

Example 13 with ProjectRepositories

use of org.sonar.scanner.protocol.input.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectDataLoaderTest method issues_mode_is_allowed_if_user_has_browse_permission.

@Test
public void issues_mode_is_allowed_if_user_has_browse_permission() {
    ComponentDto project = dbTester.components().insertProject();
    userSession.logIn().addProjectUuidPermissions(UserRole.USER, project.uuid());
    ProjectRepositories repositories = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true));
    assertThat(repositories).isNotNull();
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) ProjectRepositories(org.sonar.scanner.protocol.input.ProjectRepositories) Test(org.junit.Test)

Example 14 with ProjectRepositories

use of org.sonar.scanner.protocol.input.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectDataLoaderTest method scan_permission_on_organization_is_enough_even_without_scan_permission_on_project.

@Test
public void scan_permission_on_organization_is_enough_even_without_scan_permission_on_project() {
    ComponentDto project = dbTester.components().insertProject();
    userSession.logIn().addPermission(SCAN, project.getOrganizationUuid());
    userSession.logIn().addProjectUuidPermissions(UserRole.USER, project.uuid());
    ProjectRepositories repositories = underTest.load(ProjectDataQuery.create().setModuleKey(project.key()).setIssuesMode(true));
    assertThat(repositories).isNotNull();
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) ProjectRepositories(org.sonar.scanner.protocol.input.ProjectRepositories) Test(org.junit.Test)

Example 15 with ProjectRepositories

use of org.sonar.scanner.protocol.input.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectActionTest method do_not_fail_when_a_path_is_null.

/**
   * SONAR-7084
   */
@Test
public void do_not_fail_when_a_path_is_null() throws Exception {
    String projectKey = "org.codehaus.sonar:sonar";
    ProjectRepositories projectRepositories = new ProjectRepositories().addFileData("module-1", null, new FileData(null, null));
    when(projectDataLoader.load(any(ProjectDataQuery.class))).thenReturn(projectRepositories);
    TestResponse result = ws.newRequest().setMediaType(MediaTypes.PROTOBUF).setParam("key", projectKey).setParam("profile", "Default").execute();
    WsProjectResponse wsProjectResponse = WsProjectResponse.parseFrom(result.getInputStream());
    assertThat(wsProjectResponse.getFileDataByModuleAndPath()).isEmpty();
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) WsProjectResponse(org.sonarqube.ws.WsBatch.WsProjectResponse) FileData(org.sonar.scanner.protocol.input.FileData) ProjectRepositories(org.sonar.scanner.protocol.input.ProjectRepositories) Test(org.junit.Test)

Aggregations

ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)21 Test (org.junit.Test)19 ComponentDto (org.sonar.db.component.ComponentDto)18 OrganizationDto (org.sonar.db.organization.OrganizationDto)15 PropertyDto (org.sonar.db.property.PropertyDto)13 FileSourceDao (org.sonar.db.source.FileSourceDao)3 FileData (org.sonar.scanner.protocol.input.FileData)2 TestResponse (org.sonar.server.ws.TestResponse)2 WsProjectResponse (org.sonarqube.ws.WsBatch.WsProjectResponse)2 Date (java.util.Date)1 DbSession (org.sonar.db.DbSession)1 FilePathWithHashDto (org.sonar.db.component.FilePathWithHashDto)1