Added oparent to sdc main
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / config / MainToTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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.config;
22
23
24 import org.apache.commons.io.IOUtils;
25 import org.json.JSONObject;
26 import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
27 import org.yaml.snakeyaml.Yaml;
28
29 import java.io.*;
30 import java.nio.charset.Charset;
31 import java.util.Map;
32
33 public class MainToTest {
34
35     private static final String CREDENTIALS_FILE = "credentials.yaml";
36
37 //    public static void main(String[] args) throws Exception {
38 //        System.out.println("Hello World!"); // Display the string.
39 //        System.out.println("user.dir: " + System.getProperty("user.dir"));
40 //        System.out.println(UserRoleEnum.DESIGNER.getFirstName());
41 //        String file = readFile();
42 //        convertToJson(file);
43 //        Either<Service, RestResponse> createDefaultService1e = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true);
44 //
45 //
46 //
47 //    }
48
49     private static String convertToJson(String yamlString) {
50         Yaml yaml = new Yaml();
51         Map<String, Object> map = (Map<String, Object>) yaml.load(yamlString);
52
53         JSONObject jsonObject = new JSONObject(map);
54         return jsonObject.toString();
55     }
56
57     private static String readFile() {
58
59     File credentialsFileLocal = new File(FileHandling.getSdcVnfsPath() + File.separator + "conf"
60             + File.separator + CREDENTIALS_FILE);
61
62         InputStream inputStream = null;
63         try {
64             inputStream = new FileInputStream(credentialsFileLocal);
65         } catch (FileNotFoundException e) {
66             e.printStackTrace();
67         }
68         finally {
69             try {
70                 String mystr = IOUtils.toString(inputStream, Charset.forName("UTF-8"));
71                 inputStream.close();
72                 return mystr;
73             } catch(IOException e) {
74             }
75         }
76
77         return null;
78     }
79
80
81 }