From f59a22539d5b372e2425c39963547985379d6990 Mon Sep 17 00:00:00 2001 From: Yuli Shlosberg Date: Wed, 21 Mar 2018 11:14:08 +0200 Subject: new ui sanity docker Change-Id: I257c198c563771b5badcf36a479cb499f841682f Issue-ID: SDC-995 Signed-off-by: Yuli Shlosberg --- .../openecomp/sdc/ci/tests/api/ExtentManager.java | 16 +-- .../org/openecomp/sdc/ci/tests/config/Config.java | 9 ++ .../ci/tests/config/UserCredentialsFromFile.java | 80 +++++++++++++++ .../sdc/ci/tests/datatypes/UserCredentials.java | 58 +++++++++++ .../sdc/ci/tests/utils/rest/ResponseParser.java | 58 +++++------ .../sdc/ci/tests/webSealAccess/NeoJavaObject.java | 111 --------------------- .../src/main/resources/ci/testSuites/onap.xml | 12 --- .../main/resources/ci/testSuites/onapApiSanity.xml | 12 +++ 8 files changed, 193 insertions(+), 163 deletions(-) create mode 100644 test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java create mode 100644 test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserCredentials.java delete mode 100644 test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/webSealAccess/NeoJavaObject.java delete mode 100644 test-apis-ci/src/main/resources/ci/testSuites/onap.xml create mode 100644 test-apis-ci/src/main/resources/ci/testSuites/onapApiSanity.xml (limited to 'test-apis-ci/src/main') diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java index b320f4200e..44c4275194 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java @@ -44,23 +44,17 @@ public class ExtentManager { 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"+ -// "$('.logo-content' ).remove();"+"\n"+ -// "$('#slide-out li:first-child').on('click', function(){ $('#charts-row').hide() }) ; $('#slide-out li:last-child').on('click', function(){ $('#charts-row').show() });"+"\n"+ -// "$('.charts div:nth-child(2)').remove();"+"\n"+ - "})"; public enum suiteNameXml { - + TESTNG_FAILED_XML_NAME("testng-failed.xml"); - + suiteNameXml(String value) { this.value = value; } - + private String value; - + public String getValue() { return value; } @@ -154,7 +148,7 @@ public class ExtentManager { // htmlReporter.config().setReportName(AutomationUtils.getATTVersion()); htmlReporter.config().setReportName("SDC Automation Report"); htmlReporter.config().setChartVisibilityOnOpen(false); - htmlReporter.config().setJS(icon); +// htmlReporter.config().setJS(icon); return htmlReporter; } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java index 590297e130..9f7043d509 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/Config.java @@ -94,6 +94,7 @@ public class Config { private boolean useBrowserMobProxy; private String sdcHttpMethod; private String localDataCenter; + private boolean uiSimulator; public String getLocalDataCenter() { return localDataCenter; @@ -198,6 +199,14 @@ public class Config { return config; } + public boolean isUiSimulator() { + return uiSimulator; + } + + public void setUiSimulator(boolean uiSimulator) { + this.uiSimulator = uiSimulator; + } + private static void setPackagesAndBugs(String path, Config config) throws IOException { int separator = Math.max(path.lastIndexOf("\\"), path.lastIndexOf("/")); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java new file mode 100644 index 0000000000..42f06f2bd3 --- /dev/null +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java @@ -0,0 +1,80 @@ +package org.openecomp.sdc.ci.tests.config; + +import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; +import org.openecomp.sdc.ci.tests.utils.general.FileHandling; +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.Map; + +public class UserCredentialsFromFile { + + private static final String CREDENTIALS_FILE = "credentials.yaml"; + private static Map credentials; + private static Yaml yaml = new Yaml(); + + private static UserCredentialsFromFile credentialsFromFile; +// private UserCredentialsFromFile() { +// +// } + + public synchronized static UserCredentialsFromFile getInstance() { + if (credentialsFromFile == null) { + try { + credentialsFromFile = new UserCredentialsFromFile(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + return credentialsFromFile; + } + + private void UserCredentialsFromFile() throws IOException { + + credentials = null; + + File credentialsFileRemote = new File(FileHandling.getBasePath() + File.separator + "conf" + File.separator + CREDENTIALS_FILE); +// File credentialsFileLocal = new File(FileHandling.getConfFilesPath() + CREDENTIALS_FILE); + File credentialFile = new File(FileHandling.getSdcVnfsPath() + File.separator + "conf" + + File.separator + CREDENTIALS_FILE); + + if (false == credentialFile.exists()) { + throw new RuntimeException("The config file " + credentialFile + " cannot be found."); + } + + + File[] credentialFiles = {credentialsFileRemote, credentialFile}; + + for (File credentialsFile : credentialFiles){ + if (credentialsFile.exists()){ + try { + credentials = FileHandling.parseYamlFile(credentialsFile.getAbsolutePath()); + } catch (Exception e) { + e.printStackTrace(); + } + break; + } + } + + + + } + + + public static UserCredentials getUserCredentialsByRole(String userRole) throws Exception { + @SuppressWarnings("unchecked") + Map credentialsMap = (Map) credentials.get(userRole); + String user = (String) credentialsMap.get("username"); + String password = (String) credentialsMap.get("password"); + String firstname = (String) credentialsMap.get("firstname"); + String lastname = (String) credentialsMap.get("lastname"); + + return new UserCredentials(user, password, firstname, lastname, userRole); + } + +} diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserCredentials.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserCredentials.java new file mode 100644 index 0000000000..2de872504f --- /dev/null +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserCredentials.java @@ -0,0 +1,58 @@ +/*- + * ============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.datatypes; + +import org.openecomp.sdc.be.model.User; + +public class UserCredentials extends User { + + // private String userName; + private String password; + + public UserCredentials(String userId, String password, String firstname, String lastname, String role) { + super(); + setUserId(userId); + // this.userName = userName; + this.password = password; + setFirstName(firstname); + setLastName(lastname); + setRole(role); + } + + public UserCredentials() { + super(); + } + + // public String getUserName() { + // return userName; + // } + // public void setUserName(String userName) { + // this.userName = userName; + // } + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + +} diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java index d78a6c9026..cbfc84d1cb 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java @@ -458,49 +458,49 @@ public class ResponseParser { JsonArray jArrServices = jObject.getAsJsonArray("services"); JsonArray jArrProducts = jObject.getAsJsonArray("products"); - if (jArrReousrces != null && jArrServices != null && jArrProducts != null){ - - + + + //////// RESOURCE///////////////////////////// ArrayList restResponseArray = new ArrayList<>(); Component component = null; - for (int i = 0; i < jArrReousrces.size(); i++) { - String resourceString = (String) jArrReousrces.get(i).toString(); - component = ResponseParser.convertResourceResponseToJavaObject(resourceString); - restResponseArray.add(component); - } + if (jArrReousrces != null) { + for (int i = 0; i < jArrReousrces.size(); i++) { + String resourceString = (String) jArrReousrces.get(i).toString(); + component = ResponseParser.convertResourceResponseToJavaObject(resourceString); + restResponseArray.add(component); + } + - map.put("resources", restResponseArray); + } map.put("resources", restResponseArray); - ///////// SERVICE///////////////////////////// + ///////// SERVICE///////////////////////////// restResponseArray = new ArrayList<>(); component = null; - for (int i = 0; i < jArrServices.size(); i++) { - String resourceString = (String) jArrServices.get(i).toString(); - component = ResponseParser.convertServiceResponseToJavaObject(resourceString); - restResponseArray.add(component); - } + if (jArrServices != null ) { + for (int i = 0; i < jArrServices.size(); i++) { + String resourceString = (String) jArrServices.get(i).toString(); + component = ResponseParser.convertServiceResponseToJavaObject(resourceString); + restResponseArray.add(component); + } + + + } map.put("services", restResponseArray); - map.put("services", restResponseArray); ///////// PRODUCT///////////////////////////// restResponseArray = new ArrayList<>(); component = null; - for (int i = 0; i < jArrProducts.size(); i++) { - String resourceString = (String) jArrProducts.get(i).toString(); - component = ResponseParser.convertProductResponseToJavaObject(resourceString); - restResponseArray.add(component); - } + if ( jArrProducts != null){ + for (int i = 0; i < jArrProducts.size(); i++) { + String resourceString = (String) jArrProducts.get(i).toString(); + component = ResponseParser.convertProductResponseToJavaObject(resourceString); + restResponseArray.add(component); + } + + } map.put("products", restResponseArray); - map.put("products", restResponseArray); - - } - else { - map.put("resources", new ArrayList<>()); - map.put("services", new ArrayList<>()); - map.put("products", new ArrayList<>()); - } return map; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/webSealAccess/NeoJavaObject.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/webSealAccess/NeoJavaObject.java deleted file mode 100644 index 0c19627bda..0000000000 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/webSealAccess/NeoJavaObject.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============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.webSealAccess; - -public class NeoJavaObject { - - String userId; - String firstName; - String lastName; - String email; - String role; - String label; - String elementType; - - public NeoJavaObject(String userId, String firstName, String lastName, String email, String role, String label, - String elementType) { - super(); - this.userId = userId; - this.firstName = firstName; - this.lastName = lastName; - this.email = email; - this.role = role; - this.label = label; - this.elementType = elementType; - } - - public NeoJavaObject() { - super(); - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getRole() { - return role; - } - - public void setRole(String role) { - this.role = role; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getElementType() { - return elementType; - } - - public void setElementType(String elementType) { - this.elementType = elementType; - } - - @Override - public String toString() { - return "QueryUserNeo4jInfo [userId=" + userId + ", firstName=" + firstName + ", lastName=" + lastName - + ", email=" + email + ", role=" + role + ", label=" + label + ", elementType=" + elementType + "]"; - } - -} diff --git a/test-apis-ci/src/main/resources/ci/testSuites/onap.xml b/test-apis-ci/src/main/resources/ci/testSuites/onap.xml deleted file mode 100644 index 707500a54c..0000000000 --- a/test-apis-ci/src/main/resources/ci/testSuites/onap.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/test-apis-ci/src/main/resources/ci/testSuites/onapApiSanity.xml b/test-apis-ci/src/main/resources/ci/testSuites/onapApiSanity.xml new file mode 100644 index 0000000000..707500a54c --- /dev/null +++ b/test-apis-ci/src/main/resources/ci/testSuites/onapApiSanity.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file -- cgit 1.2.3-korg