From: mark.j.leonard Date: Wed, 7 Nov 2018 19:13:50 +0000 (+0000) Subject: Add a CSAR test file containing an InstanceGroup X-Git-Tag: 1.4.1~59 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fbabel.git;a=commitdiff_plain;h=a2fefc003db961b717a1809b6f63c4d5ae140baa Add a CSAR test file containing an InstanceGroup Add a test CSAR file to ensure that the ArtifactGeneratorToscaParser method processInstanceGroup() is covered, prior to refactoring. Change-Id: I277b6721c8a406631d54716aa68b313b1937e5cf Issue-ID: AAI-1884 Signed-off-by: mark.j.leonard --- 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; @@ -167,6 +169,16 @@ public class CsarToXmlConverterTest { assertThatGeneratedFilesMatchExpected(createExpectedXmlFiles(filesToLoad), CsarTest.SD_WAN_CSAR_FILE); } + @Test + public void generateXmlFromNetworkCollectionCsar() throws IOException, CsarConverterException { + List 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 { @@ -202,12 +214,16 @@ public class CsarToXmlConverterTest { private void assertThatGeneratedFilesMatchExpected(Map expectedXmlFiles, CsarTest csarFile) throws CsarConverterException, IOException { - List generatedArtifacts = converter.generateXmlFromCsar(csarFile.getContent(), - csarFile.getName(), SERVICE_VERSION); + List 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 Binary files /dev/null and b/src/test/resources/compressedArtifacts/service_NetworkCollection.csar 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 @@ + + extVL-invariant-uuid + resource + + + extVL-uuid + ExtVL + 40.0 + Virtual Link + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + l3-network-version-id + + + model.model-invariant-id + l3-network-invariant-id + + + + + + + + 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 @@ + + testcr1-invariant-uuid + resource + + + testcr1-uuid + TEST CR_1 + 7.0 + Create collection resource + + + T + unbounded + + + T + unbounded + + + + model-ver + + model-ver.model-version-id + test-cr-uuid + + + model.model-invariant-id + test-cr-invariant-uuid + + + + + + + + model-ver + + model-ver.model-version-id + collection-resource-version-id + + + model.model-invariant-id + collection-resource-invariant-id + + + + + + + + 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 @@ + + service-invariant-uuid + service + + + service-uuid + TEST SVC_1 + 1.0 + Testing Network Collection + + + T + unbounded + + + T + unbounded + + + + model-ver + + model-ver.model-version-id + testcr1-uuid + + + model.model-invariant-id + testcr1-invariant-uuid + + + + + + + + model-ver + + model-ver.model-version-id + service-instance-version-id + + + model.model-invariant-id + service-instance-invariant-id + + + + + + + + \ 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 @@ + + test-cr-invariant-uuid + resource + + + test-cr-uuid + testcr_1..NetworkCollection..0 + 1 + + + T + unbounded + + + F + unbounded + + + + model-ver + + model-ver.model-version-id + extVL-uuid + + + model.model-invariant-id + extVL-invariant-uuid + + + + + + + + model-ver + + model-ver.model-version-id + instance-group-version-id + + + model.model-invariant-id + instance-group-invariant-id + + + + + + + +