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 java.io.ByteArrayInputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
27 import org.junit.Rule;
28 import org.junit.rules.TestName;
29 import org.openecomp.sdc.be.model.ArtifactUiDownloadData;
30 import org.openecomp.sdc.ci.tests.utils.Decoder;
31 import org.openecomp.sdc.ci.tests.utils.Utils;
32 import org.testng.annotations.Test;
34 import com.google.gson.Gson;
36 public class ProductToscaYamlGenerationTest extends ProductTestBase {
39 public static TestName name = new TestName();
41 public ProductToscaYamlGenerationTest() {
42 super(name, ProductToscaYamlGenerationTest.class.getName());
46 public void productToscaYamlFormat() throws IOException {
48 String heatEnvArtifactHeader = (String) Utils.parseYamlConfig("heatEnvArtifactHeader");
49 // System.out.println("heatEnvArtifactHeader = \n" +
50 // heatEnvArtifactHeader);
52 String heatEnvArtifactFooter = (String) Utils.parseYamlConfig("heatEnvArtifactFooter");
53 // System.out.println("heatEnvArtifactFooter = \n" +
54 // heatEnvArtifactFooter);
56 // temporary commented
57 // RestResponse downloadResourceInstanceHeatArtifact =
58 // ArtifactRestUtils.downloadResourceInstanceArtifact(service.getUniqueId(),
59 // resourceInstanceId, sdncUserDetails,
60 // heatArtifactDefinition.getUniqueId());
61 // assertTrue("expected request returned status:" + 200 + ", actual: " +
62 // downloadResourceInstanceHeatArtifact.getErrorCode(),
63 // downloadResourceInstanceHeatArtifact.getErrorCode()==200);
65 // InputStream stream =
66 // getDecodedSteramFromString(downloadResourceInstanceHeatArtifact.getResponse());
67 // System.out.println(Utils.getParamValueFromYamlByKey(stream,
68 // "description", String.class));
74 private InputStream getDecodedSteramFromString(String encoded64Payload) throws IOException {
76 Gson gson = new Gson();
77 ArtifactUiDownloadData artifactUiDownloadData = gson.fromJson(encoded64Payload, ArtifactUiDownloadData.class);
78 String decodedPayload = Decoder.decode(artifactUiDownloadData.getBase64Contents());
79 return new ByteArrayInputStream(decodedPayload.getBytes());