Fix for radio buttons
[sdc.git] / asdc-tests / src / main / java / org / openecomp / sdc / ci / tests / utils / validation / TestYamlParser.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.utils.validation;
22
23 import java.io.File;
24 import java.io.IOException;
25 import java.nio.charset.StandardCharsets;
26 import java.nio.file.Files;
27 import java.nio.file.Path;
28 import java.nio.file.Paths;
29 import java.util.Map;
30 import java.util.Set;
31
32 import org.junit.Rule;
33 import org.junit.rules.TestName;
34 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
35 import org.openecomp.sdc.common.util.ZipUtil;
36 import org.testng.annotations.Test;
37 import org.yaml.snakeyaml.Yaml;
38
39
40
41
42 public class TestYamlParser extends ComponentBaseTest{
43
44
45         
46         
47         @Rule
48         public static TestName name = new TestName();
49
50         public TestYamlParser() {
51                 super(name, TestYamlParser.class.getName());
52         }
53
54         
55         
56
57         
58         @Test
59         public void testYaml() throws IOException{
60                 
61                 System.out.println("");
62                 
63                 File file = new File("\\\\Comp-1\\FileIO\\Stop.txt");
64                 
65                 
66                 //read file
67
68
69                 Map<String, byte[]> readZip = null;
70                 Path path = Paths.get("C:\\Users\\ys9693\\Documents\\csar\\attributesWithProporties\\attributesWithProporties.csar");
71                 byte[] data = Files.readAllBytes(path);
72                 if (data != null && data.length > 0) {
73                         readZip = ZipUtil.readZip(data);
74
75                 }
76
77                 byte[] artifactsBs = readZip.get("Definitions/VF_RI2_G6.yaml");
78                 String str = new String(artifactsBs, StandardCharsets.UTF_8);
79                 
80                                 
81
82                 
83                 Yaml yaml = new Yaml();
84                 Map<String, Object> load = (Map<String, Object>) yaml.load(str);
85                 Map<String, Object> topology_template = (Map<String, Object>) load.get("topology_template");
86                 Map<String, Object> node_templates = (Map<String, Object>) topology_template.get("node_templates");
87                 
88                 Set<String> keySet = node_templates.keySet();
89         }
90         
91
92 }