diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-09-19 21:49:28 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-09-26 23:49:38 +0200 |
commit | d66c032827817a65366acd0f98d5c64694b91dae (patch) | |
tree | 70ee5dd5828d22c442130c34d25d21030fdce9f9 /server/sonar-process/src | |
parent | b5f3b88aac1f507586983dd6b2ebbdd46b97810e (diff) | |
download | sonarqube-d66c032827817a65366acd0f98d5c64694b91dae.tar.gz sonarqube-d66c032827817a65366acd0f98d5c64694b91dae.zip |
SONAR-9845 Display type of disk in System Info on Linu
Diffstat (limited to 'server/sonar-process/src')
-rw-r--r-- | server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java | 12 | ||||
-rw-r--r-- | server/sonar-process/src/test/java/org/sonar/process/systeminfo/SystemInfoUtilsTest.java | 13 |
2 files changed, 20 insertions, 5 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java b/server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java index 0126bbe2ae7..58cb458bdeb 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java +++ b/server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java @@ -55,11 +55,13 @@ public class SystemInfoUtils { } } - public static void setAttribute(Section.Builder section, String key, boolean value) { - section.addAttributesBuilder() - .setKey(key) - .setBooleanValue(value) - .build(); + public static void setAttribute(Section.Builder section, String key, @Nullable Boolean value) { + if (value != null) { + section.addAttributesBuilder() + .setKey(key) + .setBooleanValue(value) + .build(); + } } public static void setAttribute(Section.Builder section, String key, long value) { diff --git a/server/sonar-process/src/test/java/org/sonar/process/systeminfo/SystemInfoUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/systeminfo/SystemInfoUtilsTest.java index 03410f34ea9..f7e3c09ca72 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/systeminfo/SystemInfoUtilsTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/systeminfo/SystemInfoUtilsTest.java @@ -31,6 +31,19 @@ import static org.assertj.core.api.Assertions.assertThat; public class SystemInfoUtilsTest { @Test + public void test_setAttribute_with_boolean_parameter() { + Section.Builder builder = Section.newBuilder(); + SystemInfoUtils.setAttribute(builder, "isNull", (Boolean)null); + SystemInfoUtils.setAttribute(builder, "isTrue", true); + SystemInfoUtils.setAttribute(builder, "isFalse", false); + + Section section = builder.build(); + assertThat(SystemInfoUtils.attribute(section, "isNull")).isNull(); + assertThat(SystemInfoUtils.attribute(section, "isTrue").getBooleanValue()).isTrue(); + assertThat(SystemInfoUtils.attribute(section, "isFalse").getBooleanValue()).isFalse(); + } + + @Test public void test_order() { Collection<Section> sections = asList( newSection("end2"), |