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.utils.validation;
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;
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;
42 public class TestYamlParser extends ComponentBaseTest{
48 public static TestName name = new TestName();
50 public TestYamlParser() {
51 super(name, TestYamlParser.class.getName());
59 public void testYaml() throws IOException{
61 System.out.println("");
63 File file = new File("\\\\Comp-1\\FileIO\\Stop.txt");
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);
77 byte[] artifactsBs = readZip.get("Definitions/VF_RI2_G6.yaml");
78 String str = new String(artifactsBs, StandardCharsets.UTF_8);
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");
88 Set<String> keySet = node_templates.keySet();