diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2020-03-19 12:41:40 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-03-23 20:03:41 +0000 |
commit | a5e56c8d403ba0bfdb36e94acb8def5ceb065524 (patch) | |
tree | 184bce441b640428b2bc3f1bb6e176e9f8a2d6cd | |
parent | 0c8d18b4ed3e08536eef559153c62fb80cffa253 (diff) | |
download | sonarqube-a5e56c8d403ba0bfdb36e94acb8def5ceb065524.tar.gz sonarqube-a5e56c8d403ba0bfdb36e94acb8def5ceb065524.zip |
SONAR-13214 Remove org.sonar.api.config.Settings from the API
87 files changed, 208 insertions, 252 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/Xoo.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/Xoo.java index 077eed2a593..ad450e34e74 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/Xoo.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/Xoo.java @@ -19,8 +19,7 @@ */ package org.sonar.xoo; -import java.util.Arrays; -import org.sonar.api.config.Settings; +import org.sonar.api.config.Configuration; import org.sonar.api.resources.Language; public class Xoo implements Language { @@ -30,10 +29,10 @@ public class Xoo implements Language { public static final String FILE_SUFFIXES_KEY = "sonar.xoo.file.suffixes"; public static final String DEFAULT_FILE_SUFFIXES = ".xoo"; - private final Settings settings; + private final Configuration config; - public Xoo(Settings settings) { - this.settings = settings; + public Xoo(Configuration config) { + this.config = config; } @Override @@ -48,6 +47,6 @@ public class Xoo implements Language { @Override public String[] getFileSuffixes() { - return Arrays.stream(settings.getStringArray(FILE_SUFFIXES_KEY)).filter(s -> s != null && !s.trim().isEmpty()).toArray(String[]::new); + return config.getStringArray(FILE_SUFFIXES_KEY); } } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java index bbc9c6cdb46..cb3bc1d7a36 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java @@ -93,6 +93,7 @@ public class XooPlugin implements Plugin { .description("Comma-separated list of suffixes for files to analyze. To not filter, leave the list empty.") .subCategory("General") .onQualifiers(Qualifiers.PROJECT) + .multiValues(true) .build(), // Used by DuplicationsTest and IssueFilterOnCommonRulesTest. If not declared it is not returned by api/settings PropertyDefinition.builder("sonar.cpd.xoo.minimumTokens") diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooProjectBuilder.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooProjectBuilder.java index f72b138f24f..5b6693ddad7 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooProjectBuilder.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/extensions/XooProjectBuilder.java @@ -22,19 +22,12 @@ package org.sonar.xoo.extensions; import java.io.File; import org.sonar.api.batch.bootstrap.ProjectBuilder; import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.api.config.Settings; public class XooProjectBuilder extends ProjectBuilder { - private Settings settings; - - public XooProjectBuilder(Settings settings) { - this.settings = settings; - } - @Override public void build(Context context) { - if (!settings.getBoolean("sonar.xoo.enableProjectBuilder")) { + if (!context.config().getBoolean("sonar.xoo.enableProjectBuilder").orElse(false)) { return; } ProjectDefinition root = context.projectReactor().getRoot(); diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/ChecksSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/ChecksSensor.java index f8e5445fc54..c759817d6a3 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/ChecksSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/ChecksSensor.java @@ -50,7 +50,7 @@ public class ChecksSensor implements Sensor { @Override public void execute(SensorContext context) { Checks<Check> checks = checkFactory.create(XooRulesDefinition.XOO_REPOSITORY); - checks.addAnnotatedChecks(Check.ALL); + checks.addAnnotatedChecks((Object[]) Check.ALL); FilePredicates p = context.fileSystem().predicates(); for (InputFile file : context.fileSystem().inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(Type.MAIN)))) { for (Check check : checks.all()) { diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java index e9caaef473a..a0870005056 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java @@ -53,7 +53,7 @@ public class CreateIssueByInternalKeySensor implements Sensor { private static void createIssues(InputFile file, SensorContext context) { ActiveRule rule = context.activeRules().findByInternalKey(XooRulesDefinition.XOO_REPOSITORY, - context.settings().getString(INTERNAL_KEY_PROPERTY)); + context.config().get(INTERNAL_KEY_PROPERTY).orElse(null)); if (rule != null) { NewIssue newIssue = context.newIssue(); newIssue diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java index ac0b6ef1779..cd31cc5ea22 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/HasTagSensor.java @@ -67,7 +67,7 @@ public class HasTagSensor extends AbstractXooRuleSensor { NewIssue newIssue = context.newIssue(); newIssue .forRule(ruleKey) - .gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)) + .gap(context.config().getDouble(EFFORT_TO_FIX_PROPERTY).orElse(null)) .at(newIssue.newLocation() .on(inputFile) .at(inputFile.newRange(lineCounter[0], startIndex, lineCounter[0], startIndex + tag.length()))) diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java index 03a5d0bdc91..2b7e51b27ce 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java @@ -63,7 +63,7 @@ public class OneIssuePerLineSensor implements Sensor { private void createIssues(InputFile file, SensorContext context, String repo) { RuleKey ruleKey = RuleKey.of(repo, RULE_KEY); - String severity = context.settings().getString(FORCE_SEVERITY_PROPERTY); + String severity = context.config().get(FORCE_SEVERITY_PROPERTY).orElse(null); for (int line = 1; line <= file.lines(); line++) { NewIssue newIssue = context.newIssue(); newIssue @@ -74,9 +74,9 @@ public class OneIssuePerLineSensor implements Sensor { .message("This issue is generated on each line")) .overrideSeverity(severity != null ? Severity.valueOf(severity) : null); if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(5, 5))) { - newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)); + newIssue.gap(context.config().getDouble(EFFORT_TO_FIX_PROPERTY).orElse(null)); } else { - newIssue.gap(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY)); + newIssue.gap(context.config().getDouble(EFFORT_TO_FIX_PROPERTY).orElse(null)); } newIssue.save(); } diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java index 0a765fe411b..6ee907aa9e0 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java @@ -49,7 +49,7 @@ public class RandomAccessSensor implements Sensor { @Override public void execute(SensorContext context) { - File f = new File(context.settings().getString(SONAR_XOO_RANDOM_ACCESS_ISSUE_PATHS)); + File f = new File(context.config().get(SONAR_XOO_RANDOM_ACCESS_ISSUE_PATHS).orElseThrow(() -> new IllegalStateException("Required property"))); FileSystem fs = context.fileSystem(); FilePredicates p = fs.predicates(); try { diff --git a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapContextFactory.java b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapContextFactory.java index 40aa4810cbe..b77466214f2 100644 --- a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapContextFactory.java +++ b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapContextFactory.java @@ -35,7 +35,6 @@ import javax.security.auth.login.Configuration; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; import org.apache.commons.lang.StringUtils; -import org.sonar.api.config.Settings; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; @@ -75,15 +74,15 @@ public class LdapContextFactory { private final String realm; private final String referral; - public LdapContextFactory(Settings settings, String settingsPrefix, String ldapUrl) { - this.authentication = StringUtils.defaultString(settings.getString(settingsPrefix + ".authentication"), DEFAULT_AUTHENTICATION); - this.factory = StringUtils.defaultString(settings.getString(settingsPrefix + ".contextFactoryClass"), DEFAULT_FACTORY); - this.realm = settings.getString(settingsPrefix + ".realm"); + public LdapContextFactory(org.sonar.api.config.Configuration config, String settingsPrefix, String ldapUrl) { + this.authentication = StringUtils.defaultString(config.get(settingsPrefix + ".authentication").orElse(null), DEFAULT_AUTHENTICATION); + this.factory = StringUtils.defaultString(config.get(settingsPrefix + ".contextFactoryClass").orElse(null), DEFAULT_FACTORY); + this.realm = config.get(settingsPrefix + ".realm").orElse(null); this.providerUrl = ldapUrl; - this.startTLS = settings.getBoolean(settingsPrefix + ".StartTLS"); - this.username = settings.getString(settingsPrefix + ".bindDn"); - this.password = settings.getString(settingsPrefix + ".bindPassword"); - this.referral = getReferralsMode(settings, settingsPrefix + ".followReferrals"); + this.startTLS = config.getBoolean(settingsPrefix + ".StartTLS").orElse(false); + this.username = config.get(settingsPrefix + ".bindDn").orElse(null); + this.password = config.get(settingsPrefix + ".bindPassword").orElse(null); + this.referral = getReferralsMode(config, settingsPrefix + ".followReferrals"); } /** @@ -224,12 +223,9 @@ public class LdapContextFactory { return referral; } - private static String getReferralsMode(Settings settings, String followReferralsSettingKey) { - if (settings.hasKey(followReferralsSettingKey)) { - return settings.getBoolean(followReferralsSettingKey) ? REFERRALS_FOLLOW_MODE : REFERRALS_IGNORE_MODE; - } + private static String getReferralsMode(org.sonar.api.config.Configuration config, String followReferralsSettingKey) { // By default follow referrals - return REFERRALS_FOLLOW_MODE; + return config.getBoolean(followReferralsSettingKey).orElse(true) ? REFERRALS_FOLLOW_MODE : REFERRALS_IGNORE_MODE; } @Override diff --git a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapGroupMapping.java b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapGroupMapping.java index 932d8f588b1..8387fd00ce0 100644 --- a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapGroupMapping.java +++ b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapGroupMapping.java @@ -24,7 +24,7 @@ import javax.naming.NamingException; import javax.naming.directory.Attribute; import javax.naming.directory.SearchResult; import org.apache.commons.lang.StringUtils; -import org.sonar.api.config.Settings; +import org.sonar.api.config.Configuration; /** * @author Evgeny Mandrikov @@ -42,11 +42,11 @@ public class LdapGroupMapping { /** * Constructs mapping from Sonar settings. */ - public LdapGroupMapping(Settings settings, String settingsPrefix) { - this.baseDn = settings.getString(settingsPrefix + ".group.baseDn"); - this.idAttribute = StringUtils.defaultString(settings.getString(settingsPrefix + ".group.idAttribute"), DEFAULT_ID_ATTRIBUTE); + public LdapGroupMapping(Configuration config, String settingsPrefix) { + this.baseDn = config.get(settingsPrefix + ".group.baseDn").orElse(null); + this.idAttribute = StringUtils.defaultString(config.get(settingsPrefix + ".group.idAttribute").orElse(null), DEFAULT_ID_ATTRIBUTE); - String req = StringUtils.defaultString(settings.getString(settingsPrefix + ".group.request"), DEFAULT_REQUEST); + String req = StringUtils.defaultString(config.get(settingsPrefix + ".group.request").orElse(null), DEFAULT_REQUEST); this.requiredUserAttributes = StringUtils.substringsBetween(req, "{", "}"); for (int i = 0; i < requiredUserAttributes.length; i++) { req = StringUtils.replace(req, "{" + requiredUserAttributes[i] + "}", "{" + i + "}"); diff --git a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapSettingsManager.java b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapSettingsManager.java index 953050547e8..caa8d55d301 100644 --- a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapSettingsManager.java +++ b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapSettingsManager.java @@ -23,7 +23,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; -import org.sonar.api.config.Settings; +import org.sonar.api.config.Configuration; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; @@ -42,7 +42,7 @@ public class LdapSettingsManager { private static final String LDAP_SERVERS_PROPERTY = "ldap.servers"; private static final String LDAP_PROPERTY_PREFIX = "ldap"; private static final String DEFAULT_LDAP_SERVER_KEY = "<default>"; - private final Settings settings; + private final Configuration config; private final LdapAutodiscovery ldapAutodiscovery; private Map<String, LdapUserMapping> userMappings = null; private Map<String, LdapGroupMapping> groupMappings = null; @@ -51,10 +51,10 @@ public class LdapSettingsManager { /** * Create an instance of the settings manager. * - * @param settings The settings to use. + * @param config The config to use. */ - public LdapSettingsManager(Settings settings, LdapAutodiscovery ldapAutodiscovery) { - this.settings = settings; + public LdapSettingsManager(Configuration config, LdapAutodiscovery ldapAutodiscovery) { + this.config = config; this.ldapAutodiscovery = ldapAutodiscovery; } @@ -68,10 +68,10 @@ public class LdapSettingsManager { if (userMappings == null) { // Use linked hash map to preserve order userMappings = new LinkedHashMap<>(); - String[] serverKeys = settings.getStringArray(LDAP_SERVERS_PROPERTY); + String[] serverKeys = config.getStringArray(LDAP_SERVERS_PROPERTY); if (serverKeys.length > 0) { for (String serverKey : serverKeys) { - LdapUserMapping userMapping = new LdapUserMapping(settings, LDAP_PROPERTY_PREFIX + "." + serverKey); + LdapUserMapping userMapping = new LdapUserMapping(config, LDAP_PROPERTY_PREFIX + "." + serverKey); if (StringUtils.isNotBlank(userMapping.getBaseDn())) { LOG.info("User mapping for server {}: {}", serverKey, userMapping); userMappings.put(serverKey, userMapping); @@ -81,7 +81,7 @@ public class LdapSettingsManager { } } else { // Backward compatibility with single server configuration - LdapUserMapping userMapping = new LdapUserMapping(settings, LDAP_PROPERTY_PREFIX); + LdapUserMapping userMapping = new LdapUserMapping(config, LDAP_PROPERTY_PREFIX); if (StringUtils.isNotBlank(userMapping.getBaseDn())) { LOG.info("User mapping: {}", userMapping); userMappings.put(DEFAULT_LDAP_SERVER_KEY, userMapping); @@ -103,10 +103,10 @@ public class LdapSettingsManager { if (groupMappings == null) { // Use linked hash map to preserve order groupMappings = new LinkedHashMap<>(); - String[] serverKeys = settings.getStringArray(LDAP_SERVERS_PROPERTY); + String[] serverKeys = config.getStringArray(LDAP_SERVERS_PROPERTY); if (serverKeys.length > 0) { for (String serverKey : serverKeys) { - LdapGroupMapping groupMapping = new LdapGroupMapping(settings, LDAP_PROPERTY_PREFIX + "." + serverKey); + LdapGroupMapping groupMapping = new LdapGroupMapping(config, LDAP_PROPERTY_PREFIX + "." + serverKey); if (StringUtils.isNotBlank(groupMapping.getBaseDn())) { LOG.info("Group mapping for server {}: {}", serverKey, groupMapping); groupMappings.put(serverKey, groupMapping); @@ -116,7 +116,7 @@ public class LdapSettingsManager { } } else { // Backward compatibility with single server configuration - LdapGroupMapping groupMapping = new LdapGroupMapping(settings, LDAP_PROPERTY_PREFIX); + LdapGroupMapping groupMapping = new LdapGroupMapping(config, LDAP_PROPERTY_PREFIX); if (StringUtils.isNotBlank(groupMapping.getBaseDn())) { LOG.info("Group mapping: {}", groupMapping); groupMappings.put(DEFAULT_LDAP_SERVER_KEY, groupMapping); @@ -138,7 +138,7 @@ public class LdapSettingsManager { if (contextFactories == null) { // Use linked hash map to preserve order contextFactories = new LinkedHashMap<>(); - String[] serverKeys = settings.getStringArray(LDAP_SERVERS_PROPERTY); + String[] serverKeys = config.getStringArray(LDAP_SERVERS_PROPERTY); if (serverKeys.length > 0) { initMultiLdapConfiguration(serverKeys); } else { @@ -149,9 +149,9 @@ public class LdapSettingsManager { } private void initSimpleLdapConfiguration() { - String realm = settings.getString(LDAP_PROPERTY_PREFIX + ".realm"); + String realm = config.get(LDAP_PROPERTY_PREFIX + ".realm").orElse(null); String ldapUrlKey = LDAP_PROPERTY_PREFIX + ".url"; - String ldapUrl = settings.getString(ldapUrlKey); + String ldapUrl = config.get(ldapUrlKey).orElse(null); if (ldapUrl == null && realm != null) { LOG.warn("Auto-discovery feature is deprecated, please use '{}' to specify LDAP url", ldapUrlKey); List<LdapSrvRecord> ldapServers = ldapAutodiscovery.getLdapServers(realm); @@ -162,7 +162,7 @@ public class LdapSettingsManager { for (LdapSrvRecord ldapSrvRecord : ldapServers) { if (StringUtils.isNotBlank(ldapSrvRecord.getServerUrl())) { LOG.info("Detected server: {}", ldapSrvRecord.getServerUrl()); - LdapContextFactory contextFactory = new LdapContextFactory(settings, LDAP_PROPERTY_PREFIX, ldapSrvRecord.getServerUrl()); + LdapContextFactory contextFactory = new LdapContextFactory(config, LDAP_PROPERTY_PREFIX, ldapSrvRecord.getServerUrl()); contextFactories.put(DEFAULT_LDAP_SERVER_KEY + index, contextFactory); index++; } @@ -171,24 +171,24 @@ public class LdapSettingsManager { if (StringUtils.isBlank(ldapUrl)) { throw new LdapException(String.format("The property '%s' is empty and no realm configured to try auto-discovery.", ldapUrlKey)); } - LdapContextFactory contextFactory = new LdapContextFactory(settings, LDAP_PROPERTY_PREFIX, ldapUrl); + LdapContextFactory contextFactory = new LdapContextFactory(config, LDAP_PROPERTY_PREFIX, ldapUrl); contextFactories.put(DEFAULT_LDAP_SERVER_KEY, contextFactory); } } private void initMultiLdapConfiguration(String[] serverKeys) { - if (settings.hasKey("ldap.url") || settings.hasKey("ldap.realm")) { + if (config.hasKey("ldap.url") || config.hasKey("ldap.realm")) { throw new LdapException("When defining multiple LDAP servers with the property '" + LDAP_SERVERS_PROPERTY + "', " + "all LDAP properties must be linked to one of those servers. Please remove properties like 'ldap.url', 'ldap.realm', ..."); } for (String serverKey : serverKeys) { String prefix = LDAP_PROPERTY_PREFIX + "." + serverKey; String ldapUrlKey = prefix + ".url"; - String ldapUrl = settings.getString(ldapUrlKey); + String ldapUrl = config.get(ldapUrlKey).orElse(null); if (StringUtils.isBlank(ldapUrl)) { throw new LdapException(String.format("The property '%s' property is empty while it is mandatory.", ldapUrlKey)); } - LdapContextFactory contextFactory = new LdapContextFactory(settings, prefix, ldapUrl); + LdapContextFactory contextFactory = new LdapContextFactory(config, prefix, ldapUrl); contextFactories.put(serverKey, contextFactory); } } diff --git a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapUserMapping.java b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapUserMapping.java index ec74739fdd7..8b251bb453a 100644 --- a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapUserMapping.java +++ b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/LdapUserMapping.java @@ -20,7 +20,7 @@ package org.sonar.auth.ldap; import org.apache.commons.lang.StringUtils; -import org.sonar.api.config.Settings; +import org.sonar.api.config.Configuration; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; @@ -43,11 +43,11 @@ public class LdapUserMapping { /** * Constructs mapping from Sonar settings. */ - public LdapUserMapping(Settings settings, String settingsPrefix) { + public LdapUserMapping(Configuration config, String settingsPrefix) { String usesrBaseDnSettingKey = settingsPrefix + ".user.baseDn"; - String usersBaseDn = settings.getString(usesrBaseDnSettingKey); + String usersBaseDn = config.get(usesrBaseDnSettingKey).orElse(null); if (usersBaseDn == null) { - String realm = settings.getString(settingsPrefix + ".realm"); + String realm = config.get(settingsPrefix + ".realm").orElse(null); if (realm != null) { LOG.warn("Auto-discovery feature is deprecated, please use '{}' to specify user search dn", usesrBaseDnSettingKey); usersBaseDn = LdapAutodiscovery.getDnsDomainDn(realm); @@ -55,10 +55,10 @@ public class LdapUserMapping { } this.baseDn = usersBaseDn; - this.realNameAttribute = StringUtils.defaultString(settings.getString(settingsPrefix + ".user.realNameAttribute"), DEFAULT_NAME_ATTRIBUTE); - this.emailAttribute = StringUtils.defaultString(settings.getString(settingsPrefix + ".user.emailAttribute"), DEFAULT_EMAIL_ATTRIBUTE); + this.realNameAttribute = StringUtils.defaultString(config.get(settingsPrefix + ".user.realNameAttribute").orElse(null), DEFAULT_NAME_ATTRIBUTE); + this.emailAttribute = StringUtils.defaultString(config.get(settingsPrefix + ".user.emailAttribute").orElse(null), DEFAULT_EMAIL_ATTRIBUTE); - String req = StringUtils.defaultString(settings.getString(settingsPrefix + ".user.request"), DEFAULT_REQUEST); + String req = StringUtils.defaultString(config.get(settingsPrefix + ".user.request").orElse(null), DEFAULT_REQUEST); req = StringUtils.replace(req, "{login}", "{0}"); this.request = req; } diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/KerberosTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/KerberosTest.java index a5160297b1e..ca9beee0449 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/KerberosTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/KerberosTest.java @@ -44,7 +44,7 @@ public class KerberosTest { @Test public void test() { MapSettings settings = configure(); - LdapRealm ldapRealm = new LdapRealm(new LdapSettingsManager(settings, new LdapAutodiscovery())); + LdapRealm ldapRealm = new LdapRealm(new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery())); ldapRealm.init(); @@ -61,7 +61,7 @@ public class KerberosTest { public void wrong_bind_password() { MapSettings settings = configure() .setProperty("ldap.bindPassword", "wrong_bind_password"); - LdapRealm ldapRealm = new LdapRealm(new LdapSettingsManager(settings, new LdapAutodiscovery())); + LdapRealm ldapRealm = new LdapRealm(new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery())); try { ldapRealm.init(); Assert.fail(); diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAuthenticatorTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAuthenticatorTest.java index 126b858ee51..1f94c079fbd 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAuthenticatorTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAuthenticatorTest.java @@ -44,7 +44,7 @@ public class LdapAuthenticatorTest { public void testNoConnection() { exampleServer.disableAnonymousAccess(); try { - LdapSettingsManager settingsManager = new LdapSettingsManager(LdapSettingsFactory.generateAuthenticationSettings(exampleServer, null, LdapContextFactory.AUTH_METHOD_SIMPLE), + LdapSettingsManager settingsManager = new LdapSettingsManager(LdapSettingsFactory.generateAuthenticationSettings(exampleServer, null, LdapContextFactory.AUTH_METHOD_SIMPLE).asConfig(), new LdapAutodiscovery()); LdapAuthenticator authenticator = new LdapAuthenticator(settingsManager.getContextFactories(), settingsManager.getUserMappings()); authenticator.authenticate("godin", "secret1"); @@ -55,7 +55,7 @@ public class LdapAuthenticatorTest { @Test public void testSimple() { - LdapSettingsManager settingsManager = new LdapSettingsManager(LdapSettingsFactory.generateAuthenticationSettings(exampleServer, null, LdapContextFactory.AUTH_METHOD_SIMPLE), + LdapSettingsManager settingsManager = new LdapSettingsManager(LdapSettingsFactory.generateAuthenticationSettings(exampleServer, null, LdapContextFactory.AUTH_METHOD_SIMPLE).asConfig(), new LdapAutodiscovery()); LdapAuthenticator authenticator = new LdapAuthenticator(settingsManager.getContextFactories(), settingsManager.getUserMappings()); @@ -74,7 +74,7 @@ public class LdapAuthenticatorTest { @Test public void testSimpleMultiLdap() { LdapSettingsManager settingsManager = new LdapSettingsManager( - LdapSettingsFactory.generateAuthenticationSettings(exampleServer, infosupportServer, LdapContextFactory.AUTH_METHOD_SIMPLE), new LdapAutodiscovery()); + LdapSettingsFactory.generateAuthenticationSettings(exampleServer, infosupportServer, LdapContextFactory.AUTH_METHOD_SIMPLE).asConfig(), new LdapAutodiscovery()); LdapAuthenticator authenticator = new LdapAuthenticator(settingsManager.getContextFactories(), settingsManager.getUserMappings()); assertThat(authenticator.authenticate("godin", "secret1")).isTrue(); @@ -95,7 +95,7 @@ public class LdapAuthenticatorTest { @Test public void testSasl() { - LdapSettingsManager settingsManager = new LdapSettingsManager(LdapSettingsFactory.generateAuthenticationSettings(exampleServer, null, LdapContextFactory.AUTH_METHOD_CRAM_MD5), + LdapSettingsManager settingsManager = new LdapSettingsManager(LdapSettingsFactory.generateAuthenticationSettings(exampleServer, null, LdapContextFactory.AUTH_METHOD_CRAM_MD5).asConfig(), new LdapAutodiscovery()); LdapAuthenticator authenticator = new LdapAuthenticator(settingsManager.getContextFactories(), settingsManager.getUserMappings()); @@ -111,7 +111,7 @@ public class LdapAuthenticatorTest { @Test public void testSaslMultipleLdap() { LdapSettingsManager settingsManager = new LdapSettingsManager( - LdapSettingsFactory.generateAuthenticationSettings(exampleServer, infosupportServer, LdapContextFactory.AUTH_METHOD_CRAM_MD5), new LdapAutodiscovery()); + LdapSettingsFactory.generateAuthenticationSettings(exampleServer, infosupportServer, LdapContextFactory.AUTH_METHOD_CRAM_MD5).asConfig(), new LdapAutodiscovery()); LdapAuthenticator authenticator = new LdapAuthenticator(settingsManager.getContextFactories(), settingsManager.getUserMappings()); assertThat(authenticator.authenticate("godin", "secret1")).isTrue(); diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutoDiscoveryWarningLogTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutoDiscoveryWarningLogTest.java index a9ad72f1f0e..9d5c6de7919 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutoDiscoveryWarningLogTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutoDiscoveryWarningLogTest.java @@ -45,7 +45,7 @@ public class LdapAutoDiscoveryWarningLogTest { public void does_not_display_log_when_not_using_auto_discovery() { MapSettings settings = new MapSettings() .setProperty("ldap.url", server.getUrl()); - LdapRealm realm = new LdapRealm(new LdapSettingsManager(settings, new LdapAutodiscovery())); + LdapRealm realm = new LdapRealm(new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery())); assertThat(realm.getName()).isEqualTo("LDAP"); realm.init(); @@ -58,7 +58,7 @@ public class LdapAutoDiscoveryWarningLogTest { LdapAutodiscovery ldapAutodiscovery = mock(LdapAutodiscovery.class); when(ldapAutodiscovery.getLdapServers("example.org")).thenReturn(singletonList(new LdapAutodiscovery.LdapSrvRecord(server.getUrl(), 1, 1))); // ldap.url setting is not set - LdapRealm realm = new LdapRealm(new LdapSettingsManager(new MapSettings().setProperty("ldap.realm", "example.org"), + LdapRealm realm = new LdapRealm(new LdapSettingsManager(new MapSettings().setProperty("ldap.realm", "example.org").asConfig(), ldapAutodiscovery)); realm.init(); @@ -70,7 +70,7 @@ public class LdapAutoDiscoveryWarningLogTest { public void display_warning_log_when_using_auto_discovery_to_detect_user_baseDn_on_single_server() { // ldap.user.baseDn setting is not set MapSettings settings = new MapSettings().setProperty("ldap.url", server.getUrl()).setProperty("ldap.realm", "example.org"); - LdapRealm realm = new LdapRealm(new LdapSettingsManager(settings, new LdapAutodiscovery())); + LdapRealm realm = new LdapRealm(new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery())); realm.init(); @@ -88,7 +88,7 @@ public class LdapAutoDiscoveryWarningLogTest { .setProperty("ldap.example.realm", "example.org") .setProperty("ldap.infosupport.url", server2.getUrl()) .setProperty("ldap.infosupport.realm", "infosupport.org"); - LdapRealm realm = new LdapRealm(new LdapSettingsManager(settings, new LdapAutodiscovery())); + LdapRealm realm = new LdapRealm(new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery())); realm.init(); diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupMappingTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupMappingTest.java index 6be7b1c4dcc..a2e5e11f2b6 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupMappingTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupMappingTest.java @@ -28,7 +28,7 @@ public class LdapGroupMappingTest { @Test public void defaults() { - LdapGroupMapping groupMapping = new LdapGroupMapping(new MapSettings(), "ldap"); + LdapGroupMapping groupMapping = new LdapGroupMapping(new MapSettings().asConfig(), "ldap"); assertThat(groupMapping.getBaseDn()).isNull(); assertThat(groupMapping.getIdAttribute()).isEqualTo("cn"); @@ -46,7 +46,7 @@ public class LdapGroupMappingTest { public void custom_request() { MapSettings settings = new MapSettings() .setProperty("ldap.group.request", "(&(|(objectClass=posixGroup)(objectClass=groupOfUniqueNames))(|(memberUid={uid})(uniqueMember={dn})))"); - LdapGroupMapping groupMapping = new LdapGroupMapping(settings, "ldap"); + LdapGroupMapping groupMapping = new LdapGroupMapping(settings.asConfig(), "ldap"); assertThat(groupMapping.getRequest()).isEqualTo("(&(|(objectClass=posixGroup)(objectClass=groupOfUniqueNames))(|(memberUid={0})(uniqueMember={1})))"); assertThat(groupMapping.getRequiredUserAttributes()).isEqualTo(new String[] {"uid", "dn"}); diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java index 2b954453058..619d2fe13dc 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java @@ -47,7 +47,7 @@ public class LdapGroupsProviderTest { public void defaults() { MapSettings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, null); - LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery()); + LdapSettingsManager settingsManager = new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery()); LdapGroupsProvider groupsProvider = new LdapGroupsProvider(settingsManager.getContextFactories(), settingsManager.getUserMappings(), settingsManager.getGroupMappings()); Collection<String> groups; @@ -65,7 +65,7 @@ public class LdapGroupsProviderTest { public void defaultsMultipleLdap() { MapSettings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, infosupportServer); - LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery()); + LdapSettingsManager settingsManager = new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery()); LdapGroupsProvider groupsProvider = new LdapGroupsProvider(settingsManager.getContextFactories(), settingsManager.getUserMappings(), settingsManager.getGroupMappings()); Collection<String> groups; @@ -90,7 +90,7 @@ public class LdapGroupsProviderTest { public void posix() { MapSettings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, null); settings.setProperty("ldap.group.request", "(&(objectClass=posixGroup)(memberUid={uid}))"); - LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery()); + LdapSettingsManager settingsManager = new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery()); LdapGroupsProvider groupsProvider = new LdapGroupsProvider(settingsManager.getContextFactories(), settingsManager.getUserMappings(), settingsManager.getGroupMappings()); Collection<String> groups; @@ -104,7 +104,7 @@ public class LdapGroupsProviderTest { MapSettings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, infosupportServer); settings.setProperty("ldap.example.group.request", "(&(objectClass=posixGroup)(memberUid={uid}))"); settings.setProperty("ldap.infosupport.group.request", "(&(objectClass=posixGroup)(memberUid={uid}))"); - LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery()); + LdapSettingsManager settingsManager = new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery()); LdapGroupsProvider groupsProvider = new LdapGroupsProvider(settingsManager.getContextFactories(), settingsManager.getUserMappings(), settingsManager.getGroupMappings()); Collection<String> groups; @@ -120,7 +120,7 @@ public class LdapGroupsProviderTest { public void mixed() { MapSettings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, infosupportServer); settings.setProperty("ldap.example.group.request", "(&(|(objectClass=groupOfUniqueNames)(objectClass=posixGroup))(|(uniqueMember={dn})(memberUid={uid})))"); - LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery()); + LdapSettingsManager settingsManager = new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery()); LdapGroupsProvider groupsProvider = new LdapGroupsProvider(settingsManager.getContextFactories(), settingsManager.getUserMappings(), settingsManager.getGroupMappings()); Collection<String> groups; @@ -134,7 +134,7 @@ public class LdapGroupsProviderTest { MapSettings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, infosupportServer); settings.setProperty("ldap.example.group.request", "(&(|(objectClass=groupOfUniqueNames)(objectClass=posixGroup))(|(uniqueMember={dn})(memberUid={uid})))"); settings.setProperty("ldap.infosupport.group.request", "(&(|(objectClass=groupOfUniqueNames)(objectClass=posixGroup))(|(uniqueMember={dn})(memberUid={uid})))"); - LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery()); + LdapSettingsManager settingsManager = new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery()); LdapGroupsProvider groupsProvider = new LdapGroupsProvider(settingsManager.getContextFactories(), settingsManager.getUserMappings(), settingsManager.getGroupMappings()); Collection<String> groups; diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapRealmTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapRealmTest.java index be911bac424..0678722dcdb 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapRealmTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapRealmTest.java @@ -40,7 +40,7 @@ public class LdapRealmTest { public void normal() { MapSettings settings = new MapSettings() .setProperty("ldap.url", server.getUrl()); - LdapRealm realm = new LdapRealm(new LdapSettingsManager(settings, new LdapAutodiscovery())); + LdapRealm realm = new LdapRealm(new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery())); assertThat(realm.getName()).isEqualTo("LDAP"); realm.init(); assertThat(realm.doGetAuthenticator()).isInstanceOf(LdapAuthenticator.class); @@ -53,7 +53,7 @@ public class LdapRealmTest { MapSettings settings = new MapSettings() .setProperty("ldap.url", "ldap://no-such-host") .setProperty("ldap.group.baseDn", "cn=groups,dc=example,dc=org"); - LdapRealm realm = new LdapRealm(new LdapSettingsManager(settings, new LdapAutodiscovery())); + LdapRealm realm = new LdapRealm(new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery())); assertThat(realm.getName()).isEqualTo("LDAP"); try { realm.init(); diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapReferralsTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapReferralsTest.java index 4f9b7943796..e66a4bb6b72 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapReferralsTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapReferralsTest.java @@ -23,7 +23,7 @@ import java.util.Map; import javax.annotation.Nullable; import org.junit.ClassRule; import org.junit.Test; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.MapSettings; import org.sonar.auth.ldap.server.LdapServer; import static org.assertj.core.api.Assertions.assertThat; @@ -60,10 +60,10 @@ public class LdapReferralsTest { } private static Map<String, LdapContextFactory> createFactories(@Nullable String propertyKey, @Nullable String propertyValue) { - Settings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(server, null); + MapSettings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(server, null); if (propertyKey != null) { settings.setProperty(propertyKey, propertyValue); } - return new LdapSettingsManager(settings, new LdapAutodiscovery()).getContextFactories(); + return new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery()).getContextFactories(); } } diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSearchTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSearchTest.java index 65a6a531ab9..c46bc6f3107 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSearchTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSearchTest.java @@ -45,7 +45,7 @@ public class LdapSearchTest { @BeforeClass public static void init() { - contextFactories = new LdapSettingsManager(LdapSettingsFactory.generateSimpleAnonymousAccessSettings(server, null), new LdapAutodiscovery()).getContextFactories(); + contextFactories = new LdapSettingsManager(LdapSettingsFactory.generateSimpleAnonymousAccessSettings(server, null).asConfig(), new LdapAutodiscovery()).getContextFactories(); } @Test diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java index 900a2daa328..a4b659d5b35 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java @@ -24,7 +24,6 @@ import java.util.Collections; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.api.config.Settings; import org.sonar.api.config.internal.MapSettings; import static org.assertj.core.api.Assertions.assertThat; @@ -39,9 +38,9 @@ public class LdapSettingsManagerTest { @Test public void shouldFailWhenNoLdapUrl() { - Settings settings = generateMultipleLdapSettingsWithUserAndGroupMapping(); + MapSettings settings = generateMultipleLdapSettingsWithUserAndGroupMapping(); settings.removeProperty("ldap.example.url"); - LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery()); + LdapSettingsManager settingsManager = new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery()); thrown.expect(LdapException.class); thrown.expectMessage("The property 'ldap.example.url' property is empty while it is mandatory."); @@ -50,9 +49,9 @@ public class LdapSettingsManagerTest { @Test public void shouldFailWhenMixingSingleAndMultipleConfiguration() { - Settings settings = generateMultipleLdapSettingsWithUserAndGroupMapping(); + MapSettings settings = generateMultipleLdapSettingsWithUserAndGroupMapping(); settings.setProperty("ldap.url", "ldap://foo"); - LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery()); + LdapSettingsManager settingsManager = new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery()); thrown.expect(LdapException.class); thrown @@ -64,7 +63,7 @@ public class LdapSettingsManagerTest { @Test public void testContextFactoriesWithSingleLdap() { LdapSettingsManager settingsManager = new LdapSettingsManager( - generateSingleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery()); + generateSingleLdapSettingsWithUserAndGroupMapping().asConfig(), new LdapAutodiscovery()); assertThat(settingsManager.getContextFactories().size()).isEqualTo(1); } @@ -75,7 +74,7 @@ public class LdapSettingsManagerTest { @Test public void testContextFactoriesWithMultipleLdap() { LdapSettingsManager settingsManager = new LdapSettingsManager( - generateMultipleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery()); + generateMultipleLdapSettingsWithUserAndGroupMapping().asConfig(), new LdapAutodiscovery()); assertThat(settingsManager.getContextFactories().size()).isEqualTo(2); // We do it twice to make sure the settings keep the same. assertThat(settingsManager.getContextFactories().size()).isEqualTo(2); @@ -88,7 +87,7 @@ public class LdapSettingsManagerTest { LdapSrvRecord ldap2 = new LdapSrvRecord("ldap://localhost:1899", 1, 1); when(ldapAutodiscovery.getLdapServers("example.org")).thenReturn(Arrays.asList(ldap1, ldap2)); LdapSettingsManager settingsManager = new LdapSettingsManager( - generateAutodiscoverSettings(), ldapAutodiscovery); + generateAutodiscoverSettings().asConfig(), ldapAutodiscovery); assertThat(settingsManager.getContextFactories().size()).isEqualTo(2); } @@ -97,7 +96,7 @@ public class LdapSettingsManagerTest { LdapAutodiscovery ldapAutodiscovery = mock(LdapAutodiscovery.class); when(ldapAutodiscovery.getLdapServers("example.org")).thenReturn(Collections.emptyList()); LdapSettingsManager settingsManager = new LdapSettingsManager( - generateAutodiscoverSettings(), ldapAutodiscovery); + generateAutodiscoverSettings().asConfig(), ldapAutodiscovery); thrown.expect(LdapException.class); thrown.expectMessage("The property 'ldap.url' is empty and SonarQube is not able to auto-discover any LDAP server."); @@ -112,7 +111,7 @@ public class LdapSettingsManagerTest { @Test public void testUserMappings() { LdapSettingsManager settingsManager = new LdapSettingsManager( - generateMultipleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery()); + generateMultipleLdapSettingsWithUserAndGroupMapping().asConfig(), new LdapAutodiscovery()); assertThat(settingsManager.getUserMappings().size()).isEqualTo(2); // We do it twice to make sure the settings keep the same. assertThat(settingsManager.getUserMappings().size()).isEqualTo(2); @@ -125,7 +124,7 @@ public class LdapSettingsManagerTest { @Test public void testGroupMappings() { LdapSettingsManager settingsManager = new LdapSettingsManager( - generateMultipleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery()); + generateMultipleLdapSettingsWithUserAndGroupMapping().asConfig(), new LdapAutodiscovery()); assertThat(settingsManager.getGroupMappings().size()).isEqualTo(2); // We do it twice to make sure the settings keep the same. assertThat(settingsManager.getGroupMappings().size()).isEqualTo(2); @@ -138,7 +137,7 @@ public class LdapSettingsManagerTest { @Test public void testEmptySettings() { LdapSettingsManager settingsManager = new LdapSettingsManager( - new MapSettings(), new LdapAutodiscovery()); + new MapSettings().asConfig(), new LdapAutodiscovery()); thrown.expect(LdapException.class); thrown.expectMessage("The property 'ldap.url' is empty and no realm configured to try auto-discovery."); diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUserMappingTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUserMappingTest.java index 3d151ff4da0..1c35fda4b5e 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUserMappingTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUserMappingTest.java @@ -28,7 +28,7 @@ public class LdapUserMappingTest { @Test public void defaults() { - LdapUserMapping userMapping = new LdapUserMapping(new MapSettings(), "ldap"); + LdapUserMapping userMapping = new LdapUserMapping(new MapSettings().asConfig(), "ldap"); assertThat(userMapping.getBaseDn()).isNull(); assertThat(userMapping.getRequest()).isEqualTo("(&(objectClass=inetOrgPerson)(uid={0}))"); assertThat(userMapping.getRealNameAttribute()).isEqualTo("cn"); @@ -47,7 +47,7 @@ public class LdapUserMappingTest { .setProperty("ldap.user.baseDn", "cn=users") .setProperty("ldap.user.request", "(&(objectClass=user)(sAMAccountName={0}))"); - LdapUserMapping userMapping = new LdapUserMapping(settings, "ldap"); + LdapUserMapping userMapping = new LdapUserMapping(settings.asConfig(), "ldap"); LdapSearch search = userMapping.createSearch(null, "tester"); assertThat(search.getBaseDn()).isEqualTo("cn=users"); assertThat(search.getRequest()).isEqualTo("(&(objectClass=user)(sAMAccountName={0}))"); @@ -68,7 +68,7 @@ public class LdapUserMappingTest { .setProperty("ldap.userObjectClass", "user") .setProperty("ldap.loginAttribute", "sAMAccountName"); - LdapUserMapping userMapping = new LdapUserMapping(settings, "ldap"); + LdapUserMapping userMapping = new LdapUserMapping(settings.asConfig(), "ldap"); assertThat(userMapping.getBaseDn()).isEqualTo("dc=example,dc=org"); } diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java index 754d73895d0..bc37bd849d8 100644 --- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java +++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java @@ -21,7 +21,7 @@ package org.sonar.auth.ldap; import org.junit.ClassRule; import org.junit.Test; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.MapSettings; import org.sonar.api.security.UserDetails; import org.sonar.auth.ldap.server.LdapServer; @@ -44,8 +44,8 @@ public class LdapUsersProviderTest { @Test public void test() { - Settings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, infosupportServer); - LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery()); + MapSettings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, infosupportServer); + LdapSettingsManager settingsManager = new LdapSettingsManager(settings.asConfig(), new LdapAutodiscovery()); LdapUsersProvider usersProvider = new LdapUsersProvider(settingsManager.getContextFactories(), settingsManager.getUserMappings()); UserDetails details; diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/ProjectConfigurationFactory.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/ProjectConfigurationFactory.java index 1640e67c8c1..4e73cfa22d3 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/ProjectConfigurationFactory.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/ProjectConfigurationFactory.java @@ -21,7 +21,7 @@ package org.sonar.ce.task.projectanalysis.analysis; import org.sonar.api.ce.ComputeEngineSide; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.ConfigurationBridge; import org.sonar.db.DbClient; import org.sonar.db.component.BranchType; diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/filter/IssueFilterTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/filter/IssueFilterTest.java index a5e8124ea2d..a905f0f8e21 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/filter/IssueFilterTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/filter/IssueFilterTest.java @@ -26,7 +26,7 @@ import java.util.List; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.rule.RuleKey; import org.sonar.ce.task.projectanalysis.component.Component; diff --git a/server/sonar-ce-task/src/main/java/org/sonar/ce/task/setting/SettingsLoader.java b/server/sonar-ce-task/src/main/java/org/sonar/ce/task/setting/SettingsLoader.java index 26e9d4e373d..efe406b9ded 100644 --- a/server/sonar-ce-task/src/main/java/org/sonar/ce/task/setting/SettingsLoader.java +++ b/server/sonar-ce-task/src/main/java/org/sonar/ce/task/setting/SettingsLoader.java @@ -21,13 +21,14 @@ package org.sonar.ce.task.setting; import org.picocontainer.Startable; import org.sonar.api.ce.ComputeEngineSide; +import org.sonar.api.config.internal.Settings; import org.sonar.ce.task.container.EagerStart; import org.sonar.ce.task.container.TaskContainerImpl; import org.sonar.server.setting.ThreadLocalSettings; /** * Add this class as the first components in the {@link TaskContainerImpl} - * to trigger loading of Thread local specific {@link org.sonar.api.config.Settings} in {@link ThreadLocalSettings}. + * to trigger loading of Thread local specific {@link Settings} in {@link ThreadLocalSettings}. */ @EagerStart @ComputeEngineSide diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/DefaultDatabase.java b/server/sonar-db-core/src/main/java/org/sonar/db/DefaultDatabase.java index 40991c11ca9..c4d61db0506 100644 --- a/server/sonar-db-core/src/main/java/org/sonar/db/DefaultDatabase.java +++ b/server/sonar-db-core/src/main/java/org/sonar/db/DefaultDatabase.java @@ -31,7 +31,7 @@ import javax.sql.DataSource; import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.dbcp2.BasicDataSourceFactory; import org.apache.commons.lang.StringUtils; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.db.dialect.Dialect; diff --git a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreTestDb.java b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreTestDb.java index 624cc731784..56d6821f9f7 100644 --- a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreTestDb.java +++ b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreTestDb.java @@ -30,7 +30,7 @@ import javax.annotation.Nullable; import javax.sql.DataSource; import org.apache.commons.codec.digest.DigestUtils; import org.junit.AssumptionViolatedException; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/createdb/CreateDb.java b/server/sonar-db-dao/src/test/java/org/sonar/db/createdb/CreateDb.java index 0d6a22c70ff..871d7395875 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/createdb/CreateDb.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/createdb/CreateDb.java @@ -24,7 +24,7 @@ import com.sonar.orchestrator.db.DatabaseClient; import com.sonar.orchestrator.db.DatabaseFactory; import com.sonar.orchestrator.db.DefaultDatabase; import java.util.function.Consumer; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/OrchestratorSettingsUtils.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/OrchestratorSettingsUtils.java index 8fe322172ae..255a3b9b065 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/OrchestratorSettingsUtils.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/OrchestratorSettingsUtils.java @@ -28,7 +28,7 @@ import java.util.Properties; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.text.StrSubstitutor; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import static org.apache.commons.lang.StringUtils.isEmpty; diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/SQDatabase.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/SQDatabase.java index b04f133ee51..4a2b00fb6e7 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/SQDatabase.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/SQDatabase.java @@ -29,7 +29,7 @@ import org.apache.ibatis.io.Resources; import org.apache.ibatis.jdbc.ScriptRunner; import org.sonar.api.SonarEdition; import org.sonar.api.SonarQubeSide; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.internal.SonarRuntimeImpl; import org.sonar.api.utils.System2; diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java index 358370add4e..a8612bcbb25 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java @@ -28,7 +28,7 @@ import javax.annotation.Nullable; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang.StringUtils; import org.junit.AssumptionViolatedException; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.db.dialect.H2; import org.sonar.process.logging.LogbackHelper; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/config/ConfigurationProvider.java b/server/sonar-server-common/src/main/java/org/sonar/server/config/ConfigurationProvider.java index 1fead12b3dc..74e06a003c2 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/config/ConfigurationProvider.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/config/ConfigurationProvider.java @@ -25,7 +25,7 @@ import org.apache.commons.lang.ArrayUtils; import org.picocontainer.injectors.ProviderAdapter; import org.sonar.api.config.Configuration; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import static java.util.function.Function.identity; import static org.sonar.api.config.internal.MultivalueProperty.parseAsCsv; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/setting/ChildSettings.java b/server/sonar-server-common/src/main/java/org/sonar/server/setting/ChildSettings.java index 0c047766ff5..a29fa650ed1 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/setting/ChildSettings.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/setting/ChildSettings.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.ConfigurationBridge; import static java.util.Objects.requireNonNull; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/setting/ThreadLocalSettings.java b/server/sonar-server-common/src/main/java/org/sonar/server/setting/ThreadLocalSettings.java index f2cf05f92d6..74c7affdf53 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/setting/ThreadLocalSettings.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/setting/ThreadLocalSettings.java @@ -32,10 +32,10 @@ import java.util.stream.Stream; import org.apache.ibatis.exceptions.PersistenceException; import org.sonar.api.CoreProperties; import org.sonar.api.ce.ComputeEngineSide; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.PropertyDefinition; import org.sonar.api.config.PropertyDefinitions; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.System2; import org.sonar.core.util.SettingFormatter; diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/setting/ProjectConfigurationLoaderImpl.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/setting/ProjectConfigurationLoaderImpl.java index a64d0528a3b..8d81a7937a0 100644 --- a/server/sonar-webserver-api/src/main/java/org/sonar/server/setting/ProjectConfigurationLoaderImpl.java +++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/setting/ProjectConfigurationLoaderImpl.java @@ -25,7 +25,7 @@ import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/PersistentSettings.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/PersistentSettings.java index 49c200de935..ae8e26b1ff5 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/PersistentSettings.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/PersistentSettings.java @@ -21,7 +21,7 @@ package org.sonar.server.platform; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.property.PropertyDto; diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/SettingsSection.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/SettingsSection.java index 813c18c4109..68697052eaf 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/SettingsSection.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/SettingsSection.java @@ -24,7 +24,7 @@ import java.util.TreeMap; import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; import org.sonar.api.config.PropertyDefinitions; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.server.ServerSide; import org.sonar.process.systeminfo.Global; import org.sonar.process.systeminfo.SystemInfoSection; diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationMediumTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationMediumTest.java index 6040fdc6cac..fb8b5001af5 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationMediumTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationMediumTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.sonar.api.config.PropertyDefinitions; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.notifications.Notification; import org.sonar.api.notifications.NotificationChannel; diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java index 79265b9a4a9..e87bb6098d0 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java @@ -21,7 +21,7 @@ package org.sonar.server.platform; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/SettingsSectionTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/SettingsSectionTest.java index 5eac665668b..3790efa3c01 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/SettingsSectionTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/SettingsSectionTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; import org.sonar.api.config.PropertyDefinitions; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.MapSettings; import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/CheckSecretKeyAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/CheckSecretKeyAction.java index 2339c33d0dc..1b76f09fd8f 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/CheckSecretKeyAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/CheckSecretKeyAction.java @@ -19,7 +19,7 @@ */ package org.sonar.server.setting.ws; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/EncryptAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/EncryptAction.java index a3a6fd24a0e..a4facc04719 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/EncryptAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/EncryptAction.java @@ -19,8 +19,8 @@ */ package org.sonar.server.setting.ws; -import org.sonar.api.config.Encryption; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Encryption; +import org.sonar.api.config.internal.Settings; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/GenerateSecretKeyAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/GenerateSecretKeyAction.java index 338ec47d887..df947043f8c 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/GenerateSecretKeyAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/GenerateSecretKeyAction.java @@ -19,7 +19,7 @@ */ package org.sonar.server.setting.ws; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java index f1d0afea3fe..971b767aefa 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java @@ -26,7 +26,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.server.ws.WebService; import org.sonar.server.exceptions.ForbiddenException; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java index 494fa9285ad..8991237379a 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java @@ -27,7 +27,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.server.ws.WebService; import org.sonar.server.exceptions.BadRequestException; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java index 80e636af7b2..48016199784 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java @@ -26,7 +26,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.server.ws.WebService; import org.sonar.server.exceptions.ForbiddenException; diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java index 7236908e426..14806bc4e16 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java @@ -77,7 +77,6 @@ import org.sonar.api.batch.sensor.rule.internal.DefaultAdHocRule; import org.sonar.api.batch.sensor.symbol.NewSymbolTable; import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Settings; import org.sonar.api.config.internal.ConfigurationBridge; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.internal.MetadataLoader; @@ -105,7 +104,7 @@ import static java.util.Collections.unmodifiableMap; */ public class SensorContextTester implements SensorContext { - private Settings settings; + private MapSettings settings; private DefaultFileSystem fs; private ActiveRules activeRules; private InMemorySensorStorage sensorStorage; @@ -132,8 +131,7 @@ public class SensorContextTester implements SensorContext { return new SensorContextTester(moduleBaseDir); } - @Override - public Settings settings() { + public MapSettings settings() { return settings; } @@ -142,7 +140,7 @@ public class SensorContextTester implements SensorContext { return new ConfigurationBridge(settings); } - public SensorContextTester setSettings(Settings settings) { + public SensorContextTester setSettings(MapSettings settings) { this.settings = settings; return this; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/AesCipher.java index 3111d2310a3..e6b14f3d9db 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/AesCipher.java @@ -17,7 +17,7 @@ * 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.api.config; +package org.sonar.api.config.internal; import java.io.File; import java.io.IOException; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Base64Cipher.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Base64Cipher.java index 63a78aca416..4829c075764 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/Base64Cipher.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Base64Cipher.java @@ -17,7 +17,7 @@ * 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.api.config; +package org.sonar.api.config.internal; import org.apache.commons.codec.binary.Base64; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Cipher.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Cipher.java index a2e72f01e93..556bf94c976 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/Cipher.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Cipher.java @@ -17,7 +17,7 @@ * 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.api.config; +package org.sonar.api.config.internal; interface Cipher { String encrypt(String clearText); diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/ConfigurationBridge.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/ConfigurationBridge.java index f6a24adfc88..a89ef0af3b1 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/ConfigurationBridge.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/ConfigurationBridge.java @@ -20,7 +20,6 @@ package org.sonar.api.config.internal; import java.util.Optional; -import org.sonar.api.config.Settings; import org.sonar.api.config.Configuration; /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Encryption.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Encryption.java index 9504203f356..8a4896c4480 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/Encryption.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Encryption.java @@ -17,7 +17,7 @@ * 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.api.config; +package org.sonar.api.config.internal; import java.util.HashMap; import java.util.Locale; diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/MapSettings.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/MapSettings.java index b53cdb0d0d1..764eef2812d 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/MapSettings.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/MapSettings.java @@ -23,9 +23,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Encryption; import org.sonar.api.config.PropertyDefinitions; -import org.sonar.api.config.Settings; import static java.util.Collections.unmodifiableMap; import static java.util.Objects.requireNonNull; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Settings.java index 59a10ced527..a934a807cb5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/Settings.java @@ -17,7 +17,7 @@ * 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.api.config; +package org.sonar.api.config.internal; import java.util.ArrayList; import java.util.Arrays; @@ -32,6 +32,9 @@ import javax.annotation.Nullable; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ce.ComputeEngineSide; +import org.sonar.api.config.Configuration; +import org.sonar.api.config.PropertyDefinition; +import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.scanner.ScannerSide; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.DateUtils; diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java index 66d0448ee4b..c336e9c4fa5 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java @@ -28,23 +28,22 @@ import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.fs.internal.DefaultFileSystem; +import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.internal.DefaultInputModule; +import org.sonar.api.batch.fs.internal.DefaultTextPointer; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.batch.rule.ActiveRules; +import org.sonar.api.batch.rule.Severity; import org.sonar.api.batch.rule.internal.ActiveRulesBuilder; import org.sonar.api.batch.rule.internal.NewActiveRule; -import org.sonar.api.batch.rule.Severity; import org.sonar.api.batch.sensor.error.AnalysisError; import org.sonar.api.batch.sensor.error.NewAnalysisError; import org.sonar.api.batch.sensor.highlighting.TypeOfText; import org.sonar.api.batch.sensor.issue.NewExternalIssue; import org.sonar.api.batch.sensor.issue.NewIssue; import org.sonar.api.batch.sensor.symbol.NewSymbolTable; -import org.sonar.api.config.Settings; import org.sonar.api.config.internal.MapSettings; -import org.sonar.api.batch.fs.internal.DefaultFileSystem; -import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.fs.internal.DefaultInputModule; -import org.sonar.api.batch.fs.internal.DefaultTextPointer; -import org.sonar.api.batch.fs.internal.TestInputFileBuilder; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.rule.RuleKey; import org.sonar.api.rules.RuleType; @@ -72,10 +71,10 @@ public class SensorContextTesterTest { @Test public void testSettings() { - Settings settings = new MapSettings(); + MapSettings settings = new MapSettings(); settings.setProperty("foo", "bar"); tester.setSettings(settings); - assertThat(tester.settings().getString("foo")).isEqualTo("bar"); + assertThat(tester.config().get("foo")).contains("bar"); } @Test diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/AesCipherTest.java index ce1f64ae858..900fe691286 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/AesCipherTest.java @@ -17,21 +17,19 @@ * 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.api.config; +package org.sonar.api.config.internal; +import java.io.File; +import java.net.URL; +import java.security.InvalidKeyException; +import java.security.Key; +import javax.crypto.BadPaddingException; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.StringUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import javax.crypto.BadPaddingException; - -import java.io.File; -import java.net.URL; -import java.security.InvalidKeyException; -import java.security.Key; - import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; @@ -65,7 +63,7 @@ public class AesCipherTest { thrown.expect(RuntimeException.class); thrown.expectMessage("Invalid AES key"); - URL resource = getClass().getResource("/org/sonar/api/config/AesCipherTest/bad_secret_key.txt"); + URL resource = getClass().getResource("/org/sonar/api/config/internal/AesCipherTest/bad_secret_key.txt"); AesCipher cipher = new AesCipher(new File(resource.toURI()).getCanonicalPath()); cipher.encrypt("this is a secret"); @@ -75,7 +73,7 @@ public class AesCipherTest { public void decrypt() throws Exception { AesCipher cipher = new AesCipher(pathToSecretKey()); - // the following value has been encrypted with the key /org/sonar/api/config/AesCipherTest/aes_secret_key.txt + // the following value has been encrypted with the key /org/sonar/api/config/internal/AesCipherTest/aes_secret_key.txt String clearText = cipher.decrypt("9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY="); assertThat(clearText).isEqualTo("this is a secret"); @@ -83,7 +81,7 @@ public class AesCipherTest { @Test public void decrypt_bad_key() throws Exception { - URL resource = getClass().getResource("/org/sonar/api/config/AesCipherTest/bad_secret_key.txt"); + URL resource = getClass().getResource("/org/sonar/api/config/internal/AesCipherTest/bad_secret_key.txt"); AesCipher cipher = new AesCipher(new File(resource.toURI()).getCanonicalPath()); try { @@ -97,7 +95,7 @@ public class AesCipherTest { @Test public void decrypt_other_key() throws Exception { - URL resource = getClass().getResource("/org/sonar/api/config/AesCipherTest/other_secret_key.txt"); + URL resource = getClass().getResource("/org/sonar/api/config/internal/AesCipherTest/other_secret_key.txt"); AesCipher cipher = new AesCipher(new File(resource.toURI()).getCanonicalPath()); try { @@ -137,7 +135,7 @@ public class AesCipherTest { @Test public void loadSecretKeyFromFile_trim_content() throws Exception { - URL resource = getClass().getResource("/org/sonar/api/config/AesCipherTest/non_trimmed_secret_key.txt"); + URL resource = getClass().getResource("/org/sonar/api/config/internal/AesCipherTest/non_trimmed_secret_key.txt"); String path = new File(resource.toURI()).getCanonicalPath(); AesCipher cipher = new AesCipher(null); @@ -178,7 +176,7 @@ public class AesCipherTest { } private String pathToSecretKey() throws Exception { - URL resource = getClass().getResource("/org/sonar/api/config/AesCipherTest/aes_secret_key.txt"); + URL resource = getClass().getResource("/org/sonar/api/config/internal/AesCipherTest/aes_secret_key.txt"); return new File(resource.toURI()).getCanonicalPath(); } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/EncryptionTest.java index e73b91fe9c7..5bfcf34f2c6 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/EncryptionTest.java @@ -17,7 +17,7 @@ * 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.api.config; +package org.sonar.api.config.internal; import org.junit.Test; diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java index d4554b2fc55..89845b01dbb 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java @@ -40,7 +40,6 @@ import org.sonar.api.Property; import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; import org.sonar.api.config.PropertyDefinitions; -import org.sonar.api.config.Settings; import org.sonar.api.utils.DateUtils; import static java.util.Collections.singletonList; diff --git a/sonar-plugin-api/src/test/resources/org/sonar/api/config/AesCipherTest/aes_secret_key.txt b/sonar-plugin-api-impl/src/test/resources/org/sonar/api/config/internal/AesCipherTest/aes_secret_key.txt index 65b98c522da..65b98c522da 100644 --- a/sonar-plugin-api/src/test/resources/org/sonar/api/config/AesCipherTest/aes_secret_key.txt +++ b/sonar-plugin-api-impl/src/test/resources/org/sonar/api/config/internal/AesCipherTest/aes_secret_key.txt diff --git a/sonar-plugin-api/src/test/resources/org/sonar/api/config/AesCipherTest/bad_secret_key.txt b/sonar-plugin-api-impl/src/test/resources/org/sonar/api/config/internal/AesCipherTest/bad_secret_key.txt index b33e179e5c8..b33e179e5c8 100644 --- a/sonar-plugin-api/src/test/resources/org/sonar/api/config/AesCipherTest/bad_secret_key.txt +++ b/sonar-plugin-api-impl/src/test/resources/org/sonar/api/config/internal/AesCipherTest/bad_secret_key.txt diff --git a/sonar-plugin-api/src/test/resources/org/sonar/api/config/AesCipherTest/non_trimmed_secret_key.txt b/sonar-plugin-api-impl/src/test/resources/org/sonar/api/config/internal/AesCipherTest/non_trimmed_secret_key.txt index ab83e4adc03..ab83e4adc03 100644 --- a/sonar-plugin-api/src/test/resources/org/sonar/api/config/AesCipherTest/non_trimmed_secret_key.txt +++ b/sonar-plugin-api-impl/src/test/resources/org/sonar/api/config/internal/AesCipherTest/non_trimmed_secret_key.txt diff --git a/sonar-plugin-api/src/test/resources/org/sonar/api/config/AesCipherTest/other_secret_key.txt b/sonar-plugin-api-impl/src/test/resources/org/sonar/api/config/internal/AesCipherTest/other_secret_key.txt index 23f5ecf5104..23f5ecf5104 100644 --- a/sonar-plugin-api/src/test/resources/org/sonar/api/config/AesCipherTest/other_secret_key.txt +++ b/sonar-plugin-api-impl/src/test/resources/org/sonar/api/config/internal/AesCipherTest/other_secret_key.txt diff --git a/sonar-plugin-api/build.gradle b/sonar-plugin-api/build.gradle index a50c2883ad5..bff7eec5a3b 100644 --- a/sonar-plugin-api/build.gradle +++ b/sonar-plugin-api/build.gradle @@ -9,7 +9,6 @@ apply plugin: 'com.github.johnrengelman.shadow' dependencies { // please keep the list grouped by configuration and ordered by name - compile 'commons-codec:commons-codec' compile 'commons-io:commons-io' compile 'commons-lang:commons-lang' compile 'com.google.code.gson:gson' diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectBuilder.java index a28b3dd1bc9..1397ea54d87 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectBuilder.java @@ -20,6 +20,7 @@ package org.sonar.api.batch.bootstrap; import org.sonar.api.ExtensionPoint; +import org.sonar.api.config.Configuration; import org.sonar.api.scanner.ScannerSide; /** @@ -40,13 +41,15 @@ import org.sonar.api.scanner.ScannerSide; @Deprecated public abstract class ProjectBuilder { - /** - * Plugins can use the implementation {@link org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext} - * for their unit tests. - */ @Deprecated public interface Context { ProjectReactor projectReactor(); + + /** + * Global config (command line arguments, global scanner properties). + * @since 8.3 Only as a replacement for injecting Settings + */ + Configuration config(); } /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/internal/ProjectBuilderContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/internal/ProjectBuilderContext.java index e47470c4bcc..bc6d2fcbd33 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/internal/ProjectBuilderContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/internal/ProjectBuilderContext.java @@ -22,6 +22,7 @@ package org.sonar.api.batch.bootstrap.internal; import org.sonar.api.batch.bootstrap.ProjectBuilder; import org.sonar.api.batch.bootstrap.ProjectReactor; +import org.sonar.api.config.Configuration; /** * Context that is passed to {@link org.sonar.api.batch.bootstrap.ProjectBuilder} as parameter. @@ -34,9 +35,11 @@ import org.sonar.api.batch.bootstrap.ProjectReactor; public class ProjectBuilderContext implements ProjectBuilder.Context { private final ProjectReactor reactor; + private final Configuration configuration; - public ProjectBuilderContext(ProjectReactor reactor) { + public ProjectBuilderContext(ProjectReactor reactor, Configuration configuration) { this.reactor = reactor; + this.configuration = configuration; } @Override @@ -44,4 +47,8 @@ public class ProjectBuilderContext implements ProjectBuilder.Context { return reactor; } + @Override + public Configuration config() { + return configuration; + } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobContext.java index 6401b058e45..34cea548ed0 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/postjob/PostJobContext.java @@ -22,7 +22,6 @@ package org.sonar.api.batch.postjob; import org.sonar.api.batch.AnalysisMode; import org.sonar.api.batch.postjob.issue.PostJobIssue; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Settings; /** * See {@link PostJob#execute(PostJobContext)} @@ -31,12 +30,6 @@ import org.sonar.api.config.Settings; public interface PostJobContext { /** - * @deprecated since 6.5 use {@link #config()} - */ - @Deprecated - Settings settings(); - - /** * Get configuration of the current project. * @since 6.5 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java index b156d2c5480..038a6dc5f20 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/SensorContext.java @@ -40,7 +40,6 @@ import org.sonar.api.batch.sensor.rule.AdHocRule; import org.sonar.api.batch.sensor.rule.NewAdHocRule; import org.sonar.api.batch.sensor.symbol.NewSymbolTable; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Settings; import org.sonar.api.scanner.fs.InputProject; import org.sonar.api.scanner.sensor.ProjectSensor; import org.sonar.api.utils.Version; @@ -53,12 +52,6 @@ import org.sonar.api.utils.Version; public interface SensorContext { /** - * @deprecated since 6.5 use {@link #config()} - */ - @Deprecated - Settings settings(); - - /** * Get settings of the project. * @since 6.5 */ diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java index a17031fb5af..ffbb82611e1 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java @@ -22,7 +22,7 @@ package org.sonar.api.batch.bootstrap; import java.io.File; import org.junit.Test; import org.sonar.api.batch.bootstrap.internal.ProjectBuilderContext; -import org.sonar.api.config.Settings; +import org.sonar.api.config.Configuration; import org.sonar.api.config.internal.MapSettings; import static org.assertj.core.api.Assertions.assertThat; @@ -36,8 +36,11 @@ public class ProjectBuilderTest { // this reactor is created and provided by Sonar final ProjectReactor projectReactor = new ProjectReactor(ProjectDefinition.create()); - ProjectBuilder builder = new ProjectBuilderSample(new MapSettings()); - builder.build(new ProjectBuilderContext(projectReactor)); + ProjectBuilder builder = new ProjectBuilderSample(); + final MapSettings settings = new MapSettings(); + settings.setProperty("foo", "bar"); + final Configuration configuration = settings.asConfig(); + builder.build(new ProjectBuilderContext(projectReactor, configuration)); assertThat(projectReactor.getProjects().size(), is(2)); ProjectDefinition root = projectReactor.getRoot(); @@ -47,17 +50,12 @@ public class ProjectBuilderTest { } final static class ProjectBuilderSample extends ProjectBuilder { - private Settings conf; - - public ProjectBuilderSample(Settings conf) { - // A real implementation should for example use the settings - this.conf = conf; - } @Override - protected void build(ProjectReactor reactor) { + public void build(Context context) { + assertThat(context.config().get("foo")).contains("bar"); // change name of root project - ProjectDefinition root = reactor.getRoot(); + ProjectDefinition root = context.projectReactor().getRoot(); root.setName("Name changed by plugin"); // add sub-project diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java index 33676d7216c..819b1123838 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java @@ -21,7 +21,7 @@ package org.sonar.scanner.bootstrap; import java.util.Map; import javax.annotation.concurrent.Immutable; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.PropertyDefinitions; import org.sonar.scanner.config.DefaultConfiguration; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/RawScannerProperties.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/RawScannerProperties.java index 02cea8f5a04..8d468a0cbeb 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/RawScannerProperties.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/RawScannerProperties.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.Map; import javax.annotation.concurrent.Immutable; import org.sonar.api.CoreProperties; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; /** * Properties that are coming from scanner. diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java index 019f7faf393..420257ab6e5 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java @@ -26,7 +26,7 @@ import java.util.Optional; import javax.annotation.concurrent.Immutable; import org.apache.commons.lang.ArrayUtils; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.PropertyDefinition; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.utils.log.Logger; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/DefaultPostJobContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/DefaultPostJobContext.java index 284a947e580..1165cb18405 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/DefaultPostJobContext.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/DefaultPostJobContext.java @@ -23,26 +23,18 @@ import org.sonar.api.batch.AnalysisMode; import org.sonar.api.batch.postjob.PostJobContext; import org.sonar.api.batch.postjob.issue.PostJobIssue; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Settings; public class DefaultPostJobContext implements PostJobContext { private final Configuration config; private final AnalysisMode analysisMode; - private final Settings mutableSettings; - public DefaultPostJobContext(Configuration config, Settings mutableSettings, AnalysisMode analysisMode) { + public DefaultPostJobContext(Configuration config, AnalysisMode analysisMode) { this.config = config; - this.mutableSettings = mutableSettings; this.analysisMode = analysisMode; } @Override - public Settings settings() { - return mutableSettings; - } - - @Override public Configuration config() { return config; } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfiguration.java index 1ea62744a82..ffbb30e5f19 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfiguration.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfiguration.java @@ -20,7 +20,7 @@ package org.sonar.scanner.scan; import java.util.Map; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.PropertyDefinitions; import org.sonar.scanner.config.DefaultConfiguration; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java index 90878d8bd68..cdabce5f397 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java @@ -22,7 +22,7 @@ package org.sonar.scanner.scan; import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import static java.util.Objects.requireNonNull; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java index 9cd4ac2acca..fdb477bd376 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java @@ -22,7 +22,7 @@ package org.sonar.scanner.scan; import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.scanner.bootstrap.GlobalConfiguration; import static java.util.Objects.requireNonNull; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java index ebe2a532553..9f9ee32596f 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java @@ -27,25 +27,28 @@ import org.sonar.api.utils.MessageException; 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.GlobalConfiguration; public class ProjectBuildersExecutor { private static final Logger LOG = Loggers.get(ProjectBuildersExecutor.class); + private final GlobalConfiguration globalConfig; private final ProjectBuilder[] projectBuilders; - public ProjectBuildersExecutor(ProjectBuilder... projectBuilders) { + public ProjectBuildersExecutor(GlobalConfiguration globalConfig, ProjectBuilder... projectBuilders) { + this.globalConfig = globalConfig; this.projectBuilders = projectBuilders; } - public ProjectBuildersExecutor() { - this(new ProjectBuilder[0]); + public ProjectBuildersExecutor(GlobalConfiguration globalConfig) { + this(globalConfig, new ProjectBuilder[0]); } public void execute(ProjectReactor reactor) { if (projectBuilders.length > 0) { Profiler profiler = Profiler.create(LOG).startInfo("Execute project builders"); - ProjectBuilderContext context = new ProjectBuilderContext(reactor); + ProjectBuilderContext context = new ProjectBuilderContext(reactor, globalConfig); for (ProjectBuilder projectBuilder : projectBuilders) { try { diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfiguration.java index 73de3d7e1aa..303af595644 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfiguration.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfiguration.java @@ -20,7 +20,7 @@ package org.sonar.scanner.scan; import java.util.Map; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.PropertyDefinitions; import org.sonar.scanner.config.DefaultConfiguration; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorContext.java index 0ff40eef339..b82a8d6e037 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorContext.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorContext.java @@ -23,20 +23,19 @@ import javax.annotation.concurrent.ThreadSafe; import org.sonar.api.SonarRuntime; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputModule; +import org.sonar.api.batch.fs.internal.DefaultInputProject; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.batch.sensor.internal.SensorStorage; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Settings; -import org.sonar.api.batch.fs.internal.DefaultInputProject; @ThreadSafe public class ModuleSensorContext extends ProjectSensorContext { private final InputModule module; - public ModuleSensorContext(DefaultInputProject project, InputModule module, Configuration config, Settings mutableSettings, FileSystem fs, ActiveRules activeRules, + public ModuleSensorContext(DefaultInputProject project, InputModule module, Configuration config, FileSystem fs, ActiveRules activeRules, SensorStorage sensorStorage, SonarRuntime sonarRuntime) { - super(project, config, mutableSettings, fs, activeRules, sensorStorage, sonarRuntime); + super(project, config, fs, activeRules, sensorStorage, sonarRuntime); this.module = module; } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java index 3e43dc2f8a0..9819d18c6f1 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java @@ -50,7 +50,6 @@ import org.sonar.api.batch.sensor.rule.internal.DefaultAdHocRule; import org.sonar.api.batch.sensor.symbol.NewSymbolTable; import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Settings; import org.sonar.api.scanner.fs.InputProject; import org.sonar.api.utils.Version; import org.sonar.scanner.sensor.noop.NoOpNewAnalysisError; @@ -60,7 +59,6 @@ public class ProjectSensorContext implements SensorContext { static final NoOpNewAnalysisError NO_OP_NEW_ANALYSIS_ERROR = new NoOpNewAnalysisError(); - private final Settings mutableSettings; private final FileSystem fs; private final ActiveRules activeRules; private final SensorStorage sensorStorage; @@ -68,11 +66,10 @@ public class ProjectSensorContext implements SensorContext { private final SonarRuntime sonarRuntime; private final Configuration config; - public ProjectSensorContext(DefaultInputProject project, Configuration config, Settings mutableSettings, FileSystem fs, ActiveRules activeRules, + public ProjectSensorContext(DefaultInputProject project, Configuration config, FileSystem fs, ActiveRules activeRules, SensorStorage sensorStorage, SonarRuntime sonarRuntime) { this.project = project; this.config = config; - this.mutableSettings = mutableSettings; this.fs = fs; this.activeRules = activeRules; this.sensorStorage = sensorStorage; @@ -80,11 +77,6 @@ public class ProjectSensorContext implements SensorContext { } @Override - public Settings settings() { - return mutableSettings; - } - - @Override public Configuration config() { return config; } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/config/DefaultConfigurationTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/config/DefaultConfigurationTest.java index 5a6ad80a1cd..1646722b2ce 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/config/DefaultConfigurationTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/config/DefaultConfigurationTest.java @@ -24,7 +24,7 @@ import java.util.Arrays; import org.junit.Rule; import org.junit.Test; import org.sonar.api.config.Configuration; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.PropertyDefinition; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.PropertyFieldDefinition; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java index a0e273d4b56..4fde4372d75 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java @@ -24,7 +24,7 @@ import java.util.Map; import java.util.Set; import org.junit.Rule; import org.junit.Test; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.utils.log.LogTester; import org.sonar.scanner.config.DefaultConfiguration; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java index 539db984734..c5e9427f88d 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java @@ -28,7 +28,7 @@ import org.apache.commons.io.FileUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.sonar.api.config.Encryption; +import org.sonar.api.config.internal.Encryption; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.utils.log.LogTester; import org.sonar.api.utils.log.LoggerLevel; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java index 679b3fd00ca..9b16d4d3705 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java @@ -23,7 +23,7 @@ import org.sonar.api.SonarEdition; import org.junit.Test; import org.sonar.api.CoreProperties; import org.sonar.api.SonarQubeSide; -import org.sonar.api.config.Settings; +import org.sonar.api.config.internal.Settings; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.internal.SonarRuntimeImpl; import org.sonar.api.utils.Version; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java index ca2ff21b523..a95a42d09bb 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/postjob/DefaultPostJobContextTest.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.sonar.api.batch.AnalysisMode; import org.sonar.api.config.internal.MapSettings; -import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; public class DefaultPostJobContextTest { @@ -36,12 +35,7 @@ public class DefaultPostJobContextTest { public void setUp() { settings = new MapSettings(); AnalysisMode analysisMode = mock(AnalysisMode.class); - context = new DefaultPostJobContext(settings.asConfig(), settings, analysisMode); - } - - @Test - public void testSettings() { - assertThat(context.settings()).isSameAs(settings); + context = new DefaultPostJobContext(settings.asConfig(), analysisMode); } @Test(expected=UnsupportedOperationException.class) diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectBuildersExecutorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectBuildersExecutorTest.java index 7048a9648ce..1a64f4f049c 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectBuildersExecutorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectBuildersExecutorTest.java @@ -27,6 +27,7 @@ import org.sonar.api.batch.bootstrap.ProjectBuilder; import org.sonar.api.batch.bootstrap.ProjectBuilder.Context; import org.sonar.api.batch.bootstrap.ProjectReactor; import org.sonar.api.utils.MessageException; +import org.sonar.scanner.bootstrap.GlobalConfiguration; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; @@ -51,7 +52,7 @@ public class ProjectBuildersExecutorTest { exception.expectMessage("Failed to execute project builder: Mock for ProjectBuilder"); exception.expect(MessageException.class); - new ProjectBuildersExecutor(projectBuilders).execute(reactor); + new ProjectBuildersExecutor(mock(GlobalConfiguration.class), projectBuilders).execute(reactor); } @Test @@ -61,7 +62,7 @@ public class ProjectBuildersExecutorTest { exception.expectMessage("Failed to execute project builder: org.sonar.scanner.scan.ProjectBuildersExecutorTest$MyProjectBuilder"); exception.expect(MessageException.class); - new ProjectBuildersExecutor(projectBuilders).execute(reactor); + new ProjectBuildersExecutor(mock(GlobalConfiguration.class), projectBuilders).execute(reactor); } static class MyProjectBuilder extends ProjectBuilder { diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/ModuleSensorContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/ModuleSensorContextTest.java index 4817e392310..a29e0deb855 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/ModuleSensorContextTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/ModuleSensorContextTest.java @@ -68,14 +68,13 @@ public class ModuleSensorContextTest { settings = new MapSettings(); sensorStorage = mock(SensorStorage.class); runtime = SonarRuntimeImpl.forSonarQube(Version.parse("5.5"), SonarQubeSide.SCANNER, SonarEdition.COMMUNITY); - adaptor = new ModuleSensorContext(mock(DefaultInputProject.class), mock(InputModule.class), settings.asConfig(), settings, fs, activeRules, sensorStorage, runtime); + adaptor = new ModuleSensorContext(mock(DefaultInputProject.class), mock(InputModule.class), settings.asConfig(), fs, activeRules, sensorStorage, runtime); } @Test public void shouldProvideComponents() { assertThat(adaptor.activeRules()).isEqualTo(activeRules); assertThat(adaptor.fileSystem()).isEqualTo(fs); - assertThat(adaptor.settings()).isEqualTo(settings); assertThat(adaptor.getSonarQubeVersion()).isEqualTo(Version.parse("5.5")); assertThat(adaptor.runtime()).isEqualTo(runtime); |