aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src/test/java/org/onap/policy/common/utils
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-12-14 11:36:50 -0500
committerJim Hahn <jrh3@att.com>2020-12-14 11:39:55 -0500
commite2756fa0a8054854dfaaac1c7fa064d207a0a4ae (patch)
treed0c6af9a360ee04cda225252b746be653cc6db2d /utils/src/test/java/org/onap/policy/common/utils
parentdd2aef555893e48ca8fcdc0cfb0a54538e49cfad (diff)
Convert YAML Double to Integer/Long
When a YAML number is decoded directly to type Object.class using the decode() or fromJson() methods of the StandardYamlCoder, the number is left as a Double. It should be converted to an Integer or Long, where possible. Issue-ID: POLICY-2900 Change-Id: I7707ac5c54167cbc3a4b23985c6e5fa1a507324e Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'utils/src/test/java/org/onap/policy/common/utils')
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/coder/StandardYamlCoderTest.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/utils/src/test/java/org/onap/policy/common/utils/coder/StandardYamlCoderTest.java b/utils/src/test/java/org/onap/policy/common/utils/coder/StandardYamlCoderTest.java
index c770cd3b..cadeb055 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/coder/StandardYamlCoderTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/coder/StandardYamlCoderTest.java
@@ -97,6 +97,12 @@ public class StandardYamlCoderTest {
}
@Test
+ public void testFromJsonDoubleToInteger() throws Exception {
+ Object value = coder.decode("20", Object.class);
+ assertEquals(Integer.valueOf(20), value);
+ }
+
+ @Test
public void testStandardTypeAdapter() throws Exception {
String yaml = "abc: def\n";
StandardCoderObject sco = coder.fromJson(yaml, StandardCoderObject.class);