summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-11-10 09:21:49 +0000
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-11-10 09:31:12 +0000
commit5eb0e49534114edf8a76fef5b2a8e50c7bdaa812 (patch)
treeb69c0e5d60fc48dd0c8084dfffb178b89566b83f
parent8b504f6db32630ae4b6774efabc87ed76a950053 (diff)
Replace deprecated methods in aai-common
Issue-ID: AAI-3589 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: I9e32b879ee0d143a6b66e06d425bed7412139e58
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java17
-rw-r--r--aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java7
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/Introspector.java15
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java11
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java11
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java16
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/SimpleFormat.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java12
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/RestController.java10
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java5
-rw-r--r--aai-core/src/test/java/org/onap/aai/HttpTestUtil.java24
-rw-r--r--aai-core/src/test/java/org/onap/aai/PayloadUtil.java7
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java42
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java26
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/db/ImpliedDeleteUnitTest.java4
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java12
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java4
-rw-r--r--aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/UrlBuilderTest.java2
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java2
-rw-r--r--aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java3
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java5
30 files changed, 165 insertions, 110 deletions
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java
index f591125c..72e2295e 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java
@@ -31,7 +31,19 @@ import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Paths;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -144,8 +156,7 @@ public final class AAIAuthCore {
LOGGER.debug("Reading from " + globalAuthFileName);
String authFile = new String(Files.readAllBytes(Paths.get(globalAuthFileName)));
- JsonParser parser = new JsonParser();
- JsonObject authObject = parser.parse(authFile).getAsJsonObject();
+ JsonObject authObject = JsonParser.parseString(authFile).getAsJsonObject();
if (authObject.has("roles")) {
JsonArray roles = authObject.getAsJsonArray("roles");
for (JsonElement role : roles) {
diff --git a/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java b/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java
index 612273d4..01e42f3d 100644
--- a/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java
+++ b/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java
@@ -63,7 +63,7 @@ public class ExtensionController {
Method extension = clazz.getMethod(methodName, new Class[] {AAIExtensionMap.class});
if (extension != null) {
- Object ret = extension.invoke(clazz.newInstance(), aaiExtMap);
+ Object ret = extension.invoke(clazz.getDeclaredConstructor().newInstance(), aaiExtMap);
if (ret instanceof Integer) {
Exception e = null;
@@ -101,11 +101,12 @@ public class ExtensionController {
}
if (errorCallback != null) {
- errorCallback.invoke(clazz.newInstance(), aaiExtMap);
+ errorCallback.invoke(clazz.getDeclaredConstructor().newInstance(), aaiExtMap);
} else {
Method defaultErrorCallbackExtension =
clazz.getMethod(defaultErrorCallback, new Class[] {AAIExtensionMap.class});
- defaultErrorCallbackExtension.invoke(clazz.newInstance(), aaiExtMap);
+ defaultErrorCallbackExtension.invoke(clazz.getDeclaredConstructor().newInstance(),
+ aaiExtMap);
}
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java b/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java
index c9e1f455..87983d8d 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java
@@ -103,9 +103,10 @@ public abstract class Introspector implements Cloneable {
Class<?> clazz = this.getClass(name);
if (this.isListType(name) && result == null) {
try {
- this.set(convertedName, clazz.newInstance());
+ this.set(convertedName, clazz.getDeclaredConstructor().newInstance());
result = this.get(convertedName);
- } catch (DynamicException | InstantiationException | IllegalAccessException e) {
+ } catch (DynamicException | InstantiationException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException | NoSuchMethodException | SecurityException e) {
LOGGER.warn(e.getMessage(), e);
}
}
@@ -127,9 +128,10 @@ public abstract class Introspector implements Cloneable {
Class<?> clazz = this.getClass(name);
if (this.isListType(name) && value == null) {
try {
- this.set(convertedName, clazz.newInstance());
+ this.set(convertedName, clazz.getDeclaredConstructor().newInstance());
value = this.get(convertedName);
- } catch (DynamicException | InstantiationException | IllegalAccessException e) {
+ } catch (DynamicException | InstantiationException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException | NoSuchMethodException | SecurityException e) {
LOGGER.warn(e.getMessage(), e);
}
}
@@ -159,9 +161,10 @@ public abstract class Introspector implements Cloneable {
Class<?> clazz = this.getClass(name);
if (isListType && value == null) {
try {
- this.set(convertedName, clazz.newInstance());
+ this.set(convertedName, clazz.getDeclaredConstructor().newInstance());
value = this.get(convertedName);
- } catch (DynamicException | InstantiationException | IllegalAccessException e) {
+ } catch (DynamicException | InstantiationException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException | NoSuchMethodException | SecurityException e) {
LOGGER.warn(e.getMessage(), e);
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java b/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java
index 40352360..2676d19d 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java
@@ -21,6 +21,7 @@
package org.onap.aai.introspection;
import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -159,8 +160,9 @@ public class JSONStrategy extends Introspector {
@Override
public Object newInstanceOfProperty(String name) {
try {
- return this.getClass(name).newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
+ return this.getClass(name).getDeclaredConstructor().newInstance();
+ } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
+ | NoSuchMethodException | SecurityException e) {
return null;
}
}
@@ -168,8 +170,9 @@ public class JSONStrategy extends Introspector {
@Override
public Object newInstanceOfNestedProperty(String name) {
try {
- return this.getGenericTypeClass(name).newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
+ return this.getGenericTypeClass(name).getDeclaredConstructor().newInstance();
+ } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
+ | NoSuchMethodException | SecurityException e) {
return null;
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java
index 2517e2c0..187db197 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java
@@ -23,7 +23,12 @@ package org.onap.aai.query.builder;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.Path;
@@ -288,7 +293,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
if (val != null) {
// this is because the index is registered as an Integer
if (val.getClass().equals(Long.class)) {
- this.vertexHas(key, new Integer(val.toString()));
+ this.vertexHas(key, Integer.valueOf(val.toString()));
} else {
this.vertexHas(key, val);
}
@@ -321,7 +326,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
}
// this is because the index is registered as an Integer
if (val.getClass().equals(Long.class)) {
- this.vertexHas(prop, new Integer(val.toString()));
+ this.vertexHas(prop, Integer.valueOf(val.toString()));
} else {
this.vertexHas(prop, val);
}
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java
index 423583f4..2bc90726 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java
@@ -634,7 +634,7 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
protected Object correctObjectType(Object obj) {
if (obj != null && obj.getClass().equals(Long.class)) {
- return new Integer(obj.toString());
+ return Integer.valueOf(obj.toString());
}
return obj;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
index dc478337..9f599eb9 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
@@ -575,7 +575,7 @@ public class DBSerializer {
if (value != null) {
if (!value.equals(oldValue)) {
if (propertyType.toLowerCase().contains(".long")) {
- v.property(dbProperty, new Integer(((Long) value).toString()));
+ v.property(dbProperty, Integer.valueOf(((Long) value).toString()));
} else {
v.property(dbProperty, value);
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java
index 28362826..3706da0d 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java
@@ -20,10 +20,19 @@
package org.onap.aai.serialization.queryformats;
-import com.google.gson.*;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import java.io.UnsupportedEncodingException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -47,7 +56,6 @@ import org.slf4j.LoggerFactory;
public class Aggregate extends MultiFormatMapper {
private static final Logger LOGGER = LoggerFactory.getLogger(LifecycleFormat.class);
- protected JsonParser parser = new JsonParser();
protected final DBSerializer serializer;
protected final Loader loader;
protected final UrlBuilder urlBuilder;
@@ -99,7 +107,7 @@ public class Aggregate extends MultiFormatMapper {
}
final String json = obj.marshal(false);
- return Optional.of(parser.parse(json).getAsJsonObject());
+ return Optional.of(JsonParser.parseString(json).getAsJsonObject());
} catch (AAIUnknownObjectException e) {
return Optional.empty();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java
index fc3316d4..e03620ba 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java
@@ -50,7 +50,6 @@ public class GraphSON implements FormatMapper {
private final GraphSONMapper mapper =
GraphSONMapper.build().addRegistry(JanusGraphIoRegistry.getInstance()).create();
private final GraphSONWriter writer = GraphSONWriter.build().mapper(mapper).create();
- protected JsonParser parser = new JsonParser();
@Override
public Optional<JsonObject> formatObject(Object v) {
@@ -64,7 +63,7 @@ public class GraphSON implements FormatMapper {
logger.debug("GraphSON writeVertex error : {}", e.getMessage());
}
- JsonObject jsonObject = parser.parse(result).getAsJsonObject();
+ JsonObject jsonObject = JsonParser.parseString(result).getAsJsonObject();
if (jsonObject != null) {
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java
index fccc17c6..4443ade8 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java
@@ -23,7 +23,6 @@ package org.onap.aai.serialization.queryformats;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
import java.util.Iterator;
import java.util.List;
@@ -31,7 +30,11 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.apache.tinkerpop.gremlin.structure.*;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.introspection.Loader;
import org.onap.aai.serialization.db.DBSerializer;
@@ -61,7 +64,6 @@ public abstract class HistoryFormat extends MultiFormatMapper {
protected static final String RELATED_TO = "related-to";
protected static final String NODE_ACTIONS = "node-actions";
- protected JsonParser parser = new JsonParser();
protected final DBSerializer serializer;
protected final Loader loader;
protected final UrlBuilder urlBuilder;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java
index 10bba7f6..b9ba00eb 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java
@@ -45,18 +45,15 @@ import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
public class IdURL extends MultiFormatMapper {
private final UrlBuilder urlBuilder;
- private final JsonParser parser;
private final Loader loader;
public IdURL(Loader loader, UrlBuilder urlBuilder) throws AAIException {
this.urlBuilder = urlBuilder;
- this.parser = new JsonParser();
this.loader = loader;
}
public IdURL(Builder builder) throws AAIException {
this.urlBuilder = builder.getUrlBuilder();
- this.parser = new JsonParser();
this.loader = builder.getLoader();
this.isTree = builder.isTree();
}
@@ -77,7 +74,7 @@ public class IdURL extends MultiFormatMapper {
final String json = searchResult.marshal(false);
- return Optional.of(parser.parse(json).getAsJsonObject());
+ return Optional.of(JsonParser.parseString(json).getAsJsonObject());
} catch (AAIUnknownObjectException e) {
throw new RuntimeException("Fatal error - result-data object does not exist!");
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java
index f052f778..0331925c 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java
@@ -45,19 +45,16 @@ import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
public final class PathedURL extends MultiFormatMapper {
private final UrlBuilder urlBuilder;
- private final JsonParser parser;
private final Loader loader;
private boolean includeUrl = false;
public PathedURL(Loader loader, UrlBuilder urlBuilder) throws AAIException {
this.urlBuilder = urlBuilder;
- this.parser = new JsonParser();
this.loader = loader;
}
public PathedURL(Builder builder) {
this.urlBuilder = builder.getUrlBuilder();
- this.parser = new JsonParser();
this.loader = builder.getLoader();
this.isTree = builder.isTree();
this.includeUrl = builder.isIncludeUrl();
@@ -82,7 +79,7 @@ public final class PathedURL extends MultiFormatMapper {
searchResult.setValue("resource-version", v.value(AAIProperties.RESOURCE_VERSION));
final String json = searchResult.marshal(false);
- return Optional.of(this.parser.parse(json).getAsJsonObject());
+ return Optional.of(JsonParser.parseString(json).getAsJsonObject());
} catch (AAIUnknownObjectException e) {
throw new RuntimeException("Fatal error - result-data does not exist!", e);
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java
index bd858f4b..fe47a579 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java
@@ -23,7 +23,6 @@ package org.onap.aai.serialization.queryformats;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
import java.util.Collections;
import java.util.Iterator;
@@ -47,7 +46,6 @@ import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
public class RawFormat extends MultiFormatMapper {
- protected JsonParser parser = new JsonParser();
protected final DBSerializer serializer;
protected final Loader loader;
protected final UrlBuilder urlBuilder;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java
index f4fd921f..1a69bed3 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java
@@ -56,7 +56,6 @@ public class Resource extends MultiFormatMapper {
private final Loader loader;
private final DBSerializer serializer;
- private final JsonParser parser;
private final UrlBuilder urlBuilder;
private final boolean includeUrl;
private final boolean nodesOnly;
@@ -64,7 +63,6 @@ public class Resource extends MultiFormatMapper {
private final boolean isSkipRelatedTo;
public Resource(Builder builder) {
- this.parser = new JsonParser();
this.loader = builder.getLoader();
this.serializer = builder.getSerializer();
this.urlBuilder = builder.getUrlBuilder();
@@ -190,7 +188,7 @@ public class Resource extends MultiFormatMapper {
final String json = obj.marshal(false);
- return Optional.of(getParser().parse(json).getAsJsonObject());
+ return Optional.of(JsonParser.parseString(json).getAsJsonObject());
} catch (AAIUnknownObjectException e) {
return Optional.empty();
}
@@ -209,10 +207,6 @@ public class Resource extends MultiFormatMapper {
return serializer;
}
- private JsonParser getParser() {
- return parser;
- }
-
public static class Builder implements NodesOnly<Builder>, Depth<Builder>, AsTree<Builder> {
private final Loader loader;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java
index 076f665d..e81f6037 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java
@@ -21,7 +21,6 @@
package org.onap.aai.serialization.queryformats;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
import java.util.List;
import java.util.Map;
@@ -39,7 +38,6 @@ import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
import org.onap.aai.util.AAIConfig;
public class ResourceWithSoT extends MultiFormatMapper {
- protected JsonParser parser = new JsonParser();
protected final DBSerializer serializer;
protected final Loader loader;
protected final UrlBuilder urlBuilder;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/SimpleFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/SimpleFormat.java
index f1d1c26e..657dd89b 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/SimpleFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/SimpleFormat.java
@@ -22,6 +22,7 @@ package org.onap.aai.serialization.queryformats;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
@@ -67,7 +68,7 @@ public class SimpleFormat extends RawFormat {
}
final String json = obj.marshal(false);
- return Optional.of(parser.parse(json).getAsJsonObject());
+ return Optional.of(JsonParser.parseString(json).getAsJsonObject());
} catch (AAIUnknownObjectException e) {
return Optional.empty();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java
index 2e1cbf6e..4b8229fa 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java
@@ -28,8 +28,11 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.UnsupportedEncodingException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
@@ -49,7 +52,6 @@ import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
public class TreeFormat extends MultiFormatMapper {
private static final EELFLogger TREE_FORMAT_LOGGER = EELFManager.getInstance().getLogger(TreeFormat.class);
- protected JsonParser parser = new JsonParser();
protected final DBSerializer serializer;
protected final Loader loader;
protected final UrlBuilder urlBuilder;
@@ -312,7 +314,7 @@ public class TreeFormat extends MultiFormatMapper {
final String json = obj.marshal(false);
- return Optional.of(getParser().parse(json).getAsJsonObject());
+ return Optional.of(JsonParser.parseString(json).getAsJsonObject());
} catch (AAIUnknownObjectException e) {
return Optional.empty();
}
@@ -326,10 +328,6 @@ public class TreeFormat extends MultiFormatMapper {
return serializer;
}
- private JsonParser getParser() {
- return parser;
- }
-
@Override
protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
throws AAIFormatVertexException {
diff --git a/aai-core/src/main/java/org/onap/aai/util/RestController.java b/aai-core/src/main/java/org/onap/aai/util/RestController.java
index 6c57040d..379b31f3 100644
--- a/aai-core/src/main/java/org/onap/aai/util/RestController.java
+++ b/aai-core/src/main/java/org/onap/aai/util/RestController.java
@@ -27,6 +27,7 @@ import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientResponse;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
@@ -480,9 +481,14 @@ public class RestController implements RestControllerInterface {
* @return single instance of RestController
* @throws IllegalAccessException the illegal access exception
* @throws InstantiationException the instantiation exception
+ * @throws SecurityException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ * @throws IllegalArgumentException
*/
- public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException {
- return clazz.newInstance();
+ public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException,
+ IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ return clazz.getDeclaredConstructor().newInstance();
}
/**
diff --git a/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java b/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java
index 3304e9a5..6d20a010 100644
--- a/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java
+++ b/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java
@@ -20,6 +20,8 @@
package org.onap.aai.util;
+import java.lang.reflect.InvocationTargetException;
+
import org.onap.aai.exceptions.AAIException;
public interface RestControllerInterface {
@@ -38,7 +40,8 @@ public interface RestControllerInterface {
public void Delete(String sourceID, String transId, String path) throws AAIException;
- public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException;
+ public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException,
+ IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException;
public <T> T DoesResourceExist(String resourcePath, String resourceClassName, String fromAppId, String transId);
}
diff --git a/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java b/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
index 9d406eb2..07764ecc 100644
--- a/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
+++ b/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java
@@ -20,14 +20,26 @@
package org.onap.aai;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.when;
import java.io.UnsupportedEncodingException;
import java.net.URI;
-import java.util.*;
-
-import javax.ws.rs.core.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
import org.javatuples.Pair;
import org.mockito.Mockito;
@@ -139,7 +151,7 @@ public class HttpTestUtil extends RESTAPI {
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
- doReturn(null).when(queryParameters).remove(anyObject());
+ doReturn(null).when(queryParameters).remove(any());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
try {
diff --git a/aai-core/src/test/java/org/onap/aai/PayloadUtil.java b/aai-core/src/test/java/org/onap/aai/PayloadUtil.java
index 7ee6c39c..d9448989 100644
--- a/aai-core/src/test/java/org/onap/aai/PayloadUtil.java
+++ b/aai-core/src/test/java/org/onap/aai/PayloadUtil.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
@@ -44,7 +45,7 @@ public class PayloadUtil {
String message = String.format("Unable to find the %s in src/test/resources", fileName);
assertNotNull(message, inputStream);
- String resource = IOUtils.toString(inputStream);
+ String resource = IOUtils.toString(inputStream, Charset.defaultCharset());
inputStream.close();
return resource;
@@ -58,7 +59,7 @@ public class PayloadUtil {
String message = String.format("Unable to find the %s in src/test/resources", fileName);
assertNotNull(message, inputStream);
- String resource = IOUtils.toString(inputStream);
+ String resource = IOUtils.toString(inputStream, Charset.defaultCharset());
inputStream.close();
return resource;
@@ -77,7 +78,7 @@ public class PayloadUtil {
if (cache.containsKey(fileName)) {
resource = cache.get(fileName);
} else {
- resource = IOUtils.toString(inputStream);
+ resource = IOUtils.toString(inputStream, Charset.defaultCharset());
cache.put(fileName, resource);
}
diff --git a/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java b/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java
index cafca63f..399ef7e0 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java
@@ -20,7 +20,9 @@
package org.onap.aai.rest;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.junit.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
@@ -29,7 +31,11 @@ import com.google.gson.JsonParser;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import javax.ws.rs.core.Response;
@@ -848,11 +854,11 @@ public class NotificationDmaapEventTest extends AAISetup {
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle);
- JsonObject paylaods = new JsonParser().parse(PayloadUtil.getResourcePayload(
- "customer_with_children_and_generic-vnf_with_children_and_edge_between_service-instance_vlan.json"))
- .getAsJsonObject();
- String gvnfPaylaod = paylaods.get("generic-vnf").toString();
- String custPaylaod = paylaods.get("customer").toString();
+ String json = PayloadUtil.getResourcePayload(
+ "customer_with_children_and_generic-vnf_with_children_and_edge_between_service-instance_vlan.json");
+ JsonObject payloads = JsonParser.parseString(json).getAsJsonObject();
+ String gvnfPaylaod = payloads.get("generic-vnf").toString();
+ String custPaylaod = payloads.get("customer").toString();
String gvnfUri = "/aai/v14/network/generic-vnfs/generic-vnf/gvnf";
String custUri = "/aai/v14/business/customers/customer/cust";
String vlanUri = "/aai/v14/network/generic-vnfs/generic-vnf/gvnf/l-interfaces/l-interface/lint/vlans/vlan/vlan";
@@ -909,10 +915,10 @@ public class NotificationDmaapEventTest extends AAISetup {
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MAXIMUM_DEPTH);
- JsonObject paylaods = new JsonParser()
- .parse(PayloadUtil.getResourcePayload("complex_pserver_with_relation.json")).getAsJsonObject();
- String complexPaylaod = paylaods.get("complex").toString();
- String pserverPaylaod = paylaods.get("pserver").toString();
+ JsonObject payloads = JsonParser
+ .parseString(PayloadUtil.getResourcePayload("complex_pserver_with_relation.json")).getAsJsonObject();
+ String complexPaylaod = payloads.get("complex").toString();
+ String pserverPaylaod = payloads.get("pserver").toString();
String complexUri = "/aai/v14/cloud-infrastructure/complexes/complex/complex-1";
String pserverUri = "/aai/v14/cloud-infrastructure/pservers/pserver/pserver-1";
@@ -955,11 +961,11 @@ public class NotificationDmaapEventTest extends AAISetup {
UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions));
HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle);
- JsonObject paylaods = new JsonParser().parse(PayloadUtil.getResourcePayload(
- "customer_with_children_and_generic-vnf_with_children_and_edge_between_service-instance_vlan.json"))
- .getAsJsonObject();
- String gvnfPaylaod = paylaods.get("generic-vnf").toString();
- String custPaylaod = paylaods.get("customer").toString();
+ String json = PayloadUtil.getResourcePayload(
+ "customer_with_children_and_generic-vnf_with_children_and_edge_between_service-instance_vlan.json");
+ JsonObject payloads = JsonParser.parseString(json).getAsJsonObject();
+ String gvnfPayload = payloads.get("generic-vnf").toString();
+ String custPayload = payloads.get("customer").toString();
String custUri = "/aai/v14/business/customers/customer/cust";
String ssUri = custUri + "/service-subscriptions/service-subscription/ss";
String siUri = ssUri + "/service-instances/service-instance/si";
@@ -970,7 +976,7 @@ public class NotificationDmaapEventTest extends AAISetup {
// Setup generic vnf
Response response = httpTestUtil.doGet(gvnfUri);
assertEquals("Expecting the generic-vnf to be not found", 404, response.getStatus());
- response = httpTestUtil.doPut(gvnfUri, gvnfPaylaod);
+ response = httpTestUtil.doPut(gvnfUri, gvnfPayload);
assertEquals("Expecting the generic-vnf to be created", 201, response.getStatus());
response = httpTestUtil.doGet(gvnfUri, "all");
assertEquals("Expecting the generic-vnf to be found", 200, response.getStatus());
@@ -981,7 +987,7 @@ public class NotificationDmaapEventTest extends AAISetup {
// Setup customer with service instance relation to vlan
response = httpTestUtil.doGet(custUri);
assertEquals("Expecting the customer to be not found", 404, response.getStatus());
- response = httpTestUtil.doPut(custUri, custPaylaod);
+ response = httpTestUtil.doPut(custUri, custPayload);
assertEquals("Expecting the customer to be created", 201, response.getStatus());
response = httpTestUtil.doGet(custUri, "all");
assertEquals("Expecting the customer to be found", 200, response.getStatus());
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
index 1462485d..2499defc 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
@@ -24,7 +24,7 @@ import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
@@ -33,9 +33,21 @@ import com.google.gson.JsonParser;
import java.io.UnsupportedEncodingException;
import java.net.URI;
-import java.util.*;
-
-import javax.ws.rs.core.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
import org.javatuples.Pair;
import org.json.JSONArray;
@@ -127,7 +139,7 @@ public class HttpEntryTest extends AAISetup {
when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
// TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+ Mockito.doReturn(null).when(queryParameters).remove(any());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
}
@@ -276,7 +288,7 @@ public class HttpEntryTest extends AAISetup {
Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
dbEngine.commit();
String msg = response.getEntity().toString();
- JsonObject jsonObj = new JsonParser().parse(msg).getAsJsonObject();
+ JsonObject jsonObj = JsonParser.parseString(msg).getAsJsonObject();
String resourceVersion = "";
if (jsonObj.isJsonObject()) {
resourceVersion = jsonObj.get("resource-version").getAsString();
@@ -298,7 +310,7 @@ public class HttpEntryTest extends AAISetup {
Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, content);
dbEngine.commit();
String msg = response.getEntity().toString();
- JsonObject jsonObj = new JsonParser().parse(msg).getAsJsonObject();
+ JsonObject jsonObj = JsonParser.parseString(msg).getAsJsonObject();
String resourceVersion = "";
if (jsonObj.isJsonObject()) {
resourceVersion = jsonObj.get("resource-version").getAsString();
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/ImpliedDeleteUnitTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/ImpliedDeleteUnitTest.java
index 44f89746..27f52d1b 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/db/ImpliedDeleteUnitTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/db/ImpliedDeleteUnitTest.java
@@ -198,7 +198,7 @@ public class ImpliedDeleteUnitTest {
Mockito.when(mockQueryEngine.findDeletable(Mockito.anyList())).thenReturn(vertices);
- Mockito.when(mockSerializer.getLatestVersionView(Mockito.anyObject())).thenReturn(mockIntrospector);
+ Mockito.when(mockSerializer.getLatestVersionView(Mockito.any())).thenReturn(mockIntrospector);
Mockito.when(mockIntrospector.marshal(false)).thenReturn("{\"volume-id\":\"volume-1\"}")
.thenReturn("{\"volume-id\":\"volume-2\"}").thenReturn("{\"volume-id\":\"volume-3\"}")
@@ -284,7 +284,7 @@ public class ImpliedDeleteUnitTest {
Mockito.when(mockQueryEngine.findDeletable(Mockito.anyList())).thenReturn(vertices);
- Mockito.when(mockSerializer.getLatestVersionView(Mockito.anyObject()))
+ Mockito.when(mockSerializer.getLatestVersionView(Mockito.any()))
.thenThrow(new RuntimeException("Unable to find node"));
impliedDelete.execute(vserver.id(), "SDNC", "vserver", vertices);
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java
index 1bfdf9c4..09a1d1b4 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/MultiFormatTest.java
@@ -22,7 +22,9 @@ package org.onap.aai.serialization.queryformats;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
@@ -75,16 +77,16 @@ public class MultiFormatTest extends AAISetup {
private Tree<?> resultTree;
private Path resultPath;
private SchemaVersion version;
- private JsonObject expectedTreeIdFormat = new JsonParser().parse(
+ private JsonObject expectedTreeIdFormat = JsonParser.parseString(
"{\"nodes\":[{\"resource-type\":\"generic-vnf\",\"nodes\":[{\"resource-type\":\"vserver\",\"nodes\":[{\"resource-type\":\"pserver\"}]},{\"resource-type\":\"pserver\",\"nodes\":[{\"resource-type\":\"complex\"}]}]}]}")
.getAsJsonObject();
- private JsonObject expectedPathIdFormat = new JsonParser().parse(
+ private JsonObject expectedPathIdFormat = JsonParser.parseString(
"{\"path\":[{\"resource-type\":\"generic-vnf\"},{\"resource-type\":\"vserver\"},{\"resource-type\":\"pserver\"},{\"resource-type\":\"complex\"}]}")
.getAsJsonObject();
- private JsonObject expectedAsTreeWithResourceFormat = new JsonParser().parse(
+ private JsonObject expectedAsTreeWithResourceFormat = JsonParser.parseString(
"{\"results\":[{\"generic-vnf\":{\"vnf-id\":\"vnf-id-1\",\"vnf-name\":\"vnf-name-1\",\"related-nodes\":[{\"vserver\":{\"vserver-id\":\"vserver-id-1\",\"vserver-name\":\"vserver-name-1\",\"related-nodes\":[{\"pserver\":{\"hostname\":\"hostname-1\"}}]}},{\"pserver\":{\"hostname\":\"hostname-2\",\"related-nodes\":[{\"complex\":{\"physical-location-id\":\"physical-location-id-2\",\"country\":\"US\"}}]}}]}}]}")
.getAsJsonObject();
- private JsonObject expectedAsTreeWithSimpleFormat = new JsonParser().parse(
+ private JsonObject expectedAsTreeWithSimpleFormat = JsonParser.parseString(
"{\"results\":[{\"id\":\"0\",\"node-type\":\"generic-vnf\",\"url\":null,\"properties\":{\"vnf-id\":\"vnf-id-1\",\"vnf-name\":\"vnf-name-1\"},\"related-to\":[{\"id\":\"1\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"vserver\",\"url\":null},{\"id\":\"5\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"pserver\",\"url\":null}],\"related-nodes\":[{\"id\":\"1\",\"node-type\":\"vserver\",\"url\":null,\"properties\":{\"vserver-id\":\"vserver-id-1\",\"vserver-name\":\"vserver-name-1\"},\"related-to\":[{\"id\":\"0\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"generic-vnf\",\"url\":null},{\"id\":\"2\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"pserver\",\"url\":null}],\"related-nodes\":[{\"id\":\"2\",\"node-type\":\"pserver\",\"url\":null,\"properties\":{\"hostname\":\"hostname-1\"},\"related-to\":[{\"id\":\"1\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"vserver\",\"url\":null},{\"id\":\"3\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"node-type\":\"complex\",\"url\":null}]}]},{\"id\":\"5\",\"node-type\":\"pserver\",\"url\":null,\"properties\":{\"hostname\":\"hostname-2\"},\"related-to\":[{\"id\":\"0\",\"relationship-label\":\"tosca.relationships.HostedOn\",\"node-type\":\"generic-vnf\",\"url\":null},{\"id\":\"6\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"node-type\":\"complex\",\"url\":null}],\"related-nodes\":[{\"id\":\"6\",\"node-type\":\"complex\",\"url\":null,\"properties\":{\"physical-location-id\":\"physical-location-id-2\",\"country\":\"US\"},\"related-to\":[{\"id\":\"5\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\",\"node-type\":\"pserver\",\"url\":null}]}]}]}]}")
.getAsJsonObject();
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java
index 279c3e83..7aebe84d 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/SimpleFormatTest.java
@@ -23,9 +23,9 @@ package org.onap.aai.serialization.queryformats;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -160,7 +160,7 @@ public class SimpleFormatTest extends AAISetup {
simpleFormat = new RawFormat.Builder(loader, serializer, urlBuilder).nodesOnly(true).depth(0).build();
- when(serializer.dbToObject(anyObject(), anyObject(), anyInt(), anyBoolean(), anyString()))
+ when(serializer.dbToObject(any(), any(), anyInt(), anyBoolean(), anyString()))
.thenThrow(new AAIException("Test Exception"));
simpleFormat.createPropertiesObject(vfModule);
diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/UrlBuilderTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/UrlBuilderTest.java
index c9e061c1..63671447 100644
--- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/UrlBuilderTest.java
+++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/utils/UrlBuilderTest.java
@@ -47,7 +47,7 @@ public class UrlBuilderTest extends AAISetup {
private Vertex v;
private static final String uri = "/test/uri";
- private static final Object vId = new Long(123);
+ private static final Object vId = Long.valueOf(123);
private static final String protocolAndHost = "http://localhost/aai/";
@Before
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
index a0fcf655..a281ba56 100644
--- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java
@@ -31,7 +31,7 @@ public class ErrorObjectTest {
private static final String ERROR_DISPOSITION = "5";
private static final String ERROR_SEVERITY = "ERROR";
private static final String ERROR_CATEGORY = "4";
- private static final Integer ERROR_HTTP_RESPONSE_CODE = new Integer(401);
+ private static final Integer ERROR_HTTP_RESPONSE_CODE = Integer.valueOf(401);
private static final String ERROR_REST_CODE = "3300";
private static final String ERROR_CODE = "4000";
private static final String ERROR_TEXT = "Test data error";
diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java b/aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java
index 9ed35def..a6028f9c 100644
--- a/aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java
+++ b/aai-rest/src/main/java/org/onap/aai/restclient/PropertyPasswordConfiguration.java
@@ -24,6 +24,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.Charset;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
@@ -65,7 +66,7 @@ public class PropertyPasswordConfiguration implements ApplicationContextInitiali
if (passwordStream != null) {
String keystorePassword = null;
- keystorePassword = IOUtils.toString(passwordStream);
+ keystorePassword = IOUtils.toString(passwordStream, Charset.defaultCharset());
if (keystorePassword != null) {
keystorePassword = keystorePassword.trim();
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java
index 74d254b1..57988f0b 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java
@@ -179,14 +179,11 @@ public class MockRestClient extends RestClient {
public JsonObject getPayload(String filename) throws IOException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(filename);
- // InputStream inputStream = new FileInputStream(filename);
-
String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
String message = String.format("Unable to find the %s in src/test/resources", filename);
assertNotNull(message, inputStream);
- JsonParser parser = new JsonParser();
- JsonObject payload = parser.parse(result).getAsJsonObject();
+ JsonObject payload = JsonParser.parseString(result).getAsJsonObject();
return payload;
}