aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java26
-rw-r--r--src/test/java/org/onap/aai/babel/testdata/CsarTest.java4
-rw-r--r--src/test/resources/compressedArtifacts/service_NetworkCollection.csarbin0 -> 32286 bytes
-rw-r--r--src/test/resources/generatedXml/AAI-ExtVL-resource-40.0.xml32
-rw-r--r--src/test/resources/generatedXml/AAI-TEST CR_1-resource-7.0.xml51
-rw-r--r--src/test/resources/generatedXml/AAI-TEST SVC_1-service-1.0.xml51
-rw-r--r--src/test/resources/generatedXml/AAI-testcr_1..NetworkCollection..0-resource-1.xml50
7 files changed, 208 insertions, 6 deletions
diff --git a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
index bf970a6..8d10412 100644
--- a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
+++ b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
@@ -23,6 +23,8 @@ package org.onap.aai.babel.service;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import java.io.IOException;
@@ -168,6 +170,16 @@ public class CsarToXmlConverterTest {
}
@Test
+ public void generateXmlFromNetworkCollectionCsar() throws IOException, CsarConverterException {
+ List<String> filesToLoad = new ArrayList<>();
+ filesToLoad.add("AAI-TEST SVC_1-service-1.0.xml");
+ filesToLoad.add("AAI-TEST CR_1-resource-7.0.xml");
+ filesToLoad.add("AAI-testcr_1..NetworkCollection..0-resource-1.xml");
+ filesToLoad.add("AAI-ExtVL-resource-40.0.xml");
+ assertThatGeneratedFilesMatchExpected(createExpectedXmlFiles(filesToLoad), CsarTest.NETWORK_COLLECTION_CSAR_FILE);
+ }
+
+ @Test
public void generatePortMirrorConfigurationModel()
throws CsarConverterException, IOException, XmlArtifactGenerationException {
List<String> filesToLoad = new ArrayList<>();
@@ -202,12 +214,16 @@ public class CsarToXmlConverterTest {
private void assertThatGeneratedFilesMatchExpected(Map<String, String> expectedXmlFiles, CsarTest csarFile)
throws CsarConverterException, IOException {
- List<BabelArtifact> generatedArtifacts = converter.generateXmlFromCsar(csarFile.getContent(),
- csarFile.getName(), SERVICE_VERSION);
+ List<BabelArtifact> generatedArtifacts =
+ converter.generateXmlFromCsar(csarFile.getContent(), csarFile.getName(), SERVICE_VERSION);
assertThat("Incorrect number of files generated", //
generatedArtifacts.size(), is(equalTo(expectedXmlFiles.size())));
- generatedArtifacts
- .forEach(ga -> assertThat("The content of " + ga.getName() + " must match the expected content",
- ga.getPayload(), matches(expectedXmlFiles.get(ga.getName()))));
+ for (BabelArtifact generated : generatedArtifacts) {
+ String fileName = generated.getName();
+ String expectedXml = expectedXmlFiles.get(fileName);
+ assertThat("Missing expected content for " + generated.getName(), expectedXml, is(not(nullValue())));
+ assertThat("The content of " + generated.getName() + " must match the expected content",
+ generated.getPayload(), matches(expectedXml));
+ }
}
}
diff --git a/src/test/java/org/onap/aai/babel/testdata/CsarTest.java b/src/test/java/org/onap/aai/babel/testdata/CsarTest.java
index d922e8e..0def88b 100644
--- a/src/test/java/org/onap/aai/babel/testdata/CsarTest.java
+++ b/src/test/java/org/onap/aai/babel/testdata/CsarTest.java
@@ -42,7 +42,9 @@ public enum CsarTest {
MISSING_METADATA_CSAR("service-MissingMetadataTest.csar"),
NO_YAML_FILES("noYmlFilesArchive.zip"),
PORT_MIRROR_CSAR("service_PortMirror.csar"),
- MULTIPLE_VNF_CSAR("catalog_csar_too_many_vnfConfigurations.csar");
+ MULTIPLE_VNF_CSAR("catalog_csar_too_many_vnfConfigurations.csar"),
+ NETWORK_COLLECTION_CSAR_FILE("service_NetworkCollection.csar");
+
// @formatter:on
private String filename;
diff --git a/src/test/resources/compressedArtifacts/service_NetworkCollection.csar b/src/test/resources/compressedArtifacts/service_NetworkCollection.csar
new file mode 100644
index 0000000..7a11899
--- /dev/null
+++ b/src/test/resources/compressedArtifacts/service_NetworkCollection.csar
Binary files differ
diff --git a/src/test/resources/generatedXml/AAI-ExtVL-resource-40.0.xml b/src/test/resources/generatedXml/AAI-ExtVL-resource-40.0.xml
new file mode 100644
index 0000000..5845510
--- /dev/null
+++ b/src/test/resources/generatedXml/AAI-ExtVL-resource-40.0.xml
@@ -0,0 +1,32 @@
+<model xmlns="http://org.onap.aai.inventory/v14">
+ <model-invariant-id>extVL-invariant-uuid</model-invariant-id>
+ <model-type>resource</model-type>
+ <model-vers>
+ <model-ver>
+ <model-version-id>extVL-uuid</model-version-id>
+ <model-name>ExtVL</model-name>
+ <model-version>40.0</model-version>
+ <model-description>Virtual Link</model-description>
+ <model-elements>
+ <model-element>
+ <new-data-del-flag>F</new-data-del-flag>
+ <cardinality>unbounded</cardinality>
+ <model-elements/>
+ <relationship-list>
+ <relationship>
+ <related-to>model-ver</related-to>
+ <relationship-data>
+ <relationship-key>model-ver.model-version-id</relationship-key>
+ <relationship-value>l3-network-version-id</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>model.model-invariant-id</relationship-key>
+ <relationship-value>l3-network-invariant-id</relationship-value>
+ </relationship-data>
+ </relationship>
+ </relationship-list>
+ </model-element>
+ </model-elements>
+ </model-ver>
+ </model-vers>
+</model>
diff --git a/src/test/resources/generatedXml/AAI-TEST CR_1-resource-7.0.xml b/src/test/resources/generatedXml/AAI-TEST CR_1-resource-7.0.xml
new file mode 100644
index 0000000..4ec38a0
--- /dev/null
+++ b/src/test/resources/generatedXml/AAI-TEST CR_1-resource-7.0.xml
@@ -0,0 +1,51 @@
+<model xmlns="http://org.onap.aai.inventory/v14">
+ <model-invariant-id>testcr1-invariant-uuid</model-invariant-id>
+ <model-type>resource</model-type>
+ <model-vers>
+ <model-ver>
+ <model-version-id>testcr1-uuid</model-version-id>
+ <model-name>TEST CR_1</model-name>
+ <model-version>7.0</model-version>
+ <model-description>Create collection resource</model-description>
+ <model-elements>
+ <model-element>
+ <new-data-del-flag>T</new-data-del-flag>
+ <cardinality>unbounded</cardinality>
+ <model-elements>
+ <model-element>
+ <new-data-del-flag>T</new-data-del-flag>
+ <cardinality>unbounded</cardinality>
+ <model-elements/>
+ <relationship-list>
+ <relationship>
+ <related-to>model-ver</related-to>
+ <relationship-data>
+ <relationship-key>model-ver.model-version-id</relationship-key>
+ <relationship-value>test-cr-uuid</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>model.model-invariant-id</relationship-key>
+ <relationship-value>test-cr-invariant-uuid</relationship-value>
+ </relationship-data>
+ </relationship>
+ </relationship-list>
+ </model-element>
+ </model-elements>
+ <relationship-list>
+ <relationship>
+ <related-to>model-ver</related-to>
+ <relationship-data>
+ <relationship-key>model-ver.model-version-id</relationship-key>
+ <relationship-value>collection-resource-version-id</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>model.model-invariant-id</relationship-key>
+ <relationship-value>collection-resource-invariant-id</relationship-value>
+ </relationship-data>
+ </relationship>
+ </relationship-list>
+ </model-element>
+ </model-elements>
+ </model-ver>
+ </model-vers>
+</model>
diff --git a/src/test/resources/generatedXml/AAI-TEST SVC_1-service-1.0.xml b/src/test/resources/generatedXml/AAI-TEST SVC_1-service-1.0.xml
new file mode 100644
index 0000000..ffea630
--- /dev/null
+++ b/src/test/resources/generatedXml/AAI-TEST SVC_1-service-1.0.xml
@@ -0,0 +1,51 @@
+<model xmlns="http://org.onap.aai.inventory/v14">
+ <model-invariant-id>service-invariant-uuid</model-invariant-id>
+ <model-type>service</model-type>
+ <model-vers>
+ <model-ver>
+ <model-version-id>service-uuid</model-version-id>
+ <model-name>TEST SVC_1</model-name>
+ <model-version>1.0</model-version>
+ <model-description>Testing Network Collection</model-description>
+ <model-elements>
+ <model-element>
+ <new-data-del-flag>T</new-data-del-flag>
+ <cardinality>unbounded</cardinality>
+ <model-elements>
+ <model-element>
+ <new-data-del-flag>T</new-data-del-flag>
+ <cardinality>unbounded</cardinality>
+ <model-elements/>
+ <relationship-list>
+ <relationship>
+ <related-to>model-ver</related-to>
+ <relationship-data>
+ <relationship-key>model-ver.model-version-id</relationship-key>
+ <relationship-value>testcr1-uuid</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>model.model-invariant-id</relationship-key>
+ <relationship-value>testcr1-invariant-uuid</relationship-value>
+ </relationship-data>
+ </relationship>
+ </relationship-list>
+ </model-element>
+ </model-elements>
+ <relationship-list>
+ <relationship>
+ <related-to>model-ver</related-to>
+ <relationship-data>
+ <relationship-key>model-ver.model-version-id</relationship-key>
+ <relationship-value>service-instance-version-id</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>model.model-invariant-id</relationship-key>
+ <relationship-value>service-instance-invariant-id</relationship-value>
+ </relationship-data>
+ </relationship>
+ </relationship-list>
+ </model-element>
+ </model-elements>
+ </model-ver>
+ </model-vers>
+</model> \ No newline at end of file
diff --git a/src/test/resources/generatedXml/AAI-testcr_1..NetworkCollection..0-resource-1.xml b/src/test/resources/generatedXml/AAI-testcr_1..NetworkCollection..0-resource-1.xml
new file mode 100644
index 0000000..daa1d4a
--- /dev/null
+++ b/src/test/resources/generatedXml/AAI-testcr_1..NetworkCollection..0-resource-1.xml
@@ -0,0 +1,50 @@
+<model xmlns="http://org.onap.aai.inventory/v14">
+ <model-invariant-id>test-cr-invariant-uuid</model-invariant-id>
+ <model-type>resource</model-type>
+ <model-vers>
+ <model-ver>
+ <model-version-id>test-cr-uuid</model-version-id>
+ <model-name>testcr_1..NetworkCollection..0</model-name>
+ <model-version>1</model-version>
+ <model-elements>
+ <model-element>
+ <new-data-del-flag>T</new-data-del-flag>
+ <cardinality>unbounded</cardinality>
+ <model-elements>
+ <model-element>
+ <new-data-del-flag>F</new-data-del-flag>
+ <cardinality>unbounded</cardinality>
+ <model-elements/>
+ <relationship-list>
+ <relationship>
+ <related-to>model-ver</related-to>
+ <relationship-data>
+ <relationship-key>model-ver.model-version-id</relationship-key>
+ <relationship-value>extVL-uuid</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>model.model-invariant-id</relationship-key>
+ <relationship-value>extVL-invariant-uuid</relationship-value>
+ </relationship-data>
+ </relationship>
+ </relationship-list>
+ </model-element>
+ </model-elements>
+ <relationship-list>
+ <relationship>
+ <related-to>model-ver</related-to>
+ <relationship-data>
+ <relationship-key>model-ver.model-version-id</relationship-key>
+ <relationship-value>instance-group-version-id</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>model.model-invariant-id</relationship-key>
+ <relationship-value>instance-group-invariant-id</relationship-value>
+ </relationship-data>
+ </relationship>
+ </relationship-list>
+ </model-element>
+ </model-elements>
+ </model-ver>
+ </model-vers>
+</model>