diff options
author | 2023-05-02 16:13:29 +0100 | |
---|---|---|
committer | 2023-05-02 16:13:29 +0100 | |
commit | d06f19333fda2865ed7a5beffa278daaba0f6aa3 (patch) | |
tree | d1f15203257b9b2d1183ae6e0c852df2106075d0 /so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows | |
parent | 2710810d1e058b9442bbb8b3f7d468a5ab31955a (diff) |
Fixed the CSAR file processing when the contents of the CSAR file is in alphabetical order (Definitions/asd.yaml file before TOSCA-Metadata/TOSCA.meta).
Issue-ID: SO-4098
Signed-off-by: aravind.est <aravindhan.a@est.tech>
Change-Id: I0e9c0730825eca4069ac4cb0f7ae2f97ed56efaf
Diffstat (limited to 'so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows')
3 files changed, 22 insertions, 4 deletions
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParser.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParser.java index c06d42f..cc4b783 100644 --- a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParser.java +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/main/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParser.java @@ -70,9 +70,11 @@ public class SdcCsarPackageParser { public Map<String, Object> getAsdProperties(final byte[] onapPackage) { try (final ByteArrayInputStream stream = new ByteArrayInputStream(onapPackage); - final ZipInputStream zipInputStream = new ZipInputStream(stream);) { - final String asdLocation = getAsdLocation(zipInputStream); - final String onapAsdContent = getFileInZip(zipInputStream, asdLocation).toString(); + final ZipInputStream zipInputStreamAsdLocation = new ZipInputStream(stream); + final ZipInputStream zipInputStreamAsdContent = new ZipInputStream(stream);) { + final String asdLocation = getAsdLocation(zipInputStreamAsdLocation); + stream.reset(); + final String onapAsdContent = getFileInZip(zipInputStreamAsdContent, asdLocation).toString(); logger.debug("ASD CONTENTS: {}", onapAsdContent); final JsonObject root = new Gson().toJsonTree(new Yaml().load(onapAsdContent)).getAsJsonObject(); diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParserTest.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParserTest.java index 8374faa..9de5419 100644 --- a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParserTest.java +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParserTest.java @@ -29,25 +29,41 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import java.util.List; import java.util.Map; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; /** * * @author Waqas Ikram (waqas.ikram@est.tech) * */ +@RunWith(Parameterized.class) public class SdcCsarPackageParserTest { private static final String RESOURCE_ASD_PACKAGE_CSAR_PATH = "src/test/resources/resource-Generatedasdpackage-csar.csar"; + private static final String RESOURCE_ASD_ALPHABETICAL_PACKAGE_CSAR_PATH = + "src/test/resources/resource-Generatedasdpackage-csar-alphabetical.csar"; + + + @Parameterized.Parameter + public String resourceCsarPath; + + @Parameterized.Parameters + public static Iterable<String> data() { + return Arrays.asList(RESOURCE_ASD_PACKAGE_CSAR_PATH, RESOURCE_ASD_ALPHABETICAL_PACKAGE_CSAR_PATH); + } + @Test public void testResourceAsdCsar() throws IOException { final SdcCsarPackageParser objUnderTest = new SdcCsarPackageParser(); - final byte[] content = getFileContent(Paths.get(getAbsolutePath(RESOURCE_ASD_PACKAGE_CSAR_PATH))); + final byte[] content = getFileContent(Paths.get(getAbsolutePath(resourceCsarPath))); final Map<String, Object> properties = objUnderTest.getAsdProperties(content); assertEquals("123e4567-e89b-12d3-a456-426614174000", properties.get(DESCRIPTOR_ID_PARAM_NAME)); diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/resources/resource-Generatedasdpackage-csar-alphabetical.csar b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/resources/resource-Generatedasdpackage-csar-alphabetical.csar Binary files differnew file mode 100755 index 0000000..42f2f86 --- /dev/null +++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/resources/resource-Generatedasdpackage-csar-alphabetical.csar |