From b21dbd3f34941e416094e90f508b312415952f0b Mon Sep 17 00:00:00 2001 From: vasraz Date: Tue, 20 Apr 2021 17:32:14 +0100 Subject: Improve readability of IT Config Replace with lombok (Getter/Setter) Change-Id: I2b40eb0f16018efb92c14c5fcf397c5c1fa63c67 Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3565 --- .../backend/ci/tests/api/ComponentBaseTest.java | 34 +- .../sdc/backend/ci/tests/api/ExtentManager.java | 215 ++++---- .../onap/sdc/backend/ci/tests/config/Config.java | 586 ++------------------- .../ci/tests/utils/cassandra/CassandraUtils.java | 55 +- .../ci/tests/execute/setup/ExtentManager.java | 34 +- .../ci/tests/execute/setup/SetupCDTest.java | 31 +- .../frontend/ci/tests/utilities/RestCDUtils.java | 39 +- 7 files changed, 261 insertions(+), 733 deletions(-) diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/api/ComponentBaseTest.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/api/ComponentBaseTest.java index 985d161dd6..4bb7b61624 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/api/ComponentBaseTest.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/api/ComponentBaseTest.java @@ -43,6 +43,12 @@ import org.onap.sdc.backend.ci.tests.utils.Utils; import org.onap.sdc.backend.ci.tests.utils.general.AtomicOperationUtils; import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory; import org.onap.sdc.backend.ci.tests.utils.general.FileHandling; +import org.onap.sdc.backend.ci.tests.utils.rest.BaseRestUtils; +import org.onap.sdc.backend.ci.tests.utils.rest.CatalogRestUtils; +import org.onap.sdc.backend.ci.tests.utils.rest.ProductRestUtils; +import org.onap.sdc.backend.ci.tests.utils.rest.ResourceRestUtils; +import org.onap.sdc.backend.ci.tests.utils.rest.ResponseParser; +import org.onap.sdc.backend.ci.tests.utils.rest.ServiceRestUtils; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Component; @@ -50,12 +56,6 @@ import org.openecomp.sdc.be.model.Product; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; -import org.onap.sdc.backend.ci.tests.utils.rest.BaseRestUtils; -import org.onap.sdc.backend.ci.tests.utils.rest.CatalogRestUtils; -import org.onap.sdc.backend.ci.tests.utils.rest.ProductRestUtils; -import org.onap.sdc.backend.ci.tests.utils.rest.ResourceRestUtils; -import org.onap.sdc.backend.ci.tests.utils.rest.ResponseParser; -import org.onap.sdc.backend.ci.tests.utils.rest.ServiceRestUtils; import org.slf4j.LoggerFactory; import org.testng.ITestContext; import org.testng.ITestResult; @@ -108,7 +108,7 @@ public abstract class ComponentBaseTest { @BeforeMethod(alwaysRun = true) public void setupBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception { if (!"onboardVNFShotFlow".equals(method.getName()) && - !"onboardPNFFlow".equals(method.getName())) { + !"onboardPNFFlow".equals(method.getName())) { logger.info("ExtentReport instance started from BeforeMethod..."); ExtentTestManager.startTest(method.getName()); ExtentTestManager.assignCategory(this.getClass()); @@ -147,16 +147,18 @@ public abstract class ComponentBaseTest { } public void setLog(String fromDataProvider) { - ExtentTestManager.startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "      " + fromDataProvider); + ExtentTestManager + .startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "      " + fromDataProvider); ExtentTestManager.assignCategory(this.getClass()); } protected static void performClean() throws Exception { - if (!config.getSystemUnderDebug()) { + if (!config.isSystemUnderDebug()) { deleteCreatedComponents(getCatalogAsMap()); FileHandling.overWriteExistindDir("target/outputCsar"); } else { - System.out.println("Accordindig to configuration components will not be deleted, in case to unable option to delete, please change systemUnderDebug parameter value to false ..."); + System.out.println( + "Accordindig to configuration components will not be deleted, in case to unable option to delete, please change systemUnderDebug parameter value to false ..."); } } @@ -184,16 +186,15 @@ public abstract class ComponentBaseTest { protected static List buildCollectionUniqueId(List resourcesArrayList) { - List genericCollection = new ArrayList<>(); if (resourcesArrayList.get(0) != null) { ComponentTypeEnum componentTypeEnum = resourcesArrayList.get(0).getComponentType(); resourcesArrayList.stream().filter(Objects::nonNull). - filter(s -> s.getName().toLowerCase().startsWith("ci") && !s.getName().toLowerCase().equals("cindervolume")). - filter(f -> f.getUniqueId() != null). - map(Component::getUniqueId). - collect(Collectors.toList()). - forEach((i) -> buildCollectionBaseOnComponentType(componentTypeEnum, genericCollection, i)); + filter(s -> s.getName().toLowerCase().startsWith("ci") && !s.getName().toLowerCase().equals("cindervolume")). + filter(f -> f.getUniqueId() != null). + map(Component::getUniqueId). + collect(Collectors.toList()). + forEach((i) -> buildCollectionBaseOnComponentType(componentTypeEnum, genericCollection, i)); } return genericCollection; } @@ -219,7 +220,6 @@ public abstract class ComponentBaseTest { break; - case PRODUCT: RestResponse product = ProductRestUtils.getProduct(i); Product convertProductResponseToJavaObject = ResponseParser.convertProductResponseToJavaObject(product.getResponse()); diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/api/ExtentManager.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/api/ExtentManager.java index 02fe121d5c..e1961a2dd4 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/api/ExtentManager.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/api/ExtentManager.java @@ -7,9 +7,9 @@ * 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. @@ -25,137 +25,138 @@ 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; +import java.io.File; import org.onap.sdc.backend.ci.tests.config.Config; import org.onap.sdc.backend.ci.tests.utils.Utils; import org.onap.sdc.backend.ci.tests.utils.general.FileHandling; import org.onap.sdc.backend.ci.tests.utils.rest.AutomationUtils; import org.testng.ITestContext; -import java.io.File; - 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; - public enum suiteNameXml { + private static final String VERSIONS_INFO_FILE_NAME = "versions.info"; + private static ExtentReports extent; + private static ExtentHtmlReporter htmlReporter; + private static ExtentXReporter extentxReporter; - TESTNG_FAILED_XML_NAME("testng-failed.xml"); + public enum suiteNameXml { - suiteNameXml(String value) { - this.value = value; - } + TESTNG_FAILED_XML_NAME("testng-failed.xml"); + + suiteNameXml(String value) { + this.value = value; + } - private String value; + private String value; + + public String getValue() { + return value; + } + + } - public String getValue() { - return value; - } - - } - public synchronized static ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { - String dbIp = Utils.getConfig().getReportDBhost(); - int dbPort = Utils.getConfig().getReportDBport(); - - 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(); - } + String dbIp = Utils.getConfig().getReportDBhost(); + int dbPort = Utils.getConfig().getReportDBport(); + + 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(); + } } return extent; } - - public synchronized static void setExtentXReporter(Boolean isAppend){ - extentxReporter.setAppendExisting(isAppend); - extent.attachReporter(extentxReporter); + + 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); - setConfiguration(htmlReporter); - htmlReporter.setAppendExisting(isAppend); - extent.attachReporter(htmlReporter); + + public synchronized static void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { + htmlReporter = new ExtentHtmlReporter(filePath + htmlFile); + setConfiguration(htmlReporter); + htmlReporter.setAppendExisting(isAppend); + extent.attachReporter(htmlReporter); } public synchronized static ExtentReports getReporter() { return extent; } - public static void initReporter(String filepath, String htmlFile, ITestContext context) throws Exception { - - String onboardVersion = AutomationUtils.getOnboardVersion(); - String osVersion = AutomationUtils.getOSVersion(); - Config config = Utils.getConfig(); - String envData = config.getUrl(); - String suiteName = getSuiteName(context); - - if(suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())){ - if (config.getUseBrowserMobProxy()) - setTrafficCaptue(config); - - setReporter(filepath, htmlFile, true); - String suiteNameFromVersionInfoFile = FileHandling.getKeyByValueFromPropertyFormatFile(filepath + VERSIONS_INFO_FILE_NAME, "suiteName"); - reporterDataDefinition(onboardVersion, osVersion, envData, suiteNameFromVersionInfoFile); - }else{ - FileHandling.deleteDirectory(ComponentBaseTest.getReportFolder()); - FileHandling.createDirectory(filepath); - setReporter(filepath, htmlFile, false); - reporterDataDefinition(onboardVersion, osVersion, envData, suiteName); - AutomationUtils.createVersionsInfoFile(filepath + VERSIONS_INFO_FILE_NAME, onboardVersion, osVersion, envData, suiteName); - } - - } - - public static void reporterDataDefinition(String onboardVersion, String osVersion, String envData, String suiteNameFromVersionInfoFile) throws Exception { - extent.setSystemInfo("Onboard Version", onboardVersion); - extent.setSystemInfo("OS Version", osVersion); + public static void initReporter(String filepath, String htmlFile, ITestContext context) throws Exception { + + String onboardVersion = AutomationUtils.getOnboardVersion(); + String osVersion = AutomationUtils.getOSVersion(); + Config config = Utils.getConfig(); + String envData = config.getUrl(); + String suiteName = getSuiteName(context); + + if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { + if (config.isUseBrowserMobProxy()) { + setTrafficCaptue(config); + } + + setReporter(filepath, htmlFile, true); + String suiteNameFromVersionInfoFile = FileHandling.getKeyByValueFromPropertyFormatFile(filepath + VERSIONS_INFO_FILE_NAME, "suiteName"); + reporterDataDefinition(onboardVersion, osVersion, envData, suiteNameFromVersionInfoFile); + } else { + FileHandling.deleteDirectory(ComponentBaseTest.getReportFolder()); + FileHandling.createDirectory(filepath); + setReporter(filepath, htmlFile, false); + reporterDataDefinition(onboardVersion, osVersion, envData, suiteName); + AutomationUtils.createVersionsInfoFile(filepath + VERSIONS_INFO_FILE_NAME, onboardVersion, osVersion, envData, suiteName); + } + + } + + public static void reporterDataDefinition(String onboardVersion, String osVersion, String envData, String suiteNameFromVersionInfoFile) + throws Exception { + extent.setSystemInfo("Onboard Version", onboardVersion); + extent.setSystemInfo("OS Version", osVersion); // extent.setSystemInfo("Host Name Address", RestCDUtils.getExecutionHostAddress()); - extent.setSystemInfo("ExecutedOn", envData); - extent.setSystemInfo("SuiteName", suiteNameFromVersionInfoFile); - } - - public static String getSuiteName(ITestContext context) { - String suitePath = context.getSuite().getXmlSuite().getFileName(); - if(suitePath != null){ - File file = new File(suitePath); - String suiteName = file.getName(); - return suiteName; - } - return null; - } - - public synchronized static ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception { - - htmlReporter.config().setTheme(Theme.STANDARD); - htmlReporter.config().setEncoding("UTF-8"); - htmlReporter.config().setProtocol(Protocol.HTTPS); - htmlReporter.config().setDocumentTitle("SDC Automation Report"); - htmlReporter.config().setChartVisibilityOnOpen(true); + extent.setSystemInfo("ExecutedOn", envData); + extent.setSystemInfo("SuiteName", suiteNameFromVersionInfoFile); + } + + public static String getSuiteName(ITestContext context) { + String suitePath = context.getSuite().getXmlSuite().getFileName(); + if (suitePath != null) { + File file = new File(suitePath); + String suiteName = file.getName(); + return suiteName; + } + return null; + } + + public synchronized static ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception { + + htmlReporter.config().setTheme(Theme.STANDARD); + htmlReporter.config().setEncoding("UTF-8"); + htmlReporter.config().setProtocol(Protocol.HTTPS); + htmlReporter.config().setDocumentTitle("SDC Automation Report"); + htmlReporter.config().setChartVisibilityOnOpen(true); // htmlReporter.config().setReportName(AutomationUtils.getATTVersion()); - htmlReporter.config().setReportName("SDC Automation Report"); - htmlReporter.config().setChartVisibilityOnOpen(false); + htmlReporter.config().setReportName("SDC Automation Report"); + htmlReporter.config().setChartVisibilityOnOpen(false); // htmlReporter.config().setJS(icon); - return htmlReporter; + return htmlReporter; + } + + public static void closeReporter() { + extent.flush(); + } + + public static void setTrafficCaptue(Config config) { + boolean mobProxyStatus = config.isUseBrowserMobProxy(); + if (mobProxyStatus) { + config.setCaptureTraffic(true); + } } - - public static void closeReporter(){ - extent.flush(); - } - - public static void setTrafficCaptue(Config config) { - boolean mobProxyStatus = config.getUseBrowserMobProxy(); - if (mobProxyStatus){ - config.setCaptureTraffic(true);; - } - } } diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/config/Config.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/config/Config.java index 88d6154f0e..14b4efa275 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/config/Config.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/config/Config.java @@ -20,24 +20,29 @@ package org.onap.sdc.backend.ci.tests.config; -import org.yaml.snakeyaml.Yaml; - import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.yaml.snakeyaml.Yaml; +@Getter +@Setter public class Config { private static final String SDC_DEFAULT_CONFIG_FILE = "src/test/resources/ci/conf/sdc-conf.yaml"; + private static Config configIt = null; + private String configurationFile; private String downloadAutomationFolder; private boolean systemUnderDebug; private boolean rerun; private String reportDBhost; private int reportDBport; - private String browser; private String catalogBeHost; private String esHost; @@ -47,38 +52,30 @@ public class Config { private String disributionClientHost; private String disributionClientPort; private boolean isDistributionClientRunning; - - private String errorConfigurationFile; private String resourceConfigDir; private String importResourceConfigDir; private String importResourceTestsConfigDir; - private String catalogFeHost; private String catalogFePort; private String catalogBePort; private String catalogBeTlsPort; - private String onboardingBeHost; private String onboardingBePort; - private String neoDBusername; private String neoDBpassword; - private List packages; private List bugs; private List resourcesNotToDelete; private List resourceCategoriesNotToDelete; private List serviceCategoriesNotToDelete; private boolean stopOnClassFailure = false; - private String outputFolder; private String reportName; private String url; private String remoteTestingMachineIP; private String remoteTestingMachinePort; private boolean remoteTesting; - private String cassandraHost; private String cassandraAuditKeySpace; private String cassandraArtifactKeySpace; @@ -94,71 +91,15 @@ public class Config { private String localDataCenter; private boolean uiSimulator; - public String getLocalDataCenter() { - return localDataCenter; - } - - public void setLocalDataCenter(String localDataCenter) { - this.localDataCenter = localDataCenter; - } - - private static Config configIt = null; - - private static final Yaml yaml = new Yaml(); - private Config() { super(); } - public String getOnboardingBePort() { - return onboardingBePort; - } - - public void setOnboardingBePort(String onboardingBePort) { - this.onboardingBePort = onboardingBePort; - } - - public String getOnboardingBeHost() { - return onboardingBeHost; - } - - public void setOnboardingBeHost(String onboardingBeHost) { - this.onboardingBeHost = onboardingBeHost; - } - - public static class TestPackages { - - List packages; - List bugs; - - public List getPackages() { - return packages; - } - - public void setPackages(List packages) { - this.packages = packages; - } - - public List getBugs() { - return bugs; - } - - public void setBugs(List bugs) { - this.bugs = bugs; - } - - @Override - public String toString() { - return "TestPackages [packages=" + packages + ", bugs=" + bugs + "]"; - } - - } - public synchronized static Config instance() { if (configIt == null) { try { configIt = init(); - } catch (IOException e) { + } catch (final IOException e) { e.printStackTrace(); return null; } @@ -173,503 +114,82 @@ public class Config { configFile = SDC_DEFAULT_CONFIG_FILE; } - final File file = new File(configFile); - if (!file.exists()) { + if (!((new File(configFile)).exists())) { throw new RuntimeException("The config file " + configFile + " cannot be found."); } final Config config; - InputStream in = null; - try { - - in = Files.newInputStream(Paths.get(configFile)); - - config = yaml.loadAs(in, Config.class); + try (final InputStream in = Files.newInputStream(Paths.get(configFile));) { + config = new Yaml().loadAs(in, Config.class); setPackagesAndBugs(configFile, config); - - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } } return config; } - public boolean isUiSimulator() { - return uiSimulator; - } + private static void setPackagesAndBugs(final String path, final Config config) throws IOException { - public void setUiSimulator(boolean uiSimulator) { - this.uiSimulator = uiSimulator; - } - - private static void setPackagesAndBugs(String path, Config config) throws IOException { + final int separator = Math.max(path.lastIndexOf("\\"), path.lastIndexOf("/")); + final String dirPath = path.substring(0, separator + 1); + final String packagesFile = dirPath + File.separator + "sdc-packages.yaml"; - int separator = Math.max(path.lastIndexOf("\\"), path.lastIndexOf("/")); - String dirPath = path.substring(0, separator + 1); - String packagesFile = dirPath + File.separator + "sdc-packages.yaml"; - File file = new File(packagesFile); - if (false == file.exists()) { + if (!((new File(packagesFile)).exists())) { throw new RuntimeException("The config file " + packagesFile + " cannot be found."); } - TestPackages testPackages = null; - InputStream in = null; - try { - - in = Files.newInputStream(Paths.get(packagesFile)); - - testPackages = yaml.loadAs(in, TestPackages.class); - - List bugs = testPackages.getBugs(); - List packages = testPackages.getPackages(); - - config.setBugs(bugs); - config.setPackages(packages); - - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + try (final InputStream in = Files.newInputStream(Paths.get(packagesFile));) { + final TestPackages testPackages = new Yaml().loadAs(in, TestPackages.class); + config.setBugs(testPackages.getBugs()); + config.setPackages(testPackages.getPackages()); } } - String configurationFile; - - public boolean getSystemUnderDebug() { - return systemUnderDebug; - } - - public void setSystemUnderDebug(boolean systemUnderDebug) { - this.systemUnderDebug = systemUnderDebug; - } - - public String getSdcHttpMethod() { - return sdcHttpMethod; - } - - public void setSdcHttpMethod(String sdcHttpMethod) { - this.sdcHttpMethod = sdcHttpMethod; - } - - public boolean getRerun() { - return rerun; - } - - public void setRerun(boolean rerun) { - this.rerun = rerun; - } - - 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 String getBrowser() { - return browser; - } - - public boolean getUseBrowserMobProxy() { - return useBrowserMobProxy; - } - - public void setUseBrowserMobProxy(boolean useBrowserMobProxy) { - this.useBrowserMobProxy = useBrowserMobProxy; - } - - - public boolean getCaptureTraffic() { - return captureTraffic; - } - - public void setCaptureTraffic(boolean captureTraffic) { - this.captureTraffic = captureTraffic; - } - - public void setBrowser(String browser) { - this.browser = browser; - } - - public String getConfigurationFile() { - return configurationFile; - } - - public void setConfigurationFile(String configurationFile) { - this.configurationFile = configurationFile; - } - public boolean getIsDistributionClientRunning() { return isDistributionClientRunning; } - public void setIsDistributionClientRunning(boolean isDistributionClientRunning) { + public void setIsDistributionClientRunning(final boolean isDistributionClientRunning) { this.isDistributionClientRunning = isDistributionClientRunning; } - public String getCatalogBePort() { - return catalogBePort; - } - - public String getDisributionClientHost() { - return disributionClientHost; - } - - public void setDisributionClientHost(String disributionClientHost) { - this.disributionClientHost = disributionClientHost; - } - - public String getDisributionClientPort() { - return disributionClientPort; - } - - public void setDisributionClientPort(String disributionClientPort) { - this.disributionClientPort = disributionClientPort; - } - - public void setCatalogBePort(String catalogBePort) { - this.catalogBePort = catalogBePort; - } - - public String getCatalogFeHost() { - return catalogFeHost; - } - - public void setCatalogFeHost(String catalogFeHost) { - this.catalogFeHost = catalogFeHost; - } - - public String getCatalogFePort() { - return catalogFePort; - } - - public void setCatalogFePort(String catalogFePort) { - this.catalogFePort = catalogFePort; - } - - public String getCatalogBeHost() { - return catalogBeHost; - } - - public void setCatalogBeHost(String catalogBeHost) { - this.catalogBeHost = catalogBeHost; - } - - public String getEsHost() { - return esHost; - } - - public void setEsHost(String esHost) { - this.esHost = esHost; - } - - public String getEsPort() { - return esPort; - } - - public void setEsPort(String esPort) { - this.esPort = esPort; - } - - public String getResourceConfigDir() { - return resourceConfigDir; - } - - public void setResourceConfigDir(String resourceConfigDir) { - this.resourceConfigDir = resourceConfigDir; - } - - public String getOutputFolder() { - return outputFolder; - } - - public void setOutputFolder(String outputFolder) { - this.outputFolder = outputFolder; - } - - public String getReportName() { - return reportName; - } - - public void setReportName(String reportName) { - this.reportName = reportName; - } - - public String getNeoPort() { - return neoPort; - } - - public void setNeoPort(String neoPort) { - this.neoPort = neoPort; - } - - public String getNeoHost() { - return neoHost; - } - - public void setNeoHost(String neoHost) { - this.neoHost = neoHost; - } - - public String getNeoDBpassword() { - return neoDBpassword; - } - - public String getNeoDBusername() { - return neoDBusername; - } - - public void setNeoDBusername(String neoDBusername) { - this.neoDBusername = neoDBusername; - } - - public void setNeoDBpassword(String neoDBpassword) { - this.neoDBpassword = neoDBpassword; - } - - public List getPackages() { - return packages; - } - - public void setPackages(List packages) { - this.packages = packages; - } - - public List getBugs() { - return bugs; - } - - public void setBugs(List bugs) { - this.bugs = bugs; - } - - public boolean isStopOnClassFailure() { - return stopOnClassFailure; - } - - public void setStopOnClassFailure(boolean stopOnClassFailure) { - this.stopOnClassFailure = stopOnClassFailure; - } - - public String getImportResourceConfigDir() { - return importResourceConfigDir; - } - - public void setImportResourceConfigDir(String importResourceConfigDir) { - this.importResourceConfigDir = importResourceConfigDir; - } - - public String getImportResourceTestsConfigDir() { - return importResourceTestsConfigDir; - } - - public void setImportResourceTestsConfigDir(String importResourceTestsConfigDir) { - this.importResourceTestsConfigDir = importResourceTestsConfigDir; - } - - public String getErrorConfigurationFile() { - return errorConfigurationFile; - } - - public void setErrorConfigurationFile(String errorConfigurationFile) { - this.errorConfigurationFile = errorConfigurationFile; - } - - public String getCatalogBeTlsPort() { - return catalogBeTlsPort; - } - - public void setCatalogBeTlsPort(String catalogBeTlsPort) { - this.catalogBeTlsPort = catalogBeTlsPort; - } - - public List getResourcesNotToDelete() { - return resourcesNotToDelete; - } - - public void setResourcesNotToDelete(List resourcesNotToDelete) { - this.resourcesNotToDelete = resourcesNotToDelete; - } - - public List getResourceCategoriesNotToDelete() { - return resourceCategoriesNotToDelete; - } - - public void setResourceCategoriesNotToDelete(List resourceCategoriesNotToDelete) { - this.resourceCategoriesNotToDelete = resourceCategoriesNotToDelete; - } - - public List getServiceCategoriesNotToDelete() { - return serviceCategoriesNotToDelete; - } - - public void setServiceCategoriesNotToDelete(List serviceCategoriesNotToDelete) { - this.serviceCategoriesNotToDelete = serviceCategoriesNotToDelete; - } - - public String getCassandraHost() { - return cassandraHost; - } - - public void setCassandraHost(String cassandraHost) { - this.cassandraHost = cassandraHost; - } - - public String getCassandraAuditKeySpace() { - return cassandraAuditKeySpace; - } - - public void setCassandraAuditKeySpace(String cassandraAuditKeySpace) { - this.cassandraAuditKeySpace = cassandraAuditKeySpace; - } - - public String getCassandraArtifactKeySpace() { - return cassandraArtifactKeySpace; - } - - public void setCassandraArtifactKeySpace(String cassandraArtifactKeySpace) { - this.cassandraArtifactKeySpace = cassandraArtifactKeySpace; - } - - public String getDownloadAutomationFolder() { - return downloadAutomationFolder; - } - - public void setDownloadAutomationFolder(String downloadAutomationFolder) { - this.downloadAutomationFolder = downloadAutomationFolder; - } - @Override public String toString() { return "Config [systemUnderDebug=" + systemUnderDebug + ", rerun=" + rerun + ", reportDBhost=" + reportDBhost - + ", reportDBport=" + reportDBport + ", browser=" + browser + ", catalogBeHost=" + catalogBeHost - + ", esHost=" + esHost + ", esPort=" + esPort + ", neoHost=" + neoHost + ", neoPort=" + neoPort - + ", disributionClientHost=" + disributionClientHost + ", disributionClientPort=" - + disributionClientPort + ", isDistributionClientRunning=" + isDistributionClientRunning - + ", errorConfigurationFile=" + errorConfigurationFile + ", resourceConfigDir=" + resourceConfigDir + - ", importResourceConfigDir=" + importResourceConfigDir + ", importResourceTestsConfigDir=" - + importResourceTestsConfigDir + ", catalogFeHost=" - + catalogFeHost + ", catalogFePort=" + catalogFePort + ", catalogBePort=" + catalogBePort - + ", catalogBeTlsPort=" + catalogBeTlsPort + ", neoDBusername=" + neoDBusername + ", neoDBpassword=" - + neoDBpassword + ", packages=" + packages + ", bugs=" - + bugs + ", resourcesNotToDelete=" + resourcesNotToDelete + ", resourceCategoriesNotToDelete=" - + resourceCategoriesNotToDelete + ", serviceCategoriesNotToDelete=" + serviceCategoriesNotToDelete - + ", stopOnClassFailure=" + stopOnClassFailure + ", outputFolder=" + outputFolder + ", reportName=" - + reportName + ", url=" + url + ", remoteTestingMachineIP=" + remoteTestingMachineIP - + ", remoteTestingMachinePort=" + remoteTestingMachinePort + ", remoteTesting=" + remoteTesting - + ", cassandraHost=" + cassandraHost + ", cassandraAuditKeySpace=" + cassandraAuditKeySpace - + ", cassandraArtifactKeySpace=" + cassandraArtifactKeySpace + ", cassandraAuthenticate=" - + cassandraAuthenticate + ", cassandraUsername=" + cassandraUsername + ", cassandraPassword=" - + cassandraPassword + ", cassandraSsl=" + cassandraSsl + ", cassandraTruststorePath=" - + cassandraTruststorePath + ", cassandraTruststorePassword=" + cassandraTruststorePassword - + ", captureTraffic=" + captureTraffic - + ", useBrowserMobProxy=" + useBrowserMobProxy + ", configurationFile=" + configurationFile - + ", downloadAutomationFolder=" + downloadAutomationFolder + "]"; - } - - public boolean isRemoteTesting() { - return remoteTesting; - } - - public void setRemoteTesting(boolean remoteTesting) { - this.remoteTesting = remoteTesting; - } - - public String getUrl() { - try { - return url; - } catch (Exception e) { - return null; - } - } - - public void setUrl(String url) { - this.url = url; - } - - public String getRemoteTestingMachineIP() { - return remoteTestingMachineIP; - } - - public void setRemoteTestingMachineIP(String remoteTestingMachineIP) { - this.remoteTestingMachineIP = remoteTestingMachineIP; - } - - public String getRemoteTestingMachinePort() { - return remoteTestingMachinePort; - } - - public void setRemoteTestingMachinePort(String remoteTestingMachinePort) { - this.remoteTestingMachinePort = remoteTestingMachinePort; - } - - public boolean getCassandraAuthenticate() { - return cassandraAuthenticate; - } - - public void setCassandraAuthenticate(boolean cassandraAuthenticate) { - this.cassandraAuthenticate = cassandraAuthenticate; - } - - public String getCassandraUsername() { - return cassandraUsername; - } - - public void setCassandraUsername(String cassandraUsername) { - this.cassandraUsername = cassandraUsername; - } - - public String getCassandraPassword() { - return cassandraPassword; - } - - public void setCassandraPassword(String cassandraPassword) { - this.cassandraPassword = cassandraPassword; - } - - public boolean getCassandraSsl() { - return cassandraSsl; - } - - public void setCassandraSsl(boolean cassandraSsl) { - this.cassandraSsl = cassandraSsl; - } - - public String getCassandraTruststorePath() { - return cassandraTruststorePath; - } - - public void setCassandraTruststorePath(String cassandraTruststorePath) { - this.cassandraTruststorePath = cassandraTruststorePath; - } + + ", reportDBport=" + reportDBport + ", browser=" + browser + ", catalogBeHost=" + catalogBeHost + + ", esHost=" + esHost + ", esPort=" + esPort + ", neoHost=" + neoHost + ", neoPort=" + neoPort + + ", disributionClientHost=" + disributionClientHost + ", disributionClientPort=" + + disributionClientPort + ", isDistributionClientRunning=" + isDistributionClientRunning + + ", errorConfigurationFile=" + errorConfigurationFile + ", resourceConfigDir=" + resourceConfigDir + + ", importResourceConfigDir=" + importResourceConfigDir + ", importResourceTestsConfigDir=" + + importResourceTestsConfigDir + ", catalogFeHost=" + + catalogFeHost + ", catalogFePort=" + catalogFePort + ", catalogBePort=" + catalogBePort + + ", catalogBeTlsPort=" + catalogBeTlsPort + ", neoDBusername=" + neoDBusername + ", neoDBpassword=" + + neoDBpassword + ", packages=" + packages + ", bugs=" + + bugs + ", resourcesNotToDelete=" + resourcesNotToDelete + ", resourceCategoriesNotToDelete=" + + resourceCategoriesNotToDelete + ", serviceCategoriesNotToDelete=" + serviceCategoriesNotToDelete + + ", stopOnClassFailure=" + stopOnClassFailure + ", outputFolder=" + outputFolder + ", reportName=" + + reportName + ", url=" + url + ", remoteTestingMachineIP=" + remoteTestingMachineIP + + ", remoteTestingMachinePort=" + remoteTestingMachinePort + ", remoteTesting=" + remoteTesting + + ", cassandraHost=" + cassandraHost + ", cassandraAuditKeySpace=" + cassandraAuditKeySpace + + ", cassandraArtifactKeySpace=" + cassandraArtifactKeySpace + ", cassandraAuthenticate=" + + cassandraAuthenticate + ", cassandraUsername=" + cassandraUsername + ", cassandraPassword=" + + cassandraPassword + ", cassandraSsl=" + cassandraSsl + ", cassandraTruststorePath=" + + cassandraTruststorePath + ", cassandraTruststorePassword=" + cassandraTruststorePassword + + ", captureTraffic=" + captureTraffic + + ", useBrowserMobProxy=" + useBrowserMobProxy + ", configurationFile=" + configurationFile + + ", downloadAutomationFolder=" + downloadAutomationFolder + "]"; + } + + @Getter + @Setter + @ToString + public static class TestPackages { - public String getCassandraTruststorePassword() { - return cassandraTruststorePassword; - } + private List packages; + private List bugs; - public void setCassandraTruststorePassword(String cassandraTruststorePassword) { - this.cassandraTruststorePassword = cassandraTruststorePassword; } } diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/cassandra/CassandraUtils.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/cassandra/CassandraUtils.java index 0e4ec92d5c..37f4ba50eb 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/cassandra/CassandraUtils.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/cassandra/CassandraUtils.java @@ -7,9 +7,9 @@ * 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. @@ -20,24 +20,33 @@ package org.onap.sdc.backend.ci.tests.utils.cassandra; -import com.datastax.driver.core.*; -import com.datastax.driver.core.policies.*; +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.KeyspaceMetadata; +import com.datastax.driver.core.Metadata; +import com.datastax.driver.core.Row; +import com.datastax.driver.core.Session; +import com.datastax.driver.core.TableMetadata; +import com.datastax.driver.core.policies.ConstantReconnectionPolicy; +import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy; +import com.datastax.driver.core.policies.DefaultRetryPolicy; +import com.datastax.driver.core.policies.LoadBalancingPolicy; +import com.datastax.driver.core.policies.TokenAwarePolicy; import com.datastax.driver.core.querybuilder.QueryBuilder; import com.datastax.driver.core.querybuilder.Select; import com.datastax.driver.core.querybuilder.Select.Where; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import org.javatuples.Pair; -import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; import org.onap.sdc.backend.ci.tests.utils.Utils; +import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; import org.openecomp.sdc.common.datastructure.AuditingFieldsKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - public final class CassandraUtils { + private static Logger logger = LoggerFactory.getLogger(CassandraUtils.class.getName()); protected static Cluster cluster = null; @@ -51,8 +60,8 @@ public final class CassandraUtils { logger.debug("creating cluster to hosts:{} with reconnect timeout:{}", cassandraHosts, reconnectTimeout); Cluster.Builder clusterBuilder = Cluster.builder() - .withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectTimeout)) - .withRetryPolicy(DefaultRetryPolicy.INSTANCE); + .withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectTimeout)) + .withRetryPolicy(DefaultRetryPolicy.INSTANCE); cassandraHosts.forEach(host -> clusterBuilder.addContactPoint(host)); enableAuthentication(clusterBuilder); @@ -67,7 +76,7 @@ public final class CassandraUtils { } private static void enableAuthentication(Cluster.Builder clusterBuilder) throws FileNotFoundException { - boolean authenticate = Utils.getConfig().getCassandraAuthenticate(); + boolean authenticate = Utils.getConfig().isCassandraAuthenticate(); if (authenticate) { String username = Utils.getConfig().getCassandraUsername(); String password = Utils.getConfig().getCassandraPassword(); @@ -81,7 +90,7 @@ public final class CassandraUtils { } private static void enableSsl(Cluster.Builder clusterBuilder) throws FileNotFoundException { - boolean ssl = Utils.getConfig().getCassandraSsl(); + boolean ssl = Utils.getConfig().isCassandraSsl(); if (ssl) { String truststorePath = Utils.getConfig().getCassandraTruststorePath(); String truststorePassword = Utils.getConfig().getCassandraTruststorePassword(); @@ -103,7 +112,8 @@ public final class CassandraUtils { LoadBalancingPolicy tokenAwarePolicy = new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().withLocalDc(localDataCenter).build()); clusterBuilder.withLoadBalancingPolicy(tokenAwarePolicy); } else { - logger.info("localDatacenter was provided, the driver will use the datacenter of the first contact point that was reached at initialization"); + logger.info( + "localDatacenter was provided, the driver will use the datacenter of the first contact point that was reached at initialization"); } } @@ -113,7 +123,7 @@ public final class CassandraUtils { initConnection(keyspace); } - try (Cluster cluster = CassandraUtils.cluster){ + try (Cluster cluster = CassandraUtils.cluster) { if (session != null) { session.execute(QueryBuilder.truncate(keyspace, tableName)); @@ -157,13 +167,14 @@ public final class CassandraUtils { } } finally { - if (cluster != null) { - cluster.close(); - } + if (cluster != null) { + cluster.close(); + } } } - public static List fetchFromTable(String keyspace, String tableName, List> fields) throws FileNotFoundException { + public static List fetchFromTable(String keyspace, String tableName, List> fields) + throws FileNotFoundException { List> fieldsConverted = new ArrayList<>(); @@ -188,7 +199,7 @@ public final class CassandraUtils { } public static List fetchFromTableQuery(String keyspace, String tableName, List> fields) - throws FileNotFoundException { + throws FileNotFoundException { if (session == null || session.isClosed()) { initConnection(keyspace); @@ -234,6 +245,4 @@ public final class CassandraUtils { } - - } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/ExtentManager.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/ExtentManager.java index 338a9e62c6..ed3c2335f3 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/ExtentManager.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/ExtentManager.java @@ -25,17 +25,16 @@ 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; -import org.onap.sdc.backend.ci.tests.config.Config; -import org.onap.sdc.frontend.ci.tests.utilities.FileHandling; -import org.onap.sdc.frontend.ci.tests.utilities.RestCDUtils; -import org.onap.sdc.backend.ci.tests.utils.Utils; -import org.onap.sdc.backend.ci.tests.utils.rest.AutomationUtils; -import org.testng.ITestContext; - import java.io.File; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; +import org.onap.sdc.backend.ci.tests.config.Config; +import org.onap.sdc.backend.ci.tests.utils.Utils; +import org.onap.sdc.backend.ci.tests.utils.rest.AutomationUtils; +import org.onap.sdc.frontend.ci.tests.utilities.FileHandling; +import org.onap.sdc.frontend.ci.tests.utilities.RestCDUtils; +import org.testng.ITestContext; public class ExtentManager { @@ -60,7 +59,7 @@ public class ExtentManager { } - private static synchronized ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { + private static synchronized ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { String dbIp = DriverFactory.getConfig().getReportDBhost(); int dbPort = DriverFactory.getConfig().getReportDBport(); @@ -77,19 +76,19 @@ public class ExtentManager { return extent; } - private static synchronized void setExtentXReporter(Boolean isAppend) { + private static synchronized void setExtentXReporter(Boolean isAppend) { extentxReporter.setAppendExisting(isAppend); extent.attachReporter(extentxReporter); } - private static synchronized void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { + private static synchronized void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { htmlReporter = new ExtentHtmlReporter(filePath + htmlFile); setConfiguration(htmlReporter); htmlReporter.setAppendExisting(isAppend); extent.attachReporter(htmlReporter); } - static synchronized ExtentReports getReporter() { + static synchronized ExtentReports getReporter() { return extent; } @@ -102,7 +101,7 @@ public class ExtentManager { String suiteName = getSuiteName(context); String reportStartDate = null; if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { - if (config.getUseBrowserMobProxy()) { + if (config.isUseBrowserMobProxy()) { setTrafficCaptue(config); } setReporter(filepath, htmlFile, true); @@ -116,12 +115,14 @@ public class ExtentManager { SimpleDateFormat formatter = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a"); reportStartDate = formatter.format(calendar.getTime()); reporterDataDefinition(onboardVersion, osVersion, envData, suiteName); - AutomationUtils.createVersionsInfoFile(filepath + VERSIONS_INFO_FILE_NAME, onboardVersion, osVersion, envData, suiteName, reportStartDate); + AutomationUtils + .createVersionsInfoFile(filepath + VERSIONS_INFO_FILE_NAME, onboardVersion, osVersion, envData, suiteName, reportStartDate); } } - private static void reporterDataDefinition(String onboardVersion, String osVersion, String envData, String suiteNameFromVersionInfoFile) throws Exception { + private static void reporterDataDefinition(String onboardVersion, String osVersion, String envData, String suiteNameFromVersionInfoFile) + throws Exception { extent.setSystemInfo("Onboard Version", onboardVersion); extent.setSystemInfo("OS Version", osVersion); extent.setSystemInfo("Host Name Address", RestCDUtils.getExecutionHostAddress()); @@ -139,7 +140,7 @@ public class ExtentManager { return null; } - private static synchronized ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception { + private static synchronized ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception { htmlReporter.config().setTheme(Theme.STANDARD); htmlReporter.config().setEncoding("UTF-8"); @@ -157,10 +158,9 @@ public class ExtentManager { } private static void setTrafficCaptue(Config config) { - boolean mobProxyStatus = config.getUseBrowserMobProxy(); + boolean mobProxyStatus = config.isUseBrowserMobProxy(); if (mobProxyStatus) { config.setCaptureTraffic(true); } } } - diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/SetupCDTest.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/SetupCDTest.java index 638f0b4aae..8d82ec08a2 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/SetupCDTest.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/SetupCDTest.java @@ -24,16 +24,15 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; import com.aventstack.extentreports.ExtentTest; import com.aventstack.extentreports.Status; - import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.util.Arrays; import java.util.UUID; - import net.lightbody.bmp.core.har.Har; import org.json.simple.JSONObject; import org.onap.sdc.backend.ci.tests.config.UserCredentialsFromFile; +import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum; +import org.onap.sdc.backend.ci.tests.utils.rest.AutomationUtils; import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum; import org.onap.sdc.frontend.ci.tests.datatypes.UserCredentials; import org.onap.sdc.frontend.ci.tests.execute.sanity.OnboardingFlowsUi; @@ -41,9 +40,7 @@ import org.onap.sdc.frontend.ci.tests.pages.HomePage; import org.onap.sdc.frontend.ci.tests.utilities.FileHandling; import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils; import org.onap.sdc.frontend.ci.tests.utilities.RestCDUtils; -import org.onap.sdc.backend.ci.tests.utils.rest.AutomationUtils; import org.openecomp.sdc.be.model.User; -import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; @@ -158,7 +155,7 @@ public abstract class SetupCDTest extends DriverFactory { System.out.println("ExtentReport instance started from Test..."); } - if (getConfig().getCaptureTraffic()) { + if (getConfig().isCaptureTraffic()) { try { MobProxy.getPoxyServer().newHar(method.getName() + ".har"); } catch (Throwable e) { @@ -175,7 +172,7 @@ public abstract class SetupCDTest extends DriverFactory { GeneralUIUtils.closeErrorMessage(); } finally { try { - if (getConfig().getCaptureTraffic()) { + if (getConfig().isCaptureTraffic()) { addTrafficFileToReport(result); } @@ -199,7 +196,6 @@ public abstract class SetupCDTest extends DriverFactory { getExtendTest().log(Status.ERROR, "Exception:" + e.toString()); } - ExtentTestManager.getInstance().endTest(); final String suiteName = ExtentManager.getSuiteName(context); // write result to csv file @@ -259,7 +255,7 @@ public abstract class SetupCDTest extends DriverFactory { System.out.println("Resources will not be deleted according to suite configuration ..."); } - if (getConfig().getUseBrowserMobProxy()) { + if (getConfig().isUseBrowserMobProxy()) { MobProxy.getPoxyServer().stop(); } } @@ -271,7 +267,8 @@ public abstract class SetupCDTest extends DriverFactory { String message = "no URL found"; System.out.println(message); Assert.fail(message); - } else if (!url.contains("localhost") && !url.contains("192.168.33.10") && !url.contains("127.0.0.1") && !url.contains("192.168.50.5") && !uiSimulator) { + } else if (!url.contains("localhost") && !url.contains("192.168.33.10") && !url.contains("127.0.0.1") && !url.contains("192.168.50.5") + && !uiSimulator) { localEnv = false; } return url; @@ -339,7 +336,8 @@ public abstract class SetupCDTest extends DriverFactory { return; } try { - getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() == 0 ? NUM_OF_ATTEMPTS_TO_REFTRESH : getWindowTest().getRefreshAttempts()); + getWindowTest() + .setRefreshAttempts(getWindowTest().getRefreshAttempts() == 0 ? NUM_OF_ATTEMPTS_TO_REFTRESH : getWindowTest().getRefreshAttempts()); if (!GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.MainMenuButtons.HOME_BUTTON.getValue())) { restartBrowser(role); } @@ -389,7 +387,7 @@ public abstract class SetupCDTest extends DriverFactory { private void loginWithUser(final UserRoleEnum role) { try { final String msg = String - .format("Login as user '%s', role '%s'", role.getUserId(), role.getUserRole()); + .format("Login as user '%s', role '%s'", role.getUserId(), role.getUserRole()); getExtendTest().log(Status.INFO, msg); LOGGER.info(msg); loginToSystem(role); @@ -420,7 +418,7 @@ public abstract class SetupCDTest extends DriverFactory { LOGGER.info(String.format("Setup before test for role '%s'", role.name())); if (!getWindowTest().getPreviousRole().equalsIgnoreCase(role.name())) { LOGGER.info(String.format("Logging in with new role '%s'. Previous role was: '%s'.", role.name(), - getWindowTest().getPreviousRole())); + getWindowTest().getPreviousRole())); navigateAndLogin(role); } } @@ -471,12 +469,13 @@ public abstract class SetupCDTest extends DriverFactory { String suiteName = ExtentManager.getSuiteName(myContext); if (ExtentManager.suiteNameXml.TESTNG_FAILED_XML_NAME.getValue().equals(suiteName)) { - ExtentTestManager.getInstance().startTest(RE_RUN + Thread.currentThread().getStackTrace()[2].getMethodName() + "      " + fromDataProvider); + ExtentTestManager.getInstance().startTest( + RE_RUN + Thread.currentThread().getStackTrace()[2].getMethodName() + "      " + fromDataProvider); } else { - ExtentTestManager.getInstance().startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "      " + fromDataProvider); + ExtentTestManager.getInstance() + .startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "      " + fromDataProvider); } - getWindowTest().setAddedValueFromDataProvider(fromDataProvider); ExtentTestManager.getInstance().assignCategory(this.getClass()); setBrowserBeforeTest(getRole()); diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/RestCDUtils.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/RestCDUtils.java index b090fac4be..04fd204ed3 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/RestCDUtils.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/RestCDUtils.java @@ -34,21 +34,21 @@ import org.onap.sdc.backend.ci.tests.config.Config; import org.onap.sdc.backend.ci.tests.datatypes.ComponentReqDetails; import org.onap.sdc.backend.ci.tests.datatypes.ResourceReqDetails; import org.onap.sdc.backend.ci.tests.datatypes.ServiceReqDetails; +import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum; import org.onap.sdc.backend.ci.tests.datatypes.http.RestResponse; import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.model.category.CategoryDefinition; -import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum; -import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory; -import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; import org.onap.sdc.backend.ci.tests.utils.rest.CatalogRestUtils; import org.onap.sdc.backend.ci.tests.utils.rest.CategoryRestUtils; import org.onap.sdc.backend.ci.tests.utils.rest.ResourceRestUtils; import org.onap.sdc.backend.ci.tests.utils.rest.ResponseParser; import org.onap.sdc.backend.ci.tests.utils.rest.ServiceRestUtils; import org.onap.sdc.backend.ci.tests.utils.rest.UserRestUtils; +import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory; +import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.category.CategoryDefinition; public class RestCDUtils { @@ -97,7 +97,7 @@ public class RestCDUtils { try { Thread.sleep(threadSleepTime); RestResponse getServiceResponse = ServiceRestUtils.getServiceByNameAndVersion(user, service.getName(), - service.getVersion()); + service.getVersion()); if (getServiceResponse.getErrorCode().intValue() == HttpStatus.SC_OK) { setResourceUniqueIdAndUUID(service, getServiceResponse); } @@ -135,7 +135,6 @@ public class RestCDUtils { Map> map = new HashMap<>(); - RestResponse allResourceCategories = CategoryRestUtils.getAllCategories(defaultAdminUser, ComponentTypeEnum.RESOURCE_PARAM_NAME); RestResponse allServiceCategories = CategoryRestUtils.getAllCategories(defaultAdminUser, ComponentTypeEnum.SERVICE_PARAM_NAME); @@ -156,11 +155,10 @@ public class RestCDUtils { User defaultAdminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); final String userId = defaultAdminUser.getUserId(); - List resourcesArrayList = map.get("resources"); List collect = resourcesArrayList.stream().filter(s -> s.getName().startsWith(ElementFactory.getResourcePrefix())). - map(e -> e.getUniqueId()). - collect(Collectors.toList()); + map(e -> e.getUniqueId()). + collect(Collectors.toList()); for (String uId : collect) { ResourceRestUtils.markResourceToDelete(uId, userId); @@ -169,12 +167,12 @@ public class RestCDUtils { resourcesArrayList = map.get("services"); collect = resourcesArrayList.stream(). - filter(e -> e != null). - filter(e -> e.getName() != null). - filter(s -> s.getName().startsWith(ElementFactory.getServicePrefix())). - filter(e -> e.getUniqueId() != null). - map(e -> e.getUniqueId()). - collect(Collectors.toList()); + filter(e -> e != null). + filter(e -> e.getName() != null). + filter(s -> s.getName().startsWith(ElementFactory.getServicePrefix())). + filter(e -> e.getUniqueId() != null). + map(e -> e.getUniqueId()). + collect(Collectors.toList()); for (String uId : collect) { ServiceRestUtils.markServiceToDelete(uId, userId); } @@ -204,10 +202,11 @@ public class RestCDUtils { public static void deleteOnDemand() throws IOException { Config config = DriverFactory.getConfig(); - if (!config.getSystemUnderDebug()) { + if (!config.isSystemUnderDebug()) { deleteCreatedComponents(getCatalogAsMap()); } else { - System.out.println("According to configuration components will not be deleted, in case to unable option to delete, please change systemUnderDebug parameter value to false ..."); + System.out.println( + "According to configuration components will not be deleted, in case to unable option to delete, please change systemUnderDebug parameter value to false ..."); } } -- cgit 1.2.3-korg