]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9802 order settings of api/system/info
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 21 Sep 2017 16:52:39 +0000 (18:52 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 26 Sep 2017 21:49:38 +0000 (23:49 +0200)
server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SettingsSection.java
server/sonar-server/src/main/java/org/sonar/server/platform/ws/BaseInfoWsAction.java
server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/SettingsSectionTest.java

index 961938a46d26d9eaef4164b5465f6a8e59ec5a37..303135abe95391469b746a13b72708f01d5cd865 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.server.platform.monitoring;
 
 import java.util.Map;
+import java.util.TreeMap;
 import org.sonar.api.PropertyType;
 import org.sonar.api.config.PropertyDefinition;
 import org.sonar.api.config.PropertyDefinitions;
@@ -52,7 +53,8 @@ public class SettingsSection implements SystemInfoSection, Global {
     protobuf.setName("Settings");
 
     PropertyDefinitions definitions = settings.getDefinitions();
-    for (Map.Entry<String, String> prop : settings.getProperties().entrySet()) {
+    TreeMap<String, String> orderedProps = new TreeMap<>(settings.getProperties());
+    for (Map.Entry<String, String> prop : orderedProps.entrySet()) {
       String key = prop.getKey();
       String value = obfuscateValue(definitions, key, prop.getValue());
       setAttribute(protobuf, key, value);
index 4f2607a96cc4bdcd314273a502e6a90d5b47e881..f50aebe0c6569429b423f9a583e512b7fdf60a0e 100644 (file)
@@ -36,9 +36,9 @@ public abstract class BaseInfoWsAction implements SystemWsAction {
 
   private static final String[] ORDERED_SECTION_NAMES = {
     "System", "Database", "Plugins",
-    "Web JVM State", "Web Logging", "Web JVM Properties",
-    "Search State", "Search Statistics",
-    "Compute Engine Database Connection", "Compute Engine JVM State", "Compute Engine Logging", "Compute Engine Tasks", "Compute Engine JVM Properties"};
+    "Web JVM State", "Web Database Connection", "Web Logging", "Web JVM Properties",
+    "Search State", "Search Indexes",
+    "Compute Engine Tasks", "Compute Engine JVM State", "Compute Engine Database Connection", "Compute Engine Logging", "Compute Engine JVM Properties"};
 
   private final UserSession userSession;
   private final TelemetryDataLoader telemetry;
index dc6c9c1b16c666a055bae2d14d88017ee4cd9c54..02ff00d71a632fa68d8d78ad6c2ace5a0b2011e5 100644 (file)
@@ -48,6 +48,11 @@ public class SettingsSectionTest {
     ProtobufSystemInfo.Section protobuf = underTest.toProtobuf();
     assertThatAttributeIs(protobuf, "bar", "bar value");
     assertThatAttributeIs(protobuf, "foo", "foo value");
+
+    // keys are ordered alphabetically
+    assertThat(protobuf.getAttributesList())
+      .extracting(ProtobufSystemInfo.Attribute::getKey)
+      .containsExactly("bar", "foo");
   }
 
   @Test