From e2756fa0a8054854dfaaac1c7fa064d207a0a4ae Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 14 Dec 2020 11:36:50 -0500 Subject: 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 --- .../org/onap/policy/common/utils/coder/StandardYamlCoderTest.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'utils/src/test/java') 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 @@ -96,6 +96,12 @@ public class StandardYamlCoderTest { YamlJsonTranslatorTest.verify(cont); } + @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"; -- cgit 1.2.3-korg