1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*-
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.openecomp.sdc.ci.tests.utils.rest;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class AutomationUtils extends BaseRestUtils {
public static String getOnboardVersion() {
String onboardVersionStr = null;
try {
RestResponse onboardVersion = CatalogRestUtils.getOnboardVersion();
onboardVersionStr = ResponseParser.getValueFromJsonResponse(onboardVersion.getResponse() , "Version");
} catch (Exception e) {
System.out.println("UnknownOnboardVersion");
}
return onboardVersionStr != null ? onboardVersionStr : "UnknownOnboardVersion";
}
public static String getOSVersion() {
String osVersionStr = null;
try {
RestResponse osVersion = CatalogRestUtils.getOsVersion();
osVersionStr = ResponseParser.getVersionFromResponse(osVersion);
} catch (Exception e) {
System.out.println("UnknownOSversion");
}
return osVersionStr != null ? osVersionStr : "UnknownOSversion" ;
}
public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName) throws IOException {
File myFoo = new File(filepath);
try (FileOutputStream fooStream = new FileOutputStream(myFoo, false)) {
String versions = ("onboardVersion=\"" + onboardVersion + "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\"" + envData + "\"\n" + "suiteName=\"" + suiteName + "\"\n");
byte[] myBytes = versions.getBytes();
fooStream.write(myBytes);
}
}
public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName, String reportStartTime) throws IOException {
File myFoo = new File(filepath);
try (FileOutputStream fooStream = new FileOutputStream(myFoo, false)) {
String versions = ("onboardVersion=\"" + onboardVersion + "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\"" + envData + "\"\n" + "suiteName=\"" + suiteName + "\"\n" + "reportStartTime=\"" + reportStartTime + "\"\n");
byte[] myBytes = versions.getBytes();
fooStream.write(myBytes);
}
}
public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData)
throws IOException {
createVersionsInfoFile(filepath, onboardVersion, osVersion, envData, null);
}
public static void addEnvDetailsToReport() throws FileNotFoundException{
Config config = Utils.getConfig();
config.getUrl();
}
public static File getConfigFile(String configFileName) throws Exception {
File configFile = new File(getBasePath() + File.separator + "conf" + File.separator + configFileName);
if (!configFile.exists()) {
configFile = new File(getConfFilesPath() + configFileName);
}
return configFile;
}
public static String getCiFilesPath() {
return getBasePath() + File.separator + "src" + File.separator + "main" + File.separator + "resources"
+ File.separator + "ci";
}
public static String getConfFilesPath() {
return getCiFilesPath() + File.separator + "conf" + File.separator;
}
public static String getTestSuitesFilesPath() {
return getCiFilesPath() + File.separator + "testSuites" + File.separator;
}
public static String getBasePath() {
return System.getProperty("user.dir");
}
}
|