diff options
author | Jim Hahn <jrh3@att.com> | 2020-12-14 11:36:50 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-12-14 11:39:55 -0500 |
commit | e2756fa0a8054854dfaaac1c7fa064d207a0a4ae (patch) | |
tree | d0c6af9a360ee04cda225252b746be653cc6db2d /utils/src/test | |
parent | dd2aef555893e48ca8fcdc0cfb0a54538e49cfad (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')
-rw-r--r-- | utils/src/test/java/org/onap/policy/common/utils/coder/StandardYamlCoderTest.java | 6 |
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); |