From 37f4fef730a59fd5230b90e60039b05ed5e4d88b Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 17 Jul 2019 12:05:34 -0400 Subject: Convert double to int when decoding via gson Refactored MapDoubleAdapterFactory, extracting DoubleConverter to be used by code needing to convert Double to Integer/Long after being decoded by GSON. Enhanced StandardCoder to automatically use the above converter if the desired class is a generic Object. Change-Id: I1d4e83910de41ceda383f257bfea706db2b8fbbe Issue-ID: POLICY-1919 Signed-off-by: Jim Hahn --- .../org/onap/policy/common/utils/coder/StandardCoderTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'utils/src/test/java/org/onap') diff --git a/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java b/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java index e8e3bb60..2992933f 100644 --- a/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java +++ b/utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java @@ -200,6 +200,15 @@ public class StandardCoderTest { .hasCause(ioe); } + @Test + public void testConvertFromDouble() throws Exception { + String text = "[listA, {keyA=100}, 200]"; + assertEquals(text, coder.decode(text, Object.class).toString()); + + text = "{keyB=200}"; + assertEquals(text, coder.decode(text, Object.class).toString()); + } + @Test public void testToStandard() throws Exception { MyObject obj = new MyObject(); -- cgit 1.2.3-korg