re base code
[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 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;
30
31 import java.io.ByteArrayInputStream;
32 import java.io.IOException;
33 import java.io.InputStream;
34
35 public class ProductToscaYamlGenerationTest extends ProductTestBase {
36
37         @Rule
38         public static TestName name = new TestName();
39
40         public ProductToscaYamlGenerationTest() {
41                 super(name, ProductToscaYamlGenerationTest.class.getName());
42         }
43
44         @Test
45         public void productToscaYamlFormat() throws IOException {
46
47                 String heatEnvArtifactHeader = (String) Utils.parseYamlConfig("heatEnvArtifactHeader");
48                 // System.out.println("heatEnvArtifactHeader = \n" +
49                 // heatEnvArtifactHeader);
50
51                 String heatEnvArtifactFooter = (String) Utils.parseYamlConfig("heatEnvArtifactFooter");
52                 // System.out.println("heatEnvArtifactFooter = \n" +
53                 // heatEnvArtifactFooter);
54
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);
63
64                 // InputStream stream =
65                 // getDecodedSteramFromString(downloadResourceInstanceHeatArtifact.getResponse());
66                 // System.out.println(Utils.getParamValueFromYamlByKey(stream,
67                 // "description", String.class));
68
69                 // node_types
70
71         }
72
73         private InputStream getDecodedSteramFromString(String encoded64Payload) throws IOException {
74
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());
79
80         }
81
82 }