diff options
author | Jim Hahn <jrh3@att.com> | 2020-01-29 17:21:24 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-01-29 17:27:29 -0500 |
commit | 7b420e72cf4b70eae77719f0c958a5ad25e8ce98 (patch) | |
tree | 8f4938c9c161d48a376753be739268e3bbbeb66f /utils/src/test/java | |
parent | 2ce955e7c3c53b16596a18b0f5f68f2b491d1de6 (diff) |
Convert double to int when decoding JSON
When decoding straight into a List or Map class, StandardCoder was not
applying the double-to-int conversion. Fixed it.
Issue-ID: POLICY-1625
Signed-off-by: Jim Hahn <jrh3@att.com>
Change-Id: I939e3378645d45ac98d2bca6b2a4076870a05626
Diffstat (limited to 'utils/src/test/java')
-rw-r--r-- | utils/src/test/java/org/onap/policy/common/utils/coder/StandardCoderTest.java | 16 |
1 files changed, 15 insertions, 1 deletions
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 2a70f85a..43a17dec 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP PAP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,8 +45,10 @@ import java.nio.file.Files; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.TreeMap; import org.junit.Before; import org.junit.Test; @@ -281,6 +283,18 @@ public class StandardCoderTest { assertEquals(-10, map.props.get("negInt")); assertEquals(100000000000L, map.props.get("posLong")); assertEquals(12.5, map.props.get("doubleVal")); + + // test when decoding into a map + @SuppressWarnings("unchecked") + Map<String,Object> map2 = coder.decode("{'intValue':10, 'dblVal':20.1}", TreeMap.class); + assertEquals("{dblVal=20.1, intValue=10}", map2.toString()); + } + + @Test + public void testListDouble() throws Exception { + @SuppressWarnings("unchecked") + List<Object> list = coder.decode("[10, 20.1, 30]", LinkedList.class); + assertEquals("[10, 20.1, 30]", list.toString()); } |