diff options
author | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2020-08-31 10:36:42 +0200 |
---|---|---|
committer | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2020-08-31 13:27:38 +0200 |
commit | 4cd4c471e9b56494b7ae1e4917e88fa9513082b9 (patch) | |
tree | 779311a2a203d89c54468fefeb7d56b786d55471 /sdnr/wt/common/src | |
parent | 4bd84bebdaa0c2d82050fbedd1fa8260eb62146d (diff) |
add data-provider v2 for openroadm
extend db service for writing data for v2
Issue-ID: CCSDK-2582
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Change-Id: Ib47919a7f45a4954cd76514097a0b073c605fec3
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/common/src')
-rw-r--r-- | sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java index f95dfe0b2..8b651cbe9 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java @@ -60,7 +60,7 @@ public class JSONAssert { } else if ((o1 instanceof String) && (o2 instanceof String)) { - return ((String) o1).equals(((String) o2)) ? 0 : -1; + return ((String) o1).equals((o2)) ? 0 : -1; } else if ((o1 instanceof JSONObject) && (o2 instanceof JSONObject)) { if (((JSONObject) o1).length() != ((JSONObject) o2).length()) { return ((JSONObject) o1).length() - ((JSONObject) o2).length() < 0 ? -1 : 1; @@ -137,7 +137,7 @@ public class JSONAssert { } else if ((o1 instanceof String) && (o2 instanceof String)) { - return ((String) o1).equals(((String) o2)) ? 0 : -1; + return ((String) o1).equals((o2)) ? 0 : -1; } else if ((o1 instanceof JSONObject) && (o2 instanceof JSONObject)) { if (((JSONObject) o1).length() == 0 && ((JSONObject) o2).length() == 0) { return 0; @@ -181,6 +181,56 @@ public class JSONAssert { } } + + public static void assertContainsOnlyKey(JSONObject o, String key) { + if(o==null) { + throw new AssertionError("object is null"); + } + if(key==null) { + throw new AssertionError("key is null"); + } + + Object[] keys= o.keySet().toArray(); + if(keys.length>1) { + throw new AssertionError("more than one key found"); + } + if(keys.length==0) { + throw new AssertionError("no key found"); + } + if(!key.equals(keys[0])) { + throw new AssertionError("different key found "+key+" <=> "+ keys[0]); + } + } + + + public static void assertContainsExactKeys(JSONObject o, String[] keys) { + if(o==null) { + throw new AssertionError("object is null"); + } + if(keys==null) { + throw new AssertionError("keys is null"); + } + Object[] okeys= o.keySet().toArray(); + if(okeys.length!=keys.length) { + throw new AssertionError("found different amount of keys"); + } + for(String k:keys) { + if(!o.keySet().contains(k)) { + throw new AssertionError("key "+ k+ " not found"); + } + } + } + public static void assertContainsNoKeys(JSONObject o) { + if(o==null) { + throw new AssertionError("object is null"); + } + + Object[] okeys= o.keySet().toArray(); + if(okeys.length!=0) { + throw new AssertionError("found keys"); + } + } + private static void assertEqualsNonStrict(String message, String def, String toTest) throws JSONException { JSONObject d1 = new JSONObject(def); @@ -188,6 +238,7 @@ public class JSONAssert { if (nonStrictComarator.compare(d1, d2) != 0) { throw new AssertionError(message); } + } private static void assertEqualsStrict(String message, String def, String toTest) throws JSONException { @@ -198,4 +249,6 @@ public class JSONAssert { } } + + } |