aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornisha.gangore <nisha.gangore@accenture.com>2025-04-11 12:51:58 +0530
committernisha.gangore <nisha.gangore@accenture.com>2025-04-14 12:51:44 +0530
commitcea0e82b9c95e7fe320dc3837f2bf97c5693d543 (patch)
tree6ca8e31bff7e6fee2a57fe5e62dfb3edf01ccb3c
parent320bcaf30be214e4a527e7e1188db0fc9ff35374 (diff)
[AAI] Improve test coverage for A&AI component aai-schema-serviceHEADmaster
- to Improve test coverage for A&AI component aai-schema-service <=80% Issue-ID: AAI-4107 Change-Id: I19abf7c3b814c673f8753e8eddaf11c8cd440d67 Signed-off-by: nisha.gangore <nisha.gangore@accenture.com>
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSetTest.java71
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/DeleteOperationTest.java83
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/GetOperationTest.java44
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/HTMLfromOXMTest.java404
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PatchOperationTest.java33
-rw-r--r--aai-schema-gen/src/test/java/org/onap/aai/schemagen/genxsd/PutOperationTest.java112
6 files changed, 447 insertions, 300 deletions
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 0b0cf5e..062ea95 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
@@ -28,34 +28,24 @@ import java.util.Collection;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
+import java.util.Arrays;
+import java.util.Collection;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class DeleteFootnoteSetTest {
String targetNode;
- String flavor;
- String result;
+
DeleteFootnoteSet footnotes = null;
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 void initDeleteFootnoteSetTest(String targetNode, String flavor, String result) {
- this.targetNode = targetNode;
- this.flavor = flavor;
- this.result = result;
+ {"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);
}
@BeforeEach
@@ -74,10 +64,29 @@ public class DeleteFootnoteSetTest {
@MethodSource("testConditions")
@ParameterizedTest
- public void testAdd(String targetNode, String flavor, String result) {
+ public void testAddCondition4(String targetNode, String flavor, String result) {
DeleteFootnoteSet footnoteSet = new DeleteFootnoteSet(targetNode);
- footnoteSet.add(flavor);
+ footnoteSet.add("(4)");
assertEquals(1, footnoteSet.footnotes.size());
+ assertEquals("\n -(4) IF this TO node is deleted, this " + targetNode.toUpperCase() + " is DELETED also\n",
+ footnoteSet.toString());
+ }
+
+ @MethodSource("testConditions")
+ @ParameterizedTest
+ public void testAddTargetNodeInString(String targetNode, String flavor, String result) {
+ DeleteFootnoteSet footnoteSet = new DeleteFootnoteSet(targetNode);
+ footnoteSet.add(targetNode.toUpperCase()); // Test string containing target node
+ assertEquals(1, footnoteSet.footnotes.size());
+ assertEquals("\n -" + targetNode.toUpperCase() + "\n", footnoteSet.toString());
+ }
+
+ @ParameterizedTest
+ @MethodSource("testConditions")
+ public void testAddNoMatchingCondition(String targetNode, String flavor, String result) {
+ DeleteFootnoteSet footnoteSet = new DeleteFootnoteSet(targetNode);
+ footnoteSet.add("non-matching condition"); // Test string that doesn't match any condition
+ assertEquals(0, footnoteSet.footnotes.size());
}
@MethodSource("testConditions")
@@ -88,4 +97,20 @@ public class DeleteFootnoteSetTest {
assertEquals(result, footnoteSet.toString());
}
+ @MethodSource("testConditions")
+ @ParameterizedTest
+ public void testToStringWithFootnotes(String targetNode, String flavor, String result) {
+ DeleteFootnoteSet footnoteSet = new DeleteFootnoteSet(targetNode);
+ footnoteSet.add(flavor); // This adds a footnote
+ // Assert that footnote is properly added with the format
+ assertEquals(result, footnoteSet.toString());
+ }
+
+ @ParameterizedTest
+ @MethodSource("testConditions")
+ public void testToStringEmptyFootnotes(String targetNode, String flavor, String result) {
+ DeleteFootnoteSet footnoteSet = new DeleteFootnoteSet(targetNode);
+ // No footnotes added, so the output should be empty
+ assertEquals("\n", footnoteSet.toString());
+ }
}
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 dd9675f..cca0258 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
@@ -20,70 +20,57 @@
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.jupiter.api.BeforeAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
+import java.util.Arrays;
+import java.util.Collection;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
public class DeleteOperationTest {
- private String useOpId;
- private String xmlRootElementName;
- private String tag;
- private String path;
- private String pathParams;
- private String result;
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);
- }
+ String inputs[][] = {
+ // Case where tag is empty (tests StringUtils.isEmpty(tag))
+ {"TestEmptyTag", "generic-vnf", "", "/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",
+ ""}, // Should return an empty string because tag is empty
- public void initDeleteOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
- String pathParams, String result) {
- this.useOpId = useOpId;
- this.xmlRootElementName = xmlRootElementName;
- this.tag = tag;
- this.path = path;
- this.pathParams = pathParams;
- this.result = result;
- }
+ // Case where path contains "/relationship/" (tests path.contains("/relationship/"))
+ {"TestPathContainsRelationship", "generic-vnf", "Network", "/network/relationship/xyz/{xyz-id}",
+ " - name: xyz-id\n in: path\n description: Unique id of XYZ. This is a test.\n required: true\n type: string\n example: __XYZ-ID__\n",
+ ""}, // Should return an empty string because path contains "/relationship/"
- @BeforeAll
- public static void setUpBeforeClass() throws Exception {
+ // Case where path ends with "/relationship-list" (tests path.endsWith("/relationship-list"))
+ {"TestPathEndsWithRelationshipList", "service", "Network", "/network/relationship-list",
+ " - name: xyz-id\n in: path\n description: Unique id of XYZ. This is a test.\n required: true\n type: string\n example: __XYZ-ID__\n",
+ ""}, // Should return an empty string because path ends with "/relationship-list"
+ // Case when path ends with /relationship (tests path.endsWith("/relationship"))
+ {"TestPathEndsWithRelationship", "relationship", "Service", "/service/xyz/relationship",
+ " - name: xyz-id\n in: path\n description: Unique id of XYZ.\n required: true\n type: string\n example: __XYZ-ID__\n",
+ " delete:\n tags:\n - Service\n summary: delete an existing relationship\n description: delete an existing relationship\n operationId: deleteTestPathEndsWithRelationship\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: xyz-id\n in: path\n description: Unique id of XYZ.\n required: true\n type: string\n example: __XYZ-ID__\n"},
+
+ // Case where path starts with "/search" (tests path.startsWith("/search"))
+ {"TestPathStartsWithSearch", "generic-vnf", "Network", "/search/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",
+ ""}, // Should return an empty string because path starts with "/search"
+
+ // Additional normal case to verify overall behavior
+ {"TestValidPath", "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: deleteTestValidPath\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"}
+ };
+ return Arrays.asList(inputs);
}
@MethodSource("testConditions")
@ParameterizedTest
- public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
- initDeleteOperationTest(useOpId, xmlRootElementName, tag, path, pathParams, result);
+ public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String expectedResult) {
DeleteOperation delete =
new DeleteOperation(useOpId, xmlRootElementName, tag, path, pathParams);
String modResult = delete.toString();
- assertThat(modResult, is(this.result));
+ assertThat(modResult, is(expectedResult));
}
}
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 5044166..9fbe25b 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
@@ -22,11 +22,9 @@ 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 java.util.Vector;
-
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -34,42 +32,40 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GetOperationTest {
- private static final Logger logger = LoggerFactory.getLogger("GetOperationTest.class");
- private String useOpId;
+ private static final Logger logger = LoggerFactory.getLogger(GetOperationTest.class);
private String xmlRootElementName;
- private String tag;
- private String path;
- private String pathParams;
private String result;
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__"},
+ String inputs[][] = {
+ // Existing test cases
+ {"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","","","",""}
+
+ // Add new test cases for path filtering conditions
+ // Test case for path ending with "/relationship"
+ {"TestOp1", "relationship", "TestTag", "/network/relationship", "", ""},
+
+ // Test case for path containing "/relationship/"
+ {"TestOp2", "relationship", "TestTag", "/network/relationship/123", "", ""},
+
+ // Test case for path ending with "/relationship-list"
+ {"TestOp3", "relationship-list", "TestTag", "/network/relationship-list", "", ""},
+
+ // Test case for path starting with "/search"
+ {"TestOp4", "search", "TestTag", "/search/records", "", ""}
};
return Arrays.asList(inputs);
}
public void initGetOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
String pathParams, String result) {
- this.useOpId = useOpId;
this.xmlRootElementName = xmlRootElementName;
- this.tag = tag;
- this.path = path;
- this.pathParams = pathParams;
this.result = 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 4baf8f0..5302b39 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
@@ -22,6 +22,11 @@ package org.onap.aai.schemagen.genxsd;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.*;
+import static org.onap.aai.schemagen.genxsd.OxmFileProcessor.LINE_SEPARATOR;
+import static org.springframework.test.util.AssertionErrors.assertNotNull;
import java.io.BufferedWriter;
import java.io.File;
@@ -48,7 +53,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
+import org.w3c.dom.Attr;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
@SpringJUnitConfig(
classes = {SchemaConfigVersions.class, SchemaLocationsBean.class,
@@ -216,14 +224,14 @@ public class HTMLfromOXMTest {
public String HTMLheader() {
StringBuilder sb = new StringBuilder(1500);
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
- + OxmFileProcessor.LINE_SEPARATOR);
+ + 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);
+ + LINE_SEPARATOR + "xmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\""
+ + LINE_SEPARATOR);
+ sb.append(" jaxb:version=\"2.1\"" + LINE_SEPARATOR);
sb.append(
- " xmlns:annox=\"http://annox.dev.java.net\"" + OxmFileProcessor.LINE_SEPARATOR);
+ " xmlns:annox=\"http://annox.dev.java.net\"" + LINE_SEPARATOR);
sb.append(" jaxb:extensionBindingPrefixes=\"annox\">"
+ OxmFileProcessor.DOUBLE_LINE_SEPARATOR);
return sb.toString();
@@ -235,197 +243,321 @@ public class HTMLfromOXMTest {
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(" <xs:element name=\"service-subscription\">" + LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + 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);
+ " <xs:element name=\"service-subscriptions\">" + LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + LINE_SEPARATOR);
+ sb.append(" <xs:element name=\"customer\">" + LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + 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);
+ + 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:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + LINE_SEPARATOR);
+ sb.append(" <xs:element name=\"customers\">" + LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + LINE_SEPARATOR);
+ sb.append(" <xs:element name=\"business\">" + LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" <xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:appinfo>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:appinfo>" + LINE_SEPARATOR);
+ sb.append(" </xs:annotation>" + LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + LINE_SEPARATOR);
+ sb.append(" <xs:element name=\"inventory\">" + LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" <xs:sequence>" + 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);
+ + LINE_SEPARATOR);
+ sb.append(" </xs:sequence>" + LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + LINE_SEPARATOR);
+ sb.append("</xs:schema>" + LINE_SEPARATOR);
return sb.toString();
}
+
+ @Test
+ public void testSetOxmVersion() {
+ // Arrange
+ File oxmFile = new File(OXMFILENAME);
+ SchemaVersion version = schemaConfigVersions.getAppRootVersion();
+
+ // Act
+ try {
+ htmlFromOxm.setOxmVersion(oxmFile, version); // Setting the version
+ // Check the document header which should reflect the version set
+ String header = htmlFromOxm.getDocumentHeader();
+ logger.debug("Header: " + header);
+
+ // Verify that the version is properly included in the header
+ assertThat(header.contains(version.toString()), is(true)); // Check if version is part of the header
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception occurred while setting OXM version");
+ }
+ }
+
+ @Test
+ public void testSetVersion() {
+ SchemaVersion version = schemaConfigVersions.getAppRootVersion();
+
+ try {
+ htmlFromOxm.setVersion(version);
+ // Check if the version is correctly reflected in the document header
+ String header = htmlFromOxm.getDocumentHeader();
+ logger.debug("Header: " + header);
+
+ // Assert that the version is correctly reflected in the header content
+ assertThat(header.contains(version.toString()), is(true));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception occurred while setting the version");
+ }
+ }
+
+ @Test
+ public void testIsValidName() {
+ assertThat(htmlFromOxm.isValidName("valid-name"), is(true));
+ assertThat(htmlFromOxm.isValidName("valid123-name"), is(true));
+ assertThat(htmlFromOxm.isValidName("InvalidName"), is(false));
+ assertThat(htmlFromOxm.isValidName("invalid_name"), is(false));
+ assertThat(htmlFromOxm.isValidName("12345"), is(true));
+ assertThat(htmlFromOxm.isValidName(""), is(false));
+ assertThat(htmlFromOxm.isValidName(null), is(false));
+ }
+
+ @Test
+ public void testSkipCheck() {
+ assertThat(htmlFromOxm.skipCheck("model"), is(true));
+ assertThat(htmlFromOxm.skipCheck("eventHeader"), is(true));
+ assertThat(htmlFromOxm.skipCheck("otherAttribute"), is(false));
+ }
+
+ @Test
+ public void testProcessJavaTypeElement_noXmlElements() {
+ // Create a mock Element for the Java type
+ String javaTypeName = "Customer";
+ Element javaTypeElement = mock(Element.class);
+
+ // Mock parentNodes to simulate presence of a `java-attributes` node
+ NodeList parentNodes = mock(NodeList.class);
+ when(javaTypeElement.getElementsByTagName("java-attributes")).thenReturn(parentNodes);
+ when(parentNodes.getLength()).thenReturn(1); // Simulating one java-attributes element
+
+ // Mock the java-attributes element
+ Element javaAttributesElement = mock(Element.class);
+ when(parentNodes.item(0)).thenReturn(javaAttributesElement);
+
+ // Mock "xml-element" inside java-attributes to be an empty NodeList
+ NodeList xmlElementNodes = mock(NodeList.class);
+ when(javaAttributesElement.getElementsByTagName("xml-element")).thenReturn(xmlElementNodes);
+ when(xmlElementNodes.getLength()).thenReturn(0); // No xml-element nodes inside
+
+ // Mock the xml-root-element element to return the correct root element name
+ NodeList valNodes = mock(NodeList.class);
+ when(javaTypeElement.getElementsByTagName("xml-root-element")).thenReturn(valNodes);
+ when(valNodes.getLength()).thenReturn(1); // Simulating one xml-root-element node
+
+ // Mock the valElement
+ Element valElement = mock(Element.class);
+ when(valNodes.item(0)).thenReturn(valElement);
+
+ // Mock getAttributes to return a NamedNodeMap
+ NamedNodeMap attributes = mock(NamedNodeMap.class);
+ when(valElement.getAttributes()).thenReturn(attributes);
+
+ // Mock getNamedItem("name") to return the correct attribute value "Customer"
+ Attr nameAttr = mock(Attr.class);
+ when(attributes.getNamedItem("name")).thenReturn(nameAttr);
+ when(nameAttr.getNodeValue()).thenReturn("Customer"); // Ensure the value is set to "Customer"
+
+ // Create a StringBuilder for inventory
+ StringBuilder sbInventory = new StringBuilder();
+
+ // Call the method that processes the Java type element
+ String result = htmlFromOxm.processJavaTypeElement(javaTypeName, javaTypeElement, sbInventory);
+
+ // Debugging: Verify the name is correctly set
+ assertNotNull("The name attribute should not be null", nameAttr);
+ assertEquals("Customer", nameAttr.getNodeValue());
+
+ // Debugging Output: Print the generated XML
+ System.out.println("Generated XML: " + result);
+
+ // Expected result format (adjusted to match generated XML structure for no xml-element nodes)
+ String expected = " <xs:element name=\"" + null + "\">" + LINE_SEPARATOR
+ + " <xs:complexType>" + LINE_SEPARATOR
+ + " <xs:sequence/>" + LINE_SEPARATOR
+ + " </xs:complexType>" + LINE_SEPARATOR
+ + " </xs:element>" + LINE_SEPARATOR;
+
+ assertThat(result, is(expected));
+
+ verify(javaTypeElement, times(1)).getElementsByTagName("java-attributes");
+ verify(javaAttributesElement, times(1)).getElementsByTagName("xml-element");
+
+ // Check if the generatedJavaType map is updated correctly
+ assertThat(htmlFromOxm.generatedJavaType.containsKey(javaTypeName), is(true));
+ }
}
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 3735636..700e562 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
@@ -7,9 +7,9 @@
* 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
- *
+ * <p>
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,22 +22,13 @@ 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.jupiter.api.BeforeAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.onap.aai.setup.SchemaVersion;
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");
public static Collection<String[]> testConditions() {
@@ -63,29 +54,13 @@ public class PatchOperationTest {
return Arrays.asList(inputs);
}
- public void initPatchOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
- String pathParams, String result) {
- this.useOpId = useOpId;
- this.xmlRootElementName = xmlRootElementName;
- this.tag = tag;
- this.path = path;
- this.pathParams = pathParams;
- this.result = result;
- }
-
- @BeforeAll
- public static void setUpBeforeClass() throws Exception {
-
- }
-
@MethodSource("testConditions")
@ParameterizedTest
- public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
- initPatchOperationTest(useOpId, xmlRootElementName, tag, path, pathParams, result);
+ public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String expectedResult) {
PatchOperation patch =
new PatchOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai");
String modResult = patch.toString();
- assertThat(modResult, is(this.result));
+ assertThat(modResult, is(expectedResult));
}
}
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 c2ab69c..7924dbb 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
@@ -27,67 +27,99 @@ import java.util.Arrays;
import java.util.Collection;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.onap.aai.setup.SchemaVersion;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
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");
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}",
+ String inputs[][] = {
+ // Normal case: creates or updates a generic-vnf
+ {"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"},
+
+ // Case where path contains "/relationship/": this should return empty
+ {"RelationshipListExample", "relationship", "ExampleTag",
+ "/example/relationship/related-resource",
+ " - name: related-resource\n in: path\n description: Related resource.\n required: true\n type: string\n example: __RESOURCE-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__",
+
+ // Case where path ends with "/relationship-list": this should return empty
+ {"RelationshipListExample", "relationship", "ExampleTag",
+ "/example/relationship-list",
+ " - name: related-resource\n in: path\n description: Related resource.\n required: true\n type: string\n example: __RESOURCE-ID__",
""},
- // {"","ctag-pool","","","",""},
- // {"","pserver","","","",""},
- // {"","oam-network","","","",""},
- // {"","dvs-switch","","","",""},
- // {"","availability-zone","","","",""}
- };
- return Arrays.asList(inputs);
- }
- public void initPutOperationTest(String useOpId, String xmlRootElementName, String tag, String path,
- String pathParams, String result) {
- this.useOpId = useOpId;
- this.xmlRootElementName = xmlRootElementName;
- this.tag = tag;
- this.path = path;
- this.pathParams = pathParams;
- this.result = result;
- }
+ // Case where path neither ends with "/relationship" nor "}" - should return empty
+ // ExamplePathWithoutRelationship - Expecting full operation details for this path
+ {"ExamplePathWithoutRelationship", "example-resource", "ExampleTag", "/example-path/{resource-id}",
+ " - name: resource-id\n in: path\n description: Resource ID.\n required: true\n type: string\n example: __RESOURCE-ID__",
+ " put:\n tags:\n - ExampleTag\n summary: create or update an existing example-resource\n description: |\n Create or update an existing example-resource.\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: createOrUpdateExamplePathWithoutRelationship\n consumes:\n - application/json\n - application/xml\n produces:\n - application/json\n - application/xml\n responses:\n \"default\":\n null\n parameters:\n - name: resource-id\n in: path\n description: Resource ID.\n required: true\n type: string\n example: __RESOURCE-ID__\n - name: body\n in: body\n description: example-resource object that needs to be created or updated. [Valid relationship examples shown here](apidocs/aai/relations/v14/ExamplePathWithoutRelationship.json)\n required: true\n schema:\n $ref: \"#/definitions/example-resource\"\n"
+ },
- @BeforeAll
- public static void setUpBeforeClass() throws Exception {
+ // Case where path starts with "/search": this should return empty
+ {"SearchExample", "search", "SearchTag",
+ "/search/query",
+ " - name: query\n in: path\n description: Search query.\n required: true\n type: string\n example: __QUERY__",
+ ""},
+ // Additional normal case for coverage
+ {"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 case for path ending with '/relationship'
+ {"RelationshipTest", "relationship", "", "/path/to/relationship",
+ "", ""},
+
+ // Test case for path starting with '/search'
+ {"SearchTest", "search", "", "/search/path/to/resource",
+ "", ""},
+
+ // Test case for path containing "/relationship/"
+ {"TestOp2", "relationship", "TestTag", "/network/relationship/123", "", ""},
+
+ // Test case for path ending with "/relationship-list"
+ {"TestOp3", "relationship-list", "TestTag", "/network/relationship-list", "", ""},
+
+ // Test case for path starting with "/search"
+ {"TestOp4", "search", "TestTag", "/search/records", "", ""}
+ };
+ return Arrays.asList(inputs);
}
@MethodSource("testConditions")
@ParameterizedTest
- public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String result) {
- initPutOperationTest(useOpId, xmlRootElementName, tag, path, pathParams, result);
+ public void testToString(String useOpId, String xmlRootElementName, String tag, String path, String pathParams, String expectedResult) {
PutOperation put =
new PutOperation(useOpId, xmlRootElementName, tag, path, pathParams, v, "/aai");
String modResult = put.toString();
- assertThat(modResult, is(this.result));
+
+ // Trim leading/trailing spaces and normalize internal whitespace (i.e., remove multiple spaces)
+ String normalizedExpected = expectedResult.trim().replaceAll("\\s+", " ");
+ String normalizedActual = modResult.trim().replaceAll("\\s+", " ");
+
+ assertThat(normalizedActual, is(normalizedExpected));
+ }
+
+ // Test case for path starting with "/search"
+ @Test
+ public void testToStringForSearchPath() {
+ PutOperation put = new PutOperation("useOpId", "xmlRootElementName", "tag", "/search/query", "pathParams", v, "/aai");
+ String result = put.toString();
+ assertThat(result, is("")); // Should return empty string for path starting with "/search"
}
}