[SDC-29] rebase continue work to align source
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / product / ProductToscaYamlGenerationTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.execute.product;
22
23 import java.io.ByteArrayInputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
26
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;
33
34 import com.google.gson.Gson;
35
36 public class ProductToscaYamlGenerationTest extends ProductTestBase {
37
38         @Rule
39         public static TestName name = new TestName();
40
41         public ProductToscaYamlGenerationTest() {
42                 super(name, ProductToscaYamlGenerationTest.class.getName());
43         }
44
45         @Test
46         public void productToscaYamlFormat() throws IOException {
47
48                 String heatEnvArtifactHeader = (String) Utils.parseYamlConfig("heatEnvArtifactHeader");
49                 // System.out.println("heatEnvArtifactHeader = \n" +
50                 // heatEnvArtifactHeader);
51
52                 String heatEnvArtifactFooter = (String) Utils.parseYamlConfig("heatEnvArtifactFooter");
53                 // System.out.println("heatEnvArtifactFooter = \n" +
54                 // heatEnvArtifactFooter);
55
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);
64
65                 // InputStream stream =
66                 // getDecodedSteramFromString(downloadResourceInstanceHeatArtifact.getResponse());
67                 // System.out.println(Utils.getParamValueFromYamlByKey(stream,
68                 // "description", String.class));
69
70                 // node_types
71
72         }
73
74         private InputStream getDecodedSteramFromString(String encoded64Payload) throws IOException {
75
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());
80
81         }
82
83 }