aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/ProtobufJsonFormatTest.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/util/ProtobufJsonFormatTest.java b/sonar-core/src/test/java/org/sonar/core/util/ProtobufJsonFormatTest.java
index ee036208c9e..d81033e5fd8 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/ProtobufJsonFormatTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/ProtobufJsonFormatTest.java
@@ -66,4 +66,18 @@ public class ProtobufJsonFormatTest {
ProtobufJsonFormat.write(protobuf, JsonWriter.of(new StringWriter()));
}
+
+ @Test
+ public void protobuf_empty_strings_are_not_output() throws Exception {
+ org.sonar.core.test.Test.Fake protobuf = org.sonar.core.test.Test.Fake.newBuilder().build();
+
+ // field is not set but value is "", not null
+ assertThat(protobuf.hasAString()).isFalse();
+ assertThat(protobuf.getAString()).isEqualTo("");
+
+ StringWriter json = new StringWriter();
+ JsonWriter jsonWriter = JsonWriter.of(json);
+ ProtobufJsonFormat.write(protobuf, jsonWriter);
+ assertThat(json.toString()).isEqualTo("{}");
+ }
}