aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorIgor Dysko <igor1.dysko@orange.com>2021-08-10 14:00:45 +0200
committerIgor Dysko <igor1.dysko@orange.com>2021-08-10 14:11:32 +0200
commitf477ac5eafcfc9e1b074a9fea31e7095bbc75697 (patch)
tree2eb785c6ea32f1ffb49dc79c6226eb0082aac461 /src/main/java/org
parent1f2bf6e92830e263d23d891b67a73913f707e903 (diff)
Increase java test coverage
Added new tests, removed unused code. Issue-ID: AAI-3278 Signed-off-by: Igor Dysko <igor1.dysko@orange.com> Change-Id: I046aa25c037850f3aa8a7d3e3d355b88c8f3b3c4
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/aai/graphgraph/App.java3
-rw-r--r--src/main/java/org/onap/aai/graphgraph/ModelExporter.java43
-rw-r--r--src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java2
3 files changed, 3 insertions, 45 deletions
diff --git a/src/main/java/org/onap/aai/graphgraph/App.java b/src/main/java/org/onap/aai/graphgraph/App.java
index 638d3f3..621bd0d 100644
--- a/src/main/java/org/onap/aai/graphgraph/App.java
+++ b/src/main/java/org/onap/aai/graphgraph/App.java
@@ -52,7 +52,8 @@ public class App {
ConfigurableApplicationContext context = app.run(args);
if (parser.shouldGenerateUrl()) {
ModelExporter modelExporter = context.getBean(ModelExporter.class);
- modelExporter.writeExportedModel(modelExporter.exportModel(parser.getSchemaVersion()));
+ String model = modelExporter.exportModel(parser.getSchemaVersion());
+ modelExporter.writeExportedModel(model);
SpringApplication.exit(context);
}
diff --git a/src/main/java/org/onap/aai/graphgraph/ModelExporter.java b/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
index f05c39a..745ffa4 100644
--- a/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
+++ b/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
@@ -20,7 +20,6 @@
package org.onap.aai.graphgraph;
import com.google.common.collect.Multimap;
-import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
@@ -30,9 +29,6 @@ import org.apache.velocity.tools.generic.EscapeTool;
import org.eclipse.jetty.util.StringUtil;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
-import org.onap.aai.edges.enums.DirectionNotation;
-import org.onap.aai.edges.enums.EdgeField;
-import org.onap.aai.edges.enums.MultiplicityRule;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.graphgraph.velocity.VelocityAssociation;
import org.onap.aai.graphgraph.velocity.VelocityEntity;
@@ -50,7 +46,6 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.util.*;
-import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -61,7 +56,6 @@ public class ModelExporter {
private static final String AAIMODEL_UML_FILENAME = "aaimodel.uml";
private static final String VELOCITY_TEMPLATE_FILENAME = "model_export.vm";
- private static final boolean OXM_ENABLED = false;
private static final String CAMEL_CASE_REGEX = "(?=[A-Z][a-z])";
private static final String VELOCITY_ASSOCIATION_NAME_FORMAT = "%s - %s (%s)";
@@ -76,10 +70,6 @@ public class ModelExporter {
private Multimap<String, EdgeRule> getEdgeRules(String schemaVersion) {
try {
Multimap<String, EdgeRule> allRules = edgeIngestor.getAllRules(new SchemaVersion(schemaVersion));
- if (OXM_ENABLED) {
- Map<String, Introspector> allEntities = moxyLoaderRepository.getMoxyLoaders().get(schemaVersion).getAllObjects();
- addOxmRelationships(allRules, allEntities);
- }
return allRules;
} catch (EdgeRuleNotFoundException e) {
@@ -89,39 +79,6 @@ public class ModelExporter {
return null;
}
- private void addOxmRelationships(
- Multimap<String, EdgeRule> allRules,
- Map<String, Introspector> allEntities) {
-
- for (Entry<String, Introspector> currentParent : allEntities.entrySet()) {
- currentParent.getValue().getProperties().stream()
- .filter(allEntities::containsKey)
- .filter(v -> !currentParent.getKey().equals(v))
- .forEach(v -> {
- String key = currentParent.getKey() + "|" + v;
- if (!allRules.containsKey(key)) {
- allRules.put(key, createEdgeRule(currentParent.getKey(), v));
- }
- });
- }
- }
-
- private EdgeRule createEdgeRule(String parent, String child) {
- Map<String, String> edgeRuleProps = new HashMap<>();
- edgeRuleProps.put(EdgeField.FROM.toString(), child);
- edgeRuleProps.put(EdgeField.TO.toString(), parent);
- edgeRuleProps.put(EdgeField.DIRECTION.toString(), Direction.OUT.toString());
- edgeRuleProps.put(EdgeField.LABEL.toString(), "OXM Parent-Child");
- edgeRuleProps.put(EdgeField.MULTIPLICITY.toString(), MultiplicityRule.MANY2ONE.toString());
- edgeRuleProps.put(EdgeField.DEFAULT.toString(), Boolean.toString(false));
- edgeRuleProps.put(EdgeField.PRIVATE.toString(), Boolean.toString(false));
- edgeRuleProps.put(EdgeField.DELETE_OTHER_V.toString(), DirectionNotation.DIRECTION.toString());
- edgeRuleProps.put(EdgeField.PREVENT_DELETE.toString(), DirectionNotation.DIRECTION.toString());
- edgeRuleProps.put(EdgeField.CONTAINS.toString(), DirectionNotation.DIRECTION.toString());
- edgeRuleProps.put(EdgeField.DESCRIPTION.toString(), "fake edgerule representing parent-child");
- return new EdgeRule(edgeRuleProps);
- }
-
public String exportModel(String schemaVersion) {
Map<String, Introspector> allObjects = moxyLoaderRepository.getMoxyLoaders().get(schemaVersion).getAllObjects();
Template t = initVelocity();
diff --git a/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java b/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java
index 203ef13..0cdbd9c 100644
--- a/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java
+++ b/src/main/java/org/onap/aai/graphgraph/reader/BasicSchemaReader.java
@@ -46,7 +46,7 @@ import java.util.stream.Stream;
public class BasicSchemaReader implements SchemaReader {
- private final static Logger LOGGER = LoggerFactory.getLogger(BasicSchemaReader.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(BasicSchemaReader.class);
private Map<String, Introspector> allEntities;
private Graph<String, MetadataEdge> graph = new DefaultDirectedGraph<>(MetadataEdge.class);