Search in sources :

Example 1 with Configuration

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;
}
Also used : Configuration(org.sonar.api.config.Configuration) FileSystem(org.sonar.api.batch.fs.FileSystem) File(java.io.File) HashSet(java.util.HashSet)

Example 2 with Configuration

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");
}
Also used : Configuration(org.sonar.api.config.Configuration) Test(org.junit.Test)

Example 3 with Configuration

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");
}
Also used : Configuration(org.sonar.api.config.Configuration) Branch(org.sonar.ce.task.projectanalysis.analysis.Branch) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 4 with Configuration

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");
}
Also used : Configuration(org.sonar.api.config.Configuration) DefaultBranchImpl(org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl) Test(org.junit.Test)

Example 5 with Configuration

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");
}
Also used : Configuration(org.sonar.api.config.Configuration) ComponentDto(org.sonar.db.component.ComponentDto) DefaultBranchImpl(org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl) Test(org.junit.Test)

Aggregations

Configuration (org.sonar.api.config.Configuration)47 Test (org.junit.Test)40 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)14 ComponentDto (org.sonar.db.component.ComponentDto)12 QGChangeEvent (org.sonar.server.qualitygate.changeevent.QGChangeEvent)7 MapSettings (org.sonar.api.config.internal.MapSettings)5 SnapshotDto (org.sonar.db.component.SnapshotDto)4 PropertyDefinitions (org.sonar.api.config.PropertyDefinitions)3 Encryption (org.sonar.api.config.internal.Encryption)3 Metric (org.sonar.api.measures.Metric)3 DefaultBranchImpl (org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl)3 HashSet (java.util.HashSet)2 DbClient (org.sonar.db.DbClient)2 BranchDto (org.sonar.db.component.BranchDto)2 LiveMeasureDto (org.sonar.db.measure.LiveMeasureDto)2 MetricDto (org.sonar.db.metric.MetricDto)2 ProjectDto (org.sonar.db.project.ProjectDto)2 EvaluatedQualityGate (org.sonar.server.qualitygate.EvaluatedQualityGate)2 QualityGate (org.sonar.server.qualitygate.QualityGate)2 File (java.io.File)1