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.rest;
24 import java.io.FileNotFoundException;
25 import java.io.FileOutputStream;
26 import java.io.IOException;
28 import org.openecomp.sdc.ci.tests.config.Config;
29 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
30 import org.openecomp.sdc.ci.tests.utils.Utils;
32 public class AutomationUtils extends BaseRestUtils {
35 public static String getOnboardVersion() {
36 String onboardVersionStr = null;
39 RestResponse onboardVersion = CatalogRestUtils.getOnboardVersion();
40 onboardVersionStr = ResponseParser.getValueFromJsonResponse(onboardVersion.getResponse() , "Version");
42 } catch (Exception e) {
43 System.out.println("UnknownOnboardVersion");
45 return onboardVersionStr != null ? onboardVersionStr : "UnknownOnboardVersion";
49 public static String getOSVersion() {
50 String osVersionStr = null;
52 RestResponse osVersion = CatalogRestUtils.getOsVersion();
53 osVersionStr = ResponseParser.getVersionFromResponse(osVersion);
55 } catch (Exception e) {
56 System.out.println("UnknownOSversion");
59 return osVersionStr != null ? osVersionStr : "UnknownOSversion" ;
64 public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName)
65 throws FileNotFoundException, IOException {
66 File myFoo = new File(filepath);
67 FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append
68 String versions = ("onboardVesrion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n");
69 byte[] myBytes = versions.getBytes();
70 fooStream.write(myBytes);
74 public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData)
75 throws FileNotFoundException, IOException {
76 createVersionsInfoFile(filepath, onboardVersion, osVersion, envData, null);
79 public static void addEnvDetailsToReport() throws FileNotFoundException{
81 Config config = Utils.getConfig();
85 public static File getConfigFile(String configFileName) throws Exception {
86 File configFile = new File(getBasePath() + File.separator + "conf" + File.separator + configFileName);
87 if (!configFile.exists()) {
88 configFile = new File(getConfFilesPath() + configFileName);
93 public static String getCiFilesPath() {
94 return getBasePath() + File.separator + "src" + File.separator + "main" + File.separator + "resources"
95 + File.separator + "ci";
98 public static String getConfFilesPath() {
99 return getCiFilesPath() + File.separator + "conf" + File.separator;
102 public static String getTestSuitesFilesPath() {
103 return getCiFilesPath() + File.separator + "testSuites" + File.separator;
105 public static String getBasePath() {
106 return System.getProperty("user.dir");