diff options
author | Michal Duda <michal.duda@sonarsource.com> | 2018-12-17 11:54:38 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-01-18 20:21:02 +0100 |
commit | 829f3ccf0c5418d1974efe917c4e5475df4e4141 (patch) | |
tree | 8c9ced0c03084cf797eae88bc5893a864e043dff /sonar-core/src/test | |
parent | b5cc29188339a2bf7187de25be38853553a81482 (diff) | |
download | sonarqube-829f3ccf0c5418d1974efe917c4e5475df4e4141.tar.gz sonarqube-829f3ccf0c5418d1974efe917c4e5475df4e4141.zip |
replace Protobuf.setNullable with Optional.ofNullable
Diffstat (limited to 'sonar-core/src/test')
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/util/ProtobufTest.java | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/util/ProtobufTest.java b/sonar-core/src/test/java/org/sonar/core/util/ProtobufTest.java index d688c80d169..e9b549d65d1 100644 --- a/sonar-core/src/test/java/org/sonar/core/util/ProtobufTest.java +++ b/sonar-core/src/test/java/org/sonar/core/util/ProtobufTest.java @@ -21,7 +21,6 @@ package org.sonar.core.util; import java.io.File; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -31,7 +30,6 @@ import org.sonar.test.TestUtils; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.sonar.core.test.Test.Fake; -import static org.sonar.core.util.Protobuf.setNullable; public class ProtobufTest { @@ -116,33 +114,4 @@ public class ProtobufTest { assertThat(it).isNotNull(); assertThat(it.hasNext()).isFalse(); } - - @Test - public void setNullable_sets_field_if_value_is_not_null() { - Fake.Builder builder = Fake.newBuilder(); - - setNullable("foo", builder::setLabel); - assertThat(builder.getLabel()).isEqualTo("foo"); - - builder.clear(); - setNullable(null, builder::setLabel); - assertThat(builder.hasLabel()).isFalse(); - } - - @Test - public void setNullable_converts_value_and_sets_field_if_value_is_not_null() { - Fake.Builder builder = Fake.newBuilder(); - - setNullable("foo", builder::setLabel, StringUtils::upperCase); - assertThat(builder.getLabel()).isEqualTo("FOO"); - - builder.clear(); - setNullable((String)null, builder::setLabel, StringUtils::upperCase); - assertThat(builder.hasLabel()).isFalse(); - - // do not set field if value is present but result of conversion is null - builder.clear(); - setNullable(" ", builder::setLabel, StringUtils::trimToNull); - assertThat(builder.hasLabel()).isFalse(); - } } |