X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fbabel%2Fcsar%2Fextractor%2FYamlExtractorTest.java;h=abe6f4d88ae789bc914ea3631ff8fb03829adc4c;hb=6b2de4b2de03890d0f0ba0663244ef1a98457309;hp=faeb5367fc86a286e9d059754944a676df9a5a5a;hpb=93f9fec9586702a15d6a562ead3d0d432a12b487;p=aai%2Fbabel.git diff --git a/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java b/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java index faeb536..abe6f4d 100644 --- a/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java +++ b/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java @@ -18,6 +18,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.babel.csar.extractor; import static org.junit.Assert.assertEquals; @@ -28,6 +29,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.junit.Test; +import org.onap.aai.babel.testdata.CsarTest; import org.onap.aai.babel.util.ArtifactTestUtils; import org.onap.aai.babel.xml.generator.data.Artifact; @@ -95,7 +97,7 @@ public class YamlExtractorTest { @Test public void testArchiveContainsNoYmlFiles() throws IOException { try { - extractArchive("noYmlFilesArchive.zip"); + CsarTest.NO_YAML_FILES.extractArtifacts(); fail("An instance of InvalidArchiveException should have been thrown."); } catch (Exception e) { assertTrue("An instance of InvalidArchiveException should have been thrown.", @@ -108,12 +110,18 @@ public class YamlExtractorTest { @Test public void testArchiveContainsOnlyTheExpectedYmlFilesFromSdWanService() throws IOException, InvalidArchiveException { - final List ymlFiles = extractArchive("service-SdWanServiceTest-csar.csar"); + final List ymlFiles = CsarTest.SD_WAN_CSAR_FILE.extractArtifacts(); List payloads = new ArrayList<>(); payloads.add("ymlFiles/resource-SdWanTestVsp-template.yml"); + payloads.add("ymlFiles/resource-SdWanTestVsp-template-interface.yml"); payloads.add("ymlFiles/resource-TunnelXconntest-template.yml"); + payloads.add("ymlFiles/resource-TunnelXconntest-template-interface.yml"); payloads.add("ymlFiles/service-SdWanServiceTest-template.yml"); + payloads.add("ymlFiles/service-SdWanServiceTest-template-interface.yml"); payloads.add("ymlFiles/resource-Allotedresource-template.yml"); + payloads.add("ymlFiles/resource-SdwantestvspNodesDummyServer-template.yml"); + payloads.add("ymlFiles/nodes.yml"); + payloads.add("ymlFiles/capabilities.yml"); payloads.add("ymlFiles/artifacts.yml"); payloads.add("ymlFiles/data.yml"); payloads.add("ymlFiles/groups.yml"); @@ -124,10 +132,10 @@ public class YamlExtractorTest { /** * Call the extractor with the specified arguments and assert that an exception is thrown. * - * @param archive - * @param name - * @param version - * @param expectedErrorMessage + * @param archive the compressed archive in the form of a byte array, expected to contain one or more YAML files + * @param name the name of the archive + * @param version the version of the archive + * @param expectedErrorMessage the text of the InvalidArchiveException thrown by the extractor */ private void invalidArgumentsTest(byte[] archive, String name, String version, String expectedErrorMessage) { try { @@ -138,19 +146,4 @@ public class YamlExtractorTest { assertEquals(expectedErrorMessage, ex.getLocalizedMessage()); } } - - /** - * Extract Artifacts from the specified CSAR resource. - * - * @param resourceName - * the CSAR file - * @return the extracted artifacts - * @throws InvalidArchiveException - * @throws IOException - * for I/O errors - */ - private List extractArchive(String resourceName) throws InvalidArchiveException, IOException { - byte[] csar = new ArtifactTestUtils().getCompressedArtifact(resourceName); - return new YamlExtractor().extract(csar, resourceName, "v1"); - } }