From d1c296df49c07da89e42b932503396c777386f99 Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Wed, 25 Dec 2019 09:32:44 +0200 Subject: Upgrade ExtentReport This removes the MongoDB reporter (`reporter.ExtentXReporter`) which was not in use. Issue-ID: VID-647 Change-Id: I39f934064a1686b9f827e174366442d64ee377f6 Signed-off-by: Ittay Stern --- .../onap/sdc/ci/tests/datatypes/Configuration.java | 23 -------- .../sdc/ci/tests/execute/setup/ExtentManager.java | 69 +++++----------------- 2 files changed, 16 insertions(+), 76 deletions(-) (limited to 'vid-automation/src/main') diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/Configuration.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/Configuration.java index d6a6c1f17..08a44c698 100644 --- a/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/Configuration.java +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/datatypes/Configuration.java @@ -5,7 +5,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; - import org.yaml.snakeyaml.Yaml; public class Configuration { @@ -20,8 +19,6 @@ public class Configuration { private boolean remoteTesting; private String browser; private String systemUnderDebug; - private String reportDBhost; - private int reportDBport; private boolean captureTraffic; private boolean useBrowserMobProxy; private String stopOnClassFailure; @@ -164,26 +161,6 @@ public class Configuration { } - public String getReportDBhost() { - return reportDBhost; - } - - - public void setReportDBhost(String reportDBhost) { - this.reportDBhost = reportDBhost; - } - - - public int getReportDBport() { - return reportDBport; - } - - - public void setReportDBport(int reportDBport) { - this.reportDBport = reportDBport; - } - - public boolean isCaptureTraffic() { return captureTraffic; } diff --git a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentManager.java b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentManager.java index c835648b5..e3efb089c 100644 --- a/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentManager.java +++ b/vid-automation/src/main/java/org/onap/sdc/ci/tests/execute/setup/ExtentManager.java @@ -20,29 +20,21 @@ package org.onap.sdc.ci.tests.execute.setup; +import com.aventstack.extentreports.ExtentReports; +import com.aventstack.extentreports.reporter.ExtentHtmlReporter; +import com.aventstack.extentreports.reporter.configuration.Protocol; +import com.aventstack.extentreports.reporter.configuration.Theme; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; - import org.onap.sdc.ci.tests.datatypes.Configuration; import org.onap.sdc.ci.tests.utilities.FileHandling; import org.testng.ITestContext; -import com.aventstack.extentreports.ExtentReports; -import com.aventstack.extentreports.reporter.ExtentHtmlReporter; -import com.aventstack.extentreports.reporter.ExtentXReporter; -import com.aventstack.extentreports.reporter.configuration.Protocol; -import com.aventstack.extentreports.reporter.configuration.Theme; - public class ExtentManager { private static final String VERSIONS_INFO_FILE_NAME = "versions.info"; private static ExtentReports extent; - private static ExtentHtmlReporter htmlReporter; - private static ExtentXReporter extentxReporter; private static final String icon = "$(document).ready(function() {" +"\n"+ "$('.brand-logo').html('').prepend(\"\").width(\"120px\").css(\"float\",\"left\").css(\"padding-left\",\"0\");$('.report-name').css(\"font-weight\",\"bold\");"+"\n"+ "})"; @@ -63,33 +55,16 @@ public class ExtentManager { } - public synchronized static ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { - String dbIp = DriverFactory.getConfiguration().getReportDBhost(); - int dbPort = DriverFactory.getConfiguration().getReportDBport(); - + public synchronized static void setReporter(String filePath, String htmlFile) { if (extent == null) { - extentxReporter = new ExtentXReporter(dbIp, dbPort); extent = new ExtentReports(); - initAndSetExtentHtmlReporter(filePath, htmlFile, isAppend); - - if(extentxReporter.config().getReportObjectId() != null){ - setExtentXReporter(isAppend); - }else{ - extentxReporter.stop(); - } + initAndSetExtentHtmlReporter(filePath, htmlFile); } - return extent; - } - - public synchronized static void setExtentXReporter(Boolean isAppend){ - extentxReporter.setAppendExisting(isAppend); - extent.attachReporter(extentxReporter); - } + } - public synchronized static void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception{ - htmlReporter = new ExtentHtmlReporter(filePath + htmlFile); + public synchronized static void initAndSetExtentHtmlReporter(String filePath, String htmlFile) { + ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(filePath + htmlFile); setConfiguration(htmlReporter); - htmlReporter.setAppendExisting(isAppend); extent.attachReporter(htmlReporter); } @@ -105,21 +80,21 @@ public class ExtentManager { if(suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())){ if (config.isUseBrowserMobProxy()){ - setTrafficCaptue(config); + setTrafficCapture(config); } - setReporter(filepath, htmlFile, true); + setReporter(filepath, htmlFile); suiteName = FileHandling.getKeyByValueFromPropertyFormatFile(filepath + VERSIONS_INFO_FILE_NAME, "suiteName"); }else{ FileHandling.deleteDirectory(SetupCDTest.getReportFolder()); FileHandling.createDirectory(filepath); - setReporter(filepath, htmlFile, false); + setReporter(filepath, htmlFile); createVersionsInfoFile(filepath , VERSIONS_INFO_FILE_NAME, envData, suiteName); } reporterDataDefinition(envData, suiteName); } - private static void createVersionsInfoFile(String path, String file, String envData, String suiteName) throws FileNotFoundException, IOException { + private static void createVersionsInfoFile(String path, String file, String envData, String suiteName) throws IOException { File myFoo = new File(path + file); FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append String versions = ("env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n"); @@ -128,21 +103,12 @@ public class ExtentManager { fooStream.close(); } - private static void reporterDataDefinition(String envData, String suiteNameFromVersionInfoFile) throws Exception { + private static void reporterDataDefinition(String envData, String suiteNameFromVersionInfoFile) { extent.setSystemInfo("Host Name Address", FileHandling.getExecutionHostAddress()); extent.setSystemInfo("ExecutedOn", envData); extent.setSystemInfo("SuiteName", suiteNameFromVersionInfoFile); } - public static void reporterDataDefinition(HashMap addedSystemInfo){ - Iterator iterator = addedSystemInfo.keySet().iterator(); - while(iterator.hasNext()){ - String key = iterator.next(); - String value = addedSystemInfo.get(key); - extent.setSystemInfo(key, value); - } - } - public static String getSuiteName(ITestContext context) { String suitePath = context.getSuite().getXmlSuite().getFileName(); if(suitePath != null){ @@ -153,15 +119,12 @@ public class ExtentManager { return null; } - public synchronized static ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception { - + public synchronized static ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) { htmlReporter.config().setTheme(Theme.STANDARD); htmlReporter.config().setEncoding("UTF-8"); htmlReporter.config().setProtocol(Protocol.HTTPS); htmlReporter.config().setDocumentTitle("Automation Report"); - htmlReporter.config().setChartVisibilityOnOpen(true); htmlReporter.config().setReportName("Automation Report"); - htmlReporter.config().setChartVisibilityOnOpen(false); htmlReporter.config().setJS(icon); return htmlReporter; } @@ -170,7 +133,7 @@ public class ExtentManager { extent.flush(); } - public static void setTrafficCaptue(Configuration config) { + public static void setTrafficCapture(Configuration config) { config.setCaptureTraffic(true); } } -- cgit 1.2.3-korg