diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2017-01-05 11:24:54 +0100 |
---|---|---|
committer | Julien HENRY <henryju@yahoo.fr> | 2017-01-10 20:52:16 +0100 |
commit | fafd6a2b35d2b7947a7727b10560e1f4c0a90e81 (patch) | |
tree | 31aed5897e2e8af36effa3d4cd658fa278e6c88c /sonar-scanner-engine | |
parent | b0ff5f224d41bdb89a4a42e5500ce4f830c7ab01 (diff) | |
download | sonarqube-fafd6a2b35d2b7947a7727b10560e1f4c0a90e81.tar.gz sonarqube-fafd6a2b35d2b7947a7727b10560e1f4c0a90e81.zip |
SONAR-8573 Use api/settings to load global settings
Diffstat (limited to 'sonar-scanner-engine')
11 files changed, 271 insertions, 40 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java index 19e2e4702fa..66811cfc6d8 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java @@ -42,6 +42,8 @@ import org.sonar.scanner.platform.DefaultServer; import org.sonar.scanner.repository.DefaultGlobalRepositoriesLoader; import org.sonar.scanner.repository.GlobalRepositoriesLoader; import org.sonar.scanner.repository.GlobalRepositoriesProvider; +import org.sonar.scanner.repository.settings.DefaultSettingsLoader; +import org.sonar.scanner.repository.settings.SettingsLoader; import org.sonar.scanner.storage.StoragesManager; import org.sonar.scanner.task.TaskContainer; @@ -94,6 +96,7 @@ public class GlobalContainer extends ComponentContainer { new GlobalRepositoriesProvider(), UuidFactoryImpl.INSTANCE); addIfMissing(ScannerPluginInstaller.class, PluginInstaller.class); + addIfMissing(DefaultSettingsLoader.class, SettingsLoader.class); addIfMissing(DefaultGlobalRepositoriesLoader.class, GlobalRepositoriesLoader.class); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalSettings.java index ea7d38c7720..9a11958b714 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalSettings.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalSettings.java @@ -30,7 +30,7 @@ import org.sonar.api.config.Encryption; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.Settings; import org.sonar.api.utils.MessageException; -import org.sonar.scanner.protocol.input.GlobalRepositories; +import org.sonar.scanner.repository.settings.SettingsLoader; public class GlobalSettings extends Settings { @@ -47,23 +47,23 @@ public class GlobalSettings extends Settings { "sonar.jdbc.password", JDBC_SPECIFIC_MESSAGE); private final GlobalProperties bootstrapProps; - private final GlobalRepositories globalReferentials; + private final SettingsLoader settingsLoader; private final GlobalMode mode; private final Map<String, String> properties = new HashMap<>(); public GlobalSettings(GlobalProperties bootstrapProps, PropertyDefinitions propertyDefinitions, - GlobalRepositories globalReferentials, GlobalMode mode) { + SettingsLoader settingsLoader, GlobalMode mode) { super(propertyDefinitions, new Encryption(bootstrapProps.property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH))); this.mode = mode; this.bootstrapProps = bootstrapProps; - this.globalReferentials = globalReferentials; + this.settingsLoader = settingsLoader; init(); new DroppedPropertyChecker(this.getProperties(), DROPPED_PROPERTIES).checkDroppedProperties(); } private void init() { - addProperties(globalReferentials.globalSettings()); + addProperties(settingsLoader.load(null)); addProperties(bootstrapProps.properties()); if (hasKey(CoreProperties.PERMANENT_SERVER_ID)) { diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultSettingsLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultSettingsLoader.java new file mode 100644 index 00000000000..5e72ecf04ce --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultSettingsLoader.java @@ -0,0 +1,109 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.scanner.repository.settings; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Joiner; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.commons.io.IOUtils; +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.Loggers; +import org.sonar.api.utils.log.Profiler; +import org.sonar.scanner.bootstrap.ScannerWsClient; +import org.sonarqube.ws.Settings.FieldValues.Value; +import org.sonarqube.ws.Settings.Setting; +import org.sonarqube.ws.Settings.ValuesWsResponse; +import org.sonarqube.ws.client.GetRequest; + +public class DefaultSettingsLoader implements SettingsLoader { + + private ScannerWsClient wsClient; + private static final Logger LOG = Loggers.get(DefaultSettingsLoader.class); + + public DefaultSettingsLoader(ScannerWsClient wsClient) { + this.wsClient = wsClient; + } + + @Override + public Map<String, String> load(@Nullable String componentKey) { + String url = "api/settings/values.protobuf"; + Profiler profiler = Profiler.create(LOG); + if (componentKey != null) { + url += "?component=" + componentKey; + profiler.startInfo("Load settings for component '" + componentKey + "'"); + } else { + profiler.startInfo("Load global settings"); + } + InputStream is = wsClient.call(new GetRequest(url)).contentStream(); + ValuesWsResponse values = null; + + try { + values = ValuesWsResponse.parseFrom(is); + profiler.stopInfo(); + return toMap(values.getSettingsList()); + } catch (IOException e) { + throw new IllegalStateException("Failed to load server settings", e); + } finally { + IOUtils.closeQuietly(is); + } + } + + @VisibleForTesting + static Map<String, String> toMap(List<Setting> settingsList) { + Map<String, String> result = new LinkedHashMap<>(); + for (Setting s : settingsList) { + if (!s.getInherited()) { + switch (s.getValueOneOfCase()) { + case VALUE: + result.put(s.getKey(), s.getValue()); + break; + case VALUES: + result.put(s.getKey(), Joiner.on(',').join(s.getValues().getValuesList())); + break; + case FIELDVALUES: + convertPropertySetToProps(result, s); + break; + default: + throw new IllegalStateException("Unknow property value for " + s.getKey()); + } + } + } + return result; + } + + private static void convertPropertySetToProps(Map<String, String> result, Setting s) { + List<String> ids = new ArrayList<>(); + int id = 1; + for (Value v : s.getFieldValues().getFieldValuesList()) { + for (Map.Entry<String, String> entry : v.getValue().entrySet()) { + result.put(s.getKey() + "." + id + "." + entry.getKey(), entry.getValue()); + } + ids.add(String.valueOf(id)); + id++; + } + result.put(s.getKey(), Joiner.on(',').join(ids)); + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/SettingsLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/SettingsLoader.java new file mode 100644 index 00000000000..eeebeb6b52b --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/SettingsLoader.java @@ -0,0 +1,26 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.scanner.repository.settings; + +import java.util.Map; + +public interface SettingsLoader { + Map<String, String> load(String componentKey); +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/package-info.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/package-info.java new file mode 100644 index 00000000000..f508b39ceac --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.scanner.repository.settings; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalSettingsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalSettingsTest.java index b4613a837b3..a3b68bacf73 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalSettingsTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalSettingsTest.java @@ -19,8 +19,8 @@ */ package org.sonar.scanner.bootstrap; +import com.google.common.collect.ImmutableMap; import java.util.Collections; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -28,13 +28,11 @@ import org.junit.rules.ExpectedException; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.utils.log.LogTester; import org.sonar.api.utils.log.LoggerLevel; -import org.sonar.scanner.bootstrap.GlobalMode; -import org.sonar.scanner.bootstrap.GlobalProperties; -import org.sonar.scanner.bootstrap.GlobalSettings; -import org.sonar.scanner.protocol.input.GlobalRepositories; +import org.sonar.scanner.repository.settings.SettingsLoader; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class GlobalSettingsTest { @@ -44,39 +42,38 @@ public class GlobalSettingsTest { @Rule public LogTester logTester = new LogTester(); - GlobalRepositories globalRef; + SettingsLoader settingsLoader; GlobalProperties bootstrapProps; private GlobalMode mode; @Before public void prepare() { - globalRef = new GlobalRepositories(); + settingsLoader = mock(SettingsLoader.class); bootstrapProps = new GlobalProperties(Collections.<String, String>emptyMap()); mode = mock(GlobalMode.class); } @Test public void should_load_global_settings() { - globalRef.globalSettings().put("sonar.cpd.cross", "true"); + when(settingsLoader.load(null)).thenReturn(ImmutableMap.of("sonar.cpd.cross", "true")); - GlobalSettings batchSettings = new GlobalSettings(bootstrapProps, new PropertyDefinitions(), globalRef, mode); + GlobalSettings batchSettings = new GlobalSettings(bootstrapProps, new PropertyDefinitions(), settingsLoader, mode); assertThat(batchSettings.getBoolean("sonar.cpd.cross")).isTrue(); } @Test public void should_log_warn_msg_for_each_jdbc_property_if_present() { - globalRef.globalSettings().put("sonar.jdbc.url", SOME_VALUE); - globalRef.globalSettings().put("sonar.jdbc.username", SOME_VALUE); - globalRef.globalSettings().put("sonar.jdbc.password", SOME_VALUE); + when(settingsLoader.load(null)).thenReturn(ImmutableMap.of("sonar.jdbc.url", SOME_VALUE, + "sonar.jdbc.username", SOME_VALUE, + "sonar.jdbc.password", SOME_VALUE)); - new GlobalSettings(bootstrapProps, new PropertyDefinitions(), globalRef, mode); + new GlobalSettings(bootstrapProps, new PropertyDefinitions(), settingsLoader, mode); assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly( "Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.", "Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.", - "Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database." - ); + "Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database."); } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java index c64259117c0..e6b475f7515 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java @@ -30,6 +30,7 @@ import java.io.Reader; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.LinkedList; @@ -62,6 +63,7 @@ import org.sonar.scanner.repository.ProjectRepositories; import org.sonar.scanner.repository.ProjectRepositoriesLoader; import org.sonar.scanner.repository.QualityProfileLoader; import org.sonar.scanner.repository.ServerIssuesLoader; +import org.sonar.scanner.repository.settings.SettingsLoader; import org.sonar.scanner.rule.ActiveRulesLoader; import org.sonar.scanner.rule.LoadedActiveRule; import org.sonar.scanner.rule.RulesLoader; @@ -283,7 +285,8 @@ public class ScannerMediumTester { builder.rulesLoader, builder.projectRefProvider, builder.activeRules, - new DefaultDebtModel()) + new DefaultDebtModel(), + new FakeSettingsLoader()) .setBootstrapProperties(builder.bootstrapProperties) .setLogOutput(builder.logOutput); @@ -474,6 +477,14 @@ public class ScannerMediumTester { } } + private static class FakeSettingsLoader implements SettingsLoader { + + @Override + public Map<String, String> load(String componentKey) { + return Collections.emptyMap(); + } + } + private static class FakeServerLineHashesLoader implements ServerLineHashesLoader { private Map<String, String[]> byKey = new HashMap<>(); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/log/ExceptionHandlingMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/log/ExceptionHandlingMediumTest.java index f552f33f421..918ac2c1dd6 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/log/ExceptionHandlingMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/log/ExceptionHandlingMediumTest.java @@ -20,30 +20,29 @@ package org.sonar.scanner.mediumtest.log; import java.util.Collections; - -import org.hamcrest.Matchers; +import java.util.Map; import org.hamcrest.Description; +import org.hamcrest.Matchers; import org.hamcrest.TypeSafeMatcher; import org.junit.BeforeClass; -import org.sonar.api.utils.MessageException; -import org.sonar.batch.bootstrapper.Batch; -import org.sonar.batch.bootstrapper.EnvironmentInformation; -import org.sonar.scanner.protocol.input.GlobalRepositories; -import org.sonar.scanner.repository.GlobalRepositoriesLoader; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.sonar.api.utils.MessageException; +import org.sonar.batch.bootstrapper.Batch; +import org.sonar.batch.bootstrapper.EnvironmentInformation; +import org.sonar.scanner.repository.settings.SettingsLoader; public class ExceptionHandlingMediumTest { @Rule public ExpectedException thrown = ExpectedException.none(); private Batch batch; - private static ErrorGlobalRepositoriesLoader loader; + private static ErrorSettingsLoader loader; @BeforeClass public static void beforeClass() { - loader = new ErrorGlobalRepositoriesLoader(); + loader = new ErrorSettingsLoader(); } public void setUp(boolean verbose) { @@ -64,7 +63,7 @@ public class ExceptionHandlingMediumTest { setUp(false); loader.withCause = false; thrown.expect(MessageException.class); - thrown.expectMessage("Error loading repository"); + thrown.expectMessage("Error loading settings"); thrown.expectCause(Matchers.nullValue(Throwable.class)); batch.start(); @@ -76,7 +75,7 @@ public class ExceptionHandlingMediumTest { loader.withCause = true; thrown.expect(MessageException.class); - thrown.expectMessage("Error loading repository"); + thrown.expectMessage("Error loading settings"); thrown.expectCause(new TypeSafeMatcher<Throwable>() { @Override public void describeTo(Description description) { @@ -99,16 +98,16 @@ public class ExceptionHandlingMediumTest { batch.start(); } - private static class ErrorGlobalRepositoriesLoader implements GlobalRepositoriesLoader { + private static class ErrorSettingsLoader implements SettingsLoader { boolean withCause = false; @Override - public GlobalRepositories load() { + public Map<String, String> load(String componentKey) { if (withCause) { IllegalStateException cause = new IllegalStateException("Code 401"); - throw MessageException.of("Error loading repository", cause); + throw MessageException.of("Error loading settings", cause); } else { - throw MessageException.of("Error loading repository"); + throw MessageException.of("Error loading settings"); } } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/settings/DefaultSettingsLoaderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/settings/DefaultSettingsLoaderTest.java new file mode 100644 index 00000000000..8f9be5cf33d --- /dev/null +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/settings/DefaultSettingsLoaderTest.java @@ -0,0 +1,63 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.scanner.repository.settings; + +import org.junit.Test; +import org.sonarqube.ws.Settings.FieldValues; +import org.sonarqube.ws.Settings.FieldValues.Value; +import org.sonarqube.ws.Settings.FieldValues.Value.Builder; +import org.sonarqube.ws.Settings.Setting; +import org.sonarqube.ws.Settings.Values; + +import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.entry; + +public class DefaultSettingsLoaderTest { + + @Test + public void should_load_global_multivalue_settings() { + assertThat(DefaultSettingsLoader.toMap(asList(Setting.newBuilder() + .setKey("sonar.preview.supportedPlugins") + .setValues(Values.newBuilder().addValues("java").addValues("php")).build()))) + .containsExactly(entry("sonar.preview.supportedPlugins", "java,php")); + } + + @Test + public void should_load_global_propertyset_settings() { + Builder valuesBuilder = Value.newBuilder(); + valuesBuilder.getMutableValue().put("filepattern", "**/*.xml"); + valuesBuilder.getMutableValue().put("rulepattern", "*:S12345"); + Value value1 = valuesBuilder.build(); + valuesBuilder.clear(); + valuesBuilder.getMutableValue().put("filepattern", "**/*.java"); + valuesBuilder.getMutableValue().put("rulepattern", "*:S456"); + Value value2 = valuesBuilder.build(); + + assertThat(DefaultSettingsLoader.toMap(asList(Setting.newBuilder() + .setKey("sonar.issue.exclusions.multicriteria") + .setFieldValues(FieldValues.newBuilder().addFieldValues(value1).addFieldValues(value2)).build()))) + .containsOnly(entry("sonar.issue.exclusions.multicriteria", "1,2"), + entry("sonar.issue.exclusions.multicriteria.1.filepattern", "**/*.xml"), + entry("sonar.issue.exclusions.multicriteria.1.rulepattern", "*:S12345"), + entry("sonar.issue.exclusions.multicriteria.2.filepattern", "**/*.java"), + entry("sonar.issue.exclusions.multicriteria.2.rulepattern", "*:S456")); + } +} diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleSettingsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleSettingsTest.java index f779b0d80f4..034bf4304a7 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleSettingsTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ModuleSettingsTest.java @@ -36,10 +36,10 @@ import org.sonar.scanner.analysis.DefaultAnalysisMode; import org.sonar.scanner.bootstrap.GlobalMode; import org.sonar.scanner.bootstrap.GlobalProperties; import org.sonar.scanner.bootstrap.GlobalSettings; -import org.sonar.scanner.protocol.input.GlobalRepositories; import org.sonar.scanner.report.AnalysisContextReportPublisher; import org.sonar.scanner.repository.FileData; import org.sonar.scanner.repository.ProjectRepositories; +import org.sonar.scanner.repository.settings.SettingsLoader; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -157,6 +157,6 @@ public class ModuleSettingsTest { private GlobalSettings newGlobalSettings(Map<String, String> props) { GlobalProperties globalProps = new GlobalProperties(props); return new GlobalSettings(globalProps, new PropertyDefinitions(), - new GlobalRepositories(), new GlobalMode(globalProps)); + mock(SettingsLoader.class), new GlobalMode(globalProps)); } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectSettingsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectSettingsTest.java index 5b889fb1340..6ec64aab7ed 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectSettingsTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectSettingsTest.java @@ -37,9 +37,9 @@ import org.sonar.scanner.analysis.DefaultAnalysisMode; import org.sonar.scanner.bootstrap.GlobalMode; import org.sonar.scanner.bootstrap.GlobalProperties; import org.sonar.scanner.bootstrap.GlobalSettings; -import org.sonar.scanner.protocol.input.GlobalRepositories; import org.sonar.scanner.repository.FileData; import org.sonar.scanner.repository.ProjectRepositories; +import org.sonar.scanner.repository.settings.SettingsLoader; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -68,7 +68,7 @@ public class ProjectSettingsTest { project = ProjectDefinition.create().setKey("struts"); globalMode = mock(GlobalMode.class); mode = mock(DefaultAnalysisMode.class); - bootstrapProps = new GlobalSettings(new GlobalProperties(Collections.<String, String>emptyMap()), new PropertyDefinitions(), new GlobalRepositories(), globalMode); + bootstrapProps = new GlobalSettings(new GlobalProperties(Collections.<String, String>emptyMap()), new PropertyDefinitions(), mock(SettingsLoader.class), globalMode); } @Test |