summaryrefslogtreecommitdiffstats
path: root/aai-core
diff options
context:
space:
mode:
Diffstat (limited to 'aai-core')
-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.java4
-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.java3
-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.java2
-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.java7
-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
26 files changed, 121 insertions, 96 deletions
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 02288c35..496c1e82 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 312be4f9..3c5c4489 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
@@ -293,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);
}
@@ -326,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 3be88df6..2192ff5e 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 457c0b8b..71f7bc78 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
@@ -56,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;
@@ -108,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 e73b9902..c0ba860f 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 5d583c56..02c4041f 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;
@@ -65,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 ea4cd1c4..1caa7b50 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 d8167308..0da0ec55 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
@@ -52,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;
@@ -315,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();
}
@@ -329,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 18a85e4d..1b050829 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 d09c2e1e..7634d22a 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