aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java7
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesUpdateListener.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesUpdateListenerTest.java19
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java4
-rw-r--r--tests/plugins/security-plugin/src/test/java/FakeAuthenticatorTest.java2
-rw-r--r--tests/src/test/java/org/sonarqube/tests/performance/scanner/MemoryTest.java4
7 files changed, 29 insertions, 25 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
index 100cebba00d..03e55161cd6 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
@@ -21,6 +21,7 @@ package org.sonar.server.platform;
import java.io.File;
import java.util.Date;
+import javax.annotation.CheckForNull;
import org.sonar.api.CoreProperties;
import org.sonar.api.SonarRuntime;
import org.sonar.api.ce.ComputeEngineSide;
@@ -46,9 +47,13 @@ public class ServerImpl extends Server {
this.runtime = runtime;
}
+ /**
+ * Can be null when server is waiting for migration
+ */
@Override
+ @CheckForNull
public String getId() {
- return config.get(CoreProperties.SERVER_ID).get();
+ return config.get(CoreProperties.SERVER_ID).orElse(null);
}
@Override
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesUpdateListener.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesUpdateListener.java
index 7f355769357..0cd0dcf2c75 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesUpdateListener.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesUpdateListener.java
@@ -22,7 +22,7 @@ package org.sonar.server.qualityprofile;
import com.google.common.collect.Multimap;
import java.util.Collection;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.Configuration;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.server.notification.NotificationManager;
@@ -39,16 +39,16 @@ public class BuiltInQualityProfilesUpdateListener {
private final NotificationManager notificationManager;
private final Languages languages;
- private final Settings settings;
+ private final Configuration config;
- public BuiltInQualityProfilesUpdateListener(NotificationManager notificationManager, Languages languages, Settings settings) {
+ public BuiltInQualityProfilesUpdateListener(NotificationManager notificationManager, Languages languages, Configuration config) {
this.notificationManager = notificationManager;
this.languages = languages;
- this.settings = settings;
+ this.config = config;
}
void onChange(Multimap<QProfileName, ActiveRuleChange> changedProfiles, long startDate, long endDate) {
- if (settings.getBoolean(DISABLE_NOTIFICATION_ON_BUILT_IN_QPROFILES)) {
+ if (config.getBoolean(DISABLE_NOTIFICATION_ON_BUILT_IN_QPROFILES).orElse(false)) {
return;
}
BuiltInQualityProfilesNotification notification = new BuiltInQualityProfilesNotification();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesUpdateListenerTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesUpdateListenerTest.java
index 0a826f10481..2e67e7f92bf 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesUpdateListenerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/BuiltInQualityProfilesUpdateListenerTest.java
@@ -27,8 +27,7 @@ import java.util.stream.IntStream;
import org.assertj.core.groups.Tuple;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.sonar.api.config.MapSettings;
-import org.sonar.api.config.Settings;
+import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.notifications.Notification;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
@@ -53,7 +52,7 @@ public class BuiltInQualityProfilesUpdateListenerTest {
private static final Random RANDOM = new Random();
private NotificationManager notificationManager = mock(NotificationManager.class);
- private Settings settings = new MapSettings();
+ private MapSettings settings = new MapSettings();
@Test
public void add_profile_to_notification_for_added_rules() throws Exception {
@@ -62,7 +61,7 @@ public class BuiltInQualityProfilesUpdateListenerTest {
Languages languages = new Languages();
Tuple expectedTuple = addProfile(profiles, languages, ACTIVATED);
- BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings);
+ BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings.asConfig());
underTest.onChange(profiles, 0, 1);
ArgumentCaptor<Notification> notificationArgumentCaptor = ArgumentCaptor.forClass(Notification.class);
@@ -80,7 +79,7 @@ public class BuiltInQualityProfilesUpdateListenerTest {
Languages languages = new Languages();
Tuple expectedTuple = addProfile(profiles, languages, UPDATED);
- BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings);
+ BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings.asConfig());
underTest.onChange(profiles, 0, 1);
ArgumentCaptor<Notification> notificationArgumentCaptor = ArgumentCaptor.forClass(Notification.class);
@@ -98,7 +97,7 @@ public class BuiltInQualityProfilesUpdateListenerTest {
Languages languages = new Languages();
Tuple expectedTuple = addProfile(profiles, languages, DEACTIVATED);
- BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings);
+ BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings.asConfig());
underTest.onChange(profiles, 0, 1);
ArgumentCaptor<Notification> notificationArgumentCaptor = ArgumentCaptor.forClass(Notification.class);
@@ -117,7 +116,7 @@ public class BuiltInQualityProfilesUpdateListenerTest {
Tuple expectedTuple1 = addProfile(profiles, languages, ACTIVATED);
Tuple expectedTuple2 = addProfile(profiles, languages, ACTIVATED);
- BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings);
+ BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings.asConfig());
underTest.onChange(profiles, 0, 1);
ArgumentCaptor<Notification> notificationArgumentCaptor = ArgumentCaptor.forClass(Notification.class);
@@ -137,7 +136,7 @@ public class BuiltInQualityProfilesUpdateListenerTest {
long startDate = RANDOM.nextInt(5000);
long endDate = startDate + RANDOM.nextInt(5000);
- BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings);
+ BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings.asConfig());
underTest.onChange(profiles, startDate, endDate);
ArgumentCaptor<Notification> notificationArgumentCaptor = ArgumentCaptor.forClass(Notification.class);
@@ -155,7 +154,7 @@ public class BuiltInQualityProfilesUpdateListenerTest {
Languages languages = new Languages();
addProfile(profiles, languages, ACTIVATED);
- BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings);
+ BuiltInQualityProfilesUpdateListener underTest = new BuiltInQualityProfilesUpdateListener(notificationManager, languages, settings.asConfig());
underTest.onChange(profiles, 0, 1);
verifyZeroInteractions(notificationManager);
@@ -176,7 +175,7 @@ public class BuiltInQualityProfilesUpdateListenerTest {
return randomAlphanumeric(20).toLowerCase();
}
- private void enableNotificationInGlobalSettings(){
+ private void enableNotificationInGlobalSettings() {
settings.setProperty(DISABLE_NOTIFICATION_ON_BUILT_IN_QPROFILES, false);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java
index 5e133f330c9..f215112b365 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java
@@ -23,7 +23,7 @@ package org.sonar.server.qualityprofile.ws;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.server.ws.WebService;
@@ -46,6 +46,7 @@ import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.QualityProfiles;
import org.sonarqube.ws.QualityProfiles.ShowResponse;
import org.sonarqube.ws.QualityProfiles.ShowResponse.CompareToSonarWay;
+import org.sonarqube.ws.QualityProfiles.ShowResponse.QualityProfile;
import static java.util.stream.IntStream.range;
import static org.assertj.core.api.Assertions.assertThat;
@@ -53,7 +54,6 @@ import static org.sonar.api.rule.RuleStatus.DEPRECATED;
import static org.sonar.api.utils.DateUtils.parseDateTime;
import static org.sonar.server.language.LanguageTesting.newLanguage;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.QualityProfiles.ShowResponse.QualityProfile;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_COMPARE_TO_SONAR_WAY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
@@ -64,7 +64,7 @@ public class ShowActionTest {
private static Languages LANGUAGES = new Languages(XOO1, XOO2);
@Rule
- public EsTester es = new EsTester(new RuleIndexDefinition(new MapSettings()));
+ public EsTester es = new EsTester(new RuleIndexDefinition(new MapSettings().asConfig()));
@Rule
public DbTester db = DbTester.create();
@Rule
@@ -215,7 +215,7 @@ public class ShowActionTest {
CompareToSonarWay result = call(ws.newRequest()
.setParam(PARAM_PROFILE, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"))
- .getCompareToSonarWay();
+ .getCompareToSonarWay();
assertThat(result)
.extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName, CompareToSonarWay::getMissingRuleCount)
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
index 9bf8eef05b4..19cc04bdaaf 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
@@ -181,8 +181,8 @@ public class ProjectDefinition {
String branch = properties.get(CoreProperties.PROJECT_BRANCH_PROPERTY);
if (StringUtils.isNotBlank(branch)) {
return branch;
- } else if (getParent() != null) {
- return getParent().getBranch();
+ } else if (parent != null) {
+ return parent.getBranch();
}
return null;
}
diff --git a/tests/plugins/security-plugin/src/test/java/FakeAuthenticatorTest.java b/tests/plugins/security-plugin/src/test/java/FakeAuthenticatorTest.java
index e55aacb9478..37f5fc038ad 100644
--- a/tests/plugins/security-plugin/src/test/java/FakeAuthenticatorTest.java
+++ b/tests/plugins/security-plugin/src/test/java/FakeAuthenticatorTest.java
@@ -20,7 +20,7 @@
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
-import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.config.Settings;
import org.sonar.api.security.UserDetails;
diff --git a/tests/src/test/java/org/sonarqube/tests/performance/scanner/MemoryTest.java b/tests/src/test/java/org/sonarqube/tests/performance/scanner/MemoryTest.java
index 877c3a32f09..837d42ebd67 100644
--- a/tests/src/test/java/org/sonarqube/tests/performance/scanner/MemoryTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/performance/scanner/MemoryTest.java
@@ -89,7 +89,7 @@ public class MemoryTest extends AbstractPerfTest {
.setProjectDir(baseDir);
BuildResult result = orchestrator.executeBuild(scanner);
- perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 6190L);
+ perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 6740L);
// Second execution with a property on server side
orchestrator.getServer().newHttpCall("/api/settings/set")
@@ -100,7 +100,7 @@ public class MemoryTest extends AbstractPerfTest {
.setParam("component", "big-module-tree")
.execute();
result = orchestrator.executeBuild(scanner);
- perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 6120L);
+ perfRule.assertDurationAround(MavenLogs.extractTotalTime(result.getLogs()), 6720L);
}
private void prepareModule(File parentDir, String moduleName, int depth) throws IOException {