diff options
author | Michael Lando <ml636r@att.com> | 2018-07-29 16:13:45 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2018-07-29 16:20:34 +0300 |
commit | 5b593496b8f1b8e8be8d7d2dbcc223332e65a49b (patch) | |
tree | 2f9dfc45191e723da69cf74be7829784e9741b94 /test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java | |
parent | 9200382f2ce7b4bb729aa287d0878004b2d2b4f9 (diff) |
re base code
Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5
Issue-ID: SDC-1566
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java')
-rw-r--r-- | test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java index 157377f47f..fc717ca79d 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java @@ -20,30 +20,51 @@ package org.openecomp.sdc.ci.tests.utils; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - +import org.apache.commons.codec.binary.Base64; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; +import org.junit.Assert; +import org.openecomp.sdc.be.model.ArtifactUiDownloadData; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition; import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; import org.openecomp.sdc.ci.tests.datatypes.PropertyHeatMetaDefinition; import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaParameterConstants; +import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.openecomp.sdc.ci.tests.utils.validation.CsarValidationUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import static org.testng.AssertJUnit.assertTrue; + public class CsarParserUtils { + public static final String CSAR_ARTIFACT = "assettoscacsar"; private static Logger log = LoggerFactory.getLogger(CsarValidationUtils.class.getName()); + public static byte[] downloadComponentCsar(Component csarOwner, User user) throws Exception { + String artifactUniqeId = csarOwner.getToscaArtifacts().get(CSAR_ARTIFACT).getUniqueId(); + RestResponse csarResponse = ArtifactRestUtils.downloadResourceArtifactInternalApi(csarOwner.getUniqueId(), user, artifactUniqeId); + Assert.assertNotNull(csarResponse); + BaseRestUtils.checkSuccess(csarResponse); + ArtifactUiDownloadData artifactUiDownloadData = ResponseParser.parseToObject(csarResponse.getResponse(), + ArtifactUiDownloadData.class); + byte[] fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes(); + return Base64.decodeBase64(fromUiDownload); + } + public static List<TypeHeatMetaDefinition> getListTypeHeatMetaDefinition(File csarFileLocation) throws Exception { String artifactHeatMetaLocation = ToscaParameterConstants.HEAT_META_PATH; |