re base code
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / config / MainToTest.java
1 package org.openecomp.sdc.ci.tests.config;
2
3
4 import org.apache.commons.io.IOUtils;
5 import org.json.JSONObject;
6 import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
7 import org.yaml.snakeyaml.Yaml;
8
9 import java.io.*;
10 import java.nio.charset.Charset;
11 import java.util.Map;
12
13 public class MainToTest {
14
15     private static final String CREDENTIALS_FILE = "credentials.yaml";
16
17 //    public static void main(String[] args) throws Exception {
18 //        System.out.println("Hello World!"); // Display the string.
19 //        System.out.println("user.dir: " + System.getProperty("user.dir"));
20 //        System.out.println(UserRoleEnum.DESIGNER.getFirstName());
21 //        String file = readFile();
22 //        convertToJson(file);
23 //        Either<Service, RestResponse> createDefaultService1e = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true);
24 //
25 //
26 //
27 //    }
28
29     private static String convertToJson(String yamlString) {
30         Yaml yaml = new Yaml();
31         Map<String, Object> map = (Map<String, Object>) yaml.load(yamlString);
32
33         JSONObject jsonObject = new JSONObject(map);
34         return jsonObject.toString();
35     }
36
37     private static String readFile() {
38
39     File credentialsFileLocal = new File(FileHandling.getSdcVnfsPath() + File.separator + "conf"
40             + File.separator + CREDENTIALS_FILE);
41
42         InputStream inputStream = null;
43         try {
44             inputStream = new FileInputStream(credentialsFileLocal);
45         } catch (FileNotFoundException e) {
46             e.printStackTrace();
47         }
48         finally {
49             try {
50                 String mystr = IOUtils.toString(inputStream, Charset.forName("UTF-8"));
51                 inputStream.close();
52                 return mystr;
53             } catch(IOException e) {
54             }
55         }
56
57         return null;
58     }
59
60
61 }