use of org.sonar.api.config.Configuration in project sonar-java by SonarSource.
the class JaCoCoSensor method getReportPaths.
private static Set<File> getReportPaths(SensorContext context) {
Set<File> reportPaths = new HashSet<>();
Configuration settings = context.config();
FileSystem fs = context.fileSystem();
for (String reportPath : settings.getStringArray(REPORT_PATHS_PROPERTY)) {
File report = fs.resolvePath(reportPath);
if (!report.isFile()) {
if (settings.hasKey(REPORT_PATHS_PROPERTY)) {
LOG.info("JaCoCo report not found: '{}'", reportPath);
}
} else {
reportPaths.add(report);
}
}
getReport(settings, fs, REPORT_PATH_PROPERTY, "JaCoCo UT report not found: '{}'").ifPresent(reportPaths::add);
getReport(settings, fs, IT_REPORT_PATH_PROPERTY, "JaCoCo IT report not found: '{}'").ifPresent(reportPaths::add);
return reportPaths;
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ConfigurationRepositoryTest method call_twice_get_project_settings.
@Test
public void call_twice_get_project_settings() {
analysisMetadataHolder.setProject(PROJECT);
globalSettings.setProperty("key", "value");
Configuration config = underTest.getConfiguration();
assertThat(config.get("key")).hasValue("value");
config = underTest.getConfiguration();
assertThat(config.get("key")).hasValue("value");
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ConfigurationRepositoryTest method branch_settings.
@Test
public void branch_settings() {
ComponentDto project = db.components().insertPublicProject();
ComponentDto branchDto = db.components().insertProjectBranch(project);
Branch branch = mock(Branch.class);
when(branch.getName()).thenReturn(branchDto.getBranch());
analysisMetadataHolder.setProject(Project.from(project)).setBranch(branch);
globalSettings.setProperty("global", "global value");
insertProjectProperty(project, "project", "project value");
insertProjectProperty(branchDto, "branch", "branch value");
Configuration config = underTest.getConfiguration();
assertThat(config.get("global")).hasValue("global value");
assertThat(config.get("project")).hasValue("project value");
assertThat(config.get("branch")).hasValue("branch value");
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ProjectConfigurationFactoryTest method return_global_settings.
@Test
public void return_global_settings() {
settings.setProperty("key", "value");
Configuration config = underTest.newProjectConfiguration(PROJECT_KEY, new DefaultBranchImpl());
assertThat(config.get("key")).hasValue("value");
}
use of org.sonar.api.config.Configuration in project sonarqube by SonarSource.
the class ProjectConfigurationFactoryTest method return_project_settings.
@Test
public void return_project_settings() {
ComponentDto project = db.components().insertPrivateProject();
db.properties().insertProperties(null, project.getKey(), project.name(), project.qualifier(), newComponentPropertyDto(project).setKey("1").setValue("val1"), newComponentPropertyDto(project).setKey("2").setValue("val2"), newComponentPropertyDto(project).setKey("3").setValue("val3"));
Configuration config = underTest.newProjectConfiguration(project.getDbKey(), new DefaultBranchImpl());
assertThat(config.get("1")).hasValue("val1");
assertThat(config.get("2")).hasValue("val2");
assertThat(config.get("3")).hasValue("val3");
}
Aggregations