summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java1
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/EdgesConfiguration.java11
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java13
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java9
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java1
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/TranslatorConfiguration.java3
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java532
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java370
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRuleQuery.java80
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java13
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/SchemaFilter.java22
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java76
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java69
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java47
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java30
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java20
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java5
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java30
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java8
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeIngestorException.java2
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java8
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/CaseFormatStore.java21
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java79
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/nodes/exceptions/NodeIngestorException.java2
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java50
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java38
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java15
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java135
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java75
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java10
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java216
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java99
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java14
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersion.java28
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java19
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java58
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java50
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java6
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java67
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java17
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java57
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java64
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java17
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java42
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java94
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java73
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java48
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java119
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java103
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java51
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java67
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java111
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java18
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java45
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java160
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java89
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java14
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java53
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleTest.java5
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java27
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java1
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java48
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java117
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java17
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java8
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java224
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java1
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java26
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java23
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java6
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java8
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java8
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java8
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanOverrideTest.java21
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java34
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java5
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java10
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java9
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java16
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java24
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java27
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java33
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java10
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java10
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java9
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java15
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java12
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java10
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java16
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java16
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java17
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/SingleContainmentValidationModuleTest.java8
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/UniqueLabelValidationModuleTest.java16
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java12
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java51
-rw-r--r--aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java13
96 files changed, 2294 insertions, 2201 deletions
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java
index 11f0da6a..e4d18650 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/ConfigConfiguration.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import org.onap.aai.setup.SchemaConfigVersions;
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 605dc0cf..af4d8e8e 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
@@ -19,8 +19,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.setup.Translator;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,11 +37,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
@Import({SchemaServiceConfiguration.class, ConfigConfiguration.class, TranslatorConfiguration.class})
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
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 8c520aaa..a6675d43 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
@@ -19,10 +19,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.Translator;
import org.springframework.beans.factory.annotation.Autowired;
@@ -33,12 +40,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-
@Import({SchemaServiceConfiguration.class, ConfigConfiguration.class, TranslatorConfiguration.class})
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
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 0a3dbf5e..9f523935 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
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import org.onap.aai.restclient.*;
@@ -59,21 +60,21 @@ public class RestConfiguration {
}
/*
- In the below cases bean name and method names are different because all of them qualify as restClient
+ * In the below cases bean name and method names are different because all of them qualify as restClient
*/
- @Bean(name="restClient")
+ @Bean(name = "restClient")
@ConditionalOnProperty(name = "schema.service.client", havingValue = "two-way-ssl", matchIfMissing = true)
public RestClient getSchemaServiceTwoWayClient() {
return new SchemaServiceRestClient();
}
- @Bean(name="restClient")
+ @Bean(name = "restClient")
@ConditionalOnProperty(name = "schema.service.client", havingValue = "no-auth")
public RestClient getSchemaServiceNoAuthClient() {
return new SchemaServiceNoAuthClient();
}
- @Bean(name="restClient")
+ @Bean(name = "restClient")
@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/config/SchemaServiceConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java
index c6decb03..cdd87492 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import org.onap.aai.setup.*;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/TranslatorConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/TranslatorConfiguration.java
index 941e03d9..d49e6ec7 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/TranslatorConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/TranslatorConfiguration.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import org.onap.aai.setup.*;
@@ -29,7 +30,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnProperty(prefix = "schema.translator.list", value = "config", matchIfMissing = true)
public class TranslatorConfiguration {
- //TODO check if you can put dependsOn to reduce number of config files
+ // TODO check if you can put dependsOn to reduce number of config files
@Autowired(required = false)
ConfigTranslator configTranslator;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
index 5d8c3d55..3cf67052 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java
@@ -20,6 +20,9 @@
package org.onap.aai.edges;
+import static com.jayway.jsonpath.Criteria.where;
+import static com.jayway.jsonpath.Filter.filter;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.common.cache.CacheBuilder;
@@ -30,6 +33,15 @@ import com.google.common.collect.Multimap;
import com.jayway.jsonpath.Criteria;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.Filter;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
+
+import javax.annotation.PostConstruct;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.onap.aai.edges.enums.DirectionNotation;
import org.onap.aai.edges.enums.EdgeField;
@@ -42,19 +54,9 @@ import org.onap.aai.setup.Translator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.io.IOException;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ExecutionException;
-import java.util.stream.Collectors;
-
-import static com.jayway.jsonpath.Criteria.where;
-import static com.jayway.jsonpath.Filter.filter;
-
/**
* EdgeIngestor - ingests A&AI edge rule schema files per given config, serves that edge rule
- * information, including allowing various filters to extract particular rules.
+ * information, including allowing various filters to extract particular rules.
*/
@Component
public class EdgeIngestor {
@@ -68,7 +70,7 @@ public class EdgeIngestor {
private Set<String> multipleLabelKeys;
- private LoadingCache<SchemaFilter,Multimap<String,EdgeRule>> cacheFilterStore;
+ private LoadingCache<SchemaFilter, Multimap<String, EdgeRule>> cacheFilterStore;
private LoadingCache<String, String[]> cousinLabelStore;
@@ -82,7 +84,7 @@ public class EdgeIngestor {
@PostConstruct
public void initialize() {
- for (Translator translator : translators) {
+ for (Translator translator : translators) {
try {
LOGGER.debug("Processing the translator");
translateAll(translator);
@@ -92,27 +94,29 @@ public class EdgeIngestor {
throw new ExceptionInInitializerError("EdgeIngestor could not ingest schema");
}
}
- if (versionJsonFilesMap.isEmpty() || schemaVersions==null ) {
+ if (versionJsonFilesMap.isEmpty() || schemaVersions == null) {
throw new ExceptionInInitializerError("EdgeIngestor could not ingest edgerules");
}
}
- public void translateAll(Translator translator) throws ExceptionInInitializerError{
+ public void translateAll(Translator translator) throws ExceptionInInitializerError {
/*
- Use SchemaVersions from the Translator
+ * Use SchemaVersions from the Translator
*/
this.schemaVersions = translator.getSchemaVersions();
List<SchemaVersion> schemaVersionList = this.schemaVersions.getVersions();
List<String> jsonPayloads = null;
JsonIngestor ji = new JsonIngestor();
- Map<SchemaVersion, List<String>> edgeRulesToIngest = new HashMap<>(); // Obtain a map of schema versions to a list of strings. One List per key
+ Map<SchemaVersion, List<String>> edgeRulesToIngest = new HashMap<>(); // Obtain a map of schema versions to a
+ // list of strings. One List per key
// Add to the map the JSON file per version.
for (SchemaVersion version : schemaVersionList) {
LOGGER.debug("Version being processed" + version);
// If the flag is set to not use the local files, obtain the Json from the service.
try {
- jsonPayloads = translator.getJsonPayload(version); // need to change this - need to receive the json files.
+ jsonPayloads = translator.getJsonPayload(version); // need to change this - need to receive the json
+ // files.
} catch (IOException e) {
LOGGER.error("Error in retrieving the JSON Payload" + e.getMessage());
throw new ExceptionInInitializerError("EdgeIngestor could not ingest schema");
@@ -125,43 +129,36 @@ public class EdgeIngestor {
}
versionJsonFilesMap = ji.ingestContent(edgeRulesToIngest);
- this.cacheFilterStore = CacheBuilder.newBuilder()
- .maximumSize(2000)
- .build(
- new CacheLoader<SchemaFilter, Multimap<String, EdgeRule>>() {
+ this.cacheFilterStore = CacheBuilder.newBuilder().maximumSize(2000)
+ .build(new CacheLoader<SchemaFilter, Multimap<String, EdgeRule>>() {
@Override
public Multimap<String, EdgeRule> load(SchemaFilter key) {
return extractRules(key);
}
- }
- );
+ });
- this.cousinLabelStore = CacheBuilder.newBuilder()
- .maximumSize(50)
- .build(
- new CacheLoader<String, String[]>() {
- @Override
- public String[] load(String key) throws Exception {
- return retrieveCousinLabels(key);
- }
- }
- );
+ this.cousinLabelStore = CacheBuilder.newBuilder().maximumSize(50).build(new CacheLoader<String, String[]>() {
+ @Override
+ public String[] load(String key) throws Exception {
+ return retrieveCousinLabels(key);
+ }
+ });
}
-// //-----methods for getting rule info-----//
-//
+ // //-----methods for getting rule info-----//
+ //
/**
* Gets list of all edge rules defined in the latest version's schema
*
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules associated with those types
- * where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
- *
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
* @throws EdgeRuleNotFoundException if none found
*/
public Multimap<String, EdgeRule> getAllCurrentRules() throws EdgeRuleNotFoundException {
@@ -173,22 +170,22 @@ public class EdgeIngestor {
*
* A lazy instantiation to retrieve all this info on first call
*
- * @return a set containing a list of strings where each string is
- * concatenated by a pipe (|) character such as aNodeType|bNodeType
+ * @return a set containing a list of strings where each string is
+ * concatenated by a pipe (|) character such as aNodeType|bNodeType
*/
- public Set<String> getMultipleLabelKeys(){
+ public Set<String> getMultipleLabelKeys() {
- if(multipleLabelKeys == null){
+ if (multipleLabelKeys == null) {
multipleLabelKeys = new HashSet<>();
try {
final Multimap<String, EdgeRule> edges = this.getAllCurrentRules();
- if(edges == null || edges.isEmpty()){
+ if (edges == null || edges.isEmpty()) {
LOGGER.warn("Unable to find any edge rules for the latest version");
return multipleLabelKeys;
}
edges.keySet().forEach(key -> {
Collection<EdgeRule> rules = edges.get(key);
- if(rules.size() > 1){
+ if (rules.size() > 1) {
multipleLabelKeys.add(key);
}
});
@@ -199,18 +196,19 @@ public class EdgeIngestor {
return multipleLabelKeys;
}
+
/**
* Gets list of all edge rules defined in the given version's schema
*
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules associated with those types
- * where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
- *
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
* @throws EdgeRuleNotFoundException if none found
*/
public Multimap<String, EdgeRule> getAllRules(SchemaVersion v) throws EdgeRuleNotFoundException {
@@ -229,19 +227,19 @@ public class EdgeIngestor {
* @param q - EdgeRuleQuery with filter criteria set
*
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
* @throws EdgeRuleNotFoundException if none found
*/
public Multimap<String, EdgeRule> getRules(EdgeRuleQuery q) throws EdgeRuleNotFoundException {
Multimap<String, EdgeRule> found = null;
- if(q.getVersion().isPresent()){
+ if (q.getVersion().isPresent()) {
found = extractRules(q.getFilter(), q.getVersion().get());
} else {
found = extractRules(q.getFilter(), schemaVersions.getDefaultVersion());
@@ -253,7 +251,8 @@ public class EdgeIngestor {
found.entries().stream().forEach((entry) -> {
EdgeRule rule = new EdgeRule(entry.getValue());
if (!q.getFromType().equals(rule.getFrom())) {
- /* To maintain backwards compatibility with old EdgeRules API,
+ /*
+ * To maintain backwards compatibility with old EdgeRules API,
* where the direction of the returned EdgeRule would be
* flipped (if necessary) to match the directionality of
* the input params.
@@ -270,8 +269,6 @@ public class EdgeIngestor {
}
}
-
-
/**
* Gets the rule satisfying the given filter criteria. If there are more than one
* that match, return the default rule. If there is no clear default to return, or
@@ -281,16 +278,16 @@ public class EdgeIngestor {
* @return EdgeRule satisfying given criteria
* @throws EdgeRuleNotFoundException if none found that match
* @throws AmbiguousRuleChoiceException if multiple match but no way to choice one from them
- * Specifically, if multiple node type pairs come back (ie bar|foo and asdf|foo,
- * no way to know which is appropriate over the others),
- * or if there is a mix of Tree and Cousin edges because again there is no way to
- * know which is "defaulter" than the other.
- * The default property only clarifies among multiple cousin edges of the same node pair,
- * ex: which l-interface|logical-link rule to default to.
+ * Specifically, if multiple node type pairs come back (ie bar|foo and asdf|foo,
+ * no way to know which is appropriate over the others),
+ * or if there is a mix of Tree and Cousin edges because again there is no way to
+ * know which is "defaulter" than the other.
+ * The default property only clarifies among multiple cousin edges of the same node pair,
+ * ex: which l-interface|logical-link rule to default to.
*/
public EdgeRule getRule(EdgeRuleQuery q) throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
Multimap<String, EdgeRule> found = null;
- if(q.getVersion().isPresent()){
+ if (q.getVersion().isPresent()) {
found = extractRules(q.getFilter(), q.getVersion().get());
} else {
found = extractRules(q.getFilter(), schemaVersions.getDefaultVersion());
@@ -301,7 +298,7 @@ public class EdgeIngestor {
}
EdgeRule rule = null;
- if (found.keys().size() == 1) { //only one found, cool we're done
+ if (found.keys().size() == 1) { // only one found, cool we're done
for (Entry<String, EdgeRule> e : found.entries()) {
rule = e.getValue();
}
@@ -309,12 +306,13 @@ public class EdgeIngestor {
rule = getDefaultRule(found);
}
- if (rule == null) { //should never get here though
+ if (rule == null) { // should never get here though
throw new EdgeRuleNotFoundException("No rule found for " + q.toString() + ".");
} else {
rule = new EdgeRule(rule);
if (!q.getFromType().equals(rule.getFrom())) {
- /* To maintain backwards compatibility with old EdgeRules API,
+ /*
+ * To maintain backwards compatibility with old EdgeRules API,
* where the direction of the returned EdgeRule would be
* flipped (if necessary) to match the directionality of
* the input params.
@@ -329,12 +327,13 @@ public class EdgeIngestor {
}
private EdgeRule getDefaultRule(Multimap<String, EdgeRule> found) throws AmbiguousRuleChoiceException {
- if (found.keySet().size() > 1) { //ie multiple node pairs (a|c and b|c not just all a|c) case
+ if (found.keySet().size() > 1) { // ie multiple node pairs (a|c and b|c not just all a|c) case
StringBuilder sb = new StringBuilder();
for (String k : found.keySet()) {
sb.append(k).append(" ");
}
- throw new AmbiguousRuleChoiceException("No way to select single rule from these pairs: " + sb.toString() + ".");
+ throw new AmbiguousRuleChoiceException(
+ "No way to select single rule from these pairs: " + sb.toString() + ".");
}
int defaultCount = 0;
@@ -354,6 +353,7 @@ public class EdgeIngestor {
return defRule;
}
+
/**
* Checks if there exists any rule that satisfies the given filter criteria.
*
@@ -361,7 +361,7 @@ public class EdgeIngestor {
* @return boolean
*/
public boolean hasRule(EdgeRuleQuery q) {
- if(q.getVersion().isPresent()){
+ if (q.getVersion().isPresent()) {
return !extractRules(q.getFilter(), q.getVersion().get()).isEmpty();
} else {
return !extractRules(q.getFilter(), schemaVersions.getDefaultVersion()).isEmpty();
@@ -373,28 +373,25 @@ public class EdgeIngestor {
*
* @param nodeType
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
public Multimap<String, EdgeRule> getCousinRules(String nodeType) {
- return getCousinRules(nodeType, schemaVersions.getDefaultVersion()); //default to latest
+ return getCousinRules(nodeType, schemaVersions.getDefaultVersion()); // default to latest
}
- public String[] retrieveCousinLabels(String nodeType){
+ public String[] retrieveCousinLabels(String nodeType) {
Multimap<String, EdgeRule> cousinRules = getCousinRules(nodeType);
String[] cousinLabels = new String[cousinRules.size()];
- return cousinRules.entries()
- .stream()
- .map(entry -> entry.getValue().getLabel())
- .collect(Collectors.toList())
- .toArray(cousinLabels);
+ return cousinRules.entries().stream().map(entry -> entry.getValue().getLabel()).collect(Collectors.toList())
+ .toArray(cousinLabels);
}
public String[] retrieveCachedCousinLabels(String nodeType) throws ExecutionException {
@@ -407,13 +404,13 @@ public class EdgeIngestor {
* @param nodeType
* @param v - the version of the edge rules to query
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
public Multimap<String, EdgeRule> getCousinRules(String nodeType, SchemaVersion v) {
return extractRules(new EdgeRuleQuery.Builder(nodeType).edgeType(EdgeType.COUSIN).build().getFilter(), v);
@@ -421,6 +418,7 @@ public class EdgeIngestor {
/**
* Returns if the given node type has any cousin relationships in the current version.
+ *
* @param nodeType
* @return boolean
*/
@@ -430,6 +428,7 @@ public class EdgeIngestor {
/**
* Returns if the given node type has any cousin relationships in the given version.
+ *
* @param nodeType
* @return boolean
*/
@@ -442,13 +441,13 @@ public class EdgeIngestor {
*
* @param nodeType - node type that is the container in the returned relationships
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
public Multimap<String, EdgeRule> getChildRules(String nodeType) {
return getChildRules(nodeType, schemaVersions.getDefaultVersion());
@@ -459,24 +458,28 @@ public class EdgeIngestor {
*
* @param nodeType - node type that is the container in the returned relationships
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
public Multimap<String, EdgeRule> getChildRules(String nodeType, SchemaVersion v) {
- Filter from = assembleFilterSegments(where(EdgeField.FROM.toString()).is(nodeType), getSameDirectionContainmentCriteria());
- Filter to = assembleFilterSegments(where(EdgeField.TO.toString()).is(nodeType), getOppositeDirectionContainmentCriteria());
+ Filter from = assembleFilterSegments(where(EdgeField.FROM.toString()).is(nodeType),
+ getSameDirectionContainmentCriteria());
+ Filter to = assembleFilterSegments(where(EdgeField.TO.toString()).is(nodeType),
+ getOppositeDirectionContainmentCriteria());
Filter total = from.or(to);
return extractRules(total, v);
}
/**
- * Returns if the given node type has any child relationships (ie it contains another node type) in the current version.
+ * Returns if the given node type has any child relationships (ie it contains another node type) in the current
+ * version.
+ *
* @param nodeType
* @return boolean
*/
@@ -485,7 +488,9 @@ public class EdgeIngestor {
}
/**
- * Returns if the given node type has any child relationships (ie it contains another node type) in the given version.
+ * Returns if the given node type has any child relationships (ie it contains another node type) in the given
+ * version.
+ *
* @param nodeType
* @return boolean
*/
@@ -498,13 +503,13 @@ public class EdgeIngestor {
*
* @param nodeType - node type that is the containee in the returned relationships
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
public Multimap<String, EdgeRule> getParentRules(String nodeType) {
return getParentRules(nodeType, schemaVersions.getDefaultVersion());
@@ -515,24 +520,28 @@ public class EdgeIngestor {
*
* @param nodeType - node type that is the containee in the returned relationships
* @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
*
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
*/
public Multimap<String, EdgeRule> getParentRules(String nodeType, SchemaVersion v) {
- Filter from = assembleFilterSegments(where(EdgeField.FROM.toString()).is(nodeType), getOppositeDirectionContainmentCriteria());
- Filter to = assembleFilterSegments(where(EdgeField.TO.toString()).is(nodeType), getSameDirectionContainmentCriteria());
+ Filter from = assembleFilterSegments(where(EdgeField.FROM.toString()).is(nodeType),
+ getOppositeDirectionContainmentCriteria());
+ Filter to = assembleFilterSegments(where(EdgeField.TO.toString()).is(nodeType),
+ getSameDirectionContainmentCriteria());
Filter total = from.or(to);
return extractRules(total, v);
}
/**
- * Returns if the given node type has any parent relationships (ie it is contained by another node type) in the current version.
+ * Returns if the given node type has any parent relationships (ie it is contained by another node type) in the
+ * current version.
+ *
* @param nodeType
* @return boolean
*/
@@ -541,7 +550,9 @@ public class EdgeIngestor {
}
/**
- * Returns if the given node type has any parent relationships (ie it is contained by another node type) in the given version.
+ * Returns if the given node type has any parent relationships (ie it is contained by another node type) in the
+ * given version.
+ *
* @param nodeType
* @return boolean
*/
@@ -549,22 +560,22 @@ public class EdgeIngestor {
return !getParentRules(nodeType, v).isEmpty();
}
- /**
- * Applies the given filter to the DocumentContext(s) for the given version to extract
- * edge rules, and converts this extracted information into the Multimap form
- *
- * @param filter - JsonPath filter to read the DocumentContexts with. May be null
- * to denote no filter, ie get all.
- * @param v - The schema version to extract from
- * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
- * no rules are found.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
- *
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
- */
+ /**
+ * Applies the given filter to the DocumentContext(s) for the given version to extract
+ * edge rules, and converts this extracted information into the Multimap form
+ *
+ * @param filter - JsonPath filter to read the DocumentContexts with. May be null
+ * to denote no filter, ie get all.
+ * @param v - The schema version to extract from
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Map will be empty if
+ * no rules are found.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
private Multimap<String, EdgeRule> extractRules(Filter filter, SchemaVersion v) {
SchemaFilter schemaFilter = new SchemaFilter(filter, v);
try {
@@ -575,7 +586,7 @@ public class EdgeIngestor {
}
}
- public Multimap<String, EdgeRule> extractRules(SchemaFilter schemaFilter){
+ public Multimap<String, EdgeRule> extractRules(SchemaFilter schemaFilter) {
List<Map<String, String>> foundRules = new ArrayList<>();
List<DocumentContext> docs = versionJsonFilesMap.get(schemaFilter.getSchemaVersion());
if (docs != null) {
@@ -591,115 +602,118 @@ public class EdgeIngestor {
return convertToEdgeRules(foundRules);
}
- //-----filter building helpers-----//
- /**
- * ANDs together the given start criteria with each criteria in the pieces list, and
- * then ORs together these segments into one filter.
- *
- * JsonPath doesn't have an OR method on Criteria, only on Filters, so assembling
- * a complete filter requires this sort of roundabout construction.
- *
- * @param start - Criteria of the form where(from/to).is(nodeType)
- * (ie the start of any A&AI edge rule query)
- * @param pieces - Other Criteria to be applied
- * @return Filter constructed from the given Criteria
- */
- private Filter assembleFilterSegments(Criteria start, List<Criteria> pieces) {
- List<Filter> segments = new ArrayList<>();
- for (Criteria c : pieces) {
- segments.add(filter(start).and(c));
- }
- Filter assembled = segments.remove(0);
- for (Filter f : segments) {
- assembled = assembled.or(f);
- }
- return assembled;
- }
-
- /**
- * Builds the sub-Criteria for a containment edge rule query where the direction
- * and containment fields must match.
- *
- * Used for getChildRules() where the container node type is in the "from" position and
- * for getParentRules() where the containee type is in the "to" position.
- *
- * @return List<Criteria> covering property permutations defined with either notation or explicit direction
- */
- private List<Criteria> getSameDirectionContainmentCriteria() {
- List<Criteria> crits = new ArrayList<>();
-
- crits.add(where(EdgeField.CONTAINS.toString()).is(DirectionNotation.DIRECTION.toString()));
-
- crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.OUT.toString())
- .and(EdgeField.CONTAINS.toString()).is(Direction.OUT.toString()));
-
- crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.IN.toString())
- .and(EdgeField.CONTAINS.toString()).is(Direction.IN.toString()));
-
- return crits;
- }
-
- /**
- * Builds the sub-Criteria for a containment edge rule query where the direction
- * and containment fields must not match.
- *
- * Used for getChildRules() where the container node type is in the "to" position and
- * for getParentRules() where the containee type is in the "from" position.
- *
- * @return List<Criteria> covering property permutations defined with either notation or explicit direction
- */
- private List<Criteria> getOppositeDirectionContainmentCriteria() {
- List<Criteria> crits = new ArrayList<>();
-
- crits.add(where(EdgeField.CONTAINS.toString()).is(DirectionNotation.OPPOSITE.toString()));
-
- crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.OUT.toString())
- .and(EdgeField.CONTAINS.toString()).is(Direction.IN.toString()));
-
- crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.IN.toString())
- .and(EdgeField.CONTAINS.toString()).is(Direction.OUT.toString()));
-
- return crits;
- }
-
- //-----rule packaging helpers-----//
- /**
- * Converts the raw output from reading the json file to the Multimap<String key, EdgeRule> format
- *
- * @param allFound - raw edge rule output read from json file(s)
- * (could be empty if none found)
- * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
- * {alphabetically first nodetype}|{alphabetically second nodetype}. Will be empty if input
- * was empty.
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
- *
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
- */
- private Multimap<String, EdgeRule> convertToEdgeRules(List<Map<String, String>> allFound) {
- Multimap<String, EdgeRule> rules = ArrayListMultimap.create();
-
- TypeAlphabetizer alpher = new TypeAlphabetizer();
-
- for (Map<String, String> raw : allFound) {
- EdgeRule converted = new EdgeRule(raw);
- if (converted.getFrom().equals(converted.getTo())) {
- /* the way the code worked in the past was with outs and
- * when we switched it to in the same-node-type to
- * same-node-type parent child edges were failing because all
- * of the calling code would pass the parent as the left argument,
- * so it was either in that method swap the parent/child,
- * flip the edge rule or make all callers swap. the last seemed
- * like a bad idea. and felt like the edge flip was the better
- * of the remaining 2 */
- converted.flipDirection();
- }
- String alphabetizedKey = alpher.buildAlphabetizedKey(raw.get(EdgeField.FROM.toString()), raw.get(EdgeField.TO.toString()));
- rules.put(alphabetizedKey, converted);
- }
-
- return rules;
- }
+ // -----filter building helpers-----//
+ /**
+ * ANDs together the given start criteria with each criteria in the pieces list, and
+ * then ORs together these segments into one filter.
+ *
+ * JsonPath doesn't have an OR method on Criteria, only on Filters, so assembling
+ * a complete filter requires this sort of roundabout construction.
+ *
+ * @param start - Criteria of the form where(from/to).is(nodeType)
+ * (ie the start of any A&AI edge rule query)
+ * @param pieces - Other Criteria to be applied
+ * @return Filter constructed from the given Criteria
+ */
+ private Filter assembleFilterSegments(Criteria start, List<Criteria> pieces) {
+ List<Filter> segments = new ArrayList<>();
+ for (Criteria c : pieces) {
+ segments.add(filter(start).and(c));
+ }
+ Filter assembled = segments.remove(0);
+ for (Filter f : segments) {
+ assembled = assembled.or(f);
+ }
+ return assembled;
+ }
+
+ /**
+ * Builds the sub-Criteria for a containment edge rule query where the direction
+ * and containment fields must match.
+ *
+ * Used for getChildRules() where the container node type is in the "from" position and
+ * for getParentRules() where the containee type is in the "to" position.
+ *
+ * @return List<Criteria> covering property permutations defined with either notation or explicit direction
+ */
+ private List<Criteria> getSameDirectionContainmentCriteria() {
+ List<Criteria> crits = new ArrayList<>();
+
+ crits.add(where(EdgeField.CONTAINS.toString()).is(DirectionNotation.DIRECTION.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.OUT.toString()).and(EdgeField.CONTAINS.toString())
+ .is(Direction.OUT.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.IN.toString()).and(EdgeField.CONTAINS.toString())
+ .is(Direction.IN.toString()));
+
+ return crits;
+ }
+
+ /**
+ * Builds the sub-Criteria for a containment edge rule query where the direction
+ * and containment fields must not match.
+ *
+ * Used for getChildRules() where the container node type is in the "to" position and
+ * for getParentRules() where the containee type is in the "from" position.
+ *
+ * @return List<Criteria> covering property permutations defined with either notation or explicit direction
+ */
+ private List<Criteria> getOppositeDirectionContainmentCriteria() {
+ List<Criteria> crits = new ArrayList<>();
+
+ crits.add(where(EdgeField.CONTAINS.toString()).is(DirectionNotation.OPPOSITE.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.OUT.toString()).and(EdgeField.CONTAINS.toString())
+ .is(Direction.IN.toString()));
+
+ crits.add(where(EdgeField.DIRECTION.toString()).is(Direction.IN.toString()).and(EdgeField.CONTAINS.toString())
+ .is(Direction.OUT.toString()));
+
+ return crits;
+ }
+
+ // -----rule packaging helpers-----//
+ /**
+ * Converts the raw output from reading the json file to the Multimap<String key, EdgeRule> format
+ *
+ * @param allFound - raw edge rule output read from json file(s)
+ * (could be empty if none found)
+ * @return Multimap<String, EdgeRule> of node names keys to the EdgeRules where the key takes the form of
+ * {alphabetically first nodetype}|{alphabetically second nodetype}. Will be empty if input
+ * was empty.
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ private Multimap<String, EdgeRule> convertToEdgeRules(List<Map<String, String>> allFound) {
+ Multimap<String, EdgeRule> rules = ArrayListMultimap.create();
+
+ TypeAlphabetizer alpher = new TypeAlphabetizer();
+
+ for (Map<String, String> raw : allFound) {
+ EdgeRule converted = new EdgeRule(raw);
+ if (converted.getFrom().equals(converted.getTo())) {
+ /*
+ * the way the code worked in the past was with outs and
+ * when we switched it to in the same-node-type to
+ * same-node-type parent child edges were failing because all
+ * of the calling code would pass the parent as the left argument,
+ * so it was either in that method swap the parent/child,
+ * flip the edge rule or make all callers swap. the last seemed
+ * like a bad idea. and felt like the edge flip was the better
+ * of the remaining 2
+ */
+ converted.flipDirection();
+ }
+ String alphabetizedKey =
+ alpher.buildAlphabetizedKey(raw.get(EdgeField.FROM.toString()), raw.get(EdgeField.TO.toString()));
+ rules.put(alphabetizedKey, converted);
+ }
+
+ return rules;
+ }
}
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 f8f8caca..d3c9a599 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
@@ -17,211 +17,215 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.edges;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.onap.aai.edges.enums.*;
+package org.onap.aai.edges;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.onap.aai.edges.enums.*;
+
/**
* Container for A&AI edge rule information
*/
public class EdgeRule {
- private String from;
- private String to;
- private String label;
- private Direction direction;
- private MultiplicityRule multiplicityRule;
- private Map<EdgeProperty, AAIDirection> edgeFields;
- private boolean isDefaultEdge;
- private String description;
- private boolean isPrivateEdge = false;
-
- /**
- * Instantiates a new edge rule.
- *
- * @param fieldVals - Map<String, String> where first string is
- * an EdgeField value and second string is the
- * value of that field
- */
- public EdgeRule(Map<String, String> fieldVals) {
- edgeFields = new EnumMap<>(EdgeProperty.class);
-
- from = fieldVals.get(EdgeField.FROM.toString());
- to = fieldVals.get(EdgeField.TO.toString());
- label = fieldVals.get(EdgeField.LABEL.toString());
- direction = Direction.valueOf(fieldVals.get(EdgeField.DIRECTION.toString()));
- multiplicityRule = MultiplicityRule.getValue(fieldVals.get(EdgeField.MULTIPLICITY.toString()));
- isPrivateEdge = Boolean.valueOf(fieldVals.getOrDefault(EdgeField.PRIVATE.toString(), "false"));
+ private String from;
+ private String to;
+ private String label;
+ private Direction direction;
+ private MultiplicityRule multiplicityRule;
+ private Map<EdgeProperty, AAIDirection> edgeFields;
+ private boolean isDefaultEdge;
+ private String description;
+ private boolean isPrivateEdge = false;
+
+ /**
+ * Instantiates a new edge rule.
+ *
+ * @param fieldVals - Map<String, String> where first string is
+ * an EdgeField value and second string is the
+ * value of that field
+ */
+ public EdgeRule(Map<String, String> fieldVals) {
+ edgeFields = new EnumMap<>(EdgeProperty.class);
+
+ from = fieldVals.get(EdgeField.FROM.toString());
+ to = fieldVals.get(EdgeField.TO.toString());
+ label = fieldVals.get(EdgeField.LABEL.toString());
+ direction = Direction.valueOf(fieldVals.get(EdgeField.DIRECTION.toString()));
+ multiplicityRule = MultiplicityRule.getValue(fieldVals.get(EdgeField.MULTIPLICITY.toString()));
+ isPrivateEdge = Boolean.valueOf(fieldVals.getOrDefault(EdgeField.PRIVATE.toString(), "false"));
for (EdgeProperty prop : EdgeProperty.values()) {
- String rawVal = fieldVals.get(prop.toString());
- edgeFields.put(prop, convertNotation(direction, rawVal));
- }
-
- isDefaultEdge = Boolean.valueOf(fieldVals.get(EdgeField.DEFAULT.toString()));
+ String rawVal = fieldVals.get(prop.toString());
+ edgeFields.put(prop, convertNotation(direction, rawVal));
+ }
+
+ isDefaultEdge = Boolean.valueOf(fieldVals.get(EdgeField.DEFAULT.toString()));
description = fieldVals.get(EdgeField.DESCRIPTION.toString());
- if (description == null) { //bc description is optional and not in v12 and earlier
- description = "";
- }
- }
+ if (description == null) { // bc description is optional and not in v12 and earlier
+ description = "";
+ }
+ }
// Copy Constructor
- public EdgeRule(EdgeRule edgeRule){
+ public EdgeRule(EdgeRule edgeRule) {
this.from = edgeRule.from;
- this.to = edgeRule.to;
+ this.to = edgeRule.to;
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.isDefaultEdge = edgeRule.isDefaultEdge;
+ this.isDefaultEdge = edgeRule.isDefaultEdge;
this.description = edgeRule.description;
this.isPrivateEdge = edgeRule.isPrivateEdge;
}
- /**
- * Converts whatever string was in the json for an edge property value into
- * the appropriate AAIDirection
- *
- * @param Direction dir - the edge direction
- * @param String rawVal - property value from the json, may be
- * IN, OUT, BOTH, NONE, ${direction}, or !${direction}
- * @return AAIDirection - IN/OUT/BOTH/NONE if that's the rawVal, or
- * translates the direction notation into the correct IN/OUT
- */
- private AAIDirection convertNotation(Direction dir, String rawVal) {
- if (AAIDirection.NONE.toString().equalsIgnoreCase(rawVal)) {
- return AAIDirection.NONE;
- } else if (AAIDirection.BOTH.toString().equalsIgnoreCase(rawVal)) {
- return AAIDirection.BOTH;
- } else if (AAIDirection.OUT.toString().equalsIgnoreCase(rawVal)) {
- return AAIDirection.OUT;
- } else if (AAIDirection.IN.toString().equalsIgnoreCase(rawVal)) {
- return AAIDirection.IN;
- }
-
- DirectionNotation rawDN = DirectionNotation.getValue(rawVal);
- if (DirectionNotation.DIRECTION.equals(rawDN)) {
- return AAIDirection.getValue(dir);
- } else {
- return AAIDirection.getValue(dir.opposite());
- }
- }
-
- /**
- * Gets the name of the node type in the "from" field
- * @return String nodetype
- */
- public String getFrom() {
- return from;
- }
-
- /**
- * Gets the name of the node type in the "to" field
- * @return String nodetype
- */
- public String getTo() {
- return to;
- }
-
- /**
- * Gets the edge label
- *
- * @return String label
- */
- public String getLabel() {
- return label;
- }
-
- /**
- * Gets the multiplicity rule.
- *
- * @return MultiplicityRule
- */
- public MultiplicityRule getMultiplicityRule() {
- return multiplicityRule;
- }
-
- /**
- * Gets the edge direction
- *
- * @return Direction
- */
- public Direction getDirection() {
- return direction;
- }
-
- /**
- * Gets the value of contains-other-v
- *
- * @return the value of contains-other-v
- */
- public String getContains() {
- return edgeFields.get(EdgeProperty.CONTAINS).toString();
- }
-
- /**
- * Gets the value of delete-other-v
- *
- * @return the value of delete-other-v
- */
- public String getDeleteOtherV() {
- return edgeFields.get(EdgeProperty.DELETE_OTHER_V).toString();
- }
-
- /**
- * Gets the value of the prevent-delete property
- *
- * @return String prevent-delete property value
- */
- public String getPreventDelete() {
- return edgeFields.get(EdgeProperty.PREVENT_DELETE).toString();
- }
-
- /**
- * Returns if this rule is a default or not
- *
- * @return boolean
- */
- public boolean isDefault() {
- return isDefaultEdge;
- }
-
- /**
- * Gets the description on the edge rule (if there is one)
- * @return String description
- */
- public String getDescription() {
- return this.description;
- }
-
- /**
- * Flips the direction value
- * IN -> OUT
- * OUT -> IN
- * BOTH -> BOTH
- */
- public void flipDirection() {
- if (Direction.OUT.equals(direction)) {
- direction = Direction.IN;
- } else if (Direction.IN.equals(direction)) {
- direction = Direction.OUT;
- }
- //else BOTH just stays the same
- }
-
- public boolean isPrivateEdge() {
- return isPrivateEdge;
- }
-
- public void setPrivateEdge(boolean privateEdge) {
- isPrivateEdge = privateEdge;
- }
-
- public void setPrivateEdge(String isPrivateEdge){
- this.isPrivateEdge = "true".equals(isPrivateEdge);
- }
+ /**
+ * Converts whatever string was in the json for an edge property value into
+ * the appropriate AAIDirection
+ *
+ * @param Direction dir - the edge direction
+ * @param String rawVal - property value from the json, may be
+ * IN, OUT, BOTH, NONE, ${direction}, or !${direction}
+ * @return AAIDirection - IN/OUT/BOTH/NONE if that's the rawVal, or
+ * translates the direction notation into the correct IN/OUT
+ */
+ private AAIDirection convertNotation(Direction dir, String rawVal) {
+ if (AAIDirection.NONE.toString().equalsIgnoreCase(rawVal)) {
+ return AAIDirection.NONE;
+ } else if (AAIDirection.BOTH.toString().equalsIgnoreCase(rawVal)) {
+ return AAIDirection.BOTH;
+ } else if (AAIDirection.OUT.toString().equalsIgnoreCase(rawVal)) {
+ return AAIDirection.OUT;
+ } else if (AAIDirection.IN.toString().equalsIgnoreCase(rawVal)) {
+ return AAIDirection.IN;
+ }
+
+ DirectionNotation rawDN = DirectionNotation.getValue(rawVal);
+ if (DirectionNotation.DIRECTION.equals(rawDN)) {
+ return AAIDirection.getValue(dir);
+ } else {
+ return AAIDirection.getValue(dir.opposite());
+ }
+ }
+
+ /**
+ * Gets the name of the node type in the "from" field
+ *
+ * @return String nodetype
+ */
+ public String getFrom() {
+ return from;
+ }
+
+ /**
+ * Gets the name of the node type in the "to" field
+ *
+ * @return String nodetype
+ */
+ public String getTo() {
+ return to;
+ }
+
+ /**
+ * Gets the edge label
+ *
+ * @return String label
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * Gets the multiplicity rule.
+ *
+ * @return MultiplicityRule
+ */
+ public MultiplicityRule getMultiplicityRule() {
+ return multiplicityRule;
+ }
+
+ /**
+ * Gets the edge direction
+ *
+ * @return Direction
+ */
+ public Direction getDirection() {
+ return direction;
+ }
+
+ /**
+ * Gets the value of contains-other-v
+ *
+ * @return the value of contains-other-v
+ */
+ public String getContains() {
+ return edgeFields.get(EdgeProperty.CONTAINS).toString();
+ }
+
+ /**
+ * Gets the value of delete-other-v
+ *
+ * @return the value of delete-other-v
+ */
+ public String getDeleteOtherV() {
+ return edgeFields.get(EdgeProperty.DELETE_OTHER_V).toString();
+ }
+
+ /**
+ * Gets the value of the prevent-delete property
+ *
+ * @return String prevent-delete property value
+ */
+ public String getPreventDelete() {
+ return edgeFields.get(EdgeProperty.PREVENT_DELETE).toString();
+ }
+
+ /**
+ * Returns if this rule is a default or not
+ *
+ * @return boolean
+ */
+ public boolean isDefault() {
+ return isDefaultEdge;
+ }
+
+ /**
+ * Gets the description on the edge rule (if there is one)
+ *
+ * @return String description
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Flips the direction value
+ * IN -> OUT
+ * OUT -> IN
+ * BOTH -> BOTH
+ */
+ public void flipDirection() {
+ if (Direction.OUT.equals(direction)) {
+ direction = Direction.IN;
+ } else if (Direction.IN.equals(direction)) {
+ direction = Direction.OUT;
+ }
+ // else BOTH just stays the same
+ }
+
+ public boolean isPrivateEdge() {
+ return isPrivateEdge;
+ }
+
+ public void setPrivateEdge(boolean privateEdge) {
+ isPrivateEdge = privateEdge;
+ }
+
+ public void setPrivateEdge(String isPrivateEdge) {
+ this.isPrivateEdge = "true".equals(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 c25fc789..fc58dbb6 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,24 +22,23 @@
package org.onap.aai.edges;
-import org.apache.commons.lang.StringUtils;
-import org.onap.aai.edges.enums.AAIDirection;
-import org.onap.aai.edges.enums.EdgeField;
-import org.onap.aai.edges.enums.EdgeProperty;
-import org.onap.aai.edges.enums.EdgeType;
-import org.onap.aai.setup.SchemaVersion;
+import static com.jayway.jsonpath.Criteria.where;
+import static com.jayway.jsonpath.Filter.filter;
import com.jayway.jsonpath.Filter;
import com.jayway.jsonpath.Predicate;
-import static com.jayway.jsonpath.Filter.filter;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
-import static com.jayway.jsonpath.Criteria.where;
+import org.apache.commons.lang.StringUtils;
+import org.onap.aai.edges.enums.AAIDirection;
+import org.onap.aai.edges.enums.EdgeField;
+import org.onap.aai.edges.enums.EdgeProperty;
+import org.onap.aai.edges.enums.EdgeType;
+import org.onap.aai.setup.SchemaVersion;
/**
* For querying the edge rules schema (not the database)
@@ -60,10 +59,10 @@ public class EdgeRuleQuery {
private static final String FROM_ONLY = "FromOnly";
- //required
+ // required
private String nodeA;
- //optional - null will translate to any value of the param
+ // optional - null will translate to any value of the param
private String nodeB = null;
private String label = null;
private EdgeType type = null;
@@ -83,6 +82,7 @@ public class EdgeRuleQuery {
private String getFirstNodeType() {
return nodeA;
}
+
public Builder fromOnly() {
this.nodeB = FROM_ONLY;
return this;
@@ -92,15 +92,15 @@ public class EdgeRuleQuery {
return nodeB;
}
- public Builder to(String nodeB){
+ public Builder to(String nodeB) {
this.nodeB = nodeB;
return this;
}
public Builder toOnly() {
- //Allows this to be used with single parameter constructor Builder(String nodeA)
- if(StringUtils.isEmpty(this.nodeB) && StringUtils.isNotEmpty(this.nodeA) ) {
- this.nodeB=this.nodeA;
+ // Allows this to be used with single parameter constructor Builder(String nodeA)
+ if (StringUtils.isEmpty(this.nodeB) && StringUtils.isNotEmpty(this.nodeA)) {
+ this.nodeB = this.nodeA;
}
this.nodeA = TO_ONLY;
return this;
@@ -124,7 +124,6 @@ public class EdgeRuleQuery {
return type;
}
-
public Builder direction(AAIDirection direction) {
this.direction = direction;
return this;
@@ -139,12 +138,12 @@ public class EdgeRuleQuery {
return this;
}
- public Builder setPrivate(boolean isPrivate){
+ public Builder setPrivate(boolean isPrivate) {
this.isPrivate = isPrivate;
return this;
}
- public boolean isPrivate(){
+ public boolean isPrivate() {
return isPrivate;
}
@@ -166,18 +165,18 @@ public class EdgeRuleQuery {
this.direction = builder.getDirection();
this.isPrivate = builder.isPrivate();
- //will cover from A to B case
+ // 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())) {
+ // Special logic to allow for A to B case only
+ if (("FromOnly").equals(builder.getSecondNodeType())) {
criteriaFromTo.add(buildToFromPart(builder.getFirstNodeType(), null));
} else {
criteriaFromTo.add(buildToFromPart(builder.getFirstNodeType(), builder.getSecondNodeType()));
}
- //will cover from B to A case - must be separate bc jsonpath won't let me OR predicates >:C
+ // 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())) {
+ // Special logic to allow for B to A case only
+ if (("ToOnly").equals(builder.getFirstNodeType())) {
criteriaToFrom.add(buildToFromPart(null, builder.getSecondNodeType()));
} else {
criteriaToFrom.add(buildToFromPart(builder.getSecondNodeType(), builder.getFirstNodeType()));
@@ -195,7 +194,7 @@ public class EdgeRuleQuery {
}
Predicate privatePredicate = where("private").is(String.valueOf(isPrivate));
- if(isPrivate){
+ if (isPrivate) {
criteriaFromTo.add(privatePredicate);
criteriaToFrom.add(privatePredicate);
}
@@ -205,9 +204,9 @@ public class EdgeRuleQuery {
criteriaFromTo.add(directionPred);
criteriaToFrom.add(directionPred);
}
- if(("ToOnly").equals(builder.getFirstNodeType())) {
+ if (("ToOnly").equals(builder.getFirstNodeType())) {
this.filter = filter(criteriaToFrom);
- } else if(("FromOnly").equals(builder.getSecondNodeType())) {
+ } else if (("FromOnly").equals(builder.getSecondNodeType())) {
this.filter = filter(criteriaFromTo);
} else {
this.filter = filter(criteriaFromTo).or(filter(criteriaToFrom));
@@ -215,7 +214,7 @@ public class EdgeRuleQuery {
}
private Predicate buildToFromPart(String from, String to) {
- if (from == null && to == null) { //shouldn't ever happen though
+ if (from == null && to == null) { // shouldn't ever happen though
throw new IllegalStateException("must have at least one node defined");
}
@@ -239,7 +238,7 @@ public class EdgeRuleQuery {
private Predicate addType(EdgeType type) {
if (type == EdgeType.COUSIN) {
return where(EdgeProperty.CONTAINS.toString()).is(AAIDirection.NONE.toString());
- } else { //equals TREE
+ } else { // equals TREE
return where(EdgeProperty.CONTAINS.toString()).ne(AAIDirection.NONE.toString());
}
}
@@ -259,6 +258,7 @@ public class EdgeRuleQuery {
/**
* Provides the JsonPath filter for actually querying the edge rule schema files
+ *
* @return Filter
*/
public Filter getFilter() {
@@ -284,6 +284,7 @@ public class EdgeRuleQuery {
/**
* So the Ingestor knows which version of the rules to search
+ *
* @return the Version
*/
public Optional<SchemaVersion> getVersion() {
@@ -314,7 +315,7 @@ public class EdgeRuleQuery {
sb.append(", isPrivate: ");
sb.append(isPrivate);
- if(v.isPresent()){
+ if (v.isPresent()) {
sb.append(", for version: ").append(v.get().toString()).append(".");
}
return sb.toString();
@@ -322,21 +323,19 @@ public class EdgeRuleQuery {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
EdgeRuleQuery ruleQuery = (EdgeRuleQuery) o;
- return isPrivate == ruleQuery.isPrivate &&
- Objects.equals(v, ruleQuery.v) &&
- Objects.equals(nodeA, ruleQuery.nodeA) &&
- Objects.equals(nodeB, ruleQuery.nodeB) &&
- Objects.equals(label, ruleQuery.label) &&
- direction == ruleQuery.direction &&
- type == ruleQuery.type;
+ return isPrivate == ruleQuery.isPrivate && Objects.equals(v, ruleQuery.v)
+ && Objects.equals(nodeA, ruleQuery.nodeA) && Objects.equals(nodeB, ruleQuery.nodeB)
+ && Objects.equals(label, ruleQuery.label) && direction == ruleQuery.direction && type == ruleQuery.type;
}
@Override
public int hashCode() {
- if(v.isPresent()){
+ if (v.isPresent()) {
return Objects.hash(v.get(), nodeA, nodeB, label, direction, type, isPrivate);
} else {
return Objects.hash(nodeA, nodeB, label, direction, type, isPrivate);
@@ -344,4 +343,3 @@ public class EdgeRuleQuery {
}
}
-
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java
index 713103a0..b686b3a6 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java
@@ -24,7 +24,6 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
-import org.onap.aai.setup.SchemaVersion;
import java.io.BufferedReader;
import java.io.FileReader;
@@ -35,17 +34,19 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import org.onap.aai.setup.SchemaVersion;
+
/**
* JsonIngestor produces DocumentContexts from json files
*/
public class JsonIngestor {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(JsonIngestor.class);
-
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(JsonIngestor.class);
+
/**
* Reads in given json files to queryable DocumentContexts.
*
* @param filesToIngest - map of filenames to ingest
- * per Version
+ * per Version
* @return Map<SchemaVersion, List<DocumentContext>> - map of DocumentContexts per Version
*/
public Map<SchemaVersion, List<DocumentContext>> ingest(Map<SchemaVersion, List<String>> filesToIngest) {
@@ -90,13 +91,13 @@ public class JsonIngestor {
*/
public String readInJsonFile(String rulesFilename) {
StringBuilder sb = new StringBuilder();
- try(BufferedReader br = new BufferedReader(new FileReader(rulesFilename))) {
+ try (BufferedReader br = new BufferedReader(new FileReader(rulesFilename))) {
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
- LOGGER.warn("Exception in file"+e.getMessage());
+ LOGGER.warn("Exception in file" + e.getMessage());
throw new ExceptionInInitializerError(e);
}
return sb.toString();
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/SchemaFilter.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/SchemaFilter.java
index 792e3c51..4d2c8455 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/SchemaFilter.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/SchemaFilter.java
@@ -17,21 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.edges;
import com.jayway.jsonpath.Filter;
-import org.onap.aai.setup.SchemaVersion;
import java.util.Objects;
+import org.onap.aai.setup.SchemaVersion;
+
public class SchemaFilter {
private String filter;
private SchemaVersion schemaVersion;
- public SchemaFilter(Filter filter, SchemaVersion schemaVersion){
- if(filter != null){
+ public SchemaFilter(Filter filter, SchemaVersion schemaVersion) {
+ if (filter != null) {
this.filter = filter.toString();
}
this.schemaVersion = schemaVersion;
@@ -47,11 +49,12 @@ public class SchemaFilter {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
SchemaFilter that = (SchemaFilter) o;
- return Objects.equals(filter, that.filter) &&
- Objects.equals(schemaVersion, that.schemaVersion);
+ return Objects.equals(filter, that.filter) && Objects.equals(schemaVersion, that.schemaVersion);
}
@Override
@@ -61,9 +64,6 @@ public class SchemaFilter {
@Override
public String toString() {
- return "SchemaFilter{" +
- "filter='" + filter + '\'' +
- ", schemaVersion=" + schemaVersion +
- '}';
+ return "SchemaFilter{" + "filter='" + filter + '\'' + ", schemaVersion=" + schemaVersion + '}';
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java
index fd1f5113..4cae19ea 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/TypeAlphabetizer.java
@@ -24,42 +24,42 @@ package org.onap.aai.edges;
* Helper class to produce alphabetized keys for EdgeIngestor and EdgeValidator
*/
public class TypeAlphabetizer {
- /**
- * Builds key for edge rules, where nodetypes are alphabetically sorted
- * (ignoring dashes).
- *
- * @param nodeA - first nodetype
- * @param nodeB - second nodetype
- * @return {alphabetically first nodetype}|{alphabetically second nodetype}
- * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
- * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
- *
- * This is alphabetical order to normalize the keys, as sometimes there will be multiple
- * rules for a pair of node types but the from/to value in the json is flipped for some of them.
- */
- public String buildAlphabetizedKey(String nodeA, String nodeB) {
- if (nodeA == null) {
- nodeA = "";
- }
- if (nodeB == null) {
- nodeB = "";
- }
-
- //normalize
- String normalizedNodeA = nodeA.replace("-", "");
- String normalizedNodeB = nodeB.replace("-", "");
- int cmp = normalizedNodeA.compareTo(normalizedNodeB);
-
- StringBuilder sb = new StringBuilder();
- if (cmp <= 0) {
- sb.append(nodeA);
- sb.append("|");
- sb.append(nodeB);
- } else {
- sb.append(nodeB);
- sb.append("|");
- sb.append(nodeA);
- }
- return sb.toString();
- }
+ /**
+ * Builds key for edge rules, where nodetypes are alphabetically sorted
+ * (ignoring dashes).
+ *
+ * @param nodeA - first nodetype
+ * @param nodeB - second nodetype
+ * @return {alphabetically first nodetype}|{alphabetically second nodetype}
+ * ex: buildAlphabetizedKey("l-interface", "logical-link") -> "l-interface|logical-link"
+ * buildAlphabetizedKey("logical-link", "l-interface") -> "l-interface|logical-link"
+ *
+ * This is alphabetical order to normalize the keys, as sometimes there will be multiple
+ * rules for a pair of node types but the from/to value in the json is flipped for some of them.
+ */
+ public String buildAlphabetizedKey(String nodeA, String nodeB) {
+ if (nodeA == null) {
+ nodeA = "";
+ }
+ if (nodeB == null) {
+ nodeB = "";
+ }
+
+ // normalize
+ String normalizedNodeA = nodeA.replace("-", "");
+ String normalizedNodeB = nodeB.replace("-", "");
+ int cmp = normalizedNodeA.compareTo(normalizedNodeB);
+
+ StringBuilder sb = new StringBuilder();
+ if (cmp <= 0) {
+ sb.append(nodeA);
+ sb.append("|");
+ sb.append(nodeB);
+ } else {
+ sb.append(nodeB);
+ sb.append("|");
+ sb.append(nodeA);
+ }
+ return sb.toString();
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java
index aeb5d77d..04c97fc4 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/AAIDirection.java
@@ -17,44 +17,45 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.edges.enums;
import org.apache.tinkerpop.gremlin.structure.Direction;
public enum AAIDirection {
- IN, OUT, BOTH, NONE;
+ IN, OUT, BOTH, NONE;
+
+ public AAIDirection opposite() {
+ if (this.equals(OUT)) {
+ return IN;
+ } else if (this.equals(IN)) {
+ return OUT;
+ } else {
+ return BOTH;
+ }
+ }
+
+ public static AAIDirection getValue(String aaidir) {
+ if (OUT.toString().equals(aaidir)) {
+ return OUT;
+ } else if (IN.toString().equals(aaidir)) {
+ return IN;
+ } else if (NONE.toString().equals(aaidir)) {
+ return NONE;
+ } else { // should be BOTH
+ return BOTH;
+ }
+ }
- public AAIDirection opposite() {
- if (this.equals(OUT)) {
- return IN;
- } else if (this.equals(IN)) {
- return OUT;
- } else {
- return BOTH;
- }
- }
-
- public static AAIDirection getValue(String aaidir) {
- if (OUT.toString().equals(aaidir)) {
- return OUT;
- } else if (IN.toString().equals(aaidir)) {
- return IN;
- } else if (NONE.toString().equals(aaidir)) {
- return NONE;
- } else { //should be BOTH
- return BOTH;
- }
- }
-
- public static AAIDirection getValue(Direction dir) {
- if (dir == Direction.OUT) {
- return OUT;
- } else if (dir == Direction.IN) {
- return IN;
- } else if (dir == Direction.BOTH) {
- return BOTH;
- } else {
- return NONE;
- }
- }
+ public static AAIDirection getValue(Direction dir) {
+ if (dir == Direction.OUT) {
+ return OUT;
+ } else if (dir == Direction.IN) {
+ return IN;
+ } else if (dir == Direction.BOTH) {
+ return BOTH;
+ } else {
+ return NONE;
+ }
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java
index 5a69603b..49a094b9 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/DirectionNotation.java
@@ -20,28 +20,27 @@
package org.onap.aai.edges.enums;
-public enum DirectionNotation {
- DIRECTION("${direction}"),
- OPPOSITE("!${direction}");
+public enum DirectionNotation {
+ DIRECTION("${direction}"), OPPOSITE("!${direction}");
- private final String val;
-
- DirectionNotation(String dir) {
- this.val = dir;
- }
-
- public static DirectionNotation getValue(String val) {
- if (DIRECTION.toString().equals(val)) {
- return DIRECTION;
- } else if (OPPOSITE.toString().equals(val)) {
- return OPPOSITE;
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- @Override
- public String toString() {
- return this.val;
- }
-} \ No newline at end of file
+ private final String val;
+
+ DirectionNotation(String dir) {
+ this.val = dir;
+ }
+
+ public static DirectionNotation getValue(String val) {
+ if (DIRECTION.toString().equals(val)) {
+ return DIRECTION;
+ } else if (OPPOSITE.toString().equals(val)) {
+ return OPPOSITE;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.val;
+ }
+}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java
index ff6bc82d..35ea1131 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeField.java
@@ -25,25 +25,17 @@ package org.onap.aai.edges.enums;
*
*/
public enum EdgeField {
- FROM("from"),
- TO("to"),
- LABEL("label"),
- DIRECTION("direction"),
- MULTIPLICITY("multiplicity"),
- CONTAINS("contains-other-v"),
- DELETE_OTHER_V("delete-other-v"),
- PREVENT_DELETE("prevent-delete"),
- DEFAULT("default"),
- PRIVATE("private"),
- DESCRIPTION("description");
- private final String name;
+ FROM("from"), TO("to"), LABEL("label"), DIRECTION("direction"), MULTIPLICITY("multiplicity"), CONTAINS(
+ "contains-other-v"), DELETE_OTHER_V("delete-other-v"), PREVENT_DELETE(
+ "prevent-delete"), DEFAULT("default"), PRIVATE("private"), DESCRIPTION("description");
+ private final String name;
- private EdgeField(String name) {
- this.name = name;
- }
+ private EdgeField(String name) {
+ this.name = name;
+ }
- @Override
- public String toString() {
- return name;
- }
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java
index 18e82f5e..c4e945b0 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeProperty.java
@@ -25,17 +25,15 @@ package org.onap.aai.edges.enums;
* (ie which have a directional value)
*/
public enum EdgeProperty {
- CONTAINS("contains-other-v"),
- DELETE_OTHER_V("delete-other-v"),
- PREVENT_DELETE("prevent-delete");
- private final String name;
+ CONTAINS("contains-other-v"), DELETE_OTHER_V("delete-other-v"), PREVENT_DELETE("prevent-delete");
+ private final String name;
- private EdgeProperty(String name) {
- this.name = name;
- }
+ private EdgeProperty(String name) {
+ this.name = name;
+ }
- @Override
- public String toString() {
- return name;
- }
+ @Override
+ public String toString() {
+ return name;
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java
index 4662f862..0725c92b 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/EdgeType.java
@@ -17,10 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.edges.enums;
public enum EdgeType {
- COUSIN,
- TREE,
- ALL;
+ COUSIN, TREE, ALL;
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java
index a29b4a61..ed00f152 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/enums/MultiplicityRule.java
@@ -17,23 +17,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.edges.enums;
public enum MultiplicityRule {
- MANY2ONE,
- ONE2MANY,
- ONE2ONE,
- MANY2MANY;
-
- public static MultiplicityRule getValue(String multiplicity) {
- if ("Many2Many".equalsIgnoreCase(multiplicity)) {
- return MANY2MANY;
- } else if ("One2Many".equalsIgnoreCase(multiplicity)) {
- return ONE2MANY;
- } else if ("One2One".equalsIgnoreCase(multiplicity)) {
- return ONE2ONE;
- } else { //should be "Many2One"
- return MANY2ONE;
- }
- }
+ MANY2ONE, ONE2MANY, ONE2ONE, MANY2MANY;
+
+ public static MultiplicityRule getValue(String multiplicity) {
+ if ("Many2Many".equalsIgnoreCase(multiplicity)) {
+ return MANY2MANY;
+ } else if ("One2Many".equalsIgnoreCase(multiplicity)) {
+ return ONE2MANY;
+ } else if ("One2One".equalsIgnoreCase(multiplicity)) {
+ return ONE2ONE;
+ } else { // should be "Many2One"
+ return MANY2ONE;
+ }
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java
index da79d9c7..0f226733 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/AmbiguousRuleChoiceException.java
@@ -21,11 +21,11 @@
package org.onap.aai.edges.exceptions;
public class AmbiguousRuleChoiceException extends Exception {
- public AmbiguousRuleChoiceException(String msg) {
- super(msg);
- }
+ public AmbiguousRuleChoiceException(String msg) {
+ super(msg);
+ }
- public AmbiguousRuleChoiceException(Throwable throwable){
+ public AmbiguousRuleChoiceException(Throwable throwable) {
super(throwable);
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeIngestorException.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeIngestorException.java
index 96fd65cc..cbd7aac9 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeIngestorException.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeIngestorException.java
@@ -25,7 +25,7 @@ public class EdgeIngestorException extends Exception {
super(msg);
}
- public EdgeIngestorException(Throwable throwable){
+ public EdgeIngestorException(Throwable throwable) {
super(throwable);
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java
index f9b9b643..f3ab00e7 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/exceptions/EdgeRuleNotFoundException.java
@@ -21,11 +21,11 @@
package org.onap.aai.edges.exceptions;
public class EdgeRuleNotFoundException extends Exception {
- public EdgeRuleNotFoundException(String msg) {
- super(msg);
- }
+ public EdgeRuleNotFoundException(String msg) {
+ super(msg);
+ }
- public EdgeRuleNotFoundException(Throwable throwable){
+ public EdgeRuleNotFoundException(Throwable throwable) {
super(throwable);
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/CaseFormatStore.java b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/CaseFormatStore.java
index 69a153da..03036cad 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/CaseFormatStore.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/CaseFormatStore.java
@@ -17,16 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.nodes;
import com.google.common.base.CaseFormat;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
/**
* CaseFormatStore stores the converted strings from
* lower hyphen (example-object) to lower camel case (exampleObject)
@@ -40,15 +42,16 @@ public class CaseFormatStore {
private final Map<String, String> lowerCamelToLowerHyphen = new HashMap<>();
private final Map<String, String> upperCamelToLowerHyphen = new HashMap<>();
- CaseFormatStore(){}
+ CaseFormatStore() {
+ }
/**
* Parses the document and creates a lower camel case string
* upper camel string, lower hyphen and lower camel case
*
- * @param doc Takes an xml document and adds it to the hash maps as appropriate
+ * @param doc Takes an xml document and adds it to the hash maps as appropriate
*/
- void parse(Document doc){
+ void parse(Document doc) {
// Get the xml-root-element and add those nodes
// with the attribute name and it to the hashmaps
@@ -86,19 +89,19 @@ public class CaseFormatStore {
}
}
- public Optional<String> fromLowerHyphenToLowerCamel(String value){
+ public Optional<String> fromLowerHyphenToLowerCamel(String value) {
return Optional.ofNullable(lowerHyphenToLowerCamel.get(value));
}
- public Optional<String> fromLowerHyphenToUpperCamel(String value){
+ public Optional<String> fromLowerHyphenToUpperCamel(String value) {
return Optional.ofNullable(lowerHyphenToUpperCamel.get(value));
}
- public Optional<String> fromUpperCamelToLowerHyphen(String value){
+ public Optional<String> fromUpperCamelToLowerHyphen(String value) {
return Optional.ofNullable(upperCamelToLowerHyphen.get(value));
}
- public Optional<String> fromLowerCamelToLowerHyphen(String value){
+ public Optional<String> fromLowerCamelToLowerHyphen(String value) {
return Optional.ofNullable(lowerCamelToLowerHyphen.get(value));
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
index 2428a6dd..6016fcca 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java
@@ -25,6 +25,20 @@ package org.onap.aai.nodes;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.common.base.CaseFormat;
+
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.annotation.PostConstruct;
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.eclipse.persistence.jaxb.JAXBContextProperties;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;
@@ -40,24 +54,12 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-import javax.annotation.PostConstruct;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.*;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
@Component
/*
- NodeIngestor - ingests A&AI OXM files per given config, serves DynamicJAXBContext per version
+ * NodeIngestor - ingests A&AI OXM files per given config, serves DynamicJAXBContext per version
*/
-@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true)
-@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true)
+@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
+@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
public class NodeIngestor {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(NodeIngestor.class);
@@ -70,14 +72,15 @@ public class NodeIngestor {
private Set<Translator> translators;
private CaseFormatStore caseFormatStore;
- //TODO : See if you can get rid of InputStream resets
+ // TODO : See if you can get rid of InputStream resets
/**
* Instantiates the NodeIngestor bean.
+ *
* @param translatorSet
*/
- @Autowired
+ @Autowired
public NodeIngestor(Set<Translator> translatorSet) {
this.translators = translatorSet;
this.caseFormatStore = new CaseFormatStore();
@@ -106,7 +109,7 @@ public class NodeIngestor {
this.localSchema = "true";
}
- Boolean retrieveLocalSchema = Boolean.parseBoolean(this.localSchema);
+ Boolean retrieveLocalSchema = Boolean.parseBoolean(this.localSchema);
/*
* Set this to default schemaVersion
*/
@@ -119,8 +122,8 @@ public class NodeIngestor {
List<InputStream> inputStreams = retrieveOXM(version, translator);
LOGGER.debug("Retrieved OXMs from SchemaService");
/*
- IOUtils.copy and copy the inputstream
- */
+ * IOUtils.copy and copy the inputstream
+ */
if (inputStreams.isEmpty()) {
continue;
}
@@ -151,14 +154,15 @@ public class NodeIngestor {
return DynamicJAXBContextFactory.createContextFromOXM(this.getClass().getClassLoader(), properties);
}
- private void setAllTypesAndProperties(SchemaVersion version, List<InputStream> inputStreams) throws ParserConfigurationException, IOException, SAXException {
+ private void setAllTypesAndProperties(SchemaVersion version, List<InputStream> inputStreams)
+ throws ParserConfigurationException, IOException, SAXException {
Set<String> types = new HashSet<>();
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
for (InputStream inputStream : inputStreams) {
- //TODO Change this
+ // TODO Change this
inputStream.reset();
final Document doc = docBuilder.parse(inputStream);
final NodeList list = doc.getElementsByTagName("java-type");
@@ -170,7 +174,7 @@ public class NodeIngestor {
typesPerVersion.put(version, types);
}
- private void getAllNodeTypes(NodeList list, Set<String> types){
+ private void getAllNodeTypes(NodeList list, Set<String> types) {
for (int i = 0; i < list.getLength(); i++) {
String type = list.item(i).getAttributes().getNamedItem("name").getNodeValue();
@@ -178,7 +182,8 @@ public class NodeIngestor {
}
}
- private Document createCombinedSchema(List<InputStream> inputStreams, SchemaVersion version, boolean localSchema) throws ParserConfigurationException, SAXException, IOException {
+ private Document createCombinedSchema(List<InputStream> inputStreams, SchemaVersion version, boolean localSchema)
+ throws ParserConfigurationException, SAXException, IOException {
if (localSchema) {
return createCombinedSchema(inputStreams, version);
}
@@ -191,7 +196,8 @@ public class NodeIngestor {
return masterDocBuilder.parse(inputStream);
}
- private Document createCombinedSchema(List<InputStream> inputStreams, SchemaVersion version) throws ParserConfigurationException, SAXException, IOException {
+ private Document createCombinedSchema(List<InputStream> inputStreams, SchemaVersion version)
+ throws ParserConfigurationException, SAXException, IOException {
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
@@ -247,7 +253,6 @@ public class NodeIngestor {
return schemaPerVersion.get(v);
}
-
public SchemaVersion getVersionFromClassName(String classname) {
Matcher m = classNamePattern.matcher(classname);
if (m.find()) {
@@ -259,26 +264,24 @@ public class NodeIngestor {
}
private List<InputStream> retrieveOXM(SchemaVersion version, Translator translator) throws IOException {
- /*
- Call Schema MS to get versions using RestTemplate or Local
- */
+ /*
+ * Call Schema MS to get versions using RestTemplate or Local
+ */
return translator.getVersionNodeStream(version);
}
private InputStream getShell(SchemaVersion v) {
- String source = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org." + v.toString().toLowerCase() + "\" xml-mapping-metadata-complete=\"true\">\n" +
- " <xml-schema element-form-default=\"QUALIFIED\">\n" +
- " <xml-ns namespace-uri=\"http://org.onap.aai.inventory/" + v.toString().toLowerCase() + "\" />\n" +
- " </xml-schema>\n" +
- " <java-types>\n" +
- " </java-types>\n" +
- "</xml-bindings>";
+ String source = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org."
+ + v.toString().toLowerCase() + "\" xml-mapping-metadata-complete=\"true\">\n"
+ + " <xml-schema element-form-default=\"QUALIFIED\">\n"
+ + " <xml-ns namespace-uri=\"http://org.onap.aai.inventory/" + v.toString().toLowerCase() + "\" />\n"
+ + " </xml-schema>\n" + " <java-types>\n" + " </java-types>\n" + "</xml-bindings>";
return new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8));
}
- public CaseFormatStore getCaseFormatStore(){
+ public CaseFormatStore getCaseFormatStore() {
return caseFormatStore;
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/exceptions/NodeIngestorException.java b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/exceptions/NodeIngestorException.java
index adaf538e..ef1e0d24 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/exceptions/NodeIngestorException.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/exceptions/NodeIngestorException.java
@@ -25,7 +25,7 @@ public class NodeIngestorException extends Exception {
super(msg);
}
- public NodeIngestorException(Throwable throwable){
+ public NodeIngestorException(Throwable throwable) {
super(throwable);
}
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java
index 83687a76..cc88edef 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java
@@ -17,55 +17,59 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.annotation.PostConstruct;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
-import javax.annotation.PostConstruct;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
+@Component(value = "no-auth-service-rest-client")
+public class SchemaServiceNoAuthClient extends NoAuthRestClient {
-@Component(value="no-auth-service-rest-client")
-public class SchemaServiceNoAuthClient extends NoAuthRestClient{
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceNoAuthClient.class);
- private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceNoAuthClient.class);
-
- @Value("${schema.service.base.url}")
- private String baseUrl;
+ @Value("${schema.service.base.url}")
+ private String baseUrl;
@PostConstruct
- public void init () throws Exception {
+ public void init() throws Exception {
super.init();
}
- @Override
- public String getBaseUrl() {
- return baseUrl;
- }
+ @Override
+ public String getBaseUrl() {
+ return baseUrl;
+ }
@Override
- public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
- HttpHeaders httpHeaders = new HttpHeaders();
+ public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
+ HttpHeaders httpHeaders = new HttpHeaders();
String defaultAccept = headers.getOrDefault(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
- String defaultContentType = headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
+ String defaultContentType =
+ headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
- if(headers.isEmpty()){
+ if (headers.isEmpty()) {
httpHeaders.setAccept(Collections.singletonList(MediaType.parseMediaType(defaultAccept)));
httpHeaders.setContentType(MediaType.parseMediaType(defaultContentType));
}
- httpHeaders.add("X-FromAppId", appName);
- httpHeaders.add("X-TransactionId", UUID.randomUUID().toString());
+ httpHeaders.add("X-FromAppId", appName);
+ httpHeaders.add("X-TransactionId", UUID.randomUUID().toString());
headers.forEach(httpHeaders::add);
- return httpHeaders;
- }
+ return httpHeaders;
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java
index a3e4de54..6b107285 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java
@@ -17,25 +17,28 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.annotation.PostConstruct;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
-import javax.annotation.PostConstruct;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
-@Component(value="schema-service-one-way-rest-client")
-public class SchemaServiceOneWayClient extends OneWaySSLRestClient{
+@Component(value = "schema-service-one-way-rest-client")
+public class SchemaServiceOneWayClient extends OneWaySSLRestClient {
- private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceOneWayClient.class);
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceOneWayClient.class);
@Value("${schema.service.base.url}")
private String baseUrl;
@@ -62,22 +65,23 @@ public class SchemaServiceOneWayClient extends OneWaySSLRestClient{
}
@Override
- public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
- HttpHeaders httpHeaders = new HttpHeaders();
+ public MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
+ HttpHeaders httpHeaders = new HttpHeaders();
String defaultAccept = headers.getOrDefault(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
- String defaultContentType = headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
+ String defaultContentType =
+ headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
- if(headers.isEmpty()){
+ if (headers.isEmpty()) {
httpHeaders.setAccept(Collections.singletonList(MediaType.parseMediaType(defaultAccept)));
httpHeaders.setContentType(MediaType.parseMediaType(defaultContentType));
}
- httpHeaders.add("X-FromAppId", appName);
- httpHeaders.add("X-TransactionId", UUID.randomUUID().toString());
+ httpHeaders.add("X-FromAppId", appName);
+ httpHeaders.add("X-TransactionId", UUID.randomUUID().toString());
httpHeaders.add("X-TransactionId", appName);
- headers.forEach(httpHeaders::add);
- return httpHeaders;
- }
+ headers.forEach(httpHeaders::add);
+ return httpHeaders;
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java
index 300c5d83..56ddd744 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java
@@ -19,20 +19,22 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
@Component(value = "schema-service-rest-client")
public class SchemaServiceRestClient extends TwoWaySSLRestClient {
private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceRestClient.class);
@@ -54,7 +56,7 @@ public class SchemaServiceRestClient extends TwoWaySSLRestClient {
@Override
public String getBaseUrl() {
- return baseUrl;
+ return baseUrl;
}
@Override
@@ -82,7 +84,8 @@ public class SchemaServiceRestClient extends TwoWaySSLRestClient {
HttpHeaders httpHeaders = new HttpHeaders();
String defaultAccept = headers.getOrDefault(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
- String defaultContentType = headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
+ String defaultContentType =
+ headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
if (headers.isEmpty()) {
httpHeaders.setAccept(Collections.singletonList(MediaType.parseMediaType(defaultAccept)));
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java
index 4454ad27..8949891e 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
import java.io.File;
@@ -35,79 +36,67 @@ import java.util.stream.Stream;
*/
public class AAIConfigTranslator extends ConfigTranslator {
- private static final String FILESEP = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
+ private static final String FILESEP =
+ (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
public AAIConfigTranslator(SchemaLocationsBean bean, SchemaConfigVersions schemaVersions) {
- super(bean, schemaVersions);
- }
-
- /* (non-Javadoc)
- * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles()
- */
- @Override
- public Map<SchemaVersion, List<String>> getNodeFiles() {
-
- Map<SchemaVersion, List<String>> files = new TreeMap<>();
- for (SchemaVersion v : schemaVersions.getVersions()) {
- List<String> container = getVersionNodeFiles(v);
- files.put(v, container);
- }
-
- return files;
- }
-
-
- private List<String> getVersionNodeFiles(SchemaVersion v) {
- return getVersionFiles(
- bean.getNodeDirectory(),
- v,
- () -> bean.getNodesInclusionPattern().stream(),
- () -> bean.getNodesExclusionPattern().stream()
- );
- }
-
-
- /* (non-Javadoc)
- * @see org.onap.aai.setup.ConfigTranslator#getEdgeFiles()
- */
- @Override
- public Map<SchemaVersion, List<String>> getEdgeFiles() {
-
- Map<SchemaVersion, List<String>> files = new TreeMap<>();
- for (SchemaVersion v : schemaVersions.getVersions()) {
- List<String> container = getVersionEdgeFiles(v);
- files.put(v, container);
- }
-
- return files;
- }
-
- private List<String> getVersionEdgeFiles(SchemaVersion v) {
-
- return getVersionFiles(
- bean.getEdgeDirectory(),
- v,
- () -> bean.getEdgesInclusionPattern().stream(),
- () -> bean.getEdgesExclusionPattern().stream()
- );
- }
-
- private List<String> getVersionFiles(
- String startDirectory,
- SchemaVersion schemaVersion,
- Supplier<Stream<String>> inclusionPattern,
- Supplier<Stream<String>> exclusionPattern
- ){
-
- List<String> container;
- final String directoryName = startDirectory + FILESEP + schemaVersion.toString() + FILESEP;
- container = Arrays.stream(new File(directoryName).listFiles())
- .map(File::getName)
- .filter(name -> inclusionPattern.get().anyMatch(name::matches))
- .map(name -> directoryName + name)
- .filter(name -> exclusionPattern.get().noneMatch(name::matches))
- .collect(Collectors.toList());
-
- return container;
- }
+ super(bean, schemaVersions);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles()
+ */
+ @Override
+ public Map<SchemaVersion, List<String>> getNodeFiles() {
+
+ Map<SchemaVersion, List<String>> files = new TreeMap<>();
+ for (SchemaVersion v : schemaVersions.getVersions()) {
+ List<String> container = getVersionNodeFiles(v);
+ files.put(v, container);
+ }
+
+ return files;
+ }
+
+ private List<String> getVersionNodeFiles(SchemaVersion v) {
+ return getVersionFiles(bean.getNodeDirectory(), v, () -> bean.getNodesInclusionPattern().stream(),
+ () -> bean.getNodesExclusionPattern().stream());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.setup.ConfigTranslator#getEdgeFiles()
+ */
+ @Override
+ public Map<SchemaVersion, List<String>> getEdgeFiles() {
+
+ Map<SchemaVersion, List<String>> files = new TreeMap<>();
+ for (SchemaVersion v : schemaVersions.getVersions()) {
+ List<String> container = getVersionEdgeFiles(v);
+ files.put(v, container);
+ }
+
+ return files;
+ }
+
+ private List<String> getVersionEdgeFiles(SchemaVersion v) {
+
+ return getVersionFiles(bean.getEdgeDirectory(), v, () -> bean.getEdgesInclusionPattern().stream(),
+ () -> bean.getEdgesExclusionPattern().stream());
+ }
+
+ private List<String> getVersionFiles(String startDirectory, SchemaVersion schemaVersion,
+ Supplier<Stream<String>> inclusionPattern, Supplier<Stream<String>> exclusionPattern) {
+
+ List<String> container;
+ final String directoryName = startDirectory + FILESEP + schemaVersion.toString() + FILESEP;
+ container = Arrays.stream(new File(directoryName).listFiles()).map(File::getName)
+ .filter(name -> inclusionPattern.get().anyMatch(name::matches)).map(name -> directoryName + name)
+ .filter(name -> exclusionPattern.get().noneMatch(name::matches)).collect(Collectors.toList());
+
+ return container;
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
index 3ef76d75..1c49e1de 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
@@ -22,49 +22,50 @@ package org.onap.aai.setup;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.apache.commons.io.IOUtils;
-import org.onap.aai.edges.JsonIngestor;
-import org.springframework.beans.factory.annotation.Autowired;
+
import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.apache.commons.io.IOUtils;
+import org.onap.aai.edges.JsonIngestor;
+import org.springframework.beans.factory.annotation.Autowired;
+
/**
* Converts the contents of the schema config file
* (which lists which schema files to be loaded) to
* the format the Ingestors can work with.
*
*/
-public abstract class ConfigTranslator extends Translator{
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ConfigTranslator.class);
-
- protected SchemaLocationsBean bean;
+public abstract class ConfigTranslator extends Translator {
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ConfigTranslator.class);
+
+ protected SchemaLocationsBean bean;
-
- @Autowired
+ @Autowired
public ConfigTranslator(SchemaLocationsBean schemaLocationbean, SchemaConfigVersions schemaVersions) {
- super(schemaVersions);
- this.bean = schemaLocationbean;
-
- }
-
- /**
- * Translates the contents of the schema config file
- * into the input for the NodeIngestor
- *
- * @return Map of Version to the list of (string) filenames to be
- * ingested for that version
- */
- public abstract Map<SchemaVersion, List<String>> getNodeFiles();
+ super(schemaVersions);
+ this.bean = schemaLocationbean;
+
+ }
+
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the NodeIngestor
+ *
+ * @return Map of Version to the list of (string) filenames to be
+ * ingested for that version
+ */
+ public abstract Map<SchemaVersion, List<String>> getNodeFiles();
public List<InputStream> getVersionNodeStream(SchemaVersion version) {
Map<SchemaVersion, List<String>> filesToIngest = getNodeFiles();
List<InputStream> streams = new ArrayList<>();
- if(!filesToIngest.containsKey(version)) {
+ if (!filesToIngest.containsKey(version)) {
return streams;
}
List<String> versionFiles = filesToIngest.get(version);
@@ -73,13 +74,13 @@ public abstract class ConfigTranslator extends Translator{
try {
InputStream stream = new FileInputStream(new File(name));
String value = IOUtils.toString(stream, Charset.defaultCharset());
- InputStream bis =(IOUtils.toInputStream(value, Charset.defaultCharset()));
+ InputStream bis = (IOUtils.toInputStream(value, Charset.defaultCharset()));
streams.add(bis);
} catch (FileNotFoundException e) {
- //TODO This may have to be cascaded
- LOGGER.warn("File Not Found"+e.getMessage());
+ // TODO This may have to be cascaded
+ LOGGER.warn("File Not Found" + e.getMessage());
} catch (IOException e) {
- LOGGER.warn("IOException while reading files"+e.getMessage());
+ LOGGER.warn("IOException while reading files" + e.getMessage());
}
}
return streams;
@@ -89,7 +90,7 @@ public abstract class ConfigTranslator extends Translator{
public List<String> getJsonPayload(SchemaVersion version) {
Map<SchemaVersion, List<String>> filesToIngest = getEdgeFiles();
List<String> jsonPayloads = new ArrayList<>();
- if(!filesToIngest.containsKey(version)) {
+ if (!filesToIngest.containsKey(version)) {
return jsonPayloads;
}
List<String> versionFiles = filesToIngest.get(version);
@@ -101,14 +102,14 @@ public abstract class ConfigTranslator extends Translator{
return jsonPayloads;
}
-
- /**
- * Translates the contents of the schema config file
- * into the input for the EdgeIngestor
- *
- * @return Map of Version to the List of (String) filenames to be
- * ingested for that version
- */
- public abstract Map<SchemaVersion, List<String>> getEdgeFiles();
+
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the EdgeIngestor
+ *
+ * @return Map of Version to the List of (String) filenames to be
+ * ingested for that version
+ */
+ public abstract Map<SchemaVersion, List<String>> getEdgeFiles();
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java
index e23fea26..2d9d557b 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaConfigVersions.java
@@ -17,17 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.annotation.PostConstruct;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.util.List;
-import java.util.stream.Collectors;
-
@Component("schemaConfigVersions")
@ConditionalOnExpression("'${schema.translator.list:config}'.contains('config') || '${schema.service.versions.override:false}'.equals('true')")
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java
index 9e740a8c..13591766 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaLocationsBean.java
@@ -20,120 +20,120 @@
package org.onap.aai.setup;
+import java.util.List;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
-import java.util.List;
-
@Configuration
-@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true)
-@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true)
+@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
+@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
public class SchemaLocationsBean {
- /*
- * Per Spring documentation, the last PropertySource that works will
- * be applied. Here, schema.ingest.file will be an environment variable
- * set on install that tells Spring where to look for the schema
- * ingest properties file (and the actual filename), but the former
- * PropertySource gives the default of looking on the classpath for
- * schema-ingest.properties in case that second one doesn't work.
- *
- * The schema-ingest.properties file (or its equivalent if you choose
- * to name it otherwise) must contain the entries the below @Value
- * annotations are looking for.
- */
-
- @Value("${schema.configuration.location}")
- private String schemaConfigLoc;
-
- @Value("${schema.nodes.location}")
- private String nodeDirectory;
-
- @Value("${schema.edges.location}")
- private String edgeDirectory;
-
- @Value("${schema.nodes.inclusion.list:}#{T(java.util.Arrays).asList(\".*oxm(.*).xml\")}")
- private List<String> nodesInclusionPattern;
-
- @Value("${schema.nodes.exclusion.list:}#{T(java.util.Collections).emptyList()}")
- private List<String> nodesExclusionPattern;
-
- @Value("${schema.edges.inclusion.list:}#{T(java.util.Arrays).asList(\"DbEdgeRules_.*.json\")}")
- private List<String> edgesInclusionPattern;
-
- @Value("${schema.edges.exclusion.list:}#{T(java.util.Collections).emptyList()}")
- private List<String> edgesExclusionPattern;
-
- /**
- * @return the file name/location with the list of schema files to be ingested
- */
- public String getSchemaConfigLocation() {
- return schemaConfigLoc;
- }
-
- /**
- * Sets the name/location of the file with the list of schema files to ingest
- *
- * @param schemaConfigLoc - the file name/location
- */
- public void setSchemaConfigLocation(String schemaConfigLoc) {
- this.schemaConfigLoc = schemaConfigLoc;
- }
-
- /**
- * @return the location of the OXM files
- */
- public String getNodeDirectory() {
- return nodeDirectory;
- }
-
- /**
- * Sets the location of the OXM files
- *
- * @param nodeDirectory - the location of the OXM files
- */
- public void setNodeDirectory(String nodeDirectory) {
- this.nodeDirectory = nodeDirectory;
- }
-
- /**
- * @return the location of the edge rule json files
- */
- public String getEdgeDirectory() {
- return edgeDirectory;
- }
-
- /**
- * Sets the location of the edge rule json files
- *
- * @param edgeDirectory - the location of the edge rule files
- */
- public void setEdgeDirectory(String edgeDirectory) {
- this.edgeDirectory = edgeDirectory;
- }
-
- public List<String> getNodesExclusionPattern(){
- return this.nodesExclusionPattern;
- }
-
- public List<String> getNodesInclusionPattern(){
- return this.nodesInclusionPattern;
- }
-
- public List<String> getEdgesExclusionPattern(){
- return this.edgesExclusionPattern;
- }
-
- public List<String> getEdgesInclusionPattern(){
- return this.edgesInclusionPattern;
- }
-
- //this allows the code to actually read the value from the config file
- //without this those strings get set to literally "${edgeDir}" etc
- @Bean
- public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
- return new PropertySourcesPlaceholderConfigurer();
- }
+ /*
+ * Per Spring documentation, the last PropertySource that works will
+ * be applied. Here, schema.ingest.file will be an environment variable
+ * set on install that tells Spring where to look for the schema
+ * ingest properties file (and the actual filename), but the former
+ * PropertySource gives the default of looking on the classpath for
+ * schema-ingest.properties in case that second one doesn't work.
+ *
+ * The schema-ingest.properties file (or its equivalent if you choose
+ * to name it otherwise) must contain the entries the below @Value
+ * annotations are looking for.
+ */
+
+ @Value("${schema.configuration.location}")
+ private String schemaConfigLoc;
+
+ @Value("${schema.nodes.location}")
+ private String nodeDirectory;
+
+ @Value("${schema.edges.location}")
+ private String edgeDirectory;
+
+ @Value("${schema.nodes.inclusion.list:}#{T(java.util.Arrays).asList(\".*oxm(.*).xml\")}")
+ private List<String> nodesInclusionPattern;
+
+ @Value("${schema.nodes.exclusion.list:}#{T(java.util.Collections).emptyList()}")
+ private List<String> nodesExclusionPattern;
+
+ @Value("${schema.edges.inclusion.list:}#{T(java.util.Arrays).asList(\"DbEdgeRules_.*.json\")}")
+ private List<String> edgesInclusionPattern;
+
+ @Value("${schema.edges.exclusion.list:}#{T(java.util.Collections).emptyList()}")
+ private List<String> edgesExclusionPattern;
+
+ /**
+ * @return the file name/location with the list of schema files to be ingested
+ */
+ public String getSchemaConfigLocation() {
+ return schemaConfigLoc;
+ }
+
+ /**
+ * Sets the name/location of the file with the list of schema files to ingest
+ *
+ * @param schemaConfigLoc - the file name/location
+ */
+ public void setSchemaConfigLocation(String schemaConfigLoc) {
+ this.schemaConfigLoc = schemaConfigLoc;
+ }
+
+ /**
+ * @return the location of the OXM files
+ */
+ public String getNodeDirectory() {
+ return nodeDirectory;
+ }
+
+ /**
+ * Sets the location of the OXM files
+ *
+ * @param nodeDirectory - the location of the OXM files
+ */
+ public void setNodeDirectory(String nodeDirectory) {
+ this.nodeDirectory = nodeDirectory;
+ }
+
+ /**
+ * @return the location of the edge rule json files
+ */
+ public String getEdgeDirectory() {
+ return edgeDirectory;
+ }
+
+ /**
+ * Sets the location of the edge rule json files
+ *
+ * @param edgeDirectory - the location of the edge rule files
+ */
+ public void setEdgeDirectory(String edgeDirectory) {
+ this.edgeDirectory = edgeDirectory;
+ }
+
+ public List<String> getNodesExclusionPattern() {
+ return this.nodesExclusionPattern;
+ }
+
+ public List<String> getNodesInclusionPattern() {
+ return this.nodesInclusionPattern;
+ }
+
+ public List<String> getEdgesExclusionPattern() {
+ return this.edgesExclusionPattern;
+ }
+
+ public List<String> getEdgesInclusionPattern() {
+ return this.edgesInclusionPattern;
+ }
+
+ // this allows the code to actually read the value from the config file
+ // without this those strings get set to literally "${edgeDir}" etc
+ @Bean
+ public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
index 2d2411fb..8c29f96d 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
@@ -17,10 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
+import java.io.*;
+import java.util.*;
+
+import javax.ws.rs.HttpMethod;
+
import org.onap.aai.restclient.RestClient;
import org.onap.aai.restclient.RestClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,10 +38,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
-import javax.ws.rs.HttpMethod;
-import java.io.*;
-import java.util.*;
-
/**
* <b>AAIConfigTranslator</b> is responsible for looking at the schema files and
* edge files based on the available versions Also has the ability to exclude
@@ -42,68 +45,66 @@ import java.util.*;
*/
public class SchemaServiceTranslator extends Translator {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SchemaServiceTranslator.class);
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SchemaServiceTranslator.class);
- private static final String SchemaServiceClientType = "schema.service";
+ private static final String SchemaServiceClientType = "schema.service";
- @Value("${schema.service.nodes.endpoint}")
- private String nodeSchemaUri;
+ @Value("${schema.service.nodes.endpoint}")
+ private String nodeSchemaUri;
- @Value("${schema.service.edges.endpoint}")
- private String edgeSchemaUri;
+ @Value("${schema.service.edges.endpoint}")
+ private String edgeSchemaUri;
- @Autowired
- private RestClientFactory restClientFactory;
+ @Autowired
+ private RestClientFactory restClientFactory;
- public SchemaServiceTranslator(SchemaVersions schemaVersions) {
- super(schemaVersions);
- }
+ public SchemaServiceTranslator(SchemaVersions schemaVersions) {
+ super(schemaVersions);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles()
- */
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles()
+ */
- @Override
- public List<InputStream> getVersionNodeStream(SchemaVersion version) throws IOException {
+ @Override
+ public List<InputStream> getVersionNodeStream(SchemaVersion version) throws IOException {
- List<InputStream> inputStreams = new ArrayList<>();
- String content = "";
- String uri = nodeSchemaUri + version.toString();
- Map<String, String> headersMap = new HashMap<>();
+ List<InputStream> inputStreams = new ArrayList<>();
+ String content = "";
+ String uri = nodeSchemaUri + version.toString();
+ Map<String, String> headersMap = new HashMap<>();
- headersMap.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML.toString());
+ headersMap.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML.toString());
headersMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML.toString());
- RestClient restClient = restClientFactory.getRestClient(SchemaServiceClientType);
- ResponseEntity<Resource> schemaResponse = restClient.getGetResource(content, uri,
- headersMap);
+ RestClient restClient = restClientFactory.getRestClient(SchemaServiceClientType);
+ ResponseEntity<Resource> schemaResponse = restClient.getGetResource(content, uri, headersMap);
verifySchemaServiceResponse(schemaResponse.getStatusCode());
LOGGER.debug("SchemaResponse Status code" + schemaResponse.getStatusCode());
- inputStreams.add(schemaResponse.getBody().getInputStream());
- return inputStreams;
- }
+ inputStreams.add(schemaResponse.getBody().getInputStream());
+ return inputStreams;
+ }
@Override
- public List<String> getJsonPayload(SchemaVersion version) throws IOException {
- /*
- * Call Schema MS to get versions using RestTemplate
- */
- List<String> inputStreams = new ArrayList<>();
- String content = "";
- String uri = edgeSchemaUri + version.toString();
- Map<String, String> headersMap = new HashMap<>();
-
- RestClient restClient = restClientFactory.getRestClient(SchemaServiceClientType);
-
- ResponseEntity<String> schemaResponse = restClient.getGetRequest(content, uri,
- headersMap);
+ public List<String> getJsonPayload(SchemaVersion version) throws IOException {
+ /*
+ * Call Schema MS to get versions using RestTemplate
+ */
+ List<String> inputStreams = new ArrayList<>();
+ String content = "";
+ String uri = edgeSchemaUri + version.toString();
+ Map<String, String> headersMap = new HashMap<>();
+
+ RestClient restClient = restClientFactory.getRestClient(SchemaServiceClientType);
+
+ ResponseEntity<String> schemaResponse = restClient.getGetRequest(content, uri, headersMap);
verifySchemaServiceResponse(schemaResponse.getStatusCode());
LOGGER.debug("SchemaResponse Status code" + schemaResponse.getStatusCode());
- inputStreams.add(schemaResponse.getBody());
- return inputStreams;
+ inputStreams.add(schemaResponse.getBody());
+ return inputStreams;
- }
+ }
private void verifySchemaServiceResponse(HttpStatus statusCode) throws IOException {
if (statusCode != HttpStatus.OK) {
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java
index 5518ccb2..f39042d4 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java
@@ -17,14 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.annotation.PostConstruct;
+
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.util.List;
-import java.util.stream.Collectors;
@Component("schemaServiceVersions")
@ConditionalOnExpression("'${schema.translator.list}'.contains('schema-service')")
@@ -48,7 +51,7 @@ public class SchemaServiceVersions extends SchemaVersions {
}
@PostConstruct
- public void initializeFromSchemaService() throws ExceptionInInitializerError{
+ public void initializeFromSchemaService() throws ExceptionInInitializerError {
versionsValue = versions.stream().map(SchemaVersion::new).collect(Collectors.toList());
edgeLabelVersionValue = new SchemaVersion(edgeVersion);
@@ -64,7 +67,8 @@ public class SchemaServiceVersions extends SchemaVersions {
/*
* TODO Change Method names
*/
- public void initializeFromSchemaConfig(SchemaConfigVersions schemaConfigVersion) throws ExceptionInInitializerError{
+ public void initializeFromSchemaConfig(SchemaConfigVersions schemaConfigVersion)
+ throws ExceptionInInitializerError {
versions = schemaConfigVersion.getApiVersions();
appRootVersion = schemaConfigVersion.getAppRootStartVersion();
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersion.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersion.java
index 8143b5e1..6214a6f8 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersion.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersion.java
@@ -17,62 +17,64 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.setup;
-import org.onap.aai.validation.AAISchemaValidationException;
+package org.onap.aai.setup;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.onap.aai.validation.AAISchemaValidationException;
+
public class SchemaVersion implements Comparable<SchemaVersion> {
public static final Pattern VERSION_PATTERN = Pattern.compile("v([1-9][0-9]*)");
private final Integer value;
- public SchemaVersion(String value){
+ public SchemaVersion(String value) {
Matcher matcher = VERSION_PATTERN.matcher(value);
- if(!matcher.find()){
- throw new AAISchemaValidationException("Invalid Schema Version " + value + ", value doesn't match the expected regex: " + VERSION_PATTERN);
+ if (!matcher.find()) {
+ throw new AAISchemaValidationException(
+ "Invalid Schema Version " + value + ", value doesn't match the expected regex: " + VERSION_PATTERN);
} else {
this.value = Integer.parseInt(matcher.group(1));
}
}
@Override
- public int hashCode(){
+ public int hashCode() {
return value.hashCode();
}
@Override
- public boolean equals(Object other){
+ public boolean equals(Object other) {
- if(this == other){
+ if (this == other) {
return true;
}
- if(other == null){
+ if (other == null) {
return false;
}
- if(!(other instanceof SchemaVersion)){
+ if (!(other instanceof SchemaVersion)) {
return false;
}
- SchemaVersion obj = (SchemaVersion)other;
+ SchemaVersion obj = (SchemaVersion) other;
return this.value.equals(obj.value);
}
@Override
- public String toString(){
+ public String toString() {
return String.valueOf("v" + value);
}
@Override
public int compareTo(SchemaVersion o) {
- if(o == null){
+ if (o == null) {
return -1;
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
index e7f599c6..0094a161 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersions.java
@@ -17,18 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.annotation.PostConstruct;
+
import org.onap.aai.validation.AAISchemaValidationException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.util.List;
-import java.util.stream.Collectors;
-
-
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
public class SchemaVersions {
@@ -42,9 +43,9 @@ public class SchemaVersions {
protected SchemaVersion namespaceChangeVersionValue;
protected void validate() {
- String errorMessage = "Invalid, edge label version is not in the api versions list"
- + ", please check schema.version.list and ensure that the"
- + " schema.version.edge.label.start is in that list";
+ String errorMessage = "Invalid, edge label version is not in the api versions list"
+ + ", please check schema.version.list and ensure that the"
+ + " schema.version.edge.label.start is in that list";
if (!versionsValue.contains(edgeLabelVersionValue)) {
throw new AAISchemaValidationException(errorMessage);
}
@@ -69,7 +70,7 @@ public class SchemaVersions {
throw new AAISchemaValidationException(errorMessage);
}
}
-
+
public List<SchemaVersion> getVersions() {
return versionsValue;
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java
index dde7cad6..68678b83 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java
@@ -17,20 +17,24 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+
import org.onap.aai.restclient.RestClient;
import org.onap.aai.restclient.RestClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
-import javax.annotation.PostConstruct;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
public class SchemaVersionsBean {
@@ -51,43 +55,37 @@ public class SchemaVersionsBean {
@PostConstruct
public void initialize() {
- //Call SchemaService to get versions
+ // Call SchemaService to get versions
retrieveAllSchemaVersions();
}
- public void retrieveAllSchemaVersions() throws ExceptionInInitializerError{
- /*
- Call Schema MS to get versions using RestTemplate
- */
+ public void retrieveAllSchemaVersions() throws ExceptionInInitializerError {
+ /*
+ * Call Schema MS to get versions using RestTemplate
+ */
String content = "";
Map<String, String> headersMap = new HashMap<>();
- RestClient restClient = restClientFactory
- .getRestClient(SCHEMA_SERVICE);
+ RestClient restClient = restClientFactory.getRestClient(SCHEMA_SERVICE);
- ResponseEntity<String> schemaResponse = restClient.getGetRequest( content, versionsUri, headersMap);
- Gson gson = new GsonBuilder()
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES)
- .create();
+ ResponseEntity<String> schemaResponse = restClient.getGetRequest(content, versionsUri, headersMap);
+ Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES).create();
schemaVersions = gson.fromJson(schemaResponse.getBody(), SchemaServiceVersions.class);
- if(!validateOverrides(schemaVersions)){
- throw new ExceptionInInitializerError("The versions requested is not supported by SchemaService");
- }
- if("true".equals(overrideSchemaService)){
- schemaVersions.initializeFromSchemaConfig(schemaConfigVersions);
- }
- else{
- schemaVersions.initializeFromSchemaService();
- }
+ if (!validateOverrides(schemaVersions)) {
+ throw new ExceptionInInitializerError("The versions requested is not supported by SchemaService");
+ }
+ if ("true".equals(overrideSchemaService)) {
+ schemaVersions.initializeFromSchemaConfig(schemaConfigVersions);
+ } else {
+ schemaVersions.initializeFromSchemaService();
+ }
}
- public boolean validateOverrides(SchemaServiceVersions schemaVersions1){
+ public boolean validateOverrides(SchemaServiceVersions schemaVersions1) {
boolean versionsAvailable = true;
- if("true".equals(overrideSchemaService)){
- versionsAvailable = schemaConfigVersions.getApiVersions().stream().
- allMatch(
- (s) -> schemaVersions1.getVersionsAll().contains(s)
- );
+ if ("true".equals(overrideSchemaService)) {
+ versionsAvailable = schemaConfigVersions.getApiVersions().stream()
+ .allMatch((s) -> schemaVersions1.getVersionsAll().contains(s));
}
return versionsAvailable;
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
index 09062e1c..39efde54 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
@@ -20,10 +20,11 @@
package org.onap.aai.setup;
-import org.springframework.beans.factory.annotation.Autowired;
-
import java.io.*;
import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
/**
* Converts the contents of the schema config file
* (which lists which schema files to be loaded) to
@@ -32,36 +33,33 @@ import java.util.List;
*/
public abstract class Translator {
- protected SchemaVersions schemaVersions;
+ protected SchemaVersions schemaVersions;
- public Translator(SchemaVersions schemaVersions) {
- this.schemaVersions = schemaVersions;
- }
-
- /**
- * Translates the contents of the schema config file
- * into the input for the NodeIngestor
- *
- * @return Map of Version to the list of (string) filenames to be
- * ingested for that version
- */
+ public Translator(SchemaVersions schemaVersions) {
+ this.schemaVersions = schemaVersions;
+ }
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the NodeIngestor
+ *
+ * @return Map of Version to the list of (string) filenames to be
+ * ingested for that version
+ */
public abstract List<InputStream> getVersionNodeStream(SchemaVersion version) throws IOException;
- public abstract List<String>
- getJsonPayload(SchemaVersion version) throws IOException;
-
- /**
- * Translates the contents of the schema config file
- * into the input for the EdgeIngestor
- *
- * @return Map of Version to the List of (String) filenames to be
- * ingested for that version
- */
+ public abstract List<String> getJsonPayload(SchemaVersion version) throws IOException;
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the EdgeIngestor
+ *
+ * @return Map of Version to the List of (String) filenames to be
+ * ingested for that version
+ */
- public SchemaVersions getSchemaVersions(){
+ public SchemaVersions getSchemaVersions() {
return this.schemaVersions;
- }
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java
index 3fd536b0..1506f135 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/AAISchemaValidationException.java
@@ -24,7 +24,7 @@ package org.onap.aai.validation;
* Indicates that a fatal error in the A&AI schema has been found.
*/
public class AAISchemaValidationException extends IllegalStateException {
- public AAISchemaValidationException(String msg) {
- super(msg);
- }
+ public AAISchemaValidationException(String msg) {
+ super(msg);
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java
index 768c18bd..3f0ee41f 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java
@@ -21,6 +21,7 @@
/**
*
*/
+
package org.onap.aai.validation;
import java.util.ArrayList;
@@ -29,42 +30,48 @@ import java.util.List;
import org.apache.commons.lang.StringUtils;
/**
- * When an error is found, mark that it is NOT ok to
- * continue with installation/whatever other caller function,
+ * When an error is found, mark that it is NOT ok to
+ * continue with installation/whatever other caller function,
* and keep track of the message but
* keep validating so all issues are found in one run.
*/
public class CheckEverythingStrategy implements SchemaErrorStrategy {
- private boolean isOK = true;
- private List<String> errorMsgs = new ArrayList<>();
+ private boolean isOK = true;
+ private List<String> errorMsgs = new ArrayList<>();
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
- */
- @Override
- public boolean isOK() {
- return isOK;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
+ */
+ @Override
+ public boolean isOK() {
+ return isOK;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
- */
- @Override
- public String getErrorMsg() {
- if (errorMsgs.isEmpty()) {
- return "No errors found.";
- } else {
- return StringUtils.join(errorMsgs, "\n");
- }
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
+ */
+ @Override
+ public String getErrorMsg() {
+ if (errorMsgs.isEmpty()) {
+ return "No errors found.";
+ } else {
+ return StringUtils.join(errorMsgs, "\n");
+ }
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
- */
- @Override
- public void notifyOnError(String errorMsg) {
- isOK = false;
- errorMsgs.add(errorMsg);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
+ */
+ @Override
+ public void notifyOnError(String errorMsg) {
+ isOK = false;
+ errorMsgs.add(errorMsg);
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java
index 36176587..7308e377 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/DefaultVersionValidationModule.java
@@ -21,6 +21,7 @@
/**
*
*/
+
package org.onap.aai.validation;
import java.util.List;
@@ -41,15 +42,17 @@ public class DefaultVersionValidationModule implements VersionValidationModule {
private ConfigTranslator config;
- @Autowired
- public DefaultVersionValidationModule(ConfigTranslator config) {
+ @Autowired
+ public DefaultVersionValidationModule(ConfigTranslator config) {
- this.config = config;
- }
+ this.config = config;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.validation.VersionValidationModule#validate(org.onap.aai.setup.ConfigTranslator)
- */
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.validation.VersionValidationModule#validate(org.onap.aai.setup.ConfigTranslator)
+ */
@Override
public String validate() {
Map<SchemaVersion, List<String>> nodeConfig = config.getNodeFiles();
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java
index 2c21e685..1352e6b7 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/FailFastStrategy.java
@@ -21,6 +21,7 @@
/**
*
*/
+
package org.onap.aai.validation;
/**
@@ -29,33 +30,39 @@ package org.onap.aai.validation;
* process to abort.
*/
public class FailFastStrategy implements SchemaErrorStrategy {
- private boolean isOK = true;
- private String errorMsg = "No errors found.";
+ private boolean isOK = true;
+ private String errorMsg = "No errors found.";
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
- */
- @Override
- public boolean isOK() {
- return isOK;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
+ */
+ @Override
+ public boolean isOK() {
+ return isOK;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
- */
- @Override
- public String getErrorMsg() {
- return errorMsg;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
+ */
+ @Override
+ public String getErrorMsg() {
+ return errorMsg;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
- */
- @Override
- public void notifyOnError(String errorMsg) {
- isOK = false;
- this.errorMsg = errorMsg;
- throw new AAISchemaValidationException(errorMsg);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
+ */
+ @Override
+ public void notifyOnError(String errorMsg) {
+ isOK = false;
+ this.errorMsg = errorMsg;
+ throw new AAISchemaValidationException(errorMsg);
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java
index cefc29c2..f46416cb 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/SchemaErrorStrategy.java
@@ -24,36 +24,36 @@ package org.onap.aai.validation;
* Controls response to finding problems in the schema files.
*/
public interface SchemaErrorStrategy {
- /**
- * Gives if it is OK to proceed with whatever process
- * invoked the validation (probably the installation of
- * the A&AI instance).
- *
- * @return boolean
- */
- public boolean isOK();
-
- /**
- * Gets the error message(s) gathered in the course
- * of validation.
- *
- * @return String error message or messages concatenated together
- */
- public String getErrorMsg();
-
- /**
- * Invokes the ErrorStrategy to do whatever response to
- * an issue in the schema having been found.
- *
- * Options:
- * -Throw an exception if the whole process should be
- * immediately aborted
- * -Set OK status to false, store the message and allow the
- * validation process to continue and find any other issues
- * -Completely ignore that something is wrong
- * etc.
- *
- * @param String errorMsg - the error message from the validator module
- */
- public void notifyOnError(String errorMsg);
+ /**
+ * Gives if it is OK to proceed with whatever process
+ * invoked the validation (probably the installation of
+ * the A&AI instance).
+ *
+ * @return boolean
+ */
+ public boolean isOK();
+
+ /**
+ * Gets the error message(s) gathered in the course
+ * of validation.
+ *
+ * @return String error message or messages concatenated together
+ */
+ public String getErrorMsg();
+
+ /**
+ * Invokes the ErrorStrategy to do whatever response to
+ * an issue in the schema having been found.
+ *
+ * Options:
+ * -Throw an exception if the whole process should be
+ * immediately aborted
+ * -Set OK status to false, store the message and allow the
+ * validation process to continue and find any other issues
+ * -Completely ignore that something is wrong
+ * etc.
+ *
+ * @param String errorMsg - the error message from the validator module
+ */
+ public void notifyOnError(String errorMsg);
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java
index b87be79a..ec3523bf 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidationModule.java
@@ -20,19 +20,18 @@
package org.onap.aai.validation;
-
/**
* Defines the behavior for what versions are required/optional.
*
* Constructor must take ConfigTranslator via autowiring.
*/
public interface VersionValidationModule {
-
- /**
- * Validates that all required versions have schema
- * configured for them.
- *
- * @return empty string if none missing or else an appropriate error
- */
- public String validate();
+
+ /**
+ * Validates that all required versions have schema
+ * configured for them.
+ *
+ * @return empty string if none missing or else an appropriate error
+ */
+ public String validate();
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java
index 612da353..375bec0f 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/VersionValidator.java
@@ -29,25 +29,25 @@ import org.springframework.stereotype.Component;
*/
@Component
public class VersionValidator {
- private SchemaErrorStrategy strat;
- private VersionValidationModule verMod;
-
- @Autowired
- public VersionValidator(SchemaErrorStrategy strategy, VersionValidationModule verMod) {
- this.strat = strategy;
- this.verMod = verMod;
- }
-
- public boolean validate() {
- String result = verMod.validate();
- if (!"".equals(result)) {
- strat.notifyOnError(result);
- }
-
- return strat.isOK();
- }
-
- public String getErrorMsg() {
- return strat.getErrorMsg();
- }
+ private SchemaErrorStrategy strat;
+ private VersionValidationModule verMod;
+
+ @Autowired
+ public VersionValidator(SchemaErrorStrategy strategy, VersionValidationModule verMod) {
+ this.strat = strategy;
+ this.verMod = verMod;
+ }
+
+ public boolean validate() {
+ String result = verMod.validate();
+ if (!"".equals(result)) {
+ strat.notifyOnError(result);
+ }
+
+ return strat.isOK();
+ }
+
+ public String getErrorMsg() {
+ return strat.getErrorMsg();
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java
index d4ab7aeb..73337a49 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java
@@ -21,60 +21,62 @@
package org.onap.aai.validation.edges;
import com.jayway.jsonpath.DocumentContext;
+
+import java.util.*;
+
import org.onap.aai.edges.EdgeRuleQuery;
import org.onap.aai.edges.EdgeRuleQuery.Builder;
import org.onap.aai.edges.enums.EdgeField;
import org.onap.aai.edges.enums.EdgeType;
-import java.util.*;
-
/**
* Validates that in the collection of cousin rules between a given node type pair,
- * there is exactly 1 set default=true.
+ * there is exactly 1 set default=true.
*/
public class CousinDefaultingValidationModule {
- /**
- * Validates that in the collection of cousin rules between a given node type pair,
- * there is exactly 1 set default=true.
- *
- * @param String nodeTypePair - pair of A&AI node types in the form "typeA|typeB"
- * @param List<DocumentContext> ctxs - the ingested json schema to validate
- * @return empty string if ok, appropriate error message otherwise
- */
- public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
- String[] types = nodeTypePair.split("\\|");
- EdgeRuleQuery lookup = new Builder(types[0], types[1]).edgeType(EdgeType.COUSIN).build();
- List<Map<String, String>> rules = new ArrayList<>();
- for (DocumentContext ctx : ctxs) {
- rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
- }
-
- if (rules.isEmpty()) {
- return ""; //bc irrelevant check
- }
-
- int defaultCount = 0;
- Set<String> defLabels = new HashSet<>();
- for (Map<String, String> rule : rules) {
- if ("true".equals(rule.get(EdgeField.DEFAULT.toString()))) {
- defaultCount++;
- defLabels.add(rule.get(EdgeField.LABEL.toString()));
- }
- }
-
- StringBuilder errorBase = new StringBuilder().append("Pair ").append(nodeTypePair).append(" must have exactly one cousin rule set as default. ");
- if (defaultCount == 1) {
- return "";
- } else if (defaultCount == 0){
- errorBase.append("None set.");
- return errorBase.toString();
- } else {
- errorBase.append("Multiple set, see labels: ");
- for (String label : defLabels) {
- errorBase.append(label).append(" ");
- }
- return errorBase.toString();
- }
- }
+ /**
+ * Validates that in the collection of cousin rules between a given node type pair,
+ * there is exactly 1 set default=true.
+ *
+ * @param String nodeTypePair - pair of A&AI node types in the form "typeA|typeB"
+ * @param List<DocumentContext> ctxs - the ingested json schema to validate
+ * @return empty string if ok, appropriate error message otherwise
+ */
+ public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
+ String[] types = nodeTypePair.split("\\|");
+ EdgeRuleQuery lookup = new Builder(types[0], types[1]).edgeType(EdgeType.COUSIN).build();
+ List<Map<String, String>> rules = new ArrayList<>();
+ for (DocumentContext ctx : ctxs) {
+ rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
+ }
+
+ if (rules.isEmpty()) {
+ return ""; // bc irrelevant check
+ }
+
+ int defaultCount = 0;
+ Set<String> defLabels = new HashSet<>();
+ for (Map<String, String> rule : rules) {
+ if ("true".equals(rule.get(EdgeField.DEFAULT.toString()))) {
+ defaultCount++;
+ defLabels.add(rule.get(EdgeField.LABEL.toString()));
+ }
+ }
+
+ StringBuilder errorBase = new StringBuilder().append("Pair ").append(nodeTypePair)
+ .append(" must have exactly one cousin rule set as default. ");
+ if (defaultCount == 1) {
+ return "";
+ } else if (defaultCount == 0) {
+ errorBase.append("None set.");
+ return errorBase.toString();
+ } else {
+ errorBase.append("Multiple set, see labels: ");
+ for (String label : defLabels) {
+ errorBase.append(label).append(" ");
+ }
+ return errorBase.toString();
+ }
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java
index 9a7288b0..1229cf49 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java
@@ -21,14 +21,15 @@
/**
*
*/
-package org.onap.aai.validation.edges;
-import org.onap.aai.edges.enums.EdgeField;
+package org.onap.aai.validation.edges;
import java.util.EnumSet;
import java.util.Map;
import java.util.Map.Entry;
+import org.onap.aai.edges.enums.EdgeField;
+
/**
* Default core A&AI edge field validation
* All fields in EdgeField enum are required EXCEPT description
@@ -36,37 +37,41 @@ import java.util.Map.Entry;
*/
public class DefaultEdgeFieldsValidationModule implements EdgeFieldsValidationModule {
- /* (non-Javadoc)
- * @see org.onap.aai.edges.EdgeFieldsValidator#verifyFields(java.util.Map)
- */
- @Override
- public String verifyFields(Map<String, String> rule) {
- EnumSet<EdgeField> missingFields = EnumSet.complementOf(EnumSet.allOf(EdgeField.class));
-
- for (EdgeField f : EdgeField.values()) {
- if (!rule.containsKey(f.toString()) && (f != EdgeField.DESCRIPTION) && (f != EdgeField.PRIVATE)) { //description is optional
- missingFields.add(f);
- }
- }
-
- StringBuilder errorMsg = new StringBuilder();
- if (!missingFields.isEmpty()) {
- errorMsg.append("Rule ").append(ruleToString(rule)).append(" missing required fields: ");
- for (EdgeField mf : missingFields) {
- errorMsg.append(mf.toString()).append(" ");
- }
- }
-
- return errorMsg.toString();
- }
-
- private String ruleToString(Map<String, String> rule) {
- StringBuilder sb = new StringBuilder();
- for (Entry<String, String> fields : rule.entrySet()) {
- sb.append(fields.getKey()).append(":").append(fields.getValue()).append(" ");
- }
-
- return sb.toString();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.edges.EdgeFieldsValidator#verifyFields(java.util.Map)
+ */
+ @Override
+ public String verifyFields(Map<String, String> rule) {
+ EnumSet<EdgeField> missingFields = EnumSet.complementOf(EnumSet.allOf(EdgeField.class));
+
+ for (EdgeField f : EdgeField.values()) {
+ if (!rule.containsKey(f.toString()) && (f != EdgeField.DESCRIPTION) && (f != EdgeField.PRIVATE)) { // description
+ // is
+ // optional
+ missingFields.add(f);
+ }
+ }
+
+ StringBuilder errorMsg = new StringBuilder();
+ if (!missingFields.isEmpty()) {
+ errorMsg.append("Rule ").append(ruleToString(rule)).append(" missing required fields: ");
+ for (EdgeField mf : missingFields) {
+ errorMsg.append(mf.toString()).append(" ");
+ }
+ }
+
+ return errorMsg.toString();
+ }
+
+ private String ruleToString(Map<String, String> rule) {
+ StringBuilder sb = new StringBuilder();
+ for (Entry<String, String> fields : rule.entrySet()) {
+ sb.append(fields.getKey()).append(":").append(fields.getValue()).append(" ");
+ }
+
+ return sb.toString();
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java
index 10ac1892..3bfa8d80 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeFieldsValidationModule.java
@@ -27,28 +27,28 @@ import java.util.Map;
*
*/
public interface EdgeFieldsValidationModule {
-
- /**
- * Verifies the given rule has all required fields.
- * Implement to check for what you determine to be required.
- * You may also throw an error on unexpected fields if you wish,
- * whatever makes sense for your system.
- *
- * @param rule - Map<String, String> that will look something like this:
- * {
- * "from": "foo",
- * "to": "bar",
- * "label": "tosca.relationships.network.BindsTo",
- * "direction": "OUT",
- * "multiplicity": "ONE2ONE",
- * "contains-other-v": "NONE",
- * "delete-other-v": "NONE",
- * "prevent-delete": "NONE",
- * "default": "true",
- * "description":"An edge comment"
- * }
- * @return empty String if no errors found, or String with
- * the appropriate error message
- */
- public String verifyFields(Map<String, String> rule);
+
+ /**
+ * Verifies the given rule has all required fields.
+ * Implement to check for what you determine to be required.
+ * You may also throw an error on unexpected fields if you wish,
+ * whatever makes sense for your system.
+ *
+ * @param rule - Map<String, String> that will look something like this:
+ * {
+ * "from": "foo",
+ * "to": "bar",
+ * "label": "tosca.relationships.network.BindsTo",
+ * "direction": "OUT",
+ * "multiplicity": "ONE2ONE",
+ * "contains-other-v": "NONE",
+ * "delete-other-v": "NONE",
+ * "prevent-delete": "NONE",
+ * "default": "true",
+ * "description":"An edge comment"
+ * }
+ * @return empty String if no errors found, or String with
+ * the appropriate error message
+ */
+ public String verifyFields(Map<String, String> rule);
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java
index 38dcbb7e..4eedaa07 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/EdgeRuleValidator.java
@@ -21,37 +21,37 @@
package org.onap.aai.validation.edges;
import com.jayway.jsonpath.DocumentContext;
+
+import java.util.*;
+
import org.onap.aai.edges.JsonIngestor;
import org.onap.aai.edges.TypeAlphabetizer;
import org.onap.aai.edges.enums.EdgeField;
-
import org.onap.aai.setup.ConfigTranslator;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.validation.SchemaErrorStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.*;
-
/**
* Runs all validations against the ingested schema
*/
@Component
public class EdgeRuleValidator {
- private Map<SchemaVersion, List<DocumentContext>> versionJsonFilesMap;
- private final SchemaErrorStrategy strat;
- protected final EdgeFieldsValidationModule fieldValidator;
- protected final UniqueLabelValidationModule labelValidator;
- protected final SingleContainmentValidationModule containsValidator;
- protected final CousinDefaultingValidationModule defaultsValidator;
- protected final NodeTypesValidationModule typeValidator;
+ private Map<SchemaVersion, List<DocumentContext>> versionJsonFilesMap;
+ private final SchemaErrorStrategy strat;
+ protected final EdgeFieldsValidationModule fieldValidator;
+ protected final UniqueLabelValidationModule labelValidator;
+ protected final SingleContainmentValidationModule containsValidator;
+ protected final CousinDefaultingValidationModule defaultsValidator;
+ protected final NodeTypesValidationModule typeValidator;
@Autowired
public EdgeRuleValidator(ConfigTranslator config, SchemaErrorStrategy strat,
- EdgeFieldsValidationModule fieldValidator, UniqueLabelValidationModule labelValidator,
- SingleContainmentValidationModule containsValidator, CousinDefaultingValidationModule defaultsValidator,
- NodeTypesValidationModule typeValidator) {
- //TODO - Need to change this to use files/schemaservice
+ EdgeFieldsValidationModule fieldValidator, UniqueLabelValidationModule labelValidator,
+ SingleContainmentValidationModule containsValidator, CousinDefaultingValidationModule defaultsValidator,
+ NodeTypesValidationModule typeValidator) {
+ // TODO - Need to change this to use files/schemaservice
this.versionJsonFilesMap = new JsonIngestor().ingest(config.getEdgeFiles());
this.strat = strat;
this.fieldValidator = fieldValidator;
@@ -61,49 +61,50 @@ public class EdgeRuleValidator {
this.typeValidator = typeValidator;
}
- public boolean validate() {
-
- for (Map.Entry<SchemaVersion, List<DocumentContext>> verEntry : versionJsonFilesMap.entrySet()) {
- SchemaVersion v = verEntry.getKey();
- List<DocumentContext> ctxs = verEntry.getValue();
- List<Map<String, String>> rules = collectRules(ctxs);
- Set<String> nodeTypePairs = new HashSet<>();
- TypeAlphabetizer alpher = new TypeAlphabetizer();
-
- for (Map<String, String> rule : rules) {
- handleResult(fieldValidator.verifyFields(rule));
- nodeTypePairs.add(alpher.buildAlphabetizedKey(rule.get(EdgeField.FROM.toString()), rule.get(EdgeField.TO.toString())));
- }
-
- for (String nodeTypePair : nodeTypePairs) {
- handleResult(labelValidator.validate(nodeTypePair, ctxs));
- handleResult(containsValidator.validate(nodeTypePair, ctxs));
- handleResult(defaultsValidator.validate(nodeTypePair, ctxs));
- }
-
- handleResult(typeValidator.validate(nodeTypePairs, v));
- }
-
- return strat.isOK();
- }
-
- private List<Map<String, String>> collectRules(List<DocumentContext> ctxs) {
- List<Map<String, String>> rules = new ArrayList<>();
-
- for (DocumentContext ctx : ctxs) {
- rules.addAll(ctx.read("$.rules.*"));
- }
-
- return rules;
- }
-
- private void handleResult(String result) {
- if (!"".equals(result)) {
- strat.notifyOnError(result);
- }
- }
-
- public String getErrorMsg() {
- return strat.getErrorMsg();
- }
+ public boolean validate() {
+
+ for (Map.Entry<SchemaVersion, List<DocumentContext>> verEntry : versionJsonFilesMap.entrySet()) {
+ SchemaVersion v = verEntry.getKey();
+ List<DocumentContext> ctxs = verEntry.getValue();
+ List<Map<String, String>> rules = collectRules(ctxs);
+ Set<String> nodeTypePairs = new HashSet<>();
+ TypeAlphabetizer alpher = new TypeAlphabetizer();
+
+ for (Map<String, String> rule : rules) {
+ handleResult(fieldValidator.verifyFields(rule));
+ nodeTypePairs.add(alpher.buildAlphabetizedKey(rule.get(EdgeField.FROM.toString()),
+ rule.get(EdgeField.TO.toString())));
+ }
+
+ for (String nodeTypePair : nodeTypePairs) {
+ handleResult(labelValidator.validate(nodeTypePair, ctxs));
+ handleResult(containsValidator.validate(nodeTypePair, ctxs));
+ handleResult(defaultsValidator.validate(nodeTypePair, ctxs));
+ }
+
+ handleResult(typeValidator.validate(nodeTypePairs, v));
+ }
+
+ return strat.isOK();
+ }
+
+ private List<Map<String, String>> collectRules(List<DocumentContext> ctxs) {
+ List<Map<String, String>> rules = new ArrayList<>();
+
+ for (DocumentContext ctx : ctxs) {
+ rules.addAll(ctx.read("$.rules.*"));
+ }
+
+ return rules;
+ }
+
+ private void handleResult(String result) {
+ if (!"".equals(result)) {
+ strat.notifyOnError(result);
+ }
+ }
+
+ public String getErrorMsg() {
+ return strat.getErrorMsg();
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java
index e8c45063..0de66249 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/NodeTypesValidationModule.java
@@ -20,16 +20,15 @@
package org.onap.aai.validation.edges;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
/**
* Validates that the node types appearing in the edge rules are valid
* against the ingested OXM.
@@ -38,52 +37,52 @@ import java.util.Set;
*/
@Component
public class NodeTypesValidationModule {
- private NodeIngestor ni;
-
- @Autowired
- public NodeTypesValidationModule(NodeIngestor ni) {
- this.ni = ni;
- }
-
- /**
- * Validate that every node type in the given set is defined in
- * the OXM for the given version
- *
- * @param nodeTypePairs - all the node types in
- * the edge rules for the given version being validated
- * @param v - the version being validated
- * @return empty string if all types are present in the given version's ingested OXM, else
- * appropriate error message
- */
- public String validate(Collection<String> nodeTypePairs, SchemaVersion v) {
- //setup
- Set<String> nodeTypes = new HashSet<>();
- for (String pair : nodeTypePairs) {
- String[] types = pair.split("\\|");
-
- for (String type : types) {
- if (!"".equals(type)) {
- nodeTypes.add(type);
- }
- }
- }
-
- //validation
- Set<String> badTypes = new HashSet<>();
- for (String type : nodeTypes) {
- if (!ni.hasNodeType(type, v)) {
- badTypes.add(type);
- }
- }
-
- if (badTypes.isEmpty()) {
- return "";
- } else {
- StringBuilder errorBase = new StringBuilder().append("Invalid node type(s) found: ");
- for (String bt : badTypes) {
- errorBase.append(bt).append(" ");
- }
- return errorBase.toString();
- }
- }
+ private NodeIngestor ni;
+
+ @Autowired
+ public NodeTypesValidationModule(NodeIngestor ni) {
+ this.ni = ni;
+ }
+
+ /**
+ * Validate that every node type in the given set is defined in
+ * the OXM for the given version
+ *
+ * @param nodeTypePairs - all the node types in
+ * the edge rules for the given version being validated
+ * @param v - the version being validated
+ * @return empty string if all types are present in the given version's ingested OXM, else
+ * appropriate error message
+ */
+ public String validate(Collection<String> nodeTypePairs, SchemaVersion v) {
+ // setup
+ Set<String> nodeTypes = new HashSet<>();
+ for (String pair : nodeTypePairs) {
+ String[] types = pair.split("\\|");
+
+ for (String type : types) {
+ if (!"".equals(type)) {
+ nodeTypes.add(type);
+ }
+ }
+ }
+
+ // validation
+ Set<String> badTypes = new HashSet<>();
+ for (String type : nodeTypes) {
+ if (!ni.hasNodeType(type, v)) {
+ badTypes.add(type);
+ }
+ }
+
+ if (badTypes.isEmpty()) {
+ return "";
+ } else {
+ StringBuilder errorBase = new StringBuilder().append("Invalid node type(s) found: ");
+ for (String bt : badTypes) {
+ errorBase.append(bt).append(" ");
+ }
+ return errorBase.toString();
+ }
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java
index ad2cffeb..5f6a9646 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java
@@ -21,40 +21,41 @@
package org.onap.aai.validation.edges;
import com.jayway.jsonpath.DocumentContext;
-import org.onap.aai.edges.EdgeRuleQuery;
-import org.onap.aai.edges.enums.EdgeType;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.onap.aai.edges.EdgeRuleQuery;
+import org.onap.aai.edges.enums.EdgeType;
+
/**
* Validates that the given node type pair has at most one containment relationship
* in their edge rules.
*
*/
public class SingleContainmentValidationModule {
-
- /**
- * Validates that the given node type pair has at most one containment relationship
- * in their edge rules.
- *
- * @param String nodeTypePair - pair of A&AI node types in the form "typeA|typeB"
- * @param List<DocumentContext> ctxs - the ingested json to validate
- * @return empty string if passes, else appropriate error message
- */
- public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
- String[] types = nodeTypePair.split("\\|");
- EdgeRuleQuery lookup = new EdgeRuleQuery.Builder(types[0], types[1]).edgeType(EdgeType.TREE).build();
- List<Map<String, String>> rules = new ArrayList<>();
- for (DocumentContext ctx : ctxs) {
- rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
- }
-
- if (rules.isEmpty() || rules.size() == 1) {
- return "";
- } else { //had more than one containment relationship for the pair
- return "Pair " + nodeTypePair + " has multiple containment rules. Only one allowed.";
- }
- }
+
+ /**
+ * Validates that the given node type pair has at most one containment relationship
+ * in their edge rules.
+ *
+ * @param String nodeTypePair - pair of A&AI node types in the form "typeA|typeB"
+ * @param List<DocumentContext> ctxs - the ingested json to validate
+ * @return empty string if passes, else appropriate error message
+ */
+ public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
+ String[] types = nodeTypePair.split("\\|");
+ EdgeRuleQuery lookup = new EdgeRuleQuery.Builder(types[0], types[1]).edgeType(EdgeType.TREE).build();
+ List<Map<String, String>> rules = new ArrayList<>();
+ for (DocumentContext ctx : ctxs) {
+ rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
+ }
+
+ if (rules.isEmpty() || rules.size() == 1) {
+ return "";
+ } else { // had more than one containment relationship for the pair
+ return "Pair " + nodeTypePair + " has multiple containment rules. Only one allowed.";
+ }
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java
index 35d74667..82dc1694 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java
@@ -21,46 +21,47 @@
package org.onap.aai.validation.edges;
import com.jayway.jsonpath.DocumentContext;
+
+import java.util.*;
+
import org.onap.aai.edges.EdgeRuleQuery;
import org.onap.aai.edges.EdgeRuleQuery.Builder;
import org.onap.aai.edges.enums.EdgeField;
-import java.util.*;
-
/**
* Applies label validation rules
*
*/
public class UniqueLabelValidationModule {
-
- /**
- * Validates that the given pair of node types have no duplicate labels in
- * their edge rules
- *
- * @param String nodeTypePair - of the form "typeA|typeB"
- * @param List<DocumentContext> ctxs - the edge rule json to pull rules from
- * (ie all files for one version)
- * @return empty string if no errors, else string error message
- */
- public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
- String[] types = nodeTypePair.split("\\|");
- EdgeRuleQuery lookup = new Builder(types[0], types[1]).build();
-
- List<Map<String, String>> rules = new ArrayList<>();
- for (DocumentContext ctx : ctxs) {
- rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
- }
-
- Set<String> labelsSeen = new HashSet<>();
- for (Map<String, String> rule : rules) {
- String label = rule.get(EdgeField.LABEL.toString());
- if (labelsSeen.contains(label)) {
- return "Pair " + nodeTypePair + " has multiple rules using the same label: " + label +
- ". Every rule between the same node type pair must have a unique label.";
- } else {
- labelsSeen.add(label);
- }
- }
- return "";
- }
+
+ /**
+ * Validates that the given pair of node types have no duplicate labels in
+ * their edge rules
+ *
+ * @param String nodeTypePair - of the form "typeA|typeB"
+ * @param List<DocumentContext> ctxs - the edge rule json to pull rules from
+ * (ie all files for one version)
+ * @return empty string if no errors, else string error message
+ */
+ public String validate(String nodeTypePair, List<DocumentContext> ctxs) {
+ String[] types = nodeTypePair.split("\\|");
+ EdgeRuleQuery lookup = new Builder(types[0], types[1]).build();
+
+ List<Map<String, String>> rules = new ArrayList<>();
+ for (DocumentContext ctx : ctxs) {
+ rules.addAll(ctx.read("$.rules.[?]", lookup.getFilter()));
+ }
+
+ Set<String> labelsSeen = new HashSet<>();
+ for (Map<String, String> rule : rules) {
+ String label = rule.get(EdgeField.LABEL.toString());
+ if (labelsSeen.contains(label)) {
+ return "Pair " + nodeTypePair + " has multiple rules using the same label: " + label
+ + ". Every rule between the same node type pair must have a unique label.";
+ } else {
+ labelsSeen.add(label);
+ }
+ }
+ return "";
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java
index bbb3388f..024525b9 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DefaultDuplicateNodeDefinitionValidationModule.java
@@ -20,6 +20,9 @@
package org.onap.aai.validation.nodes;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -36,9 +39,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-
/**
* Default duplicate rules for A&AI -
* node types may never have a duplicate definition
@@ -49,56 +49,59 @@ import com.google.common.collect.Multimap;
*/
public class DefaultDuplicateNodeDefinitionValidationModule implements DuplicateNodeDefinitionValidationModule {
- /* (non-Javadoc)
- * @see org.onap.aai.nodes.validation.DuplicateNodeDefinitionValidationModule#findDuplicates(java.util.List)
- */
- @Override
- public String findDuplicates(List<String> files, SchemaVersion v) {
- try {
- final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
-
- Multimap<String, String> types = ArrayListMultimap.create();
- boolean foundDups = false;
- for (String file : files) {
- InputStream inputStream = new FileInputStream(file);
- final Document doc = docBuilder.parse(inputStream);
- final NodeList list = doc.getElementsByTagName("java-type");
-
- for (int i = 0; i < list.getLength(); i++) {
- String type = list.item(i).getAttributes().getNamedItem("name").getNodeValue();
- if (types.containsKey(type)) {
- foundDups = true;
- }
- types.put(type, file);
- }
- }
-
- if (foundDups) {
- return buildErrorMsg(types, v);
- } else {
- return "";
- }
- } catch (ParserConfigurationException | SAXException | IOException e) {
- // TODO something useful with this information
- return e.getMessage();
- }
- }
-
- private String buildErrorMsg(Multimap<String, String> types, SchemaVersion v) {
- StringBuilder errorMsg = new StringBuilder().append("Duplicates found in version ").append(v.toString()).append(". ");
- for (String nodeType : types.keySet()) {
- Collection<String> files = types.get(nodeType);
- if (files.size() == 1) {
- continue; //only record the duplicated ones
- }
- errorMsg.append(nodeType).append(" has definitions in ");
- for (String file : files) {
- errorMsg.append(file).append(" ");
- }
- }
- return errorMsg.toString();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.aai.nodes.validation.DuplicateNodeDefinitionValidationModule#findDuplicates(java.util.List)
+ */
+ @Override
+ public String findDuplicates(List<String> files, SchemaVersion v) {
+ try {
+ final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+
+ Multimap<String, String> types = ArrayListMultimap.create();
+ boolean foundDups = false;
+ for (String file : files) {
+ InputStream inputStream = new FileInputStream(file);
+ final Document doc = docBuilder.parse(inputStream);
+ final NodeList list = doc.getElementsByTagName("java-type");
+
+ for (int i = 0; i < list.getLength(); i++) {
+ String type = list.item(i).getAttributes().getNamedItem("name").getNodeValue();
+ if (types.containsKey(type)) {
+ foundDups = true;
+ }
+ types.put(type, file);
+ }
+ }
+
+ if (foundDups) {
+ return buildErrorMsg(types, v);
+ } else {
+ return "";
+ }
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ // TODO something useful with this information
+ return e.getMessage();
+ }
+ }
+
+ private String buildErrorMsg(Multimap<String, String> types, SchemaVersion v) {
+ StringBuilder errorMsg =
+ new StringBuilder().append("Duplicates found in version ").append(v.toString()).append(". ");
+ for (String nodeType : types.keySet()) {
+ Collection<String> files = types.get(nodeType);
+ if (files.size() == 1) {
+ continue; // only record the duplicated ones
+ }
+ errorMsg.append(nodeType).append(" has definitions in ");
+ for (String file : files) {
+ errorMsg.append(file).append(" ");
+ }
+ }
+ return errorMsg.toString();
+ }
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java
index 5484adda..4fbf4198 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/DuplicateNodeDefinitionValidationModule.java
@@ -35,13 +35,13 @@ import org.onap.aai.setup.SchemaVersion;
* etc.
*/
public interface DuplicateNodeDefinitionValidationModule {
- /**
- * Finds any duplicates according to the defined rules
- *
- * @param files - the OXM files to use with full directory
- * @return empty String if none found, else a String
- * with appropriate information about what node types
- * were found
- */
- String findDuplicates(List<String> files, SchemaVersion v);
+ /**
+ * Finds any duplicates according to the defined rules
+ *
+ * @param files - the OXM files to use with full directory
+ * @return empty String if none found, else a String
+ * with appropriate information about what node types
+ * were found
+ */
+ String findDuplicates(List<String> files, SchemaVersion v);
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java
index 38b3a70c..ac9ecbdd 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/nodes/NodeValidator.java
@@ -33,28 +33,29 @@ import org.springframework.stereotype.Component;
public class NodeValidator {
private ConfigTranslator translator;
- private SchemaErrorStrategy strat;
- private DuplicateNodeDefinitionValidationModule dupChecker;
+ private SchemaErrorStrategy strat;
+ private DuplicateNodeDefinitionValidationModule dupChecker;
- @Autowired
- public NodeValidator( ConfigTranslator translator, SchemaErrorStrategy strategy, DuplicateNodeDefinitionValidationModule dupChecker) {
+ @Autowired
+ public NodeValidator(ConfigTranslator translator, SchemaErrorStrategy strategy,
+ DuplicateNodeDefinitionValidationModule dupChecker) {
this.translator = translator;
- this.strat = strategy;
- this.dupChecker = dupChecker;
- }
-
- public boolean validate() {
-
- for(Entry<SchemaVersion, List<String>> entry : translator.getNodeFiles().entrySet()) {
- String result = dupChecker.findDuplicates(entry.getValue(), entry.getKey());
- if (!"".equals(result)) {
- strat.notifyOnError(result);
- }
- }
- return strat.isOK();
- }
-
- public String getErrorMsg() {
- return strat.getErrorMsg();
- }
+ this.strat = strategy;
+ this.dupChecker = dupChecker;
+ }
+
+ public boolean validate() {
+
+ for (Entry<SchemaVersion, List<String>> entry : translator.getNodeFiles().entrySet()) {
+ String result = dupChecker.findDuplicates(entry.getValue(), entry.getKey());
+ if (!"".equals(result)) {
+ strat.notifyOnError(result);
+ }
+ }
+ return strat.isOK();
+ }
+
+ public String getErrorMsg() {
+ return strat.getErrorMsg();
+ }
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java
index 3ed7bb79..e3826576 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorLocalTest.java
@@ -20,18 +20,23 @@
package org.onap.aai.edges;
+import static org.junit.Assert.*;
+
import com.google.common.collect.Multimap;
+
+import java.util.Collection;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.onap.aai.restclient.MockProvider;
import org.onap.aai.config.EdgesConfiguration;
import org.onap.aai.edges.enums.AAIDirection;
import org.onap.aai.edges.enums.MultiplicityRule;
import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
+import org.onap.aai.restclient.MockProvider;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.testutils.TestUtilConfigTranslator;
@@ -42,16 +47,14 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.util.Collection;
-
-import static org.junit.Assert.*;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { EdgesConfiguration.class, TestUtilConfigTranslator.class})
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" })
+@ContextConfiguration(classes = {EdgesConfiguration.class, TestUtilConfigTranslator.class})
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
-//@TestPropertySource(locations = "/schema-service-rest.properties" )
+// @TestPropertySource(locations = "/schema-service-rest.properties" )
@SpringBootTest
public class EdgeIngestorLocalTest {
@Autowired
@@ -70,7 +73,7 @@ public class EdgeIngestorLocalTest {
assertTrue(2 == results.get("bar|foo").size());
boolean seenLabel1 = false;
boolean seenLabel2 = false;
- for(EdgeRule r : results.get("bar|foo")) {
+ for (EdgeRule r : results.get("bar|foo")) {
if ("eats".equals(r.getLabel())) {
seenLabel1 = true;
}
@@ -107,16 +110,17 @@ public class EdgeIngestorLocalTest {
@Test
public void getRulesFlippedTypesTest() throws EdgeRuleNotFoundException {
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build();
+ EdgeRuleQuery q =
+ new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build();
Multimap<String, EdgeRule> results = edgeIngestor.getRules(q);
assertTrue(results.size() == 3);
for (EdgeRule r : results.get("l-interface|logical-link")) {
- if ("org.onap.relationships.inventory.Source".equals(r.getLabel()) ||
- "org.onap.relationships.inventory.Destination".equals(r.getLabel())) {
- //these are defined with from=logical-link, to=l-interface, so they must be flipped
+ if ("org.onap.relationships.inventory.Source".equals(r.getLabel())
+ || "org.onap.relationships.inventory.Destination".equals(r.getLabel())) {
+ // these are defined with from=logical-link, to=l-interface, so they must be flipped
assertTrue(Direction.IN.equals(r.getDirection()));
} else if ("tosca.relationships.network.LinksTo".equals(r.getLabel())) {
- //this is defined with from=l-interface, to=logical-link, so it shouldn't be flipped
+ // this is defined with from=l-interface, to=logical-link, so it shouldn't be flipped
assertTrue(Direction.OUT.equals(r.getDirection()));
} else {
fail("how did you get here");
@@ -126,19 +130,19 @@ public class EdgeIngestorLocalTest {
@Test
public void fromToSameFlipTests() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- //getRules, setting from and to
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop","bloop").version(new SchemaVersion("v11")).build();
+ // getRules, setting from and to
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop", "bloop").version(new SchemaVersion("v11")).build();
Multimap<String, EdgeRule> results = edgeIngestor.getRules(q);
assertTrue(results.size() == 1);
for (EdgeRule r : results.get("bloop|bloop")) {
assertTrue(Direction.IN.equals(r.getDirection()));
}
- //getRule, setting just from
+ // getRule, setting just from
EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bloop").version(new SchemaVersion("v11")).build();
assertTrue(Direction.IN.equals(edgeIngestor.getRule(q2).getDirection()));
- //getChildRules
+ // getChildRules
Multimap<String, EdgeRule> child = edgeIngestor.getChildRules("bloop", new SchemaVersion("v11"));
assertTrue(child.size() == 1);
for (EdgeRule r : child.get("bloop|bloop")) {
@@ -186,7 +190,7 @@ public class EdgeIngestorLocalTest {
assertTrue("parent".equals(result.getFrom()));
assertTrue("notation".equals(result.getTo()));
assertTrue("has".equals(result.getLabel()));
- //direction flipped to match input order per old EdgeRules.java API
+ // direction flipped to match input order per old EdgeRules.java API
assertTrue(Direction.IN.equals(result.getDirection()));
assertTrue(MultiplicityRule.MANY2MANY.equals(result.getMultiplicityRule()));
assertTrue(AAIDirection.OUT.toString().equals(result.getContains()));
@@ -195,44 +199,47 @@ public class EdgeIngestorLocalTest {
assertTrue("parent contains notation".equals(result.getDescription()));
}
-// @Test
-// public void getRuleWithDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-//
-// EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").version(new SchemaVersion("v11")).build();
-// EdgeRule res = edgeIngestor.getRule(q);
-// assertTrue(res.isDefault());
-// assertTrue("tosca.relationships.network.LinksTo".equals(res.getLabel()));
-// }
-//
-// @Test
-// public void getRuleWithNonDefault() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-// EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").label("org.onap.relationships.inventory.Source").version(new SchemaVersion("v11")).build();
-// EdgeRule res = edgeIngestor.getRule(q);
-// assertFalse(res.isDefault());
-// assertTrue("org.onap.relationships.inventory.Source".equals(res.getLabel()));
-// }
+ // @Test
+ // public void getRuleWithDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ //
+ // EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").version(new
+ // SchemaVersion("v11")).build();
+ // EdgeRule res = edgeIngestor.getRule(q);
+ // assertTrue(res.isDefault());
+ // assertTrue("tosca.relationships.network.LinksTo".equals(res.getLabel()));
+ // }
+ //
+ // @Test
+ // public void getRuleWithNonDefault() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ // EdgeRuleQuery q = new
+ // EdgeRuleQuery.Builder("l-interface","logical-link").label("org.onap.relationships.inventory.Source").version(new
+ // SchemaVersion("v11")).build();
+ // EdgeRule res = edgeIngestor.getRule(q);
+ // assertFalse(res.isDefault());
+ // assertTrue("org.onap.relationships.inventory.Source".equals(res.getLabel()));
+ // }
@Test
public void getRuleNoneFoundTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
thrown.expect(EdgeRuleNotFoundException.class);
thrown.expectMessage("No rule found for");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","nonexistent").build();
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build();
edgeIngestor.getRule(q);
}
-// @Test
-// public void getRuleTooManyPairsTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-// thrown.expect(AmbiguousRuleChoiceException.class);
-// thrown.expectMessage("No way to select single rule from these pairs:");
-// EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
-// edgeIngestor.getRule(q);
-// }
+ // @Test
+ // public void getRuleTooManyPairsTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ // thrown.expect(AmbiguousRuleChoiceException.class);
+ // thrown.expectMessage("No way to select single rule from these pairs:");
+ // EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
+ // edgeIngestor.getRule(q);
+ // }
@Test
public void getRuleAmbiguousDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
thrown.expect(AmbiguousRuleChoiceException.class);
thrown.expectMessage("Multiple defaults found.");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed","plant").version(new SchemaVersion("v11")).build();
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build();
edgeIngestor.getRule(q);
}
@@ -244,19 +251,20 @@ public class EdgeIngestorLocalTest {
edgeIngestor.getRule(q);
}
-// @Test
-// public void hasRuleTest() {
-// assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build()));
-// assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build()));
-// }
-//
-// @Test
-// public void getCousinRulesTest() {
-// Multimap<String, EdgeRule> results = edgeIngestor.getCousinRules("dog");
-// assertTrue(results.size() == 2);
-// assertTrue(results.containsKey("dog|puppy"));
-// assertTrue(results.containsKey("dog|foo"));
-// }
+ // @Test
+ // public void hasRuleTest() {
+ // assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new
+ // SchemaVersion("v11")).build()));
+ // assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build()));
+ // }
+ //
+ // @Test
+ // public void getCousinRulesTest() {
+ // Multimap<String, EdgeRule> results = edgeIngestor.getCousinRules("dog");
+ // assertTrue(results.size() == 2);
+ // assertTrue(results.containsKey("dog|puppy"));
+ // assertTrue(results.containsKey("dog|foo"));
+ // }
@Test
public void getCousinRulesWithVersionTest() {
@@ -272,13 +280,13 @@ public class EdgeIngestorLocalTest {
assertTrue(results.isEmpty());
}
-// @Test
-// public void hasCousinTest() {
-// assertTrue(edgeIngestor.hasCousinRule("foo"));
-// assertTrue(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v10")));
-// assertFalse(edgeIngestor.hasCousinRule("parent"));
-// assertFalse(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v11")));
-// }
+ // @Test
+ // public void hasCousinTest() {
+ // assertTrue(edgeIngestor.hasCousinRule("foo"));
+ // assertTrue(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v10")));
+ // assertFalse(edgeIngestor.hasCousinRule("parent"));
+ // assertFalse(edgeIngestor.hasCousinRule("foo", new SchemaVersion("v11")));
+ // }
@Test
public void getChildRulesTest() {
@@ -306,13 +314,13 @@ public class EdgeIngestorLocalTest {
assertTrue(results.isEmpty());
}
-// @Test
-// public void hasChildTest() {
-// assertTrue(edgeIngestor.hasChildRule("foo"));
-// assertTrue(edgeIngestor.hasChildRule("foo", new SchemaVersion("v10")));
-// assertFalse(edgeIngestor.hasChildRule("puppy"));
-// assertFalse(edgeIngestor.hasChildRule("foo", new SchemaVersion("v11")));
-// }
+ // @Test
+ // public void hasChildTest() {
+ // assertTrue(edgeIngestor.hasChildRule("foo"));
+ // assertTrue(edgeIngestor.hasChildRule("foo", new SchemaVersion("v10")));
+ // assertFalse(edgeIngestor.hasChildRule("puppy"));
+ // assertFalse(edgeIngestor.hasChildRule("foo", new SchemaVersion("v11")));
+ // }
@Test
public void getParentRulesTest() {
@@ -347,11 +355,11 @@ public class EdgeIngestorLocalTest {
assertFalse(edgeIngestor.hasParentRule("foo", new SchemaVersion("v11")));
}
-// @Test
-// public void getAllCurrentRulesTest() throws EdgeRuleNotFoundException {
-// Multimap<String, EdgeRule> res = edgeIngestor.getAllCurrentRules();
-// assertTrue(res.size() == 18);
-// }
+ // @Test
+ // public void getAllCurrentRulesTest() throws EdgeRuleNotFoundException {
+ // Multimap<String, EdgeRule> res = edgeIngestor.getAllCurrentRules();
+ // assertTrue(res.size() == 18);
+ // }
@Test
public void getAllRulesTest() throws EdgeRuleNotFoundException {
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java
index ab83e196..8fdce62b 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorTest.java
@@ -22,6 +22,8 @@ package org.onap.aai.edges;
import static org.junit.Assert.*;
+import com.google.common.collect.Multimap;
+
import java.util.Collection;
import org.apache.tinkerpop.gremlin.structure.Direction;
@@ -30,13 +32,13 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.onap.aai.restclient.MockProvider;
-import org.onap.aai.restclient.MockRestClient;
import org.onap.aai.config.EdgesConfiguration;
import org.onap.aai.edges.enums.AAIDirection;
import org.onap.aai.edges.enums.MultiplicityRule;
import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
+import org.onap.aai.restclient.MockProvider;
+import org.onap.aai.restclient.MockRestClient;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -45,11 +47,10 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import com.google.common.collect.Multimap;
-
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {MockProvider.class, EdgesConfiguration.class})
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties" })
+@TestPropertySource(
+ properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties"})
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@SpringBootTest
@@ -74,7 +75,7 @@ public class EdgeIngestorTest {
assertTrue(2 == results.get("bar|foo").size());
boolean seenLabel1 = false;
boolean seenLabel2 = false;
- for(EdgeRule r : results.get("bar|foo")) {
+ for (EdgeRule r : results.get("bar|foo")) {
if ("eats".equals(r.getLabel())) {
seenLabel1 = true;
}
@@ -111,16 +112,17 @@ public class EdgeIngestorTest {
@Test
public void getRulesFlippedTypesTest() throws EdgeRuleNotFoundException {
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build();
+ EdgeRuleQuery q =
+ new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build();
Multimap<String, EdgeRule> results = edgeIngestor.getRules(q);
assertTrue(results.size() == 3);
for (EdgeRule r : results.get("l-interface|logical-link")) {
- if ("org.onap.relationships.inventory.Source".equals(r.getLabel()) ||
- "org.onap.relationships.inventory.Destination".equals(r.getLabel())) {
- //these are defined with from=logical-link, to=l-interface, so they must be flipped
+ if ("org.onap.relationships.inventory.Source".equals(r.getLabel())
+ || "org.onap.relationships.inventory.Destination".equals(r.getLabel())) {
+ // these are defined with from=logical-link, to=l-interface, so they must be flipped
assertTrue(Direction.IN.equals(r.getDirection()));
} else if ("tosca.relationships.network.LinksTo".equals(r.getLabel())) {
- //this is defined with from=l-interface, to=logical-link, so it shouldn't be flipped
+ // this is defined with from=l-interface, to=logical-link, so it shouldn't be flipped
assertTrue(Direction.OUT.equals(r.getDirection()));
} else {
fail("how did you get here");
@@ -130,19 +132,19 @@ public class EdgeIngestorTest {
@Test
public void fromToSameFlipTests() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- //getRules, setting from and to
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop","bloop").version(new SchemaVersion("v11")).build();
+ // getRules, setting from and to
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("bloop", "bloop").version(new SchemaVersion("v11")).build();
Multimap<String, EdgeRule> results = edgeIngestor.getRules(q);
assertTrue(results.size() == 1);
for (EdgeRule r : results.get("bloop|bloop")) {
assertTrue(Direction.IN.equals(r.getDirection()));
}
- //getRule, setting just from
+ // getRule, setting just from
EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bloop").version(new SchemaVersion("v11")).build();
assertTrue(Direction.IN.equals(edgeIngestor.getRule(q2).getDirection()));
- //getChildRules
+ // getChildRules
Multimap<String, EdgeRule> child = edgeIngestor.getChildRules("bloop", new SchemaVersion("v11"));
assertTrue(child.size() == 1);
for (EdgeRule r : child.get("bloop|bloop")) {
@@ -182,25 +184,24 @@ public class EdgeIngestorTest {
assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete()));
assertTrue("parent contains notation".equals(result.getDescription()));
}
-// @Test
-// public void getRuleSimpleTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
-// EdgeRuleQuery q = new EdgeRuleQuery.Builder("parent", "notation").build();
-// Multimap<String, EdgeRule> results = edgeIngestor.getRules(q);
-// assertTrue(results.size() == 1);
-// // EdgeRule result = edgeIngestor.getRule(q);
-// for (EdgeRule result : results.get("parent|notation")) {
-// assertTrue("parent".equals(result.getFrom()));
-// assertTrue("notation".equals(result.getTo()));
-// assertTrue("has".equals(result.getLabel()));
-// assertTrue(Direction.OUT.equals(result.getDirection()));
-// assertTrue(MultiplicityRule.MANY2MANY.equals(result.getMultiplicityRule()));
-// assertTrue(AAIDirection.OUT.toString().equals(result.getContains()));
-// assertTrue(AAIDirection.NONE.toString().equals(result.getDeleteOtherV()));
-// assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete()));
-// assertTrue("parent contains notation".equals(result.getDescription()));
-// }
-// }
-
+ // @Test
+ // public void getRuleSimpleTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+ // EdgeRuleQuery q = new EdgeRuleQuery.Builder("parent", "notation").build();
+ // Multimap<String, EdgeRule> results = edgeIngestor.getRules(q);
+ // assertTrue(results.size() == 1);
+ // // EdgeRule result = edgeIngestor.getRule(q);
+ // for (EdgeRule result : results.get("parent|notation")) {
+ // assertTrue("parent".equals(result.getFrom()));
+ // assertTrue("notation".equals(result.getTo()));
+ // assertTrue("has".equals(result.getLabel()));
+ // assertTrue(Direction.OUT.equals(result.getDirection()));
+ // assertTrue(MultiplicityRule.MANY2MANY.equals(result.getMultiplicityRule()));
+ // assertTrue(AAIDirection.OUT.toString().equals(result.getContains()));
+ // assertTrue(AAIDirection.NONE.toString().equals(result.getDeleteOtherV()));
+ // assertTrue(AAIDirection.NONE.toString().equals(result.getPreventDelete()));
+ // assertTrue("parent contains notation".equals(result.getDescription()));
+ // }
+ // }
@Test
public void getRuleFlippedTypesTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
@@ -209,7 +210,7 @@ public class EdgeIngestorTest {
assertTrue("parent".equals(result.getFrom()));
assertTrue("notation".equals(result.getTo()));
assertTrue("has".equals(result.getLabel()));
- //direction flipped to match input order per old EdgeRules.java API
+ // direction flipped to match input order per old EdgeRules.java API
assertTrue(Direction.IN.equals(result.getDirection()));
assertTrue(MultiplicityRule.MANY2MANY.equals(result.getMultiplicityRule()));
assertTrue(AAIDirection.OUT.toString().equals(result.getContains()));
@@ -221,7 +222,8 @@ public class EdgeIngestorTest {
@Test
public void getRuleWithDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").version(new SchemaVersion("v11")).build();
+ EdgeRuleQuery q =
+ new EdgeRuleQuery.Builder("l-interface", "logical-link").version(new SchemaVersion("v11")).build();
EdgeRule res = edgeIngestor.getRule(q);
assertTrue(res.isDefault());
assertTrue("tosca.relationships.network.LinksTo".equals(res.getLabel()));
@@ -229,7 +231,8 @@ public class EdgeIngestorTest {
@Test
public void getRuleWithNonDefault() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","logical-link").label("org.onap.relationships.inventory.Source").version(new SchemaVersion("v11")).build();
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "logical-link")
+ .label("org.onap.relationships.inventory.Source").version(new SchemaVersion("v11")).build();
EdgeRule res = edgeIngestor.getRule(q);
assertFalse(res.isDefault());
assertTrue("org.onap.relationships.inventory.Source".equals(res.getLabel()));
@@ -239,7 +242,7 @@ public class EdgeIngestorTest {
public void getRuleNoneFoundTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
thrown.expect(EdgeRuleNotFoundException.class);
thrown.expectMessage("No rule found for");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface","nonexistent").build();
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build();
edgeIngestor.getRule(q);
}
@@ -255,7 +258,7 @@ public class EdgeIngestorTest {
public void getRuleAmbiguousDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
thrown.expect(AmbiguousRuleChoiceException.class);
thrown.expectMessage("Multiple defaults found.");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed","plant").version(new SchemaVersion("v11")).build();
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build();
edgeIngestor.getRule(q);
}
@@ -269,10 +272,12 @@ public class EdgeIngestorTest {
@Test
public void hasRuleTest() {
- assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build()));
- assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v10")).build()));
+ assertTrue(edgeIngestor
+ .hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v11")).build()));
+ assertFalse(edgeIngestor
+ .hasRule(new EdgeRuleQuery.Builder("l-interface").version(new SchemaVersion("v10")).build()));
assertTrue(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build()));
-// assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build()));
+ // assertFalse(edgeIngestor.hasRule(new EdgeRuleQuery.Builder("l-interface").build()));
}
@Test
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java
index 395c9cc7..0a6a3f07 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeIngestorWiringTest.java
@@ -22,6 +22,8 @@ package org.onap.aai.edges;
import static org.junit.Assert.*;
+import com.google.common.collect.Multimap;
+
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,7 +31,6 @@ import org.onap.aai.config.EdgesConfiguration;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersionsBean;
-
import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -37,20 +38,21 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import com.google.common.collect.Multimap;
-
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {EdgesConfiguration.class, ConfigTranslatorForWiringTest.class})
-@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@SpringBootTest
public class EdgeIngestorWiringTest {
@Autowired
EdgeIngestor ei;
-
+
@Test
public void test() throws EdgeRuleNotFoundException {
assertNotNull(ei);
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("quux", "foo").label("dancesWith").version(new SchemaVersion("v10")).build();
+ EdgeRuleQuery q =
+ new EdgeRuleQuery.Builder("quux", "foo").label("dancesWith").version(new SchemaVersion("v10")).build();
Multimap<String, EdgeRule> results = ei.getRules(q);
assertTrue(results.size() == 1);
assertTrue(results.containsKey("foo|quux"));
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java
index 27c8d6e1..c1894f00 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleQueryTest.java
@@ -22,6 +22,9 @@ package org.onap.aai.edges;
import static org.junit.Assert.*;
+import com.jayway.jsonpath.DocumentContext;
+import com.jayway.jsonpath.JsonPath;
+
import java.io.InputStream;
import java.util.List;
import java.util.Scanner;
@@ -30,14 +33,10 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.aai.edges.enums.EdgeType;
-import com.jayway.jsonpath.DocumentContext;
-import com.jayway.jsonpath.JsonPath;
-
-
public class EdgeRuleQueryTest {
private DocumentContext testRules;
private String readStart = "$.rules.[?]";
-
+
/* **** DATA SETUP **** */
@Before
public void setup() {
@@ -46,85 +45,85 @@ public class EdgeRuleQueryTest {
Scanner scanner = new Scanner(is);
String json = scanner.useDelimiter("\\Z").next();
scanner.close();
-
+
this.testRules = JsonPath.parse(json);
}
/* **** TESTS **** */
@Test
public void testFromToSingle() {
- //rule defined from quux to foo
+ // rule defined from quux to foo
EdgeRuleQuery q = new EdgeRuleQuery.Builder("quux", "foo").build();
List<Object> results = testRules.read(readStart, q.getFilter());
-
+
assertTrue(results.size() == 1);
}
@Test
public void testToFromSingle() {
- //rule defined from quux to foo, this is flipped
+ // rule defined from quux to foo, this is flipped
EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo", "quux").build();
List<Object> results = testRules.read(readStart, q.getFilter());
-
+
assertTrue(results.size() == 1);
}
-
+
@Test
public void testFromToMultiple() {
- //rules have two from foo to bar
+ // rules have two from foo to bar
EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo", "bar").build();
List<Object> results = testRules.read(readStart, q.getFilter());
assertTrue(results.size() == 2);
}
-
+
@Test
public void testToFromMultiple() {
- //rules have two from foo to bar
+ // rules have two from foo to bar
EdgeRuleQuery q = new EdgeRuleQuery.Builder("bar", "foo").build();
List<Object> results = testRules.read(readStart, q.getFilter());
-
+
assertTrue(results.size() == 2);
assertTrue(!(results.get(0).toString().equals(results.get(1).toString())));
}
-
+
@Test
public void testJustFrom() {
- //there are 4 foo rules (foo>bar, foo>bar, foo>baz, quux>foo)
+ // there are 4 foo rules (foo>bar, foo>bar, foo>baz, quux>foo)
EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
List<Object> results = testRules.read(readStart, q.getFilter());
assertTrue(results.size() == 4);
-
- //there are 2 bar rules
+
+ // there are 2 bar rules
EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("bar").build();
List<Object> results2 = testRules.read(readStart, q2.getFilter());
assertTrue(results2.size() == 2);
}
-
+
@Test
public void testWithLabel() {
- //there are foo >eats> bar and foo >eatz> bar
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo","bar").label("eatz").build();
+ // there are foo >eats> bar and foo >eatz> bar
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo", "bar").label("eatz").build();
List<Object> results = testRules.read(readStart, q.getFilter());
assertTrue(results.size() == 1);
assertTrue(results.get(0).toString().contains("eatz"));
}
-
+
@Test
public void testCousin() {
EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").edgeType(EdgeType.COUSIN).build();
List<Object> results = testRules.read(readStart, q.getFilter());
assertTrue(results.size() == 2);
-
+
EdgeRuleQuery q2 = new EdgeRuleQuery.Builder("foo", "bar").edgeType(EdgeType.COUSIN).label("eats").build();
List<Object> results2 = testRules.read(readStart, q2.getFilter());
assertTrue(results2.size() == 1);
assertTrue(results2.get(0).toString().contains("eats"));
-
- EdgeRuleQuery q3 = new EdgeRuleQuery.Builder("foo","quux").edgeType(EdgeType.COUSIN).build();
+
+ EdgeRuleQuery q3 = new EdgeRuleQuery.Builder("foo", "quux").edgeType(EdgeType.COUSIN).build();
List<Object> results3 = testRules.read(readStart, q3.getFilter());
assertTrue(results3.isEmpty());
}
-
+
@Test
public void testTree() {
EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").edgeType(EdgeType.TREE).build();
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleTest.java
index 5abae6b7..3fdabfd1 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/EdgeRuleTest.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.edges;
import static org.junit.Assert.*;
@@ -44,12 +45,12 @@ public class EdgeRuleTest {
rule.put("private", "true");
EdgeRule r = new EdgeRule(rule);
-
+
r.flipDirection();
assertTrue(Direction.IN.equals(r.getDirection()));
r.flipDirection();
assertTrue(Direction.OUT.equals(r.getDirection()));
-
+
rule.put("direction", "BOTH");
EdgeRule r2 = new EdgeRule(rule);
r2.flipDirection();
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java
index 4475b3f2..c67be641 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/JsonIngestorTest.java
@@ -20,17 +20,18 @@
package org.onap.aai.edges;
+import static com.jayway.jsonpath.Criteria.where;
+import static com.jayway.jsonpath.Filter.filter;
import static org.junit.Assert.*;
+import com.jayway.jsonpath.DocumentContext;
+import com.jayway.jsonpath.Filter;
+
import java.util.*;
+
import org.junit.Test;
import org.onap.aai.setup.SchemaVersion;
-import com.jayway.jsonpath.DocumentContext;
-import com.jayway.jsonpath.Filter;
-import static com.jayway.jsonpath.Criteria.where;
-import static com.jayway.jsonpath.Filter.filter;
-
public class JsonIngestorTest {
private SchemaVersion LATEST = new SchemaVersion("v14");
@@ -39,34 +40,34 @@ public class JsonIngestorTest {
@Test
public void test() {
- //setup
+ // setup
List<String> files = new ArrayList<>();
files.add("src/test/resources/edgeRules/test.json");
files.add("src/test/resources/edgeRules/test2.json");
files.add("src/test/resources/edgeRules/otherTestRules.json");
Map<SchemaVersion, List<String>> input = new TreeMap<>();
input.put(LATEST, files);
-
+
List<String> files2 = new ArrayList<>();
files2.add("src/test/resources/edgeRules/test.json");
input.put(V10, files2);
-
+
List<String> files3 = new ArrayList<>();
files3.add("src/test/resources/edgeRules/test3.json");
files3.add("src/test/resources/edgeRules/defaultEdgesTest.json");
input.put(V11, files3);
-
- //test
+
+ // test
JsonIngestor ji = new JsonIngestor();
Map<SchemaVersion, List<DocumentContext>> results = ji.ingest(input);
-
+
assertTrue(results.entrySet().size() == 3);
assertTrue(results.get(LATEST).size() == 3);
assertTrue(results.get(V11).size() == 2);
assertTrue(results.get(V10).size() == 1);
-
+
Filter f = filter(where("from").is("foo").and("contains-other-v").is("NONE"));
- List<Map<String, String>> filterRes = results.get(V10).get(0).read("$.rules.[?]",f);
+ List<Map<String, String>> filterRes = results.get(V10).get(0).read("$.rules.[?]", f);
assertTrue(filterRes.size() == 2);
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java
index 3f49428f..4e3d61dd 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/edges/TypeAlphabetizerTest.java
@@ -21,6 +21,7 @@
package org.onap.aai.edges;
import static org.junit.Assert.*;
+
import org.junit.Test;
public class TypeAlphabetizerTest {
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java
index cec3f9d8..dca21f2d 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java
@@ -20,14 +20,26 @@
package org.onap.aai.nodes;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.onap.aai.restclient.MockProvider;
import org.onap.aai.config.NodesConfiguration;
+import org.onap.aai.restclient.MockProvider;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.testutils.TestUtilConfigTranslator;
import org.springframework.beans.factory.annotation.Autowired;
@@ -39,19 +51,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.w3c.dom.Document;
-import javax.xml.bind.SchemaOutputResolver;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.io.*;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-
@RunWith(SpringRunner.class)
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties" })
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties"})
@ContextConfiguration(classes = {TestUtilConfigTranslator.class, NodesConfiguration.class})
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@@ -59,8 +62,8 @@ import static org.junit.Assert.*;
@SpringBootTest
public class NodeIngestorLocalTest {
- //set thrown.expect to whatever a specific test needs
- //this establishes a default of expecting no exceptions to be thrown
+ // set thrown.expect to whatever a specific test needs
+ // this establishes a default of expecting no exceptions to be thrown
@Rule
public ExpectedException thrown = ExpectedException.none();
@Autowired
@@ -75,21 +78,20 @@ public class NodeIngestorLocalTest {
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- transformer.transform(new DOMSource(doc),
- new StreamResult(new OutputStreamWriter(out, "UTF-8")));
+ transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out, "UTF-8")));
}
@Test
public void testGetContextForVersion11() {
DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
- //should work bc Foo is valid in test_network_v10 schema
+ // should work bc Foo is valid in test_network_v10 schema
DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
foo10.set("fooId", "bar");
assertTrue("bar".equals(foo10.get("fooId")));
- //should work bc Bar is valid in test_business_v10 schema
+ // should work bc Bar is valid in test_business_v10 schema
DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
bar10.set("barId", "bar2");
assertTrue("bar2".equals(bar10.get("barId")));
@@ -98,7 +100,7 @@ public class NodeIngestorLocalTest {
DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
- //should work bc Foo.quantity is valid in test_network_v11 schema
+ // should work bc Foo.quantity is valid in test_network_v11 schema
DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
foo11.set("quantity", "12");
assertTrue("12".equals(foo11.get("quantity")));
@@ -109,9 +111,8 @@ public class NodeIngestorLocalTest {
XSDOutputResolver outputResolver11 = new XSDOutputResolver();
ctx11.generateSchema(outputResolver11);
-
thrown.expect(IllegalArgumentException.class);
- //should fail bc Quux not in v10 test schema
+ // should fail bc Quux not in v10 test schema
ctx10.newDynamicEntity("Quux");
}
@@ -157,8 +158,7 @@ public class NodeIngestorLocalTest {
private class XSDOutputResolver extends SchemaOutputResolver {
@Override
- public Result createOutput(String namespaceUri, String suggestedFileName)
- throws IOException {
+ public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
// create new file
// create stream result
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java
index ec529f9d..7035affd 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java
@@ -20,14 +20,26 @@
package org.onap.aai.nodes;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.*;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.onap.aai.restclient.MockProvider;
import org.onap.aai.config.NodesConfiguration;
+import org.onap.aai.restclient.MockProvider;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -37,72 +49,60 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.w3c.dom.Document;
-import javax.xml.bind.SchemaOutputResolver;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import java.io.*;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-
-
@RunWith(SpringJUnit4ClassRunner.class)
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties" })
+@TestPropertySource(
+ properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties"})
-@ContextConfiguration(classes = { MockProvider.class, NodesConfiguration.class})
+@ContextConfiguration(classes = {MockProvider.class, NodesConfiguration.class})
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@SpringBootTest
public class NodeIngestorTest {
@Autowired
NodeIngestor nodeIngestor;
- //set thrown.expect to whatever a specific test needs
- //this establishes a default of expecting no exceptions to be thrown
+ // set thrown.expect to whatever a specific test needs
+ // this establishes a default of expecting no exceptions to be thrown
@Rule
public ExpectedException thrown = ExpectedException.none();
-
+
@Test
public void testGetContextForVersion() {
DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
-
- //should work bc Foo is valid in test_network_v10 schema
+
+ // should work bc Foo is valid in test_network_v10 schema
DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
- foo10.set("fooId","bar");
+ foo10.set("fooId", "bar");
assertTrue("bar".equals(foo10.get("fooId")));
-
- //should work bc Bar is valid in test_business_v10 schema
+
+ // should work bc Bar is valid in test_business_v10 schema
DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
- bar10.set("barId","bar2");
+ bar10.set("barId", "bar2");
assertTrue("bar2".equals(bar10.get("barId")));
XSDOutputResolver outputResolver10 = new XSDOutputResolver();
ctx10.generateSchema(outputResolver10);
-
+
DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
-
- //should work bc Foo.quantity is valid in test_network_v11 schema
+
+ // should work bc Foo.quantity is valid in test_network_v11 schema
DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
- foo11.set("quantity","12");
+ foo11.set("quantity", "12");
assertTrue("12".equals(foo11.get("quantity")));
-
+
DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
- quux11.set("qManagerName","some guy");
+ quux11.set("qManagerName", "some guy");
assertTrue("some guy".equals(quux11.get("qManagerName")));
XSDOutputResolver outputResolver11 = new XSDOutputResolver();
ctx11.generateSchema(outputResolver11);
-
thrown.expect(IllegalArgumentException.class);
- //should fail bc Quux not in v10 test schema
+ // should fail bc Quux not in v10 test schema
ctx10.newDynamicEntity("Quux");
}
@Test
public void testHasNodeType() {
- //TODO remove for integration tests
+ // TODO remove for integration tests
assertTrue(nodeIngestor.hasNodeType("foo", new SchemaVersion("v11")));
assertTrue(nodeIngestor.hasNodeType("quux", new SchemaVersion("v11")));
assertFalse(nodeIngestor.hasNodeType("quux", new SchemaVersion("v10")));
@@ -110,7 +110,7 @@ public class NodeIngestorTest {
@Test
public void testGetVersionFromClassName() {
- assertEquals(nodeIngestor.getVersionFromClassName("inventory.aai.onap.org.v13.Evc"),new SchemaVersion("v13"));
+ assertEquals(nodeIngestor.getVersionFromClassName("inventory.aai.onap.org.v13.Evc"), new SchemaVersion("v13"));
}
@@ -123,24 +123,23 @@ public class NodeIngestorTest {
@Test
public void testGetObjectsInVersion() {
assertEquals(nodeIngestor.getObjectsInVersion(new SchemaVersion("v13")).size(), 148);
- //comment for IntegrationTest
- //assertEquals(nodeIngestor.getObjectsInVersion(new SchemaVersion("v13")).size(), 229);
+ // comment for IntegrationTest
+ // assertEquals(nodeIngestor.getObjectsInVersion(new SchemaVersion("v13")).size(), 229);
}
-
+
@Test
public void testCombinedSchema() throws TransformerException, IOException {
DynamicJAXBContext ctx13 = nodeIngestor.getContextForVersion(new SchemaVersion("v13"));
XSDOutputResolver outputResolver13 = new XSDOutputResolver();
ctx13.generateSchema(outputResolver13);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- printDocument(nodeIngestor.getSchema(new SchemaVersion("v13")),buffer);
+ printDocument(nodeIngestor.getSchema(new SchemaVersion("v13")), buffer);
String content = new String(Files.readAllBytes(Paths.get("src/test/resources/forWiringTests/aai_oxm_v13.xml")));
content = content.replaceAll("\\s+", "");
String expected = buffer.toString().replaceAll("\\s+", "");
-
- assertThat("OXM:\n"+expected,expected, is(content));
+ assertThat("OXM:\n" + expected, expected, is(content));
}
public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException {
@@ -152,30 +151,26 @@ public class NodeIngestorTest {
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- transformer.transform(new DOMSource(doc),
- new StreamResult(new OutputStreamWriter(out, "UTF-8")));
+ transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out, "UTF-8")));
}
-
+
private class XSDOutputResolver extends SchemaOutputResolver {
- @Override
- public Result createOutput(String namespaceUri, String suggestedFileName)
- throws IOException {
-
- // create new file
- // create stream result
- File temp = File.createTempFile("schema", ".xsd");
- StreamResult result = new StreamResult(temp);
- System.out.println("Schema file: "+temp.getAbsolutePath());
-
- // set system id
- result.setSystemId(temp.toURI().toURL().toString());
-
- // return result
- return result;
- }
- }
+ @Override
+ public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
-}
+ // create new file
+ // create stream result
+ File temp = File.createTempFile("schema", ".xsd");
+ StreamResult result = new StreamResult(temp);
+ System.out.println("Schema file: " + temp.getAbsolutePath());
+ // set system id
+ result.setSystemId(temp.toURI().toURL().toString());
+ // return result
+ return result;
+ }
+ }
+
+}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java
index 0aaa8802..d2412c08 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorWiringTest.java
@@ -30,29 +30,30 @@ import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersionsBean;
-
import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ConfigTranslatorForWiringTest.class, NodesConfiguration.class})
-@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties"})
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties"})
@SpringBootTest
public class NodeIngestorWiringTest {
@Autowired
NodeIngestor ni;
-
+
@Test
public void test() {
DynamicJAXBContext ctx10 = ni.getContextForVersion(new SchemaVersion("v10"));
-
- //should work bc Bar is valid in test_business_v10 schema
+
+ // should work bc Bar is valid in test_business_v10 schema
DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
- bar10.set("barId","bar2");
+ bar10.set("barId", "bar2");
assertTrue("bar2".equals(bar10.get("barId")));
}
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java
index 6f8b7367..f0fed324 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockProvider.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,8 +28,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
-@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true)
-@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true)
+@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
+@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
public class MockProvider {
@Value("${mock.filename}")
@@ -49,10 +50,9 @@ public class MockProvider {
};
}
- @Bean(name="restClient")
+ @Bean(name = "restClient")
@ConditionalOnProperty(name = "schema.service.client", havingValue = "mock-no-auth")
public RestClient getSchemaServiceNoAuthClient() {
return new MockRestClient(fileName);
}
}
-
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java
index 87e4bfe8..52e6364b 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/MockRestClient.java
@@ -17,20 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
+import static org.junit.Assert.assertNotNull;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+
import com.att.eelf.configuration.EELFLogger;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import org.apache.commons.io.IOUtils;
-import org.springframework.core.io.Resource;
-import org.springframework.http.*;
-import org.springframework.stereotype.Component;
-import org.springframework.test.web.client.ExpectedCount;
-import org.springframework.test.web.client.MockRestServiceServer;
-import org.springframework.util.MultiValueMap;
-import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.InputStream;
@@ -40,33 +37,40 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertNotNull;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+import org.apache.commons.io.IOUtils;
+import org.springframework.core.io.Resource;
+import org.springframework.http.*;
+import org.springframework.stereotype.Component;
+import org.springframework.test.web.client.ExpectedCount;
+import org.springframework.test.web.client.MockRestServiceServer;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
@Component
public class MockRestClient extends RestClient {
-private RestTemplate restTemplate;
- private MockRestServiceServer mockRestServiceServer;
+ private RestTemplate restTemplate;
+ private MockRestServiceServer mockRestServiceServer;
String fileName = "mockrequests";
public MockRestClient(String fileName) {
/*
- List<MockRestServiceServer> mockedAAIRequests = new ArrayList<>(aaiRequests.size());
+ * List<MockRestServiceServer> mockedAAIRequests = new ArrayList<>(aaiRequests.size());
*/
List<MockRestServiceServer> mockedAAIRequests = new ArrayList<>();
restTemplate = new RestTemplate();
- /* MockRestServiceServer server = MockRestServiceServer
- .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate())
- .build();
- server.expect(MockRestRequestMatchers.requestTo(url))
- .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/
+ /*
+ * MockRestServiceServer server = MockRestServiceServer
+ * .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate())
+ * .build();
+ * server.expect(MockRestRequestMatchers.requestTo(url))
+ * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
+ */
// RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class);
- //when(mockBuilder.build()).thenReturn(restTemplate);
+ // when(mockBuilder.build()).thenReturn(restTemplate);
JsonObject payload = null;
try {
@@ -77,23 +81,20 @@ private RestTemplate restTemplate;
JsonArray mockUris = payload.getAsJsonArray("mock-uri");
-
mockRestServiceServer = MockRestServiceServer.createServer(restTemplate);
String url = "https://localhost:8447/aai/v14";
- /*mockRestServiceServer.expect(requestTo(url))
- .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/
-
+ /*
+ * mockRestServiceServer.expect(requestTo(url))
+ * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
+ */
for (int i = 0; i < mockUris.size(); i++) {
String responseFile = mockUris.get(i).getAsJsonObject().get("response-file").getAsString();
String contentTypeValue = mockUris.get(i).getAsJsonObject().get("content").getAsString();
-
String uri = mockUris.get(i).getAsJsonObject().get("aai-uri").getAsString();
- InputStream inputStream = getClass()
- .getClassLoader()
- .getResourceAsStream(responseFile);
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream(responseFile);
String responseBody = null;
try {
responseBody = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
@@ -101,57 +102,51 @@ private RestTemplate restTemplate;
e.printStackTrace();
}
-
mockRestServiceServer.expect(ExpectedCount.manyTimes(), requestTo(url + uri))
- .andExpect(method(HttpMethod.GET))
- .andExpect(content().contentType(contentTypeValue))
- .andRespond(withStatus(HttpStatus.OK).body(responseBody.toString()).contentType(MediaType.valueOf(contentTypeValue)));
-
+ .andExpect(method(HttpMethod.GET)).andExpect(content().contentType(contentTypeValue))
+ .andRespond(withStatus(HttpStatus.OK).body(responseBody.toString())
+ .contentType(MediaType.valueOf(contentTypeValue)));
}
}
- public MockRestClient() {
+ public MockRestClient() {
- restTemplate = new RestTemplate();
- /* MockRestServiceServer server = MockRestServiceServer
- .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate())
- .build();
- server.expect(MockRestRequestMatchers.requestTo(url))
- .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/
+ restTemplate = new RestTemplate();
+ /*
+ * MockRestServiceServer server = MockRestServiceServer
+ * .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate())
+ * .build();
+ * server.expect(MockRestRequestMatchers.requestTo(url))
+ * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
+ */
// RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class);
- //when(mockBuilder.build()).thenReturn(restTemplate);
+ // when(mockBuilder.build()).thenReturn(restTemplate);
JsonObject payload = null;
try {
- payload = getPayload( fileName + ".json");
+ payload = getPayload(fileName + ".json");
} catch (IOException e) {
e.printStackTrace();
}
JsonArray mockUris = payload.getAsJsonArray("mock-uri");
-
-
- mockRestServiceServer = MockRestServiceServer.createServer(restTemplate);
- String url="https://localhost:8447/aai/v14";
- /*mockRestServiceServer.expect(requestTo(url))
- .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/
-
-
-
+ mockRestServiceServer = MockRestServiceServer.createServer(restTemplate);
+ String url = "https://localhost:8447/aai/v14";
+ /*
+ * mockRestServiceServer.expect(requestTo(url))
+ * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
+ */
for (int i = 0; i < mockUris.size(); i++) {
String responseFile = mockUris.get(i).getAsJsonObject().get("response-file").getAsString();
String contentTypeValue = mockUris.get(i).getAsJsonObject().get("content").getAsString();
-
String uri = mockUris.get(i).getAsJsonObject().get("aai-uri").getAsString();
- InputStream inputStream = getClass()
- .getClassLoader()
- .getResourceAsStream(responseFile);
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream(responseFile);
String responseBody = null;
try {
responseBody = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
@@ -159,31 +154,26 @@ private RestTemplate restTemplate;
e.printStackTrace();
}
-
mockRestServiceServer.expect(ExpectedCount.manyTimes(), requestTo(url + uri))
- .andExpect(method(HttpMethod.GET))
- .andExpect(content().contentType(contentTypeValue))
- .andRespond(withStatus(HttpStatus.OK).body(responseBody.toString()).contentType(MediaType.valueOf(contentTypeValue)));
-
+ .andExpect(method(HttpMethod.GET)).andExpect(content().contentType(contentTypeValue))
+ .andRespond(withStatus(HttpStatus.OK).body(responseBody.toString())
+ .contentType(MediaType.valueOf(contentTypeValue)));
}
-
}
- public JsonObject getTestDetails(String fileName) throws IOException {
+ public JsonObject getTestDetails(String fileName) throws IOException {
- JsonObject payload = getPayload(fileName );
+ JsonObject payload = getPayload(fileName);
return payload;
}
public JsonObject getPayload(String filename) throws IOException {
- InputStream inputStream = getClass()
- .getClassLoader()
- .getResourceAsStream(filename);
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream(filename);
- //InputStream inputStream = new FileInputStream(filename);
+ // InputStream inputStream = new FileInputStream(filename);
String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
String message = String.format("Unable to find the %s in src/test/resources", filename);
@@ -195,28 +185,33 @@ private RestTemplate restTemplate;
}
@Override
- public ResponseEntity execute(String uri, HttpMethod method, Map<String,String> headers, String body) {
+ public ResponseEntity execute(String uri, HttpMethod method, Map<String, String> headers, String body) {
- String url="https://localhost:8447/aai/v14/"+ uri;
+ String url = "https://localhost:8447/aai/v14/" + uri;
- /* MockRestServiceServer server = MockRestServiceServer
- .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate())
- .build();
- server.expect(MockRestRequestMatchers.requestTo(url))
- .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/
-
- // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class);
- //when(mockBuilder.build()).thenReturn(restTemplate);
+ /*
+ * MockRestServiceServer server = MockRestServiceServer
+ * .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate())
+ * .build();
+ * server.expect(MockRestRequestMatchers.requestTo(url))
+ * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
+ */
- /*MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate);
- server.expect(requestTo(url))
- .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
- return new ResponseEntity("blah", HttpStatus.OK);
- server.expect(ExpectedCount.manyTimes(), requestTo(Matchers.startsWith(aaiBaseUrl + aaiRequests.get(i).get("aai-uri").asText())))
- .andExpect(method(HttpMethod.GET))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andRespond(withStatus(HttpStatus.OK).body(aaiResponses.get(i).toString()).contentType(MediaType.APPLICATION_JSON));*/
+ // RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class);
+ // when(mockBuilder.build()).thenReturn(restTemplate);
+ /*
+ * MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate);
+ * server.expect(requestTo(url))
+ * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
+ * return new ResponseEntity("blah", HttpStatus.OK);
+ * server.expect(ExpectedCount.manyTimes(), requestTo(Matchers.startsWith(aaiBaseUrl +
+ * aaiRequests.get(i).get("aai-uri").asText())))
+ * .andExpect(method(HttpMethod.GET))
+ * .andExpect(content().contentType(MediaType.APPLICATION_JSON))
+ * .andRespond(withStatus(HttpStatus.OK).body(aaiResponses.get(i).toString()).contentType(MediaType.
+ * APPLICATION_JSON));
+ */
HttpHeaders headersMap = new HttpHeaders();
@@ -228,35 +223,40 @@ private RestTemplate restTemplate;
HttpEntity httpEntity = new HttpEntity(headers);
- ResponseEntity responseEntity = restTemplate.exchange(url , HttpMethod.GET, httpEntity, String.class);
+ ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class);
- // mockRestServiceServer.verify();
- return responseEntity;
+ // mockRestServiceServer.verify();
+ return responseEntity;
}
@Override
- public ResponseEntity executeResource(String uri, HttpMethod method, Map<String,String> headers, String body) {
+ public ResponseEntity executeResource(String uri, HttpMethod method, Map<String, String> headers, String body) {
- String url="https://localhost:8447/aai/v14/"+ uri;
+ String url = "https://localhost:8447/aai/v14/" + uri;
- /* MockRestServiceServer server = MockRestServiceServer
- .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate())
- .build();
- server.expect(MockRestRequestMatchers.requestTo(url))
- .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));*/
+ /*
+ * MockRestServiceServer server = MockRestServiceServer
+ * .bindTo(restClientFactory.getRestClient(ClientType.SchemaService).getRestTemplate())
+ * .build();
+ * server.expect(MockRestRequestMatchers.requestTo(url))
+ * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
+ */
// RestTemplateBuilder mockBuilder = mock(RestTemplateBuilder.class);
- //when(mockBuilder.build()).thenReturn(restTemplate);
-
- /*MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate);
- server.expect(requestTo(url))
- .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
- return new ResponseEntity("blah", HttpStatus.OK);
- server.expect(ExpectedCount.manyTimes(), requestTo(Matchers.startsWith(aaiBaseUrl + aaiRequests.get(i).get("aai-uri").asText())))
- .andExpect(method(HttpMethod.GET))
- .andExpect(content().contentType(MediaType.APPLICATION_JSON))
- .andRespond(withStatus(HttpStatus.OK).body(aaiResponses.get(i).toString()).contentType(MediaType.APPLICATION_JSON));*/
+ // when(mockBuilder.build()).thenReturn(restTemplate);
+ /*
+ * MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate);
+ * server.expect(requestTo(url))
+ * .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
+ * return new ResponseEntity("blah", HttpStatus.OK);
+ * server.expect(ExpectedCount.manyTimes(), requestTo(Matchers.startsWith(aaiBaseUrl +
+ * aaiRequests.get(i).get("aai-uri").asText())))
+ * .andExpect(method(HttpMethod.GET))
+ * .andExpect(content().contentType(MediaType.APPLICATION_JSON))
+ * .andRespond(withStatus(HttpStatus.OK).body(aaiResponses.get(i).toString()).contentType(MediaType.
+ * APPLICATION_JSON));
+ */
HttpHeaders headersMap = new HttpHeaders();
@@ -268,7 +268,7 @@ private RestTemplate restTemplate;
HttpEntity httpEntity = new HttpEntity(headers);
- ResponseEntity responseEntity = restTemplate.exchange(url , HttpMethod.GET, httpEntity, Resource.class);
+ ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, Resource.class);
// mockRestServiceServer.verify();
return responseEntity;
@@ -280,16 +280,16 @@ private RestTemplate restTemplate;
return restTemplate;
}
- public String getBaseUrl(){
- return "";
+ public String getBaseUrl() {
+ return "";
}
- protected MultiValueMap<String,String> getHeaders(Map<String,String> headers){
- return null;
+ protected MultiValueMap<String, String> getHeaders(Map<String, String> headers) {
+ return null;
}
- protected EELFLogger getLogger(){
- return null;
+ protected EELFLogger getLogger() {
+ return null;
}
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java
index 4c3b0fcf..36b8fb3e 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/RestClientTest.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
public class RestClientTest {
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java
index cd161dea..53134075 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/restclient/SchemaRestClientTest.java
@@ -17,8 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.restclient;
+import java.util.HashMap;
+import java.util.Map;
+
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -31,13 +35,12 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.util.HashMap;
-import java.util.Map;
-
@Ignore
@RunWith(SpringJUnit4ClassRunner.class)
-@TestPropertySource(locations = "/schemaService/schema-service-rest.properties" )
-@ContextConfiguration(classes = {RestClientFactoryConfiguration.class, SchemaServiceRestClient.class, RestClientFactory.class, PropertyPasswordConfiguration.class})
+@TestPropertySource(locations = "/schemaService/schema-service-rest.properties")
+@ContextConfiguration(
+ classes = {RestClientFactoryConfiguration.class, SchemaServiceRestClient.class, RestClientFactory.class,
+ PropertyPasswordConfiguration.class})
@SpringBootTest
public class SchemaRestClientTest {
@@ -47,21 +50,16 @@ public class SchemaRestClientTest {
private RestClientFactory restClientFactory;
@Test
- public void testGetRequestToSchemaService() {
+ public void testGetRequestToSchemaService() {
ResponseEntity aaiResponse;
RestClient restClient = null;
- restClient = restClientFactory
- .getRestClient(SCHEMA_SERVICE);
+ restClient = restClientFactory.getRestClient(SCHEMA_SERVICE);
String uri = "";
Map<String, String> headersMap = new HashMap<>();
String content = "";
- aaiResponse = restClient.execute(
- uri,
- HttpMethod.GET,
- headersMap,
- content);
- System.out.println("Helo"+aaiResponse.getStatusCode());
+ aaiResponse = restClient.execute(uri, HttpMethod.GET, headersMap, content);
+ System.out.println("Helo" + aaiResponse.getStatusCode());
}
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java
index aca50416..8136ac0b 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/ConfigTranslatorWiringTest.java
@@ -20,6 +20,12 @@
package org.onap.aai.setup;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Map;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
@@ -29,20 +35,17 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {SchemaLocationsBean.class, SchemaConfigVersions.class, ConfigTranslatorForWiringTest.class})
-@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
+@ContextConfiguration(
+ classes = {SchemaLocationsBean.class, SchemaConfigVersions.class, ConfigTranslatorForWiringTest.class})
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@SpringBootTest
public class ConfigTranslatorWiringTest {
@Autowired
ConfigTranslator ct;
-
+
@Test
public void test() {
assertNotNull(ct);
@@ -50,7 +53,7 @@ public class ConfigTranslatorWiringTest {
assertTrue(nodes.containsKey(new SchemaVersion("v10")));
assertTrue(1 == nodes.get(new SchemaVersion("v10")).size());
assertTrue("src/test/resources/oxm/test_business_v10.xml".equals(nodes.get(new SchemaVersion("v10")).get(0)));
-
+
Map<SchemaVersion, List<String>> edges = ct.getEdgeFiles();
assertTrue(edges.containsKey(new SchemaVersion("v10")));
assertTrue(1 == edges.get(new SchemaVersion("v10")).size());
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java
index 45ed88fa..4d7bf692 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanDefaultInjectionTest.java
@@ -20,15 +20,15 @@
package org.onap.aai.setup;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SchemaLocationsBean.class})
public class SchemaLocationsBeanDefaultInjectionTest {
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java
index 886dfe02..bfaa917e 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanEnvVarInjectionTest.java
@@ -20,6 +20,9 @@
package org.onap.aai.setup;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,16 +30,13 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SchemaLocationsBean.class})
@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest2.properties"})
public class SchemaLocationsBeanEnvVarInjectionTest {
@Autowired
SchemaLocationsBean bean;
-
+
@Test
public void test() {
assertNotNull(bean);
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java
index 105cb1de..78df3891 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterTest.java
@@ -20,17 +20,17 @@
package org.onap.aai.setup;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:forWiringTests/testContext.xml"})
+@ContextConfiguration(locations = {"classpath:forWiringTests/testContext.xml"})
public class SchemaLocationsBeanXMLSetterTest {
@Autowired
SchemaLocationsBean bean;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java
index a9b5d0c5..af94765f 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaLocationsBeanXMLSetterWithPropFileTest.java
@@ -20,17 +20,17 @@
package org.onap.aai.setup;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:forWiringTests/testUsingPropFileContext.xml"})
+@ContextConfiguration(locations = {"classpath:forWiringTests/testUsingPropFileContext.xml"})
public class SchemaLocationsBeanXMLSetterWithPropFileTest {
@Autowired
SchemaLocationsBean bean;
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanOverrideTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanOverrideTest.java
index 72409bc7..ecc188f7 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanOverrideTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanOverrideTest.java
@@ -17,8 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.util.List;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -30,20 +37,16 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.io.IOException;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-override-test.properties" })
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-override-test.properties"})
@ContextConfiguration(classes = {MockProvider.class, SchemaVersionsBean.class, SchemaConfigVersions.class})
@SpringBootTest
public class SchemaVersionsBeanOverrideTest {
- //set thrown.expect to whatever a specific test needs
- //this establishes a default of expecting no exceptions to be thrown
+ // set thrown.expect to whatever a specific test needs
+ // this establishes a default of expecting no exceptions to be thrown
@Rule
public ExpectedException thrown = ExpectedException.none();
@Autowired
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java
index b1208d62..981be806 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/setup/SchemaVersionsBeanTest.java
@@ -17,8 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.setup;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.util.List;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -30,20 +37,15 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.io.IOException;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties" })
+@TestPropertySource(
+ properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties"})
@ContextConfiguration(classes = {MockProvider.class, SchemaVersionsBean.class})
@SpringBootTest
public class SchemaVersionsBeanTest {
- //set thrown.expect to whatever a specific test needs
- //this establishes a default of expecting no exceptions to be thrown
+ // set thrown.expect to whatever a specific test needs
+ // this establishes a default of expecting no exceptions to be thrown
@Rule
public ExpectedException thrown = ExpectedException.none();
@Autowired
@@ -69,12 +71,14 @@ public class SchemaVersionsBeanTest {
List<SchemaVersion> versionsList = SchemaVersionsBean.getVersions();
assertNotNull(versionsList);
SchemaVersions versions = SchemaVersionsBean.getSchemaVersions();
- /*//assertEquals(versions.getAppRootVersion(), new SchemaVersion("v15"));
- assertEquals(versions.getAppRootVersion(), new SchemaVersion("v11"));
- assertEquals(versions.getDepthVersion(), new SchemaVersion("v10"));
- assertEquals(versions.getEdgeLabelVersion(), new SchemaVersion("v12"));
- assertEquals(versions.getNamespaceChangeVersion(), new SchemaVersion("v11"));
- assertEquals(versions.getRelatedLinkVersion(), new SchemaVersion("v10"));*/
+ /*
+ * //assertEquals(versions.getAppRootVersion(), new SchemaVersion("v15"));
+ * assertEquals(versions.getAppRootVersion(), new SchemaVersion("v11"));
+ * assertEquals(versions.getDepthVersion(), new SchemaVersion("v10"));
+ * assertEquals(versions.getEdgeLabelVersion(), new SchemaVersion("v12"));
+ * assertEquals(versions.getNamespaceChangeVersion(), new SchemaVersion("v11"));
+ * assertEquals(versions.getRelatedLinkVersion(), new SchemaVersion("v10"));
+ */
assertEquals(versions.getAppRootVersion(), new SchemaVersion("v15"));
assertEquals(versions.getDepthVersion(), new SchemaVersion("v15"));
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java
index dd1c0b7c..2f5f15e8 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadEdgeConfigForValidationTest.java
@@ -20,11 +20,12 @@
package org.onap.aai.testutils;
+import java.util.*;
+
import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.SchemaConfigVersions;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaConfigVersions;
-import java.util.*;
/**
* Good oxm, bad edge rules for rainy day edge rule validation testing
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java
index 90afdcce..b91007be 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/BadNodeConfigForValidationTest.java
@@ -20,15 +20,16 @@
package org.onap.aai.testutils;
-import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaConfigVersions;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.SchemaConfigVersions;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+
/**
* All schema files here are valid for sunny day validator testing
*/
@@ -59,5 +60,4 @@ public class BadNodeConfigForValidationTest extends ConfigTranslator {
return input;
}
-
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java
index e8d10e8c..1d8e4bcb 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/ConfigTranslatorForWiringTest.java
@@ -20,15 +20,16 @@
package org.onap.aai.testutils;
-import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaConfigVersions;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.SchemaConfigVersions;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+
public class ConfigTranslatorForWiringTest extends ConfigTranslator {
public ConfigTranslatorForWiringTest(SchemaLocationsBean bean, SchemaConfigVersions schemaVersions) {
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java
index 631ce91f..8f1f1761 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/GoodConfigForValidationTest.java
@@ -20,16 +20,17 @@
package org.onap.aai.testutils;
-import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaConfigVersions;
-import org.onap.aai.setup.SchemaVersions;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.SchemaConfigVersions;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+
/**
* All schema files here are valid for sunny day validator testing
*/
@@ -47,7 +48,7 @@ public class GoodConfigForValidationTest extends ConfigTranslator {
List<String> files = new ArrayList<>();
files.add("src/test/resources/oxm/goodConfigForValidationTest_oxm.xml");
Map<SchemaVersion, List<String>> input = new TreeMap<>();
- //input.put(SchemaVersion.getLatest(), files);
+ // input.put(SchemaVersion.getLatest(), files);
for (SchemaVersion v : schemaVersions.getVersions()) {
input.put(v, files);
}
@@ -59,12 +60,11 @@ public class GoodConfigForValidationTest extends ConfigTranslator {
Map<SchemaVersion, List<String>> input = new TreeMap<>();
List<String> files = new ArrayList<>();
files.add("src/test/resources/edgeRules/test3.json");
- //input.put(SchemaVersion.getLatest(), files);
+ // input.put(SchemaVersion.getLatest(), files);
for (SchemaVersion v : schemaVersions.getVersions()) {
input.put(v, files);
}
return input;
}
-
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java
index ba3e4ac0..28dfd60c 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/SchemaIncompleteTranslator.java
@@ -20,17 +20,18 @@
package org.onap.aai.testutils;
-import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaConfigVersions;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.SchemaConfigVersions;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+
public class SchemaIncompleteTranslator extends ConfigTranslator {
-
+
public SchemaIncompleteTranslator(SchemaLocationsBean bean, SchemaConfigVersions schemaVersions) {
super(bean, schemaVersions);
}
@@ -40,17 +41,16 @@ public class SchemaIncompleteTranslator extends ConfigTranslator {
List<String> files10 = new ArrayList<>();
files10.add("src/test/resources/oxm/test_network_v10.xml");
files10.add("src/test/resources/oxm/test_business_v10.xml");
-
+
List<String> files11 = new ArrayList<>();
files11.add("src/test/resources/oxm/test_network_v11.xml");
files11.add("src/test/resources/oxm/test_business_v11.xml");
List<String> files12 = new ArrayList<>();
files12.add("src/test/resources/oxm/business_oxm_v12.xml");
-
+
Map<SchemaVersion, List<String>> input = new TreeMap<>();
-
-
+
input.put(new SchemaVersion("v10"), files10);
input.put(new SchemaVersion("v11"), files11);
input.put(new SchemaVersion("v12"), files12);
@@ -65,16 +65,16 @@ public class SchemaIncompleteTranslator extends ConfigTranslator {
files.add("src/test/resources/edgeRules/otherTestRules.json");
Map<SchemaVersion, List<String>> input = new TreeMap<>();
input.put(schemaVersions.getDefaultVersion(), files);
-
+
List<String> files2 = new ArrayList<>();
files2.add("src/test/resources/edgeRules/test.json");
input.put(new SchemaVersion("v10"), files2);
-
+
List<String> files3 = new ArrayList<>();
files3.add("src/test/resources/edgeRules/test3.json");
files3.add("src/test/resources/edgeRules/defaultEdgesTest.json");
input.put(new SchemaVersion("v11"), files3);
-
+
return input;
}
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java
index 8988a1ca..74ea5135 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslator.java
@@ -20,21 +20,24 @@
package org.onap.aai.testutils;
-import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaConfigVersions;
-import org.springframework.context.annotation.PropertySource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.SchemaConfigVersions;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+import org.springframework.context.annotation.PropertySource;
+
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
public class TestUtilConfigTranslator extends ConfigTranslator {
public static final SchemaVersion LATEST = new SchemaVersion("v15");
+
public TestUtilConfigTranslator(SchemaLocationsBean bean, SchemaConfigVersions schemaVersions) {
super(bean, schemaVersions);
}
@@ -44,11 +47,11 @@ public class TestUtilConfigTranslator extends ConfigTranslator {
List<String> files10 = new ArrayList<>();
files10.add("src/test/resources/oxm/test_network_v10.xml");
files10.add("src/test/resources/oxm/test_business_v10.xml");
-
+
List<String> files11 = new ArrayList<>();
files11.add("src/test/resources/oxm/test_network_v11.xml");
files11.add("src/test/resources/oxm/test_business_v11.xml");
-
+
Map<SchemaVersion, List<String>> input = new TreeMap<>();
input.put(new SchemaVersion("v10"), files10);
input.put(new SchemaVersion("v11"), files11);
@@ -58,8 +61,8 @@ public class TestUtilConfigTranslator extends ConfigTranslator {
files13.add("src/test/resources/oxm/common_oxm_v13.xml");
files13.add("src/test/resources/oxm/serviceDesign_oxm_v13.xml");
files13.add("src/test/resources/oxm/network_oxm_v13.xml");
-
- input.put(new SchemaVersion("v10"), files10);
+
+ input.put(new SchemaVersion("v10"), files10);
input.put(new SchemaVersion("v11"), files11);
input.put(new SchemaVersion("v13"), files13);
return input;
@@ -73,11 +76,11 @@ public class TestUtilConfigTranslator extends ConfigTranslator {
files.add("src/test/resources/edgeRules/otherTestRules.json");
Map<SchemaVersion, List<String>> input = new TreeMap<>();
input.put(LATEST, files);
-
+
List<String> files2 = new ArrayList<>();
files2.add("src/test/resources/edgeRules/test.json");
input.put(new SchemaVersion("v10"), files2);
-
+
List<String> files3 = new ArrayList<>();
files3.add("src/test/resources/edgeRules/test3.json");
files3.add("src/test/resources/edgeRules/defaultEdgesTest.json");
@@ -85,5 +88,3 @@ public class TestUtilConfigTranslator extends ConfigTranslator {
return input;
}
}
-
-
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java
index 28b0e2da..1c572ac8 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/testutils/TestUtilConfigTranslatorforBusiness.java
@@ -20,17 +20,18 @@
package org.onap.aai.testutils;
-import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaConfigVersions;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.SchemaConfigVersions;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+
public class TestUtilConfigTranslatorforBusiness extends ConfigTranslator {
-
+
public TestUtilConfigTranslatorforBusiness(SchemaLocationsBean bean, SchemaConfigVersions schemaVersions) {
super(bean, schemaVersions);
}
@@ -38,21 +39,21 @@ public class TestUtilConfigTranslatorforBusiness extends ConfigTranslator {
@Override
public Map<SchemaVersion, List<String>> getNodeFiles() {
List<String> files10 = new ArrayList<>();
-// files10.add("src/test/resources/oxm/test_network_v10.xml");
-// files10.add("src/test/resources/oxm/test_business_v10.xml");
-
+ // files10.add("src/test/resources/oxm/test_network_v10.xml");
+ // files10.add("src/test/resources/oxm/test_business_v10.xml");
+
List<String> files11 = new ArrayList<>();
-// files11.add("src/test/resources/oxm/test_network_v11.xml");
+ // files11.add("src/test/resources/oxm/test_network_v11.xml");
files11.add("src/test/resources/oxm/business_v11.xml");
-
+
List<String> files13 = new ArrayList<>();
files13.add("src/test/resources/oxm/business_oxm_v13.xml");
files13.add("src/test/resources/oxm/common_oxm_v13.xml");
files13.add("src/test/resources/oxm/serviceDesign_oxm_v13.xml");
files13.add("src/test/resources/oxm/network_oxm_v13.xml");
-
+
Map<SchemaVersion, List<String>> input = new TreeMap<>();
-// input.put(Version.V10, files10);
+ // input.put(Version.V10, files10);
input.put(new SchemaVersion("v11"), files11);
input.put(schemaVersions.getDefaultVersion(), files13);
return input;
@@ -64,15 +65,15 @@ public class TestUtilConfigTranslatorforBusiness extends ConfigTranslator {
files.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json");
Map<SchemaVersion, List<String>> input = new TreeMap<>();
input.put(schemaVersions.getDefaultVersion(), files);
-
+
List<String> files2 = new ArrayList<>();
files2.add("src/test/resources/dbedgerules/test.json");
-// input.put(Version.V10, files2);
-
+ // input.put(Version.V10, files2);
+
List<String> files3 = new ArrayList<>();
files3.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json");
input.put(new SchemaVersion("v11"), files3);
-
+
return input;
}
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java
index f43ea7dc..d2852925 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/CheckEverythingStrategyTest.java
@@ -30,17 +30,17 @@ public class CheckEverythingStrategyTest {
@Test
public void test() {
CheckEverythingStrategy strat = new CheckEverythingStrategy();
- //no issues so nothing notified, should be fine
+ // no issues so nothing notified, should be fine
assertTrue(strat.isOK());
assertTrue("No errors found.".equals(strat.getErrorMsg()));
-
- //simulate post one error
+
+ // simulate post one error
String testError1 = "oh noes a problem with the gooble-gobble edge rule!";
strat.notifyOnError(testError1);
assertFalse(strat.isOK());
assertTrue(testError1.equals(strat.getErrorMsg()));
-
- //simulate multiple found
+
+ // simulate multiple found
String testError2 = "error 2";
String testError3 = "duplicate labels not everything is a fork";
strat.notifyOnError(testError2);
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java
index 0d9ded01..ceced416 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/FailFastStrategyTest.java
@@ -31,16 +31,16 @@ import org.onap.aai.validation.FailFastStrategy;
public class FailFastStrategyTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
-
+
@Test
public void test() {
FailFastStrategy strat = new FailFastStrategy();
-
- //simulate no issues found
+
+ // simulate no issues found
assertTrue(strat.isOK());
assertTrue("No errors found.".equals(strat.getErrorMsg()));
-
- //simulate an issue found
+
+ // simulate an issue found
String testError = "hi i'm a problem";
thrown.expect(AAISchemaValidationException.class);
thrown.expectMessage(testError);
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java
index 667a76ab..4bab99a1 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorRainyDayTest.java
@@ -37,9 +37,12 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {NodesConfiguration.class, BadNodeConfigForValidationTest.class,
- CheckEverythingStrategy.class, DefaultVersionValidationModule.class, VersionValidator.class})
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" })
+@ContextConfiguration(
+ classes = {NodesConfiguration.class, BadNodeConfigForValidationTest.class, CheckEverythingStrategy.class,
+ DefaultVersionValidationModule.class, VersionValidator.class})
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@SpringBootTest
public class VersionValidatorRainyDayTest {
@Autowired
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java
index 2be68558..2598928e 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/VersionValidatorSunnyDayTest.java
@@ -27,7 +27,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.nodes.NodeIngestor;
-
import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.GoodConfigForValidationTest;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,14 +36,12 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {
- NodesConfiguration.class,
- GoodConfigForValidationTest.class,
- CheckEverythingStrategy.class,
- DefaultVersionValidationModule.class,
- VersionValidator.class
-})
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" })
+@ContextConfiguration(
+ classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class,
+ DefaultVersionValidationModule.class, VersionValidator.class})
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@SpringBootTest
public class VersionValidatorSunnyDayTest {
@Autowired
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java
index 75ab0d52..58940af5 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/CousinDefaultingValidationModuleTest.java
@@ -22,6 +22,8 @@ package org.onap.aai.validation.edges;
import static org.junit.Assert.*;
+import com.jayway.jsonpath.DocumentContext;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -32,8 +34,6 @@ import org.junit.Test;
import org.onap.aai.edges.JsonIngestor;
import org.onap.aai.setup.SchemaVersion;
-import com.jayway.jsonpath.DocumentContext;
-
public class CousinDefaultingValidationModuleTest {
private static List<DocumentContext> ctxs;
private static CousinDefaultingValidationModule validator;
@@ -46,12 +46,12 @@ public class CousinDefaultingValidationModuleTest {
SchemaVersion LATEST_VERSION = new SchemaVersion("v14");
testRules.put(LATEST_VERSION, testFiles);
-
+
JsonIngestor ji = new JsonIngestor();
ctxs = ji.ingest(testRules).get(LATEST_VERSION);
validator = new CousinDefaultingValidationModule();
}
-
+
@Test
public void testValidCousins() {
assertTrue("".equals(validator.validate("boop|beep", ctxs)));
@@ -66,12 +66,12 @@ public class CousinDefaultingValidationModuleTest {
public void testValidSingleContains() {
assertTrue("".equals(validator.validate("family|baby", ctxs)));
}
-
+
@Test
public void testInvalidTooManyDefaults() {
assertTrue(validator.validate("sheep|wool", ctxs).contains("Multiple set"));
}
-
+
@Test
public void testInvalidNoDefaults() {
assertTrue(validator.validate("cloth|thread", ctxs).contains("None set"));
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java
index f92c636b..a4c70b81 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModuleTest.java
@@ -39,7 +39,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class DefaultEdgeFieldsValidationModuleTest {
@Autowired
EdgeFieldsValidationModule validator;
-
+
@Test
public void test() {
Map<String, String> test = new HashMap<>();
@@ -47,13 +47,13 @@ public class DefaultEdgeFieldsValidationModuleTest {
test.put(f.toString(), "test");
}
assertTrue("".equals(validator.verifyFields(test)));
-
+
test.remove(EdgeField.DESCRIPTION.toString());
- assertTrue("".equals(validator.verifyFields(test))); //bc description is optional
-
+ assertTrue("".equals(validator.verifyFields(test))); // bc description is optional
+
test.remove(EdgeField.CONTAINS.toString());
assertTrue(validator.verifyFields(test).contains("missing required fields: contains-other-v"));
-
+
test.remove(EdgeField.FROM.toString());
assertTrue(validator.verifyFields(test).contains("missing required fields: from contains-other-v"));
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java
index 5f553ed5..75b27716 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorRainyDayTest.java
@@ -27,7 +27,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.nodes.NodeIngestor;
-
import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.BadEdgeConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
@@ -38,11 +37,14 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {NodesConfiguration.class, BadEdgeConfigForValidationTest.class,
- CheckEverythingStrategy.class, DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class,
- SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, NodeTypesValidationModule.class,
- EdgeRuleValidator.class})
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" })
+@ContextConfiguration(
+ classes = {NodesConfiguration.class, BadEdgeConfigForValidationTest.class, CheckEverythingStrategy.class,
+ DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class,
+ SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class,
+ NodeTypesValidationModule.class, EdgeRuleValidator.class})
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@SpringBootTest
public class EdgeRuleValidatorRainyDayTest {
@Autowired
@@ -50,7 +52,7 @@ public class EdgeRuleValidatorRainyDayTest {
@Test
public void test() {
- assertNotNull(validator); //verify spring wiring OK
+ assertNotNull(validator); // verify spring wiring OK
assertFalse(validator.validate());
String errors = validator.getErrorMsg();
assertTrue(errors.contains("missing required fields: delete-other-v"));
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java
index 6c68027b..ca6b3171 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/EdgeRuleValidatorSunnyDayTest.java
@@ -27,7 +27,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.nodes.NodeIngestor;
-
import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.GoodConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
@@ -38,11 +37,14 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {NodesConfiguration.class, GoodConfigForValidationTest.class,
- CheckEverythingStrategy.class, DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class,
- SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class, NodeTypesValidationModule.class,
- EdgeRuleValidator.class})
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" })
+@ContextConfiguration(
+ classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class,
+ DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class,
+ SingleContainmentValidationModule.class, CousinDefaultingValidationModule.class,
+ NodeTypesValidationModule.class, EdgeRuleValidator.class})
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@SpringBootTest
public class EdgeRuleValidatorSunnyDayTest {
@Autowired
@@ -50,7 +52,7 @@ public class EdgeRuleValidatorSunnyDayTest {
@Test
public void test() {
- assertNotNull(validator); //verify spring wiring OK
+ assertNotNull(validator); // verify spring wiring OK
assertTrue(validator.validate());
assertTrue("No errors found.".equals(validator.getErrorMsg()));
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java
index fc854061..cc38915c 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/NodeTypesValidationModuleTest.java
@@ -30,7 +30,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.nodes.NodeIngestor;
-
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersionsBean;
import org.onap.aai.testutils.TestUtilConfigTranslator;
@@ -41,8 +40,11 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {NodesConfiguration.class, TestUtilConfigTranslator.class, NodeTypesValidationModule.class})
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" })
+@ContextConfiguration(
+ classes = {NodesConfiguration.class, TestUtilConfigTranslator.class, NodeTypesValidationModule.class})
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@SpringBootTest
public class NodeTypesValidationModuleTest {
@Autowired
@@ -55,7 +57,12 @@ public class NodeTypesValidationModuleTest {
testPairs.add("foo|foo");
testPairs.add("foo|quux");
assertTrue("".equals(validator.validate(testPairs, new SchemaVersion("v11"))));
- assertTrue(validator.validate(testPairs, new SchemaVersion("v10")).contains("Invalid node type(s) found: quux")); //bc no quux in v10
+ assertTrue(
+ validator.validate(testPairs, new SchemaVersion("v10")).contains("Invalid node type(s) found: quux")); // bc
+ // no
+ // quux
+ // in
+ // v10
}
@Test
@@ -64,6 +71,6 @@ public class NodeTypesValidationModuleTest {
testPairs.add("bar|");
testPairs.add("|foo");
testPairs.add("|");
- assertTrue("".equals(validator.validate(testPairs, new SchemaVersion("v11")))); //bc empty just ignored
+ assertTrue("".equals(validator.validate(testPairs, new SchemaVersion("v11")))); // bc empty just ignored
}
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/SingleContainmentValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/SingleContainmentValidationModuleTest.java
index 7acb558a..a704d80b 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/SingleContainmentValidationModuleTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/SingleContainmentValidationModuleTest.java
@@ -22,6 +22,8 @@ package org.onap.aai.validation.edges;
import static org.junit.Assert.*;
+import com.jayway.jsonpath.DocumentContext;
+
import java.util.*;
import org.junit.BeforeClass;
@@ -29,8 +31,6 @@ import org.junit.Test;
import org.onap.aai.edges.JsonIngestor;
import org.onap.aai.setup.SchemaVersion;
-import com.jayway.jsonpath.DocumentContext;
-
public class SingleContainmentValidationModuleTest {
private static List<DocumentContext> ctxs;
private static SingleContainmentValidationModule validator;
@@ -42,7 +42,7 @@ public class SingleContainmentValidationModuleTest {
List<String> testFiles = new ArrayList<>();
testFiles.add("src/test/resources/edgeRules/containsValidationTest.json");
testRules.put(LATEST, testFiles);
-
+
JsonIngestor ji = new JsonIngestor();
ctxs = ji.ingest(testRules).get(LATEST);
validator = new SingleContainmentValidationModule();
@@ -57,7 +57,7 @@ public class SingleContainmentValidationModuleTest {
public void testValidWithNone() {
assertTrue("".equals(validator.validate("bread|cheese", ctxs)));
}
-
+
@Test
public void testInvalid() {
assertTrue(validator.validate("box|cat", ctxs).contains("has multiple containment rules"));
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/UniqueLabelValidationModuleTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/UniqueLabelValidationModuleTest.java
index 233f8b4b..76e52036 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/UniqueLabelValidationModuleTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/edges/UniqueLabelValidationModuleTest.java
@@ -22,6 +22,8 @@ package org.onap.aai.validation.edges;
import static org.junit.Assert.*;
+import com.jayway.jsonpath.DocumentContext;
+
import java.util.*;
import org.junit.BeforeClass;
@@ -29,8 +31,6 @@ import org.junit.Test;
import org.onap.aai.edges.JsonIngestor;
import org.onap.aai.setup.SchemaVersion;
-import com.jayway.jsonpath.DocumentContext;
-
public class UniqueLabelValidationModuleTest {
private static List<DocumentContext> ctxs;
private static UniqueLabelValidationModule validator;
@@ -43,7 +43,7 @@ public class UniqueLabelValidationModuleTest {
testFiles.add("src/test/resources/edgeRules/labelValidationTest1.json");
testFiles.add("src/test/resources/edgeRules/labelValidationTest2.json");
testRules.put(LATEST, testFiles);
-
+
JsonIngestor ji = new JsonIngestor();
ctxs = ji.ingest(testRules).get(LATEST);
validator = new UniqueLabelValidationModule();
@@ -54,13 +54,13 @@ public class UniqueLabelValidationModuleTest {
assertTrue("".equals(validator.validate("human|monster", ctxs)));
assertTrue("".equals(validator.validate("monster|human", ctxs)));
}
-
+
@Test
public void testValidDupLabelButDiffPairs() {
assertTrue("".equals(validator.validate("human|strange-and-interesting-plant", ctxs)));
assertTrue("".equals(validator.validate("strange-and-interesting-plant|human", ctxs)));
}
-
+
@Test
public void testValidAcrossFiles() {
assertTrue("".equals(validator.validate("human|toaster", ctxs)));
@@ -72,19 +72,19 @@ public class UniqueLabelValidationModuleTest {
assertTrue(validator.validate("sphinx|monster", ctxs).contains("has multiple rules using the same label"));
assertTrue(validator.validate("monster|sphinx", ctxs).contains("has multiple rules using the same label"));
}
-
+
@Test
public void testInvalidSetOneFileJustCousins() {
assertTrue(validator.validate("griffin|hippogriff", ctxs).contains("has multiple rules using the same label"));
assertTrue(validator.validate("hippogriff|griffin", ctxs).contains("has multiple rules using the same label"));
}
-
+
@Test
public void testInvalidSetMultipleFiles() {
assertTrue(validator.validate("lava|floor", ctxs).contains("has multiple rules using the same label"));
assertTrue(validator.validate("floor|lava", ctxs).contains("has multiple rules using the same label"));
}
-
+
@Test
public void testInvalidCopyInOtherFile() {
assertTrue(validator.validate("badger|mushroom", ctxs).contains("has multiple rules using the same label"));
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java
index fc4ddd45..e164df04 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorRainyDayTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
-
import org.onap.aai.testutils.BadNodeConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule;
@@ -38,10 +37,13 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {BadNodeConfigForValidationTest.class, NodesConfiguration.class,
- CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class})
+@ContextConfiguration(
+ classes = {BadNodeConfigForValidationTest.class, NodesConfiguration.class, CheckEverythingStrategy.class,
+ DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class})
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" })
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@SpringBootTest
public class NodeValidatorRainyDayTest {
@@ -50,7 +52,7 @@ public class NodeValidatorRainyDayTest {
@Test
public void test() {
- assertNotNull(validator); //check spring wiring ok
+ assertNotNull(validator); // check spring wiring ok
assertFalse(validator.validate());
String result = validator.getErrorMsg();
assertTrue(result.contains("LogicalLink"));
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java
index 6ab84d40..288913b1 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSchemaIncompleteTest.java
@@ -20,6 +20,18 @@
package org.onap.aai.validation.nodes;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -27,9 +39,7 @@ import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.nodes.NodeIngestor;
-
import org.onap.aai.setup.SchemaVersion;
-
import org.onap.aai.testutils.SchemaIncompleteTranslator;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -40,43 +50,33 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.w3c.dom.Document;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { SchemaIncompleteTranslator.class, NodesConfiguration.class})
+@ContextConfiguration(classes = {SchemaIncompleteTranslator.class, NodesConfiguration.class})
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" })
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@SpringBootTest
@Ignore
public class NodeValidatorSchemaIncompleteTest {
@Autowired
NodeIngestor ni;
-
- //set thrown.expect to whatever a specific test needs
- //this establishes a default of expecting no exceptions to be thrown
+
+ // set thrown.expect to whatever a specific test needs
+ // this establishes a default of expecting no exceptions to be thrown
@Rule
- public ExpectedException thrown = ExpectedException.none();
+ public ExpectedException thrown = ExpectedException.none();
- //Throws a NullPointerException because a JavaType is referenced, but not defined
+ // Throws a NullPointerException because a JavaType is referenced, but not defined
@Test
public void testIncompleteCombinedSchema() throws TransformerException, IOException, IllegalStateException {
thrown.expect(NullPointerException.class);
- //TODO Change for Exception
+ // TODO Change for Exception
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- printDocument(ni.getSchema(new SchemaVersion("v12")),buffer);
+ printDocument(ni.getSchema(new SchemaVersion("v12")), buffer);
}
-
+
public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException {
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
@@ -86,7 +86,6 @@ public class NodeValidatorSchemaIncompleteTest {
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- transformer.transform(new DOMSource(doc),
- new StreamResult(new OutputStreamWriter(out, "UTF-8")));
+ transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out, "UTF-8")));
}
}
diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java
index b69182fc..81b69e6e 100644
--- a/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java
+++ b/aai-schema-ingest/src/test/java/org/onap/aai/validation/nodes/NodeValidatorSunnyDayTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.config.NodesConfiguration;
-
import org.onap.aai.testutils.GoodConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
import org.onap.aai.validation.nodes.DefaultDuplicateNodeDefinitionValidationModule;
@@ -35,10 +34,14 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = { NodesConfiguration.class, GoodConfigForValidationTest.class,
- CheckEverythingStrategy.class, DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class})
-@TestPropertySource(properties = { "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties" })
+@ContextConfiguration(
+ classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class,
+ DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class})
+@TestPropertySource(
+ properties = {
+ "schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@SpringBootTest
public class NodeValidatorSunnyDayTest {
@@ -47,7 +50,7 @@ public class NodeValidatorSunnyDayTest {
@Test
public void test() {
- assertNotNull(validator); //check spring wiring ok
+ assertNotNull(validator); // check spring wiring ok
assertTrue(validator.validate());
assertTrue("No errors found.".equals(validator.getErrorMsg()));
}