summaryrefslogtreecommitdiffstats
path: root/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities')
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java2
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/DownloadManager.java11
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java16
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtillViaApis.java298
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java42
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java26
6 files changed, 355 insertions, 40 deletions
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java
index c06a51ce91..1abae858e3 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java
@@ -478,7 +478,7 @@ public final class ArtifactUIUtils {
String heatDisplayName = pairToUpdate.getHeatArtifactDisplayName();
GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue()+heatDisplayName);
- File latestFilefromDir = FileHandling.getLastModifiedFileFromDir();
+ File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir();
String pattern = PARAMETERS;
Map<String, Object> mapUpdetedEnvFile = FileHandling.parseYamlFileToMapByPattern(updateEnvFile, pattern);
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/DownloadManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/DownloadManager.java
index ceada39b04..f4264ffdea 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/DownloadManager.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/DownloadManager.java
@@ -68,8 +68,11 @@ public class DownloadManager {
* @param vspName
* @throws Exception
*/
- public static void downloadCsarByNameFromVSPRepository(String vspName, String vspId) throws Exception{
- FileHandling.cleanCurrentDownloadDir();
+ public static void downloadCsarByNameFromVSPRepository(String vspName, String vspId, Boolean isDelete) throws Exception{
+
+ if(isDelete){
+ FileHandling.cleanCurrentDownloadDir();
+ }
HomePage.showVspRepository();
boolean vspFound = HomePage.searchForVSP(vspName);
if (vspFound){
@@ -88,6 +91,10 @@ public class DownloadManager {
}
}
+ public static void downloadCsarByNameFromVSPRepository(String vspName, String vspId) throws Exception{
+ downloadCsarByNameFromVSPRepository(vspName, vspId, true);
+ }
+
// AttFtpClient instance = AttFtpClient.getInstance();
//
// String server = "localhost";
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java
index 4fe1938af8..8c2556d00a 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java
@@ -264,11 +264,19 @@ public class FileHandling {
}
- public static synchronized File getLastModifiedFileFromDir() throws Exception{
- return getLastModifiedFileFromDir(SetupCDTest.getWindowTest().getDownloadDirectory());
+ /**
+ * @return last modified file name from default directory
+ * @throws Exception
+ */
+ public static synchronized File getLastModifiedFileNameFromDir() throws Exception{
+ return getLastModifiedFileNameFromDir(SetupCDTest.getWindowTest().getDownloadDirectory());
}
- public static synchronized File getLastModifiedFileFromDir(String dirPath){
+ /**
+ * @param dirPath
+ * @return last modified file name from dirPath directory
+ */
+ public static synchronized File getLastModifiedFileNameFromDir(String dirPath){
File dir = new File(dirPath);
File[] files = dir.listFiles();
if (files == null) {
@@ -397,7 +405,7 @@ public class FileHandling {
public static String getMD5OfFile(File file) throws IOException {
String content = FileUtils.readFileToString(file);
- String md5 = GeneralUtility.calculateMD5ByString(content);
+ String md5 = GeneralUtility.calculateMD5Base64EncodedByString(content);
return md5;
}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtillViaApis.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtillViaApis.java
new file mode 100644
index 0000000000..6abce99acb
--- /dev/null
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtillViaApis.java
@@ -0,0 +1,298 @@
+/*-
+ * ============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.utilities;
+
+import static org.testng.AssertJUnit.assertTrue;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.bouncycastle.util.encoders.Base64;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.ci.tests.api.Urls;
+import org.openecomp.sdc.ci.tests.config.Config;
+import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers;
+import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
+import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
+import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
+import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.utils.Utils;
+import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
+import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
+import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
+
+import com.clearspring.analytics.util.Pair;
+import com.google.gson.Gson;
+
+import fj.data.Either;
+
+public class OnboardingUtillViaApis {
+
+ protected static Map<String, String> prepareHeadersMap(String userId) {
+ Map<String, String> headersMap = new HashMap<String, String>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
+ headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId);
+ return headersMap;
+ }
+
+ public static Pair<String, VendorSoftwareProductObject> createVspViaApis(String filepath, String vnfFile, User user) throws Exception {
+
+ VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject();
+
+ AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(user);
+ Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(vnfFile, filepath, user, amdocsLicenseMembers);
+ Map<String, String> map = createVendorSoftwareProduct.right;
+ vendorSoftwareProductObject.setAttContact(map.get("attContact"));
+ vendorSoftwareProductObject.setCategory(map.get("category"));
+ vendorSoftwareProductObject.setComponentId(map.get("componentId"));
+ vendorSoftwareProductObject.setDescription(map.get("description"));
+ vendorSoftwareProductObject.setSubCategory(map.get("subCategory"));
+ vendorSoftwareProductObject.setVendorName(map.get("vendorName"));
+ vendorSoftwareProductObject.setVspId(map.get("vspId"));
+ Pair<String, VendorSoftwareProductObject> pair = new Pair<String, VendorSoftwareProductObject>(createVendorSoftwareProduct.left, vendorSoftwareProductObject);
+ return pair;
+ }
+
+/* public static Resource createResourceFromVSP(Pair<String, Map<String, String>> createVendorSoftwareProduct, String vspName) throws Exception {
+ List<String> tags = new ArrayList<>();
+ tags.add(vspName);
+ Map<String, String> map = createVendorSoftwareProduct.right;
+ ResourceReqDetails resourceDetails = new ResourceReqDetails();
+ resourceDetails.setCsarUUID(map.get("vspId"));
+ resourceDetails.setCsarVersion("1.0");
+ resourceDetails.setName(vspName);
+ resourceDetails.setTags(tags);
+ resourceDetails.setDescription(map.get("description"));
+ resourceDetails.setResourceType(map.get("componentType"));
+ resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_DATABASE.getCategory(), ResourceCategoryEnum.GENERIC_DATABASE.getSubCategory());
+ resourceDetails.setVendorName(map.get("vendorName"));
+ resourceDetails.setVendorRelease("1.0");
+ resourceDetails.setResourceType("VF");
+ resourceDetails.setResourceVendorModelNumber("666");
+ resourceDetails.setContactId(map.get("attContact"));
+ resourceDetails.setIcon("defaulticon");
+ Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value();
+
+ return resource;
+ }*/
+ public static Resource createResourceFromVSP(ResourceReqDetails resourceDetails, String vspName) throws Exception {
+// List<String> tags = new ArrayList<>();
+// tags.add(vspName);
+// Map<String, String> map = createVendorSoftwareProduct.right;
+// ResourceReqDetails resourceDetails = new ResourceReqDetails();
+// resourceDetails.setCsarUUID(map.get("vspId"));
+// resourceDetails.setCsarVersion("1.0");
+// resourceDetails.setName(vspName);
+// resourceDetails.setTags(tags);
+// resourceDetails.setDescription(map.get("description"));
+// resourceDetails.setResourceType(map.get("componentType"));
+// resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_DATABASE.getCategory(), ResourceCategoryEnum.GENERIC_DATABASE.getSubCategory());
+// resourceDetails.setVendorName(map.get("vendorName"));
+// resourceDetails.setVendorRelease("1.0");
+// resourceDetails.setResourceType("VF");
+// resourceDetails.setResourceVendorModelNumber("666");
+// resourceDetails.setContactId(map.get("attContact"));
+// resourceDetails.setIcon("defaulticon");
+ Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceDetails, UserRoleEnum.DESIGNER, true).left().value();
+
+ return resource;
+ }
+ public static void downloadToscaCsarToDirectory(Component component, File file) {
+ try {
+ Either<String, RestResponse> componentToscaArtifactPayload = AtomicOperationUtils.getComponenetArtifactPayload(component, "assettoscacsar");
+ if(componentToscaArtifactPayload.left().value() != null){
+ convertPayloadToFile(componentToscaArtifactPayload.left().value(), file);
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+// public static void convertPayloadToFile(String payload, File file, boolean isBased64, boolean isSdcFormat) throws IOException{
+//
+// Gson gson = new Gson();
+// byte[] byteArray = null;
+// Map<String, String> fromJson;
+// @SuppressWarnings("unchecked")
+// String string = null;// = fromJson.get("base64Contents").toString();
+// if(isSdcFormat){
+// fromJson = gson.fromJson(payload, Map.class);
+// string = fromJson.get("base64Contents").toString();
+// }else if (isBased64) {
+// byteArray = Base64.decode(string.getBytes(StandardCharsets.UTF_8));
+// }else{
+// byteArray = payload.getBytes(StandardCharsets.UTF_8);
+// }
+// File downloadedFile = new File(file.getAbsolutePath());
+// FileOutputStream fos = new FileOutputStream(downloadedFile);
+// fos.write(byteArray);
+// fos.flush();
+// fos.close();
+//
+// }
+
+ public static void convertPayloadToFile(String payload, File file) throws IOException{
+
+ Gson gson = new Gson();
+ @SuppressWarnings("unchecked")
+ Map<String, String> fromJson = gson.fromJson(payload, Map.class);
+ String string = fromJson.get("base64Contents").toString();
+ byte[] byteArray = Base64.decode(string.getBytes(StandardCharsets.UTF_8));
+ File downloadedFile = new File(file.getAbsolutePath());
+ FileOutputStream fos = new FileOutputStream(downloadedFile);
+ fos.write(byteArray);
+ fos.flush();
+ fos.close();
+ }
+
+
+ public static void convertPayloadToZipFile(String payload, File file) throws IOException{
+
+ byte[] byteArray = payload.getBytes(StandardCharsets.ISO_8859_1);
+ File downloadedFile = new File(file.getAbsolutePath());
+ FileOutputStream fos = new FileOutputStream(downloadedFile);
+ fos.write(byteArray);
+ fos.flush();
+ fos.close();
+
+
+// ZipOutputStream fos = null;
+//
+//
+// for (Charset charset : Charset.availableCharsets().values()) {
+// try{
+// // System.out.println("How to do it???");
+// File downloadedFile = new File(file.getAbsolutePath() + "_" + charset +".csar");
+// fos = new ZipOutputStream(new FileOutputStream(downloadedFile));
+// byte[] byteArray = payload.getBytes(charset);
+// fos.write(byteArray);
+// fos.flush();
+//
+// }
+// catch(Exception e){
+// fos.close();
+// }
+// }
+ System.out.println("");
+
+// ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(byteArray));
+// ZipEntry entry = null;
+// while ((entry = zipStream.getNextEntry()) != null) {
+//
+// String entryName = entry.getName();
+//
+// FileOutputStream out = new FileOutputStream(file+"/"+entryName);
+//
+// byte[] byteBuff = new byte[4096];
+// int bytesRead = 0;
+// while ((bytesRead = zipStream.read(byteBuff)) != -1)
+// {
+// out.write(byteBuff, 0, bytesRead);
+// }
+//
+// out.close();
+// zipStream.closeEntry();
+// }
+// zipStream.close();
+//
+
+
+
+ BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(payload.getBytes(StandardCharsets.ISO_8859_1)));
+ String filePath = file.toString();
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(filePath)));
+ int inByte;
+ while((inByte = bis.read()) != -1) bos.write(inByte);
+ bis.close();
+ bos.close();
+ }
+
+ public static Either<String, RestResponse> getVendorSoftwareProduct(String vspId, User user, Boolean validateState) throws Exception {
+
+ Config config = Utils.getConfig();
+ String url = String.format(Urls.GET_VENDOR_SOFTWARE_PRODUCT, config.getCatalogBeHost(), config.getCatalogBePort(), vspId);
+ String userId = user.getUserId();
+ Map<String, String> headersMap = prepareHeadersMap(userId);
+ headersMap.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(), "123456");
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "*/*");
+ headersMap.put("Accept-Encoding", "gzip, deflate, br");
+ HttpRequest http = new HttpRequest();
+ RestResponse response = http.httpSendGet(url, headersMap);
+ if (validateState) {
+ assertTrue("add property to resource failed: " + response.getResponseMessage(), response.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+ if (response.getErrorCode() != BaseRestUtils.STATUS_CODE_SUCCESS && response.getResponse().getBytes() == null && response.getResponse().getBytes().length == 0) {
+ return Either.right(response);
+ }
+ return Either.left(response.getResponse());
+
+ }
+
+ public static ResourceReqDetails prepareOnboardedResourceDetailsBeforeCreate(VendorSoftwareProductObject vendorSoftwareProductObject, String vspName) {
+
+ List<String> tags = new ArrayList<>();
+ tags.add(vspName);
+ ResourceReqDetails resourceDetails = new ResourceReqDetails();
+ resourceDetails.setCsarUUID(vendorSoftwareProductObject.getVspId());
+ resourceDetails.setCsarVersion("1.0");
+ resourceDetails.setName(vspName);
+ resourceDetails.setTags(tags);
+ resourceDetails.setDescription(vendorSoftwareProductObject.getDescription());
+ resourceDetails.addCategoryChain(ResourceCategoryEnum.GENERIC_DATABASE.getCategory(), ResourceCategoryEnum.GENERIC_DATABASE.getSubCategory());
+ resourceDetails.setVendorName(vendorSoftwareProductObject.getVendorName());
+ resourceDetails.setVendorRelease("1.0");
+ resourceDetails.setResourceType("VF");
+ resourceDetails.setResourceVendorModelNumber("666");
+ resourceDetails.setContactId(vendorSoftwareProductObject.getAttContact());
+ resourceDetails.setIcon("defaulticon");
+
+ return resourceDetails;
+ }
+
+ public static ServiceReqDetails prepareServiceDetailsBeforeCreate(User user) {
+
+ ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(ServiceCategoriesEnum.NETWORK_L4, user);
+ serviceDetails.setServiceType("MyServiceType");
+ serviceDetails.setServiceRole("MyServiceRole");
+ serviceDetails.setNamingPolicy("MyServiceNamingPolicy");
+ serviceDetails.setEcompGeneratedNaming(false);
+
+ return serviceDetails;
+ }
+}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java
index 398e1f18db..b4f834a421 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java
@@ -56,6 +56,7 @@ import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers;
import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum;
+import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
@@ -520,21 +521,6 @@ public class OnboardingUtils {
return new Pair<RestResponse, Map<String, String>>(response, vspMetadta);
}
-/* public static RestResponse getVendorSoftwareProduct(Map vspObject, User user) throws Exception {
- Config config = Utils.getConfig();
- String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-software-products/" + vspObject.get("vspId"),
- config.getCatalogBeHost(), config.getCatalogBePort());
-
- String userId = user.getUserId();
-
- Map<String, String> headersMap = prepareHeadersMap(userId);
- HttpRequest http = new HttpRequest();
-
- RestResponse response = http.httpsSendGet(url, headersMap);
-
- return response;
- }*/
-
public static RestResponse validateUpload(String vspid, User user) throws Exception {
Config config = Utils.getConfig();
String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/0.1/orchestration-template-candidate/process",
@@ -748,7 +734,7 @@ public class OnboardingUtils {
String vspName = createVendorSoftwareProduct.left;
DownloadManager.downloadCsarByNameFromVSPRepository(vspName, createVendorSoftwareProduct.right.get("vspId"));
- File latestFilefromDir = FileHandling.getLastModifiedFileFromDir();
+ File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir();
ExtentTestActions.log(Status.INFO, String.format("Searching for onboarded %s", vnfFile));
HomePage.showVspRepository();
@@ -810,19 +796,19 @@ public class OnboardingUtils {
}
-enum SnmpTypeEnum{
- SNMP_POLL ("snmp"),
- SNMP_TRAP ("snmp-trap");
+ enum SnmpTypeEnum{
+ SNMP_POLL ("snmp"),
+ SNMP_TRAP ("snmp-trap");
+
+ private String value;
- private String value;
-
- public String getValue() {
- return value;
- }
-
- private SnmpTypeEnum(String value) {
- this.value = value;
- }
+ public String getValue() {
+ return value;
+ }
+ private SnmpTypeEnum(String value) {
+ this.value = value;
+ }
}
+
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java
index c76bf4b74a..1eaa626e94 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java
@@ -539,30 +539,41 @@ public final class ResourceUIUtils {
return getCreatedResource;
}
+ /**
+ * @deprecated Use {@link #createVF(ResourceReqDetails,User)} instead
+ */
public static void createResource(ResourceReqDetails resource, User user) throws Exception {
+ createVF(resource, user);
+ }
+
+ public static void createVF(ResourceReqDetails resource, User user) throws Exception {
ExtentTestActions.log(Status.INFO, "Going to create a new VF.");
+ createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_VF);
+ }
+
+ public static void createResource(ResourceReqDetails resource, User user, DataTestIdEnum.Dashboard button) {
WebElement addVFButton = null;
try {
GeneralUIUtils.ultimateWait();
try{
GeneralUIUtils.hoverOnAreaByClassName("w-sdc-dashboard-card-new");
- addVFButton = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_VF.getValue());
+ addVFButton = GeneralUIUtils.getWebElementByTestID(button.getValue());
}
catch (Exception e){
File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resource.getName());
final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath();
- SetupCDTest.getExtendTest().log(Status.WARNING, "Add VF button is not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath));
+ SetupCDTest.getExtendTest().log(Status.WARNING, "Add button is not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath));
showButtonsADD();
- addVFButton = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_VF.getValue());
+ addVFButton = GeneralUIUtils.getWebElementByTestID(button.getValue());
}
addVFButton.click();
GeneralUIUtils.ultimateWait();
}
catch (Exception e ) {
- SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on ADD VF button, retrying ... "));
+ SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on ADD button, retrying ... "));
GeneralUIUtils.hoverOnAreaByClassName("w-sdc-dashboard-card-new");
GeneralUIUtils.ultimateWait();
- GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_VF.getValue()).click();
+ GeneralUIUtils.getWebElementByTestID(button.getValue()).click();
GeneralUIUtils.ultimateWait();
}
fillResourceGeneralInformationPage(resource, user, true);
@@ -1140,4 +1151,9 @@ public final class ResourceUIUtils {
SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s %s", textToClick, customizationFoLogLocal));
GeneralUIUtils.clickOnElementByText(textToClick);
}
+
+ public static void createPNF(ResourceReqDetails resource, User user) throws Exception {
+ ExtentTestActions.log(Status.INFO, "Going to create a new PNF.");
+ createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_PNF);
+ }
}