aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Brilla <xbrilla@fi.muni.cz>2020-03-24 13:08:36 +0100
committerDavid Brilla <david.brilla@tieto.com>2020-04-21 11:29:53 +0200
commit6915f57d07f466a6dd54be693b2af2cec9b8e0c1 (patch)
tree7c1309f6575aee88434fca15b2001e72f81a46bc
parent71d81fa49428fcd2080844482e4e1205a9481ae4 (diff)
AAI-common sonar fixes
Issue-ID: AAI-2786 Change-Id: Ia37e660886fce56c8ab5c53888fcbf265692a359 Signed-off-by: David Brilla <david.brilla@tieto.com>
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java16
-rw-r--r--aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java60
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java30
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java22
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java23
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java39
-rw-r--r--aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java6
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/model/AAIResource.java131
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/model/AAIResourceKeys.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java19
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java10
-rw-r--r--aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java36
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java2
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java4
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIExceptionWithInfo.java18
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java1
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java1
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java7
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java3
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java62
23 files changed, 200 insertions, 306 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 c64251ad..0e170301 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
@@ -54,7 +54,7 @@ public final class AAIAuthCore {
private String globalAuthFileName = AAIConstants.AAI_AUTH_CONFIG_FILENAME;
- private final Pattern AUTH_POLICY_PATTERN;
+ private final Pattern authPolicyPattern;
private final Set<String> validFunctions = new HashSet<>();
private Map<String, AAIUser> users;
private boolean timerSet = false;
@@ -72,14 +72,14 @@ public final class AAIAuthCore {
public AAIAuthCore(String basePath, String filename){
this.basePath = basePath;
this.globalAuthFileName = filename;
- AUTH_POLICY_PATTERN = Pattern.compile("^" + this.basePath + "/v\\d+/([\\w\\-]*)");
+ authPolicyPattern = Pattern.compile("^" + this.basePath + "/v\\d+/([\\w\\-]*)");
init();
}
public AAIAuthCore(String basePath, String filename, String pattern){
this.basePath = basePath;
this.globalAuthFileName = filename;
- AUTH_POLICY_PATTERN = Pattern.compile(pattern);
+ authPolicyPattern = Pattern.compile(pattern);
init();
}
@@ -253,7 +253,7 @@ public final class AAIAuthCore {
} else if (uri.startsWith(basePath + "/tools")) {
authPolicyFunctionName = "tools";
} else {
- Matcher match = AUTH_POLICY_PATTERN.matcher(uri);
+ Matcher match = authPolicyPattern.matcher(uri);
if (match.find()) {
authPolicyFunctionName = match.group(1);
}
diff --git a/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java b/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
index fe2e1ff7..56321cf1 100644
--- a/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
+++ b/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
@@ -76,7 +76,6 @@ public class ListEndpoints {
if (schemaUriBasePath == null) {
String errorMsg = "Unable to find the property schema.uri.base.path,"
+ " please check if specified in system property or in schema-ingest.properties";
- System.err.println(errorMsg);
LOGGER.error(errorMsg);
}
@@ -96,11 +95,11 @@ public class ListEndpoints {
Loader loader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(ModelType.MOXY, version);
try {
- final Introspector start = loader.introspectorFromName(this.START);
+ final Introspector start = loader.introspectorFromName(START);
Set<String> startMap = new HashSet<>();
beginAudit(start, basePath + "/" + version, startMap);
} catch (AAIUnknownObjectException e) {
- throw new RuntimeException("Failed to find object " + this.START + ", cannot run ListEndpoints audit");
+ throw new RuntimeException("Failed to find object " + START + ", cannot run ListEndpoints audit");
}
}
@@ -114,7 +113,7 @@ public class ListEndpoints {
String currentUri = "";
- if (!obj.getDbName().equals("inventory")) {
+ if (!obj.getDbName().equals(START)) {
currentUri = uri + obj.getGenericURI();
} else {
currentUri = uri;
@@ -126,8 +125,6 @@ public class ListEndpoints {
endpoints.add(currentUri);
}
- String dbName = obj.getDbName();
-
populateLogicalName(obj, uri, currentUri);
Set<String> properties = obj.getProperties();
@@ -196,7 +193,7 @@ public class ListEndpoints {
}
if (uri.endsWith("/relationship-list")) {
- uri = uri.substring(0, uri.lastIndexOf("/"));
+ uri = uri.substring(0, uri.lastIndexOf('/'));
}
String logicalName = "";
@@ -222,8 +219,8 @@ public class ListEndpoints {
if (endpointToLogicalName.containsKey(uri) && uri.endsWith("}")) {
logicalName = logicalName + "From" + endpointToLogicalName.get(uri);
- } else if (endpointToLogicalName.containsKey(uri.substring(0, uri.lastIndexOf("/")))) {
- logicalName = logicalName + "From" + endpointToLogicalName.get(uri.substring(0, uri.lastIndexOf("/")));
+ } else if (endpointToLogicalName.containsKey(uri.substring(0, uri.lastIndexOf('/')))) {
+ logicalName = logicalName + "From" + endpointToLogicalName.get(uri.substring(0, uri.lastIndexOf('/')));
}
endpointToLogicalName.put(currentUri, logicalName);
@@ -264,7 +261,6 @@ public class ListEndpoints {
Matcher m = null;
if (!filterOut.equals("")) {
p = Pattern.compile(filterOut);
- m = null;
}
for (String s : endpoints) {
if (p != null) {
diff --git a/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java b/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java
index b8694554..30f877c3 100644
--- a/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java
+++ b/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java
@@ -20,7 +20,6 @@
package org.onap.aai.config;
-import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@@ -35,7 +34,7 @@ public class SpringContextAware implements ApplicationContextAware {
}
@Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ public void setApplicationContext(ApplicationContext applicationContext) {
context = applicationContext;
}
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java
index 02dede24..6c2eee15 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java
@@ -33,7 +33,6 @@ import org.apache.tinkerpop.gremlin.structure.io.Io;
import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
import org.apache.tinkerpop.gremlin.structure.io.Mapper;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
@@ -119,7 +118,7 @@ public final class GraphSONPartialIO
return new Builder(version);
}
- public final static class Builder implements Io.Builder<GraphSONPartialIO> {
+ public static final class Builder implements Io.Builder<GraphSONPartialIO> {
private IoRegistry registry = null;
private Graph graph;
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
index d3dfd150..1b3a3287 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
@@ -49,7 +49,7 @@ import org.apache.tinkerpop.gremlin.structure.io.Mapper;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.structure.util.Host;
@@ -60,7 +60,6 @@ import org.apache.tinkerpop.shaded.jackson.core.type.TypeReference;
import org.apache.tinkerpop.shaded.jackson.databind.JsonNode;
import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
import org.apache.tinkerpop.shaded.jackson.databind.node.JsonNodeType;
-import org.onap.aai.dbmap.InMemoryGraph;
/**
* This is a Wrapper around the GraphsonReader class
@@ -68,16 +67,15 @@ import org.onap.aai.dbmap.InMemoryGraph;
* GraphsonReader is a final class . hence the use of the Wrapper
* instead of inheriting-overwriting
*
- *
+ *
*/
public final class GraphSONPartialReader implements GraphReader {
private final ObjectMapper mapper;
private final long batchSize;
- private final GraphSONVersion version;
private boolean unwrapAdjacencyList = false;
private final GraphSONReader reader;
- private static final Logger LOGGER = LoggerFactory.getLogger(InMemoryGraph.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(GraphSONPartialReader.class);
final TypeReference<Map<String, Object>> mapTypeReference = new TypeReference<Map<String, Object>>() {};
@@ -85,7 +83,6 @@ public final class GraphSONPartialReader implements GraphReader {
mapper = builder.mapper.createMapper();
batchSize = builder.batchSize;
unwrapAdjacencyList = builder.unwrapAdjacencyList;
- version = ((GraphSONMapper) builder.mapper).getVersion();
reader = GraphSONReader.build().create();
}
@@ -119,7 +116,7 @@ public final class GraphSONPartialReader implements GraphReader {
if (supportsTx && counter.incrementAndGet() % batchSize == 0)
graphToWriteTo.tx().commit();
} catch (Exception ex) {
- LOGGER.info("Error in reading vertex from graphson" + vertex.toString());
+ LOGGER.info(String.format("Error in reading vertex from graphson%s", vertex.toString()));
}
});
@@ -138,13 +135,13 @@ public final class GraphSONPartialReader implements GraphReader {
: cachedOutV.addEdge(e.label(), cachedInV);
e.properties().forEachRemaining(p -> newEdge.property(p.key(), p.value()));
} else {
- LOGGER.debug("Ghost edges from " + cachedOutV + " to " + cachedInV);
+ LOGGER.debug(String.format("Ghost edges from %s to %s", cachedOutV, cachedInV));
}
if (supportsTx && counter.incrementAndGet() % batchSize == 0)
graphToWriteTo.tx().commit();
} catch (Exception ex) {
- LOGGER.info("Error in writing vertex into graph" + e.toString());
+ LOGGER.info(String.format("Error in writing vertex into graph%s", e.toString()));
}
}));
@@ -168,9 +165,6 @@ public final class GraphSONPartialReader implements GraphReader {
final Function<Attachable<Vertex>, Vertex> vertexAttachMethod,
final Function<Attachable<Edge>, Edge> edgeAttachMethod, final Direction attachEdgesOfThisDirection)
throws IOException {
- // return readVertexStrings(inputStream).<Vertex>map(FunctionUtils.wrapFunction(line -> readVertex(new
- // ByteArrayInputStream(line.getBytes()), vertexAttachMethod, edgeAttachMethod,
- // attachEdgesOfThisDirection))).iterator();
return reader.readVertices(inputStream, vertexAttachMethod, edgeAttachMethod, attachEdgesOfThisDirection);
}
@@ -219,23 +213,6 @@ public final class GraphSONPartialReader implements GraphReader {
@Override
public Edge readEdge(final InputStream inputStream, final Function<Attachable<Edge>, Edge> edgeAttachMethod)
throws IOException {
- /*
- * if (version == GraphSONVersion.v1_0) {
- * final Map<String, Object> edgeData = mapper.readValue(inputStream, mapTypeReference);
- *
- * final Map<String, Object> edgeProperties = edgeData.containsKey(GraphSONTokens.PROPERTIES) ?
- * (Map<String, Object>) edgeData.get(GraphSONTokens.PROPERTIES) : Collections.EMPTY_MAP;
- * final DetachedEdge edge = new DetachedEdge(edgeData.get(GraphSONTokens.ID),
- * edgeData.get(GraphSONTokens.LABEL).toString(),
- * edgeProperties,
- * Pair.with(edgeData.get(GraphSONTokens.OUT), edgeData.get(GraphSONTokens.OUT_LABEL).toString()),
- * Pair.with(edgeData.get(GraphSONTokens.IN), edgeData.get(GraphSONTokens.IN_LABEL).toString()));
- *
- * return edgeAttachMethod.apply(edge);
- * } else {
- * return edgeAttachMethod.apply((DetachedEdge) mapper.readValue(inputStream, Edge.class));
- * }
- */
return reader.readEdge(inputStream, edgeAttachMethod);
}
@@ -252,19 +229,6 @@ public final class GraphSONPartialReader implements GraphReader {
@Override
public VertexProperty readVertexProperty(final InputStream inputStream,
final Function<Attachable<VertexProperty>, VertexProperty> vertexPropertyAttachMethod) throws IOException {
- /*
- * if (version == GraphSONVersion.v1_0) {
- * final Map<String, Object> vpData = mapper.readValue(inputStream, mapTypeReference);
- * final Map<String, Object> metaProperties = (Map<String, Object>) vpData.get(GraphSONTokens.PROPERTIES);
- * final DetachedVertexProperty vp = new DetachedVertexProperty(vpData.get(GraphSONTokens.ID),
- * vpData.get(GraphSONTokens.LABEL).toString(),
- * vpData.get(GraphSONTokens.VALUE), metaProperties);
- * return vertexPropertyAttachMethod.apply(vp);
- * } else {
- * return vertexPropertyAttachMethod.apply((DetachedVertexProperty) mapper.readValue(inputStream,
- * VertexProperty.class));
- * }
- */
return reader.readVertexProperty(inputStream, vertexPropertyAttachMethod);
}
@@ -279,16 +243,6 @@ public final class GraphSONPartialReader implements GraphReader {
@Override
public Property readProperty(final InputStream inputStream,
final Function<Attachable<Property>, Property> propertyAttachMethod) throws IOException {
- /*
- * if (version == GraphSONVersion.v1_0) {
- * final Map<String, Object> propertyData = mapper.readValue(inputStream, mapTypeReference);
- * final DetachedProperty p = new DetachedProperty(propertyData.get(GraphSONTokens.KEY).toString(),
- * propertyData.get(GraphSONTokens.VALUE));
- * return propertyAttachMethod.apply(p);
- * } else {
- * return propertyAttachMethod.apply((DetachedProperty) mapper.readValue(inputStream, Property.class));
- * }
- */
return reader.readProperty(inputStream, propertyAttachMethod);
}
@@ -318,7 +272,7 @@ public final class GraphSONPartialReader implements GraphReader {
return new Builder();
}
- public final static class Builder implements ReaderBuilder<GraphSONPartialReader> {
+ public static final class Builder implements ReaderBuilder<GraphSONPartialReader> {
private long batchSize = 10000;
private Mapper<ObjectMapper> mapper = GraphSONMapper.build().create();
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
index d253f876..e6b6fbaf 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
@@ -20,16 +20,7 @@
package org.onap.aai.dbgen;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.collect.Multimap;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.Cardinality;
import org.janusgraph.core.JanusGraph;
@@ -37,36 +28,41 @@ import org.janusgraph.core.Multiplicity;
import org.janusgraph.core.PropertyKey;
import org.janusgraph.core.schema.JanusGraphManagement;
import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
-import org.onap.aai.introspection.*;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderUtil;
import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.schema.enums.PropertyMetadata;
-import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
public class SchemaGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(SchemaGenerator.class);
+ private SchemaGenerator() {
+
+ }
+
/**
* Load schema into JanusGraph.
*
- * @param graph
- * the graph
* @param graphMgmt
* the graph mgmt
*/
- public static void loadSchemaIntoJanusGraph(final JanusGraph graph, final JanusGraphManagement graphMgmt,
+ public static void loadSchemaIntoJanusGraph(final JanusGraphManagement graphMgmt,
String backend) {
try {
AAIConfig.init();
} catch (Exception ex) {
LOGGER.error(" ERROR - Could not run AAIConfig.init(). " + LogFormatTools.getStackTop(ex));
- // System.out.println(" ERROR - Could not run AAIConfig.init(). ");
System.exit(1);
}
@@ -177,7 +173,7 @@ public class SchemaGenerator {
String imsg = "-- About to call graphMgmt commit";
LOGGER.info(imsg);
if (backend != null) {
- LOGGER.info("Successfully loaded the schema to " + backend);
+ LOGGER.info(String.format("Successfully loaded the schema to %s", backend));
}
graphMgmt.commit();
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
index 5bb4b656..13040d30 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
@@ -54,9 +54,12 @@ import java.util.Properties;
public class AAIGraph {
private static final Logger logger = LoggerFactory.getLogger(AAIGraph.class);
+ private static final String IN_MEMORY = "inmemory";
protected JanusGraph graph;
private static boolean isInit = false;
+
+
/**
* Instantiates a new AAI graph.
*/
@@ -107,7 +110,7 @@ public class AAIGraph {
propertiesConfiguration.getKeys()
.forEachRemaining(k -> graphProps.setProperty(k, propertiesConfiguration.getString(k)));
- if ("inmemory".equals(graphProps.get("storage.backend"))) {
+ if (IN_MEMORY.equals(graphProps.get("storage.backend"))) {
// Load the propertyKeys, indexes and edge-Labels into the DB
loadSchema(graph);
loadSnapShotToInMemoryGraph(graph, graphProps);
@@ -131,13 +134,12 @@ public class AAIGraph {
if ("true".equals(value)) {
try (Graph transaction = graph.newTransaction()) {
String location = System.getProperty("snapshot.location");
- logAndPrint("Loading snapshot to inmemory graph.");
+ logger.info("Loading snapshot to inmemory graph.");
transaction.io(IoCore.graphson()).readGraph(location);
transaction.tx().commit();
- logAndPrint("Snapshot loaded to inmemory graph.");
+ logger.info("Snapshot loaded to inmemory graph.");
} catch (Exception e) {
- logAndPrint("ERROR: Could not load datasnapshot to in memory graph. \n"
- + ExceptionUtils.getFullStackTrace(e));
+ logger.info(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s", ExceptionUtils.getFullStackTrace(e)));
throw new RuntimeException(e);
}
}
@@ -148,11 +150,11 @@ public class AAIGraph {
// Load the propertyKeys, indexes and edge-Labels into the DB
JanusGraphManagement graphMgt = graph.openManagement();
- System.out.println("-- loading schema into JanusGraph");
+ logger.info("-- loading schema into JanusGraph");
if ("true".equals(SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.enabled", "false"))) {
- SchemaGenerator4Hist.loadSchemaIntoJanusGraph(graph, graphMgt, "inmemory");
+ SchemaGenerator4Hist.loadSchemaIntoJanusGraph(graph, graphMgt, IN_MEMORY);
} else {
- SchemaGenerator.loadSchemaIntoJanusGraph(graph, graphMgt, "inmemory");
+ SchemaGenerator.loadSchemaIntoJanusGraph(graphMgt, IN_MEMORY);
}
}
@@ -174,8 +176,4 @@ public class AAIGraph {
return graph;
}
- private void logAndPrint(String msg) {
- System.out.println(msg);
- logger.info(msg);
- }
}
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
index ea939b32..6bf04246 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
@@ -20,36 +20,25 @@
package org.onap.aai.dbmap;
-import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.*;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterators;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.lang.StringUtils;
+import org.janusgraph.diskstorage.configuration.ConfigElement;
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory;
-import java.util.Iterator;
import java.util.Objects;
-import java.util.regex.Pattern;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.lang.StringUtils;
-import org.janusgraph.diskstorage.configuration.ConfigElement;
-import org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration;
/**
* For building a config that JanusGraphFactory.open can use with an identifiable graph.unique-instance-id
*/
public class AAIGraphConfig {
- private static final Logger logger = LoggerFactory.getLogger(AAIGraphConfig.class);
private AAIGraphConfig() {
- };
+
+ }
public PropertiesConfiguration getCc(String configPath, String graphType, String service)
throws ConfigurationException, FileNotFoundException {
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
index d017b7e9..ac9407e3 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
@@ -28,7 +28,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
-import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphFactory;
@@ -47,8 +46,7 @@ public class InMemoryGraph {
/*
* Create a In-memory graph
*/
- InputStream is = new FileInputStream(builder.propertyFile);
- try {
+ try(InputStream is = new FileInputStream(builder.propertyFile)){
graph = JanusGraphFactory.open(builder.propertyFile);
Properties graphProps = new Properties();
@@ -56,34 +54,31 @@ public class InMemoryGraph {
JanusGraphManagement graphMgt = graph.openManagement();
if (builder.isSchemaEnabled) {
LOGGER.info("Schema Enabled");
- SchemaGenerator.loadSchemaIntoJanusGraph(graph, graphMgt, graphProps.getProperty("storage.backend"));
+ SchemaGenerator.loadSchemaIntoJanusGraph(graphMgt, graphProps.getProperty("storage.backend"));
}
- JanusGraphTransaction transaction = graph.newTransaction();
- LOGGER.info("Loading snapshot");
- if (builder.isPartialGraph) {
- if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
- transaction.io(GraphSONPartialIO.build()).readGraph(builder.graphsonLocation);
- } else {
- transaction.io(GraphSONPartialIO.build()).reader().create().readGraph(builder.seqInputStream,
+ try (JanusGraphTransaction transaction = graph.newTransaction()) {
+ LOGGER.info("Loading snapshot");
+ if (builder.isPartialGraph) {
+ if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
+ transaction.io(GraphSONPartialIO.build()).readGraph(builder.graphsonLocation);
+ } else {
+ transaction.io(GraphSONPartialIO.build()).reader().create().readGraph(builder.seqInputStream,
graph);
- }
- } else {
- if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
- transaction.io(IoCore.graphson()).readGraph(builder.graphsonLocation);
+ }
} else {
- transaction.io(IoCore.graphson()).reader().create().readGraph(builder.seqInputStream, graph);
+ if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
+ transaction.io(IoCore.graphson()).readGraph(builder.graphsonLocation);
+ } else {
+ transaction.io(IoCore.graphson()).reader().create().readGraph(builder.seqInputStream, graph);
+ }
}
+ transaction.commit();
}
- transaction.commit();
} catch (Exception e) {
- // TODO : Changesysout to logger
- e.printStackTrace();
- LOGGER.error("ERROR: Could not load datasnapshot to in memory graph. \n" + LogFormatTools.getStackTop(e));
+ LOGGER.error(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s", LogFormatTools.getStackTop(e)));
throw new IllegalStateException("Could not load datasnapshot to in memory graph");
- } finally {
- is.close();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
index b3a8773e..3c030466 100644
--- a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
+++ b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
@@ -101,8 +101,8 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
} else {
return;
}
- if (jo.getString("event-topic") != null) {
- eventName = jo.getString("event-topic");
+ if (jo.getString(EVENT_TOPIC) != null) {
+ eventName = jo.getString(EVENT_TOPIC);
}
if (joPayload.has("event-header")) {
try {
@@ -129,7 +129,7 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
if ("AAI-EVENT".equals(eventName)) {
restTemplate.exchange(baseUrl + endpoint, HttpMethod.POST, httpEntity, String.class);
} else {
- LOGGER.error(eventName + "|Event Topic invalid.");
+ LOGGER.error(String.format("%s|Event Topic invalid.", eventName));
}
} catch (JMSException | JSONException e) {
aaiElsErrorCode = AaiElsErrorCode.DATA_ERROR;
diff --git a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResource.java b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResource.java
index ddeabf07..7e446fb6 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResource.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResource.java
@@ -23,6 +23,7 @@ package org.onap.aai.domain.model;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
public class AAIResource {
@@ -42,29 +43,29 @@ public class AAIResource {
private String relationshipListClass;
private String relationshipUtils;
- private Map<String, String> PropertyDataTypeMap;
- private Multimap<String, String> NodeMapIndexedProps;
- private Multimap<String, String> NodeAltKey1Props;
- private Multimap<String, String> NodeDependencies;
- private Multimap<String, String> NodeKeyProps;
- private Multimap<String, String> NodeReqProps;
- private Multimap<String, String> NodeNameProps;
- private Multimap<String, String> NodeUniqueProps;
+ private Map<String, String> propertyDataTypeMap;
+ private Multimap<String, String> nodeMapIndexedProps;
+ private Multimap<String, String> nodeAltKey1Props;
+ private Multimap<String, String> nodeDependencies;
+ private Multimap<String, String> nodeKeyProps;
+ private Multimap<String, String> nodeReqProps;
+ private Multimap<String, String> nodeNameProps;
+ private Multimap<String, String> nodeUniqueProps;
// if new dataTypes are added - make sure to update getAllFields() method below
- private ArrayList<String> stringFields;
- private ArrayList<String> stringListFields;
- private ArrayList<String> longFields;
- private ArrayList<String> intFields;
- private ArrayList<String> shortFields;
- private ArrayList<String> booleanFields;
-
- private ArrayList<String> requiredFields;
- private ArrayList<String> orderedFields;
+ private List<String> stringFields;
+ private List<String> stringListFields;
+ private List<String> longFields;
+ private List<String> intFields;
+ private List<String> shortFields;
+ private List<String> booleanFields;
+
+ private List<String> requiredFields;
+ private List<String> orderedFields;
private AAIResource recurseToResource;
private boolean allowDirectWrite;
private boolean allowDirectRead;
- private ArrayList<String> autoGenUuidFields;
+ private List<String> autoGenUuidFields;
/**
* Gets the parent.
@@ -222,7 +223,7 @@ public class AAIResource {
* @return the property data type map
*/
public Map<String, String> getPropertyDataTypeMap() {
- return PropertyDataTypeMap;
+ return propertyDataTypeMap;
}
/**
@@ -231,7 +232,7 @@ public class AAIResource {
* @param propertyDataTypeMap the property data type map
*/
public void setPropertyDataTypeMap(Map<String, String> propertyDataTypeMap) {
- PropertyDataTypeMap = propertyDataTypeMap;
+ this.propertyDataTypeMap = propertyDataTypeMap;
}
/**
@@ -240,7 +241,7 @@ public class AAIResource {
* @return the node map indexed props
*/
public Multimap<String, String> getNodeMapIndexedProps() {
- return NodeMapIndexedProps;
+ return nodeMapIndexedProps;
}
/**
@@ -249,7 +250,7 @@ public class AAIResource {
* @param nodeMapIndexedProps the node map indexed props
*/
public void setNodeMapIndexedProps(Multimap<String, String> nodeMapIndexedProps) {
- NodeMapIndexedProps = nodeMapIndexedProps;
+ this.nodeMapIndexedProps = nodeMapIndexedProps;
}
/**
@@ -258,7 +259,7 @@ public class AAIResource {
* @return the node key props
*/
public Multimap<String, String> getNodeKeyProps() {
- return NodeKeyProps;
+ return nodeKeyProps;
}
/**
@@ -267,7 +268,7 @@ public class AAIResource {
* @param nodeKeyProps the node key props
*/
public void setNodeKeyProps(Multimap<String, String> nodeKeyProps) {
- this.NodeKeyProps = nodeKeyProps;
+ this.nodeKeyProps = nodeKeyProps;
}
/**
@@ -276,7 +277,7 @@ public class AAIResource {
* @return the node name props
*/
public Multimap<String, String> getNodeNameProps() {
- return NodeNameProps;
+ return nodeNameProps;
}
/**
@@ -286,7 +287,7 @@ public class AAIResource {
*/
public void setNodeNameProps(Multimap<String, String> nodeNameProps) {
- NodeNameProps = nodeNameProps;
+ this.nodeNameProps = nodeNameProps;
}
/**
@@ -295,7 +296,7 @@ public class AAIResource {
* @return the node unique props
*/
public Multimap<String, String> getNodeUniqueProps() {
- return NodeUniqueProps;
+ return nodeUniqueProps;
}
/**
@@ -304,7 +305,7 @@ public class AAIResource {
* @param nodeUniqueProps the node unique props
*/
public void setNodeUniqueProps(Multimap<String, String> nodeUniqueProps) {
- NodeUniqueProps = nodeUniqueProps;
+ this.nodeUniqueProps = nodeUniqueProps;
}
/**
@@ -313,7 +314,7 @@ public class AAIResource {
* @return the node req props
*/
public Multimap<String, String> getNodeReqProps() {
- return NodeReqProps;
+ return nodeReqProps;
}
/**
@@ -322,7 +323,7 @@ public class AAIResource {
* @param nodeReqProps the node req props
*/
public void setNodeReqProps(Multimap<String, String> nodeReqProps) {
- NodeReqProps = nodeReqProps;
+ this.nodeReqProps = nodeReqProps;
}
/**
@@ -384,9 +385,9 @@ public class AAIResource {
*
* @return the string fields
*/
- public ArrayList<String> getStringFields() {
+ public List<String> getStringFields() {
if (this.stringFields == null) {
- this.stringFields = new ArrayList<String>();
+ this.stringFields = new ArrayList<>();
}
return this.stringFields;
}
@@ -396,7 +397,7 @@ public class AAIResource {
*
* @param stringFields the new string fields
*/
- public void setStringFields(ArrayList<String> stringFields) {
+ public void setStringFields(List<String> stringFields) {
this.stringFields = stringFields;
}
@@ -405,9 +406,9 @@ public class AAIResource {
*
* @return the string list fields
*/
- public ArrayList<String> getStringListFields() {
+ public List<String> getStringListFields() {
if (this.stringListFields == null) {
- this.stringListFields = new ArrayList<String>();
+ this.stringListFields = new ArrayList<>();
}
return this.stringListFields;
}
@@ -417,7 +418,7 @@ public class AAIResource {
*
* @param stringListFields the new string list fields
*/
- public void setStringListFields(ArrayList<String> stringListFields) {
+ public void setStringListFields(List<String> stringListFields) {
this.stringListFields = stringListFields;
}
@@ -426,9 +427,9 @@ public class AAIResource {
*
* @return the long fields
*/
- public ArrayList<String> getLongFields() {
+ public List<String> getLongFields() {
if (this.longFields == null) {
- this.longFields = new ArrayList<String>();
+ this.longFields = new ArrayList<>();
}
return longFields;
}
@@ -438,7 +439,7 @@ public class AAIResource {
*
* @param longFields the new long fields
*/
- public void setLongFields(ArrayList<String> longFields) {
+ public void setLongFields(List<String> longFields) {
this.longFields = longFields;
}
@@ -447,9 +448,9 @@ public class AAIResource {
*
* @return the int fields
*/
- public ArrayList<String> getIntFields() {
+ public List<String> getIntFields() {
if (this.intFields == null) {
- this.intFields = new ArrayList<String>();
+ this.intFields = new ArrayList<>();
}
return intFields;
}
@@ -459,7 +460,7 @@ public class AAIResource {
*
* @param intFields the new int fields
*/
- public void setIntFields(ArrayList<String> intFields) {
+ public void setIntFields(List<String> intFields) {
this.intFields = intFields;
}
@@ -468,9 +469,9 @@ public class AAIResource {
*
* @return the short fields
*/
- public ArrayList<String> getShortFields() {
+ public List<String> getShortFields() {
if (this.shortFields == null) {
- this.shortFields = new ArrayList<String>();
+ this.shortFields = new ArrayList<>();
}
return shortFields;
}
@@ -480,7 +481,7 @@ public class AAIResource {
*
* @param shortFields the new short fields
*/
- public void setShortFields(ArrayList<String> shortFields) {
+ public void setShortFields(List<String> shortFields) {
this.shortFields = shortFields;
}
@@ -489,9 +490,9 @@ public class AAIResource {
*
* @return the boolean fields
*/
- public ArrayList<String> getBooleanFields() {
+ public List<String> getBooleanFields() {
if (this.booleanFields == null) {
- this.booleanFields = new ArrayList<String>();
+ this.booleanFields = new ArrayList<>();
}
return booleanFields;
}
@@ -501,7 +502,7 @@ public class AAIResource {
*
* @param booleanFields the new boolean fields
*/
- public void setBooleanFields(ArrayList<String> booleanFields) {
+ public void setBooleanFields(List<String> booleanFields) {
this.booleanFields = booleanFields;
}
@@ -510,9 +511,9 @@ public class AAIResource {
*
* @return the required fields
*/
- public ArrayList<String> getRequiredFields() {
+ public List<String> getRequiredFields() {
if (this.requiredFields == null) {
- this.requiredFields = new ArrayList<String>();
+ this.requiredFields = new ArrayList<>();
}
return requiredFields;
}
@@ -522,7 +523,7 @@ public class AAIResource {
*
* @param requiredFields the new required fields
*/
- public void setRequiredFields(ArrayList<String> requiredFields) {
+ public void setRequiredFields(List<String> requiredFields) {
this.requiredFields = requiredFields;
}
@@ -531,9 +532,9 @@ public class AAIResource {
*
* @return the ordered fields
*/
- public ArrayList<String> getOrderedFields() {
+ public List<String> getOrderedFields() {
if (this.orderedFields == null) {
- this.orderedFields = new ArrayList<String>();
+ this.orderedFields = new ArrayList<>();
}
return this.orderedFields;
}
@@ -543,9 +544,9 @@ public class AAIResource {
*
* @return the all fields
*/
- public ArrayList<String> getAllFields() {
+ public List<String> getAllFields() {
- ArrayList<String> allFields = new ArrayList<String>();
+ ArrayList<String> allFields = new ArrayList<>();
allFields.addAll(getBooleanFields());
allFields.addAll(getStringListFields());
allFields.addAll(getStringFields());
@@ -572,10 +573,10 @@ public class AAIResource {
/**
* Sets the node alt key 1 props.
*
- * @param _dbRulesNodeAltKey1Props the db rules node alt key 1 props
+ * @param dbRulesNodeAltKey1Props the db rules node alt key 1 props
*/
- public void setNodeAltKey1Props(Multimap<String, String> _dbRulesNodeAltKey1Props) {
- this.NodeAltKey1Props = _dbRulesNodeAltKey1Props;
+ public void setNodeAltKey1Props(Multimap<String, String> dbRulesNodeAltKey1Props) {
+ this.nodeAltKey1Props = dbRulesNodeAltKey1Props;
}
/**
@@ -584,16 +585,16 @@ public class AAIResource {
* @return the node alt key 1 props
*/
public Multimap<String, String> getNodeAltKey1Props() {
- return this.NodeAltKey1Props;
+ return this.nodeAltKey1Props;
}
/**
* Sets the node dependencies.
*
- * @param _dbRulesNodeDependencies the db rules node dependencies
+ * @param dbRulesNodeDependencies the db rules node dependencies
*/
- public void setNodeDependencies(Multimap<String, String> _dbRulesNodeDependencies) {
- this.NodeDependencies = _dbRulesNodeDependencies;
+ public void setNodeDependencies(Multimap<String, String> dbRulesNodeDependencies) {
+ this.nodeDependencies = dbRulesNodeDependencies;
}
/**
@@ -602,7 +603,7 @@ public class AAIResource {
* @return the node dependencies
*/
public Multimap<String, String> getNodeDependencies() {
- return this.NodeDependencies;
+ return this.nodeDependencies;
}
/**
@@ -665,9 +666,9 @@ public class AAIResource {
*
* @return the auto gen uuid fields
*/
- public ArrayList<String> getAutoGenUuidFields() {
+ public List<String> getAutoGenUuidFields() {
if (this.autoGenUuidFields == null) {
- this.autoGenUuidFields = new ArrayList<String>();
+ this.autoGenUuidFields = new ArrayList<>();
}
return this.autoGenUuidFields;
}
diff --git a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResourceKeys.java b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResourceKeys.java
index 64149513..1373c93d 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResourceKeys.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResourceKeys.java
@@ -33,7 +33,7 @@ public class AAIResourceKeys {
*/
public List<AAIResourceKey> getAaiResourceKey() {
if (aaiResourceKey == null) {
- aaiResourceKey = new ArrayList<AAIResourceKey>();
+ aaiResourceKey = new ArrayList<>();
}
return aaiResourceKey;
}
diff --git a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
index 413faf62..ac13ab07 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
@@ -23,24 +23,25 @@ package org.onap.aai.domain.model;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import java.util.HashMap;
+import java.util.Map;
public class AAIResources {
private DynamicJAXBContext jaxbContext;
- private HashMap<String, AAIResource> aaiResources;
- private HashMap<String, AAIResource> resourceLookup;
+ private Map<String, AAIResource> resources;
+ private Map<String, AAIResource> resourceLookup;
/**
* Gets the aai resources.
*
* @return the aai resources
*/
- public HashMap<String, AAIResource> getAaiResources() {
- if (aaiResources == null) {
- aaiResources = new HashMap<String, AAIResource>();
+ public Map<String, AAIResource> getAaiResources() {
+ if (resources == null) {
+ resources = new HashMap<>();
}
- return aaiResources;
+ return resources;
}
/**
@@ -66,9 +67,9 @@ public class AAIResources {
*
* @return the resource lookup
*/
- public HashMap<String, AAIResource> getResourceLookup() {
+ public Map<String, AAIResource> getResourceLookup() {
if (resourceLookup == null) {
- resourceLookup = new HashMap<String, AAIResource>();
+ resourceLookup = new HashMap<>();
}
return resourceLookup;
}
@@ -78,7 +79,7 @@ public class AAIResources {
*
* @param resourceLookup the resource lookup
*/
- public void setResourceLookup(HashMap<String, AAIResource> resourceLookup) {
+ public void setResourceLookup(Map<String, AAIResource> resourceLookup) {
this.resourceLookup = resourceLookup;
}
diff --git a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
index e81b3e3c..cde4f4b9 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
@@ -105,11 +105,11 @@ import java.util.List;
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {"transactionLogEntries"})
+@XmlType(name = "", propOrder = {"logEntries"})
@XmlRootElement(name = "transaction-log-entries", namespace = "http://org.onap.aai.inventory")
public class TransactionLogEntries {
- protected List<TransactionLogEntry> transactionLogEntries;
+ protected List<TransactionLogEntry> logEntries;
/**
* Gets the transaction log entries.
@@ -117,10 +117,10 @@ public class TransactionLogEntries {
* @return the transaction log entries
*/
public List<TransactionLogEntry> getTransactionLogEntries() {
- if (transactionLogEntries == null) {
- transactionLogEntries = new ArrayList<TransactionLogEntry>();
+ if (logEntries == null) {
+ logEntries = new ArrayList<>();
}
- return this.transactionLogEntries;
+ return this.logEntries;
}
}
diff --git a/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java b/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java
index eafffe63..5c825242 100644
--- a/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java
+++ b/aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java
@@ -22,32 +22,14 @@ package org.onap.aai.audit;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.onap.aai.AAISetup;
-import org.onap.aai.concurrent.AaiCallable;
-import org.onap.aai.setup.SchemaServiceVersions;
import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.setup.SchemaVersionsBean;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.stereotype.Component;
-import org.springframework.test.context.TestPropertySource;
-import javax.validation.constraints.AssertTrue;
-import java.io.File;
-import java.io.FileReader;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import static org.junit.Assert.assertTrue;
-
public class ListEndpointsTest extends AAISetup {
private Properties properties;
@@ -55,7 +37,7 @@ public class ListEndpointsTest extends AAISetup {
private ListEndpoints listEndpoints;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
properties = new Properties();
version = schemaVersions.getDefaultVersion();
listEndpoints = new ListEndpoints(basePath, schemaVersions.getDefaultVersion());
@@ -63,7 +45,7 @@ public class ListEndpointsTest extends AAISetup {
@Test
public void testGetEndpoints() {
- Assert.assertTrue(listEndpoints != null);
+ Assert.assertNotNull(listEndpoints);
List<String> list = listEndpoints.getEndpoints();
Assert.assertTrue(list != null && !list.isEmpty());
@@ -74,32 +56,26 @@ public class ListEndpointsTest extends AAISetup {
@Test
public void testGetEndpointsWithParam() {
- Assert.assertTrue(listEndpoints != null);
+ Assert.assertNotNull(listEndpoints);
List<String> list = listEndpoints.getEndpoints();
Assert.assertTrue(list != null && !list.isEmpty());
}
@Test(expected = RuntimeException.class)
public void testGetEndpoints_throwException() {
- ListEndpoints listEndpointsFail = new ListEndpoints(basePath, null);
+ new ListEndpoints(basePath, null);
}
@Test
public void testGetLogicalNames() {
- Assert.assertTrue(listEndpoints != null);
+ Assert.assertNotNull(listEndpoints);
Map<String, String> map = listEndpoints.getLogicalNames();
Assert.assertTrue(map != null && !map.isEmpty());
}
@Test
- public void testToString() {
- Assert.assertTrue(listEndpoints != null);
- String endpoints = listEndpoints.toString();
- }
-
- @Test
public void testToStrinWithParam() {
- Assert.assertTrue(listEndpoints != null);
+ Assert.assertNotNull(listEndpoints);
String endpoints = listEndpoints.toString("complex");
Assert.assertTrue(!endpoints.contains("complex"));
}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java
index d1403ad2..fe51ab05 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java
@@ -357,7 +357,7 @@ public class Fault {
*/
public List<String> getVariable() {
if (variable == null) {
- variable = new ArrayList<String>();
+ variable = new ArrayList<>();
}
return this.variable;
}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java
index 268b7673..f4a4b47f 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java
@@ -188,7 +188,7 @@ public class Info {
*/
public List<ResponseMessage> getResponseMessage() {
if (responseMessage == null) {
- responseMessage = new ArrayList<ResponseMessage>();
+ responseMessage = new ArrayList<>();
}
return this.responseMessage;
}
@@ -361,7 +361,7 @@ public class Info {
*/
public List<String> getVariable() {
if (variable == null) {
- variable = new ArrayList<String>();
+ variable = new ArrayList<>();
}
return this.variable;
}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIExceptionWithInfo.java b/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIExceptionWithInfo.java
index e7f2901e..3ba07532 100644
--- a/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIExceptionWithInfo.java
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIExceptionWithInfo.java
@@ -20,11 +20,11 @@
package org.onap.aai.exceptions;
-import java.util.HashMap;
+import java.util.Map;
public class AAIExceptionWithInfo extends AAIException {
- HashMap<String, Object> infoHash;
+ Map<String, Object> infoHash;
String info;
/**
@@ -33,7 +33,7 @@ public class AAIExceptionWithInfo extends AAIException {
* @param infoHash the info hash
* @param info the info
*/
- public AAIExceptionWithInfo(HashMap<String, Object> infoHash, String info) {
+ public AAIExceptionWithInfo(Map<String, Object> infoHash, String info) {
super();
setInfoHash(infoHash);
setInfo(info);
@@ -46,7 +46,7 @@ public class AAIExceptionWithInfo extends AAIException {
* @param infoHash the info hash
* @param info the info
*/
- public AAIExceptionWithInfo(String code, HashMap<String, Object> infoHash, String info) {
+ public AAIExceptionWithInfo(String code, Map<String, Object> infoHash, String info) {
super(code);
setInfoHash(infoHash);
setInfo(info);
@@ -60,7 +60,7 @@ public class AAIExceptionWithInfo extends AAIException {
* @param infoHash the info hash
* @param info the info
*/
- public AAIExceptionWithInfo(String code, String details, HashMap<String, Object> infoHash, String info) {
+ public AAIExceptionWithInfo(String code, String details, Map<String, Object> infoHash, String info) {
super(code, details);
setInfoHash(infoHash);
setInfo(info);
@@ -74,7 +74,7 @@ public class AAIExceptionWithInfo extends AAIException {
* @param infoHash the info hash
* @param info the info
*/
- public AAIExceptionWithInfo(String code, Throwable cause, HashMap<String, Object> infoHash, String info) {
+ public AAIExceptionWithInfo(String code, Throwable cause, Map<String, Object> infoHash, String info) {
super(code, cause);
setInfoHash(infoHash);
setInfo(info);
@@ -89,7 +89,7 @@ public class AAIExceptionWithInfo extends AAIException {
* @param infoHash the info hash
* @param info the info
*/
- public AAIExceptionWithInfo(String code, Throwable cause, String details, HashMap<String, Object> infoHash,
+ public AAIExceptionWithInfo(String code, Throwable cause, String details, Map<String, Object> infoHash,
String info) {
super(code, cause, details);
setInfoHash(infoHash);
@@ -101,7 +101,7 @@ public class AAIExceptionWithInfo extends AAIException {
*
* @return the info hash
*/
- public HashMap<String, Object> getInfoHash() {
+ public Map<String, Object> getInfoHash() {
return infoHash;
}
@@ -110,7 +110,7 @@ public class AAIExceptionWithInfo extends AAIException {
*
* @param infoHash the info hash
*/
- public void setInfoHash(HashMap<String, Object> infoHash) {
+ public void setInfoHash(Map<String, Object> infoHash) {
this.infoHash = infoHash;
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java
index af4d8e8e..ad7c3718 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java
@@ -44,7 +44,6 @@ import org.springframework.context.annotation.PropertySource;
@Configuration
public class EdgesConfiguration {
- private static final String CONFIG_TRANSLATOR = "config";
private static final String SCHEMA_SERVICE_TRANSLATOR = "schema-service";
@Autowired(required = false)
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java
index 0bb36a2d..2e6847d2 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java
@@ -47,7 +47,6 @@ import org.springframework.context.annotation.PropertySource;
@Configuration
public class NodesConfiguration {
- private static final String CONFIG_TRANSLATOR = "config";
private static final String SCHEMA_SERVICE_TRANSLATOR = "schema-service";
private static final Logger LOGGER = LoggerFactory.getLogger(NodesConfiguration.class);
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java
index 529c0684..c46ab78d 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java
@@ -23,7 +23,6 @@
package org.onap.aai.config;
import org.onap.aai.restclient.*;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -48,19 +47,19 @@ public class RestConfiguration {
* In the below cases bean name and method names are different because all of them qualify as restClient
*/
@Bean(name = "restClient")
- @ConditionalOnProperty(name = "schema.service.client", havingValue = "two-way-ssl", matchIfMissing = true)
+ @ConditionalOnProperty(name = "schema.service.client", havingValue = TWO_WAY_SSL, matchIfMissing = true)
public RestClient getSchemaServiceTwoWayClient() {
return new SchemaServiceRestClient();
}
@Bean(name = "restClient")
- @ConditionalOnProperty(name = "schema.service.client", havingValue = "no-auth")
+ @ConditionalOnProperty(name = "schema.service.client", havingValue = NO_AUTH)
public RestClient getSchemaServiceNoAuthClient() {
return new SchemaServiceNoAuthClient();
}
@Bean(name = "restClient")
- @ConditionalOnProperty(name = "schema.service.client", havingValue = "one-way-ssl")
+ @ConditionalOnProperty(name = "schema.service.client", havingValue = ONE_WAY_SSL)
public RestClient getSchemaServiceOneWayClient() {
return new SchemaServiceOneWayClient();
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
index 68def753..8861c5cc 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java
@@ -24,7 +24,6 @@ import org.apache.tinkerpop.gremlin.structure.Direction;
import org.onap.aai.edges.enums.*;
import java.util.EnumMap;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -77,7 +76,7 @@ public class EdgeRule {
this.label = edgeRule.label;
this.direction = Direction.valueOf(edgeRule.direction.toString());
this.multiplicityRule = MultiplicityRule.valueOf(edgeRule.multiplicityRule.toString());
- this.edgeFields = new HashMap<>(edgeRule.edgeFields);
+ this.edgeFields = new EnumMap<>(edgeRule.edgeFields);
this.isDefaultEdge = edgeRule.isDefaultEdge;
this.description = edgeRule.description;
this.isPrivateEdge = edgeRule.isPrivateEdge;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
index fc58dbb6..8ecbe2a3 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java
@@ -22,9 +22,7 @@
package org.onap.aai.edges;
-import static com.jayway.jsonpath.Criteria.where;
-import static com.jayway.jsonpath.Filter.filter;
-
+import com.jayway.jsonpath.Criteria;
import com.jayway.jsonpath.Filter;
import com.jayway.jsonpath.Predicate;
@@ -54,10 +52,11 @@ public class EdgeRuleQuery {
private EdgeType type;
private boolean isPrivate;
+ private static final String TO_ONLY = "ToOnly";
+ private static final String FROM_ONLY = "FromOnly";
+
public static class Builder {
- private static final String TO_ONLY = "ToOnly";
- private static final String FROM_ONLY = "FromOnly";
// required
private String nodeA;
@@ -168,7 +167,7 @@ public class EdgeRuleQuery {
// will cover from A to B case
List<Predicate> criteriaFromTo = new ArrayList<>();
// Special logic to allow for A to B case only
- if (("FromOnly").equals(builder.getSecondNodeType())) {
+ if ((FROM_ONLY).equals(builder.getSecondNodeType())) {
criteriaFromTo.add(buildToFromPart(builder.getFirstNodeType(), null));
} else {
criteriaFromTo.add(buildToFromPart(builder.getFirstNodeType(), builder.getSecondNodeType()));
@@ -176,7 +175,7 @@ public class EdgeRuleQuery {
// will cover from B to A case - must be separate bc jsonpath won't let me OR predicates >:C
List<Predicate> criteriaToFrom = new ArrayList<>();
// Special logic to allow for B to A case only
- if (("ToOnly").equals(builder.getFirstNodeType())) {
+ if ((TO_ONLY).equals(builder.getFirstNodeType())) {
criteriaToFrom.add(buildToFromPart(null, builder.getSecondNodeType()));
} else {
criteriaToFrom.add(buildToFromPart(builder.getSecondNodeType(), builder.getFirstNodeType()));
@@ -192,7 +191,7 @@ public class EdgeRuleQuery {
criteriaFromTo.add(typePred);
criteriaToFrom.add(typePred);
}
- Predicate privatePredicate = where("private").is(String.valueOf(isPrivate));
+ Predicate privatePredicate = Criteria.where("private").is(String.valueOf(isPrivate));
if (isPrivate) {
criteriaFromTo.add(privatePredicate);
@@ -204,12 +203,12 @@ public class EdgeRuleQuery {
criteriaFromTo.add(directionPred);
criteriaToFrom.add(directionPred);
}
- if (("ToOnly").equals(builder.getFirstNodeType())) {
- this.filter = filter(criteriaToFrom);
- } else if (("FromOnly").equals(builder.getSecondNodeType())) {
- this.filter = filter(criteriaFromTo);
+ if ((TO_ONLY).equals(builder.getFirstNodeType())) {
+ this.filter = Filter.filter(criteriaToFrom);
+ } else if ((FROM_ONLY).equals(builder.getSecondNodeType())) {
+ this.filter = Filter.filter(criteriaFromTo);
} else {
- this.filter = filter(criteriaFromTo).or(filter(criteriaToFrom));
+ this.filter = Filter.filter(criteriaFromTo).or(Filter.filter(criteriaToFrom));
}
}
@@ -221,44 +220,44 @@ public class EdgeRuleQuery {
Predicate p;
if (to == null) {
- p = where(EdgeField.FROM.toString()).is(from);
+ p = Criteria.where(EdgeField.FROM.toString()).is(from);
} else if (from == null) {
- p = where(EdgeField.TO.toString()).is(to);
+ p = Criteria.where(EdgeField.TO.toString()).is(to);
} else {
- p = where(EdgeField.FROM.toString()).is(from).and(EdgeField.TO.toString()).is(to);
+ p = Criteria.where(EdgeField.FROM.toString()).is(from).and(EdgeField.TO.toString()).is(to);
}
return p;
}
private Predicate addLabel(String label) {
- return where(EdgeField.LABEL.toString()).is(label);
+ return Criteria.where(EdgeField.LABEL.toString()).is(label);
}
private Predicate addType(EdgeType type) {
if (type == EdgeType.COUSIN) {
- return where(EdgeProperty.CONTAINS.toString()).is(AAIDirection.NONE.toString());
+ return Criteria.where(EdgeProperty.CONTAINS.toString()).is(AAIDirection.NONE.toString());
} else { // equals TREE
- return where(EdgeProperty.CONTAINS.toString()).ne(AAIDirection.NONE.toString());
+ return Criteria.where(EdgeProperty.CONTAINS.toString()).ne(AAIDirection.NONE.toString());
}
}
private Predicate addDirection(AAIDirection direction) {
if (direction == AAIDirection.OUT) {
- return where(EdgeField.DIRECTION.toString()).in(AAIDirection.OUT.toString(), AAIDirection.BOTH.toString());
+ return Criteria.where(EdgeField.DIRECTION.toString()).in(AAIDirection.OUT.toString(), AAIDirection.BOTH.toString());
} else if (direction == AAIDirection.IN) {
- return where(EdgeField.DIRECTION.toString()).in(AAIDirection.IN.toString(), AAIDirection.BOTH.toString());
+ return Criteria.where(EdgeField.DIRECTION.toString()).in(AAIDirection.IN.toString(), AAIDirection.BOTH.toString());
} else if (direction == AAIDirection.BOTH) {
- return where(EdgeField.DIRECTION.toString()).is(AAIDirection.BOTH.toString());
+ return Criteria.where(EdgeField.DIRECTION.toString()).is(AAIDirection.BOTH.toString());
} else if (direction == AAIDirection.NONE) {
- return where(EdgeField.DIRECTION.toString()).is(AAIDirection.NONE.toString());
+ return Criteria.where(EdgeField.DIRECTION.toString()).is(AAIDirection.NONE.toString());
}
- return where(EdgeField.DIRECTION.toString()).is(AAIDirection.NONE.toString());
+ return Criteria.where(EdgeField.DIRECTION.toString()).is(AAIDirection.NONE.toString());
}
/**
* Provides the JsonPath filter for actually querying the edge rule schema files
- *
+ *
* @return Filter
*/
public Filter getFilter() {
@@ -284,7 +283,7 @@ public class EdgeRuleQuery {
/**
* So the Ingestor knows which version of the rules to search
- *
+ *
* @return the Version
*/
public Optional<SchemaVersion> getVersion() {
@@ -315,9 +314,7 @@ public class EdgeRuleQuery {
sb.append(", isPrivate: ");
sb.append(isPrivate);
- if (v.isPresent()) {
- sb.append(", for version: ").append(v.get().toString()).append(".");
- }
+ v.ifPresent(schemaVersion -> sb.append(", for version: ").append(schemaVersion.toString()).append("."));
return sb.toString();
}
@@ -335,11 +332,8 @@ public class EdgeRuleQuery {
@Override
public int hashCode() {
- if (v.isPresent()) {
- return Objects.hash(v.get(), nodeA, nodeB, label, direction, type, isPrivate);
- } else {
- return Objects.hash(nodeA, nodeB, label, direction, type, isPrivate);
- }
+ return v.map(schemaVersion -> Objects.hash(schemaVersion, nodeA, nodeB, label, direction, type, isPrivate))
+ .orElseGet(() -> Objects.hash(nodeA, nodeB, label, direction, type, isPrivate));
}
}