aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/common/src
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2023-03-14 12:21:18 +0530
committerRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2023-03-14 12:33:28 +0530
commitc46e67188dc3e315ca6070120fbd11be51d58080 (patch)
tree6fe0a11799006f0d69cab197ecebac45f1b65a25 /sdnr/wt/common/src
parentc82a57b8b435543aa27261df1b272af3892307ba (diff)
javax to jakarta and refactoring
change log level from INFO to DEBUG and Java17 changes Issue-ID: CCSDK-3864 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: I60247aeea3d8daa70c8e17af8cbf694b86dd6946 Signed-off-by: Ravi Pendurty <ravi.pendurty@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.java46
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java2
2 files changed, 26 insertions, 22 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 b207c3e00..060699cc0 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
@@ -21,6 +21,7 @@
*/
package org.onap.ccsdk.features.sdnr.wt.common.test;
+import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import org.json.JSONArray;
@@ -45,6 +46,7 @@ public class JSONAssert {
int x = this.test(o1.get(key), o2.get(key));
if (x != 0) {
return x;
+ } else {
}
}
return 0;
@@ -53,8 +55,8 @@ public class JSONAssert {
private int test(Object o1, Object o2) {
int x;
if ((o1 instanceof Double) && (o2 instanceof Double)) {
-
- return (((Double) o1).doubleValue() - ((Double) o2).doubleValue()) < 0 ? -1 : 1;
+ double delta = (((Double) o1).doubleValue() - ((Double) o2).doubleValue());
+ return delta == 0.0 ? 0 : delta < 0 ? -1 : 1;
} else if ((o1 instanceof Boolean) && (o2 instanceof Boolean)) {
return ((Boolean) o1).booleanValue() == ((Boolean) o2).booleanValue() ? 0 : -1;
@@ -183,50 +185,52 @@ public class JSONAssert {
public static void assertContainsOnlyKey(JSONObject o, String key) {
- if(o==null) {
+ if (o == null) {
throw new AssertionError("object is null");
}
- if(key==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");
+ Object[] keys = o.keySet().toArray();
+ if (keys.length > 1) {
+ throw new AssertionError("more than one key found: " + Arrays.toString(keys));
}
- if(keys.length==0) {
+ if (keys.length == 0) {
throw new AssertionError("no key found");
}
- if(!key.equals(keys[0])) {
- throw new AssertionError("different key found "+key+" <=> "+ keys[0]);
+ 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) {
+ if (o == null) {
throw new AssertionError("object is null");
}
- if(keys==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");
+ Object[] okeys = o.keySet().toArray();
+ if (okeys.length != keys.length) {
+ throw new AssertionError(
+ "found different amount of keys: " + Arrays.toString(okeys) + " expected:" + Arrays.toString(keys));
}
- for(String k:keys) {
- if(!o.keySet().contains(k)) {
- throw new AssertionError("key "+ k+ " not found");
+ 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) {
+ if (o == null) {
throw new AssertionError("object is null");
}
- Object[] okeys= o.keySet().toArray();
- if(okeys.length!=0) {
+ Object[] okeys = o.keySet().toArray();
+ if (okeys.length != 0) {
throw new AssertionError("found keys");
}
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java
index c6bd16484..4fb4a00c1 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/threading/KeyBasedThreadpool.java
@@ -91,7 +91,7 @@ public class KeyBasedThreadpool<T, S> implements GenericRunnableFactoryCallback<
LOG.debug("key pool size reached. waiting for someone else to stop");
}
} else {
- LOG.info("nothing to execute. queue is empty.");
+ LOG.debug("nothing to execute. queue is empty.");
}
}