Search in sources :

Example 1 with GlobalSettings

use of org.sonar.scanner.bootstrap.GlobalSettings in project sonarqube by SonarSource.

the class ModuleSettingsTest method test_loading_of_parent_module_settings_for_new_module.

// SONAR-6386
@Test
public void test_loading_of_parent_module_settings_for_new_module() {
    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of("overridding", "batch", "on-batch", "true"));
    ProjectRepositories projRepos = createSettings("struts", ImmutableMap.of("on-module", "true", "overridding", "module"));
    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
    ProjectDefinition.create().setKey("struts").addSubProject(module);
    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projRepos, mode, mock(AnalysisContextReportPublisher.class));
    assertThat(moduleSettings.getString("overridding")).isEqualTo("module");
    assertThat(moduleSettings.getString("on-batch")).isEqualTo("true");
    assertThat(moduleSettings.getString("on-module")).isEqualTo("true");
}
Also used : GlobalSettings(org.sonar.scanner.bootstrap.GlobalSettings) AnalysisContextReportPublisher(org.sonar.scanner.report.AnalysisContextReportPublisher) ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 2 with GlobalSettings

use of org.sonar.scanner.bootstrap.GlobalSettings in project sonarqube by SonarSource.

the class AnalysisContextReportPublisherTest method prepare.

@Before
public void prepare() throws Exception {
    logTester.setLevel(LoggerLevel.INFO);
    system2 = mock(System2.class);
    when(system2.properties()).thenReturn(new Properties());
    projectRepos = mock(ProjectRepositories.class);
    globalSettings = mock(GlobalSettings.class);
    publisher = new AnalysisContextReportPublisher(analysisMode, pluginRepo, system2, projectRepos, globalSettings);
}
Also used : System2(org.sonar.api.utils.System2) GlobalSettings(org.sonar.scanner.bootstrap.GlobalSettings) Properties(java.util.Properties) ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) Before(org.junit.Before)

Example 3 with GlobalSettings

use of org.sonar.scanner.bootstrap.GlobalSettings in project sonarqube by SonarSource.

the class ProjectSettingsTest method prepare.

@Before
public void prepare() {
    emptyFileData = ImmutableTable.of();
    emptySettings = ImmutableTable.of();
    project = ProjectDefinition.create().setKey("struts");
    globalMode = mock(GlobalMode.class);
    mode = mock(DefaultAnalysisMode.class);
    bootstrapProps = new GlobalSettings(new GlobalProperties(Collections.<String, String>emptyMap()), new PropertyDefinitions(), mock(SettingsLoader.class), globalMode);
}
Also used : GlobalProperties(org.sonar.scanner.bootstrap.GlobalProperties) PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) GlobalMode(org.sonar.scanner.bootstrap.GlobalMode) GlobalSettings(org.sonar.scanner.bootstrap.GlobalSettings) DefaultAnalysisMode(org.sonar.scanner.analysis.DefaultAnalysisMode) Before(org.junit.Before)

Example 4 with GlobalSettings

use of org.sonar.scanner.bootstrap.GlobalSettings in project sonarqube by SonarSource.

the class ModuleSettingsTest method should_fail_when_accessing_secured_properties_in_issues.

@Test
public void should_fail_when_accessing_secured_properties_in_issues() {
    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of("sonar.foo.secured", "bar"));
    ProjectRepositories projSettingsRepo = createSettings("struts-core", ImmutableMap.of("sonar.foo.license.secured", "bar2"));
    when(mode.isIssues()).thenReturn(true);
    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projSettingsRepo, mode, mock(AnalysisContextReportPublisher.class));
    assertThat(moduleSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
    thrown.expect(MessageException.class);
    thrown.expectMessage("Access to the secured property 'sonar.foo.secured' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
    moduleSettings.getString("sonar.foo.secured");
}
Also used : GlobalSettings(org.sonar.scanner.bootstrap.GlobalSettings) AnalysisContextReportPublisher(org.sonar.scanner.report.AnalysisContextReportPublisher) ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 5 with GlobalSettings

use of org.sonar.scanner.bootstrap.GlobalSettings in project sonarqube by SonarSource.

the class ModuleSettingsTest method test_loading_of_module_settings.

@Test
public void test_loading_of_module_settings() {
    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of("overridding", "batch", "on-batch", "true"));
    ProjectRepositories projRepos = createSettings("struts-core", ImmutableMap.of("on-module", "true", "overridding", "module"));
    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projRepos, mode, mock(AnalysisContextReportPublisher.class));
    assertThat(moduleSettings.getString("overridding")).isEqualTo("module");
    assertThat(moduleSettings.getString("on-batch")).isEqualTo("true");
    assertThat(moduleSettings.getString("on-module")).isEqualTo("true");
}
Also used : GlobalSettings(org.sonar.scanner.bootstrap.GlobalSettings) AnalysisContextReportPublisher(org.sonar.scanner.report.AnalysisContextReportPublisher) ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Aggregations

GlobalSettings (org.sonar.scanner.bootstrap.GlobalSettings)6 ProjectRepositories (org.sonar.scanner.repository.ProjectRepositories)5 Test (org.junit.Test)4 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)4 AnalysisContextReportPublisher (org.sonar.scanner.report.AnalysisContextReportPublisher)4 Before (org.junit.Before)2 Properties (java.util.Properties)1 PropertyDefinitions (org.sonar.api.config.PropertyDefinitions)1 System2 (org.sonar.api.utils.System2)1 DefaultAnalysisMode (org.sonar.scanner.analysis.DefaultAnalysisMode)1 GlobalMode (org.sonar.scanner.bootstrap.GlobalMode)1 GlobalProperties (org.sonar.scanner.bootstrap.GlobalProperties)1