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;
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);
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;
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