[SDC-29] rebase continue work to align source
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / api / ExtentManager.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
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.api;
22
23 import org.openecomp.sdc.ci.tests.utils.rest.AutomationUtils;
24
25 import com.aventstack.extentreports.ExtentReports;
26 import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
27 import com.aventstack.extentreports.reporter.ExtentXReporter;
28 import com.aventstack.extentreports.reporter.configuration.Protocol;
29 import com.aventstack.extentreports.reporter.configuration.Theme;
30
31 public class ExtentManager {
32
33     private static ExtentReports extent;
34     
35     public synchronized static ExtentReports getReporter(String filePath) {
36         if (extent == null) {
37                 // initialize the HtmlReporter
38                 ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(filePath);
39                 
40                 // initialize ExtentReports and attach the HtmlReporter
41                 extent = new ExtentReports();
42
43                 // attach all reporters
44                 extent.attachReporter(htmlReporter);
45
46             
47         }
48         
49         return extent;
50     }
51     
52     public synchronized static ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) {
53         htmlReporter.config().setTheme(Theme.STANDARD);
54         
55         htmlReporter.config().setEncoding("UTF-8");
56         
57         htmlReporter.config().setProtocol(Protocol.HTTPS);
58         
59         htmlReporter.config().setDocumentTitle("ASDC Automation Report");
60         
61         htmlReporter.config().setChartVisibilityOnOpen(true);
62         
63         htmlReporter.config().setReportName(AutomationUtils.getOSVersion());
64         
65         return htmlReporter;
66     }
67     
68     public synchronized static ExtentReports getReporter() {
69         return extent;
70     }
71 }
72