2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.product;
23 import com.google.gson.Gson;
24 import org.junit.Rule;
25 import org.junit.rules.TestName;
26 import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
27 import org.openecomp.sdc.ci.tests.utils.Decoder;
28 import org.openecomp.sdc.ci.tests.utils.Utils;
29 import org.testng.annotations.Test;
31 import java.io.ByteArrayInputStream;
32 import java.io.IOException;
33 import java.io.InputStream;
35 public class ProductToscaYamlGenerationTest extends ProductTestBase {
38 public static TestName name = new TestName();
40 public ProductToscaYamlGenerationTest() {
41 super(name, ProductToscaYamlGenerationTest.class.getName());
45 public void productToscaYamlFormat() throws IOException {
47 String heatEnvArtifactHeader = (String) Utils.parseYamlConfig("heatEnvArtifactHeader");
48 // System.out.println("heatEnvArtifactHeader = \n" +
49 // heatEnvArtifactHeader);
51 String heatEnvArtifactFooter = (String) Utils.parseYamlConfig("heatEnvArtifactFooter");
52 // System.out.println("heatEnvArtifactFooter = \n" +
53 // heatEnvArtifactFooter);
55 // temporary commented
56 // RestResponse downloadResourceInstanceHeatArtifact =
57 // ArtifactRestUtils.downloadResourceInstanceArtifact(service.getUniqueId(),
58 // resourceInstanceId, sdncUserDetails,
59 // heatArtifactDefinition.getUniqueId());
60 // assertTrue("expected request returned status:" + 200 + ", actual: " +
61 // downloadResourceInstanceHeatArtifact.getErrorCode(),
62 // downloadResourceInstanceHeatArtifact.getErrorCode()==200);
64 // InputStream stream =
65 // getDecodedSteramFromString(downloadResourceInstanceHeatArtifact.getResponse());
66 // System.out.println(Utils.getParamValueFromYamlByKey(stream,
67 // "description", String.class));
73 private InputStream getDecodedSteramFromString(String encoded64Payload) throws IOException {
75 Gson gson = new Gson();
76 ArtifactUiDownloadData artifactUiDownloadData = gson.fromJson(encoded64Payload, ArtifactUiDownloadData.class);
77 String decodedPayload = Decoder.decode(artifactUiDownloadData.getBase64Contents());
78 return new ByteArrayInputStream(decodedPayload.getBytes());