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");
}
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"));
}
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();
}
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();
}
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();
}
Aggregations