1 package org.onap.sdc.ci.tests.datatypes;
4 import java.io.IOException;
5 import java.io.InputStream;
6 import java.nio.file.Files;
7 import java.nio.file.Paths;
9 import org.yaml.snakeyaml.Yaml;
11 public class Configuration {
13 private String beHost;
14 private String feHost;
18 private String remoteTestingMachineIP;
19 private int remoteTestingMachinePort;
20 private boolean remoteTesting;
21 private String browser;
22 private String systemUnderDebug;
23 private String reportDBhost;
24 private int reportDBport;
25 private boolean captureTraffic;
26 private boolean useBrowserMobProxy;
27 private String stopOnClassFailure;
28 private String reportFileName;
29 private String reportFolder;
30 private int numOfAttemptsToRefresh;
31 private boolean rerun;
32 private String windowsDownloadDirectory;
33 private String screenshotFolder;
34 private String harFilesFolder;
35 private boolean useCustomLogin;
36 private String geckoDriverPath;
38 public Configuration(String url) {
40 basicInit(url, false);
43 public Configuration(String url, boolean useCustomLogin) {
45 basicInit(url, useCustomLogin);
48 private void basicInit(String url, boolean useCustomLogin) {
49 this.remoteTesting = false;
50 this.captureTraffic = false;
51 this.useBrowserMobProxy = false;
52 this.reportFolder = "." + File.separator + "ExtentReport" + File.separator;
53 this.reportFileName = "UI_Extent_Report.html";
54 this.screenshotFolder = reportFolder + "screenshots" + File.separator;
55 this.harFilesFolder = reportFolder + "har_files" + File.separator;
56 this.browser = "firefox";
58 this.numOfAttemptsToRefresh = 2;
59 this.useCustomLogin = useCustomLogin;
60 this.geckoDriverPath = null;
63 public String getGeckoDriverPath(){
64 return this.geckoDriverPath; }
66 public void setGeckoDriverPath(String geckoDriverPath){ this.geckoDriverPath = geckoDriverPath; }
68 public String getBeHost() {
72 public void setBeHost(String beHost) {
77 public String getFeHost() {
82 public void setFeHost(String feHost) {
87 public int getBePort() {
92 public void setBePort(int bePort) {
97 public int getFePort() {
102 public void setFePort(int fePort) {
103 this.fePort = fePort;
107 public String getUrl() {
112 public void setUrl(String url) {
117 public String getRemoteTestingMachineIP() {
118 return remoteTestingMachineIP;
122 public void setRemoteTestingMachineIP(String remoteTestingMachineIP) {
123 this.remoteTestingMachineIP = remoteTestingMachineIP;
127 public int getRemoteTestingMachinePort() {
128 return remoteTestingMachinePort;
132 public void setRemoteTestingMachinePort(int remoteTestingMachinePort) {
133 this.remoteTestingMachinePort = remoteTestingMachinePort;
137 public boolean isRemoteTesting() {
138 return remoteTesting;
142 public void setRemoteTesting(boolean remoteTesting) {
143 this.remoteTesting = remoteTesting;
147 public String getBrowser() {
152 public void setBrowser(String browser) {
153 this.browser = browser;
157 public String getSystemUnderDebug() {
158 return systemUnderDebug;
162 public void setSystemUnderDebug(String systemUnderDebug) {
163 this.systemUnderDebug = systemUnderDebug;
167 public String getReportDBhost() {
172 public void setReportDBhost(String reportDBhost) {
173 this.reportDBhost = reportDBhost;
177 public int getReportDBport() {
182 public void setReportDBport(int reportDBport) {
183 this.reportDBport = reportDBport;
187 public boolean isCaptureTraffic() {
188 return captureTraffic;
192 public void setCaptureTraffic(boolean captureTraffic) {
193 this.captureTraffic = captureTraffic;
197 public boolean isUseBrowserMobProxy() {
198 return useBrowserMobProxy;
202 public void setUseBrowserMobProxy(boolean useBrowserMobProxy) {
203 this.useBrowserMobProxy = useBrowserMobProxy;
207 public String getStopOnClassFailure() {
208 return stopOnClassFailure;
212 public void setStopOnClassFailure(String stopOnClassFailure) {
213 this.stopOnClassFailure = stopOnClassFailure;
217 public String getReportFileName() {
218 return reportFileName;
222 public void setReportFileName(String reportFileName) {
223 this.reportFileName = reportFileName;
227 public String getReportFolder() {
232 public void setReportFolder(String reportFolder) {
233 this.reportFolder = reportFolder;
237 public int getNumOfAttemptsToRefresh() {
238 return numOfAttemptsToRefresh;
242 public void setNumOfAttemptsToRefresh(int numOfAttemptsToRefresh) {
243 this.numOfAttemptsToRefresh = numOfAttemptsToRefresh;
247 public boolean isRerun() {
252 public void setRerun(boolean rerun) {
259 public String getWindowsDownloadDirectory() {
260 return windowsDownloadDirectory;
263 public void setWindowsDownloadDirectory(String windowsDownloadDirectory) {
264 this.windowsDownloadDirectory = windowsDownloadDirectory;
267 public String getScreenshotFolder() {
268 return screenshotFolder;
271 public void setScreenshotFolder(String screenshotFolder) {
272 this.screenshotFolder = screenshotFolder;
275 public String getHarFilesFolder() {
276 return harFilesFolder;
279 public void setHarFilesFolder(String harFilesFolder) {
280 this.harFilesFolder = harFilesFolder;
283 public boolean isUseCustomLogin() {
284 return useCustomLogin;
287 public void setUseCustomLogin(boolean useCustomLogin) {
288 this.useCustomLogin = useCustomLogin;
291 public synchronized static Configuration loadConfigFile(File configFile) {
292 return loadConfigFile(configFile, Configuration.class);
295 public Configuration(){
299 public synchronized static <T> T loadConfigFile(File configFile, Class<T> clazz){
300 InputStream in = null;
303 String absolutePath = configFile.getAbsolutePath();
304 in = Files.newInputStream(Paths.get(absolutePath));
305 Yaml yaml = new Yaml();
306 config = yaml.loadAs(in, clazz);
308 } catch (IOException e) {
314 } catch (IOException e) {