aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-gen
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-09-19 16:55:36 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-09-19 16:55:36 +0200
commit7343beeaf260747aef6a6b9c22acd91de67c5ca0 (patch)
treecc90d98dfb61d5066184b346612bb04caaae64b4 /aai-schema-gen
parente0ad4f2890f9f933199bc6f1b3f0e988da471aa9 (diff)
Add instructions to invoke the linter and code formatter plugins to the README and invoke the formatter
Issue-ID: AAI-3526 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: Ibd383994732cea6460153704a1153beb530dc6c3
Diffstat (limited to 'aai-schema-gen')
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java43
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java476
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/SchemaConfiguration.java12
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/SpringContextAware.java27
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/SwaggerGenerationConfiguration.java15
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java93
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSet.java65
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteOperation.java14
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/EdgeDescription.java35
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/GetOperation.java36
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java39
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodeGetOperation.java17
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java43
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/OxmFileProcessor.java13
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PatchOperation.java14
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutOperation.java16
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutRelationPathSet.java26
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java39
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDJavaType.java21
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java62
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/Api.java1
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/Definition.java2
-rw-r--r--aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java482
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/GenerateXsdTest.java193
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSetTest.java100
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteOperationTest.java105
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/EdgeDescriptionTest.java564
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/GetOperationTest.java146
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/HTMLfromOXMTest.java664
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodeGetOperationTest.java152
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXMTest.java798
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java107
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutOperationTest.java109
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutRelationPathSetTest.java388
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDElementTest.java1285
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDJavaTypeTest.java129
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/YAMLfromOXMTest.java1599
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/swagger/DefinitionTest.java9
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforBusiness.java73
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforDataLink.java69
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforEdges.java77
41 files changed, 4232 insertions, 3926 deletions
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java
index 85ecfad..ae5426f 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java
@@ -4,13 +4,13 @@
* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,13 +19,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen;
import freemarker.template.TemplateException;
-import org.onap.aai.schemagen.swagger.GenerateSwagger;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersions;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import java.io.File;
import java.io.IOException;
@@ -33,23 +30,25 @@ import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
+import org.onap.aai.schemagen.swagger.GenerateSwagger;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
public class AutoGenerateHtml {
private static final String AAI_GENERATE_VERSION = "aai.generate.version";
public static final String DEFAULT_SCHEMA_DIR = "../aai-schema";
- //if the program is run from aai-common, use this directory as default"
+ // if the program is run from aai-common, use this directory as default"
public static final String ALT_SCHEMA_DIR = "aai-schema";
- //used to check to see if program is run from aai-schema-gen
+ // used to check to see if program is run from aai-schema-gen
public static final String DEFAULT_RUN_DIR = "aai-schema-gen";
public static void main(String[] args) throws IOException, TemplateException {
String savedProperty = System.getProperty(AAI_GENERATE_VERSION);
- AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
- "org.onap.aai.setup",
- "org.onap.aai.schemagen"
- );
-
+ AnnotationConfigApplicationContext ctx =
+ new AnnotationConfigApplicationContext("org.onap.aai.setup", "org.onap.aai.schemagen");
SchemaVersions schemaVersions = ctx.getBean(SchemaVersions.class);
@@ -58,18 +57,20 @@ public class AutoGenerateHtml {
Collections.reverse(versionsToGen);
ListIterator<SchemaVersion> versionIterator = versionsToGen.listIterator();
String schemaDir;
- if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) {
+ if (System.getProperty("user.dir") != null
+ && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) {
schemaDir = ALT_SCHEMA_DIR;
- }
- else {
- schemaDir = DEFAULT_SCHEMA_DIR;
- }
- String release = System.getProperty("aai.release", "onap");
+ } else {
+ schemaDir = DEFAULT_SCHEMA_DIR;
+ }
+ String release = System.getProperty("aai.release", "onap");
while (versionIterator.hasNext()) {
System.setProperty(AAI_GENERATE_VERSION, versionIterator.next().toString());
- String yamlFile = schemaDir + "/src/main/resources/" + release + "/aai_swagger_yaml/aai_swagger_" + System.getProperty(AAI_GENERATE_VERSION)+ ".yaml";
+ String yamlFile =
+ schemaDir + "/src/main/resources/" + release + "/aai_swagger_yaml/aai_swagger_"
+ + System.getProperty(AAI_GENERATE_VERSION) + ".yaml";
File swaggerYamlFile = new File(yamlFile);
- if(swaggerYamlFile.exists()) {
+ if (swaggerYamlFile.exists()) {
GenerateSwagger.schemaVersions = schemaVersions;
GenerateSwagger.main(args);
}
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java
index 9d3f258..490e290 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,126 +17,124 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.schemagen;
-
-import java.nio.charset.StandardCharsets;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.schemagen.genxsd.HTMLfromOXM;
-import org.onap.aai.schemagen.genxsd.NodesYAMLfromOXM;
-import org.onap.aai.schemagen.genxsd.YAMLfromOXM;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.w3c.dom.NodeList;
+package org.onap.aai.schemagen;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
+import org.onap.aai.schemagen.genxsd.HTMLfromOXM;
+import org.onap.aai.schemagen.genxsd.NodesYAMLfromOXM;
+import org.onap.aai.schemagen.genxsd.YAMLfromOXM;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.w3c.dom.NodeList;
+
public class GenerateXsd {
- private static final Logger logger = LoggerFactory.getLogger("GenerateXsd.class");
- protected static String apiVersion = null;
- public static AnnotationConfigApplicationContext ctx = null;
- static String apiVersionFmt = null;
- static boolean useAnnotationsInXsd = false;
- static String responsesUrl = null;
- static String responsesLabel = null;
- static String jsonEdges = null;
- static Map<String, String> generatedJavaType;
- static Map<String, String> appliedPaths;
- static String RELEASE = System.getProperty("aai.release", "onap");
-
-
- static NodeList javaTypeNodes;
- static Map<String,String> javaTypeDefinitions = createJavaTypeDefinitions();
- private static Map<String, String> createJavaTypeDefinitions()
- {
+ private static final Logger logger = LoggerFactory.getLogger("GenerateXsd.class");
+ protected static String apiVersion = null;
+ public static AnnotationConfigApplicationContext ctx = null;
+ static String apiVersionFmt = null;
+ static boolean useAnnotationsInXsd = false;
+ static String responsesUrl = null;
+ static String responsesLabel = null;
+ static String jsonEdges = null;
+ static Map<String, String> generatedJavaType;
+ static Map<String, String> appliedPaths;
+ static String RELEASE = System.getProperty("aai.release", "onap");
+
+ static NodeList javaTypeNodes;
+ static Map<String, String> javaTypeDefinitions = createJavaTypeDefinitions();
+
+ private static Map<String, String> createJavaTypeDefinitions() {
StringBuilder aaiInternal = new StringBuilder();
- Map<String,String> javaTypeDefinitions = new HashMap<String, String>();
- aaiInternal.append(" aai-internal:\n");
- aaiInternal.append(" properties:\n");
- aaiInternal.append(" property-name:\n");
- aaiInternal.append(" type: string\n");
- aaiInternal.append(" property-value:\n");
- aaiInternal.append(" type: string\n");
-// javaTypeDefinitions.put("aai-internal", aaiInternal.toString());
- return javaTypeDefinitions;
+ Map<String, String> javaTypeDefinitions = new HashMap<String, String>();
+ aaiInternal.append(" aai-internal:\n");
+ aaiInternal.append(" properties:\n");
+ aaiInternal.append(" property-name:\n");
+ aaiInternal.append(" type: string\n");
+ aaiInternal.append(" property-value:\n");
+ aaiInternal.append(" type: string\n");
+ // javaTypeDefinitions.put("aai-internal", aaiInternal.toString());
+ return javaTypeDefinitions;
}
- public static final int VALUE_NONE = 0;
- public static final int VALUE_DESCRIPTION = 1;
- public static final int VALUE_INDEXED_PROPS = 2;
- public static final int VALUE_CONTAINER = 3;
-
- private static final String GENERATE_TYPE_XSD = "xsd";
- private static final String GENERATE_TYPE_YAML = "yaml";
+ public static final int VALUE_NONE = 0;
+ public static final int VALUE_DESCRIPTION = 1;
+ public static final int VALUE_INDEXED_PROPS = 2;
+ public static final int VALUE_CONTAINER = 3;
- private final static String NODE_DIR = System.getProperty("nodes.configuration.location");
- private final static String EDGE_DIR = System.getProperty("edges.configuration.location");
- private static final String BASE_ROOT = "aai-schema/";
- private static final String BASE_AUTO_GEN_ROOT = "aai-schema/";
+ private static final String GENERATE_TYPE_XSD = "xsd";
+ private static final String GENERATE_TYPE_YAML = "yaml";
- private static final String ROOT = BASE_ROOT + "src/main/resources";
- private static final String AUTO_GEN_ROOT = BASE_AUTO_GEN_ROOT + "src/main/resources";
+ private final static String NODE_DIR = System.getProperty("nodes.configuration.location");
+ private final static String EDGE_DIR = System.getProperty("edges.configuration.location");
+ private static final String BASE_ROOT = "aai-schema/";
+ private static final String BASE_AUTO_GEN_ROOT = "aai-schema/";
- private static final String NORMAL_START_DIR = "aai-schema-gen";
- private static final String XSD_DIR = ROOT + "/" + RELEASE +"/aai_schema";
+ private static final String ROOT = BASE_ROOT + "src/main/resources";
+ private static final String AUTO_GEN_ROOT = BASE_AUTO_GEN_ROOT + "src/main/resources";
- private static final String
- YAML_DIR = (((System.getProperty("user.dir") != null) && (!System.getProperty("user.dir").contains(
- NORMAL_START_DIR))) ?
- AUTO_GEN_ROOT :
- ROOT) + "/" + RELEASE + "/aai_swagger_yaml";
+ private static final String NORMAL_START_DIR = "aai-schema-gen";
+ private static final String XSD_DIR = ROOT + "/" + RELEASE + "/aai_schema";
- /* These three strings are for yaml auto-generation from aai-common class*/
+ private static final String YAML_DIR = (((System.getProperty("user.dir") != null)
+ && (!System.getProperty("user.dir").contains(NORMAL_START_DIR))) ? AUTO_GEN_ROOT : ROOT)
+ + "/" + RELEASE + "/aai_swagger_yaml";
- private static final int SWAGGER_SUPPORT_STARTS_VERSION = 1; // minimum version to support swagger documentation
+ /* These three strings are for yaml auto-generation from aai-common class */
+ private static final int SWAGGER_SUPPORT_STARTS_VERSION = 1; // minimum version to support
+ // swagger documentation
- private static boolean validVersion(String versionToGen) {
+ private static boolean validVersion(String versionToGen) {
- if ("ALL".equalsIgnoreCase(versionToGen)) {
- return true;
- }
+ if ("ALL".equalsIgnoreCase(versionToGen)) {
+ return true;
+ }
- SchemaVersions schemaVersions = SpringContextAware.getBean(SchemaVersions.class);
- if (schemaVersions == null) {
- return false;
+ SchemaVersions schemaVersions = SpringContextAware.getBean(SchemaVersions.class);
+ if (schemaVersions == null) {
+ return false;
+ }
+ for (SchemaVersion v : schemaVersions.getVersions()) {
+ if (v.toString().equals(versionToGen)) {
+ return true;
+ }
}
- for (SchemaVersion v : schemaVersions.getVersions()) {
- if (v.toString().equals(versionToGen)) {
- return true;
- }
- }
- return false;
- }
+ return false;
+ }
- private static boolean versionSupportsSwagger(String version) {
+ private static boolean versionSupportsSwagger(String version) {
return Integer.parseInt(version.substring(1)) >= SWAGGER_SUPPORT_STARTS_VERSION;
}
- public static String getAPIVersion() {
- return apiVersion;
- }
+ public static String getAPIVersion() {
+ return apiVersion;
+ }
+
+ public static String getYamlDir() {
+ return YAML_DIR;
+ }
- public static String getYamlDir() {
- return YAML_DIR;
- }
+ public static String getResponsesUrl() {
+ return responsesUrl;
+ }
- public static String getResponsesUrl() {
- return responsesUrl;
- }
- public static void main(String[] args) throws IOException {
- String versionToGen = System.getProperty("gen_version");
+ public static void main(String[] args) throws IOException {
+ String versionToGen = System.getProperty("gen_version");
if (versionToGen == null) {
System.err.println("Version is required, ie v<n> or ALL.");
System.exit(1);
@@ -151,176 +149,172 @@ public class GenerateXsd {
fileTypeToGen = fileTypeToGen.toLowerCase();
}
- AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
- "org.onap.aai.setup",
- "org.onap.aai.schemagen"
- );
+ AnnotationConfigApplicationContext ctx =
+ new AnnotationConfigApplicationContext("org.onap.aai.setup", "org.onap.aai.schemagen");
- SchemaVersions schemaVersions = ctx.getBean(SchemaVersions.class);
+ SchemaVersions schemaVersions = ctx.getBean(SchemaVersions.class);
- if ( !fileTypeToGen.equals(GENERATE_TYPE_XSD) && !fileTypeToGen.equals(GENERATE_TYPE_YAML)) {
- System.err.println("Invalid gen_type passed. " + fileTypeToGen);
- System.exit(1);
- }
+ if (!fileTypeToGen.equals(GENERATE_TYPE_XSD) && !fileTypeToGen.equals(GENERATE_TYPE_YAML)) {
+ System.err.println("Invalid gen_type passed. " + fileTypeToGen);
+ System.exit(1);
+ }
- String responsesLabel = System.getProperty("yamlresponses_url");
- responsesUrl = responsesLabel;
+ String responsesLabel = System.getProperty("yamlresponses_url");
+ responsesUrl = responsesLabel;
- List<SchemaVersion> versionsToGen = new ArrayList<>();
- if (!"ALL".equalsIgnoreCase(versionToGen) && !versionToGen.matches("v\\d+") && !validVersion(versionToGen)) {
- System.err.println("Invalid version passed. " + versionToGen);
- System.exit(1);
- }
- else if ("ALL".equalsIgnoreCase(versionToGen)) {
- versionsToGen = schemaVersions.getVersions();
- Collections.sort(versionsToGen);
- Collections.reverse(versionsToGen);
- } else {
- versionsToGen.add(new SchemaVersion(versionToGen));
- }
-
- //process file type System property
- if ( fileTypeToGen.equals(GENERATE_TYPE_YAML) ) {
- if ( responsesUrl == null || responsesUrl.length() < 1
- || responsesLabel == null || responsesLabel.length() < 1 ) {
- System.err.println("generating swagger yaml file requires yamlresponses_url and yamlresponses_label properties" );
- System.exit(1);
- } else {
- responsesUrl = "description: "+ "Response codes found in [response codes]("+responsesLabel+ ").\n";
- }
- }
- /*
- * TODO: Oxm Path is config driveb
- */
- String oxmPath;
- if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains(
- NORMAL_START_DIR)) {
- oxmPath = BASE_AUTO_GEN_ROOT + NODE_DIR;
- }
- else {
- oxmPath = BASE_ROOT + NODE_DIR;
- }
+ List<SchemaVersion> versionsToGen = new ArrayList<>();
+ if (!"ALL".equalsIgnoreCase(versionToGen) && !versionToGen.matches("v\\d+")
+ && !validVersion(versionToGen)) {
+ System.err.println("Invalid version passed. " + versionToGen);
+ System.exit(1);
+ } else if ("ALL".equalsIgnoreCase(versionToGen)) {
+ versionsToGen = schemaVersions.getVersions();
+ Collections.sort(versionsToGen);
+ Collections.reverse(versionsToGen);
+ } else {
+ versionsToGen.add(new SchemaVersion(versionToGen));
+ }
- String outfileName = null;
- File outfile;
- String nodesfileName = null;
- File nodesfile;
- String fileContent = null;
- String nodesContent = null;
-
-
- for (SchemaVersion v : versionsToGen) {
- apiVersion = v.toString();
- logger.debug("YAMLdir = "+ YAML_DIR);
- logger.debug("Generating " + apiVersion + " " + fileTypeToGen);
- apiVersionFmt = "." + apiVersion + ".";
- generatedJavaType = new HashMap<String, String>();
- appliedPaths = new HashMap<String, String>();
- File edgeRuleFile = null;
- String fileName = EDGE_DIR + "DbEdgeRules_" + apiVersion + ".json";
- logger.debug("user.dir = "+System.getProperty("user.dir"));
- if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains(
- NORMAL_START_DIR)) {
- fileName = BASE_AUTO_GEN_ROOT + fileName;
-
- }
- else {
- fileName = BASE_ROOT + fileName;
-
- }
- edgeRuleFile = new File( fileName);
-// Document doc = ni.getSchema(translateVersion(v));
-
- if ( fileTypeToGen.equals(GENERATE_TYPE_XSD) ) {
- outfileName = XSD_DIR + "/aai_schema_" + apiVersion + "." + GENERATE_TYPE_XSD;
- try {
- HTMLfromOXM swagger = ctx.getBean(HTMLfromOXM.class);
- swagger.setVersion(v);
- fileContent = swagger.process();
- if ( fileContent.startsWith("Schema format issue")) {
- throw new Exception(fileContent);
- }
- } catch(Exception e) {
- logger.error( "Exception creating output file " + outfileName);
- logger.error( e.getMessage());
- System.exit(-1);
+ // process file type System property
+ if (fileTypeToGen.equals(GENERATE_TYPE_YAML)) {
+ if (responsesUrl == null || responsesUrl.length() < 1 || responsesLabel == null
+ || responsesLabel.length() < 1) {
+ System.err.println(
+ "generating swagger yaml file requires yamlresponses_url and yamlresponses_label properties");
+ System.exit(1);
+ } else {
+ responsesUrl = "description: " + "Response codes found in [response codes]("
+ + responsesLabel + ").\n";
+ }
}
- } else if ( versionSupportsSwagger(apiVersion )) {
- outfileName = YAML_DIR + "/aai_swagger_" + apiVersion + "." + GENERATE_TYPE_YAML;
- nodesfileName = YAML_DIR + "/aai_swagger_" + apiVersion + "." + "nodes"+"."+
- GENERATE_TYPE_YAML;
- try {
- YAMLfromOXM swagger = (YAMLfromOXM) ctx.getBean(YAMLfromOXM.class);
- swagger.setVersion(v);
- fileContent = swagger.process();
- Map combinedJavaTypes = swagger.getCombinedJavaTypes();
- NodesYAMLfromOXM nodesSwagger = ctx.getBean(NodesYAMLfromOXM.class);
- nodesSwagger.setVersion(v);
- nodesSwagger.setCombinedJavaTypes(combinedJavaTypes);
- nodesContent = nodesSwagger.process();
- } catch(Exception e) {
- logger.error("Exception creating output file " + outfileName, e);
+ /*
+ * TODO: Oxm Path is config driveb
+ */
+ String oxmPath;
+ if (System.getProperty("user.dir") != null
+ && !System.getProperty("user.dir").contains(NORMAL_START_DIR)) {
+ oxmPath = BASE_AUTO_GEN_ROOT + NODE_DIR;
+ } else {
+ oxmPath = BASE_ROOT + NODE_DIR;
}
- } else {
- continue;
- }
- outfile = new File(outfileName);
- File parentDir = outfile.getParentFile();
- if(!parentDir.exists()) {
+
+ String outfileName = null;
+ File outfile;
+ String nodesfileName = null;
+ File nodesfile;
+ String fileContent = null;
+ String nodesContent = null;
+
+ for (SchemaVersion v : versionsToGen) {
+ apiVersion = v.toString();
+ logger.debug("YAMLdir = " + YAML_DIR);
+ logger.debug("Generating " + apiVersion + " " + fileTypeToGen);
+ apiVersionFmt = "." + apiVersion + ".";
+ generatedJavaType = new HashMap<String, String>();
+ appliedPaths = new HashMap<String, String>();
+ File edgeRuleFile = null;
+ String fileName = EDGE_DIR + "DbEdgeRules_" + apiVersion + ".json";
+ logger.debug("user.dir = " + System.getProperty("user.dir"));
+ if (System.getProperty("user.dir") != null
+ && !System.getProperty("user.dir").contains(NORMAL_START_DIR)) {
+ fileName = BASE_AUTO_GEN_ROOT + fileName;
+
+ } else {
+ fileName = BASE_ROOT + fileName;
+
+ }
+ edgeRuleFile = new File(fileName);
+ // Document doc = ni.getSchema(translateVersion(v));
+
+ if (fileTypeToGen.equals(GENERATE_TYPE_XSD)) {
+ outfileName = XSD_DIR + "/aai_schema_" + apiVersion + "." + GENERATE_TYPE_XSD;
+ try {
+ HTMLfromOXM swagger = ctx.getBean(HTMLfromOXM.class);
+ swagger.setVersion(v);
+ fileContent = swagger.process();
+ if (fileContent.startsWith("Schema format issue")) {
+ throw new Exception(fileContent);
+ }
+ } catch (Exception e) {
+ logger.error("Exception creating output file " + outfileName);
+ logger.error(e.getMessage());
+ System.exit(-1);
+ }
+ } else if (versionSupportsSwagger(apiVersion)) {
+ outfileName = YAML_DIR + "/aai_swagger_" + apiVersion + "." + GENERATE_TYPE_YAML;
+ nodesfileName = YAML_DIR + "/aai_swagger_" + apiVersion + "." + "nodes" + "."
+ + GENERATE_TYPE_YAML;
+ try {
+ YAMLfromOXM swagger = (YAMLfromOXM) ctx.getBean(YAMLfromOXM.class);
+ swagger.setVersion(v);
+ fileContent = swagger.process();
+ Map combinedJavaTypes = swagger.getCombinedJavaTypes();
+ NodesYAMLfromOXM nodesSwagger = ctx.getBean(NodesYAMLfromOXM.class);
+ nodesSwagger.setVersion(v);
+ nodesSwagger.setCombinedJavaTypes(combinedJavaTypes);
+ nodesContent = nodesSwagger.process();
+ } catch (Exception e) {
+ logger.error("Exception creating output file " + outfileName, e);
+ }
+ } else {
+ continue;
+ }
+ outfile = new File(outfileName);
+ File parentDir = outfile.getParentFile();
+ if (!parentDir.exists()) {
parentDir.mkdirs();
}
- if(nodesfileName != null) {
- BufferedWriter nodesBW = null;
- nodesfile = new File(nodesfileName);
- parentDir = nodesfile.getParentFile();
- if(!parentDir.exists()){
+ if (nodesfileName != null) {
+ BufferedWriter nodesBW = null;
+ nodesfile = new File(nodesfileName);
+ parentDir = nodesfile.getParentFile();
+ if (!parentDir.exists()) {
parentDir.mkdirs();
}
- try {
- if(!nodesfile.createNewFile()) {
- logger.error( "File {} already exist", nodesfileName);
+ try {
+ if (!nodesfile.createNewFile()) {
+ logger.error("File {} already exist", nodesfileName);
}
- } catch (IOException e) {
- logger.error( "Exception creating output file " + nodesfileName, e);
- }
- try {
- Charset charset = StandardCharsets.UTF_8;
- Path path = Paths.get(nodesfileName);
- nodesBW = Files.newBufferedWriter(path, charset);
- nodesBW.write(nodesContent);
- } catch ( IOException e) {
- logger.error( "Exception writing output file " + outfileName, e);
- } finally {
- if ( nodesBW != null ) {
- nodesBW.close();
- }
+ } catch (IOException e) {
+ logger.error("Exception creating output file " + nodesfileName, e);
+ }
+ try {
+ Charset charset = StandardCharsets.UTF_8;
+ Path path = Paths.get(nodesfileName);
+ nodesBW = Files.newBufferedWriter(path, charset);
+ nodesBW.write(nodesContent);
+ } catch (IOException e) {
+ logger.error("Exception writing output file " + outfileName, e);
+ } finally {
+ if (nodesBW != null) {
+ nodesBW.close();
+ }
+ }
}
- }
- try {
- if(!outfile.createNewFile()) {
- logger.error( "File {} already exist", outfileName);
+ try {
+ if (!outfile.createNewFile()) {
+ logger.error("File {} already exist", outfileName);
}
- } catch (IOException e) {
- logger.error( "Exception creating output file " + outfileName, e);
- }
- BufferedWriter bw = null;
- try {
- Charset charset = StandardCharsets.UTF_8;
- Path path = Paths.get(outfileName);
- bw = Files.newBufferedWriter(path, charset);
- bw.write(fileContent);
- } catch ( IOException e) {
- logger.error( "Exception writing output file " + outfileName, e);
- } finally {
- if ( bw != null ) {
- bw.close();
+ } catch (IOException e) {
+ logger.error("Exception creating output file " + outfileName, e);
}
- }
- logger.debug( "GeneratedXSD successful, saved in " + outfileName);
- }
+ BufferedWriter bw = null;
+ try {
+ Charset charset = StandardCharsets.UTF_8;
+ Path path = Paths.get(outfileName);
+ bw = Files.newBufferedWriter(path, charset);
+ bw.write(fileContent);
+ } catch (IOException e) {
+ logger.error("Exception writing output file " + outfileName, e);
+ } finally {
+ if (bw != null) {
+ bw.close();
+ }
+ }
+ logger.debug("GeneratedXSD successful, saved in " + outfileName);
+ }
- }
+ }
}
-
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SchemaConfiguration.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SchemaConfiguration.java
index 26ff4b6..4657862 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SchemaConfiguration.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SchemaConfiguration.java
@@ -10,7 +10,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen;
import org.onap.aai.edges.EdgeIngestor;
@@ -34,8 +35,10 @@ import org.springframework.context.annotation.Configuration;
public class SchemaConfiguration {
@Bean
- public EdgeIngestor edgeIngestor(SchemaLocationsBean schemaLocationsBean, SchemaVersions schemaVersions){
- return new EdgeIngestor(configTranslator(schemaLocationsBean, schemaVersions), schemaVersions);
+ public EdgeIngestor edgeIngestor(SchemaLocationsBean schemaLocationsBean,
+ SchemaVersions schemaVersions) {
+ return new EdgeIngestor(configTranslator(schemaLocationsBean, schemaVersions),
+ schemaVersions);
}
@Bean(name = "nodeIngestor")
@@ -44,7 +47,8 @@ public class SchemaConfiguration {
}
@Bean(name = "configTranslator")
- public ConfigTranslator configTranslator(SchemaLocationsBean schemaLocationsBean, SchemaVersions schemaVersions) {
+ public ConfigTranslator configTranslator(SchemaLocationsBean schemaLocationsBean,
+ SchemaVersions schemaVersions) {
return new AAIConfigTranslator(schemaLocationsBean, schemaVersions);
}
}
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SpringContextAware.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SpringContextAware.java
index d91cf81..4bdc05b 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SpringContextAware.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SpringContextAware.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,8 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.schemagen;
+package org.onap.aai.schemagen;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
@@ -31,31 +31,30 @@ public class SpringContextAware implements ApplicationContextAware {
private static ApplicationContext context = null;
public static ApplicationContext getApplicationContext() {
- return context;
+ return context;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- context = applicationContext;
+ context = applicationContext;
}
-
- public static <T> T getBean(String beanName, Class<T> requiredType) {
- if(context != null){
- return context.getBean(beanName, requiredType);
- }
+ public static <T> T getBean(String beanName, Class<T> requiredType) {
+ if (context != null) {
+ return context.getBean(beanName, requiredType);
+ }
return null;
- }
+ }
- public static <T> T getBean(Class<T> clazz){
- if(context != null){
+ public static <T> T getBean(Class<T> clazz) {
+ if (context != null) {
return context.getBean(clazz);
}
return null;
}
- public static Object getBean(String bean){
- if(context != null){
+ public static Object getBean(String bean) {
+ if (context != null) {
return context.getBean(bean);
}
return null;
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SwaggerGenerationConfiguration.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SwaggerGenerationConfiguration.java
index e479328..0370e8b 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SwaggerGenerationConfiguration.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SwaggerGenerationConfiguration.java
@@ -10,7 +10,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,15 +19,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.schemagen;
+package org.onap.aai.schemagen;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.schemagen.genxsd.HTMLfromOXM;
import org.onap.aai.schemagen.genxsd.NodesYAMLfromOXM;
import org.onap.aai.schemagen.genxsd.YAMLfromOXM;
+import org.onap.aai.setup.SchemaVersions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
@@ -45,19 +45,22 @@ public class SwaggerGenerationConfiguration {
@Bean
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public NodesYAMLfromOXM nodesYamlFromOXM(SchemaVersions schemaVersions, NodeIngestor nodeIngestor, EdgeIngestor edgeIngestor) {
+ public NodesYAMLfromOXM nodesYamlFromOXM(SchemaVersions schemaVersions,
+ NodeIngestor nodeIngestor, EdgeIngestor edgeIngestor) {
return new NodesYAMLfromOXM(basePath, schemaVersions, nodeIngestor, edgeIngestor);
}
@Bean
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public HTMLfromOXM htmlFromOXM(SchemaVersions schemaVersions, NodeIngestor nodeIngestor, EdgeIngestor edgeIngestor) {
+ public HTMLfromOXM htmlFromOXM(SchemaVersions schemaVersions, NodeIngestor nodeIngestor,
+ EdgeIngestor edgeIngestor) {
return new HTMLfromOXM(maxOccurs, schemaVersions, nodeIngestor, edgeIngestor);
}
@Bean
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
- public YAMLfromOXM yamlFromOXM(SchemaVersions schemaVersions, NodeIngestor nodeIngestor, EdgeIngestor edgeIngestor) {
+ public YAMLfromOXM yamlFromOXM(SchemaVersions schemaVersions, NodeIngestor nodeIngestor,
+ EdgeIngestor edgeIngestor) {
return new YAMLfromOXM(basePath, schemaVersions, nodeIngestor, edgeIngestor);
}
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java
index c4db6f9..87ba528 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,62 +20,63 @@
package org.onap.aai.schemagen.genxsd;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.*;
+
import org.onap.aai.setup.ConfigTranslator;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.*;
-
public class ConfigTranslatorForDocs extends ConfigTranslator {
- public ConfigTranslatorForDocs(SchemaLocationsBean bean, SchemaVersions schemaVersions) {
- super(bean, schemaVersions);
- }
+ public ConfigTranslatorForDocs(SchemaLocationsBean bean, SchemaVersions schemaVersions) {
+ super(bean, schemaVersions);
+ }
- @Override
- public Map<SchemaVersion, List<String>> getNodeFiles() {
- List<SchemaVersion> versionsToGen = new ArrayList<>();
- versionsToGen = schemaVersions.getVersions();
- Collections.sort(versionsToGen);
- Collections.reverse(versionsToGen);
- Map<SchemaVersion, List<String>> mp = new TreeMap<>();
- for (SchemaVersion v : versionsToGen) {
- File dir = new File(bean.getNodeDirectory() + File.separator + v.toString().toLowerCase());
- File [] fileSet = dir.listFiles();
- List<String> files = new ArrayList<>();
- for(File f: fileSet ) {
- files.add(f.getAbsolutePath());
- }
+ @Override
+ public Map<SchemaVersion, List<String>> getNodeFiles() {
+ List<SchemaVersion> versionsToGen = new ArrayList<>();
+ versionsToGen = schemaVersions.getVersions();
+ Collections.sort(versionsToGen);
+ Collections.reverse(versionsToGen);
+ Map<SchemaVersion, List<String>> mp = new TreeMap<>();
+ for (SchemaVersion v : versionsToGen) {
+ File dir =
+ new File(bean.getNodeDirectory() + File.separator + v.toString().toLowerCase());
+ File[] fileSet = dir.listFiles();
+ List<String> files = new ArrayList<>();
+ for (File f : fileSet) {
+ files.add(f.getAbsolutePath());
+ }
- mp.put(v, files);
+ mp.put(v, files);
+ }
+ return mp;
}
- return mp;
- }
- @Override
- public Map<SchemaVersion, List<String>> getEdgeFiles() {
- List<SchemaVersion> versionsToGen = new ArrayList<>();
- versionsToGen = schemaVersions.getVersions();
- Collections.sort(versionsToGen);
- Collections.reverse(versionsToGen);
- Map<SchemaVersion, List<String>> mp = new TreeMap<>();
- for (SchemaVersion v : versionsToGen) {
- File dir = new File(bean.getEdgeDirectory());
- File [] fileSet = dir.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.contains("_"+v.toString().toLowerCase());
+ @Override
+ public Map<SchemaVersion, List<String>> getEdgeFiles() {
+ List<SchemaVersion> versionsToGen = new ArrayList<>();
+ versionsToGen = schemaVersions.getVersions();
+ Collections.sort(versionsToGen);
+ Collections.reverse(versionsToGen);
+ Map<SchemaVersion, List<String>> mp = new TreeMap<>();
+ for (SchemaVersion v : versionsToGen) {
+ File dir = new File(bean.getEdgeDirectory());
+ File[] fileSet = dir.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.contains("_" + v.toString().toLowerCase());
+ }
+ });
+ List<String> files = new ArrayList<>();
+ for (File f : fileSet) {
+ files.add(f.getAbsolutePath());
+ }
+ mp.put(v, files);
}
- });
- List<String> files = new ArrayList<>();
- for(File f: fileSet ) {
- files.add(f.getAbsolutePath());
- }
- mp.put(v, files);
+ return mp;
}
- return mp;
- }
}
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSet.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSet.java
index a570d6f..969bdf9 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSet.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSet.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,41 +17,48 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
import java.util.Set;
import java.util.TreeSet;
public class DeleteFootnoteSet {
- protected Set<String> footnotes = new TreeSet<>();
- protected String targetNode = "<NodeType>";
- public DeleteFootnoteSet(String targetNode) {
- super();
- this.targetNode = targetNode == null ? "" : targetNode;
- }
+ protected Set<String> footnotes = new TreeSet<>();
+ protected String targetNode = "<NodeType>";
+
+ public DeleteFootnoteSet(String targetNode) {
+ super();
+ this.targetNode = targetNode == null ? "" : targetNode;
+ }
- public void add(String s ) {
- String fullnote=null;
- if("(1)".equals(s)) {
- fullnote = s+" IF this "+targetNode.toUpperCase()+" node is deleted, this FROM node is DELETED also";
- } else if("(2)".equals(s)) {
- fullnote = s+" IF this "+targetNode.toUpperCase()+" node is deleted, this TO node is DELETED also";
- } else if("(3)".equals(s)) {
- fullnote = s+" IF this FROM node is deleted, this "+targetNode.toUpperCase()+" is DELETED also";
- } else if("(4)".equals(s)) {
- fullnote = s+" IF this TO node is deleted, this "+targetNode.toUpperCase()+" is DELETED also";
- } else if(s.contains(targetNode.toUpperCase())) {
- fullnote = s;
- } else {
- return;
+ public void add(String s) {
+ String fullnote = null;
+ if ("(1)".equals(s)) {
+ fullnote = s + " IF this " + targetNode.toUpperCase()
+ + " node is deleted, this FROM node is DELETED also";
+ } else if ("(2)".equals(s)) {
+ fullnote = s + " IF this " + targetNode.toUpperCase()
+ + " node is deleted, this TO node is DELETED also";
+ } else if ("(3)".equals(s)) {
+ fullnote = s + " IF this FROM node is deleted, this " + targetNode.toUpperCase()
+ + " is DELETED also";
+ } else if ("(4)".equals(s)) {
+ fullnote = s + " IF this TO node is deleted, this " + targetNode.toUpperCase()
+ + " is DELETED also";
+ } else if (s.contains(targetNode.toUpperCase())) {
+ fullnote = s;
+ } else {
+ return;
+ }
+ footnotes.add(fullnote);
}
- footnotes.add(fullnote);
- }
- public String toString() {
- StringBuilder sb = new StringBuilder();
- if(footnotes.size() > 0) sb.append("\n -");
- sb.append(String.join("\n -", footnotes)+"\n");
- return sb.toString();
- }
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ if (footnotes.size() > 0)
+ sb.append("\n -");
+ sb.append(String.join("\n -", footnotes) + "\n");
+ return sb.toString();
+ }
}
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteOperation.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteOperation.java
index c59e8f0..8c7ecce 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteOperation.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteOperation.java
@@ -22,6 +22,7 @@ package org.onap.aai.schemagen.genxsd;
import java.util.HashMap;
import java.util.StringTokenizer;
+
import org.apache.commons.lang3.StringUtils;
import org.onap.aai.schemagen.GenerateXsd;
@@ -35,7 +36,7 @@ public class DeleteOperation {
public static HashMap<String, String> deletePaths = new HashMap<String, String>();
public DeleteOperation(String useOpId, String xmlRootElementName, String tag, String path,
- String pathParams) {
+ String pathParams) {
super();
this.useOpId = useOpId;
this.xmlRootElementName = xmlRootElementName;
@@ -48,7 +49,7 @@ public class DeleteOperation {
public String toString() {
StringTokenizer st;
st = new StringTokenizer(path, "/");
- //a valid tag is necessary
+ // a valid tag is necessary
if (StringUtils.isEmpty(tag)) {
return "";
}
@@ -61,9 +62,9 @@ public class DeleteOperation {
if (path.startsWith("/search")) {
return "";
}
- //All Delete operation paths end with "relationship"
- //or there is a parameter at the end of the path
- //and there is a parameter in the path
+ // All Delete operation paths end with "relationship"
+ // or there is a parameter at the end of the path
+ // and there is a parameter in the path
if (!path.endsWith("/relationship") && !path.endsWith("}")) {
return "";
@@ -72,8 +73,7 @@ public class DeleteOperation {
pathSb.append(" delete:\n");
pathSb.append(" tags:\n");
pathSb.append(" - ").append(tag).append("\n");
- pathSb.append(" summary: delete an existing ").append(xmlRootElementName)
- .append("\n");
+ pathSb.append(" summary: delete an existing ").append(xmlRootElementName).append("\n");
pathSb.append(" description: delete an existing ").append(xmlRootElementName)
.append("\n");
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/EdgeDescription.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/EdgeDescription.java
index 5bdb87e..585e14e 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/EdgeDescription.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/EdgeDescription.java
@@ -40,17 +40,17 @@ public class EdgeDescription {
public EdgeDescription(EdgeRule ed) {
super();
- if (ed.getDirection().toString().equals(ed.getContains()) &&
- AAIDirection.getValue("OUT").equals(AAIDirection.getValue(ed.getDirection()))) {
+ if (ed.getDirection().toString().equals(ed.getContains())
+ && AAIDirection.getValue("OUT").equals(AAIDirection.getValue(ed.getDirection()))) {
this.lineageType = LineageType.PARENT;
- } else if (AAIDirection.getValue("IN").equals(AAIDirection.getValue(ed.getContains())) &&
- ed.getDirection().toString().equals(ed.getContains())) {
+ } else if (AAIDirection.getValue("IN").equals(AAIDirection.getValue(ed.getContains()))
+ && ed.getDirection().toString().equals(ed.getContains())) {
this.lineageType = LineageType.CHILD;
- } else if (AAIDirection.getValue("OUT").equals(AAIDirection.getValue(ed.getContains())) &&
- AAIDirection.getValue("IN").equals(AAIDirection.getValue(ed.getDirection()))) {
+ } else if (AAIDirection.getValue("OUT").equals(AAIDirection.getValue(ed.getContains()))
+ && AAIDirection.getValue("IN").equals(AAIDirection.getValue(ed.getDirection()))) {
this.lineageType = LineageType.PARENT;
- } else if (AAIDirection.getValue("IN").equals(AAIDirection.getValue(ed.getContains())) &&
- AAIDirection.getValue("OUT").equals(AAIDirection.getValue(ed.getDirection()))) {
+ } else if (AAIDirection.getValue("IN").equals(AAIDirection.getValue(ed.getContains()))
+ && AAIDirection.getValue("OUT").equals(AAIDirection.getValue(ed.getDirection()))) {
this.lineageType = LineageType.PARENT;
} else {
this.lineageType = LineageType.UNRELATED;
@@ -153,21 +153,18 @@ public class EdgeDescription {
}
}
if (result.length() == 0) {
- result = String
- .join(" ", "(", ed.getFrom(), this.getShortLabel(), ed.getTo() + ",",
- this.getMultiplicity());
+ result = String.join(" ", "(", ed.getFrom(), this.getShortLabel(), ed.getTo() + ",",
+ this.getMultiplicity());
}
} else {
if (LineageType.PARENT == lineageType) {
result = " (PARENT of " + otherNodeName;
- result = String
- .join(" ", result + ",", ed.getFrom(), this.getShortLabel(), ed.getTo() + ",",
- this.getMultiplicity());
+ result = String.join(" ", result + ",", ed.getFrom(), this.getShortLabel(),
+ ed.getTo() + ",", this.getMultiplicity());
}
if (result.length() == 0) {
- result = String
- .join(" ", "(", ed.getFrom(), this.getShortLabel(), ed.getTo() + ",",
- this.getMultiplicity());
+ result = String.join(" ", "(", ed.getFrom(), this.getShortLabel(), ed.getTo() + ",",
+ this.getMultiplicity());
}
}
@@ -187,8 +184,8 @@ public class EdgeDescription {
*/
public boolean hasDelTarget() {
- return StringUtils.isNotEmpty(ed.getDeleteOtherV()) &&
- (!"NONE".equalsIgnoreCase(ed.getDeleteOtherV()));
+ return StringUtils.isNotEmpty(ed.getDeleteOtherV())
+ && (!"NONE".equalsIgnoreCase(ed.getDeleteOtherV()));
}
/**
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/GetOperation.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/GetOperation.java
index f9d1799..6228f86 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/GetOperation.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/GetOperation.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
+
import org.apache.commons.lang3.StringUtils;
import org.onap.aai.schemagen.GenerateXsd;
@@ -31,8 +32,7 @@ public class GetOperation {
static Map<String, Vector<String>> containers = new HashMap<String, Vector<String>>();
public static void addContainerProps(String container, Vector<String> containerProps) {
- containers.put(container, containerProps);
- ;
+ containers.put(container, containerProps);;
}
private String useOpId;
@@ -43,23 +43,23 @@ public class GetOperation {
private String queryParams;
public GetOperation(String useOpId, String xmlRootElementName, String tag, String path,
- String pathParams) {
+ String pathParams) {
super();
this.useOpId = useOpId;
this.xmlRootElementName = xmlRootElementName;
this.tag = tag;
this.path = path;
this.pathParams = pathParams;
-// StringBuilder p = new StringBuilder();
+ // StringBuilder p = new StringBuilder();
if (containers.get(xmlRootElementName) == null) {
this.queryParams = "";
} else {
this.queryParams = String.join("", containers.get(xmlRootElementName));
-// for(String param : containers.get(xmlRootElementName)) {
-// p.append(param);
-// }
-// this.queryParams = p.toString();
+ // for(String param : containers.get(xmlRootElementName)) {
+ // p.append(param);
+ // }
+ // this.queryParams = p.toString();
}
}
@@ -67,13 +67,13 @@ public class GetOperation {
public String toString() {
StringTokenizer st;
st = new StringTokenizer(path, "/");
- //Path has to be longer than one element
- /*
- if ( st.countTokens() <= 1) {
- return "";
- }
- */
- //a valid tag is necessary
+ // Path has to be longer than one element
+ /*
+ * if ( st.countTokens() <= 1) {
+ * return "";
+ * }
+ */
+ // a valid tag is necessary
if (StringUtils.isEmpty(tag)) {
return "";
}
@@ -116,9 +116,9 @@ public class GetOperation {
if (StringUtils.isNotEmpty(pathParams)) {
pathSb.append(pathParams);
}
-// if ( StringUtils.isNotEmpty(pathParams) && StringUtils.isNotEmpty(queryParams)) {
-// pathSb.append("\n");
-// }
+ // if ( StringUtils.isNotEmpty(pathParams) && StringUtils.isNotEmpty(queryParams)) {
+ // pathSb.append("\n");
+ // }
if (StringUtils.isNotEmpty(queryParams)) {
pathSb.append(queryParams);
}
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java
index 01598a0..980a3f3 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java
@@ -26,7 +26,9 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+
import javax.xml.parsers.ParserConfigurationException;
+
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.nodes.NodeIngestor;
@@ -47,7 +49,7 @@ public class HTMLfromOXM extends OxmFileProcessor {
private String maxOccurs;
public HTMLfromOXM(String maxOccurs, SchemaVersions schemaVersions, NodeIngestor ni,
- EdgeIngestor ei) {
+ EdgeIngestor ei) {
super(schemaVersions, ni, ei);
this.maxOccurs = maxOccurs;
}
@@ -67,7 +69,6 @@ public class HTMLfromOXM extends OxmFileProcessor {
this.v = v;
}
-
@Override
public String getDocumentHeader() {
StringBuilder sb = new StringBuilder();
@@ -86,15 +87,13 @@ public class HTMLfromOXM extends OxmFileProcessor {
.append(LINE_SEPARATOR).append("xmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\"")
.append(LINE_SEPARATOR).append(" jaxb:version=\"2.1\"").append(LINE_SEPARATOR)
.append(" xmlns:annox=\"http://annox.dev.java.net\"").append(LINE_SEPARATOR)
- .append(" jaxb:extensionBindingPrefixes=\"annox\">")
- .append(DOUBLE_LINE_SEPARATOR);
+ .append(" jaxb:extensionBindingPrefixes=\"annox\">").append(DOUBLE_LINE_SEPARATOR);
return sb.toString();
}
@Override
- public String process()
- throws ParserConfigurationException, SAXException, IOException, FileNotFoundException,
- EdgeRuleNotFoundException {
+ public String process() throws ParserConfigurationException, SAXException, IOException,
+ FileNotFoundException, EdgeRuleNotFoundException {
StringBuilder sb = new StringBuilder();
try {
@@ -119,7 +118,7 @@ public class HTMLfromOXM extends OxmFileProcessor {
elem = getJavaTypeElement(javaTypeName, false);
}
XSDElement javaTypeElement = new XSDElement(elem, maxOccurs);
- //javaTypeName = javaTypeElement.name();
+ // javaTypeName = javaTypeElement.name();
if (javaTypeName == null) {
String msg = "Invalid OXM file: <java-type> has no name attribute in " + oxmFile;
logger.error(msg);
@@ -129,8 +128,8 @@ public class HTMLfromOXM extends OxmFileProcessor {
logger.debug("skipping Nodes entry (temporary feature)");
continue;
}
- logger.debug(getXmlRootElementName(javaTypeName) + " vs " + javaTypeName + ":" +
- generatedJavaType.containsKey(getXmlRootElementName(javaTypeName)));
+ logger.debug(getXmlRootElementName(javaTypeName) + " vs " + javaTypeName + ":"
+ + generatedJavaType.containsKey(getXmlRootElementName(javaTypeName)));
if (!"Inventory".equals(javaTypeName)) {
generatedJavaType.put(javaTypeName, null);
@@ -154,15 +153,14 @@ public class HTMLfromOXM extends OxmFileProcessor {
}
protected boolean skipCheck(String javaAttribute) {
- if (javaAttribute.equals("model")
- || javaAttribute.equals("eventHeader")) {
+ if (javaAttribute.equals("model") || javaAttribute.equals("eventHeader")) {
return true;
}
return false;
}
public String processJavaTypeElement(String javaTypeName, Element javaType_Element,
- StringBuilder sbInventory) {
+ StringBuilder sbInventory) {
String xmlRootElementName = getXMLRootElementName(javaType_Element);
NodeList parentNodes = javaType_Element.getElementsByTagName("java-attributes");
@@ -203,13 +201,14 @@ public class HTMLfromOXM extends OxmFileProcessor {
XSDElement xmlElementElement =
new XSDElement((Element) xmlElementNodes.item(i), maxOccurs);
-// String elementName = xmlElementElement.getAttribute("name");
+ // String elementName = xmlElementElement.getAttribute("name");
String elementType = xmlElementElement.getAttribute("type");
- //No simple types; only AAI custom types
- String addType = elementType.contains("." + v.toString() + ".") ?
- elementType.substring(elementType.lastIndexOf('.') + 1) : null;
- if (elementType.contains("." + v.toString() + ".") &&
- !generatedJavaType.containsKey(addType)) {
+ // No simple types; only AAI custom types
+ String addType = elementType.contains("." + v.toString() + ".")
+ ? elementType.substring(elementType.lastIndexOf('.') + 1)
+ : null;
+ if (elementType.contains("." + v.toString() + ".")
+ && !generatedJavaType.containsKey(addType)) {
generatedJavaType.put(addType, elementType);
javatypeElement = getJavaTypeElement(addType, processingInventory);
sb.append(processJavaTypeElement(addType, javatypeElement, null));
@@ -218,7 +217,7 @@ public class HTMLfromOXM extends OxmFileProcessor {
logger.trace("Skipping nodes, temporary testing");
continue;
}
- //assembles the basic <element>
+ // assembles the basic <element>
sb1.append(xmlElementElement.getHTMLElement(v, true, this));
}
if (!processingInventory) {
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodeGetOperation.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodeGetOperation.java
index bdfdfd6..24c34d9 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodeGetOperation.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodeGetOperation.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
+
import org.apache.commons.lang3.StringUtils;
import org.onap.aai.schemagen.GenerateXsd;
@@ -55,7 +56,7 @@ public class NodeGetOperation {
private String queryParams;
public NodeGetOperation(String useOpId, String xmlRootElementName, String tag, String path,
- String pathParams) {
+ String pathParams) {
super();
this.useOpId = useOpId;
this.xmlRootElementName = xmlRootElementName;
@@ -89,13 +90,13 @@ public class NodeGetOperation {
public String toString() {
StringTokenizer st;
st = new StringTokenizer(CRUDpath, "/");
- //Path has to be longer than one element
- /*
- if ( st.countTokens() <= 1) {
- return "";
- }
- */
- //a valid tag is necessary
+ // Path has to be longer than one element
+ /*
+ * if ( st.countTokens() <= 1) {
+ * return "";
+ * }
+ */
+ // a valid tag is necessary
if (StringUtils.isEmpty(tag)) {
return "";
}
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java
index c42aaed..8bceb5c 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java
@@ -21,6 +21,7 @@
package org.onap.aai.schemagen.genxsd;
import com.google.common.collect.Multimap;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
@@ -39,7 +40,9 @@ import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
+
import javax.xml.parsers.ParserConfigurationException;
+
import org.apache.commons.lang3.StringUtils;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
@@ -69,7 +72,7 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
private final String basePath;
public NodesYAMLfromOXM(String basePath, SchemaVersions schemaVersions, NodeIngestor ni,
- EdgeIngestor ei) {
+ EdgeIngestor ei) {
super(schemaVersions, ni, ei);
this.basePath = basePath;
}
@@ -95,14 +98,18 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
sb.append("\n\n [Differences versus the previous schema version](" + "apidocs")
.append(basePath).append("/aai_swagger_").append(v.toString()).append(".diff)");
}
- sb.append(DOUBLE_LINE_SEPARATOR).append(
- " Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved.")
- .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR).append(
- " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License.")
- .append(DOUBLE_LINE_SEPARATOR).append(
- " You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)")
- .append(DOUBLE_LINE_SEPARATOR).append(
- " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.")
+ sb.append(DOUBLE_LINE_SEPARATOR)
+ .append(
+ " Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved.")
+ .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR)
+ .append(
+ " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License.")
+ .append(DOUBLE_LINE_SEPARATOR)
+ .append(
+ " You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)")
+ .append(DOUBLE_LINE_SEPARATOR)
+ .append(
+ " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.")
.append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR)
.append(" This document is best viewed with Firefox or Chrome. ");
sb.append(
@@ -201,9 +208,8 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
if (namespaceFilter != null && (!namespaceFilter.contains(entry.getKey()))) {
continue;
}
- logger.debug(
- "Key: " + entry.getKey() + "Test: " +
- ("relationship-dict".equals(entry.getKey()) ? "true" : "false"));
+ logger.debug("Key: " + entry.getKey() + "Test: "
+ + ("relationship-dict".equals(entry.getKey()) ? "true" : "false"));
if (entry.getKey().matches("relationship-dict")) {
String jb = entry.getValue();
logger.debug("Value: " + jb);
@@ -235,8 +241,7 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
return dictSb.toString();
}
- private String processJavaTypeElementSwagger(
- String javaTypeName, Element javaTypeElement,
+ private String processJavaTypeElementSwagger(String javaTypeName, Element javaTypeElement,
StringBuilder pathSb, StringBuilder definitionsSb, String path, String tag, String opId,
String getItemName, StringBuilder pathParams, String validEdges) {
@@ -650,18 +655,16 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
private void writeYAMLfile(String outfileName, String fileContent) {
outfileName = (StringUtils.isEmpty(outfileName)) ? "aai_swagger" : outfileName;
- outfileName = (outfileName.lastIndexOf(File.separator) == -1)
- ? YAML_DIR + File.separator + outfileName + "_" + v.toString() + "." +
- GENERATE_TYPE_YAML
- : outfileName;
+ outfileName = (outfileName.lastIndexOf(File.separator) == -1) ? YAML_DIR + File.separator
+ + outfileName + "_" + v.toString() + "." + GENERATE_TYPE_YAML : outfileName;
File outfile = new File(outfileName);
File parentDir = outfile.getParentFile();
if (parentDir != null && !parentDir.exists()) {
parentDir.mkdirs();
}
try {
- if(!outfile.createNewFile()) {
- logger.error( "File {} already exist", outfileName);
+ if (!outfile.createNewFile()) {
+ logger.error("File {} already exist", outfileName);
}
} catch (IOException e) {
logger.error("Exception creating output file " + outfileName, e);
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/OxmFileProcessor.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/OxmFileProcessor.java
index 224192a..fde0877 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/OxmFileProcessor.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/OxmFileProcessor.java
@@ -24,6 +24,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
+import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -31,10 +32,12 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.nodes.NodeIngestor;
@@ -49,16 +52,6 @@ import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.*;
-
public abstract class OxmFileProcessor {
public static final String LINE_SEPARATOR = System.getProperty("line.separator");
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PatchOperation.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PatchOperation.java
index b52e34b..652117d 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PatchOperation.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PatchOperation.java
@@ -21,6 +21,7 @@
package org.onap.aai.schemagen.genxsd;
import java.util.StringTokenizer;
+
import org.apache.commons.lang3.StringUtils;
import org.onap.aai.schemagen.GenerateXsd;
import org.onap.aai.setup.SchemaVersion;
@@ -36,7 +37,7 @@ public class PatchOperation {
private String basePath;
public PatchOperation(String useOpId, String xmlRootElementName, String tag, String path,
- String pathParams, SchemaVersion v, String basePath) {
+ String pathParams, SchemaVersion v, String basePath) {
super();
this.useOpId = useOpId;
this.xmlRootElementName = xmlRootElementName;
@@ -55,7 +56,7 @@ public class PatchOperation {
public String toString() {
StringTokenizer st;
st = new StringTokenizer(path, "/");
- //a valid tag is necessary
+ // a valid tag is necessary
if (StringUtils.isEmpty(tag)) {
return "";
}
@@ -68,7 +69,7 @@ public class PatchOperation {
if (path.startsWith("/search")) {
return "";
}
- //No Patch operation paths end with "relationship"
+ // No Patch operation paths end with "relationship"
if (path.endsWith("/relationship")) {
return "";
@@ -95,8 +96,7 @@ public class PatchOperation {
pathSb.append(" summary: update an existing ").append(xmlRootElementName)
.append("\n");
pathSb.append(" description: |\n");
- pathSb.append(" Update an existing ").append(xmlRootElementName)
- .append("\n");
+ pathSb.append(" Update an existing ").append(xmlRootElementName).append("\n");
pathSb.append(" #\n");
pathSb.append(
" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
@@ -126,8 +126,8 @@ public class PatchOperation {
pathSb.append(" - name: body\n");
pathSb.append(" in: body\n");
pathSb.append(" description: ").append(xmlRootElementName)
- .append(" object that needs to be updated.")
- .append(relationshipExamplesSb.toString()).append("\n");
+ .append(" object that needs to be updated.").append(relationshipExamplesSb.toString())
+ .append("\n");
pathSb.append(" required: true\n");
pathSb.append(" schema:\n");
pathSb.append(" $ref: \"#/definitions/").append(prefixForPatch)
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutOperation.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutOperation.java
index d1e7ca5..a4c6a51 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutOperation.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutOperation.java
@@ -37,7 +37,7 @@ public class PutOperation {
private String basePath;
public PutOperation(String useOpId, String xmlRootElementName, String tag, String path,
- String pathParams, SchemaVersion v, String basePath) {
+ String pathParams, SchemaVersion v, String basePath) {
super();
this.useOpId = useOpId;
this.xmlRootElementName = xmlRootElementName;
@@ -50,13 +50,13 @@ public class PutOperation {
@Override
public String toString() {
- //a valid tag is necessary
+ // a valid tag is necessary
if (StringUtils.isEmpty(tag)) {
return "";
}
- //All Put operation paths end with "relationship"
- //or there is a parameter at the end of the path
- //and there is a parameter in the path
+ // All Put operation paths end with "relationship"
+ // or there is a parameter at the end of the path
+ // and there is a parameter in the path
if (path.contains("/" + RELATIONSHIP + "/")) { // filter paths with relationship-list
return "";
}
@@ -81,11 +81,11 @@ public class PutOperation {
if (path.endsWith("/" + RELATIONSHIP)) {
pathSb.append(" summary: see node definition for valid relationships\n");
} else {
- pathSb.append(" summary: create or update an existing ")
- .append(xmlRootElementName).append("\n");
+ pathSb.append(" summary: create or update an existing ").append(xmlRootElementName)
+ .append("\n");
pathSb.append(" description: |\n Create or update an existing ")
.append(xmlRootElementName).append(
- ".\n #\n Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n");
+ ".\n #\n Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n");
}
relationshipExamplesSb.append("[Valid relationship examples shown here](apidocs")
.append(basePath).append("/relations/").append(version.toString()).append("/")
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutRelationPathSet.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutRelationPathSet.java
index 43abb1e..fff28fc 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutRelationPathSet.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/PutRelationPathSet.java
@@ -21,6 +21,7 @@
package org.onap.aai.schemagen.genxsd;
import com.google.common.collect.Multimap;
+
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
@@ -28,6 +29,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
+
import org.apache.commons.text.similarity.LevenshteinDistance;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
@@ -61,9 +63,8 @@ public class PutRelationPathSet {
this.opId = opId;
this.version = v;
objectName = DeleteOperation.deletePaths.get(apiPath);
- logger.debug(
- "II-apiPath: " + apiPath + "\nPath: " + path + "\nopId=" + opId + "\nobjectName=" +
- objectName);
+ logger.debug("II-apiPath: " + apiPath + "\nPath: " + path + "\nopId=" + opId
+ + "\nobjectName=" + objectName);
}
private void process(EdgeIngestor edgeIngestor) {
@@ -140,15 +141,15 @@ public class PutRelationPathSet {
}
private void writeRelationsFile() {
- File examplefilePath = new File(
- GenerateXsd.getYamlDir() + "/relations/" + version.toString() + "/" +
- opId.replace("RelationshipListRelationship", "") + ".json");
+ File examplefilePath =
+ new File(GenerateXsd.getYamlDir() + "/relations/" + version.toString() + "/"
+ + opId.replace("RelationshipListRelationship", "") + ".json");
logger.debug(String.join("exampleFilePath: ", examplefilePath.toString()));
try {
if (!examplefilePath.exists()) {
examplefilePath.getParentFile().mkdirs();
- if(!examplefilePath.createNewFile()) {
+ if (!examplefilePath.createNewFile()) {
logger.debug("examplefilePath create file error");
}
}
@@ -199,12 +200,14 @@ public class PutRelationPathSet {
int targetMaxScore = 0;
for (Map.Entry<String, String> p : DeleteOperation.deletePaths.entrySet()) {
if (p.getValue().equals(obj)) {
- targetScore = (targetScore >= proximity.apply(apiPath, p.getKey())) ?
- proximity.apply(apiPath, p.getKey()) : targetScore;
+ targetScore = (targetScore >= proximity.apply(apiPath, p.getKey()))
+ ? proximity.apply(apiPath, p.getKey())
+ : targetScore;
targetPath =
(targetScore >= proximity.apply(apiPath, p.getKey())) ? p.getKey() : targetPath;
- targetMaxScore = (targetMaxScore <= proximity.apply(apiPath, p.getKey())) ?
- proximity.apply(apiPath, p.getKey()) : targetScore;
+ targetMaxScore = (targetMaxScore <= proximity.apply(apiPath, p.getKey()))
+ ? proximity.apply(apiPath, p.getKey())
+ : targetScore;
logger.trace(proximity.apply(apiPath, p.getKey()) + ":" + p.getKey());
logger.trace(proximity.apply(apiPath, p.getKey()) + ":" + apiPath);
}
@@ -238,4 +241,3 @@ public class PutRelationPathSet {
}
}
-
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java
index bbdcd70..205d16c 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java
@@ -21,10 +21,12 @@
package org.onap.aai.schemagen.genxsd;
import com.google.common.base.Joiner;
+
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
+
import org.apache.commons.lang3.StringUtils;
import org.onap.aai.setup.SchemaVersion;
import org.w3c.dom.Attr;
@@ -131,9 +133,9 @@ public class XSDElement implements Element {
.equals(this.xmlElementElement.getAttribute("name"))) {
continue;
}
-// This stopped working, replaced with above - should figure out why...
-// if ( !xmlPropElement.getParentNode().isSameNode(this.xmlElementElement))
-// continue;
+ // This stopped working, replaced with above - should figure out why...
+ // if ( !xmlPropElement.getParentNode().isSameNode(this.xmlElementElement))
+ // continue;
NodeList childNodes = xmlPropElement.getElementsByTagName("xml-property");
for (int j = 0; j < childNodes.getLength(); ++j) {
@@ -158,7 +160,7 @@ public class XSDElement implements Element {
}
}
if (pathDescriptionProperty != null) {
- //suppress non-printable characters in a description
+ // suppress non-printable characters in a description
String replaceDescription = pathDescriptionProperty.replaceAll("[^\\p{ASCII}]", "");
return replaceDescription;
}
@@ -189,8 +191,8 @@ public class XSDElement implements Element {
}
if (needValue == VALUE_INDEXED_PROPS && attrValue.equals("indexedProps")) {
useValue = VALUE_INDEXED_PROPS;
- } else if (needValue == VALUE_DSLSTARTNODE &&
- attrValue.equals("dslStartNodeProps")) {
+ } else if (needValue == VALUE_DSLSTARTNODE
+ && attrValue.equals("dslStartNodeProps")) {
useValue = VALUE_DSLSTARTNODE;
}
if (useValue != VALUE_NONE && attrName.equals("value")) {
@@ -262,8 +264,8 @@ public class XSDElement implements Element {
StringBuilder sbParameter = new StringBuilder();
sbParameter.append(" - name: ").append(this.getAttribute("name")).append("\n");
sbParameter.append((" in: query\n"));
- if (this.getAttribute("description") != null &&
- this.getAttribute("description").length() > 0) {
+ if (this.getAttribute("description") != null
+ && this.getAttribute("description").length() > 0) {
sbParameter.append(" description: ").append(this.getAttribute("description"))
.append("\n");
} else {
@@ -330,8 +332,9 @@ public class XSDElement implements Element {
String elementType = this.getAttribute("type");
String elementContainerType = this.getAttribute("container-type");
String elementIsRequired = this.getAttribute("required");
- String addType = elementType.contains("." + v.toString() + ".") ?
- elementType.substring(elementType.lastIndexOf('.') + 1) : null;
+ String addType = elementType.contains("." + v.toString() + ".")
+ ? elementType.substring(elementType.lastIndexOf('.') + 1)
+ : null;
if (addType != null) {
sbElement.append(" <xs:element ref=\"tns:")
@@ -363,18 +366,18 @@ public class XSDElement implements Element {
sbElement.append(
StringUtils.isNotEmpty(annotation) ? ">" + OxmFileProcessor.LINE_SEPARATOR : "");
sbElement.append(annotation);
- sbElement.append(StringUtils.isNotEmpty(annotation) ?
- " </xs:element>" + OxmFileProcessor.LINE_SEPARATOR :
- "/>" + OxmFileProcessor.LINE_SEPARATOR);
+ sbElement.append(StringUtils.isNotEmpty(annotation)
+ ? " </xs:element>" + OxmFileProcessor.LINE_SEPARATOR
+ : "/>" + OxmFileProcessor.LINE_SEPARATOR);
} else {
sbElement.append("/>").append(OxmFileProcessor.LINE_SEPARATOR);
}
return this.getHTMLElementWrapper(sbElement.toString(), v, useAnnotation);
-// return sbElement.toString();
+ // return sbElement.toString();
}
public String getHTMLElementWrapper(String unwrappedElement, SchemaVersion v,
- boolean useAnnotation) {
+ boolean useAnnotation) {
NodeList childNodes = this.getElementsByTagName("xml-element-wrapper");
@@ -392,8 +395,9 @@ public class XSDElement implements Element {
sbElement.append(" <xs:element name=\"").append(xmlElementWrapper).append("\"");
String elementType = xmlElementElement.getAttribute("type");
String elementIsRequired = this.getAttribute("required");
- String addType = elementType.contains("." + v.toString() + ".") ?
- elementType.substring(elementType.lastIndexOf('.') + 1) : null;
+ String addType = elementType.contains("." + v.toString() + ".")
+ ? elementType.substring(elementType.lastIndexOf('.') + 1)
+ : null;
if (elementIsRequired == null || !elementIsRequired.equals("true") || addType != null) {
sbElement.append(" minOccurs=\"0\"");
@@ -799,5 +803,4 @@ public class XSDElement implements Element {
xmlElementElement.setIdAttributeNode(idAttr, isId);
}
-
}
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDJavaType.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDJavaType.java
index ee776b2..d8864f5 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDJavaType.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDJavaType.java
@@ -30,14 +30,15 @@ public class XSDJavaType extends XSDElement {
}
/*
- public XSDJavaType(XSDElement javaTypeElement, StringBuffer pathSb, StringBuffer definitionsSb,
- StringBuffer pathParams) {
- super(javaTypeElement);
- this.pathSb = pathSb;
- this.definitionsSb = definitionsSb;
- this.pathParams = pathParams;
- }
- */
+ * public XSDJavaType(XSDElement javaTypeElement, StringBuffer pathSb, StringBuffer
+ * definitionsSb,
+ * StringBuffer pathParams) {
+ * super(javaTypeElement);
+ * this.pathSb = pathSb;
+ * this.definitionsSb = definitionsSb;
+ * this.pathParams = pathParams;
+ * }
+ */
public String getItemName() {
NodeList parentNodes = this.getElementsByTagName("java-attributes");
if (parentNodes.getLength() == 0) {
@@ -57,8 +58,8 @@ public class XSDJavaType extends XSDElement {
Element parentElement = (Element) parentNodes.item(0);
NodeList xmlElementNodes = parentElement.getElementsByTagName("xml-element");
XSDElement xmlElementElement = new XSDElement((Element) xmlElementNodes.item(0));
- if (xmlElementElement.hasAttribute("container-type") &&
- xmlElementElement.getAttribute("container-type").equals("java.util.ArrayList")) {
+ if (xmlElementElement.hasAttribute("container-type")
+ && xmlElementElement.getAttribute("container-type").equals("java.util.ArrayList")) {
return xmlElementElement.getAttribute("name");
}
return null;
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java
index 849b40c..ff6f7dd 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java
@@ -22,6 +22,7 @@ package org.onap.aai.schemagen.genxsd;
import com.google.common.base.CharMatcher;
import com.google.common.collect.Multimap;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
@@ -40,7 +41,9 @@ import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
+
import javax.xml.parsers.ParserConfigurationException;
+
import org.apache.commons.lang3.StringUtils;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
@@ -71,7 +74,7 @@ public class YAMLfromOXM extends OxmFileProcessor {
private String basePath;
public YAMLfromOXM(String basePath, SchemaVersions schemaVersions, NodeIngestor ni,
- EdgeIngestor ei) {
+ EdgeIngestor ei) {
super(schemaVersions, ni, ei);
this.basePath = basePath;
}
@@ -94,17 +97,21 @@ public class YAMLfromOXM extends OxmFileProcessor {
sb.append("swagger: \"2.0\"\ninfo:").append(LINE_SEPARATOR).append(" ");
sb.append("description: |");
if (versionSupportsSwaggerDiff(v.toString())) {
- sb.append("\n\n [Differences versus the previous schema version]("
- + "apidocs" + basePath + "/aai_swagger_" + v.toString() + ".diff)");
+ sb.append("\n\n [Differences versus the previous schema version](" + "apidocs"
+ + basePath + "/aai_swagger_" + v.toString() + ".diff)");
}
- sb.append(DOUBLE_LINE_SEPARATOR).append(
- " Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved.")
- .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR).append(
- " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License.")
- .append(DOUBLE_LINE_SEPARATOR).append(
- " You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)")
- .append(DOUBLE_LINE_SEPARATOR).append(
- " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.")
+ sb.append(DOUBLE_LINE_SEPARATOR)
+ .append(
+ " Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved.")
+ .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR)
+ .append(
+ " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License.")
+ .append(DOUBLE_LINE_SEPARATOR)
+ .append(
+ " You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)")
+ .append(DOUBLE_LINE_SEPARATOR)
+ .append(
+ " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.")
.append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR)
.append(" This document is best viewed with Firefox or Chrome. ");
sb.append(
@@ -112,8 +119,9 @@ public class YAMLfromOXM extends OxmFileProcessor {
sb.append("Edge definitions can be found with the node definitions.").append(LINE_SEPARATOR)
.append(" version: \"").append(v.toString()).append("\"").append(LINE_SEPARATOR);
sb.append(" title: Active and Available Inventory REST API").append(LINE_SEPARATOR);
- sb.append(" license:").append(LINE_SEPARATOR).append(
- " name: Apache 2.0\n url: http://www.apache.org/licenses/LICENSE-2.0.html")
+ sb.append(" license:").append(LINE_SEPARATOR)
+ .append(
+ " name: Apache 2.0\n url: http://www.apache.org/licenses/LICENSE-2.0.html")
.append(LINE_SEPARATOR);
sb.append(" contact:").append(LINE_SEPARATOR).append(" name: n/a")
.append(LINE_SEPARATOR).append(" url: n/a").append(LINE_SEPARATOR)
@@ -238,9 +246,8 @@ public class YAMLfromOXM extends OxmFileProcessor {
return dictSb.toString();
}
- private String processJavaTypeElementSwagger(
- String javaTypeName, Element javaTypeElement, StringBuilder pathSb,
- StringBuilder definitionsSb, String path, String tag, String opId,
+ private String processJavaTypeElementSwagger(String javaTypeName, Element javaTypeElement,
+ StringBuilder pathSb, StringBuilder definitionsSb, String path, String tag, String opId,
String getItemName, StringBuilder pathParams, String validEdges) {
String xmlRootElementName = getXMLRootElementName(javaTypeElement);
@@ -302,8 +309,9 @@ public class YAMLfromOXM extends OxmFileProcessor {
NodeList xmlElementNodes = parentElement.getElementsByTagName("xml-element");
StringBuilder sbParameters = new StringBuilder();
- StringBuilder sbPathParameters =
- new StringBuilder(); // separate naming path parameters from name of parameter in the schema
+ StringBuilder sbPathParameters = new StringBuilder(); // separate naming path parameters
+ // from name of parameter in the
+ // schema
StringBuilder sbRequired = new StringBuilder();
int requiredCnt = 0;
@@ -339,8 +347,8 @@ public class YAMLfromOXM extends OxmFileProcessor {
// use alternate name for parameter if already in the path string
modifiedName = "/{" + xmlElementElement.getAttribute("name") + "}";
if (path.contains(modifiedName)) {
- modifiedName = path.substring(path.lastIndexOf('/') + 1) + "." +
- xmlElementElement.getAttribute("name");
+ modifiedName = path.substring(path.lastIndexOf('/') + 1) + "."
+ + xmlElementElement.getAttribute("name");
} else {
modifiedName = xmlElementElement.getAttribute("name");
}
@@ -443,9 +451,8 @@ public class YAMLfromOXM extends OxmFileProcessor {
.equals(xmlElementElement.getAttribute("container-type"))) {
// need properties for getXmlRootElementName(addType)
namespaceFilter.add(getXmlRootElementName(addType));
- newPathParams =
- new StringBuilder((pathParams == null ? "" : pathParams.toString())
- + sbParameters);
+ newPathParams = new StringBuilder(
+ (pathParams == null ? "" : pathParams.toString()) + sbParameters);
processJavaTypeElementSwagger(addType, getJavaTypeElementSwagger(addType),
pathSb, definitionsSb, path, tag == null ? useTag : tag, useOpId, null,
newPathParams, validEdges);
@@ -644,8 +651,8 @@ public class YAMLfromOXM extends OxmFileProcessor {
if (patchPropertyCnt > 0) {
definitionsLocalPatchSb.append(" " + patchDefinePrefix).append(xmlRootElementName)
.append(":\n");
- if (StringUtils.isNotEmpty(pathDescriptionProperty) ||
- StringUtils.isNotEmpty(validEdges)) {
+ if (StringUtils.isNotEmpty(pathDescriptionProperty)
+ || StringUtils.isNotEmpty(validEdges)) {
definitionsLocalPatchSb.append(" description: |\n");
}
if (pathDescriptionProperty != null) {
@@ -721,8 +728,8 @@ public class YAMLfromOXM extends OxmFileProcessor {
parentDir.mkdirs();
}
try {
- if(!outfile.createNewFile()) {
- logger.error( "File {} already exist", outfileName);
+ if (!outfile.createNewFile()) {
+ logger.error("File {} already exist", outfileName);
}
} catch (IOException e) {
logger.error("Exception creating output file " + outfileName, e);
@@ -747,4 +754,3 @@ public class YAMLfromOXM extends OxmFileProcessor {
}
}
-
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/Api.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/Api.java
index a3adcd8..1dad255 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/Api.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/Api.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.swagger;
import java.util.List;
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/Definition.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/Definition.java
index 9df9842..8919857 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/Definition.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/Definition.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
+
package org.onap.aai.schemagen.swagger;
import java.util.List;
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java
index 6663dc4..39b1e83 100644
--- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java
+++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,75 +17,80 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.swagger;
import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml;
import com.fasterxml.jackson.dataformat.yaml.snakeyaml.constructor.SafeConstructor;
+
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
-import org.onap.aai.setup.SchemaVersions;
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
+import org.onap.aai.setup.SchemaVersions;
+
public class GenerateSwagger {
public static final String LINE_SEPARATOR = System.getProperty("line.separator");
public static final String DEFAULT_WIKI = "";
public static final String DEFAULT_SCHEMA_DIR = "../aai-schema";
- //if the program is run from aai-common, use this directory as default"
+ // if the program is run from aai-common, use this directory as default"
public static final String ALT_SCHEMA_DIR = "aai-schema";
- //used to check to see if program is run from aai-schema-gen
+ // used to check to see if program is run from aai-schema-gen
public static final String DEFAULT_RUN_DIR = "aai-schema-gen";
- public static SchemaVersions schemaVersions;
+ public static SchemaVersions schemaVersions;
public SchemaVersions getSchemaVersions() {
- return schemaVersions;
- }
-
-
-
- public static void main(String[] args) throws IOException, TemplateException {
-
-
+ return schemaVersions;
+ }
+ public static void main(String[] args) throws IOException, TemplateException {
- // SchemaVersions schemaVersions = SpringContextAware.getBean(SchemaVersions.class);
- String CURRENT_VERSION = schemaVersions.getDefaultVersion().toString();
- String schemaDir = System.getProperty("aai.schema.dir");
+ // SchemaVersions schemaVersions = SpringContextAware.getBean(SchemaVersions.class);
+ String CURRENT_VERSION = schemaVersions.getDefaultVersion().toString();
+ String schemaDir = System.getProperty("aai.schema.dir");
String versionToGenerate = System.getProperty("aai.generate.version");
String wikiLink = System.getProperty("aai.wiki.link");
- String release = System.getProperty("aai.release", "onap");
-
- if(schemaDir == null){
- if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) {
- System.out.println("Warning: Schema directory is not set so using default schema dir: " + ALT_SCHEMA_DIR);
- schemaDir = ALT_SCHEMA_DIR;
- }
- else {
- System.out.println("Warning: Schema directory is not set so using default schema dir: " + DEFAULT_SCHEMA_DIR);
- schemaDir = DEFAULT_SCHEMA_DIR;
- }
+ String release = System.getProperty("aai.release", "onap");
+
+ if (schemaDir == null) {
+ if (System.getProperty("user.dir") != null
+ && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) {
+ System.out
+ .println("Warning: Schema directory is not set so using default schema dir: "
+ + ALT_SCHEMA_DIR);
+ schemaDir = ALT_SCHEMA_DIR;
+ } else {
+ System.out
+ .println("Warning: Schema directory is not set so using default schema dir: "
+ + DEFAULT_SCHEMA_DIR);
+ schemaDir = DEFAULT_SCHEMA_DIR;
+ }
}
- if(versionToGenerate == null){
- System.out.println("Warning: Version to generate is not set so using default versionToGenerate " + CURRENT_VERSION);
+ if (versionToGenerate == null) {
+ System.out.println(
+ "Warning: Version to generate is not set so using default versionToGenerate "
+ + CURRENT_VERSION);
versionToGenerate = CURRENT_VERSION;
}
- if(wikiLink == null){
+ if (wikiLink == null) {
System.out.println("Warning: aai.wiki.link property is not set so using default");
wikiLink = DEFAULT_WIKI;
}
- String yamlFile = schemaDir + "/src/main/resources/" + release + "/aai_swagger_yaml/aai_swagger_" + versionToGenerate + ".yaml";
+ String yamlFile = schemaDir + "/src/main/resources/" + release
+ + "/aai_swagger_yaml/aai_swagger_" + versionToGenerate + ".yaml";
File swaggerYamlFile = new File(yamlFile);
- if(!swaggerYamlFile.exists()){
+ if (!swaggerYamlFile.exists()) {
System.err.println("Unable to find the swagger yaml file: " + swaggerYamlFile);
System.exit(1);
}
@@ -93,21 +98,23 @@ public class GenerateSwagger {
Yaml yaml = new Yaml(new SafeConstructor());
Map<String, Object> swaggerMap = null;
- try (BufferedReader reader = new BufferedReader(new FileReader(swaggerYamlFile))){
+ try (BufferedReader reader = new BufferedReader(new FileReader(swaggerYamlFile))) {
swaggerMap = (Map<String, Object>) yaml.load(reader);
- } catch(Exception ex){
- System.err.println("Unable load yaml file: " + swaggerYamlFile + " : " + ex.getMessage());
+ } catch (Exception ex) {
+ System.err
+ .println("Unable load yaml file: " + swaggerYamlFile + " : " + ex.getMessage());
throw new IOException();
}
Map<String, Object> map = (Map<String, Object>) swaggerMap.get("paths");
- Map<String, Object> schemaDefinitionmap = (Map<String, Object>) swaggerMap.get("definitions");
+ Map<String, Object> schemaDefinitionmap =
+ (Map<String, Object>) swaggerMap.get("definitions");
Map<String, Object> infoMap = (Map<String, Object>) swaggerMap.get("info");
Map<String, List<Api>> tagMap = new LinkedHashMap<>();
List<Api> apis = convertToApi(map);
apis.forEach((api) -> {
- if(!tagMap.containsKey(api.getTag())){
+ if (!tagMap.containsKey(api.getTag())) {
List<Api> newApis = new ArrayList<>();
newApis.add(api);
tagMap.put(api.getTag(), newApis);
@@ -125,8 +132,9 @@ public class GenerateSwagger {
List<Definition> definitionList = convertToDefinition(schemaDefinitionmap);
- definitionList = definitionList
- .stream().sorted(Comparator.comparing(Definition::getDefinitionName)).collect(Collectors.toList());
+ definitionList =
+ definitionList.stream().sorted(Comparator.comparing(Definition::getDefinitionName))
+ .collect(Collectors.toList());
resultMap.put("aaiApis", tagMap);
resultMap.put("sortedAaiApis", sortedTagMap);
@@ -136,23 +144,22 @@ public class GenerateSwagger {
if (infoMap.containsKey("description")) {
String infoDescription = infoMap.get("description").toString();
- infoDescription = Arrays.stream(infoDescription.split("\n"))
- .map(line -> {
- line = line.trim();
- String hyperLink = "";
- if(line.trim().contains("Differences versus")) {
- return "";
- }
- if(line.trim().contains("https://")){
- int startIndex = line.indexOf("https://");
- int endIndex = line.lastIndexOf("/");
- hyperLink = line.substring(startIndex, endIndex);
- return String.format("<a href=\"%s\">%s</a><br/>", hyperLink, line);
- }
- return String.format("%s<br/>", line);
- })
+ infoDescription = Arrays.stream(infoDescription.split("\n")).map(line -> {
+ line = line.trim();
+ String hyperLink = "";
+ if (line.trim().contains("Differences versus")) {
+ return "";
+ }
+ if (line.trim().contains("https://")) {
+ int startIndex = line.indexOf("https://");
+ int endIndex = line.lastIndexOf("/");
+ hyperLink = line.substring(startIndex, endIndex);
+ return String.format("<a href=\"%s\">%s</a><br/>", hyperLink, line);
+ }
+ return String.format("%s<br/>", line);
+ })
- .collect(Collectors.joining(LINE_SEPARATOR));
+ .collect(Collectors.joining(LINE_SEPARATOR));
resultMap.put("description", infoDescription);
}
@@ -160,11 +167,12 @@ public class GenerateSwagger {
Configuration configuration = new Configuration();
configuration.setClassForTemplateLoading(Api.class, "/");
String resourcePath = "src/main/resources";
- if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) {
- configuration.setDirectoryForTemplateLoading(new File(DEFAULT_RUN_DIR + "/" + resourcePath));
- }
- else {
- configuration.setDirectoryForTemplateLoading(new File(resourcePath));
+ if (System.getProperty("user.dir") != null
+ && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) {
+ configuration
+ .setDirectoryForTemplateLoading(new File(DEFAULT_RUN_DIR + "/" + resourcePath));
+ } else {
+ configuration.setDirectoryForTemplateLoading(new File(resourcePath));
}
Template template = configuration.getTemplate("swagger.html.ftl");
@@ -172,29 +180,31 @@ public class GenerateSwagger {
File outputDir = new File(outputDirStr);
- if(!outputDir.exists()){
+ if (!outputDir.exists()) {
boolean resp = outputDir.mkdir();
- if(!resp){
+ if (!resp) {
System.err.println("Unable to create the directory: " + outputDirStr);
System.exit(1);
}
- } else if(outputDir.isFile()){
- System.err.println("Unable to create the directory: " + outputDirStr + " since a filename with that string exists");
+ } else if (outputDir.isFile()) {
+ System.err.println("Unable to create the directory: " + outputDirStr
+ + " since a filename with that string exists");
System.exit(1);
}
- Writer file = new FileWriter(new File(outputDirStr + "/aai_swagger_" + versionToGenerate + ".html"));
+ Writer file =
+ new FileWriter(new File(outputDirStr + "/aai_swagger_" + versionToGenerate + ".html"));
template.process(resultMap, file);
}
- public static List<Api> convertToApi(Map<String, Object> pathMap){
+ public static List<Api> convertToApi(Map<String, Object> pathMap) {
- if(pathMap == null)
+ if (pathMap == null)
throw new IllegalArgumentException();
List<Api> apis = new ArrayList<>();
- pathMap.forEach( (pathKey, pathValue) -> {
+ pathMap.forEach((pathKey, pathValue) -> {
Api api = new Api();
Map<String, Object> httpVerbMap = (Map<String, Object>) pathValue;
@@ -206,83 +216,85 @@ public class GenerateSwagger {
Api.HttpVerb httpVerb = new Api.HttpVerb();
- Map<String, Object> httpVerbValueMap = (Map<String,Object>)httpVerbValue;
+ Map<String, Object> httpVerbValueMap = (Map<String, Object>) httpVerbValue;
httpVerb.setType(httpVerbKey);
- if(httpVerbValueMap.containsKey("tags")){
- httpVerb.setTags((List<String>)httpVerbValueMap.get("tags"));
+ if (httpVerbValueMap.containsKey("tags")) {
+ httpVerb.setTags((List<String>) httpVerbValueMap.get("tags"));
}
- if(httpVerbValueMap.containsKey("summary")){
- httpVerb.setSummary((String)httpVerbValueMap.get("summary"));
+ if (httpVerbValueMap.containsKey("summary")) {
+ httpVerb.setSummary((String) httpVerbValueMap.get("summary"));
}
- if(httpVerbValueMap.containsKey("operationId")){
- httpVerb.setOperationId((String)httpVerbValueMap.get("operationId"));
+ if (httpVerbValueMap.containsKey("operationId")) {
+ httpVerb.setOperationId((String) httpVerbValueMap.get("operationId"));
}
- if(httpVerbValueMap.containsKey("consumes")){
- httpVerb.setConsumes((List<String>)httpVerbValueMap.get("consumes"));
- if(httpVerb.getConsumes() != null){
+ if (httpVerbValueMap.containsKey("consumes")) {
+ httpVerb.setConsumes((List<String>) httpVerbValueMap.get("consumes"));
+ if (httpVerb.getConsumes() != null) {
httpVerb.setConsumerEnabled(true);
}
}
- if(httpVerbValueMap.containsKey("produces")){
- httpVerb.setProduces((List<String>)httpVerbValueMap.get("produces"));
+ if (httpVerbValueMap.containsKey("produces")) {
+ httpVerb.setProduces((List<String>) httpVerbValueMap.get("produces"));
}
- if(httpVerbValueMap.containsKey("parameters")){
- List<Map<String, Object>> parameters = (List<Map<String, Object>>) httpVerbValueMap.get("parameters");
- List<Map<String, Object>> requestParameters = parameters
- .stream()
- .filter((parameter) -> !parameter.get("name").equals("body"))
- .collect(Collectors.toList());
+ if (httpVerbValueMap.containsKey("parameters")) {
+ List<Map<String, Object>> parameters =
+ (List<Map<String, Object>>) httpVerbValueMap.get("parameters");
+ List<Map<String, Object>> requestParameters = parameters.stream()
+ .filter((parameter) -> !parameter.get("name").equals("body"))
+ .collect(Collectors.toList());
httpVerb.setParameters(requestParameters);
- if(httpVerb.getParameters() != null){
+ if (httpVerb.getParameters() != null) {
httpVerb.setParametersEnabled(true);
}
- List<Map<String, Object>> requestBodyList = parameters
- .stream()
- .filter((parameter) -> parameter.get("name").equals("body"))
- .collect(Collectors.toList());
+ List<Map<String, Object>> requestBodyList = parameters.stream()
+ .filter((parameter) -> parameter.get("name").equals("body"))
+ .collect(Collectors.toList());
Map<String, Object> requestBody = null;
- if(requestBodyList != null && requestBodyList.size() == 1){
+ if (requestBodyList != null && requestBodyList.size() == 1) {
requestBody = requestBodyList.get(0);
- for(String key : requestBody.keySet()) {
- //Filter out all the relationship links that appear in the YAML
- if(key.equals("description")) {
- String reqBody=(String)requestBody.get(key);
- if(!reqBody.replaceAll("\\[.*.json\\)", "").equals(reqBody)) {
- requestBody.put(key, reqBody.replaceAll("\\[.*.json\\)", ""));
+ for (String key : requestBody.keySet()) {
+ // Filter out all the relationship links that appear in the YAML
+ if (key.equals("description")) {
+ String reqBody = (String) requestBody.get(key);
+ if (!reqBody.replaceAll("\\[.*.json\\)", "").equals(reqBody)) {
+ requestBody.put(key, reqBody.replaceAll("\\[.*.json\\)", ""));
+ }
}
- }
- //Filter out all the patchDefinition links that appear in the YAML
- if(key.equals("schema")) {
- LinkedHashMap<String,String> reqBody = (LinkedHashMap<String,String>)requestBody.get(key);
- String schema=reqBody.get("$ref");
- String schemaNopatch = schema.replace("patchDefinitions", "definitions");
-
- if(! schema.equals(schemaNopatch)) {
- reqBody.put("$ref", schemaNopatch);
- requestBody.put(key, reqBody);
+ // Filter out all the patchDefinition links that appear in the YAML
+ if (key.equals("schema")) {
+ LinkedHashMap<String, String> reqBody =
+ (LinkedHashMap<String, String>) requestBody.get(key);
+ String schema = reqBody.get("$ref");
+ String schemaNopatch =
+ schema.replace("patchDefinitions", "definitions");
+
+ if (!schema.equals(schemaNopatch)) {
+ reqBody.put("$ref", schemaNopatch);
+ requestBody.put(key, reqBody);
+ }
}
- }
}
httpVerb.setBodyParametersEnabled(true);
httpVerb.setBodyParameters(requestBody);
- if(requestBody != null && requestBody.containsKey("schema")){
- Map<String, Object> schemaMap = (Map<String, Object>)requestBody.get("schema");
- if(schemaMap != null && schemaMap.containsKey("$ref")){
+ if (requestBody != null && requestBody.containsKey("schema")) {
+ Map<String, Object> schemaMap =
+ (Map<String, Object>) requestBody.get("schema");
+ if (schemaMap != null && schemaMap.containsKey("$ref")) {
String schemaLink = schemaMap.get("$ref").toString();
httpVerb.setSchemaLink(schemaLink);
int retCode = schemaLink.lastIndexOf('/');
- if(retCode != -1 && retCode != schemaLink.length()){
+ if (retCode != -1 && retCode != schemaLink.length()) {
httpVerb.setSchemaType(schemaLink.substring(retCode));
}
}
@@ -290,19 +302,19 @@ public class GenerateSwagger {
}
}
- if(httpVerbValueMap.containsKey("responses")){
+ if (httpVerbValueMap.containsKey("responses")) {
List<Api.HttpVerb.Response> responses = new ArrayList<Api.HttpVerb.Response>();
- Map<String, Object> responsesMap = (Map<String, Object>) httpVerbValueMap.get("responses");
+ Map<String, Object> responsesMap =
+ (Map<String, Object>) httpVerbValueMap.get("responses");
- responsesMap
- .entrySet()
- .stream()
+ responsesMap.entrySet().stream()
.filter((res) -> !"default".equalsIgnoreCase(res.getKey()))
.forEach((responseMap) -> {
- Map<String, Object> responseValueMap = (Map<String, Object>)responseMap.getValue();
+ Map<String, Object> responseValueMap =
+ (Map<String, Object>) responseMap.getValue();
Api.HttpVerb.Response response = new Api.HttpVerb.Response();
@@ -310,23 +322,27 @@ public class GenerateSwagger {
response.setDescription((String) responseValueMap.get("description"));
response.setVersion((String) responseValueMap.get("version"));
- if(responseValueMap != null && responseValueMap.containsKey("schema")){
- Map<String, Object> schemaMap = (Map<String, Object>)responseValueMap.get("schema");
- if(schemaMap != null && schemaMap.containsKey("$ref")){
+ if (responseValueMap != null
+ && responseValueMap.containsKey("schema")) {
+ Map<String, Object> schemaMap =
+ (Map<String, Object>) responseValueMap.get("schema");
+ if (schemaMap != null && schemaMap.containsKey("$ref")) {
String schemaLink = schemaMap.get("$ref").toString();
httpVerb.setHasReturnSchema(true);
- //Filter out all the getDefinition links that appear in the YAML
- httpVerb.setReturnSchemaLink(schemaLink.replace("getDefinitions", "definitions"));
+ // Filter out all the getDefinition links that appear in the
+ // YAML
+ httpVerb.setReturnSchemaLink(
+ schemaLink.replace("getDefinitions", "definitions"));
int retCode = schemaLink.lastIndexOf('/');
- if(retCode != -1 && retCode != schemaLink.length()){
- httpVerb.setReturnSchemaObject(schemaLink.substring(retCode));
+ if (retCode != -1 && retCode != schemaLink.length()) {
+ httpVerb
+ .setReturnSchemaObject(schemaLink.substring(retCode));
}
}
}
responses.add(response);
- }
- );
+ });
httpVerb.setResponses(responses);
}
@@ -343,145 +359,132 @@ public class GenerateSwagger {
public static List<Definition> convertToDefinition(Map<String, Object> definitionMap) {
- if(definitionMap == null)
+ if (definitionMap == null)
throw new IllegalArgumentException();
List<Definition> defintionsList = new ArrayList<>();
- definitionMap
- .entrySet()
- .forEach((entry) -> {
+ definitionMap.entrySet().forEach((entry) -> {
- Definition definition = new Definition();
- String key = entry.getKey();
- Map<String, Object> valueMap = (Map<String, Object>) entry.getValue();
+ Definition definition = new Definition();
+ String key = entry.getKey();
+ Map<String, Object> valueMap = (Map<String, Object>) entry.getValue();
- definition.setDefinitionName(key);
+ definition.setDefinitionName(key);
- if(valueMap.containsKey("description")){
- String description = valueMap.get("description").toString();
- description = formatDescription(description);
- definition.setDefinitionDescription(description);
- definition.setHasDescription(true);
- }
+ if (valueMap.containsKey("description")) {
+ String description = valueMap.get("description").toString();
+ description = formatDescription(description);
+ definition.setDefinitionDescription(description);
+ definition.setHasDescription(true);
+ }
- List<Definition.Property> definitionProperties = new ArrayList<>();
+ List<Definition.Property> definitionProperties = new ArrayList<>();
- List<String> requiredProperties = (valueMap.get("required") == null) ? new ArrayList<>() : (List<String>) valueMap.get("required");
+ List<String> requiredProperties = (valueMap.get("required") == null) ? new ArrayList<>()
+ : (List<String>) valueMap.get("required");
- Set<String> requiredPropsSet = new HashSet<>(requiredProperties);
+ Set<String> requiredPropsSet = new HashSet<>(requiredProperties);
- valueMap
- .entrySet()
- .stream()
- .filter( (e) -> "properties".equals(e.getKey()))
- .forEach((propertyEntries) -> {
- Map<String, Object> propertyRealEntries = (Map<String, Object>) propertyEntries.getValue();
- propertyRealEntries
- .forEach((propertyKey, value) -> {
- Definition.Property definitionProperty = new Definition.Property();
- if (requiredPropsSet.contains(propertyKey)) {
- definitionProperty.setRequired(true);
- }
- definitionProperty.setPropertyName(propertyKey);
- Map<String, Object> definitionPropertyMap =
- (Map<String, Object>) value;
-
- if (definitionPropertyMap.containsKey("description")) {
- definitionProperty.setPropertyDescription(
- definitionPropertyMap.get("description").toString());
- definitionProperty.setHasPropertyDescription(true);
- }
- if (definitionPropertyMap.containsKey("type")) {
- String type = definitionPropertyMap.get("type").toString();
- definitionProperty.setPropertyType(type);
- definitionProperty.setHasType(true);
- if ("array".equals(type)) {
- definitionProperty.setPropertyType("object[]");
- if (!definitionPropertyMap.containsKey("items")) {
- throw new RuntimeException(
- "Unable to find the property items even though the type is array for " +
- propertyKey);
- } else {
- Map<String, Object> itemMap =
- (Map<String, Object>) definitionPropertyMap
- .get("items");
- if (itemMap.containsKey("$ref")) {
- definitionProperty.setHasPropertyReference(true);
- String refItem = itemMap.get("$ref").toString();
- int retCode = refItem.lastIndexOf('/');
- if (retCode != -1 && retCode != refItem.length()) {
- definitionProperty
- .setPropertyReferenceObjectName(
- refItem.substring(retCode + 1));
- }
- definitionProperty.setPropertyReference(refItem);
- }
- }
- } else {
- if (definitionPropertyMap.containsKey("$ref")) {
- definitionProperty.setHasPropertyReference(true);
- String refItem =
- definitionPropertyMap.get("$ref").toString();
- int retCode = refItem.lastIndexOf('/');
- if (retCode != -1 && retCode != refItem.length()) {
- definitionProperty.setPropertyReferenceObjectName(
- refItem.substring(retCode + 1));
- }
- definitionProperty.setPropertyReference(refItem);
+ valueMap.entrySet().stream().filter((e) -> "properties".equals(e.getKey()))
+ .forEach((propertyEntries) -> {
+ Map<String, Object> propertyRealEntries =
+ (Map<String, Object>) propertyEntries.getValue();
+ propertyRealEntries.forEach((propertyKey, value) -> {
+ Definition.Property definitionProperty = new Definition.Property();
+ if (requiredPropsSet.contains(propertyKey)) {
+ definitionProperty.setRequired(true);
+ }
+ definitionProperty.setPropertyName(propertyKey);
+ Map<String, Object> definitionPropertyMap = (Map<String, Object>) value;
+
+ if (definitionPropertyMap.containsKey("description")) {
+ definitionProperty.setPropertyDescription(
+ definitionPropertyMap.get("description").toString());
+ definitionProperty.setHasPropertyDescription(true);
+ }
+ if (definitionPropertyMap.containsKey("type")) {
+ String type = definitionPropertyMap.get("type").toString();
+ definitionProperty.setPropertyType(type);
+ definitionProperty.setHasType(true);
+ if ("array".equals(type)) {
+ definitionProperty.setPropertyType("object[]");
+ if (!definitionPropertyMap.containsKey("items")) {
+ throw new RuntimeException(
+ "Unable to find the property items even though the type is array for "
+ + propertyKey);
+ } else {
+ Map<String, Object> itemMap =
+ (Map<String, Object>) definitionPropertyMap.get("items");
+ if (itemMap.containsKey("$ref")) {
+ definitionProperty.setHasPropertyReference(true);
+ String refItem = itemMap.get("$ref").toString();
+ int retCode = refItem.lastIndexOf('/');
+ if (retCode != -1 && retCode != refItem.length()) {
+ definitionProperty.setPropertyReferenceObjectName(
+ refItem.substring(retCode + 1));
}
+ definitionProperty.setPropertyReference(refItem);
}
}
- definitionProperties.add(definitionProperty);
- });
+ } else {
+ if (definitionPropertyMap.containsKey("$ref")) {
+ definitionProperty.setHasPropertyReference(true);
+ String refItem = definitionPropertyMap.get("$ref").toString();
+ int retCode = refItem.lastIndexOf('/');
+ if (retCode != -1 && retCode != refItem.length()) {
+ definitionProperty.setPropertyReferenceObjectName(
+ refItem.substring(retCode + 1));
+ }
+ definitionProperty.setPropertyReference(refItem);
+ }
+ }
+ }
+ definitionProperties.add(definitionProperty);
});
+ });
- definition.setPropertyList(definitionProperties);
+ definition.setPropertyList(definitionProperties);
- List<Definition.Property> schemaProperties = definitionProperties.
- stream()
- .filter(Definition.Property::isHasPropertyReference)
- .collect(Collectors.toList());
+ List<Definition.Property> schemaProperties = definitionProperties.stream()
+ .filter(Definition.Property::isHasPropertyReference).collect(Collectors.toList());
- List<Definition.Property> regularProperties = definitionProperties.
- stream()
- .filter((o) -> !o.isHasPropertyReference())
- .collect(Collectors.toList());
+ List<Definition.Property> regularProperties = definitionProperties.stream()
+ .filter((o) -> !o.isHasPropertyReference()).collect(Collectors.toList());
- definition.setRegularPropertyList(regularProperties);
- definition.setSchemaPropertyList(schemaProperties);
+ definition.setRegularPropertyList(regularProperties);
+ definition.setSchemaPropertyList(schemaProperties);
- defintionsList.add(definition);
- });
+ defintionsList.add(definition);
+ });
return defintionsList;
}
- public static String formatDescription(String description){
+ public static String formatDescription(String description) {
- description = Arrays.stream(description.split("\n"))
- .map((line) -> {
+ description = Arrays.stream(description.split("\n")).map((line) -> {
+ line = line.trim();
+ if (line.contains("######")) {
+ line = line.replaceAll("#", "");
line = line.trim();
- if(line.contains("######")){
- line = line.replaceAll("#", "");
- line = line.trim();
- String headerId = line.toLowerCase().replaceAll("\\s", "-");
-
- if(line.contains("Related Nodes")){
- return String.format("<h6 id=\"%s\">%s</h6>%s<ul>", headerId, line, LINE_SEPARATOR);
- } else {
- return String.format("<h6 id=\"%s\">%s</h6>", headerId, line);
- }
- } else if(line.startsWith("-")){
- line = line.replaceFirst("-", "");
- line = line.trim();
- return String.format("<li>%s</li>", line);
+ String headerId = line.toLowerCase().replaceAll("\\s", "-");
+
+ if (line.contains("Related Nodes")) {
+ return String.format("<h6 id=\"%s\">%s</h6>%s<ul>", headerId, line,
+ LINE_SEPARATOR);
} else {
- return String.format("<p>%s</p>", line);
+ return String.format("<h6 id=\"%s\">%s</h6>", headerId, line);
}
- })
- .collect(Collectors.joining(LINE_SEPARATOR));
+ } else if (line.startsWith("-")) {
+ line = line.replaceFirst("-", "");
+ line = line.trim();
+ return String.format("<li>%s</li>", line);
+ } else {
+ return String.format("<p>%s</p>", line);
+ }
+ }).collect(Collectors.joining(LINE_SEPARATOR));
- if(description.contains("<ul>")){
+ if (description.contains("<ul>")) {
description = description + "</ul>";
}
@@ -489,4 +492,3 @@ public class GenerateSwagger {
}
}
-
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/GenerateXsdTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/GenerateXsdTest.java
index c6d2dde..0b99454 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/GenerateXsdTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/GenerateXsdTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,8 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -26,10 +34,10 @@ import org.junit.runner.RunWith;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.schemagen.genxsd.*;
+import org.onap.aai.schemagen.testutils.TestUtilConfigTranslatorforBusiness;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.schemagen.testutils.TestUtilConfigTranslatorforBusiness;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,111 +46,98 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {
- SchemaLocationsBean.class,
- TestUtilConfigTranslatorforBusiness.class,
- EdgeIngestor.class,
- NodeIngestor.class,
- SwaggerGenerationConfiguration.class,
- SchemaVersions.class
-})
-@TestPropertySource(properties = {
- "schema.uri.base.path = /aai",
- "schema.xsd.maxoccurs = 5000"
-})
+@ContextConfiguration(
+ classes = {SchemaLocationsBean.class, TestUtilConfigTranslatorforBusiness.class,
+ EdgeIngestor.class, NodeIngestor.class, SwaggerGenerationConfiguration.class,
+ SchemaVersions.class})
+@TestPropertySource(properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000"})
public class GenerateXsdTest {
- private static final Logger logger = LoggerFactory.getLogger("GenerateXsd.class");
- private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
- private static final String EDGEFILENAME = "src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json";
- public static AnnotationConfigApplicationContext ctx = null;
- private static String testXML;
-
- @Autowired
+ private static final Logger logger = LoggerFactory.getLogger("GenerateXsd.class");
+ private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
+ private static final String EDGEFILENAME =
+ "src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json";
+ public static AnnotationConfigApplicationContext ctx = null;
+ private static String testXML;
+
+ @Autowired
YAMLfromOXM yamlFromOxm;
- @Autowired
+ @Autowired
HTMLfromOXM htmlFromOxm;
- @Autowired
+ @Autowired
SchemaVersions schemaVersions;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- XSDElementTest x = new XSDElementTest();
- x.setUp();
- testXML = x.getTestXML();
- logger.debug(testXML);
- BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
- bw.write(testXML);
- bw.close();
- BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
- bw1.write(YAMLfromOXMTest.EdgeDefs());
- bw1.close();
-
- }
-
- @Before
- public void setUp() throws Exception {
- //PowerMockito.mockStatic(GenerateXsd.class);
- XSDElementTest x = new XSDElementTest();
- x.setUp();
- testXML = x.getTestXML();
-// logger.info(testXML);
- }
-
- @Test
- public void test_generateSwaggerFromOxmFile( ) {
-
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String fileContent = null;
- try {
-
- yamlFromOxm.setXmlVersion(testXML, v);
- fileContent = yamlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ XSDElementTest x = new XSDElementTest();
+ x.setUp();
+ testXML = x.getTestXML();
+ logger.debug(testXML);
+ BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
+ bw.write(testXML);
+ bw.close();
+ BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
+ bw1.write(YAMLfromOXMTest.EdgeDefs());
+ bw1.close();
+
}
- assertThat(fileContent, is(new YAMLfromOXMTest().YAMLresult()));
- }
-
- @Test
- public void test_generateXSDFromOxmFile( ) {
-
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String fileContent = null;
- try {
- htmlFromOxm.setXmlVersion(testXML, v);
- fileContent = htmlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+
+ @Before
+ public void setUp() throws Exception {
+ // PowerMockito.mockStatic(GenerateXsd.class);
+ XSDElementTest x = new XSDElementTest();
+ x.setUp();
+ testXML = x.getTestXML();
+ // logger.info(testXML);
+ }
+
+ @Test
+ public void test_generateSwaggerFromOxmFile() {
+
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String fileContent = null;
+ try {
+
+ yamlFromOxm.setXmlVersion(testXML, v);
+ fileContent = yamlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat(fileContent, is(new YAMLfromOXMTest().YAMLresult()));
}
-// logger.debug(fileContent);
- assertThat(fileContent, is(new HTMLfromOXMTest().HTMLresult()));
- }
-
- @Test
- public void testGetAPIVersion() {
- GenerateXsd.apiVersion = schemaVersions.getAppRootVersion().toString();
- assertThat(GenerateXsd.getAPIVersion(),is("v11"));
- }
-
- @Test
- public void testGetYamlDir() {
- assertThat(GenerateXsd.getYamlDir(),is("aai-schema/src/main/resources/onap/aai_swagger_yaml"));
- }
-
- @Test
- public void testGetResponsesUrl() {
- assertNull(GenerateXsd.getResponsesUrl());
- }
-}
+ @Test
+ public void test_generateXSDFromOxmFile() {
+
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String fileContent = null;
+ try {
+ htmlFromOxm.setXmlVersion(testXML, v);
+ fileContent = htmlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ // logger.debug(fileContent);
+ assertThat(fileContent, is(new HTMLfromOXMTest().HTMLresult()));
+ }
+
+ @Test
+ public void testGetAPIVersion() {
+ GenerateXsd.apiVersion = schemaVersions.getAppRootVersion().toString();
+ assertThat(GenerateXsd.getAPIVersion(), is("v11"));
+ }
+
+ @Test
+ public void testGetYamlDir() {
+ assertThat(GenerateXsd.getYamlDir(),
+ is("aai-schema/src/main/resources/onap/aai_swagger_yaml"));
+ }
+
+ @Test
+ public void testGetResponsesUrl() {
+ assertNull(GenerateXsd.getResponsesUrl());
+ }
+}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSetTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSetTest.java
index fe1aa6f..4729af4 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSetTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSetTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,67 +17,73 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import java.util.Arrays;
-import java.util.Collection;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
@RunWith(Parameterized.class)
public class DeleteFootnoteSetTest {
- String targetNode;
- String flavor;
- String result;
- DeleteFootnoteSet footnotes = null;
+ String targetNode;
+ String flavor;
+ String result;
+ DeleteFootnoteSet footnotes = null;
- @Parameters
- public static Collection<String[]> testConditions() {
- String inputs [][] = {
- {"vserver","(1)", "\n -(1) IF this VSERVER node is deleted, this FROM node is DELETED also\n"},
- {"ctag-pool","(2)", "\n -(2) IF this CTAG-POOL node is deleted, this TO node is DELETED also\n"},
- {"pserver","(3)", "\n -(3) IF this FROM node is deleted, this PSERVER is DELETED also\n"},
- {"oam-network","(4)", "\n -(4) IF this TO node is deleted, this OAM-NETWORK is DELETED also\n"},
- {"dvs-switch","(1)", "\n -(1) IF this DVS-SWITCH node is deleted, this FROM node is DELETED also\n"},
- {"availability-zone","(3)", "\n -(3) IF this FROM node is deleted, this AVAILABILITY-ZONE is DELETED also\n"}
- };
- return (Arrays.asList(inputs));
- }
+ @Parameters
+ public static Collection<String[]> testConditions() {
+ String inputs[][] = {
+ {"vserver", "(1)",
+ "\n -(1) IF this VSERVER node is deleted, this FROM node is DELETED also\n"},
+ {"ctag-pool", "(2)",
+ "\n -(2) IF this CTAG-POOL node is deleted, this TO node is DELETED also\n"},
+ {"pserver", "(3)",
+ "\n -(3) IF this FROM node is deleted, this PSERVER is DELETED also\n"},
+ {"oam-network", "(4)",
+ "\n -(4) IF this TO node is deleted, this OAM-NETWORK is DELETED also\n"},
+ {"dvs-switch", "(1)",
+ "\n -(1) IF this DVS-SWITCH node is deleted, this FROM node is DELETED also\n"},
+ {"availability-zone", "(3)",
+ "\n -(3) IF this FROM node is deleted, this AVAILABILITY-ZONE is DELETED also\n"}};
+ return (Arrays.asList(inputs));
+ }
- public DeleteFootnoteSetTest(String targetNode, String flavor, String result) {
- super();
- this.targetNode = targetNode;
- this.flavor = flavor;
- this.result=result;
- }
+ public DeleteFootnoteSetTest(String targetNode, String flavor, String result) {
+ super();
+ this.targetNode = targetNode;
+ this.flavor = flavor;
+ this.result = result;
+ }
- @Before
- public void setUp() throws Exception {
- footnotes = new DeleteFootnoteSet(this.targetNode);
- }
+ @Before
+ public void setUp() throws Exception {
+ footnotes = new DeleteFootnoteSet(this.targetNode);
+ }
- @Test
- public void testDeleteFootnoteSet() {
- assertThat(footnotes.targetNode, is(this.targetNode));
- }
+ @Test
+ public void testDeleteFootnoteSet() {
+ assertThat(footnotes.targetNode, is(this.targetNode));
+ }
- @Test
- public void testAdd() {
- footnotes.add(this.flavor);
- assertThat(footnotes.footnotes.size(), is(1));
- }
+ @Test
+ public void testAdd() {
+ footnotes.add(this.flavor);
+ assertThat(footnotes.footnotes.size(), is(1));
+ }
- @Test
- public void testToString() {
- footnotes.add(this.flavor);
- assertThat(footnotes.toString(), is(this.result));
- }
+ @Test
+ public void testToString() {
+ footnotes.add(this.flavor);
+ assertThat(footnotes.toString(), is(this.result));
+ }
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteOperationTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteOperationTest.java
index 0f44954..08f5c81 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteOperationTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteOperationTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,65 +17,76 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import java.util.Arrays;
-import java.util.Collection;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
@RunWith(Parameterized.class)
public class DeleteOperationTest {
- private String useOpId;
- private String xmlRootElementName;
- private String tag;
- private String path;
- private String pathParams;
- private String result;
+ private String useOpId;
+ private String xmlRootElementName;
+ private String tag;
+ private String path;
+ private String pathParams;
+ private String result;
+
+ @Parameters
+ public static Collection<String[]> testConditions() {
+ String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
+ "/network/generic-vnfs/generic-vnf/{vnf-id}",
+ " - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__\n",
+ " delete:\n tags:\n - Network\n summary: delete an existing generic-vnf\n description: delete an existing generic-vnf\n operationId: deleteNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__\n - name: resource-version\n in: query\n description: resource-version for concurrency\n required: true\n type: string\n"},
+ // if ( StringUtils.isEmpty(tag) )
+ {"GenericVnf", "generic-vnf", "", "/generic-vnf/{vnf-id}",
+ " - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__\n",
+ ""},
+ // Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
+ {"CloudInfrastructurePserversPserverPInterfaces", "p-interfaces", "CloudInfrastructure",
+ "/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces",
+ " - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",
+ ""},
+ // {"","ctag-pool","","","",""},
+ // {"","pserver","","","",""},
+ // {"","oam-network","","","",""},
+ // {"","dvs-switch","","","",""},
+ // {"","availability-zone","","","",""}
+ };
+ return Arrays.asList(inputs);
+ }
- @Parameters
- public static Collection<String []> testConditions() {
- String inputs [][] = {
- {"NetworkGenericVnfsGenericVnf","generic-vnf","Network","/network/generic-vnfs/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__\n"," delete:\n tags:\n - Network\n summary: delete an existing generic-vnf\n description: delete an existing generic-vnf\n operationId: deleteNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__\n - name: resource-version\n in: query\n description: resource-version for concurrency\n required: true\n type: string\n"},
-// if ( StringUtils.isEmpty(tag) )
- {"GenericVnf","generic-vnf","","/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__\n",""},
-// Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
- {"CloudInfrastructurePserversPserverPInterfaces","p-interfaces","CloudInfrastructure","/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces"," - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",""},
-// {"","ctag-pool","","","",""},
-// {"","pserver","","","",""},
-// {"","oam-network","","","",""},
-// {"","dvs-switch","","","",""},
-// {"","availability-zone","","","",""}
- };
- return Arrays.asList(inputs);
- }
+ public DeleteOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
+ String pathParams, String result) {
+ super();
+ this.useOpId = useOpId;
+ this.xmlRootElementName = xmlRootElementName;
+ this.tag = tag;
+ this.path = path;
+ this.pathParams = pathParams;
+ this.result = result;
+ }
- public DeleteOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
- super();
- this.useOpId = useOpId;
- this.xmlRootElementName = xmlRootElementName;
- this.tag = tag;
- this.path = path;
- this.pathParams=pathParams;
- this.result = result;
- }
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
- }
+ }
- @Test
- public void testToString() {
- DeleteOperation delete = new DeleteOperation(useOpId, xmlRootElementName, tag, path, pathParams);
- String modResult = delete.toString();
- assertThat(modResult, is(this.result));
- }
+ @Test
+ public void testToString() {
+ DeleteOperation delete =
+ new DeleteOperation(useOpId, xmlRootElementName, tag, path, pathParams);
+ String modResult = delete.toString();
+ assertThat(modResult, is(this.result));
+ }
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/EdgeDescriptionTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/EdgeDescriptionTest.java
index b17901f..1469272 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/EdgeDescriptionTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/EdgeDescriptionTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,9 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
import com.google.common.collect.Multimap;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.util.*;
+
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -38,311 +49,314 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.util.*;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {SchemaVersions.class, SchemaLocationsBean.class, TestUtilConfigTranslatorforEdges.class, EdgeIngestor.class})
-@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/schemaIngest/schemaIngestTest.properties"})
-
+@ContextConfiguration(
+ classes = {SchemaVersions.class, SchemaLocationsBean.class,
+ TestUtilConfigTranslatorforEdges.class, EdgeIngestor.class})
+@TestPropertySource(
+ properties = {
+ "schemaIngestPropLoc = src/test/resources/schemaIngest/schemaIngestTest.properties"})
-public class EdgeDescriptionTest {
- private static final String EDGEFILENAME = "src/test/resources/dbedgerules/EdgeDescriptionRules_test.json";
- @Autowired
+public class EdgeDescriptionTest {
+ private static final String EDGEFILENAME =
+ "src/test/resources/dbedgerules/EdgeDescriptionRules_test.json";
+ @Autowired
ConfigTranslator ct;
- @Autowired
+ @Autowired
EdgeIngestor edgeIngestor;
- String nodeName = "availability-zone";
- String toNode = "complex";
- SchemaVersion v10 = new SchemaVersion("v10");
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- String json = "{"
- + " \"rules\": ["
- + " {"
- + " \"from\": \"availability-zone\","
- + " \"to\": \"complex\","
- + " \"label\": \"org.onap.relationships.inventory.LocatedIn\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2ONE\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"this description\""
- + " },"
- + " {"
- + " \"from\": \"availability-zone\","
- + " \"to\": \"service-capability\","
- + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2MANY\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"availability-zone\","
- + " \"to\": \"cloud-region\","
- + " \"label\": \"org.onap.relationships.inventory.BelongsTo\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2ONE\","
- + " \"contains-other-v\": \"!${direction}\","
- + " \"delete-other-v\": \"!${direction}\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"NONE\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"ctag-pool\","
- + " \"to\": \"availability-zone\","
- + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2MANY\","
- + " \"contains-other-v\": \"${direction}\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"dvs-switch\","
- + " \"to\": \"availability-zone\","
- + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2MANY\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"generic-vnf\","
- + " \"to\": \"availability-zone\","
- + " \"label\": \"org.onap.relationships.inventory.Uses\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2MANY\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"${direction}\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"pserver\","
- + " \"to\": \"availability-zone\","
- + " \"label\": \"org.onap.relationships.inventory.MemberOf\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2ONE\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"${direction}\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"vce\","
- + " \"to\": \"availability-zone\","
- + " \"label\": \"org.onap.relationships.inventory.Uses\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2MANY\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " ]}";
- BufferedWriter bw = new BufferedWriter(new FileWriter(EDGEFILENAME));
- bw.write(json);
- bw.close();
- }
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- File edges = new File(EDGEFILENAME);
- edges.delete();
- }
- @Before
- public void setUp() throws Exception {
+ String nodeName = "availability-zone";
+ String toNode = "complex";
+ SchemaVersion v10 = new SchemaVersion("v10");
- }
- @Test
- public void test() {
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ String json = "{" + " \"rules\": [" + " {" + " \"from\": \"availability-zone\","
+ + " \"to\": \"complex\","
+ + " \"label\": \"org.onap.relationships.inventory.LocatedIn\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\"," + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\"," + " \"description\":\"this description\""
+ + " }," + " {" + " \"from\": \"availability-zone\","
+ + " \"to\": \"service-capability\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\"," + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\"," + " \"description\":\"\"" + " }," + " {"
+ + " \"from\": \"availability-zone\"," + " \"to\": \"cloud-region\","
+ + " \"label\": \"org.onap.relationships.inventory.BelongsTo\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"!${direction}\","
+ + " \"delete-other-v\": \"!${direction}\"," + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"NONE\"," + " \"default\": \"true\","
+ + " \"description\":\"\"" + " }," + " {" + " \"from\": \"ctag-pool\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"${direction}\","
+ + " \"delete-other-v\": \"NONE\"," + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"!${direction}\"," + " \"default\": \"true\","
+ + " \"description\":\"\"" + " }," + " {" + " \"from\": \"dvs-switch\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\"," + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\"," + " \"description\":\"\"" + " }," + " {"
+ + " \"from\": \"generic-vnf\"," + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"!${direction}\"," + " \"default\": \"true\","
+ + " \"description\":\"\"" + " }," + " {" + " \"from\": \"pserver\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.MemberOf\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"!${direction}\"," + " \"default\": \"true\","
+ + " \"description\":\"\"" + " }," + " {" + " \"from\": \"vce\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\"," + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\"," + " \"description\":\"\"" + " }," + " ]}";
+ BufferedWriter bw = new BufferedWriter(new FileWriter(EDGEFILENAME));
+ bw.write(json);
+ bw.close();
+ }
- Map<SchemaVersion, List<String>> edges = ct.getEdgeFiles();
- assertTrue(edges.containsKey(v10));
- assertTrue(1 == edges.get(v10).size());
- assertTrue("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json".equals(edges.get(v10).get(0)));
- }
- @Test
- public void testGetDeleteOtherV() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode+"-"+"NONE";
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getDeleteOtherV(), is(target)); } );
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ File edges = new File(EDGEFILENAME);
+ edges.delete();
}
- }
- @Test
- public void testGetPreventDelete() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode+"-"+"IN";
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getPreventDelete(), is(target)); } );
+ @Before
+ public void setUp() throws Exception {
+
}
- }
- @Test
- public void testGetAlsoDeleteFootnote() throws EdgeRuleNotFoundException {
-// String toNode="cloud-region";
-// String target = "availability-zone"+"|"+toNode+"-"+"(4)";
- List<String> notedTypes = Arrays.asList("cloud-region", "ctag-pool");
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals("availability-zone") && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); String target = ed.getRuleKey()+"-"+(notedTypes.contains(ed.getTo()) ? "(4)" : ""); assertThat(ed.getRuleKey()+"-"+ed.getAlsoDeleteFootnote(ed.getFrom()), is(target)); } );
+ @Test
+ public void test() {
+
+ Map<SchemaVersion, List<String>> edges = ct.getEdgeFiles();
+ assertTrue(edges.containsKey(v10));
+ assertTrue(1 == edges.get(v10).size());
+ assertTrue("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json"
+ .equals(edges.get(v10).get(0)));
}
-/*
- for (EdgeDescription ed : edges) {
- String modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getFrom());
- assertThat(modResult, is(target));
- ed.setDeleteOtherV("IN");
- target = "availability-zone"+"|"+"complex"+"-"+"(4)";
- modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getFrom());
- assertThat(modResult, is(target));
- target = "availability-zone"+"|"+"complex"+"-"+"(1)";
- modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getTo());
- assertThat(modResult, is(target));
- ed.setDeleteOtherV("OUT");
- target = "availability-zone"+"|"+"complex"+"-"+"(2)";
- modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getFrom());
- assertThat(modResult, is(target));
- target = "availability-zone"+"|"+"complex"+"-"+"(3)";
- modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getTo());
- assertThat(modResult, is(target));
+
+ @Test
+ public void testGetDeleteOtherV() throws EdgeRuleNotFoundException {
+ String target = "availability-zone" + "|" + toNode + "-" + "NONE";
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getDeleteOtherV(), is(target));
+ });
+ }
}
-*/
- }
- @Test
- public void testGetTo() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode+"-"+toNode;
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getTo(), is(target)); } );
+ @Test
+ public void testGetPreventDelete() throws EdgeRuleNotFoundException {
+ String target = "availability-zone" + "|" + toNode + "-" + "IN";
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getPreventDelete(), is(target));
+ });
+ }
}
- }
- @Test
- public void testGetFrom() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode+"-"+"availability-zone";
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getFrom(), is(target)); } );
+ @Test
+ public void testGetAlsoDeleteFootnote() throws EdgeRuleNotFoundException {
+ // String toNode="cloud-region";
+ // String target = "availability-zone"+"|"+toNode+"-"+"(4)";
+ List<String> notedTypes = Arrays.asList("cloud-region", "ctag-pool");
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals("availability-zone") && (!i.isPrivateEdge())))
+ .forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ String target =
+ ed.getRuleKey() + "-" + (notedTypes.contains(ed.getTo()) ? "(4)" : "");
+ assertThat(ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getFrom()),
+ is(target));
+ });
+ }
+ /*
+ * for (EdgeDescription ed : edges) {
+ * String modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getFrom());
+ * assertThat(modResult, is(target));
+ * ed.setDeleteOtherV("IN");
+ * target = "availability-zone"+"|"+"complex"+"-"+"(4)";
+ * modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getFrom());
+ * assertThat(modResult, is(target));
+ * target = "availability-zone"+"|"+"complex"+"-"+"(1)";
+ * modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getTo());
+ * assertThat(modResult, is(target));
+ * ed.setDeleteOtherV("OUT");
+ * target = "availability-zone"+"|"+"complex"+"-"+"(2)";
+ * modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getFrom());
+ * assertThat(modResult, is(target));
+ * target = "availability-zone"+"|"+"complex"+"-"+"(3)";
+ * modResult = ed.getRuleKey() + "-" + ed.getAlsoDeleteFootnote(ed.getTo());
+ * assertThat(modResult, is(target));
+ * }
+ */
}
- }
- @Test
- public void testGetRuleKey() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode;
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey(), is(target)); } );
+ @Test
+ public void testGetTo() throws EdgeRuleNotFoundException {
+ String target = "availability-zone" + "|" + toNode + "-" + toNode;
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getTo(), is(target));
+ });
+ }
}
- }
- @Test
- public void testGetMultiplicity() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode+"-"+"MANY2ONE";
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getMultiplicity(), is(target)); } );
+ @Test
+ public void testGetFrom() throws EdgeRuleNotFoundException {
+ String target = "availability-zone" + "|" + toNode + "-" + "availability-zone";
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getFrom(), is(target));
+ });
+ }
}
- }
- @Test
- public void testGetDirection() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode+"-"+"OUT";
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getDirection(), is(target)); } );
+ @Test
+ public void testGetRuleKey() throws EdgeRuleNotFoundException {
+ String target = "availability-zone" + "|" + toNode;
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey(), is(target));
+ });
+ }
}
- }
- @Test
- public void testGetDescription() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode+"-"+"this description";
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getDescription(), is(target)); } );
+ @Test
+ public void testGetMultiplicity() throws EdgeRuleNotFoundException {
+ String target = "availability-zone" + "|" + toNode + "-" + "MANY2ONE";
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getMultiplicity(), is(target));
+ });
+ }
}
- }
- @Test
- public void testGetRelationshipDescription() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode+"-"+"this description";
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getDescription(), is(target)); } );
+ @Test
+ public void testGetDirection() throws EdgeRuleNotFoundException {
+ String target = "availability-zone" + "|" + toNode + "-" + "OUT";
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getDirection(), is(target));
+ });
+ }
}
- }
- @Test
- public void testGetType() throws EdgeRuleNotFoundException {
- String toNode = "cloud-region";
- String target = "availability-zone"+"|"+toNode+"-"+"PARENT";
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getType(), is(target)); } );
+ @Test
+ public void testGetDescription() throws EdgeRuleNotFoundException {
+ String target = "availability-zone" + "|" + toNode + "-" + "this description";
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getDescription(), is(target));
+ });
+ }
}
- }
- @Test
- public void testGetLabel() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode+"-"+"org.onap.relationships.inventory.LocatedIn";
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getLabel(), is(target)); } );
+ @Test
+ public void testGetRelationshipDescription() throws EdgeRuleNotFoundException {
+ String target = "availability-zone" + "|" + toNode + "-" + "this description";
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getDescription(), is(target));
+ });
+ }
}
- }
- @Test
- public void testGetShortLabel() throws EdgeRuleNotFoundException {
- String target = "availability-zone"+"|"+toNode+"-"+"LocatedIn";
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> (i.getTo().equals(toNode) && (! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); assertThat(ed.getRuleKey()+"-"+ed.getShortLabel(), is(target)); } );
+ @Test
+ public void testGetType() throws EdgeRuleNotFoundException {
+ String toNode = "cloud-region";
+ String target = "availability-zone" + "|" + toNode + "-" + "PARENT";
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getType(), is(target));
+ });
+ }
}
- }
-}
+ @Test
+ public void testGetLabel() throws EdgeRuleNotFoundException {
+ String target =
+ "availability-zone" + "|" + toNode + "-" + "org.onap.relationships.inventory.LocatedIn";
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getLabel(), is(target));
+ });
+ }
+ }
+ @Test
+ public void testGetShortLabel() throws EdgeRuleNotFoundException {
+ String target = "availability-zone" + "|" + toNode + "-" + "LocatedIn";
+ Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(v10);
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream()
+ .filter((i) -> (i.getTo().equals(toNode) && (!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ assertThat(ed.getRuleKey() + "-" + ed.getShortLabel(), is(target));
+ });
+ }
+ }
+}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/GetOperationTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/GetOperationTest.java
index 74fa60b..aad62ce 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/GetOperationTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/GetOperationTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,8 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Vector;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,80 +35,82 @@ import org.junit.runners.Parameterized.Parameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Vector;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
@RunWith(Parameterized.class)
public class GetOperationTest {
- private static final Logger logger = LoggerFactory.getLogger("GetOperationTest.class");
- private String useOpId;
- private String xmlRootElementName;
- private String tag;
- private String path;
- private String pathParams;
- private String result;
+ private static final Logger logger = LoggerFactory.getLogger("GetOperationTest.class");
+ private String useOpId;
+ private String xmlRootElementName;
+ private String tag;
+ private String path;
+ private String pathParams;
+ private String result;
- @Parameters
- public static Collection<String []> testConditions() {
- String inputs [][] = {
- {"NetworkGenericVnfsGenericVnf","generic-vnf","Network","/network/generic-vnfs/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"," /network/generic-vnfs/generic-vnf/{vnf-id}:\n get:\n tags:\n - Network\n summary: returns generic-vnf\n description: returns generic-vnf\n operationId: getNetworkGenericVnfsGenericVnf\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/definitions/generic-vnf\"\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"},
- {"GenericVnf","generic-vnf","","/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",""},
- {"CloudInfrastructurePserversPserverPInterfaces","p-interfaces","CloudInfrastructure","/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces"," - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__"," /cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces:\n get:\n tags:\n - CloudInfrastructure\n summary: returns p-interfaces\n description: returns p-interfaces\n operationId: getCloudInfrastructurePserversPserverPInterfaces\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/definitions/p-interfaces\"\n \"default\":\n null parameters:\n - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__ - name: interface-name\n in: query\n description:\n required: false\n type: string - name: prov-status\n in: query\n description:\n required: false\n type: string"},
- // {"","ctag-pool","","","",""},
-// {"","pserver","","","",""},
-// {"","oam-network","","","",""},
-// {"","dvs-switch","","","",""},
-// {"","availability-zone","","","",""}
- };
- return Arrays.asList(inputs);
- }
+ @Parameters
+ public static Collection<String[]> testConditions() {
+ String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
+ "/network/generic-vnfs/generic-vnf/{vnf-id}",
+ " - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",
+ " /network/generic-vnfs/generic-vnf/{vnf-id}:\n get:\n tags:\n - Network\n summary: returns generic-vnf\n description: returns generic-vnf\n operationId: getNetworkGenericVnfsGenericVnf\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/definitions/generic-vnf\"\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"},
+ {"GenericVnf", "generic-vnf", "", "/generic-vnf/{vnf-id}",
+ " - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",
+ ""},
+ {"CloudInfrastructurePserversPserverPInterfaces", "p-interfaces", "CloudInfrastructure",
+ "/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces",
+ " - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",
+ " /cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces:\n get:\n tags:\n - CloudInfrastructure\n summary: returns p-interfaces\n description: returns p-interfaces\n operationId: getCloudInfrastructurePserversPserverPInterfaces\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/definitions/p-interfaces\"\n \"default\":\n null parameters:\n - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__ - name: interface-name\n in: query\n description:\n required: false\n type: string - name: prov-status\n in: query\n description:\n required: false\n type: string"},
+ // {"","ctag-pool","","","",""},
+ // {"","pserver","","","",""},
+ // {"","oam-network","","","",""},
+ // {"","dvs-switch","","","",""},
+ // {"","availability-zone","","","",""}
+ };
+ return Arrays.asList(inputs);
+ }
+
+ public GetOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
+ String pathParams, String result) {
+ super();
+ this.useOpId = useOpId;
+ this.xmlRootElementName = xmlRootElementName;
+ this.tag = tag;
+ this.path = path;
+ this.pathParams = pathParams;
+ this.result = result;
+ }
- public GetOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
- super();
- this.useOpId = useOpId;
- this.xmlRootElementName = xmlRootElementName;
- this.tag = tag;
- this.path = path;
- this.pathParams=pathParams;
- this.result = result;
- }
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- String container = "p-interfaces";
- String queryProps[] = {
- " - name: interface-name\n in: query\n description:\n required: false\n type: string",
- " - name: prov-status\n in: query\n description:\n required: false\n type: string"
- };
- Vector<String> containerProps = new Vector<String>();
- for(String prop : queryProps) {
- containerProps.add(prop);
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ String container = "p-interfaces";
+ String queryProps[] = {
+ " - name: interface-name\n in: query\n description:\n required: false\n type: string",
+ " - name: prov-status\n in: query\n description:\n required: false\n type: string"};
+ Vector<String> containerProps = new Vector<String>();
+ for (String prop : queryProps) {
+ containerProps.add(prop);
+ }
+ GetOperation.addContainerProps(container, containerProps);
}
- GetOperation.addContainerProps(container, containerProps);
- }
- @Test
- public void testAddContainerProps() {
- String container = this.xmlRootElementName;
- String prop = " - name: "+container+"\n in: query\n description:\n required: false\n type: string";
- Vector<String> queryProps = new Vector<String>();
- queryProps.add(prop);
- for(String p : queryProps) {
- logger.debug("qProp="+p);
+ @Test
+ public void testAddContainerProps() {
+ String container = this.xmlRootElementName;
+ String prop = " - name: " + container
+ + "\n in: query\n description:\n required: false\n type: string";
+ Vector<String> queryProps = new Vector<String>();
+ queryProps.add(prop);
+ for (String p : queryProps) {
+ logger.debug("qProp=" + p);
+ }
+ logger.debug("Done=" + this.xmlRootElementName);
+ GetOperation.addContainerProps(container, queryProps);
+ assertThat(GetOperation.containers.get(container).get(0), is(prop));
}
- logger.debug("Done="+this.xmlRootElementName);
- GetOperation.addContainerProps(container, queryProps);
- assertThat(GetOperation.containers.get(container).get(0), is(prop));
- }
- @Test
- public void testToString() {
- GetOperation get = new GetOperation(useOpId, xmlRootElementName, tag, path, pathParams);
- String modResult = get.toString();
- assertThat(modResult, is(this.result));
- }
+ @Test
+ public void testToString() {
+ GetOperation get = new GetOperation(useOpId, xmlRootElementName, tag, path, pathParams);
+ String modResult = get.toString();
+ assertThat(modResult, is(this.result));
+ }
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/HTMLfromOXMTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/HTMLfromOXMTest.java
index b5d9489..d4a6517 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/HTMLfromOXMTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/HTMLfromOXMTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,8 +17,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -39,342 +52,383 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.w3c.dom.Element;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {
- SchemaVersions.class,
- SchemaLocationsBean.class,
- TestUtilConfigTranslatorforBusiness.class,
- EdgeIngestor.class,
- NodeIngestor.class,
- SwaggerGenerationConfiguration.class
+@ContextConfiguration(
+ classes = {SchemaVersions.class, SchemaLocationsBean.class,
+ TestUtilConfigTranslatorforBusiness.class, EdgeIngestor.class, NodeIngestor.class,
+ SwaggerGenerationConfiguration.class
-})
-@TestPropertySource(properties = {
- "schema.uri.base.path = /aai",
- "schema.xsd.maxoccurs = 5000"
-})
+ })
+@TestPropertySource(properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000"})
public class HTMLfromOXMTest {
- private static final Logger logger = LoggerFactory.getLogger("HTMLfromOXMTest.class");
- private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
- public static AnnotationConfigApplicationContext ctx = null;
- private static String testXML;
- protected static final String SERVICE_NAME = "JUNIT";
-
+ private static final Logger logger = LoggerFactory.getLogger("HTMLfromOXMTest.class");
+ private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
+ public static AnnotationConfigApplicationContext ctx = null;
+ private static String testXML;
+ protected static final String SERVICE_NAME = "JUNIT";
- @Autowired
- HTMLfromOXM htmlFromOxm;
+ @Autowired
+ HTMLfromOXM htmlFromOxm;
- @Autowired
+ @Autowired
SchemaVersions schemaVersions;
- @BeforeClass
- public static void setUpContext() throws Exception {
+ @BeforeClass
+ public static void setUpContext() throws Exception {
- }
- @BeforeClass
+ }
+
+ @BeforeClass
public static void setupBundleconfig() throws Exception {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
System.setProperty("aai.service.name", SERVICE_NAME);
}
- @Before
- public void setUp() throws Exception {
- setUp(0);
- }
+ @Before
+ public void setUp() throws Exception {
+ setUp(0);
+ }
- public void setUp(int sbopt) throws Exception
- {
- XSDElementTest x = new XSDElementTest();
- x.setUp(sbopt);
- testXML = x.testXML;
- logger.debug(testXML);
- BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
- bw.write(testXML);
- bw.close();
- }
+ public void setUp(int sbopt) throws Exception {
+ XSDElementTest x = new XSDElementTest();
+ x.setUp(sbopt);
+ testXML = x.testXML;
+ logger.debug(testXML);
+ BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
+ bw.write(testXML);
+ bw.close();
+ }
- @Test
- public void testGetDocumentHeader() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String header = null;
- try {
- htmlFromOxm.setXmlVersion(testXML, v);
- htmlFromOxm.setSchemaVersions(schemaVersions);
- header = htmlFromOxm.getDocumentHeader();
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testGetDocumentHeader() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String header = null;
+ try {
+ htmlFromOxm.setXmlVersion(testXML, v);
+ htmlFromOxm.setSchemaVersions(schemaVersions);
+ header = htmlFromOxm.getDocumentHeader();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug("Header:");
+ logger.debug(header);
+ assertThat(header, is(HTMLheader()));
}
- logger.debug("Header:");
- logger.debug(header);
- assertThat(header, is(HTMLheader()));
- }
- @Test
- public void testProcess() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String fileContent = null;
- try {
- htmlFromOxm.setXmlVersion(testXML, v);
- fileContent = htmlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testProcess() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String fileContent = null;
+ try {
+ htmlFromOxm.setXmlVersion(testXML, v);
+ fileContent = htmlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug("FileContent-I:");
+ logger.debug(fileContent);
+ assertThat(fileContent, is(HTMLresult(0)));
}
- logger.debug("FileContent-I:");
- logger.debug(fileContent);
- assertThat(fileContent, is(HTMLresult(0)));
- }
- @Test
- public void testProcessWithCombiningJavaTypes() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String fileContent = null;
- try {
- setUp(1);
- htmlFromOxm.setXmlVersion(testXML, v);
- fileContent = htmlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testProcessWithCombiningJavaTypes() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String fileContent = null;
+ try {
+ setUp(1);
+ htmlFromOxm.setXmlVersion(testXML, v);
+ fileContent = htmlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug("FileContent-I:");
+ logger.debug(fileContent);
+ assertThat(fileContent, is(HTMLresult(1)));
}
- logger.debug("FileContent-I:");
- logger.debug(fileContent);
- assertThat(fileContent, is(HTMLresult(1)));
- }
- @Test
- public void testHTMLfromOXMFileVersion() throws IOException {
- String outfileName = "testXML.xml";
- File XMLfile = new File(outfileName);
- XMLfile.createNewFile();
- BufferedWriter bw = null;
- Charset charset = Charset.forName("UTF-8");
- Path path = Paths.get(outfileName);
- bw = Files.newBufferedWriter(path, charset);
- bw.write(testXML);
- bw.close();
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String fileContent = null;
- try {
- htmlFromOxm.setXmlVersion(testXML, v);
- fileContent = htmlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testHTMLfromOXMFileVersion() throws IOException {
+ String outfileName = "testXML.xml";
+ File XMLfile = new File(outfileName);
+ XMLfile.createNewFile();
+ BufferedWriter bw = null;
+ Charset charset = Charset.forName("UTF-8");
+ Path path = Paths.get(outfileName);
+ bw = Files.newBufferedWriter(path, charset);
+ bw.write(testXML);
+ bw.close();
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String fileContent = null;
+ try {
+ htmlFromOxm.setXmlVersion(testXML, v);
+ fileContent = htmlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ XMLfile.delete();
+ logger.debug("FileContent-I:");
+ logger.debug(fileContent);
+ assertThat(fileContent, is(HTMLresult(0)));
}
- XMLfile.delete();
- logger.debug("FileContent-I:");
- logger.debug(fileContent);
- assertThat(fileContent, is(HTMLresult(0)));
- }
- @Test
- public void testHTMLfromOXMStringVersion() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String fileContent = null;
- try {
- htmlFromOxm.setXmlVersion(testXML, v);
- fileContent = htmlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testHTMLfromOXMStringVersion() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String fileContent = null;
+ try {
+ htmlFromOxm.setXmlVersion(testXML, v);
+ fileContent = htmlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug("FileContent-II:");
+ logger.debug(fileContent);
+ assertThat(fileContent, is(HTMLresult(0)));
}
- logger.debug("FileContent-II:");
- logger.debug(fileContent);
- assertThat(fileContent, is(HTMLresult(0)));
- }
- @Test
- public void testProcessJavaTypeElement() {
- String target = "Element=java-type/Customer";
- SchemaVersion v = schemaVersions.getAppRootVersion();
- Element customer = null;
- try {
- htmlFromOxm.setXmlVersion(testXML, v);
- htmlFromOxm.process();
- customer = htmlFromOxm.getJavaTypeElementSwagger("Customer");
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testProcessJavaTypeElement() {
+ String target = "Element=java-type/Customer";
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ Element customer = null;
+ try {
+ htmlFromOxm.setXmlVersion(testXML, v);
+ htmlFromOxm.process();
+ customer = htmlFromOxm.getJavaTypeElementSwagger("Customer");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ logger.debug("Element:");
+ logger.debug("Element=" + customer.getNodeName() + "/" + customer.getAttribute("name"));
+ assertThat("Element=" + customer.getNodeName() + "/" + customer.getAttribute("name"),
+ is(target));
}
- logger.debug("Element:");
- logger.debug("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"));
- assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target)); }
- public String HTMLresult() {
- return HTMLresult(0);
- }
+ public String HTMLresult() {
+ return HTMLresult(0);
+ }
- public String HTMLresult(int sbopt) {
- StringBuilder sb = new StringBuilder(32368);
- sb.append(HTMLheader());
- sb.append(HTMLdefs(sbopt));
- return sb.toString();
- }
+ public String HTMLresult(int sbopt) {
+ StringBuilder sb = new StringBuilder(32368);
+ sb.append(HTMLheader());
+ sb.append(HTMLdefs(sbopt));
+ return sb.toString();
+ }
- public String HTMLheader() {
- StringBuilder sb = new StringBuilder(1500);
- sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://org.onap.aai.inventory/v11\" xmlns:tns=\"http://org.onap.aai.inventory/v11\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"" + OxmFileProcessor.LINE_SEPARATOR + "xmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\"" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" jaxb:version=\"2.1\"" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" xmlns:annox=\"http://annox.dev.java.net\"" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" jaxb:extensionBindingPrefixes=\"annox\">" + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
- return sb.toString();
- }
+ public String HTMLheader() {
+ StringBuilder sb = new StringBuilder(1500);
+ sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ "<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://org.onap.aai.inventory/v11\" xmlns:tns=\"http://org.onap.aai.inventory/v11\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
+ + OxmFileProcessor.LINE_SEPARATOR + "xmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\""
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" jaxb:version=\"2.1\"" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " xmlns:annox=\"http://annox.dev.java.net\"" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" jaxb:extensionBindingPrefixes=\"annox\">"
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ return sb.toString();
+ }
- public String HTMLdefs() {
- return HTMLdefs(0);
- }
- public String HTMLdefs(int sbopt) {
- StringBuilder sb = new StringBuilder(1500);
- sb.append(" <xs:element name=\"service-subscription\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Object that group service instances.\",indexedProps=\"service-type\",dependentOn=\"customer\",container=\"service-subscriptions\",crossEntityReference=\"service-instance,service-type\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"service-type\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Value defined by orchestration to identify this service.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"temp-ub-sub-account-id\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"This property will be deleted from A&amp;AI in the near future. Only stop gap solution.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"service-subscriptions\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Collection of objects that group service instances.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element ref=\"tns:service-subscription\" minOccurs=\"0\" maxOccurs=\"5000\"/>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"customer\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- if ( sbopt == 0 ) {
- sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- } else {
- sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-type,subscriber-name,global-customer-id\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
+ public String HTMLdefs() {
+ return HTMLdefs(0);
}
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"global-customer-id\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Global customer id used across to uniquely identify customer.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"subscriber-name\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber name, an alternate way to retrieve a customer.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- if ( sbopt == 0 ) {
- sb.append(" <xs:element name=\"subscriber-type\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- } else {
- sb.append(" <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"subscriber-type\" type=\"xs:string\" minOccurs=\"0\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ public String HTMLdefs(int sbopt) {
+ StringBuilder sb = new StringBuilder(1500);
+ sb.append(" <xs:element name=\"service-subscription\">" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Object that group service instances.\",indexedProps=\"service-type\",dependentOn=\"customer\",container=\"service-subscriptions\",crossEntityReference=\"service-instance,service-type\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:element name=\"service-type\" type=\"xs:string\" minOccurs=\"0\">"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Value defined by orchestration to identify this service.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <xs:element name=\"temp-ub-sub-account-id\" type=\"xs:string\" minOccurs=\"0\">"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"This property will be deleted from A&amp;AI in the near future. Only stop gap solution.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <xs:element name=\"service-subscriptions\">" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Collection of objects that group service instances.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <xs:element ref=\"tns:service-subscription\" minOccurs=\"0\" maxOccurs=\"5000\"/>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:element name=\"customer\">" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ if (sbopt == 0) {
+ sb.append(
+ " <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ } else {
+ sb.append(
+ " <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-type,subscriber-name,global-customer-id\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ }
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <xs:element name=\"global-customer-id\" type=\"xs:string\" minOccurs=\"0\">"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(isKey=true,description=\"Global customer id used across to uniquely identify customer.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:element name=\"subscriber-name\" type=\"xs:string\" minOccurs=\"0\">"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber name, an alternate way to retrieve a customer.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ if (sbopt == 0) {
+ sb.append(
+ " <xs:element name=\"subscriber-type\" type=\"xs:string\" minOccurs=\"0\">"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ } else {
+ sb.append(
+ " <xs:element name=\"resource-version\" type=\"xs:string\" minOccurs=\"0\">"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <xs:element name=\"subscriber-type\" type=\"xs:string\" minOccurs=\"0\">"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"field\">@org.onap.aai.annotations.Metadata(description=\"Subscriber type, a way to provide VID with only the INFRA customers.\",defaultValue=\"CUST\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+
+ }
+ sb.append(" <xs:element ref=\"tns:service-subscriptions\" minOccurs=\"0\"/>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:element name=\"customers\">" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Collection of customer identifiers to provide linkage back to BSS information.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:element ref=\"tns:customer\" minOccurs=\"0\" maxOccurs=\"5000\"/>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:element name=\"business\">" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Namespace for business related constructs\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:element ref=\"tns:customers\" minOccurs=\"0\"/>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:element name=\"inventory\">" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" <xs:element ref=\"tns:business\" minOccurs=\"0\"/>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append("</xs:schema>" + OxmFileProcessor.LINE_SEPARATOR);
+ return sb.toString();
}
- sb.append(" <xs:element ref=\"tns:service-subscriptions\" minOccurs=\"0\"/>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"customers\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Collection of customer identifiers to provide linkage back to BSS information.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element ref=\"tns:customer\" minOccurs=\"0\" maxOccurs=\"5000\"/>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"business\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <annox:annotate target=\"class\">@org.onap.aai.annotations.Metadata(description=\"Namespace for business related constructs\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element ref=\"tns:customers\" minOccurs=\"0\"/>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element name=\"inventory\">" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" <xs:element ref=\"tns:business\" minOccurs=\"0\"/>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append("</xs:schema>" + OxmFileProcessor.LINE_SEPARATOR);
- return sb.toString();
- }
}
-
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodeGetOperationTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodeGetOperationTest.java
index 8ecc8b5..fc75150 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodeGetOperationTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodeGetOperationTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,8 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Vector;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,82 +35,86 @@ import org.junit.runners.Parameterized.Parameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Vector;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
@RunWith(Parameterized.class)
public class NodeGetOperationTest {
- private static final Logger logger = LoggerFactory.getLogger("NodeGetOperationTest.class");
- private String useOpId;
- private String xmlRootElementName;
- private String tag;
- private String path;
- private String pathParams;
- private String result;
+ private static final Logger logger = LoggerFactory.getLogger("NodeGetOperationTest.class");
+ private String useOpId;
+ private String xmlRootElementName;
+ private String tag;
+ private String path;
+ private String pathParams;
+ private String result;
- @Parameters
- public static Collection<String []> testConditions() {
- String inputs [][] = {
- {"NetworkGenericVnfsGenericVnf","generic-vnf","Network","/network/generic-vnfs/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"," /nodes/generic-vnfs/generic-vnf/{vnf-id}:\n get:\n tags:\n - Operations\n summary: returns generic-vnf\n description: returns generic-vnf\n operationId: getNetworkGenericVnfsGenericVnf\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/definitions/generic-vnf\"\n \"default\":\n null\n parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"},
- {"GenericVnf","generic-vnf","","/Network/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",""},
- {"CloudInfrastructurePserversPserverPInterfaces","p-interfaces","CloudInfrastructure","/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces"," - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__"," /nodes/p-interfaces?parameter=value[&parameter2=value2]:\n get:\n tags:\n - Operations\n summary: returns p-interfaces\n description: returns p-interfaces\n operationId: getCloudInfrastructurePserversPserverPInterfaces\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/definitions/p-interfaces\"\n \"default\":\n null\n parameters:\n - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__\n - name: interface-name\n in: query\n description:\n required: false\n type: string - name: prov-status\n in: query\n description:\n required: false\n type: string"},
- // {"","ctag-pool","","","",""},
-// {"","pserver","","","",""},
-// {"","oam-network","","","",""},
-// {"","dvs-switch","","","",""},
-// {"","availability-zone","","","",""}
- };
- return Arrays.asList(inputs);
- }
+ @Parameters
+ public static Collection<String[]> testConditions() {
+ String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
+ "/network/generic-vnfs/generic-vnf/{vnf-id}",
+ " - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",
+ " /nodes/generic-vnfs/generic-vnf/{vnf-id}:\n get:\n tags:\n - Operations\n summary: returns generic-vnf\n description: returns generic-vnf\n operationId: getNetworkGenericVnfsGenericVnf\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/definitions/generic-vnf\"\n \"default\":\n null\n parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"},
+ {"GenericVnf", "generic-vnf", "", "/Network/generic-vnf/{vnf-id}",
+ " - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",
+ ""},
+ {"CloudInfrastructurePserversPserverPInterfaces", "p-interfaces", "CloudInfrastructure",
+ "/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces",
+ " - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",
+ " /nodes/p-interfaces?parameter=value[&parameter2=value2]:\n get:\n tags:\n - Operations\n summary: returns p-interfaces\n description: returns p-interfaces\n operationId: getCloudInfrastructurePserversPserverPInterfaces\n produces:\n - application/json\n - application/xml\n responses:\n \"200\":\n description: successful operation\n schema:\n $ref: \"#/definitions/p-interfaces\"\n \"default\":\n null\n parameters:\n - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__\n - name: interface-name\n in: query\n description:\n required: false\n type: string - name: prov-status\n in: query\n description:\n required: false\n type: string"},
+ // {"","ctag-pool","","","",""},
+ // {"","pserver","","","",""},
+ // {"","oam-network","","","",""},
+ // {"","dvs-switch","","","",""},
+ // {"","availability-zone","","","",""}
+ };
+ return Arrays.asList(inputs);
+ }
+
+ public NodeGetOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
+ String pathParams, String result) {
+ super();
+ this.useOpId = useOpId;
+ this.xmlRootElementName = xmlRootElementName;
+ this.tag = tag;
+ this.path = path;
+ this.pathParams = pathParams;
+ this.result = result;
+ }
- public NodeGetOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
- super();
- this.useOpId = useOpId;
- this.xmlRootElementName = xmlRootElementName;
- this.tag = tag;
- this.path = path;
- this.pathParams=pathParams;
- this.result = result;
- }
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- String container = "p-interfaces";
- String queryProps[] = {
- " - name: interface-name\n in: query\n description:\n required: false\n type: string",
- " - name: prov-status\n in: query\n description:\n required: false\n type: string"
- };
- Vector<String> containerProps = new Vector<String>();
- for(String prop : queryProps) {
- containerProps.add(prop);
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ String container = "p-interfaces";
+ String queryProps[] = {
+ " - name: interface-name\n in: query\n description:\n required: false\n type: string",
+ " - name: prov-status\n in: query\n description:\n required: false\n type: string"};
+ Vector<String> containerProps = new Vector<String>();
+ for (String prop : queryProps) {
+ containerProps.add(prop);
+ }
+ NodeGetOperation.addContainerProps(container, containerProps);
}
- NodeGetOperation.addContainerProps(container, containerProps);
- }
- @Test
- public void testAddContainerProps() {
- String container = this.xmlRootElementName;
- String prop = " - name: "+container+"\n in: query\n description:\n required: false\n type: string";
- Vector<String> queryProps = new Vector<String>();
- queryProps.add(prop);
- String props=null;
- for(String p : queryProps) {
- props += "qProp="+p+"\n";
-// logger.debug("qProp="+p);
+ @Test
+ public void testAddContainerProps() {
+ String container = this.xmlRootElementName;
+ String prop = " - name: " + container
+ + "\n in: query\n description:\n required: false\n type: string";
+ Vector<String> queryProps = new Vector<String>();
+ queryProps.add(prop);
+ String props = null;
+ for (String p : queryProps) {
+ props += "qProp=" + p + "\n";
+ // logger.debug("qProp="+p);
+ }
+ // logger.debug("Done="+this.xmlRootElementName);
+ NodeGetOperation.addContainerProps(container, queryProps);
+ assertThat(props + "Done=" + this.xmlRootElementName,
+ NodeGetOperation.containers.get(container).get(0), is(prop));
}
-// logger.debug("Done="+this.xmlRootElementName);
- NodeGetOperation.addContainerProps(container, queryProps);
- assertThat(props+"Done="+this.xmlRootElementName,NodeGetOperation.containers.get(container).get(0), is(prop));
- }
- @Test
- public void testToString() {
- NodeGetOperation get = new NodeGetOperation(useOpId, xmlRootElementName, tag, path, pathParams);
- String modResult = get.toString();
- assertThat(modResult, is(this.result));
- }
+ @Test
+ public void testToString() {
+ NodeGetOperation get =
+ new NodeGetOperation(useOpId, xmlRootElementName, tag, path, pathParams);
+ String modResult = get.toString();
+ assertThat(modResult, is(this.result));
+ }
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXMTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXMTest.java
index ed403e0..468de16 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXMTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXMTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,8 +17,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -39,232 +52,229 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.w3c.dom.Element;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {
- SchemaVersions.class,
- SchemaLocationsBean.class,
- TestUtilConfigTranslatorforEdges.class,
- EdgeIngestor.class,
- NodeIngestor.class,
- SwaggerGenerationConfiguration.class
+@ContextConfiguration(
+ classes = {SchemaVersions.class, SchemaLocationsBean.class,
+ TestUtilConfigTranslatorforEdges.class, EdgeIngestor.class, NodeIngestor.class,
+ SwaggerGenerationConfiguration.class
-})
-@TestPropertySource(properties = {
- "schema.uri.base.path = /aai",
- "schema.xsd.maxoccurs = 5000"
-})
+ })
+@TestPropertySource(properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000"})
public class NodesYAMLfromOXMTest {
-//public class NodesYAMLfromOXMTest extends AAISetup {
- private static final Logger logger = LoggerFactory.getLogger("NodesYAMLfromOXMTest.class");
- private static final String OXMFILENAME = "src/test/resources/oxm/business_v11.xml";
- private static final String EDGEFILENAME = "src/test/resources/dbedgerules/EdgeDescriptionRules_test.json";
- public static AnnotationConfigApplicationContext ctx = null;
- private static String testXML;
+ // public class NodesYAMLfromOXMTest extends AAISetup {
+ private static final Logger logger = LoggerFactory.getLogger("NodesYAMLfromOXMTest.class");
+ private static final String OXMFILENAME = "src/test/resources/oxm/business_v11.xml";
+ private static final String EDGEFILENAME =
+ "src/test/resources/dbedgerules/EdgeDescriptionRules_test.json";
+ public static AnnotationConfigApplicationContext ctx = null;
+ private static String testXML;
- @Autowired
- NodesYAMLfromOXM nodesYamlFromOxm;
- @Autowired
+ @Autowired
+ NodesYAMLfromOXM nodesYamlFromOxm;
+ @Autowired
SchemaVersions schemaVersions;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
- XSDElementTest x = new XSDElementTest();
- x.setUp();
- testXML = x.testXML;
- logger.debug(testXML);
- BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
- bw.write(testXML);
- bw.close();
- BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
- bw1.write(YAMLfromOXMTest.EdgeDefs());
- bw1.close();
+ XSDElementTest x = new XSDElementTest();
+ x.setUp();
+ testXML = x.testXML;
+ logger.debug(testXML);
+ BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
+ bw.write(testXML);
+ bw.close();
+ BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
+ bw1.write(YAMLfromOXMTest.EdgeDefs());
+ bw1.close();
+ }
- }
-
- @Before
- public void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
- NodeGetOperation.checklist.clear();
- XSDElementTest x = new XSDElementTest();
- x.setUp();
- testXML = x.testXML;
+ NodeGetOperation.checklist.clear();
+ XSDElementTest x = new XSDElementTest();
+ x.setUp();
+ testXML = x.testXML;
- logger.debug(testXML);
- }
+ logger.debug(testXML);
+ }
- @Test
- public void testGetDocumentHeader() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String header = null;
- try {
- nodesYamlFromOxm.setXmlVersion(testXML, v);
- nodesYamlFromOxm.process();
- header = nodesYamlFromOxm.getDocumentHeader();
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testGetDocumentHeader() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String header = null;
+ try {
+ nodesYamlFromOxm.setXmlVersion(testXML, v);
+ nodesYamlFromOxm.process();
+ header = nodesYamlFromOxm.getDocumentHeader();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("Header:\n" + header, header, is(YAMLheader()));
}
- assertThat("Header:\n"+header,header, is(YAMLheader()));
- }
- @Test
- public void testProcess() {
+ @Test
+ public void testProcess() {
+
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String fileContent = null;
+ try {
+ nodesYamlFromOxm.setXmlVersion(testXML, v);
+ fileContent = nodesYamlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("FileContent-I:\n" + fileContent, fileContent, is(YAMLresult()));
+ }
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String fileContent = null;
- try {
- nodesYamlFromOxm.setXmlVersion(testXML, v);
- fileContent = nodesYamlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testNodesYAMLfromOXMFileVersionFile() throws IOException {
+ String outfileName = "testXML.xml";
+ File XMLfile = new File(outfileName);
+ XMLfile.createNewFile();
+ BufferedWriter bw = null;
+ Charset charset = Charset.forName("UTF-8");
+ Path path = Paths.get(outfileName);
+ bw = Files.newBufferedWriter(path, charset);
+ bw.write(testXML);
+ bw.close();
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String fileContent = null;
+ try {
+ nodesYamlFromOxm.setXmlVersion(testXML, v);
+ fileContent = nodesYamlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ XMLfile.delete();
+ assertThat("FileContent:\n" + fileContent, fileContent, is(YAMLresult()));
}
- assertThat("FileContent-I:\n"+fileContent,fileContent, is(YAMLresult()));
- }
- @Test
- public void testNodesYAMLfromOXMFileVersionFile() throws IOException {
- String outfileName = "testXML.xml";
- File XMLfile = new File(outfileName);
- XMLfile.createNewFile();
- BufferedWriter bw = null;
- Charset charset = Charset.forName("UTF-8");
- Path path = Paths.get(outfileName);
- bw = Files.newBufferedWriter(path, charset);
- bw.write(testXML);
- bw.close();
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String fileContent = null;
- try {
- nodesYamlFromOxm.setXmlVersion(testXML, v);
- fileContent = nodesYamlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testNodesYAMLfromOXMStringVersionFile() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String fileContent = null;
+ try {
+ nodesYamlFromOxm.setXmlVersion(testXML, v);
+ fileContent = nodesYamlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("FileContent-II:\n" + fileContent, fileContent, is(YAMLresult()));
}
- XMLfile.delete();
- assertThat("FileContent:\n"+fileContent,fileContent, is(YAMLresult()));
- }
- @Test
- public void testNodesYAMLfromOXMStringVersionFile() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String fileContent = null;
- try {
- nodesYamlFromOxm.setXmlVersion(testXML, v);
- fileContent = nodesYamlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testAppendDefinitions() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String definitions = null;
+ try {
+ nodesYamlFromOxm.setXmlVersion(testXML, v);
+ nodesYamlFromOxm.process();
+ definitions = nodesYamlFromOxm.appendDefinitions();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("Definitions:\n" + definitions, definitions, is(YAMLgetDefs()));
}
- assertThat("FileContent-II:\n"+fileContent,fileContent, is(YAMLresult()));
- }
- @Test
- public void testAppendDefinitions() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String definitions = null;
- try {
- nodesYamlFromOxm.setXmlVersion(testXML, v);
- nodesYamlFromOxm.process();
- definitions = nodesYamlFromOxm.appendDefinitions();
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testGetXMLRootElementName() {
+ String target = "RootElement=customer";
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ Element customer = null;
+ String root = null;
+ try {
+ nodesYamlFromOxm.setXmlVersion(testXML, v);
+ nodesYamlFromOxm.process();
+ customer = nodesYamlFromOxm.getJavaTypeElementSwagger("Customer");
+ root = nodesYamlFromOxm.getXMLRootElementName(customer);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("RootElement=" + root, is(target));
}
- assertThat("Definitions:\n"+definitions,definitions, is(YAMLgetDefs()));
- }
- @Test
- public void testGetXMLRootElementName() {
- String target = "RootElement=customer";
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- Element customer = null;
- String root = null;
- try {
- nodesYamlFromOxm.setXmlVersion(testXML, v);
- nodesYamlFromOxm.process();
- customer = nodesYamlFromOxm.getJavaTypeElementSwagger("Customer");
- root = nodesYamlFromOxm.getXMLRootElementName(customer);
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testGetXmlRootElementName() {
+ String target = "RootElement=customer";
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String root = null;
+ try {
+ nodesYamlFromOxm.setXmlVersion(testXML, v);
+ nodesYamlFromOxm.process();
+ root = nodesYamlFromOxm.getXmlRootElementName("Customer");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("RootElement=" + root, is(target));
}
- assertThat("RootElement="+root, is(target));
- }
- @Test
- public void testGetXmlRootElementName() {
- String target = "RootElement=customer";
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String root = null;
- try {
- nodesYamlFromOxm.setXmlVersion(testXML, v);
- nodesYamlFromOxm.process();
- root = nodesYamlFromOxm.getXmlRootElementName("Customer");
- } catch(Exception e) {
- e.printStackTrace();
+ @Test
+ public void testGetJavaTypeElementSwagger() {
+ String target = "Element=java-type/Customer";
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ Element customer = null;
+ try {
+ nodesYamlFromOxm.setXmlVersion(testXML, v);
+ nodesYamlFromOxm.process();
+ customer = nodesYamlFromOxm.getJavaTypeElementSwagger("Customer");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("Element=" + customer.getNodeName() + "/" + customer.getAttribute("name"),
+ is(target));
}
- assertThat("RootElement="+root, is(target));
- }
- @Test
- public void testGetJavaTypeElementSwagger() {
- String target = "Element=java-type/Customer";
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- Element customer = null;
- try {
- nodesYamlFromOxm.setXmlVersion(testXML, v);
- nodesYamlFromOxm.process();
- customer = nodesYamlFromOxm.getJavaTypeElementSwagger("Customer");
- } catch(Exception e) {
- e.printStackTrace();
+ public String YAMLresult() {
+ StringBuilder sb = new StringBuilder(32368);
+ sb.append(YAMLheader());
+ sb.append(YAMLops());
+ sb.append(YAMLgetDefs());
+ return sb.toString();
}
- assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target));
- }
- public String YAMLresult() {
- StringBuilder sb = new StringBuilder(32368);
- sb.append(YAMLheader());
- sb.append(YAMLops());
- sb.append(YAMLgetDefs());
- return sb.toString();
- }
- public String YAMLheader() {
- StringBuilder sb = new StringBuilder(1500);
+ public String YAMLheader() {
+ StringBuilder sb = new StringBuilder(1500);
sb.append("swagger: \"2.0\"\n");
sb.append("info:" + OxmFileProcessor.LINE_SEPARATOR);
sb.append(" description: |\n");
sb.append("\n");
- sb.append(" [Differences versus the previous schema version](apidocs/aai/aai_swagger_v11.diff)" + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
- sb.append(" Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
- sb.append(" Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ sb.append(
+ " [Differences versus the previous schema version](apidocs/aai/aai_swagger_v11.diff)"
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ sb.append(
+ " Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved."
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ sb.append(
+ " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License."
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
sb.append(" You may obtain a copy of the License at\n");
sb.append("\n");
- sb.append(" (https://creativecommons.org/licenses/by/4.0/)" + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
- sb.append(" Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."+ OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
- sb.append(" This document is best viewed with Firefox or Chrome. Nodes can be found by opening the models link below and finding the node-type. Edge definitions can be found with the node definitions." + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" (https://creativecommons.org/licenses/by/4.0/)"
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ sb.append(
+ " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ sb.append(
+ " This document is best viewed with Firefox or Chrome. Nodes can be found by opening the models link below and finding the node-type. Edge definitions can be found with the node definitions."
+ + OxmFileProcessor.LINE_SEPARATOR);
sb.append(" version: \"v11\"" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" title: Active and Available Inventory REST API" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " title: Active and Available Inventory REST API" + OxmFileProcessor.LINE_SEPARATOR);
sb.append(" license:" + OxmFileProcessor.LINE_SEPARATOR);
sb.append(" name: Apache 2.0" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html"
+ + OxmFileProcessor.LINE_SEPARATOR);
sb.append(" contact:" + OxmFileProcessor.LINE_SEPARATOR);
sb.append(" name: n/a" + OxmFileProcessor.LINE_SEPARATOR);
sb.append(" url: n/a" + OxmFileProcessor.LINE_SEPARATOR);
@@ -274,203 +284,219 @@ public class NodesYAMLfromOXMTest {
sb.append("schemes:" + OxmFileProcessor.LINE_SEPARATOR);
sb.append(" - https\n");
sb.append("paths:" + OxmFileProcessor.LINE_SEPARATOR);
- return sb.toString();
- }
+ return sb.toString();
+ }
- public String YAMLops() {
- StringBuilder sb = new StringBuilder(16384);
- sb.append(" /nodes/customers/customer/{global-customer-id}:\n");
- sb.append(" get:\n");
- sb.append(" tags:\n");
- sb.append(" - Operations\n");
- sb.append(" summary: returns customer\n");
- sb.append(" description: returns customer\n");
- sb.append(" operationId: getBusinessCustomersCustomer\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"200\":\n");
- sb.append(" description: successful operation\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/customer\"\n");
- sb.append(" \"default\":\n");
- sb.append(" null\n parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: path\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
- sb.append(" /nodes/customers?parameter=value[&parameter2=value2]:\n");
- sb.append(" get:\n");
- sb.append(" tags:\n");
- sb.append(" - Operations\n");
- sb.append(" summary: returns customers\n");
- sb.append(" description: returns customers\n");
- sb.append(" operationId: getBusinessCustomers\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"200\":\n");
- sb.append(" description: successful operation\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/customers\"\n");
- sb.append(" \"default\":\n");
- sb.append(" null\n parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: query\n");
- sb.append(" description: n/a\n");
- sb.append(" required: false\n");
- sb.append(" type: string\n");
- sb.append(" - name: subscriber-name\n");
- sb.append(" in: query\n");
- sb.append(" description: n/a\n");
- sb.append(" required: false\n");
- sb.append(" type: string\n");
- sb.append(" - name: subscriber-type\n");
- sb.append(" in: query\n");
- sb.append(" description: n/a\n");
- sb.append(" required: false\n");
- sb.append(" type: string\n");
- sb.append(" /nodes/service-subscriptions/service-subscription/{service-type}:\n");
- sb.append(" get:\n");
- sb.append(" tags:\n");
- sb.append(" - Operations\n");
- sb.append(" summary: returns service-subscription\n");
- sb.append(" description: returns service-subscription\n");
- sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"200\":\n");
- sb.append(" description: successful operation\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/service-subscription\"\n");
- sb.append(" \"default\":\n");
- sb.append(" null\n parameters:\n");
- sb.append(" - name: service-type\n");
- sb.append(" in: path\n");
- sb.append(" description: Value defined by orchestration to identify this service.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __SERVICE-TYPE__\n");
- sb.append(" /nodes/service-subscriptions?parameter=value[&parameter2=value2]:\n");
- sb.append(" get:\n");
- sb.append(" tags:\n");
- sb.append(" - Operations\n");
- sb.append(" summary: returns service-subscriptions\n");
- sb.append(" description: returns service-subscriptions\n");
- sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"200\":\n");
- sb.append(" description: successful operation\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/service-subscriptions\"\n");
- sb.append(" \"default\":\n");
- sb.append(" null\n parameters:\n");
- sb.append(" - name: service-type\n");
- sb.append(" in: query\n");
- sb.append(" description: n/a\n");
- sb.append(" required: false\n");
- sb.append(" type: string\n");
- return sb.toString();
- }
+ public String YAMLops() {
+ StringBuilder sb = new StringBuilder(16384);
+ sb.append(" /nodes/customers/customer/{global-customer-id}:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Operations\n");
+ sb.append(" summary: returns customer\n");
+ sb.append(" description: returns customer\n");
+ sb.append(" operationId: getBusinessCustomersCustomer\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/customer\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null\n parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" /nodes/customers?parameter=value[&parameter2=value2]:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Operations\n");
+ sb.append(" summary: returns customers\n");
+ sb.append(" description: returns customers\n");
+ sb.append(" operationId: getBusinessCustomers\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/customers\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null\n parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: query\n");
+ sb.append(" description: n/a\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ sb.append(" - name: subscriber-name\n");
+ sb.append(" in: query\n");
+ sb.append(" description: n/a\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ sb.append(" - name: subscriber-type\n");
+ sb.append(" in: query\n");
+ sb.append(" description: n/a\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ sb.append(" /nodes/service-subscriptions/service-subscription/{service-type}:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Operations\n");
+ sb.append(" summary: returns service-subscription\n");
+ sb.append(" description: returns service-subscription\n");
+ sb.append(
+ " operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/service-subscription\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null\n parameters:\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Value defined by orchestration to identify this service.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __SERVICE-TYPE__\n");
+ sb.append(" /nodes/service-subscriptions?parameter=value[&parameter2=value2]:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Operations\n");
+ sb.append(" summary: returns service-subscriptions\n");
+ sb.append(" description: returns service-subscriptions\n");
+ sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/service-subscriptions\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null\n parameters:\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: query\n");
+ sb.append(" description: n/a\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ return sb.toString();
+ }
- public String YAMLgetDefs() {
- StringBuilder sb = new StringBuilder(8092);
- sb.append("definitions:\n");
- sb.append(" business:\n");
- sb.append(" description: |\n");
- sb.append(" Namespace for business related constructs\n");
- sb.append(" properties:\n");
- sb.append(" customers:\n");
- sb.append(" type: array\n");
- sb.append(" items:\n");
- sb.append(" $ref: \"#/definitions/customer\"\n");
- sb.append(" customer:\n");
- sb.append(" description: |\n");
- sb.append(" customer identifiers to provide linkage back to BSS information.\n");
- sb.append(" ###### Related Nodes\n");
- sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
- sb.append("\n");
- sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
- sb.append(" required:\n");
- sb.append(" - global-customer-id\n");
- sb.append(" - subscriber-name\n");
- sb.append(" - subscriber-type\n");
- sb.append(" properties:\n");
- sb.append(" global-customer-id:\n");
- sb.append(" type: string\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" subscriber-name:\n");
- sb.append(" type: string\n");
- sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
- sb.append(" subscriber-type:\n");
- sb.append(" type: string\n");
- sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
- sb.append(" resource-version:\n");
- sb.append(" type: string\n");
- sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
- sb.append(" service-subscriptions:\n");
- sb.append(" type: array\n");
- sb.append(" items:\n");
- sb.append(" $ref: \"#/definitions/service-subscription\"\n");
- sb.append(" customers:\n");
- sb.append(" description: |\n");
- sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
- sb.append(" properties:\n");
- sb.append(" customer:\n");
- sb.append(" type: array\n");
- sb.append(" items: \n");
- sb.append(" $ref: \"#/definitions/customer\"\n");
- sb.append(" inventory:\n");
- sb.append(" properties:\n");
- sb.append(" business:\n");
- sb.append(" type: object\n");
- sb.append(" $ref: \"#/definitions/business\"\n");
- sb.append(" nodes:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" properties:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" type: array" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" items:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" $ref: \"#/definitions/inventory-item-data\"" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" service-subscription:\n");
- sb.append(" description: |\n");
- sb.append(" Object that group service instances.\n");
- sb.append(" ###### Related Nodes\n");
- sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
- sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
- sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
- sb.append("\n");
- sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
- sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
- sb.append(" required:\n");
- sb.append(" - service-type\n");
- sb.append(" properties:\n");
- sb.append(" service-type:\n");
- sb.append(" type: string\n");
- sb.append(" description: Value defined by orchestration to identify this service.\n");
- sb.append(" temp-ub-sub-account-id:\n");
- sb.append(" type: string\n");
- sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
- sb.append(" resource-version:\n");
- sb.append(" type: string\n");
- sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
- sb.append(" service-subscriptions:\n");
- sb.append(" description: |\n");
- sb.append(" Collection of objects that group service instances.\n");
- sb.append(" properties:\n");
- sb.append(" service-subscription:\n");
- sb.append(" type: array\n");
- sb.append(" items: \n");
- sb.append(" $ref: \"#/definitions/service-subscription\"\n");
- return sb.toString();
- }
+ public String YAMLgetDefs() {
+ StringBuilder sb = new StringBuilder(8092);
+ sb.append("definitions:\n");
+ sb.append(" business:\n");
+ sb.append(" description: |\n");
+ sb.append(" Namespace for business related constructs\n");
+ sb.append(" properties:\n");
+ sb.append(" customers:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/definitions/customer\"\n");
+ sb.append(" customer:\n");
+ sb.append(" description: |\n");
+ sb.append(" customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(
+ " - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
+ sb.append(" required:\n");
+ sb.append(" - global-customer-id\n");
+ sb.append(" - subscriber-name\n");
+ sb.append(" - subscriber-type\n");
+ sb.append(" properties:\n");
+ sb.append(" global-customer-id:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" subscriber-name:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Subscriber name, an alternate way to retrieve a customer.\n");
+ sb.append(" subscriber-type:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
+ sb.append(" resource-version:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
+ sb.append(" service-subscriptions:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/definitions/service-subscription\"\n");
+ sb.append(" customers:\n");
+ sb.append(" description: |\n");
+ sb.append(
+ " Collection of customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" properties:\n");
+ sb.append(" customer:\n");
+ sb.append(" type: array\n");
+ sb.append(" items: \n");
+ sb.append(" $ref: \"#/definitions/customer\"\n");
+ sb.append(" inventory:\n");
+ sb.append(" properties:\n");
+ sb.append(" business:\n");
+ sb.append(" type: object\n");
+ sb.append(" $ref: \"#/definitions/business\"\n");
+ sb.append(" nodes:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" properties:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" type: array" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" items:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" $ref: \"#/definitions/inventory-item-data\""
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" service-subscription:\n");
+ sb.append(" description: |\n");
+ sb.append(" Object that group service instances.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(
+ " - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
+ sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
+ sb.append(
+ " - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(
+ " -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
+ sb.append(
+ " -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
+ sb.append(" required:\n");
+ sb.append(" - service-type\n");
+ sb.append(" properties:\n");
+ sb.append(" service-type:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Value defined by orchestration to identify this service.\n");
+ sb.append(" temp-ub-sub-account-id:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
+ sb.append(" resource-version:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
+ sb.append(" service-subscriptions:\n");
+ sb.append(" description: |\n");
+ sb.append(" Collection of objects that group service instances.\n");
+ sb.append(" properties:\n");
+ sb.append(" service-subscription:\n");
+ sb.append(" type: array\n");
+ sb.append(" items: \n");
+ sb.append(" $ref: \"#/definitions/service-subscription\"\n");
+ return sb.toString();
+ }
}
-
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java
index 098b33b..d939a74 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,8 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -26,58 +33,62 @@ import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.onap.aai.setup.SchemaVersion;
-import java.util.Arrays;
-import java.util.Collection;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
@RunWith(Parameterized.class)
public class PatchOperationTest {
- private String useOpId;
- private String xmlRootElementName;
- private String tag;
- private String path;
- private String pathParams;
- private String result;
- private static SchemaVersion v = new SchemaVersion("v16");
+ private String useOpId;
+ private String xmlRootElementName;
+ private String tag;
+ private String path;
+ private String pathParams;
+ private String result;
+ private static SchemaVersion v = new SchemaVersion("v16");
+
+ @Parameters
+ public static Collection<String[]> testConditions() {
+ String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
+ "/network/generic-vnfs/generic-vnf/{vnf-id}",
+ " - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",
+ " patch:\n tags:\n - Network\n summary: update an existing generic-vnf\n description: |\n Update an existing generic-vnf\n #\n Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n The PUT operation will entirely replace an existing object.\n The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n #\n Other differences between PUT and PATCH are:\n #\n - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n operationId: UpdateNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n produces:\n - application/json\n responses:\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__ - name: body\n in: body\n description: generic-vnf object that needs to be updated.[See Examples](apidocs/aai/relations/v16/NetworkGenericVnfsGenericVnf.json)\n required: true\n schema:\n $ref: \"#/definitions/generic-vnf\"\n"},
+ // if ( StringUtils.isEmpty(tag) )
+ {"GenericVnf", "generic-vnf", "", "/generic-vnf/{vnf-id}",
+ " - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",
+ ""},
+ // Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
+ {"CloudInfrastructurePserversPserverPInterfaces", "p-interfaces", "CloudInfrastructure",
+ "/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces",
+ " - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",
+ ""},
+ // {"","ctag-pool","","","",""},
+ // {"","pserver","","","",""},
+ // {"","oam-network","","","",""},
+ // {"","dvs-switch","","","",""},
+ // {"","availability-zone","","","",""}
+ };
+ return Arrays.asList(inputs);
+ }
- @Parameters
- public static Collection<String []> testConditions() {
- String inputs [][] = {
- {"NetworkGenericVnfsGenericVnf","generic-vnf","Network","/network/generic-vnfs/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"," patch:\n tags:\n - Network\n summary: update an existing generic-vnf\n description: |\n Update an existing generic-vnf\n #\n Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n The PUT operation will entirely replace an existing object.\n The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n #\n Other differences between PUT and PATCH are:\n #\n - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n operationId: UpdateNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n produces:\n - application/json\n responses:\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__ - name: body\n in: body\n description: generic-vnf object that needs to be updated.[See Examples](apidocs/aai/relations/v16/NetworkGenericVnfsGenericVnf.json)\n required: true\n schema:\n $ref: \"#/definitions/generic-vnf\"\n"},
-// if ( StringUtils.isEmpty(tag) )
- {"GenericVnf","generic-vnf","","/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",""},
-// Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
- {"CloudInfrastructurePserversPserverPInterfaces","p-interfaces","CloudInfrastructure","/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces"," - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",""},
- // {"","ctag-pool","","","",""},
-// {"","pserver","","","",""},
-// {"","oam-network","","","",""},
-// {"","dvs-switch","","","",""},
-// {"","availability-zone","","","",""}
- };
- return Arrays.asList(inputs);
- }
+ public PatchOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
+ String pathParams, String result) {
+ super();
+ this.useOpId = useOpId;
+ this.xmlRootElementName = xmlRootElementName;
+ this.tag = tag;
+ this.path = path;
+ this.pathParams = pathParams;
+ this.result = result;
+ }
- public PatchOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
- super();
- this.useOpId = useOpId;
- this.xmlRootElementName = xmlRootElementName;
- this.tag = tag;
- this.path = path;
- this.pathParams=pathParams;
- this.result = result;
- }
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
- }
+ }
- @Test
- public void testToString() {
- PatchOperation patch = new PatchOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai" );
- String modResult = patch.toString();
- assertThat(modResult, is(this.result));
- }
+ @Test
+ public void testToString() {
+ PatchOperation patch =
+ new PatchOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai");
+ String modResult = patch.toString();
+ assertThat(modResult, is(this.result));
+ }
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutOperationTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutOperationTest.java
index 7c5c00d..c5b9408 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutOperationTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutOperationTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,8 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -26,58 +33,64 @@ import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.onap.aai.setup.SchemaVersion;
-import java.util.Arrays;
-import java.util.Collection;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
@RunWith(Parameterized.class)
public class PutOperationTest {
- private String useOpId;
- private String xmlRootElementName;
- private String tag;
- private String path;
- private String pathParams;
- private String result;
- private static SchemaVersion v = new SchemaVersion("v14");
+ private String useOpId;
+ private String xmlRootElementName;
+ private String tag;
+ private String path;
+ private String pathParams;
+ private String result;
+ private static SchemaVersion v = new SchemaVersion("v14");
+
+ @Parameters
+ public static Collection<String[]> testConditions() {
+ String inputs[][] = {{"NetworkGenericVnfsGenericVnf", "generic-vnf", "Network",
+ "/network/generic-vnfs/generic-vnf/{vnf-id}",
+ " - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",
+ " put:\n tags:\n - Network\n summary: create or update an existing generic-vnf\n description: |\n Create or update an existing generic-vnf.\n #\n Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n operationId: createOrUpdateNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__ - name: body\n in: body\n description: generic-vnf object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/"
+ + v.toString()
+ + "/NetworkGenericVnfsGenericVnf.json)\n required: true\n schema:\n $ref: \"#/definitions/generic-vnf\"\n"},
+ // if ( StringUtils.isEmpty(tag) )
+ {"GenericVnf", "generic-vnf", "", "/generic-vnf/{vnf-id}",
+ " - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",
+ ""},
+ // Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
+ {"CloudInfrastructurePserversPserverPInterfaces", "p-interfaces", "CloudInfrastructure",
+ "/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces",
+ " - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",
+ ""},
+ // {"","ctag-pool","","","",""},
+ // {"","pserver","","","",""},
+ // {"","oam-network","","","",""},
+ // {"","dvs-switch","","","",""},
+ // {"","availability-zone","","","",""}
+ };
+ return Arrays.asList(inputs);
+ }
- @Parameters
- public static Collection<String []> testConditions() {
- String inputs [][] = {
- {"NetworkGenericVnfsGenericVnf","generic-vnf","Network","/network/generic-vnfs/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__"," put:\n tags:\n - Network\n summary: create or update an existing generic-vnf\n description: |\n Create or update an existing generic-vnf.\n #\n Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n operationId: createOrUpdateNetworkGenericVnfsGenericVnf\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null parameters:\n - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__ - name: body\n in: body\n description: generic-vnf object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/"+v.toString()+"/NetworkGenericVnfsGenericVnf.json)\n required: true\n schema:\n $ref: \"#/definitions/generic-vnf\"\n"},
-// if ( StringUtils.isEmpty(tag) )
- {"GenericVnf","generic-vnf","","/generic-vnf/{vnf-id}"," - name: vnf-id\n in: path\n description: Unique id of VNF. This is unique across the graph.\n required: true\n type: string\n example: __VNF-ID__",""},
-// Test: if ( !path.endsWith("/relationship") && !path.endsWith("}") )
- {"CloudInfrastructurePserversPserverPInterfaces","p-interfaces","CloudInfrastructure","/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces"," - name: hostname\n in: path\n description: Value from executing hostname on the compute node.\n required: true\n type: string\n example: __HOSTNAME__",""},
- // {"","ctag-pool","","","",""},
-// {"","pserver","","","",""},
-// {"","oam-network","","","",""},
-// {"","dvs-switch","","","",""},
-// {"","availability-zone","","","",""}
- };
- return Arrays.asList(inputs);
- }
+ public PutOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
+ String pathParams, String result) {
+ super();
+ this.useOpId = useOpId;
+ this.xmlRootElementName = xmlRootElementName;
+ this.tag = tag;
+ this.path = path;
+ this.pathParams = pathParams;
+ this.result = result;
+ }
- public PutOperationTest(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
- super();
- this.useOpId = useOpId;
- this.xmlRootElementName = xmlRootElementName;
- this.tag = tag;
- this.path = path;
- this.pathParams=pathParams;
- this.result = result;
- }
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
- }
+ }
- @Test
- public void testToString() {
- PutOperation put = new PutOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai");
- String modResult = put.toString();
- assertThat(modResult, is(this.result));
- }
+ @Test
+ public void testToString() {
+ PutOperation put =
+ new PutOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai");
+ String modResult = put.toString();
+ assertThat(modResult, is(this.result));
+ }
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutRelationPathSetTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutRelationPathSetTest.java
index 526c923..09a8dd4 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutRelationPathSetTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutRelationPathSetTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,8 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Ignore;
@@ -33,225 +42,168 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {
- SchemaVersions.class,
- EdgeIngestor.class
-})
-@TestPropertySource(properties = {
- "schema.uri.base.path = /aai"
-})
+@ContextConfiguration(classes = {SchemaVersions.class, EdgeIngestor.class})
+@TestPropertySource(properties = {"schema.uri.base.path = /aai"})
@Ignore("This test needs to get major rework done as it is written very poorly")
public class PutRelationPathSetTest {
- private static final String EDGEFILENAME = "src/test/resources/dbedgerules/EdgeDescriptionRules_test.json";
-
- private static String json;
- private SchemaVersion v ;
- private File relationsFile ;
- private String target = "/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/availability-zones/availability-zone/{availability-zone-name}/relationship-list/relationship";
- private String opId = "createOrUpdateCloudInfrastructureCloudRegionsCloudRegionAvailabilityZonesAvailabilityZoneRelationshipListRelationship";
- private String path = "/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/availability-zones/availability-zone/{availability-zone-name}/relationship-list/relationship";
- PutRelationPathSet prp = null;
- @Autowired
- SchemaVersions schemaVersions;
-
- @Autowired
- EdgeIngestor edgeIngestor;
-
-
- @Before
- public void setUpBeforeClass() throws Exception {
- v = schemaVersions.getDefaultVersion();
-
- relationsFile = new File(GenerateXsd.getYamlDir() + "/relations/" + v.toString()+"/createOrUpdateCloudInfrastructureCloudRegionsCloudRegionAvailabilityZonesAvailabilityZone.json");
- json = "{"
- + " \"rules\": ["
- + " {"
- + " \"from\": \"availability-zone\","
- + " \"to\": \"complex\","
- + " \"label\": \"org.onap.relationships.inventory.LocatedIn\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2ONE\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"this description\""
- + " },"
- + " {"
- + " \"from\": \"availability-zone\","
- + " \"to\": \"service-capability\","
- + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2MANY\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"availability-zone\","
- + " \"to\": \"cloud-region\","
- + " \"label\": \"org.onap.relationships.inventory.BelongsTo\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2ONE\","
- + " \"contains-other-v\": \"!${direction}\","
- + " \"delete-other-v\": \"!${direction}\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"NONE\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"ctag-pool\","
- + " \"to\": \"availability-zone\","
- + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2MANY\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"dvs-switch\","
- + " \"to\": \"availability-zone\","
- + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2MANY\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"generic-vnf\","
- + " \"to\": \"availability-zone\","
- + " \"label\": \"org.onap.relationships.inventory.Uses\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2MANY\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"${direction}\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"vf-module\","
- + " \"to\": \"vnfc\","
- + " \"label\": \"org.onap.relationships.inventory.Uses\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"ONE2MANY\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"${direction}\","
- + " \"prevent-delete\": \"${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"pserver\","
- + " \"to\": \"availability-zone\","
- + " \"label\": \"org.onap.relationships.inventory.MemberOf\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2ONE\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"${direction}\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " {"
- + " \"from\": \"vce\","
- + " \"to\": \"availability-zone\","
- + " \"label\": \"org.onap.relationships.inventory.Uses\","
- + " \"direction\": \"OUT\","
- + " \"multiplicity\": \"MANY2MANY\","
- + " \"contains-other-v\": \"NONE\","
- + " \"delete-other-v\": \"NONE\","
- + " \"SVC-INFRA\": \"NONE\","
- + " \"prevent-delete\": \"!${direction}\","
- + " \"default\": \"true\","
- + " \"description\":\"\""
- + " },"
- + " ]}";
-
- BufferedWriter bw = new BufferedWriter(new FileWriter(EDGEFILENAME));
- bw.write(json);
- bw.close();
-
- }
-
- @Before
- public void setUp() throws Exception {
-
- DeleteOperation.deletePaths.put("/cloud-infrastructure/pservers/pserver/{hostname}","pserver");
- DeleteOperation.deletePaths.put("/network/vces/vce/{vnf-id}","vce");
- DeleteOperation.deletePaths.put("/cloud-infrastructure/complexes/complex/{physical-location-id}","complex");
- DeleteOperation.deletePaths.put("/service-design-and-creation/service-capabilities/service-capability/{service-type}/{vnf-type}","service-capability");
- DeleteOperation.deletePaths.put("/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}","cloud-region");
- DeleteOperation.deletePaths.put("/network/generic-vnfs/generic-vnf/{vnf-id}","generic-vnf");
- DeleteOperation.deletePaths.put("/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/dvs-switches/dvs-switch/{switch-name}","dvs-switch");
- DeleteOperation.deletePaths.put("/cloud-infrastructure/complexes/complex/{physical-location-id}/ctag-pools/ctag-pool/{target-pe}/{availability-zone-name}","ctag-pool");
-
- DeleteOperation.deletePaths.put(path.replace("/relationship-list/relationship", ""),"availability-zone");
- PutRelationPathSet.add(opId, path);
- }
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- File edges = new File(EDGEFILENAME);
- edges.delete();
- }
- @Test
- public void testAdd() {
- PutRelationPathSet.add(opId, path);
- assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
- assertThat(PutRelationPathSet.putRelationPaths.get(opId), is(target));
- }
-
- @Test
- public void testPutRelationPathSet() {
-
- this.prp = new PutRelationPathSet(v);
- assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
- prp.generateRelations(edgeIngestor);
- assertTrue(this.relationsFile.exists());
- this.relationsFile.delete();
- }
-
- @Test
- public void testPutRelationPathSetStringString() {
- this.prp = new PutRelationPathSet(opId, path, v);
- assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
- }
-
- @Test
- public void testGenerateRelations() {
- PutRelationPathSet prp = new PutRelationPathSet(opId, "availability-zone", v);
- prp.generateRelations(edgeIngestor);
- assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
- assertThat(PutRelationPathSet.putRelationPaths.get(opId), is(target));
- assertTrue(this.relationsFile.exists());
-// this.relationsFile.delete();
- }
+ private static final String EDGEFILENAME =
+ "src/test/resources/dbedgerules/EdgeDescriptionRules_test.json";
+
+ private static String json;
+ private SchemaVersion v;
+ private File relationsFile;
+ private String target =
+ "/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/availability-zones/availability-zone/{availability-zone-name}/relationship-list/relationship";
+ private String opId =
+ "createOrUpdateCloudInfrastructureCloudRegionsCloudRegionAvailabilityZonesAvailabilityZoneRelationshipListRelationship";
+ private String path =
+ "/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/availability-zones/availability-zone/{availability-zone-name}/relationship-list/relationship";
+ PutRelationPathSet prp = null;
+ @Autowired
+ SchemaVersions schemaVersions;
+
+ @Autowired
+ EdgeIngestor edgeIngestor;
+
+ @Before
+ public void setUpBeforeClass() throws Exception {
+ v = schemaVersions.getDefaultVersion();
+
+ relationsFile = new File(GenerateXsd.getYamlDir() + "/relations/" + v.toString()
+ + "/createOrUpdateCloudInfrastructureCloudRegionsCloudRegionAvailabilityZonesAvailabilityZone.json");
+ json = "{" + " \"rules\": [" + " {" + " \"from\": \"availability-zone\","
+ + " \"to\": \"complex\","
+ + " \"label\": \"org.onap.relationships.inventory.LocatedIn\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\"," + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\"," + " \"description\":\"this description\""
+ + " }," + " {" + " \"from\": \"availability-zone\","
+ + " \"to\": \"service-capability\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\"," + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\"," + " \"description\":\"\"" + " }," + " {"
+ + " \"from\": \"availability-zone\"," + " \"to\": \"cloud-region\","
+ + " \"label\": \"org.onap.relationships.inventory.BelongsTo\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"!${direction}\","
+ + " \"delete-other-v\": \"!${direction}\"," + " \"SVC-INFRA\": \"NONE\","
+ + " \"prevent-delete\": \"NONE\"," + " \"default\": \"true\","
+ + " \"description\":\"\"" + " }," + " {" + " \"from\": \"ctag-pool\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\"," + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\"," + " \"description\":\"\"" + " }," + " {"
+ + " \"from\": \"dvs-switch\"," + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.AppliesTo\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\"," + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\"," + " \"description\":\"\"" + " }," + " {"
+ + " \"from\": \"generic-vnf\"," + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"!${direction}\"," + " \"default\": \"true\","
+ + " \"description\":\"\"" + " }," + " {" + " \"from\": \"vf-module\","
+ + " \"to\": \"vnfc\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"ONE2MANY\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"${direction}\"," + " \"default\": \"true\","
+ + " \"description\":\"\"" + " }," + " {" + " \"from\": \"pserver\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.MemberOf\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2ONE\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"${direction}\","
+ + " \"prevent-delete\": \"!${direction}\"," + " \"default\": \"true\","
+ + " \"description\":\"\"" + " }," + " {" + " \"from\": \"vce\","
+ + " \"to\": \"availability-zone\","
+ + " \"label\": \"org.onap.relationships.inventory.Uses\","
+ + " \"direction\": \"OUT\"," + " \"multiplicity\": \"MANY2MANY\","
+ + " \"contains-other-v\": \"NONE\"," + " \"delete-other-v\": \"NONE\","
+ + " \"SVC-INFRA\": \"NONE\"," + " \"prevent-delete\": \"!${direction}\","
+ + " \"default\": \"true\"," + " \"description\":\"\"" + " }," + " ]}";
+
+ BufferedWriter bw = new BufferedWriter(new FileWriter(EDGEFILENAME));
+ bw.write(json);
+ bw.close();
+
+ }
+
+ @Before
+ public void setUp() throws Exception {
+
+ DeleteOperation.deletePaths.put("/cloud-infrastructure/pservers/pserver/{hostname}",
+ "pserver");
+ DeleteOperation.deletePaths.put("/network/vces/vce/{vnf-id}", "vce");
+ DeleteOperation.deletePaths
+ .put("/cloud-infrastructure/complexes/complex/{physical-location-id}", "complex");
+ DeleteOperation.deletePaths.put(
+ "/service-design-and-creation/service-capabilities/service-capability/{service-type}/{vnf-type}",
+ "service-capability");
+ DeleteOperation.deletePaths.put(
+ "/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}",
+ "cloud-region");
+ DeleteOperation.deletePaths.put("/network/generic-vnfs/generic-vnf/{vnf-id}",
+ "generic-vnf");
+ DeleteOperation.deletePaths.put(
+ "/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/dvs-switches/dvs-switch/{switch-name}",
+ "dvs-switch");
+ DeleteOperation.deletePaths.put(
+ "/cloud-infrastructure/complexes/complex/{physical-location-id}/ctag-pools/ctag-pool/{target-pe}/{availability-zone-name}",
+ "ctag-pool");
+
+ DeleteOperation.deletePaths.put(path.replace("/relationship-list/relationship", ""),
+ "availability-zone");
+ PutRelationPathSet.add(opId, path);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ File edges = new File(EDGEFILENAME);
+ edges.delete();
+ }
+
+ @Test
+ public void testAdd() {
+ PutRelationPathSet.add(opId, path);
+ assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
+ assertThat(PutRelationPathSet.putRelationPaths.get(opId), is(target));
+ }
+
+ @Test
+ public void testPutRelationPathSet() {
+
+ this.prp = new PutRelationPathSet(v);
+ assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
+ prp.generateRelations(edgeIngestor);
+ assertTrue(this.relationsFile.exists());
+ this.relationsFile.delete();
+ }
+
+ @Test
+ public void testPutRelationPathSetStringString() {
+ this.prp = new PutRelationPathSet(opId, path, v);
+ assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
+ }
+
+ @Test
+ public void testGenerateRelations() {
+ PutRelationPathSet prp = new PutRelationPathSet(opId, "availability-zone", v);
+ prp.generateRelations(edgeIngestor);
+ assertThat(PutRelationPathSet.putRelationPaths.size(), is(1));
+ assertThat(PutRelationPathSet.putRelationPaths.get(opId), is(target));
+ assertTrue(this.relationsFile.exists());
+ // this.relationsFile.delete();
+ }
}
-
-
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDElementTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDElementTest.java
index 7c8dd78..7ce87af 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDElementTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDElementTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,8 +17,25 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.collection.IsIn.in;
+import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
+import static org.hamcrest.core.Every.everyItem;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.*;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -31,625 +48,721 @@ import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.*;
+public class XSDElementTest {
+ private static final Logger logger = LoggerFactory.getLogger("XSDElementTest.class");
+ private static final int maxSizeForXml = 20000;
+ protected String testXML;
+ protected Document doc = null;
+ protected NodeList javaTypeNodes = null;
+
+ public String getTestXML() {
+ return testXML;
+ }
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.collection.IsIn.in;
-import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
-import static org.hamcrest.core.Every.everyItem;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
-public class XSDElementTest {
- private static final Logger logger = LoggerFactory.getLogger("XSDElementTest.class");
- private static final int maxSizeForXml = 20000;
- protected String testXML;
- protected Document doc = null;
- protected NodeList javaTypeNodes=null;
-
- public String getTestXML() {
- return testXML;
- }
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- setUp(0);
- }
-
- public void setUp( int sbopt ) throws Exception {
- StringBuilder sb = new StringBuilder(maxSizeForXml);
- addNamespace(sb);
- addBusiness(sb);
- addCustomers(sb);
- if ( sbopt == 0 ) {
- addCustomer(sb);
- } else {
- addCustomerNoSubscriberType(sb);
- addCustomerSubscriberType(sb);
+ @Before
+ public void setUp() throws Exception {
+ setUp(0);
+ }
+
+ public void setUp(int sbopt) throws Exception {
+ StringBuilder sb = new StringBuilder(maxSizeForXml);
+ addNamespace(sb);
+ addBusiness(sb);
+ addCustomers(sb);
+ if (sbopt == 0) {
+ addCustomer(sb);
+ } else {
+ addCustomerNoSubscriberType(sb);
+ addCustomerSubscriberType(sb);
+ }
+ addServiceSubscriptions(sb);
+ addServiceSubscription(sb);
+ addEndOfXML(sb);
+ testXML = sb.toString();
+ init();
+ }
+
+ public void setUpRelationship() throws Exception {
+ StringBuilder sb = new StringBuilder(maxSizeForXml);
+ addNamespaceNoInventory(sb);
+ addRelationship(sb);
+ addRelationshipList(sb);
+ addRelatedToProperty(sb);
+ addRelationshipData(sb);
+ addEndOfXML(sb);
+ testXML = sb.toString();
+ init();
+ }
+
+ private void addNamespace(StringBuilder sb) {
+ sb.append(
+ "<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org.v11\" xml-mapping-metadata-complete=\"true\">\n");
+ sb.append("<xml-schema element-form-default=\"QUALIFIED\">\n");
+ sb.append("<xml-ns namespace-uri=\"http://org.onap.aai.inventory/v11\" />\n");
+ sb.append("</xml-schema>\n");
+ sb.append("<java-types>\n");
+ sb.append("<java-type name=\"Inventory\">\n");
+ sb.append("<xml-root-element name=\"inventory\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element java-attribute=\"business\" name=\"business\" type=\"inventory.aai.onap.org.v11.Business\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
+ }
+
+ private void addNamespaceNoInventory(StringBuilder sb) {
+ sb.append(
+ "<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org.v11\" xml-mapping-metadata-complete=\"true\">\n");
+ sb.append("<xml-schema element-form-default=\"QUALIFIED\">\n");
+ sb.append("<xml-ns namespace-uri=\"http://org.onap.aai.inventory/v11\" />\n");
+ sb.append("</xml-schema>\n");
+ sb.append("<java-types>\n");
}
- addServiceSubscriptions(sb);
- addServiceSubscription(sb);
- addEndOfXML(sb);
- testXML = sb.toString();
- init();
- }
-
- public void setUpRelationship( ) throws Exception {
- StringBuilder sb = new StringBuilder(maxSizeForXml);
- addNamespaceNoInventory(sb);
- addRelationship(sb);
- addRelationshipList(sb);
- addRelatedToProperty(sb);
- addRelationshipData(sb);
- addEndOfXML(sb);
- testXML = sb.toString();
- init();
- }
-
- private void addNamespace(StringBuilder sb){
- sb.append("<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org.v11\" xml-mapping-metadata-complete=\"true\">\n");
- sb.append("<xml-schema element-form-default=\"QUALIFIED\">\n");
- sb.append("<xml-ns namespace-uri=\"http://org.onap.aai.inventory/v11\" />\n");
- sb.append("</xml-schema>\n");
- sb.append("<java-types>\n");
- sb.append("<java-type name=\"Inventory\">\n");
- sb.append("<xml-root-element name=\"inventory\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"business\" name=\"business\" type=\"inventory.aai.onap.org.v11.Business\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
-
- private void addNamespaceNoInventory(StringBuilder sb){
- sb.append("<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org.v11\" xml-mapping-metadata-complete=\"true\">\n");
- sb.append("<xml-schema element-form-default=\"QUALIFIED\">\n");
- sb.append("<xml-ns namespace-uri=\"http://org.onap.aai.inventory/v11\" />\n");
- sb.append("</xml-schema>\n");
- sb.append("<java-types>\n");
- }
-
- private void addBusiness(StringBuilder sb){
- sb.append("<java-type name=\"Business\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Namespace for business related constructs\" />\n");
+
+ private void addBusiness(StringBuilder sb) {
+ sb.append("<java-type name=\"Business\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Namespace for business related constructs\" />\n");
sb.append("</xml-properties>\n");
sb.append("<xml-root-element name=\"business\" />\n");
sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"customers\" name=\"customers\" type=\"inventory.aai.onap.org.v11.Customers\" />\n");
+ sb.append(
+ "<xml-element java-attribute=\"customers\" name=\"customers\" type=\"inventory.aai.onap.org.v11.Customers\" />\n");
sb.append("</java-attributes>\n");
sb.append("</java-type>\n");
- }
-
- private void addCustomers(StringBuilder sb){
- sb.append("<java-type name=\"Customers\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Collection of customer identifiers to provide linkage back to BSS information.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("<xml-root-element name=\"customers\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"customer\" name=\"customer\" type=\"inventory.aai.onap.org.v11.Customer\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"maximumDepth\" value=\"0\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</java-type>\n");
- }
-
- private void addCustomer(StringBuilder sb){
- sb.append("<java-type name=\"Customer\">\n");
- sb.append("<xml-root-element name=\"customer\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"globalCustomerId\" name=\"global-customer-id\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Global customer id used across to uniquely identify customer.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"subscriberName\" name=\"subscriber-name\" required=\"true\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Subscriber name, an alternate way to retrieve a customer.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"subscriberType\" name=\"subscriber-type\" required=\"true\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Subscriber type, a way to provide VID with only the INFRA customers.\" />\n");
- sb.append("<xml-property name=\"defaultValue\" value=\"CUST\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"serviceSubscriptions\" name=\"service-subscriptions\" type=\"inventory.aai.onap.org.v11.ServiceSubscriptions\" />\n");
-// sb.append("<xml-element java-attribute=\"relationshipList\" name=\"relationship-list\" type=\"inventory.aai.onap.org.v11.RelationshipList\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"customer identifiers to provide linkage back to BSS information.\" />\n");
- sb.append("<xml-property name=\"nameProps\" value=\"subscriber-name\" />\n");
- sb.append("<xml-property name=\"indexedProps\" value=\"subscriber-name,global-customer-id,subscriber-type\" />\n");
- sb.append("<xml-property name=\"searchable\" value=\"global-customer-id,subscriber-name\" />\n");
- sb.append("<xml-property name=\"uniqueProps\" value=\"global-customer-id\" />\n");
- sb.append("<xml-property name=\"container\" value=\"customers\" />\n");
- sb.append("<xml-property name=\"namespace\" value=\"business\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</java-type>\n");
- }
-
- private void addCustomerNoSubscriberType(StringBuilder sb){
- sb.append("<java-type name=\"Customer\">\n");
- sb.append("<xml-root-element name=\"customer\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"globalCustomerId\" name=\"global-customer-id\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Global customer id used across to uniquely identify customer.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"subscriberName\" name=\"subscriber-name\" required=\"true\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Subscriber name, an alternate way to retrieve a customer.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"serviceSubscriptions\" name=\"service-subscriptions\" type=\"inventory.aai.onap.org.v11.ServiceSubscriptions\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"customer identifiers to provide linkage back to BSS information.\" />\n");
- sb.append("<xml-property name=\"nameProps\" value=\"subscriber-name\" />\n");
- sb.append("<xml-property name=\"indexedProps\" value=\"subscriber-name,global-customer-id\" />\n");
- sb.append("<xml-property name=\"searchable\" value=\"global-customer-id,subscriber-name\" />\n");
- sb.append("<xml-property name=\"uniqueProps\" value=\"global-customer-id\" />\n");
- sb.append("<xml-property name=\"container\" value=\"customers\" />\n");
- sb.append("<xml-property name=\"namespace\" value=\"business\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</java-type>\n");
- }
-
- private void addCustomerSubscriberType(StringBuilder sb){
- sb.append("<java-type name=\"Customer\">\n");
- sb.append("<xml-root-element name=\"customer\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"subscriberType\" name=\"subscriber-type\" required=\"true\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Subscriber type, a way to provide VID with only the INFRA customers.\" />\n");
- sb.append("<xml-property name=\"defaultValue\" value=\"CUST\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("</java-attributes>\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"indexedProps\" value=\"subscriber-type\" />\n");
- sb.append("<xml-property name=\"container\" value=\"customers\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</java-type>\n");
- }
-
- private void addServiceSubscriptions(StringBuilder sb){
- sb.append("<java-type name=\"ServiceSubscriptions\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Collection of objects that group service instances.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("<xml-root-element name=\"service-subscriptions\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"serviceSubscription\" name=\"service-subscription\" type=\"inventory.aai.onap.org.v11.ServiceSubscription\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
- private void addServiceSubscription(StringBuilder sb){
- sb.append("<java-type name=\"ServiceSubscription\">\n");
- sb.append("<xml-root-element name=\"service-subscription\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"serviceType\" name=\"service-type\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Value defined by orchestration to identify this service.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"tempUbSubAccountId\" name=\"temp-ub-sub-account-id\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"This property will be deleted from A&amp;AI in the near future. Only stop gap solution.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
-// sb.append("<xml-element java-attribute=\"relationshipList\" name=\"relationship-list\" type=\"inventory.aai.onap.org.v11.RelationshipList\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Object that group service instances.\" />\n");
- sb.append("<xml-property name=\"indexedProps\" value=\"service-type\" />\n");
- sb.append("<xml-property name=\"dependentOn\" value=\"customer\" />\n");
- sb.append("<xml-property name=\"container\" value=\"service-subscriptions\" />\n");
- sb.append("<xml-property name=\"crossEntityReference\" value=\"service-instance,service-type\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</java-type>\n");
- }
-
- private void addRelationshipList(StringBuilder sb ) {
- sb.append("<java-type name=\"RelationshipList\">\n");
- sb.append("<xml-root-element name=\"relationship-list\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relationship\" name=\"relationship\" type=\"inventory.aai.onap.org.v11.Relationship\" />/n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
-
- private void addRelationship(StringBuilder sb ) {
- sb.append("<java-type name=\"Relationship\">\n");
- sb.append("<xml-root-element name=\"relationship\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"relatedTo\" name=\"related-to\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"A keyword provided by A&amp;AI to indicate type of node.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"relatedLink\" name=\"related-link\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"URL to the object in A&amp;AI.\" />");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relationshipData\" name=\"relationship-data\" type=\"inventory.aai.onap.org.v11.RelationshipData\" />\n");
- sb.append("<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relatedToProperty\" name=\"related-to-property\" type=\"inventory.aai.onap.org.v11.RelatedToProperty\" />\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
-
- private void addRelatedToProperty(StringBuilder sb) {
- sb.append("<java-type name=\"RelatedToProperty\">\n");
- sb.append("<xml-root-element name=\"related-to-property\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"propertyKey\" name=\"property-key\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Key part of a key/value pair\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"propertyValue\" name=\"property-value\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Value part of a key/value pair\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
-
- private void addRelationshipData(StringBuilder sb){
- sb.append("<java-type name=\"RelationshipData\">\n");
- sb.append("<xml-root-element name=\"relationship-data\" />\n");
- sb.append("<java-attributes>\n");
- sb.append("<xml-element java-attribute=\"relationshipKey\" name=\"relationship-key\" required=\"true\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"A keyword provided by A&amp;AI to indicate an attribute.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("<xml-element java-attribute=\"relationshipValue\" name=\"relationship-value\" required=\"true\" type=\"java.lang.String\">\n");
- sb.append("<xml-properties>\n");
- sb.append("<xml-property name=\"description\" value=\"Value of the attribute.\" />\n");
- sb.append("</xml-properties>\n");
- sb.append("</xml-element>\n");
- sb.append("</java-attributes>\n");
- sb.append("</java-type>\n");
- }
-
-
- private void addEndOfXML(StringBuilder sb){
- sb.append("</java-types>\n");
- sb.append("</xml-bindings>\n");
- }
-
- public void init() throws ParserConfigurationException, SAXException, IOException {
- DocumentBuilder dBuilder = null;
- try {
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- dbFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- dBuilder = dbFactory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- throw e;
}
- try {
- InputSource isInput = new InputSource(new StringReader(testXML));
- doc = dBuilder.parse(isInput);
- } catch (SAXException e) {
- throw e;
- } catch (IOException e) {
- throw e;
+
+ private void addCustomers(StringBuilder sb) {
+ sb.append("<java-type name=\"Customers\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Collection of customer identifiers to provide linkage back to BSS information.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("<xml-root-element name=\"customers\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"customer\" name=\"customer\" type=\"inventory.aai.onap.org.v11.Customer\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"maximumDepth\" value=\"0\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</java-type>\n");
+ }
+
+ private void addCustomer(StringBuilder sb) {
+ sb.append("<java-type name=\"Customer\">\n");
+ sb.append("<xml-root-element name=\"customer\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element java-attribute=\"globalCustomerId\" name=\"global-customer-id\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Global customer id used across to uniquely identify customer.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"subscriberName\" name=\"subscriber-name\" required=\"true\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Subscriber name, an alternate way to retrieve a customer.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"subscriberType\" name=\"subscriber-type\" required=\"true\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Subscriber type, a way to provide VID with only the INFRA customers.\" />\n");
+ sb.append("<xml-property name=\"defaultValue\" value=\"CUST\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"serviceSubscriptions\" name=\"service-subscriptions\" type=\"inventory.aai.onap.org.v11.ServiceSubscriptions\" />\n");
+ // sb.append("<xml-element java-attribute=\"relationshipList\" name=\"relationship-list\"
+ // type=\"inventory.aai.onap.org.v11.RelationshipList\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"customer identifiers to provide linkage back to BSS information.\" />\n");
+ sb.append("<xml-property name=\"nameProps\" value=\"subscriber-name\" />\n");
+ sb.append(
+ "<xml-property name=\"indexedProps\" value=\"subscriber-name,global-customer-id,subscriber-type\" />\n");
+ sb.append(
+ "<xml-property name=\"searchable\" value=\"global-customer-id,subscriber-name\" />\n");
+ sb.append("<xml-property name=\"uniqueProps\" value=\"global-customer-id\" />\n");
+ sb.append("<xml-property name=\"container\" value=\"customers\" />\n");
+ sb.append("<xml-property name=\"namespace\" value=\"business\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</java-type>\n");
}
- NodeList bindingsNodes = doc.getElementsByTagName("xml-bindings");
- Element bindingElement;
- NodeList javaTypesNodes;
- Element javaTypesElement;
+ private void addCustomerNoSubscriberType(StringBuilder sb) {
+ sb.append("<java-type name=\"Customer\">\n");
+ sb.append("<xml-root-element name=\"customer\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element java-attribute=\"globalCustomerId\" name=\"global-customer-id\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Global customer id used across to uniquely identify customer.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"subscriberName\" name=\"subscriber-name\" required=\"true\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Subscriber name, an alternate way to retrieve a customer.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"serviceSubscriptions\" name=\"service-subscriptions\" type=\"inventory.aai.onap.org.v11.ServiceSubscriptions\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"customer identifiers to provide linkage back to BSS information.\" />\n");
+ sb.append("<xml-property name=\"nameProps\" value=\"subscriber-name\" />\n");
+ sb.append(
+ "<xml-property name=\"indexedProps\" value=\"subscriber-name,global-customer-id\" />\n");
+ sb.append(
+ "<xml-property name=\"searchable\" value=\"global-customer-id,subscriber-name\" />\n");
+ sb.append("<xml-property name=\"uniqueProps\" value=\"global-customer-id\" />\n");
+ sb.append("<xml-property name=\"container\" value=\"customers\" />\n");
+ sb.append("<xml-property name=\"namespace\" value=\"business\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</java-type>\n");
+ }
- if ( bindingsNodes == null || bindingsNodes.getLength() == 0 ) {
- throw new SAXException("OXM file error: missing <binding-nodes> in XML");
+ private void addCustomerSubscriberType(StringBuilder sb) {
+ sb.append("<java-type name=\"Customer\">\n");
+ sb.append("<xml-root-element name=\"customer\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element java-attribute=\"subscriberType\" name=\"subscriber-type\" required=\"true\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Subscriber type, a way to provide VID with only the INFRA customers.\" />\n");
+ sb.append("<xml-property name=\"defaultValue\" value=\"CUST\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("</java-attributes>\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"indexedProps\" value=\"subscriber-type\" />\n");
+ sb.append("<xml-property name=\"container\" value=\"customers\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</java-type>\n");
}
- bindingElement = (Element) bindingsNodes.item(0);
- javaTypesNodes = bindingElement.getElementsByTagName("java-types");
- if ( javaTypesNodes.getLength() < 1 ) {
- throw new SAXException("OXM file error: missing <binding-nodes><java-types> in XML");
+ private void addServiceSubscriptions(StringBuilder sb) {
+ sb.append("<java-type name=\"ServiceSubscriptions\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Collection of objects that group service instances.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("<xml-root-element name=\"service-subscriptions\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"serviceSubscription\" name=\"service-subscription\" type=\"inventory.aai.onap.org.v11.ServiceSubscription\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
}
- javaTypesElement = (Element) javaTypesNodes.item(0);
- javaTypeNodes = javaTypesElement.getElementsByTagName("java-type");
- if ( javaTypeNodes.getLength() < 1 ) {
- throw new SAXException("OXM file error: missing <binding-nodes><java-types><java-type> in XML");
+ private void addServiceSubscription(StringBuilder sb) {
+ sb.append("<java-type name=\"ServiceSubscription\">\n");
+ sb.append("<xml-root-element name=\"service-subscription\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element java-attribute=\"serviceType\" name=\"service-type\" required=\"true\" type=\"java.lang.String\" xml-key=\"true\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Value defined by orchestration to identify this service.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"tempUbSubAccountId\" name=\"temp-ub-sub-account-id\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"This property will be deleted from A&amp;AI in the near future. Only stop gap solution.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"resourceVersion\" name=\"resource-version\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Used for optimistic concurrency. Must be empty on create, valid on update and delete.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ // sb.append("<xml-element java-attribute=\"relationshipList\" name=\"relationship-list\"
+ // type=\"inventory.aai.onap.org.v11.RelationshipList\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Object that group service instances.\" />\n");
+ sb.append("<xml-property name=\"indexedProps\" value=\"service-type\" />\n");
+ sb.append("<xml-property name=\"dependentOn\" value=\"customer\" />\n");
+ sb.append("<xml-property name=\"container\" value=\"service-subscriptions\" />\n");
+ sb.append(
+ "<xml-property name=\"crossEntityReference\" value=\"service-instance,service-type\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</java-type>\n");
}
- logger.debug(testXML);
- }
- @Test
- public void testXSDElement() {
- // repeat of testGetIndexedProps() which uses the constructor
- ArrayList<String> target = new ArrayList<String>();
- target.add("subscriber-name");
- target.add("global-customer-id");
- target.add("subscriber-type");
- target.add("service-type");
-
- Vector<String> indexedProps = new Vector<String>();
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- indexedProps.addAll(javaTypeElement.getIndexedProps());
+
+ private void addRelationshipList(StringBuilder sb) {
+ sb.append("<java-type name=\"RelationshipList\">\n");
+ sb.append("<xml-root-element name=\"relationship-list\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relationship\" name=\"relationship\" type=\"inventory.aai.onap.org.v11.Relationship\" />/n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
}
- assertThat(new ArrayList<>(indexedProps),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
- }
-
- @Test
- public void testName() {
- ArrayList<String> target = new ArrayList<String>();
- target.add("ServiceSubscriptions");
- target.add("ServiceSubscription");
- target.add("Inventory");
- target.add("Business");
- target.add("Customers");
- target.add("Customer");
- ArrayList<String> names = new ArrayList<String>();
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- names.add(javaTypeElement.name());
+
+ private void addRelationship(StringBuilder sb) {
+ sb.append("<java-type name=\"Relationship\">\n");
+ sb.append("<xml-root-element name=\"relationship\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element java-attribute=\"relatedTo\" name=\"related-to\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"A keyword provided by A&amp;AI to indicate type of node.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"relatedLink\" name=\"related-link\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"URL to the object in A&amp;AI.\" />");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relationshipData\" name=\"relationship-data\" type=\"inventory.aai.onap.org.v11.RelationshipData\" />\n");
+ sb.append(
+ "<xml-element container-type=\"java.util.ArrayList\" java-attribute=\"relatedToProperty\" name=\"related-to-property\" type=\"inventory.aai.onap.org.v11.RelatedToProperty\" />\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
}
- logger.debug(String.join("|", names));
- assertThat(names,both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
- }
-
- @Test
- public void testGetAddTypes() {
- HashMap<String,ArrayList<String>> map = new HashMap<String,ArrayList<String>>();
- HashMap<String,ArrayList<String>> target = new HashMap<String,ArrayList<String>>();
- target.put("Customer", new ArrayList<>(Arrays.asList("ServiceSubscriptions", "RelationshipList")));
- target.put("Customer", new ArrayList<>(Arrays.asList("ServiceSubscriptions")));
- target.put("Business", new ArrayList<>(Arrays.asList("Customers")));
- target.put("Inventory", new ArrayList<>(Arrays.asList("Business")));
- target.put("Customers", new ArrayList<>(Arrays.asList("Customer")));
- target.put("ServiceSubscription", new ArrayList<>(Arrays.asList("RelationshipList")));
- target.put("ServiceSubscription", new ArrayList<>(Arrays.asList()));
- target.put("ServiceSubscriptions", new ArrayList<>(Arrays.asList("ServiceSubscription")));
-
- for ( int i = 0; i < javaTypeNodes.getLength(); ++i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- ArrayList<String> addTypes = new ArrayList<String>();
- NodeList xmlElementNodes = javaTypeElement.getElementsByTagName("xml-element");
- String name=javaTypeElement.name();
- for ( int j = 0; j < xmlElementNodes.getLength(); ++j ) {
- XSDElement xmlElement = new XSDElement((Element) xmlElementNodes.item(j));
- addTypes.addAll(xmlElement.getAddTypes("v11"));
- map.put(name,addTypes);
- }
+
+ private void addRelatedToProperty(StringBuilder sb) {
+ sb.append("<java-type name=\"RelatedToProperty\">\n");
+ sb.append("<xml-root-element name=\"related-to-property\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element java-attribute=\"propertyKey\" name=\"property-key\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Key part of a key/value pair\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"propertyValue\" name=\"property-value\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"Value part of a key/value pair\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
}
- for(String key : map.keySet()) {
- assertThat("Expected for key:"+key, map.get(key),equalTo(target.get(key)));
+
+ private void addRelationshipData(StringBuilder sb) {
+ sb.append("<java-type name=\"RelationshipData\">\n");
+ sb.append("<xml-root-element name=\"relationship-data\" />\n");
+ sb.append("<java-attributes>\n");
+ sb.append(
+ "<xml-element java-attribute=\"relationshipKey\" name=\"relationship-key\" required=\"true\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append(
+ "<xml-property name=\"description\" value=\"A keyword provided by A&amp;AI to indicate an attribute.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append(
+ "<xml-element java-attribute=\"relationshipValue\" name=\"relationship-value\" required=\"true\" type=\"java.lang.String\">\n");
+ sb.append("<xml-properties>\n");
+ sb.append("<xml-property name=\"description\" value=\"Value of the attribute.\" />\n");
+ sb.append("</xml-properties>\n");
+ sb.append("</xml-element>\n");
+ sb.append("</java-attributes>\n");
+ sb.append("</java-type>\n");
}
- }
-/*
- @Test
- public void testGetRequiredElements() {
- HashMap<String,ArrayList<String>> map = new HashMap<String,ArrayList<String>>();
- ArrayList<String> target = new ArrayList<String>();
- target.add("global-customer-id\n");
- target.add("subscriber-name\n");
- target.add("subscriber-type");
- for ( int i = 0; i < javaTypeNodes.getLength(); ++i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- ArrayList<String> requiredItems = new ArrayList<String>();
- String name=javaTypeElement.name();
- requiredItems.addAll(javaTypeElement.getRequiredElements("v11"));
- map.put(name,requiredItems);
+
+ private void addEndOfXML(StringBuilder sb) {
+ sb.append("</java-types>\n");
+ sb.append("</xml-bindings>\n");
}
- for(String key : map.keySet()) {
- assertThat(map.get(key),equalTo(target));
+
+ public void init() throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilder dBuilder = null;
+ try {
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ dbFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ dBuilder = dbFactory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ throw e;
+ }
+ try {
+ InputSource isInput = new InputSource(new StringReader(testXML));
+ doc = dBuilder.parse(isInput);
+ } catch (SAXException e) {
+ throw e;
+ } catch (IOException e) {
+ throw e;
+ }
+
+ NodeList bindingsNodes = doc.getElementsByTagName("xml-bindings");
+ Element bindingElement;
+ NodeList javaTypesNodes;
+ Element javaTypesElement;
+
+ if (bindingsNodes == null || bindingsNodes.getLength() == 0) {
+ throw new SAXException("OXM file error: missing <binding-nodes> in XML");
+ }
+
+ bindingElement = (Element) bindingsNodes.item(0);
+ javaTypesNodes = bindingElement.getElementsByTagName("java-types");
+ if (javaTypesNodes.getLength() < 1) {
+ throw new SAXException("OXM file error: missing <binding-nodes><java-types> in XML");
+ }
+ javaTypesElement = (Element) javaTypesNodes.item(0);
+
+ javaTypeNodes = javaTypesElement.getElementsByTagName("java-type");
+ if (javaTypeNodes.getLength() < 1) {
+ throw new SAXException(
+ "OXM file error: missing <binding-nodes><java-types><java-type> in XML");
+ }
+ logger.debug(testXML);
}
- }
-*/
- @Test
- public void testGetPathDescriptionProperty() {
- ArrayList<String> target = new ArrayList<String>();
- target.add("Namespace for business related constructs");
- target.add("Collection of customer identifiers to provide linkage back to BSS information.");
- target.add("customer identifiers to provide linkage back to BSS information.");
- target.add("Collection of objects that group service instances.");
- target.add("Object that group service instances.");
- List<String> descs = new ArrayList<String>();
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- if(javaTypeElement.getPathDescriptionProperty() != null)
- descs.add(javaTypeElement.getPathDescriptionProperty());
+
+ @Test
+ public void testXSDElement() {
+ // repeat of testGetIndexedProps() which uses the constructor
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("subscriber-name");
+ target.add("global-customer-id");
+ target.add("subscriber-type");
+ target.add("service-type");
+
+ Vector<String> indexedProps = new Vector<String>();
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ indexedProps.addAll(javaTypeElement.getIndexedProps());
+ }
+ assertThat(new ArrayList<>(indexedProps),
+ both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
}
- logger.debug(String.join("|", descs));
- assertThat(new ArrayList<>(descs),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
- }
-
- @Test
- public void testGetIndexedProps() {
- ArrayList<String> target = new ArrayList<String>();
- target.add("subscriber-name");
- target.add("global-customer-id");
- target.add("subscriber-type");
- target.add("service-type");
-
- Vector<String> indexedProps = new Vector<String>();
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- indexedProps.addAll(javaTypeElement.getIndexedProps());
+
+ @Test
+ public void testName() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("ServiceSubscriptions");
+ target.add("ServiceSubscription");
+ target.add("Inventory");
+ target.add("Business");
+ target.add("Customers");
+ target.add("Customer");
+ ArrayList<String> names = new ArrayList<String>();
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ names.add(javaTypeElement.name());
+ }
+ logger.debug(String.join("|", names));
+ assertThat(names,
+ both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
}
- assertThat(new ArrayList<>(indexedProps),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
- }
-
- @Test
- public void testGetContainerProperty() {
- ArrayList<String> target = new ArrayList<String>();
- target.add("service-subscriptions");
- target.add("customers");
- List<String> containers = new ArrayList<String>();
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- if(javaTypeElement.getContainerProperty() != null)
- containers.add(javaTypeElement.getContainerProperty());
+
+ @Test
+ public void testGetAddTypes() {
+ HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
+ HashMap<String, ArrayList<String>> target = new HashMap<String, ArrayList<String>>();
+ target.put("Customer",
+ new ArrayList<>(Arrays.asList("ServiceSubscriptions", "RelationshipList")));
+ target.put("Customer", new ArrayList<>(Arrays.asList("ServiceSubscriptions")));
+ target.put("Business", new ArrayList<>(Arrays.asList("Customers")));
+ target.put("Inventory", new ArrayList<>(Arrays.asList("Business")));
+ target.put("Customers", new ArrayList<>(Arrays.asList("Customer")));
+ target.put("ServiceSubscription", new ArrayList<>(Arrays.asList("RelationshipList")));
+ target.put("ServiceSubscription", new ArrayList<>(Arrays.asList()));
+ target.put("ServiceSubscriptions", new ArrayList<>(Arrays.asList("ServiceSubscription")));
+
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ ArrayList<String> addTypes = new ArrayList<String>();
+ NodeList xmlElementNodes = javaTypeElement.getElementsByTagName("xml-element");
+ String name = javaTypeElement.name();
+ for (int j = 0; j < xmlElementNodes.getLength(); ++j) {
+ XSDElement xmlElement = new XSDElement((Element) xmlElementNodes.item(j));
+ addTypes.addAll(xmlElement.getAddTypes("v11"));
+ map.put(name, addTypes);
+ }
+ }
+ for (String key : map.keySet()) {
+ assertThat("Expected for key:" + key, map.get(key), equalTo(target.get(key)));
+ }
}
- logger.debug(String.join("|", containers));
- assertThat(new ArrayList<>(containers),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
- }
-
- @Test
- public void testGetQueryParamYAML() {
- ArrayList<String> target = new ArrayList<String>();
- target.add(" - name: global-customer-id\n in: query\n description: n/a\n required: false\n type: string\n");
- target.add(" - name: subscriber-name\n in: query\n description: n/a\n required: false\n type: string\n");
- target.add(" - name: subscriber-type\n in: query\n description: n/a\n required: false\n type: string\n");
- Vector<String> indexedProps = new Vector<String>();
- for ( int i = 0; i < javaTypeNodes.getLength(); ++i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- if(javaTypeElement.getContainerProperty() != null) {
- indexedProps.addAll(javaTypeElement.getIndexedProps());
- String container = javaTypeElement.getContainerProperty();
- Vector<String> containerProps = new Vector<String>();
- NodeList xmlElementNodes = javaTypeElement.getElementsByTagName("xml-element");
- for ( int j = 0; j < xmlElementNodes.getLength(); ++j ) {
- XSDElement xmlElement = new XSDElement((Element) xmlElementNodes.item(j));
- if(indexedProps.contains(xmlElement.name()))
- containerProps.add(xmlElement.getQueryParamYAML());
+
+ /*
+ * @Test
+ * public void testGetRequiredElements() {
+ * HashMap<String,ArrayList<String>> map = new HashMap<String,ArrayList<String>>();
+ * ArrayList<String> target = new ArrayList<String>();
+ * target.add("global-customer-id\n");
+ * target.add("subscriber-name\n");
+ * target.add("subscriber-type");
+ * for ( int i = 0; i < javaTypeNodes.getLength(); ++i ) {
+ * XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ * ArrayList<String> requiredItems = new ArrayList<String>();
+ * String name=javaTypeElement.name();
+ * requiredItems.addAll(javaTypeElement.getRequiredElements("v11"));
+ * map.put(name,requiredItems);
+ * }
+ * for(String key : map.keySet()) {
+ * assertThat(map.get(key),equalTo(target));
+ * }
+ * }
+ */
+ @Test
+ public void testGetPathDescriptionProperty() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("Namespace for business related constructs");
+ target
+ .add("Collection of customer identifiers to provide linkage back to BSS information.");
+ target.add("customer identifiers to provide linkage back to BSS information.");
+ target.add("Collection of objects that group service instances.");
+ target.add("Object that group service instances.");
+ List<String> descs = new ArrayList<String>();
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if (javaTypeElement.getPathDescriptionProperty() != null)
+ descs.add(javaTypeElement.getPathDescriptionProperty());
}
- GetOperation.addContainerProps(container, containerProps);
- }
+ logger.debug(String.join("|", descs));
+ assertThat(new ArrayList<>(descs),
+ both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
}
-/*
- List<String> queryParams = new ArrayList<String>();
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- if(javaTypeElement.getQueryParamYAML() != null)
- queryParams.add(javaTypeElement.getQueryParamYAML());
+
+ @Test
+ public void testGetIndexedProps() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("subscriber-name");
+ target.add("global-customer-id");
+ target.add("subscriber-type");
+ target.add("service-type");
+
+ Vector<String> indexedProps = new Vector<String>();
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ indexedProps.addAll(javaTypeElement.getIndexedProps());
+ }
+ assertThat(new ArrayList<>(indexedProps),
+ both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
}
-*/
- assertThat(GetOperation.containers.get("customers"),equalTo( target));
- }
-
- @Test
- public void testGetPathParamYAML() {
- ArrayList<String> target = new ArrayList<String>();
- target.add(" - name: Inventory\n in: path\n description: Inventory\n required: true\n example: __INVENTORY__\n");
- target.add(" - name: Business\n in: path\n description: Business\n required: true\n example: __BUSINESS__\n");
- target.add(" - name: Customers\n in: path\n description: Customers\n required: true\n example: __CUSTOMERS__\n");
- target.add(" - name: Customer\n in: path\n description: Customer\n required: true\n example: __CUSTOMER__\n");
- target.add(" - name: ServiceSubscriptions\n in: path\n description: ServiceSubscriptions\n required: true\n example: __SERVICESUBSCRIPTIONS__\n");
- target.add(" - name: ServiceSubscription\n in: path\n description: ServiceSubscription\n required: true\n example: __SERVICESUBSCRIPTION__\n");
- List<String> pathParams = new ArrayList<String>();
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- if(javaTypeElement.getPathParamYAML(javaTypeElement.name()) != null)
- pathParams.add(javaTypeElement.getPathParamYAML(javaTypeElement.name()));
+
+ @Test
+ public void testGetContainerProperty() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add("service-subscriptions");
+ target.add("customers");
+ List<String> containers = new ArrayList<String>();
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if (javaTypeElement.getContainerProperty() != null)
+ containers.add(javaTypeElement.getContainerProperty());
+ }
+ logger.debug(String.join("|", containers));
+ assertThat(new ArrayList<>(containers),
+ both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
}
- logger.debug(String.join("|", pathParams));
- assertThat(new ArrayList<>(pathParams),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
- }
-
- @Test
- public void testGetHTMLAnnotation() {
- ArrayList<String> target = new ArrayList<String>();
- target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " <annox:annotate target=\"Business\">@org.onap.aai.annotations.Metadata(description=\"Namespace for business related constructs\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " <annox:annotate target=\"Customers\">@org.onap.aai.annotations.Metadata(description=\"Collection of customer identifiers to provide linkage back to BSS information.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " <annox:annotate target=\"Customer\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " <annox:annotate target=\"ServiceSubscriptions\">@org.onap.aai.annotations.Metadata(description=\"Collection of objects that group service instances.\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " <annox:annotate target=\"ServiceSubscription\">@org.onap.aai.annotations.Metadata(description=\"Object that group service instances.\",indexedProps=\"service-type\",dependentOn=\"customer\",container=\"service-subscriptions\",crossEntityReference=\"service-instance,service-type\")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
- List<String> annotes = new ArrayList<String>();
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- if(StringUtils.isNotEmpty(javaTypeElement.getHTMLAnnotation(javaTypeElement.name(),"")))
- annotes.add(javaTypeElement.getHTMLAnnotation(javaTypeElement.name(), " "));
+
+ @Test
+ public void testGetQueryParamYAML() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add(
+ " - name: global-customer-id\n in: query\n description: n/a\n required: false\n type: string\n");
+ target.add(
+ " - name: subscriber-name\n in: query\n description: n/a\n required: false\n type: string\n");
+ target.add(
+ " - name: subscriber-type\n in: query\n description: n/a\n required: false\n type: string\n");
+ Vector<String> indexedProps = new Vector<String>();
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if (javaTypeElement.getContainerProperty() != null) {
+ indexedProps.addAll(javaTypeElement.getIndexedProps());
+ String container = javaTypeElement.getContainerProperty();
+ Vector<String> containerProps = new Vector<String>();
+ NodeList xmlElementNodes = javaTypeElement.getElementsByTagName("xml-element");
+ for (int j = 0; j < xmlElementNodes.getLength(); ++j) {
+ XSDElement xmlElement = new XSDElement((Element) xmlElementNodes.item(j));
+ if (indexedProps.contains(xmlElement.name()))
+ containerProps.add(xmlElement.getQueryParamYAML());
+ }
+ GetOperation.addContainerProps(container, containerProps);
+ }
+ }
+ /*
+ * List<String> queryParams = new ArrayList<String>();
+ * for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
+ * XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ * if(javaTypeElement.getQueryParamYAML() != null)
+ * queryParams.add(javaTypeElement.getQueryParamYAML());
+ * }
+ */
+ assertThat(GetOperation.containers.get("customers"), equalTo(target));
}
- logger.debug("result:");
- logger.debug(String.join("|", annotes));
- logger.debug("Expected:");
- logger.debug(String.join("|", target));
- assertThat(new ArrayList<>(annotes),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
-
- }
-
- @Test
- public void testGetTypePropertyYAML() {
- ArrayList<String> target = new ArrayList<String>();
- target.add(" Inventory:\n type: ");
- target.add(" Business:\n type: description: Namespace for business related constructs\n");
- target.add(" Customers:\n type: description: Collection of customer identifiers to provide linkage back to BSS information.\n");
- target.add(" Customer:\n type: description: customer identifiers to provide linkage back to BSS information.\n");
- target.add(" ServiceSubscriptions:\n type: description: Collection of objects that group service instances.\n");
- target.add(" ServiceSubscription:\n type: description: Object that group service instances.\n");
- StringBuilder sb = new StringBuilder(" Customer:\n type: description: |\n customer identifiers to provide linkage back to BSS information.\n");
- sb.append(" *This property can be used as a filter to find the start node for a dsl query\n");
- String yamlDesc = sb.toString();
- List<String> types = new ArrayList<String>();
- String container;
- String customerDesc = null;
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- if(javaTypeElement.getTypePropertyYAML(false) != null)
- types.add(javaTypeElement.getTypePropertyYAML(false));
- container = javaTypeElement.getContainerProperty();
- if ( "customers".equals(container)) {
- customerDesc = javaTypeElement.getTypePropertyYAML(true);
- }
+
+ @Test
+ public void testGetPathParamYAML() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add(
+ " - name: Inventory\n in: path\n description: Inventory\n required: true\n example: __INVENTORY__\n");
+ target.add(
+ " - name: Business\n in: path\n description: Business\n required: true\n example: __BUSINESS__\n");
+ target.add(
+ " - name: Customers\n in: path\n description: Customers\n required: true\n example: __CUSTOMERS__\n");
+ target.add(
+ " - name: Customer\n in: path\n description: Customer\n required: true\n example: __CUSTOMER__\n");
+ target.add(
+ " - name: ServiceSubscriptions\n in: path\n description: ServiceSubscriptions\n required: true\n example: __SERVICESUBSCRIPTIONS__\n");
+ target.add(
+ " - name: ServiceSubscription\n in: path\n description: ServiceSubscription\n required: true\n example: __SERVICESUBSCRIPTION__\n");
+ List<String> pathParams = new ArrayList<String>();
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if (javaTypeElement.getPathParamYAML(javaTypeElement.name()) != null)
+ pathParams.add(javaTypeElement.getPathParamYAML(javaTypeElement.name()));
+ }
+ logger.debug(String.join("|", pathParams));
+ assertThat(new ArrayList<>(pathParams),
+ both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
}
- assertThat(new ArrayList<>(types),both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
- assertEquals(customerDesc, yamlDesc );
- }
-
- @Test
- public void testIsStandardType() {
- HashMap<String,ArrayList<String>> map = new HashMap<String,ArrayList<String>>();
- HashMap<String,ArrayList<String>> target = new HashMap<String,ArrayList<String>>();
- target.put("Customer", new ArrayList<>(Arrays.asList("global-customer-id","subscriber-name", "subscriber-type","resource-version")));
- target.put("Business", new ArrayList<>());
- target.put("Inventory", new ArrayList<>());
- target.put("Customers", new ArrayList<>());
- target.put("ServiceSubscriptions", new ArrayList<>());
- target.put("ServiceSubscription", new ArrayList<>(Arrays.asList("service-type", "temp-ub-sub-account-id", "resource-version")));
-
- for ( int i = 0; i < javaTypeNodes.getLength(); ++i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- ArrayList<String> addTypes = new ArrayList<String>();
- NodeList xmlElementNodes = javaTypeElement.getElementsByTagName("xml-element");
- String name=javaTypeElement.name();
- for ( int j = 0; j < xmlElementNodes.getLength(); ++j ) {
- XSDElement xmlElement = new XSDElement((Element) xmlElementNodes.item(j));
- if(xmlElement.isStandardType())
- addTypes.add(xmlElement.name());
- }
- map.put(name,addTypes);
+
+ @Test
+ public void testGetHTMLAnnotation() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>"
+ + OxmFileProcessor.LINE_SEPARATOR
+ + " <annox:annotate target=\"Business\">@org.onap.aai.annotations.Metadata(description=\"Namespace for business related constructs\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>"
+ + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>"
+ + OxmFileProcessor.LINE_SEPARATOR
+ + " <annox:annotate target=\"Customers\">@org.onap.aai.annotations.Metadata(description=\"Collection of customer identifiers to provide linkage back to BSS information.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>"
+ + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>"
+ + OxmFileProcessor.LINE_SEPARATOR
+ + " <annox:annotate target=\"Customer\">@org.onap.aai.annotations.Metadata(description=\"customer identifiers to provide linkage back to BSS information.\",nameProps=\"subscriber-name\",indexedProps=\"subscriber-name,global-customer-id,subscriber-type\",searchable=\"global-customer-id,subscriber-name\",uniqueProps=\"global-customer-id\",container=\"customers\",namespace=\"business\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>"
+ + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>"
+ + OxmFileProcessor.LINE_SEPARATOR
+ + " <annox:annotate target=\"ServiceSubscriptions\">@org.onap.aai.annotations.Metadata(description=\"Collection of objects that group service instances.\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>"
+ + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ target.add(" <xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR + " <xs:appinfo>"
+ + OxmFileProcessor.LINE_SEPARATOR
+ + " <annox:annotate target=\"ServiceSubscription\">@org.onap.aai.annotations.Metadata(description=\"Object that group service instances.\",indexedProps=\"service-type\",dependentOn=\"customer\",container=\"service-subscriptions\",crossEntityReference=\"service-instance,service-type\")</annox:annotate>"
+ + OxmFileProcessor.LINE_SEPARATOR + " </xs:appinfo>"
+ + OxmFileProcessor.LINE_SEPARATOR + " </xs:annotation>"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ List<String> annotes = new ArrayList<String>();
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if (StringUtils
+ .isNotEmpty(javaTypeElement.getHTMLAnnotation(javaTypeElement.name(), "")))
+ annotes.add(javaTypeElement.getHTMLAnnotation(javaTypeElement.name(), " "));
+ }
+ logger.debug("result:");
+ logger.debug(String.join("|", annotes));
+ logger.debug("Expected:");
+ logger.debug(String.join("|", target));
+ assertThat(new ArrayList<>(annotes),
+ both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
+
}
- for(String key : map.keySet()) {
- assertThat(map.get(key),equalTo(target.get(key)));
+
+ @Test
+ public void testGetTypePropertyYAML() {
+ ArrayList<String> target = new ArrayList<String>();
+ target.add(" Inventory:\n type: ");
+ target.add(
+ " Business:\n type: description: Namespace for business related constructs\n");
+ target.add(
+ " Customers:\n type: description: Collection of customer identifiers to provide linkage back to BSS information.\n");
+ target.add(
+ " Customer:\n type: description: customer identifiers to provide linkage back to BSS information.\n");
+ target.add(
+ " ServiceSubscriptions:\n type: description: Collection of objects that group service instances.\n");
+ target.add(
+ " ServiceSubscription:\n type: description: Object that group service instances.\n");
+ StringBuilder sb = new StringBuilder(
+ " Customer:\n type: description: |\n customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(
+ " *This property can be used as a filter to find the start node for a dsl query\n");
+ String yamlDesc = sb.toString();
+ List<String> types = new ArrayList<String>();
+ String container;
+ String customerDesc = null;
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ if (javaTypeElement.getTypePropertyYAML(false) != null)
+ types.add(javaTypeElement.getTypePropertyYAML(false));
+ container = javaTypeElement.getContainerProperty();
+ if ("customers".equals(container)) {
+ customerDesc = javaTypeElement.getTypePropertyYAML(true);
+ }
+ }
+ assertThat(new ArrayList<>(types),
+ both(everyItem(is(in(target.toArray())))).and(containsInAnyOrder(target.toArray())));
+ assertEquals(customerDesc, yamlDesc);
}
- }
+ @Test
+ public void testIsStandardType() {
+ HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
+ HashMap<String, ArrayList<String>> target = new HashMap<String, ArrayList<String>>();
+ target.put("Customer", new ArrayList<>(Arrays.asList("global-customer-id",
+ "subscriber-name", "subscriber-type", "resource-version")));
+ target.put("Business", new ArrayList<>());
+ target.put("Inventory", new ArrayList<>());
+ target.put("Customers", new ArrayList<>());
+ target.put("ServiceSubscriptions", new ArrayList<>());
+ target.put("ServiceSubscription", new ArrayList<>(
+ Arrays.asList("service-type", "temp-ub-sub-account-id", "resource-version")));
+
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ ArrayList<String> addTypes = new ArrayList<String>();
+ NodeList xmlElementNodes = javaTypeElement.getElementsByTagName("xml-element");
+ String name = javaTypeElement.name();
+ for (int j = 0; j < xmlElementNodes.getLength(); ++j) {
+ XSDElement xmlElement = new XSDElement((Element) xmlElementNodes.item(j));
+ if (xmlElement.isStandardType())
+ addTypes.add(xmlElement.name());
+ }
+ map.put(name, addTypes);
+ }
+ for (String key : map.keySet()) {
+ assertThat(map.get(key), equalTo(target.get(key)));
+ }
+ }
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDJavaTypeTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDJavaTypeTest.java
index b961524..e750da2 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDJavaTypeTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/XSDJavaTypeTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,85 +17,86 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
-import org.junit.Before;
-import org.junit.Test;
-import org.w3c.dom.Element;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
import java.util.HashMap;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Element;
public class XSDJavaTypeTest extends XSDElementTest {
- @Before
- public void setUp() throws Exception {
- super.setUp();
- }
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
- @Test
- public void testXSDJavaTypeElement() {
- HashMap<String,String> map = new HashMap<String,String>();
- HashMap<String,String> target = new HashMap<String,String>();
- target.put("Customer", "global-customer-id");
- target.put("Business", "customers");
- target.put("Inventory", "business");
- target.put("Customers","customer");
- target.put("ServiceSubscriptions", "service-subscription");
- target.put("ServiceSubscription", "service-type");
+ @Test
+ public void testXSDJavaTypeElement() {
+ HashMap<String, String> map = new HashMap<String, String>();
+ HashMap<String, String> target = new HashMap<String, String>();
+ target.put("Customer", "global-customer-id");
+ target.put("Business", "customers");
+ target.put("Inventory", "business");
+ target.put("Customers", "customer");
+ target.put("ServiceSubscriptions", "service-subscription");
+ target.put("ServiceSubscription", "service-type");
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- XSDJavaType javaType = new XSDJavaType(javaTypeElement);
- map.put(javaType.name(),javaType.getItemName());
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ XSDJavaType javaType = new XSDJavaType(javaTypeElement);
+ map.put(javaType.name(), javaType.getItemName());
+ }
+ for (String key : map.keySet()) {
+ assertThat("For key: " + key, map.get(key), equalTo(target.get(key)));
+ }
}
- for(String key : map.keySet()) {
- assertThat("For key: "+key,map.get(key),equalTo(target.get(key)));
- }
- }
- @Test
- public void testGetItemName() {
- HashMap<String,String> map = new HashMap<String,String>();
- HashMap<String,String> target = new HashMap<String,String>();
- target.put("Customer", "global-customer-id");
- target.put("Business", "customers");
- target.put("Inventory", "business");
- target.put("Customers","customer");
- target.put("ServiceSubscriptions", "service-subscription");
- target.put("ServiceSubscription", "service-type");
+ @Test
+ public void testGetItemName() {
+ HashMap<String, String> map = new HashMap<String, String>();
+ HashMap<String, String> target = new HashMap<String, String>();
+ target.put("Customer", "global-customer-id");
+ target.put("Business", "customers");
+ target.put("Inventory", "business");
+ target.put("Customers", "customer");
+ target.put("ServiceSubscriptions", "service-subscription");
+ target.put("ServiceSubscription", "service-type");
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- XSDJavaType javaType = new XSDJavaType(javaTypeElement);
- map.put(javaType.name(),javaType.getItemName());
- }
- for(String key : map.keySet()) {
- assertThat("For key: "+key,map.get(key),equalTo(target.get(key)));
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ XSDJavaType javaType = new XSDJavaType(javaTypeElement);
+ map.put(javaType.name(), javaType.getItemName());
+ }
+ for (String key : map.keySet()) {
+ assertThat("For key: " + key, map.get(key), equalTo(target.get(key)));
+ }
}
- }
- @Test
- public void testGetArrayType() {
- HashMap<String,String> map = new HashMap<String,String>();
- HashMap<String,String> target = new HashMap<String,String>();
- target.put("Customer", null);
- target.put("Business", null);
- target.put("Inventory", null);
- target.put("Customers","customer");
- target.put("ServiceSubscriptions", "service-subscription");
- target.put("ServiceSubscription", null);
+ @Test
+ public void testGetArrayType() {
+ HashMap<String, String> map = new HashMap<String, String>();
+ HashMap<String, String> target = new HashMap<String, String>();
+ target.put("Customer", null);
+ target.put("Business", null);
+ target.put("Inventory", null);
+ target.put("Customers", "customer");
+ target.put("ServiceSubscriptions", "service-subscription");
+ target.put("ServiceSubscription", null);
- for ( int i = 0; i < javaTypeNodes.getLength(); ++ i ) {
- XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
- XSDJavaType javaType = new XSDJavaType(javaTypeElement);
- map.put(javaType.name(),javaType.getArrayType());
- }
- for(String key : map.keySet()) {
- assertThat(map.get(key),equalTo(target.get(key)));
+ for (int i = 0; i < javaTypeNodes.getLength(); ++i) {
+ XSDElement javaTypeElement = new XSDElement((Element) javaTypeNodes.item(i));
+ XSDJavaType javaType = new XSDJavaType(javaTypeElement);
+ map.put(javaType.name(), javaType.getArrayType());
+ }
+ for (String key : map.keySet()) {
+ assertThat(map.get(key), equalTo(target.get(key)));
+ }
}
- }
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/YAMLfromOXMTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/YAMLfromOXMTest.java
index 06653c8..1d06c38 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/YAMLfromOXMTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/YAMLfromOXMTest.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,9 +17,27 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.schemagen.genxsd;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
import com.google.common.collect.Multimap;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -43,802 +61,845 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {
- SchemaVersions.class,
- SchemaLocationsBean.class,
- TestUtilConfigTranslatorforBusiness.class,
- SchemaVersions.class,
- EdgeIngestor.class,
- NodeIngestor.class,
- SwaggerGenerationConfiguration.class
-
-})
-@TestPropertySource(properties = {
- "schema.uri.base.path = /aai",
- "schema.xsd.maxoccurs = 5000"
-})
+@ContextConfiguration(
+ classes = {SchemaVersions.class, SchemaLocationsBean.class,
+ TestUtilConfigTranslatorforBusiness.class, SchemaVersions.class, EdgeIngestor.class,
+ NodeIngestor.class, SwaggerGenerationConfiguration.class
+
+ })
+@TestPropertySource(properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000"})
public class YAMLfromOXMTest {
- @Autowired
+ @Autowired
EdgeIngestor edgeIngestor;
- @Autowired
+ @Autowired
NodeIngestor nodeIngestor;
- private static final Logger logger = LoggerFactory.getLogger("YAMLfromOXMTest.class");
- private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
- private static final String EDGEFILENAME = "src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json";
- public static AnnotationConfigApplicationContext ctx = null;
- private static String testXML;
- protected static final String SERVICE_NAME = "JUNIT";
+ private static final Logger logger = LoggerFactory.getLogger("YAMLfromOXMTest.class");
+ private static final String OXMFILENAME = "src/test/resources/oxm/business_oxm_v11.xml";
+ private static final String EDGEFILENAME =
+ "src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json";
+ public static AnnotationConfigApplicationContext ctx = null;
+ private static String testXML;
+ protected static final String SERVICE_NAME = "JUNIT";
boolean first = true;
@Autowired
- YAMLfromOXM yamlFromOxm;
+ YAMLfromOXM yamlFromOxm;
@Autowired
SchemaVersions schemaVersions;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
- System.setProperty("aai.service.name", SERVICE_NAME);
- }
-
-
-
- @Before
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+ System.setProperty("aai.service.name", SERVICE_NAME);
+ }
+
+ @Before
+ public void setUp() throws Exception {
XSDElementTest x = new XSDElementTest();
- x.setUp();
- testXML = x.testXML;
- logger.debug(testXML);
- BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
- bw.write(testXML);
- bw.close();
- BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
- bw1.write(EdgeDefs());
- bw1.close();
+ x.setUp();
+ testXML = x.testXML;
+ logger.debug(testXML);
+ BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
+ bw.write(testXML);
+ bw.close();
+ BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
+ bw1.write(EdgeDefs());
+ bw1.close();
}
-
- public void setupRelationship() throws Exception{
+
+ public void setupRelationship() throws Exception {
XSDElementTest x = new XSDElementTest();
- x.setUpRelationship();
+ x.setUpRelationship();
+
+ testXML = x.testXML;
+ logger.debug(testXML);
+ BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
+
+ bw.write(testXML);
+
+ bw.close();
+ BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
+ bw1.write(EdgeDefs());
+ bw1.close();
+ }
+
+ @Test
+ public void AtestIngestors() throws EdgeRuleNotFoundException {
+ Multimap<String, EdgeRule> results =
+ edgeIngestor.getAllRules(schemaVersions.getDefaultVersion());
+ SortedSet<String> ss = new TreeSet<String>(results.keySet());
+ for (String key : ss) {
+ results.get(key).stream().filter((i) -> ((!i.isPrivateEdge()))).forEach((i) -> {
+ EdgeDescription ed = new EdgeDescription(i);
+ System.out.println(ed.getRuleKey());
+ });
+ }
+ Document doc = nodeIngestor.getSchema(schemaVersions.getDefaultVersion());
+ assertNotNull(doc);
+ }
+
+ @Test
+ public void testGetDocumentHeader() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String header = null;
+ try {
+ yamlFromOxm.setXmlVersion(testXML, v);
+ yamlFromOxm.process();
+ header = yamlFromOxm.getDocumentHeader();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("Header:\n" + header, header, is(YAMLheader()));
+ }
+
+ @Test
+ public void testProcess() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String fileContent = null;
+ try {
+ yamlFromOxm.setXmlVersion(testXML, v);
+ fileContent = yamlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("FileContent-TestProcess:\n" + fileContent, fileContent, is(YAMLresult()));
+ }
- testXML = x.testXML;
- logger.debug(testXML);
- BufferedWriter bw = new BufferedWriter(new FileWriter(OXMFILENAME));
+ @Test
+ public void testYAMLfromOXMFileVersionFile() throws IOException {
+ String outfileName = "testXML.xml";
+ File XMLfile = new File(outfileName);
+ XMLfile.createNewFile();
+ BufferedWriter bw = null;
+ Charset charset = Charset.forName("UTF-8");
+ Path path = Paths.get(outfileName);
+ bw = Files.newBufferedWriter(path, charset);
+ bw.write(testXML);
+ bw.close();
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String fileContent = null;
+ try {
+ yamlFromOxm.setXmlVersion(testXML, v);
+ fileContent = yamlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ XMLfile.delete();
+ assertThat("FileContent-OXMFileVersionFile:\n" + fileContent, fileContent,
+ is(YAMLresult()));
+ }
- bw.write(testXML);
+ @Test
+ public void testYAMLfromOXMStringVersionFile() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String fileContent = null;
+ try {
+ yamlFromOxm.setXmlVersion(testXML, v);
+ fileContent = yamlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("FileContent-OXMStringVersionFile:\n" + fileContent, fileContent,
+ is(YAMLresult()));
+ }
- bw.close();
- BufferedWriter bw1 = new BufferedWriter(new FileWriter(EDGEFILENAME));
- bw1.write(EdgeDefs());
- bw1.close();
- }
+ @Test
+ public void testRelationshipListYAMLfromOXMStringVersionFile() {
+ try {
+ setupRelationship();
+ } catch (Exception e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String fileContent = null;
+ try {
+ yamlFromOxm.setXmlVersion(testXML, v);
+ fileContent = yamlFromOxm.process();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ boolean matchFound = fileContent.contains((YAMLRelationshipList()));
+ assertTrue("RelationshipListFormat:\n", matchFound);
+ }
- @Test
- public void AtestIngestors() throws EdgeRuleNotFoundException {
- Multimap<String, EdgeRule> results = edgeIngestor.getAllRules(schemaVersions.getDefaultVersion());
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
- for(String key : ss) {
- results.get(key).stream().filter((i) -> ((! i.isPrivateEdge()))).forEach((i) ->{ EdgeDescription ed = new EdgeDescription(i); System.out.println(ed.getRuleKey()); } );
+ @Test
+ public void testAppendDefinitions() {
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String definitions = null;
+ try {
+ yamlFromOxm.setXmlVersion(testXML, v);
+ yamlFromOxm.process();
+ definitions = yamlFromOxm.appendDefinitions();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("Definitions:\n" + definitions, definitions,
+ is(YAMLdefs() + YAMLdefsAddPatch()));
}
- Document doc = nodeIngestor.getSchema(schemaVersions.getDefaultVersion());
- assertNotNull(doc);
- }
-
- @Test
- public void testGetDocumentHeader() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String header = null;
- try {
- yamlFromOxm.setXmlVersion(testXML, v);
- yamlFromOxm.process();
- header = yamlFromOxm.getDocumentHeader();
- } catch(Exception e) {
- e.printStackTrace();
+
+ @Test
+ public void testGetXMLRootElementName() {
+ String target = "RootElement=customer";
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ Element customer = null;
+ String root = null;
+ try {
+ yamlFromOxm.setXmlVersion(testXML, v);
+ yamlFromOxm.process();
+ customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
+ root = yamlFromOxm.getXMLRootElementName(customer);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("RootElement=" + root, is(target));
}
- assertThat("Header:\n"+header,header, is(YAMLheader()));
- }
-
- @Test
- public void testProcess() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String fileContent = null;
- try {
- yamlFromOxm.setXmlVersion(testXML, v);
- fileContent = yamlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+
+ @Test
+ public void testGetXmlRootElementName() {
+ String target = "RootElement=customer";
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ String root = null;
+ try {
+ yamlFromOxm.setXmlVersion(testXML, v);
+ yamlFromOxm.process();
+ root = yamlFromOxm.getXmlRootElementName("Customer");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("RootElement=" + root, is(target));
}
- assertThat("FileContent-TestProcess:\n"+fileContent,fileContent, is(YAMLresult()));
- }
-
- @Test
- public void testYAMLfromOXMFileVersionFile() throws IOException {
- String outfileName = "testXML.xml";
- File XMLfile = new File(outfileName);
- XMLfile.createNewFile();
- BufferedWriter bw = null;
- Charset charset = Charset.forName("UTF-8");
- Path path = Paths.get(outfileName);
- bw = Files.newBufferedWriter(path, charset);
- bw.write(testXML);
- bw.close();
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String fileContent = null;
- try {
- yamlFromOxm.setXmlVersion(testXML, v);
- fileContent = yamlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+
+ @Test
+ public void testGetJavaTypeElementSwagger() {
+ String target = "Element=java-type/Customer";
+ SchemaVersion v = schemaVersions.getAppRootVersion();
+ String apiVersion = v.toString();
+ Element customer = null;
+ try {
+ yamlFromOxm.setXmlVersion(testXML, v);
+ yamlFromOxm.process();
+ customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ assertThat("Element=" + customer.getNodeName() + "/" + customer.getAttribute("name"),
+ is(target));
}
- XMLfile.delete();
- assertThat("FileContent-OXMFileVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
- }
-
- @Test
- public void testYAMLfromOXMStringVersionFile() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String fileContent = null;
- try {
- yamlFromOxm.setXmlVersion(testXML, v);
- fileContent = yamlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+
+ public String YAMLresult() {
+ StringBuilder sb = new StringBuilder(32368);
+ sb.append(YAMLheader());
+ sb.append(YAMLops());
+ sb.append(YAMLdefs());
+ sb.append(YAMLdefsAddPatch());
+ return sb.toString();
}
- assertThat("FileContent-OXMStringVersionFile:\n"+fileContent,fileContent, is(YAMLresult()));
- }
-
- @Test
- public void testRelationshipListYAMLfromOXMStringVersionFile() {
- try {
- setupRelationship();
- } catch (Exception e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
+
+ public String YAMLheader() {
+ StringBuilder sb = new StringBuilder(1500);
+ sb.append("swagger: \"2.0\"\n");
+ sb.append("info:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" description: |\n");
+ sb.append("\n");
+ sb.append(
+ " [Differences versus the previous schema version](apidocs/aai/aai_swagger_v11.diff)"
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ sb.append(
+ " Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved."
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ sb.append(
+ " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License."
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ sb.append(" You may obtain a copy of the License at\n");
+ sb.append("\n");
+ sb.append(" (https://creativecommons.org/licenses/by/4.0/)"
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ sb.append(
+ " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."
+ + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
+ sb.append(
+ " This document is best viewed with Firefox or Chrome. Nodes can be found by opening the models link below and finding the node-type. Edge definitions can be found with the node definitions."
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" version: \"v11\"" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(
+ " title: Active and Available Inventory REST API" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" license:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" name: Apache 2.0\n");
+ sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html"
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" contact:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" name: n/a" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" url: n/a" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" email: n/a" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append("host: n/a" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append("basePath: /aai/v11" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append("schemes:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" - https\n");
+ sb.append("paths:" + OxmFileProcessor.LINE_SEPARATOR);
+ return sb.toString();
}
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String fileContent = null;
- try {
- yamlFromOxm.setXmlVersion(testXML, v);
- fileContent = yamlFromOxm.process();
- } catch(Exception e) {
- e.printStackTrace();
+
+ public String YAMLops() {
+ StringBuilder sb = new StringBuilder(16384);
+ sb.append(
+ " /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: returns service-subscription\n");
+ sb.append(" description: returns service-subscription\n");
+ sb.append(
+ " operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/service-subscription\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Value defined by orchestration to identify this service.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __SERVICE-TYPE__\n");
+ sb.append(" put:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: create or update an existing service-subscription\n");
+ sb.append(" description: |\n");
+ sb.append(" Create or update an existing service-subscription.\n");
+ sb.append(" #\n");
+ sb.append(
+ " Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n");
+ sb.append(
+ " operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Value defined by orchestration to identify this service.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __SERVICE-TYPE__\n");
+ sb.append(" - name: body\n");
+ sb.append(" in: body\n");
+ sb.append(
+ " description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
+ sb.append(" required: true\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/service-subscription\"\n");
+ sb.append(" patch:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: update an existing service-subscription\n");
+ sb.append(" description: |\n");
+ sb.append(" Update an existing service-subscription\n");
+ sb.append(" #\n");
+ sb.append(
+ " Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
+ sb.append(" The PUT operation will entirely replace an existing object.\n");
+ sb.append(
+ " The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n");
+ sb.append(" #\n");
+ sb.append(" Other differences between PUT and PATCH are:\n");
+ sb.append(" #\n");
+ sb.append(
+ " - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
+ sb.append(
+ " - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
+ sb.append(
+ " - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
+ sb.append(
+ " operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Value defined by orchestration to identify this service.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __SERVICE-TYPE__\n");
+ sb.append(" - name: body\n");
+ sb.append(" in: body\n");
+ sb.append(" description: service-subscription object that needs to be updated.");
+ sb.append(
+ "[See Examples](apidocs/aai/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
+ sb.append(" required: true\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/zzzz-patch-service-subscription\"\n");
+ sb.append(" delete:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: delete an existing service-subscription\n");
+ sb.append(" description: delete an existing service-subscription\n");
+ sb.append(
+ " operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Value defined by orchestration to identify this service.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __SERVICE-TYPE__\n");
+ sb.append(" - name: resource-version\n");
+ sb.append(" in: query\n");
+ sb.append(" description: resource-version for concurrency\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: returns service-subscriptions\n");
+ sb.append(" description: returns service-subscriptions\n");
+ sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/service-subscriptions\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: service-type\n");
+ sb.append(" in: query\n");
+ sb.append(" description: n/a\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ sb.append(" /business/customers/customer/{global-customer-id}:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: returns customer\n");
+ sb.append(" description: returns customer\n");
+ sb.append(" operationId: getBusinessCustomersCustomer\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/customer\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" put:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: create or update an existing customer\n");
+ sb.append(" description: |\n");
+ sb.append(" Create or update an existing customer.\n");
+ sb.append(" #\n");
+ sb.append(
+ " Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n");
+ sb.append(" operationId: createOrUpdateBusinessCustomersCustomer\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: body\n");
+ sb.append(" in: body\n");
+ sb.append(
+ " description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v11/BusinessCustomersCustomer.json)\n");
+ sb.append(" required: true\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/customer\"\n");
+ sb.append(" patch:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: update an existing customer\n");
+ sb.append(" description: |\n");
+ sb.append(" Update an existing customer\n");
+ sb.append(" #\n");
+ sb.append(
+ " Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
+ sb.append(" The PUT operation will entirely replace an existing object.\n");
+ sb.append(
+ " The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n");
+ sb.append(" #\n");
+ sb.append(" Other differences between PUT and PATCH are:\n");
+ sb.append(" #\n");
+ sb.append(
+ " - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
+ sb.append(
+ " - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
+ sb.append(
+ " - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
+ sb.append(" operationId: UpdateBusinessCustomersCustomer\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: body\n");
+ sb.append(" in: body\n");
+ sb.append(" description: customer object that needs to be updated.");
+ sb.append("[See Examples](apidocs/aai/relations/v11/BusinessCustomersCustomer.json)\n");
+ sb.append(" required: true\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/zzzz-patch-customer\"\n");
+ sb.append(" delete:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: delete an existing customer\n");
+ sb.append(" description: delete an existing customer\n");
+ sb.append(" operationId: deleteBusinessCustomersCustomer\n");
+ sb.append(" consumes:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: path\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
+ sb.append(" - name: resource-version\n");
+ sb.append(" in: query\n");
+ sb.append(" description: resource-version for concurrency\n");
+ sb.append(" required: true\n");
+ sb.append(" type: string\n");
+ sb.append(" /business/customers:\n");
+ sb.append(" get:\n");
+ sb.append(" tags:\n");
+ sb.append(" - Business\n");
+ sb.append(" summary: returns customers\n");
+ sb.append(" description: returns customers\n");
+ sb.append(" operationId: getBusinessCustomers\n");
+ sb.append(" produces:\n");
+ sb.append(" - application/json\n");
+ sb.append(" - application/xml\n");
+ sb.append(" responses:\n");
+ sb.append(" \"200\":\n");
+ sb.append(" description: successful operation\n");
+ sb.append(" schema:\n");
+ sb.append(" $ref: \"#/definitions/customers\"\n");
+ sb.append(" \"default\":\n");
+ sb.append(" null parameters:\n");
+ sb.append(" - name: global-customer-id\n");
+ sb.append(" in: query\n");
+ sb.append(" description: n/a\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ sb.append(" - name: subscriber-name\n");
+ sb.append(" in: query\n");
+ sb.append(" description: n/a\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ sb.append(" - name: subscriber-type\n");
+ sb.append(" in: query\n");
+ sb.append(" description: n/a\n");
+ sb.append(" required: false\n");
+ sb.append(" type: string\n");
+ return sb.toString();
}
- boolean matchFound = fileContent.contains(( YAMLRelationshipList()));
- assertTrue("RelationshipListFormat:\n", matchFound);
- }
-
- @Test
- public void testAppendDefinitions() {
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String definitions = null;
- try {
- yamlFromOxm.setXmlVersion(testXML, v);
- yamlFromOxm.process();
- definitions = yamlFromOxm.appendDefinitions();
- } catch(Exception e) {
- e.printStackTrace();
+
+ public String YAMLdefs() {
+ StringBuilder sb = new StringBuilder(8092);
+ sb.append("definitions:\n");
+ sb.append(" business:\n");
+ sb.append(" description: |\n");
+ sb.append(" Namespace for business related constructs\n");
+ sb.append(" properties:\n");
+ sb.append(" customers:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/definitions/customer\"\n");
+ sb.append(" customer:\n");
+ sb.append(" description: |\n");
+ sb.append(" customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(
+ " - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
+ sb.append(" required:\n");
+ sb.append(" - global-customer-id\n");
+ sb.append(" - subscriber-name\n");
+ sb.append(" - subscriber-type\n");
+ sb.append(" properties:\n");
+ sb.append(" global-customer-id:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" subscriber-name:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Subscriber name, an alternate way to retrieve a customer.\n");
+ sb.append(" subscriber-type:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
+ sb.append(" resource-version:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
+ sb.append(" service-subscriptions:\n");
+ sb.append(" type: array\n");
+ sb.append(" items:\n");
+ sb.append(" $ref: \"#/definitions/service-subscription\"\n");
+ sb.append(" customers:\n");
+ sb.append(" description: |\n");
+ sb.append(
+ " Collection of customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" properties:\n");
+ sb.append(" customer:\n");
+ sb.append(" type: array\n");
+ sb.append(" items: \n");
+ sb.append(" $ref: \"#/definitions/customer\"\n");
+ sb.append(" inventory:\n");
+ sb.append(" properties:\n");
+ sb.append(" business:\n");
+ sb.append(" type: object\n");
+ sb.append(" $ref: \"#/definitions/business\"\n");
+ sb.append(" nodes:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" properties:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" type: array" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" items:" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" $ref: \"#/definitions/inventory-item-data\""
+ + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(" service-subscription:\n");
+ sb.append(" description: |\n");
+ sb.append(" Object that group service instances.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(
+ " - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
+ sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
+ sb.append(
+ " - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(
+ " -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
+ sb.append(
+ " -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
+ sb.append(" required:\n");
+ sb.append(" - service-type\n");
+ sb.append(" properties:\n");
+ sb.append(" service-type:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Value defined by orchestration to identify this service.\n");
+ sb.append(" temp-ub-sub-account-id:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
+ sb.append(" resource-version:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
+ sb.append(" service-subscriptions:\n");
+ sb.append(" description: |\n");
+ sb.append(" Collection of objects that group service instances.\n");
+ sb.append(" properties:\n");
+ sb.append(" service-subscription:\n");
+ sb.append(" type: array\n");
+ sb.append(" items: \n");
+ sb.append(" $ref: \"#/definitions/service-subscription\"\n");
+ return sb.toString();
}
- assertThat("Definitions:\n"+definitions,definitions, is(YAMLdefs()+YAMLdefsAddPatch()));
- }
-
- @Test
- public void testGetXMLRootElementName() {
- String target = "RootElement=customer";
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- Element customer = null;
- String root = null;
- try {
- yamlFromOxm.setXmlVersion(testXML, v);
- yamlFromOxm.process();
- customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
- root = yamlFromOxm.getXMLRootElementName(customer);
- } catch(Exception e) {
- e.printStackTrace();
+
+ public String YAMLdefsAddPatch() {
+ StringBuilder sb = new StringBuilder(8092);
+ sb.append(" zzzz-patch-customer:\n");
+ sb.append(" description: |\n");
+ sb.append(" customer identifiers to provide linkage back to BSS information.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(
+ " - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
+ sb.append(" properties:\n");
+ sb.append(" global-customer-id:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Global customer id used across to uniquely identify customer.\n");
+ sb.append(" subscriber-name:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Subscriber name, an alternate way to retrieve a customer.\n");
+ sb.append(" subscriber-type:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
+ sb.append(" zzzz-patch-service-subscription:\n");
+ sb.append(" description: |\n");
+ sb.append(" Object that group service instances.\n");
+ sb.append(" ###### Related Nodes\n");
+ sb.append(
+ " - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
+ sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
+ sb.append(
+ " - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
+ sb.append("\n");
+ sb.append(
+ " -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
+ sb.append(
+ " -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
+ sb.append(" properties:\n");
+ sb.append(" service-type:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: Value defined by orchestration to identify this service.\n");
+ sb.append(" temp-ub-sub-account-id:\n");
+ sb.append(" type: string\n");
+ sb.append(
+ " description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
+ return sb.toString();
}
- assertThat("RootElement="+root, is(target));
- }
-
- @Test
- public void testGetXmlRootElementName() {
- String target = "RootElement=customer";
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- String root = null;
- try {
- yamlFromOxm.setXmlVersion(testXML, v);
- yamlFromOxm.process();
- root = yamlFromOxm.getXmlRootElementName("Customer");
- } catch(Exception e) {
- e.printStackTrace();
+
+ public String YAMLRelationshipList() {
+ StringBuilder sb = new StringBuilder(8092);
+ sb.append(" relationship-list:\n");
+ sb.append(" properties:\n");
+ sb.append(" relationship:\n");
+ sb.append(" type: object\n");
+ sb.append(" $ref: \"#/definitions/relationship\"\n");
+ return sb.toString();
}
- assertThat("RootElement="+root, is(target));
- }
-
- @Test
- public void testGetJavaTypeElementSwagger() {
- String target = "Element=java-type/Customer";
- SchemaVersion v = schemaVersions.getAppRootVersion();
- String apiVersion = v.toString();
- Element customer = null;
- try {
- yamlFromOxm.setXmlVersion(testXML, v);
- yamlFromOxm.process();
- customer = yamlFromOxm.getJavaTypeElementSwagger("Customer");
- } catch(Exception e) {
- e.printStackTrace();
+
+ public static String EdgeDefs() {
+ StringBuilder sb = new StringBuilder(8092);
+ sb.append("{\n" + " \"rules\": [\n");
+ sb.append(" {\n");
+ sb.append(" \"from\": \"service-subscription\",\n");
+ sb.append(" \"to\": \"customer\",\n"
+ + " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n"
+ + " \"direction\": \"OUT\",\n" + " \"multiplicity\": \"MANY2ONE\",\n"
+ + " \"contains-other-v\": \"!${direction}\",\n"
+ + " \"delete-other-v\": \"!${direction}\",\n"
+ + " \"prevent-delete\": \"NONE\",\n" + " \"default\": \"true\",\n"
+ + " \"description\":\"\"\n");
+ sb.append(" },\n");
+ sb.append(" {\n" + " \"from\": \"service-instance\",\n"
+ + " \"to\": \"service-subscription\",\n"
+ + " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n"
+ + " \"direction\": \"OUT\",\n" + " \"multiplicity\": \"MANY2ONE\",\n"
+ + " \"contains-other-v\": \"!${direction}\",\n"
+ + " \"delete-other-v\": \"!${direction}\",\n"
+ + " \"prevent-delete\": \"NONE\",\n" + " \"default\": \"true\",\n"
+ + " \"description\":\"\"\n" + " },\n");
+ sb.append(" {\n" + " \"from\": \"service-subscription\",\n"
+ + " \"to\": \"tenant\",\n"
+ + " \"label\": \"org.onap.relationships.inventory.Uses\",\n"
+ + " \"direction\": \"OUT\",\n" + " \"multiplicity\": \"MANY2MANY\",\n"
+ + " \"contains-other-v\": \"NONE\",\n" + " \"delete-other-v\": \"NONE\",\n"
+ + " \"prevent-delete\": \"NONE\",\n" + " \"default\": \"true\",\n"
+ + " \"description\":\"\"\n" + " }");
+ sb.append(" ]\n" + "}\n");
+ return sb.toString();
}
- assertThat("Element="+customer.getNodeName()+"/"+customer.getAttribute("name"), is(target));
- }
-
- public String YAMLresult() {
- StringBuilder sb = new StringBuilder(32368);
- sb.append(YAMLheader());
- sb.append(YAMLops());
- sb.append(YAMLdefs());
- sb.append(YAMLdefsAddPatch());
- return sb.toString();
- }
- public String YAMLheader() {
- StringBuilder sb = new StringBuilder(1500);
- sb.append("swagger: \"2.0\"\n");
- sb.append("info:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" description: |\n");
- sb.append("\n");
- sb.append(" [Differences versus the previous schema version](apidocs/aai/aai_swagger_v11.diff)" + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
- sb.append(" Copyright &copy; 2017-18 AT&amp;T Intellectual Property. All rights reserved." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
- sb.append(" Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
- sb.append(" You may obtain a copy of the License at\n");
- sb.append("\n");
- sb.append(" (https://creativecommons.org/licenses/by/4.0/)"+ OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
- sb.append(" Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License." + OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
- sb.append(" This document is best viewed with Firefox or Chrome. Nodes can be found by opening the models link below and finding the node-type. Edge definitions can be found with the node definitions." + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" version: \"v11\"" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" title: Active and Available Inventory REST API" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" license:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" name: Apache 2.0\n");
- sb.append(" url: http://www.apache.org/licenses/LICENSE-2.0.html" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" contact:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" name: n/a" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" url: n/a" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" email: n/a" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append("host: n/a" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append("basePath: /aai/v11" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append("schemes:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" - https\n");
- sb.append("paths:" + OxmFileProcessor.LINE_SEPARATOR);
- return sb.toString();
- }
-
- public String YAMLops() {
- StringBuilder sb = new StringBuilder(16384);
- sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}:\n");
- sb.append(" get:\n");
- sb.append(" tags:\n");
- sb.append(" - Business\n");
- sb.append(" summary: returns service-subscription\n");
- sb.append(" description: returns service-subscription\n");
- sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"200\":\n");
- sb.append(" description: successful operation\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/service-subscription\"\n");
- sb.append(" \"default\":\n");
- sb.append(" null parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: path\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
- sb.append(" - name: service-type\n");
- sb.append(" in: path\n");
- sb.append(" description: Value defined by orchestration to identify this service.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __SERVICE-TYPE__\n");
- sb.append(" put:\n");
- sb.append(" tags:\n");
- sb.append(" - Business\n");
- sb.append(" summary: create or update an existing service-subscription\n");
- sb.append(" description: |\n");
- sb.append(" Create or update an existing service-subscription.\n");
- sb.append(" #\n");
- sb.append(" Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n");
- sb.append(" operationId: createOrUpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
- sb.append(" consumes:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"default\":\n");
- sb.append(" null parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: path\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
- sb.append(" - name: service-type\n");
- sb.append(" in: path\n");
- sb.append(" description: Value defined by orchestration to identify this service.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __SERVICE-TYPE__\n");
- sb.append(" - name: body\n");
- sb.append(" in: body\n");
- sb.append(" description: service-subscription object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
- sb.append(" required: true\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/service-subscription\"\n");
- sb.append(" patch:\n");
- sb.append(" tags:\n");
- sb.append(" - Business\n");
- sb.append(" summary: update an existing service-subscription\n");
- sb.append(" description: |\n");
- sb.append(" Update an existing service-subscription\n");
- sb.append(" #\n");
- sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
- sb.append(" The PUT operation will entirely replace an existing object.\n");
- sb.append(" The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n");
- sb.append(" #\n");
- sb.append(" Other differences between PUT and PATCH are:\n");
- sb.append(" #\n");
- sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
- sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
- sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
- sb.append(" operationId: UpdateBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
- sb.append(" consumes:\n");
- sb.append(" - application/json\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" responses:\n");
- sb.append(" \"default\":\n");
- sb.append(" null parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: path\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
- sb.append(" - name: service-type\n");
- sb.append(" in: path\n");
- sb.append(" description: Value defined by orchestration to identify this service.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __SERVICE-TYPE__\n");
- sb.append(" - name: body\n");
- sb.append(" in: body\n");
- sb.append(" description: service-subscription object that needs to be updated.");
- sb.append("[See Examples](apidocs/aai/relations/v11/BusinessCustomersCustomerServiceSubscriptionsServiceSubscription.json)\n");
- sb.append(" required: true\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/zzzz-patch-service-subscription\"\n");
- sb.append(" delete:\n");
- sb.append(" tags:\n");
- sb.append(" - Business\n");
- sb.append(" summary: delete an existing service-subscription\n");
- sb.append(" description: delete an existing service-subscription\n");
- sb.append(" operationId: deleteBusinessCustomersCustomerServiceSubscriptionsServiceSubscription\n");
- sb.append(" consumes:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"default\":\n");
- sb.append(" null parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: path\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
- sb.append(" - name: service-type\n");
- sb.append(" in: path\n");
- sb.append(" description: Value defined by orchestration to identify this service.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __SERVICE-TYPE__\n");
- sb.append(" - name: resource-version\n");
- sb.append(" in: query\n");
- sb.append(" description: resource-version for concurrency\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" /business/customers/customer/{global-customer-id}/service-subscriptions:\n");
- sb.append(" get:\n");
- sb.append(" tags:\n");
- sb.append(" - Business\n");
- sb.append(" summary: returns service-subscriptions\n");
- sb.append(" description: returns service-subscriptions\n");
- sb.append(" operationId: getBusinessCustomersCustomerServiceSubscriptions\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"200\":\n");
- sb.append(" description: successful operation\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/service-subscriptions\"\n");
- sb.append(" \"default\":\n");
- sb.append(" null parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: path\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
- sb.append(" - name: service-type\n");
- sb.append(" in: query\n");
- sb.append(" description: n/a\n");
- sb.append(" required: false\n");
- sb.append(" type: string\n");
- sb.append(" /business/customers/customer/{global-customer-id}:\n");
- sb.append(" get:\n");
- sb.append(" tags:\n");
- sb.append(" - Business\n");
- sb.append(" summary: returns customer\n");
- sb.append(" description: returns customer\n");
- sb.append(" operationId: getBusinessCustomersCustomer\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"200\":\n");
- sb.append(" description: successful operation\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/customer\"\n");
- sb.append(" \"default\":\n");
- sb.append(" null parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: path\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
- sb.append(" put:\n");
- sb.append(" tags:\n");
- sb.append(" - Business\n");
- sb.append(" summary: create or update an existing customer\n");
- sb.append(" description: |\n");
- sb.append(" Create or update an existing customer.\n");
- sb.append(" #\n");
- sb.append(" Note! This PUT method has a corresponding PATCH method that can be used to update just a few of the fields of an existing object, rather than a full object replacement. An example can be found in the [PATCH section] below\n");
- sb.append(" operationId: createOrUpdateBusinessCustomersCustomer\n");
- sb.append(" consumes:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"default\":\n");
- sb.append(" null parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: path\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
- sb.append(" - name: body\n");
- sb.append(" in: body\n");
- sb.append(" description: customer object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v11/BusinessCustomersCustomer.json)\n");
- sb.append(" required: true\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/customer\"\n");
- sb.append(" patch:\n");
- sb.append(" tags:\n");
- sb.append(" - Business\n");
- sb.append(" summary: update an existing customer\n");
- sb.append(" description: |\n");
- sb.append(" Update an existing customer\n");
- sb.append(" #\n");
- sb.append(" Note: Endpoints that are not devoted to object relationships support both PUT and PATCH operations.\n");
- sb.append(" The PUT operation will entirely replace an existing object.\n");
- sb.append(" The PATCH operation sends a \"description of changes\" for an existing object. The entire set of changes must be applied. An error result means no change occurs.\n");
- sb.append(" #\n");
- sb.append(" Other differences between PUT and PATCH are:\n");
- sb.append(" #\n");
- sb.append(" - For PATCH, you can send any of the values shown in sample REQUEST body. There are no required values.\n");
- sb.append(" - For PATCH, resource-id which is a required REQUEST body element for PUT, must not be sent.\n");
- sb.append(" - PATCH cannot be used to update relationship elements; there are dedicated PUT operations for this.\n");
- sb.append(" operationId: UpdateBusinessCustomersCustomer\n");
- sb.append(" consumes:\n");
- sb.append(" - application/json\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" responses:\n");
- sb.append(" \"default\":\n");
- sb.append(" null parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: path\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
- sb.append(" - name: body\n");
- sb.append(" in: body\n");
- sb.append(" description: customer object that needs to be updated.");
- sb.append("[See Examples](apidocs/aai/relations/v11/BusinessCustomersCustomer.json)\n");
- sb.append(" required: true\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/zzzz-patch-customer\"\n");
- sb.append(" delete:\n");
- sb.append(" tags:\n");
- sb.append(" - Business\n");
- sb.append(" summary: delete an existing customer\n");
- sb.append(" description: delete an existing customer\n");
- sb.append(" operationId: deleteBusinessCustomersCustomer\n");
- sb.append(" consumes:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"default\":\n");
- sb.append(" null parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: path\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" example: __GLOBAL-CUSTOMER-ID__\n");
- sb.append(" - name: resource-version\n");
- sb.append(" in: query\n");
- sb.append(" description: resource-version for concurrency\n");
- sb.append(" required: true\n");
- sb.append(" type: string\n");
- sb.append(" /business/customers:\n");
- sb.append(" get:\n");
- sb.append(" tags:\n");
- sb.append(" - Business\n");
- sb.append(" summary: returns customers\n");
- sb.append(" description: returns customers\n");
- sb.append(" operationId: getBusinessCustomers\n");
- sb.append(" produces:\n");
- sb.append(" - application/json\n");
- sb.append(" - application/xml\n");
- sb.append(" responses:\n");
- sb.append(" \"200\":\n");
- sb.append(" description: successful operation\n");
- sb.append(" schema:\n");
- sb.append(" $ref: \"#/definitions/customers\"\n");
- sb.append(" \"default\":\n");
- sb.append(" null parameters:\n");
- sb.append(" - name: global-customer-id\n");
- sb.append(" in: query\n");
- sb.append(" description: n/a\n");
- sb.append(" required: false\n");
- sb.append(" type: string\n");
- sb.append(" - name: subscriber-name\n");
- sb.append(" in: query\n");
- sb.append(" description: n/a\n");
- sb.append(" required: false\n");
- sb.append(" type: string\n");
- sb.append(" - name: subscriber-type\n");
- sb.append(" in: query\n");
- sb.append(" description: n/a\n");
- sb.append(" required: false\n");
- sb.append(" type: string\n");
- return sb.toString();
- }
- public String YAMLdefs() {
- StringBuilder sb = new StringBuilder(8092);
- sb.append("definitions:\n");
- sb.append(" business:\n");
- sb.append(" description: |\n");
- sb.append(" Namespace for business related constructs\n");
- sb.append(" properties:\n");
- sb.append(" customers:\n");
- sb.append(" type: array\n");
- sb.append(" items:\n");
- sb.append(" $ref: \"#/definitions/customer\"\n");
- sb.append(" customer:\n");
- sb.append(" description: |\n");
- sb.append(" customer identifiers to provide linkage back to BSS information.\n");
- sb.append(" ###### Related Nodes\n");
- sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
- sb.append("\n");
- sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
- sb.append(" required:\n");
- sb.append(" - global-customer-id\n");
- sb.append(" - subscriber-name\n");
- sb.append(" - subscriber-type\n");
- sb.append(" properties:\n");
- sb.append(" global-customer-id:\n");
- sb.append(" type: string\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" subscriber-name:\n");
- sb.append(" type: string\n");
- sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
- sb.append(" subscriber-type:\n");
- sb.append(" type: string\n");
- sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
- sb.append(" resource-version:\n");
- sb.append(" type: string\n");
- sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
- sb.append(" service-subscriptions:\n");
- sb.append(" type: array\n");
- sb.append(" items:\n");
- sb.append(" $ref: \"#/definitions/service-subscription\"\n");
- sb.append(" customers:\n");
- sb.append(" description: |\n");
- sb.append(" Collection of customer identifiers to provide linkage back to BSS information.\n");
- sb.append(" properties:\n");
- sb.append(" customer:\n");
- sb.append(" type: array\n");
- sb.append(" items: \n");
- sb.append(" $ref: \"#/definitions/customer\"\n");
- sb.append(" inventory:\n");
- sb.append(" properties:\n");
- sb.append(" business:\n");
- sb.append(" type: object\n");
- sb.append(" $ref: \"#/definitions/business\"\n");
- sb.append(" nodes:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" properties:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" inventory-item-data:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" type: array" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" items:" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" $ref: \"#/definitions/inventory-item-data\"" + OxmFileProcessor.LINE_SEPARATOR);
- sb.append(" service-subscription:\n");
- sb.append(" description: |\n");
- sb.append(" Object that group service instances.\n");
- sb.append(" ###### Related Nodes\n");
- sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
- sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
- sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
- sb.append("\n");
- sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
- sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
- sb.append(" required:\n");
- sb.append(" - service-type\n");
- sb.append(" properties:\n");
- sb.append(" service-type:\n");
- sb.append(" type: string\n");
- sb.append(" description: Value defined by orchestration to identify this service.\n");
- sb.append(" temp-ub-sub-account-id:\n");
- sb.append(" type: string\n");
- sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
- sb.append(" resource-version:\n");
- sb.append(" type: string\n");
- sb.append(" description: Used for optimistic concurrency. Must be empty on create, valid on update and delete.\n");
- sb.append(" service-subscriptions:\n");
- sb.append(" description: |\n");
- sb.append(" Collection of objects that group service instances.\n");
- sb.append(" properties:\n");
- sb.append(" service-subscription:\n");
- sb.append(" type: array\n");
- sb.append(" items: \n");
- sb.append(" $ref: \"#/definitions/service-subscription\"\n");
- return sb.toString();
- }
- public String YAMLdefsAddPatch() {
- StringBuilder sb = new StringBuilder(8092);
- sb.append(" zzzz-patch-customer:\n");
- sb.append(" description: |\n");
- sb.append(" customer identifiers to provide linkage back to BSS information.\n");
- sb.append(" ###### Related Nodes\n");
- sb.append(" - FROM service-subscription (CHILD of customer, service-subscription BelongsTo customer, MANY2ONE)(1)\n");
- sb.append("\n");
- sb.append(" -(1) IF this CUSTOMER node is deleted, this FROM node is DELETED also\n");
- sb.append(" properties:\n");
- sb.append(" global-customer-id:\n");
- sb.append(" type: string\n");
- sb.append(" description: Global customer id used across to uniquely identify customer.\n");
- sb.append(" subscriber-name:\n");
- sb.append(" type: string\n");
- sb.append(" description: Subscriber name, an alternate way to retrieve a customer.\n");
- sb.append(" subscriber-type:\n");
- sb.append(" type: string\n");
- sb.append(" description: Subscriber type, a way to provide VID with only the INFRA customers.\n");
- sb.append(" zzzz-patch-service-subscription:\n");
- sb.append(" description: |\n");
- sb.append(" Object that group service instances.\n");
- sb.append(" ###### Related Nodes\n");
- sb.append(" - TO customer (PARENT of service-subscription, service-subscription BelongsTo customer, MANY2ONE)(4)\n");
- sb.append(" - TO tenant( service-subscription Uses tenant, MANY2MANY)\n");
- sb.append(" - FROM service-instance (CHILD of service-subscription, service-instance BelongsTo service-subscription, MANY2ONE)(1)\n");
- sb.append("\n");
- sb.append(" -(1) IF this SERVICE-SUBSCRIPTION node is deleted, this FROM node is DELETED also\n");
- sb.append(" -(4) IF this TO node is deleted, this SERVICE-SUBSCRIPTION is DELETED also\n");
- sb.append(" properties:\n");
- sb.append(" service-type:\n");
- sb.append(" type: string\n");
- sb.append(" description: Value defined by orchestration to identify this service.\n");
- sb.append(" temp-ub-sub-account-id:\n");
- sb.append(" type: string\n");
- sb.append(" description: This property will be deleted from A&AI in the near future. Only stop gap solution.\n");
- return sb.toString();
- }
-
- public String YAMLRelationshipList() {
- StringBuilder sb = new StringBuilder(8092);
- sb.append(" relationship-list:\n");
- sb.append(" properties:\n");
- sb.append(" relationship:\n");
- sb.append(" type: object\n");
- sb.append(" $ref: \"#/definitions/relationship\"\n");
- return sb.toString();
- }
-
- public static String EdgeDefs() {
- StringBuilder sb = new StringBuilder(8092);
- sb.append("{\n" +
- " \"rules\": [\n");
- sb.append(" {\n");
- sb.append(" \"from\": \"service-subscription\",\n");
- sb.append(" \"to\": \"customer\",\n" +
- " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
- " \"direction\": \"OUT\",\n" +
- " \"multiplicity\": \"MANY2ONE\",\n" +
- " \"contains-other-v\": \"!${direction}\",\n" +
- " \"delete-other-v\": \"!${direction}\",\n" +
- " \"prevent-delete\": \"NONE\",\n" +
- " \"default\": \"true\",\n" +
- " \"description\":\"\"\n");
- sb.append(" },\n");
- sb.append(" {\n" +
- " \"from\": \"service-instance\",\n" +
- " \"to\": \"service-subscription\",\n" +
- " \"label\": \"org.onap.relationships.inventory.BelongsTo\",\n" +
- " \"direction\": \"OUT\",\n" +
- " \"multiplicity\": \"MANY2ONE\",\n" +
- " \"contains-other-v\": \"!${direction}\",\n" +
- " \"delete-other-v\": \"!${direction}\",\n" +
- " \"prevent-delete\": \"NONE\",\n" +
- " \"default\": \"true\",\n" +
- " \"description\":\"\"\n" +
- " },\n");
- sb.append(" {\n" +
- " \"from\": \"service-subscription\",\n" +
- " \"to\": \"tenant\",\n" +
- " \"label\": \"org.onap.relationships.inventory.Uses\",\n" +
- " \"direction\": \"OUT\",\n" +
- " \"multiplicity\": \"MANY2MANY\",\n" +
- " \"contains-other-v\": \"NONE\",\n" +
- " \"delete-other-v\": \"NONE\",\n" +
- " \"prevent-delete\": \"NONE\",\n" +
- " \"default\": \"true\",\n" +
- " \"description\":\"\"\n" +
- " }");
- sb.append(" ]\n" +
- "}\n");
- return sb.toString();
- }
-} \ No newline at end of file
+}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/swagger/DefinitionTest.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/swagger/DefinitionTest.java
index 3a53019..98169d8 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/swagger/DefinitionTest.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/swagger/DefinitionTest.java
@@ -46,12 +46,11 @@ public class DefinitionTest {
*/
@Parameters
public static Collection<String[]> testConditions() {
- String inputs[][] = {
- {"name1", "desc1",
- "Definition{definitionName='name1', definitionDescription='desc1', propertyList=[]}"},
- {"name2", "desc2",
+ String inputs[][] = {{"name1", "desc1",
+ "Definition{definitionName='name1', definitionDescription='desc1', propertyList=[]}"},
+ {"name2", "desc2",
"Definition{definitionName='name2', definitionDescription='desc2', propertyList=[]}"},
- {"fake", "random",
+ {"fake", "random",
"Definition{definitionName='fake', definitionDescription='random', propertyList=[]}"}};
return (Arrays.asList(inputs));
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforBusiness.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforBusiness.java
index e7de26b..fdc2002 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforBusiness.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforBusiness.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,54 +20,55 @@
package org.onap.aai.schemagen.testutils;
-import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersion;
-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.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+
public class TestUtilConfigTranslatorforBusiness extends ConfigTranslator {
- public TestUtilConfigTranslatorforBusiness(SchemaLocationsBean bean, SchemaVersions schemaVersions) {
- super(bean, schemaVersions);
- }
+ public TestUtilConfigTranslatorforBusiness(SchemaLocationsBean bean,
+ SchemaVersions schemaVersions) {
+ super(bean, schemaVersions);
+ }
- @Override
- public Map<SchemaVersion, List<String>> getNodeFiles() {
+ @Override
+ public Map<SchemaVersion, List<String>> getNodeFiles() {
- List<String> files11 = new ArrayList<>();
- files11.add("src/test/resources/oxm/business_oxm_v11.xml");
+ List<String> files11 = new ArrayList<>();
+ files11.add("src/test/resources/oxm/business_oxm_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");
+ 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(new SchemaVersion("v11"), files11);
- input.put(schemaVersions.getDefaultVersion(), files13);
- return input;
- }
+ Map<SchemaVersion, List<String>> input = new TreeMap<>();
+ input.put(new SchemaVersion("v11"), files11);
+ input.put(schemaVersions.getDefaultVersion(), files13);
+ return input;
+ }
- @Override
- public Map<SchemaVersion, List<String>> getEdgeFiles() {
- List<String> files = new ArrayList<>();
- files.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json");
- Map<SchemaVersion, List<String>> input = new TreeMap<>();
- input.put(schemaVersions.getDefaultVersion(), files);
+ @Override
+ public Map<SchemaVersion, List<String>> getEdgeFiles() {
+ List<String> files = new ArrayList<>();
+ 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");
+ List<String> files2 = new ArrayList<>();
+ files2.add("src/test/resources/dbedgerules/test.json");
- List<String> files3 = new ArrayList<>();
- files3.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json");
- input.put(new SchemaVersion("v11"), files3);
+ List<String> files3 = new ArrayList<>();
+ files3.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json");
+ input.put(new SchemaVersion("v11"), files3);
- return input;
- }
+ return input;
+ }
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforDataLink.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforDataLink.java
index 3cee014..7fdcc34 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforDataLink.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforDataLink.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,40 +20,49 @@
package org.onap.aai.schemagen.testutils;
-import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersions;
-
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import org.onap.aai.setup.ConfigTranslator;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+
public class TestUtilConfigTranslatorforDataLink extends ConfigTranslator {
- public TestUtilConfigTranslatorforDataLink(SchemaLocationsBean bean, SchemaVersions schemaVersions) {
- super(bean, schemaVersions);
- }
-
- @Override
- public Map<SchemaVersion, List<String>> getNodeFiles() {
-
- Map<SchemaVersion, List<String>> input = new TreeMap<>();
- input.put(new SchemaVersion("v1"), Arrays.asList("src/test/resources/oxm/dbalias_oxm_one.xml"));
- input.put(new SchemaVersion("v2"), Arrays.asList("src/test/resources/oxm/dbalias_oxm_two.xml"));
- input.put(new SchemaVersion("v3"), Arrays.asList("src/test/resources/oxm/dbalias_oxm_three.xml"));
- input.put(new SchemaVersion("v4"), Arrays.asList("src/test/resources/oxm/dbalias_oxm_four.xml"));
- return input;
- }
-
- @Override
- public Map<SchemaVersion, List<String>> getEdgeFiles() {
- Map<SchemaVersion, List<String>> input = new TreeMap<>();
- input.put(new SchemaVersion("v1"), Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_one.json"));
- input.put(new SchemaVersion("v2"), Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_two.json"));
- input.put(new SchemaVersion("v3"), Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_three.json"));
- input.put(new SchemaVersion("v4"), Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_four.json"));
- return input;
- }
+ public TestUtilConfigTranslatorforDataLink(SchemaLocationsBean bean,
+ SchemaVersions schemaVersions) {
+ super(bean, schemaVersions);
+ }
+
+ @Override
+ public Map<SchemaVersion, List<String>> getNodeFiles() {
+
+ Map<SchemaVersion, List<String>> input = new TreeMap<>();
+ input.put(new SchemaVersion("v1"),
+ Arrays.asList("src/test/resources/oxm/dbalias_oxm_one.xml"));
+ input.put(new SchemaVersion("v2"),
+ Arrays.asList("src/test/resources/oxm/dbalias_oxm_two.xml"));
+ input.put(new SchemaVersion("v3"),
+ Arrays.asList("src/test/resources/oxm/dbalias_oxm_three.xml"));
+ input.put(new SchemaVersion("v4"),
+ Arrays.asList("src/test/resources/oxm/dbalias_oxm_four.xml"));
+ return input;
+ }
+
+ @Override
+ public Map<SchemaVersion, List<String>> getEdgeFiles() {
+ Map<SchemaVersion, List<String>> input = new TreeMap<>();
+ input.put(new SchemaVersion("v1"),
+ Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_one.json"));
+ input.put(new SchemaVersion("v2"),
+ Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_two.json"));
+ input.put(new SchemaVersion("v3"),
+ Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_three.json"));
+ input.put(new SchemaVersion("v4"),
+ Arrays.asList("src/test/resources/dbedgerules/DbEdgerules_four.json"));
+ return input;
+ }
}
diff --git a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforEdges.java b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforEdges.java
index e39986f..ca45b9d 100644
--- a/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforEdges.java
+++ b/aai-schema-gen/src/test/java/org/onap/aai/schemagen/testutils/TestUtilConfigTranslatorforEdges.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,54 +20,55 @@
package org.onap.aai.schemagen.testutils;
-import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersion;
-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.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+
public class TestUtilConfigTranslatorforEdges extends ConfigTranslator {
- public TestUtilConfigTranslatorforEdges(SchemaLocationsBean bean, SchemaVersions schemaVersions) {
- super(bean, schemaVersions);
- }
+ public TestUtilConfigTranslatorforEdges(SchemaLocationsBean bean,
+ SchemaVersions schemaVersions) {
+ super(bean, schemaVersions);
+ }
- @Override
- public Map<SchemaVersion, List<String>> getNodeFiles() {
- List<String> files11 = new ArrayList<>();
- files11.add("src/test/resources/oxm/business_oxm_v11.xml");
+ @Override
+ public Map<SchemaVersion, List<String>> getNodeFiles() {
+ List<String> files11 = new ArrayList<>();
+ files11.add("src/test/resources/oxm/business_oxm_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");
+ 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(new SchemaVersion("v11"), files11);
- input.put(new SchemaVersion("v13"), files13);
- return input;
- }
+ Map<SchemaVersion, List<String>> input = new TreeMap<>();
+ input.put(new SchemaVersion("v11"), files11);
+ input.put(new SchemaVersion("v13"), files13);
+ return input;
+ }
- @Override
- public Map<SchemaVersion, List<String>> getEdgeFiles() {
- List<String> files = new ArrayList<>();
- files.add("src/test/resources/dbedgerules/test.json");
- files.add("src/test/resources/dbedgerules/test2.json");
- Map<SchemaVersion, List<String>> input = new TreeMap<>();
- input.put(schemaVersions.getDefaultVersion(), files);
+ @Override
+ public Map<SchemaVersion, List<String>> getEdgeFiles() {
+ List<String> files = new ArrayList<>();
+ files.add("src/test/resources/dbedgerules/test.json");
+ files.add("src/test/resources/dbedgerules/test2.json");
+ Map<SchemaVersion, List<String>> input = new TreeMap<>();
+ input.put(schemaVersions.getDefaultVersion(), files);
- List<String> files2 = new ArrayList<>();
- files2.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json");
- input.put(new SchemaVersion("v10"), files2);
- List<String> files3 = new ArrayList<>();
- files3.add("src/test/resources/dbedgerules/EdgeDescriptionRules_test.json");
- input.put(new SchemaVersion("v11"), files3);
+ List<String> files2 = new ArrayList<>();
+ files2.add("src/test/resources/dbedgerules/DbEdgeBusinessRules_test.json");
+ input.put(new SchemaVersion("v10"), files2);
+ List<String> files3 = new ArrayList<>();
+ files3.add("src/test/resources/dbedgerules/EdgeDescriptionRules_test.json");
+ input.put(new SchemaVersion("v11"), files3);
- return input;
- }
+ return input;
+ }
}