summaryrefslogtreecommitdiffstats
path: root/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities')
-rw-r--r--ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ArtifactUIUtils.java70
-rw-r--r--ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/FileHandling.java30
-rw-r--r--ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/GeneralUIUtils.java344
-rw-r--r--ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/MethodManipulationUtils.java15
-rw-r--r--ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/OnboardUtility.java477
-rw-r--r--ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ResourceUIUtils.java299
-rw-r--r--ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/RestCDUtils.java167
-rw-r--r--ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ServiceUIUtils.java147
8 files changed, 0 insertions, 1549 deletions
diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ArtifactUIUtils.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ArtifactUIUtils.java
deleted file mode 100644
index 91c9c07da8..0000000000
--- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ArtifactUIUtils.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.openecomp.sdc.uici.tests.utilities;
-
-import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.retryMethodOnException;
-
-import java.util.Map;
-
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum;
-import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum;
-import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.Artifatcs;
-import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.InformationalArtifatcs;
-import org.openqa.selenium.WebElement;
-
-import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-import org.openecomp.sdc.common.api.ArtifactTypeEnum;
-import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
-
-public final class ArtifactUIUtils {
-
- private ArtifactUIUtils() {
- throw new UnsupportedOperationException();
- }
-
- public static void addInformationArtifact(ArtifactReqDetails artifact, String filePath,
- final InformationalArtifatcs dataTestEnum) {
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.sleep(2000);
- GeneralUIUtils.getWebElementWaitForVisible(dataTestEnum.getValue()).click();
-
- final WebElement browseWebElement = FunctionalInterfaces.retryMethodOnException(
- () -> GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.BROWSE_BUTTON.getValue()));
- browseWebElement.sendKeys(filePath);
-
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.DESCRIPTION.getValue())
- .sendKeys(artifact.getDescription());
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.DONE.getValue()).click();
-
- }
-
- public static Map<String, Map<String, Object>> getArtifactsListFromResponse(String jsonResponse,
- String fieldOfArtifactList) {
- JSONObject object = (JSONObject) JSONValue.parse(jsonResponse);
- Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) object.get(fieldOfArtifactList);
- return map;
- }
-
- /**
- * Creates a deployment artifact on the vf. <br>
- * Moves automatically to DeploymentArtifact Section
- *
- * @param artifactPayloadPath
- * @param artifactType
- */
- public static void createDeploymentArtifactOnVf(final String artifactPayloadPath,
- final ArtifactTypeEnum artifactType) {
- GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.DEPLOYMENT_ARTIFACT);
- GeneralUIUtils.getWebElementWaitForClickable(Artifatcs.ADD_DEPLOYMENT_ARTIFACT.getValue()).click();
- GeneralUIUtils.getSelectList("Create New Artifact", Artifatcs.SELECT_ARTIFACT_DROPDOWN.getValue());
- GeneralUIUtils.getSelectList(artifactType.getType(), Artifatcs.ARTIFACT_TYPE_DROPDOWN.getValue());
- GeneralUIUtils.getWebElementWaitForVisible(Artifatcs.ARTIFACT_DESCRIPTION.getValue())
- .sendKeys("Artifact Description");
- GeneralUIUtils.getWebElementWaitForVisible(Artifatcs.ARTIFACT_LABEL.getValue()).sendKeys("MyArtifactLabel");
- retryMethodOnException(() -> GeneralUIUtils.getWebElementByDataTestId(Artifatcs.BROWSE_BUTTON.getValue())
- .sendKeys(artifactPayloadPath));
- GeneralUIUtils.getWebElementWaitForVisible(Artifatcs.ADD_BUTTON.getValue()).click();
- GeneralUIUtils.waitForLoader();
- }
-
-}
diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/FileHandling.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/FileHandling.java
deleted file mode 100644
index b1549741ed..0000000000
--- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/FileHandling.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.openecomp.sdc.uici.tests.utilities;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Map;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class FileHandling {
-
- public static Map<?, ?> parseYamlFile(String filePath) throws FileNotFoundException {
- Yaml yaml = new Yaml();
- File file = new File(filePath);
- InputStream inputStream = new FileInputStream(file);
- Map<?, ?> map = (Map<?, ?>) yaml.load(inputStream);
- return map;
- }
-
- public static String getBasePath() {
- return System.getProperty("user.dir");
- }
-
- public static String getResourcesFilesPath() {
- return getBasePath() + File.separator + "src" + File.separator + "main" + File.separator + "resources"
- + File.separator + "Files" + File.separator;
- }
-
-}
diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/GeneralUIUtils.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/GeneralUIUtils.java
deleted file mode 100644
index 42aab187ea..0000000000
--- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/GeneralUIUtils.java
+++ /dev/null
@@ -1,344 +0,0 @@
-package org.openecomp.sdc.uici.tests.utilities;
-
-import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.retryMethodOnException;
-import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.retryMethodOnResult;
-import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.swallowException;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-import java.util.function.Function;
-import java.util.function.Supplier;
-
-import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum;
-import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum;
-import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.Dashboard;
-import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest;
-import org.openqa.selenium.By;
-import org.openqa.selenium.Platform;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.firefox.FirefoxDriver;
-import org.openqa.selenium.interactions.Actions;
-import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.remote.RemoteWebDriver;
-import org.openqa.selenium.support.ui.ExpectedCondition;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.Select;
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.testng.Assert;
-
-import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
-
-public final class GeneralUIUtils {
-
- private static final int DEFAULT_WAIT_TIME_IN_SECONDS = 10;
- /**************** DRIVERS ****************/
- private static WebDriver driver;
-
- private GeneralUIUtils() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Finding a component in the home screen by name and clicks on it
- * Uses the search
- *
- * @param componentName
- * @throws Exception
- */
- public static void findComponentAndClick(String componentName) throws Exception {
- getWebElementWaitForVisible("main-menu-input-search").sendKeys(componentName);
- try {
- getWebElementWaitForClickable(componentName).click();
- GeneralUIUtils.waitForLoader();
- getWebElementWaitForVisible("formlifecyclestate");
- } catch (Exception e) {
- String msg = String.format("DID NOT FIND A COMPONENT NAMED %s", componentName);
- System.out.println(msg);
- Assert.fail(msg);
- }
- }
-
- public static WebElement getWebElementWaitForVisible(String dataTestId) {
- return getWebElementWaitForVisible(dataTestId, DEFAULT_WAIT_TIME_IN_SECONDS);
- }
-
- public static WebElement getWebElementWaitForVisible(String dataTestId, int time) {
- WebDriverWait wait = new WebDriverWait(getDriver(), time);
- ExpectedCondition<WebElement> visibilityOfElementLocated = ExpectedConditions
- .visibilityOfElementLocated(builDataTestIdLocator(dataTestId));
- WebElement webElement = wait.until(visibilityOfElementLocated);
- return webElement;
- }
-
- public static WebElement getWebElementWaitForClickable(String dataTestId) {
- WebDriverWait wait = new WebDriverWait(getDriver(), DEFAULT_WAIT_TIME_IN_SECONDS);
- ExpectedCondition<WebElement> condition = ExpectedConditions
- .elementToBeClickable(builDataTestIdLocator(dataTestId));
- WebElement webElement = wait.until(condition);
- return webElement;
- }
-
- private static By builDataTestIdLocator(String dataTestId) {
- return By.xpath("//*[@data-tests-id='" + dataTestId + "']");
-
- }
-
- /**
- * Returns A list of Web Elements When they are all visible
- *
- * @param dataTestId
- * @return
- */
- public static List<WebElement> getWebElementsListWaitForVisible(String dataTestId) {
- WebDriverWait wait = new WebDriverWait(getDriver(), DEFAULT_WAIT_TIME_IN_SECONDS);
- ExpectedCondition<List<WebElement>> visibilityOfAllElementsLocatedBy = ExpectedConditions
- .visibilityOfAllElementsLocatedBy(builDataTestIdLocator(dataTestId));
- return wait.until(visibilityOfAllElementsLocatedBy);
- }
-
- /**
- * @deprecated Do not use. use {@link #getWebElementWaitForVisible(String)}
- * @param dataTestId
- * @return
- */
- public static WebElement getWebElementByDataTestId(String dataTestId) {
- return driver.findElement(builDataTestIdLocator(dataTestId));
- }
-
- /**
- * Checks if element is present with given dataTestsId
- *
- * @param dataTestId
- * @return
- */
- public static boolean isElementPresent(String dataTestId) {
- final boolean isPresent = !driver.findElements(builDataTestIdLocator(dataTestId)).isEmpty();
- return isPresent;
- }
-
- public static void clickOnCreateEntityFromDashboard(String buttonId) {
- Supplier<WebElement> addVfButtonSipplier = () -> {
- // TODO ui-ci replace with data-test-id
- GeneralUIUtils.moveToHTMLElementByClassName("w-sdc-dashboard-card-new");
- return GeneralUIUtils.getWebElementByDataTestId(buttonId);
- };
- WebElement addVfButton = FunctionalInterfaces.retryMethodOnException(addVfButtonSipplier);
- addVfButton.click();
- }
-
- // this function located select list by the data-test-id value and the item
- // to be selected..
- public static Select getSelectList(String item, String dataTestId) {
- Select selectlist = new Select(driver.findElement(builDataTestIdLocator(dataTestId)));
- if (item != null) {
- selectlist.selectByVisibleText(item);
- }
- return selectlist;
- }
-
- // Define description area .
- public static String defineDescription(String descriptionText) {
-
- WebElement resourceDescriptionTextbox = GeneralUIUtils.getWebElementWaitForVisible("description");
- resourceDescriptionTextbox.clear();
- resourceDescriptionTextbox.sendKeys(descriptionText);
-
- return descriptionText;
- }
-
- /**
- * Clicks on the create button waits for the create to finish and the check
- * in button to appear
- */
- public static void clickCreateButton() {
- GeneralUIUtils.waitForLoader();
- getWebElementWaitForClickable(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue()).click();
- GeneralUIUtils.waitForLoader();
- closeNotificatin();
- getWebElementWaitForVisible(DataTestIdEnum.LifeCyleChangeButtons.CHECK_IN.getValue());
- }
-
- public static void closeNotificatin() {
- WebElement notification = driver.findElement(By.className("ui-notification"));
- if (notification != null) {
- notification.click();
- }
- }
-
- public static void clickSaveButton() {
- WebElement createButton = getWebElementWaitForClickable(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue());
- createButton.click();
- }
-
- public static void checkIn() {
- waitForLoader();
- getWebElementWaitForVisible(DataTestIdEnum.LifeCyleChangeButtons.CHECK_IN.getValue()).click();
- getWebElementWaitForVisible(DataTestIdEnum.ModalItems.ACCEP_TESTING_MESSAGE.getValue()).sendKeys("Check in !");
- getWebElementWaitForVisible(DataTestIdEnum.ModalItems.OK.getValue()).click();
- waitForLoader();
- }
-
- public static void moveToStep(CreateAndUpdateStepsEnum Stepname) {
- waitForLoader();
- getWebElementWaitForClickable(Stepname.getValue()).click();
- waitForLoader();
- }
-
- public static void sleep(int duration) {
- swallowException(() -> Thread.sleep(duration));
- }
-
- public static WebDriver getDriver() {
- return driver;
- }
-
- public static void initDriver() {
- try {
- System.out.println("opening browser");
- WebDriver webDriver;
- boolean remoteTesting = SetupCDTest.config.isRemoteTesting();
- if (!remoteTesting) {
- webDriver = new FirefoxDriver();
- } else {
- String remoteEnvIP = SetupCDTest.config.getRemoteTestingMachineIP();
- String remoteEnvPort = SetupCDTest.config.getRemoteTestingMachinePort();
- DesiredCapabilities cap = new DesiredCapabilities();
- cap = DesiredCapabilities.firefox();
- cap.setPlatform(Platform.WINDOWS);
- cap.setBrowserName("firefox");
-
- String remoteNodeUrl = String.format(SetupCDTest.SELENIUM_NODE_URL, remoteEnvIP, remoteEnvPort);
- webDriver = new RemoteWebDriver(new URL(remoteNodeUrl), cap);
-
- }
- driver = webDriver;
-
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
-
- }
-
- /**
- * waits until either loader finishes or 10 seconds has passed.<br>
- * If 10 seconds has passed and loader didn't finish throws
- * LoaderStuckException.<br>
- */
- public static void waitForLoader() {
- waitForLoader(10);
- }
-
- /**
- * waits until either loader finishes or maxWaitTimeInSeconds has
- * passed.<br>
- * If maxWaitTimeInSeconds has passed and loader didn't finish throws
- * LoaderStuckException.<br>
- *
- * @param maxWaitTimeInSeconds
- */
- public static void waitForLoader(int maxWaitTimeInSeconds) {
- long maxWaitTimeMS = maxWaitTimeInSeconds * 1000L;
- Boolean loaderIsRunning = retryMethodOnResult(
- () -> isElementPresent(DataTestIdEnum.GeneralSection.LOADER.getValue()),
- isLoaderPresent -> !isLoaderPresent, maxWaitTimeMS, 50);
- if (loaderIsRunning) {
- throw new LoaderStuckException(
- "UI Loader is stuck, max wait time of " + maxWaitTimeInSeconds + " seconds has passed.");
- }
-
- }
-
- private static class LoaderStuckException extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- private LoaderStuckException(String message) {
- super(message);
- }
- }
-
- /**
- * Move to HTML element by class name. When moving to the HTML element, it
- * will raise hover event.
- *
- * @param className
- */
- public static void moveToHTMLElementByClassName(String className) {
- Actions actions = new Actions(getDriver());
- final WebElement createButtonsArea = getDriver().findElement(By.className(className));
- actions.moveToElement(createButtonsArea).perform();
- }
-
- /**
- * Move to HTML element by element id. When moving to the HTML element, it
- * will raise hover event.
- *
- * @param className
- */
- public static void moveToHTMLElementByDataTestId(String dataTestId) {
- Actions actions = new Actions(getDriver());
- final WebElement createButtonsArea = getWebElementByDataTestId(dataTestId);
- actions.moveToElement(createButtonsArea).perform();
- }
-
- public static void defineVendorName(String resourceVendorName) {
- // TODO ui-ci replace with Enum
- WebElement resourceVendorNameTextbox = getWebElementWaitForVisible("vendorName");
- resourceVendorNameTextbox.clear();
- resourceVendorNameTextbox.sendKeys(resourceVendorName);
- }
-
- public static String defineUserId(String UserId) {
- // TODO ui-ci replace with Enum
- WebElement resourceTagsTextbox = getWebElementWaitForVisible("contactId");
- resourceTagsTextbox.clear();
- resourceTagsTextbox.sendKeys(UserId);
- return UserId;
- }
-
- public static void clickAddComponent(Dashboard componentType) {
- Runnable clickAddTask = () -> {
- // TODO ui-ci replace with data-test-id
- moveToHTMLElementByClassName("w-sdc-dashboard-card-new");
- WebElement addVfButton = getWebElementByDataTestId(componentType.getValue());
- addVfButton.click();
- };
- retryMethodOnException(clickAddTask);
- }
-
- /**
- * This method perform submit for testing process for existing service or
- * resource.<br>
- * It assumes it is activated when in the resource screen and the Submit For
- * Testing button is available.
- *
- * @param componentNameForMessage
- * TODO
- */
- public static void submitForTestingElement(String componentNameForMessage) {
- waitForLoader();
- getWebElementWaitForVisible(DataTestIdEnum.LifeCyleChangeButtons.SUBMIT_FOR_TESTING.getValue()).click();
- waitForLoader();
- getWebElementWaitForVisible(DataTestIdEnum.ModalItems.SUMBIT_FOR_TESTING_MESSAGE.getValue())
- .sendKeys("Submit for testing for " + componentNameForMessage);
- waitForLoader();
- getWebElementWaitForClickable(DataTestIdEnum.ModalItems.OK.getValue()).click();
- waitForLoader();
- waitForElementToDisappear(DataTestIdEnum.ModalItems.OK.getValue());
-
- }
-
- /**
- * Waits Until elements disappears or until 10 seconds pass
- *
- * @param dataTestId
- */
- public static void waitForElementToDisappear(String dataTestId) {
- Supplier<Boolean> elementPresenseChecker = () -> GeneralUIUtils.isElementPresent(dataTestId);
- Function<Boolean, Boolean> verifier = isElementPresent -> !isElementPresent;
- FunctionalInterfaces.retryMethodOnResult(elementPresenseChecker, verifier);
-
- }
-
-} \ No newline at end of file
diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/MethodManipulationUtils.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/MethodManipulationUtils.java
deleted file mode 100644
index 28b39e86f3..0000000000
--- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/MethodManipulationUtils.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.openecomp.sdc.uici.tests.utilities;
-
-/**
- * Class For manipulations on method
- *
- * @author mshitrit
- *
- */
-public final class MethodManipulationUtils {
-
- private MethodManipulationUtils() {
- throw new IllegalAccessError();
- }
-
-}
diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/OnboardUtility.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/OnboardUtility.java
deleted file mode 100644
index 3d21539e86..0000000000
--- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/OnboardUtility.java
+++ /dev/null
@@ -1,477 +0,0 @@
-package org.openecomp.sdc.uici.tests.utilities;
-
-import static org.testng.AssertJUnit.assertTrue;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.nio.file.FileSystems;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.validation.constraints.AssertTrue;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.apache.http.entity.mime.content.FileBody;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.json.JSONObject;
-import org.junit.Test;
-import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum;
-
-import org.openecomp.sdc.ci.tests.config.Config;
-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.rest.ResponseParser;
-import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
-
-/**
- * Utility Class For Onboarding
- *
- * @author mshitrit
- *
- */
-public final class OnboardUtility {
-
- private OnboardUtility() {
- throw new UnsupportedOperationException();
- }
-
- private static final class Constants {
- private static final String VENDOR_SOFTWARE_PRODUCTS = "vendor-software-products";
- private static final String VENDOR_LICENSE_MODELS = "vendor-license-models";
-
- private static final String VSP_ID = "vspId";
- private static final String VALUE = "value";
-
- enum Actions {
- CHECK_IN("Checkin"), SUBMIT("Submit"), CREATE_PACKAGE("Create_Package");
-
- private String value;
-
- private Actions(String value) {
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
- };
- }
-
- /**
- * @param heatFileName
- * @param filepath
- * @param userId
- * @param vld
- * @return
- * @throws Exception
- */
- public static void createVendorSoftwareProduct(String heatFileName, String filepath, String userId,
- VendorLicenseDetails vld) {
- RestResponse createNewVendorSoftwareProduct = FunctionalInterfaces
- .swallowException(() -> createNewVendorSoftwareProduct(vld, userId));
- assertTrue(createNewVendorSoftwareProduct.getErrorCode() == HttpStatus.SC_OK);
- String vspid = ResponseParser.getValueFromJsonResponse(createNewVendorSoftwareProduct.getResponse(),
- Constants.VSP_ID);
-
- RestResponse response = FunctionalInterfaces
- .swallowException(() -> uploadHeatPackage(filepath, heatFileName, vspid, userId));
- assertTrue(response.getErrorCode() == HttpStatus.SC_OK);
-
- response = actionOnComponent(vspid, Constants.Actions.CHECK_IN.getValue(), Constants.VENDOR_SOFTWARE_PRODUCTS,
- userId);
- assertTrue(response.getErrorCode() == HttpStatus.SC_OK);
-
- response = actionOnComponent(vspid, Constants.Actions.SUBMIT.getValue(), Constants.VENDOR_SOFTWARE_PRODUCTS,
- userId);
- assertTrue(response.getErrorCode() == HttpStatus.SC_OK);
-
- response = actionOnComponent(vspid, Constants.Actions.CREATE_PACKAGE.getValue(),
- Constants.VENDOR_SOFTWARE_PRODUCTS, userId);
- assertTrue(response.getErrorCode() == HttpStatus.SC_OK);
-
- }
-
- /**
- * Contains Details Relevant to Vendor License
- *
- * @author mshitrit
- *
- */
- public static final class VendorLicenseDetails {
- private final String vendorId;
- private final String vendorLicenseName;
- private final String vendorLicenseAgreementId;
- private final String featureGroupId;
- private final String vendorSoftwareProduct;
-
- private VendorLicenseDetails(String vendorId, String vendorLicenseName, String vendorLicenseAgreementId,
- String featureGroupId) {
- super();
- this.vendorId = vendorId;
- this.vendorLicenseName = vendorLicenseName;
- this.vendorLicenseAgreementId = vendorLicenseAgreementId;
- this.featureGroupId = featureGroupId;
- vendorSoftwareProduct = UUID.randomUUID().toString().split("-")[0];
- }
-
- public String getVendorId() {
- return vendorId;
- }
-
- public String getVendorLicenseName() {
- return vendorLicenseName;
- }
-
- public String getVendorLicenseAgreementId() {
- return vendorLicenseAgreementId;
- }
-
- public String getFeatureGroupId() {
- return featureGroupId;
- }
-
- public String getVendorSoftwareProduct() {
- return vendorSoftwareProduct;
- }
-
- }
-
- /**
- * Creates Vendor License
- *
- * @param userId
- * @return
- * @throws Exception
- */
- public static VendorLicenseDetails createVendorLicense(String userId) {
- final String fieldNameValue = Constants.VALUE;
- String vendorLicenseName = UUID.randomUUID().toString().split("-")[0];
- RestResponse vendorLicenseResponse = FunctionalInterfaces
- .swallowException(() -> createVendorLicenseModels(vendorLicenseName, userId));
- assertTrue(vendorLicenseResponse.getErrorCode() == HttpStatus.SC_OK);
-
- String vendorId = ResponseParser.getValueFromJsonResponse(vendorLicenseResponse.getResponse(), fieldNameValue);
-
- RestResponse vendorKeyGroupsResponse = FunctionalInterfaces
- .swallowException(() -> createVendorKeyGroups(vendorId, userId));
- assertTrue(vendorKeyGroupsResponse.getErrorCode() == HttpStatus.SC_OK);
- String keyGroupId = ResponseParser.getValueFromJsonResponse(vendorKeyGroupsResponse.getResponse(),
- fieldNameValue);
-
- RestResponse vendorEntitlementPool = FunctionalInterfaces
- .swallowException(() -> createVendorEntitlementPool(vendorId, userId));
- assertTrue(vendorEntitlementPool.getErrorCode() == HttpStatus.SC_OK);
- String entitlementPoolId = ResponseParser.getValueFromJsonResponse(vendorEntitlementPool.getResponse(),
- fieldNameValue);
-
- RestResponse vendorLicenseFeatureGroups = FunctionalInterfaces.swallowException(
- () -> createVendorLicenseFeatureGroups(vendorId, keyGroupId, entitlementPoolId, userId));
- assertTrue(vendorLicenseFeatureGroups.getErrorCode() == HttpStatus.SC_OK);
- String featureGroupId = ResponseParser.getValueFromJsonResponse(vendorLicenseFeatureGroups.getResponse(),
- fieldNameValue);
-
- RestResponse vendorLicenseAgreement = FunctionalInterfaces
- .swallowException(() -> createVendorLicenseAgreement(vendorId, featureGroupId, userId));
- assertTrue(vendorLicenseAgreement.getErrorCode() == HttpStatus.SC_OK);
- String vendorLicenseAgreementId = ResponseParser.getValueFromJsonResponse(vendorLicenseAgreement.getResponse(),
- fieldNameValue);
-
- RestResponse actionOnComponent = actionOnComponent(vendorId, Constants.Actions.CHECK_IN.getValue(),
- Constants.VENDOR_LICENSE_MODELS, userId);
- assertTrue(actionOnComponent.getErrorCode() == HttpStatus.SC_OK);
-
- actionOnComponent = actionOnComponent(vendorId, Constants.Actions.SUBMIT.getValue(),
- Constants.VENDOR_LICENSE_MODELS, userId);
- assertTrue(actionOnComponent.getErrorCode() == HttpStatus.SC_OK);
-
- return new VendorLicenseDetails(vendorId, vendorLicenseName, vendorLicenseAgreementId, featureGroupId);
- }
-
- private static RestResponse actionOnComponent(String vspid, String action, String onboardComponent, String userId) {
- Config config = FunctionalInterfaces.swallowException(() -> Utils.getConfig());
- String url = String.format("http://%s:%s/onboarding-api/v1.0/%s/%s/actions", config.getCatalogBeHost(),
- config.getCatalogBePort(), onboardComponent, vspid);
-
- JSONObject jObject = new JSONObject();
- FunctionalInterfaces.swallowException(() -> jObject.put("action", action));
-
- Map<String, String> headersMap = prepareHeadersMap(userId);
-
- HttpRequest http = new HttpRequest();
- RestResponse response = FunctionalInterfaces
- .swallowException(() -> http.httpSendPut(url, jObject.toString(), headersMap));
- return response;
- }
-
- private static RestResponse createVendorLicenseModels(String name, String userId) throws Exception {
- Config config = Utils.getConfig();
- String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-license-models", config.getCatalogBeHost(),
- config.getCatalogBePort());
-
- JSONObject jObject = new JSONObject();
- jObject.put("vendorName", name);
- jObject.put("description", "new vendor license model");
- jObject.put("iconRef", "icon");
-
- Map<String, String> headersMap = prepareHeadersMap(userId);
-
- HttpRequest http = new HttpRequest();
- RestResponse response = http.httpSendPost(url, jObject.toString(), headersMap);
- return response;
-
- }
-
- private static RestResponse createVendorLicenseAgreement(String vspid, String featureGroupId, String userId)
- throws Exception {
- Config config = Utils.getConfig();
- String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/license-agreements",
- config.getCatalogBeHost(), config.getCatalogBePort(), vspid);
-
- JSONObject licenseTermpObject = new JSONObject();
- licenseTermpObject.put("choice", "Fixed_Term");
- licenseTermpObject.put("other", "");
-
- JSONObject jObjectBody = new JSONObject();
- jObjectBody.put("name", "abc");
- jObjectBody.put("description", "new vendor license agreement");
- jObjectBody.put("requirementsAndConstrains", "abc");
- jObjectBody.put("licenseTerm", licenseTermpObject);
- jObjectBody.put("addedFeatureGroupsIds", Arrays.asList(featureGroupId).toArray());
-
- Map<String, String> headersMap = prepareHeadersMap(userId);
-
- HttpRequest http = new HttpRequest();
- RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap);
- return response;
- }
-
- private static RestResponse createVendorLicenseFeatureGroups(String vspid, String licenseKeyGroupId,
- String entitlementPoolId, String userId) throws Exception {
- Config config = Utils.getConfig();
- String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/feature-groups",
- config.getCatalogBeHost(), config.getCatalogBePort(), vspid);
-
- JSONObject jObject = new JSONObject();
- jObject.put("name", "xyz");
- jObject.put("description", "new vendor license feature groups");
- jObject.put("partNumber", "123abc456");
- jObject.put("addedLicenseKeyGroupsIds", Arrays.asList(licenseKeyGroupId).toArray());
- jObject.put("addedEntitlementPoolsIds", Arrays.asList(entitlementPoolId).toArray());
-
- Map<String, String> headersMap = prepareHeadersMap(userId);
-
- HttpRequest http = new HttpRequest();
- RestResponse response = http.httpSendPost(url, jObject.toString(), headersMap);
- return response;
-
- }
-
- private static RestResponse createVendorEntitlementPool(String vspid, String userId) throws Exception {
- Config config = Utils.getConfig();
- String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/entitlement-pools",
- config.getCatalogBeHost(), config.getCatalogBePort(), vspid);
-
- JSONObject jEntitlementMetricObject = new JSONObject();
- jEntitlementMetricObject.put("choice", "CPU");
- jEntitlementMetricObject.put("other", "");
-
- JSONObject jAggregationFunctionObject = new JSONObject();
- jAggregationFunctionObject.put("choice", "Peak");
- jAggregationFunctionObject.put("other", "");
-
- JSONObject jOperationalScope = new JSONObject();
- jOperationalScope.put("choices", Arrays.asList("Availability_Zone").toArray());
- jOperationalScope.put("other", "");
-
- JSONObject jTimeObject = new JSONObject();
- jTimeObject.put("choice", "Hour");
- jTimeObject.put("other", "");
-
- JSONObject jObjectBody = new JSONObject();
- jObjectBody.put("name", "def");
- jObjectBody.put("description", "new vendor license entitlement pool");
- jObjectBody.put("thresholdValue", "23");
- jObjectBody.put("thresholdUnits", "Absolute");
- jObjectBody.put("entitlementMetric", jEntitlementMetricObject);
- jObjectBody.put("increments", "abcd");
- jObjectBody.put("aggregationFunction", jAggregationFunctionObject);
- jObjectBody.put("operationalScope", jOperationalScope);
- jObjectBody.put("time", jTimeObject);
- jObjectBody.put("manufacturerReferenceNumber", "123aaa");
-
- Map<String, String> headersMap = prepareHeadersMap(userId);
-
- HttpRequest http = new HttpRequest();
- RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap);
- return response;
- }
-
- private static RestResponse createVendorKeyGroups(String vspid, String userId) throws Exception {
- Config config = Utils.getConfig();
- String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/license-key-groups",
- config.getCatalogBeHost(), config.getCatalogBePort(), vspid);
-
- JSONObject jOperationalScope = new JSONObject();
- jOperationalScope.put("choices", Arrays.asList("Tenant").toArray());
- jOperationalScope.put("other", "");
-
- JSONObject jObjectBody = new JSONObject();
- jObjectBody.put("name", "keyGroup");
- jObjectBody.put("description", "new vendor license key group");
- jObjectBody.put("operationalScope", jOperationalScope);
- jObjectBody.put("type", "Universal");
-
- Map<String, String> headersMap = prepareHeadersMap(userId);
-
- HttpRequest http = new HttpRequest();
- RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap);
- return response;
- }
-
- private static RestResponse createNewVendorSoftwareProduct(VendorLicenseDetails vld, String userId)
- throws Exception {
- Config config = Utils.getConfig();
- String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-software-products",
- config.getCatalogBeHost(), config.getCatalogBePort());
-
- JSONObject jlicensingDataObj = new JSONObject();
- jlicensingDataObj.put("licenseAgreement", vld.getVendorLicenseAgreementId());
- jlicensingDataObj.put("featureGroups", Arrays.asList(vld.getFeatureGroupId()).toArray());
-
- JSONObject jObject = new JSONObject();
- jObject.put("name", vld.getVendorSoftwareProduct());
- jObject.put("description", "new VSP description");
- jObject.put("category", "resourceNewCategory.generic");
- jObject.put("subCategory", "resourceNewCategory.generic.database");
- jObject.put("licensingVersion", "1.0");
- jObject.put("vendorName", vld.getVendorLicenseName());
- jObject.put("vendorId", vld.getVendorId());
- jObject.put("icon", "icon");
- jObject.put("licensingData", jlicensingDataObj);
-
- Map<String, String> headersMap = prepareHeadersMap(userId);
- HttpRequest http = new HttpRequest();
-
- RestResponse response = http.httpSendPost(url, jObject.toString(), headersMap);
-
- return response;
- }
-
- private static RestResponse uploadHeatPackage(String filepath, String filename, String vspid, String userId)
- throws Exception {
- Config config = Utils.getConfig();
- CloseableHttpResponse response = null;
-
- MultipartEntityBuilder mpBuilder = MultipartEntityBuilder.create();
- mpBuilder.addPart("resourceZip", new FileBody(getTestZipFile(filepath, filename)));
-
- String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/upload",
- config.getCatalogBeHost(), config.getCatalogBePort(), vspid);
-
- Map<String, String> headersMap = prepareHeadersMap(userId);
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "multipart/form-data");
-
- CloseableHttpClient client = HttpClients.createDefault();
- try {
- HttpPost httpPost = new HttpPost(url);
- RestResponse restResponse = new RestResponse();
-
- Iterator<String> iterator = headersMap.keySet().iterator();
- while (iterator.hasNext()) {
- String key = iterator.next();
- String value = headersMap.get(key);
- httpPost.addHeader(key, value);
- }
- httpPost.setEntity(mpBuilder.build());
- response = client.execute(httpPost);
- HttpEntity entity = response.getEntity();
- String responseBody = null;
- if (entity != null) {
- InputStream instream = entity.getContent();
- StringWriter writer = new StringWriter();
- IOUtils.copy(instream, writer);
- responseBody = writer.toString();
- try {
-
- } finally {
- instream.close();
- }
- }
-
- restResponse.setErrorCode(response.getStatusLine().getStatusCode());
- restResponse.setResponse(responseBody);
-
- return restResponse;
-
- } finally {
- closeResponse(response);
- closeHttpClient(client);
-
- }
- }
-
- private static void closeResponse(CloseableHttpResponse response) {
- try {
- if (response != null) {
- response.close();
- }
- } catch (IOException e) {
- System.out.println(String.format("failed to close client or response: %s", e.getMessage()));
- }
- }
-
- private static void closeHttpClient(CloseableHttpClient client) {
- try {
- if (client != null) {
- client.close();
- }
- } catch (IOException e) {
- System.out.println(String.format("failed to close client or response: %s", e.getMessage()));
- }
- }
-
- private static File getTestZipFile(String filepath, String filename) throws IOException {
- Config config = Utils.getConfig();
- String sourceDir = config.getImportResourceTestsConfigDir();
- java.nio.file.Path filePath = FileSystems.getDefault().getPath(filepath + File.separator + filename);
- return filePath.toFile();
- }
-
- 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 void createVfFromOnboarding(String userID, String zipFile, String filepath) {
- VendorLicenseDetails vld = createVendorLicense(userID);
- createVendorSoftwareProduct(zipFile, filepath, userID, vld);
-
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.OPEN_MODAL_BUTTON.getValue()).click();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.ONBOARDING_SEARCH.getValue())
- .sendKeys(vld.getVendorSoftwareProduct());
-
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.sleep(1000);
- GeneralUIUtils.getWebElementWaitForClickable(vld.getVendorSoftwareProduct()).click();
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.IMPORT_ICON.getValue()).click();
- GeneralUIUtils.getWebElementWaitForClickable(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue()).click();
- GeneralUIUtils.waitForLoader(300);
- }
-
-}
diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ResourceUIUtils.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ResourceUIUtils.java
deleted file mode 100644
index 149912944e..0000000000
--- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ResourceUIUtils.java
+++ /dev/null
@@ -1,299 +0,0 @@
-package org.openecomp.sdc.uici.tests.utilities;
-
-import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.retryMethodOnException;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.function.Function;
-import java.util.function.Supplier;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum;
-import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.Dashboard;
-import org.openqa.selenium.By;
-import org.openqa.selenium.Keys;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
-
-public final class ResourceUIUtils {
- public static final String RESOURCE_NAME_PREFIX = "ResourceCDTest-";
- protected static final boolean IS_BEFORE_TEST = true;
- public static final String INITIAL_VERSION = "0.1";
- public static final String ICON_RESOURCE_NAME = "call_controll";
- protected static final String UPDATED_RESOURCE_ICON_NAME = "objectStorage";
-
- private ResourceUIUtils() {
- }
-
- public static void defineResourceName(String resourceName) {
-
- WebElement resourceNameTextbox = GeneralUIUtils.getDriver().findElement(By.name("componentName"));
- resourceNameTextbox.clear();
- resourceNameTextbox.sendKeys(resourceName);
- }
-
- public static void defineResourceCategory(String category, String datatestsid) {
-
- GeneralUIUtils.getSelectList(category, datatestsid);
- }
-
- public static void importFileWithSendKeyBrowse(String FilePath, String FileName) throws Exception {
- WebElement browsebutton = GeneralUIUtils.getWebElementWaitForVisible("browseButton");
- browsebutton.sendKeys(FilePath + FileName);
- }
-
- public static void defineTagsList(ResourceReqDetails resource, String[] resourceTags) {
- List<String> taglist = new ArrayList<String>();
- ;
- WebElement resourceTagsTextbox = GeneralUIUtils.getWebElementWaitForVisible("i-sdc-tag-input");
- for (String tag : resourceTags) {
- resourceTagsTextbox.clear();
- resourceTagsTextbox.sendKeys(tag);
- resourceTagsTextbox.sendKeys(Keys.ENTER);
- taglist.add(tag);
- }
- resource.setTags(taglist);
- }
-
- public static void defineVendorRelease(String resourceVendorRelease) {
-
- WebElement resourceVendorReleaseTextbox = GeneralUIUtils.getWebElementWaitForVisible("vendorRelease");
- resourceVendorReleaseTextbox.clear();
- resourceVendorReleaseTextbox.sendKeys(resourceVendorRelease);
- }
-
- public static void defineProjectCode(String projectCode) {
-
- WebElement resourceNameTextbox = GeneralUIUtils.getDriver().findElement(By.name("projectCode"));
- resourceNameTextbox.clear();
- resourceNameTextbox.sendKeys(projectCode);
- }
-
- public static void clickButton(String selectButton) {
-
- WebElement clickButton = GeneralUIUtils.getDriver()
- .findElement(By.xpath("//*[@data-tests-id='" + selectButton + "']"));
- clickButton.click();
- }
-
- public static WebElement Waitfunctionforbuttons(String element, int timeout) {
- WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), timeout);
- return wait.until(ExpectedConditions.elementToBeClickable(By.xpath(element)));
- }
-
- // coded by teddy
- public static void fillGeneralInformationPage(ResourceReqDetails resource, User user) {
- try {
- resource.setContactId(user.getUserId());
- resource.setCreatorUserId(user.getUserId());
- resource.setCreatorFullName(user.getFullName());
- defineResourceName(resource.getName());
- defineResourceCategory(resource.getCategories().get(0).getSubcategories().get(0).getName(),
- "selectGeneralCategory");
- GeneralUIUtils.defineDescription(resource.getDescription());
- GeneralUIUtils.defineVendorName(resource.getVendorName());
- defineVendorRelease(resource.getVendorRelease());
- defineTagsList(resource, new String[] { resource.getName() });
- GeneralUIUtils.defineUserId(resource.getCreatorUserId());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static ResourceReqDetails createResourceInUI(User user) {
- ResourceReqDetails defineResourceDetails = defineResourceDetails();
- GeneralUIUtils.clickAddComponent(DataTestIdEnum.Dashboard.BUTTON_ADD_VF);
-
- GeneralUIUtils.waitForLoader();
- fillGeneralInformationPage(defineResourceDetails, user);
- GeneralUIUtils.clickCreateButton();
- return defineResourceDetails;
-
- }
-
- @SuppressWarnings("deprecation")
- private static void openImportWithFile(String filePath, String fileName, Dashboard elementType) {
- Runnable openImportTask = () -> {
- GeneralUIUtils.moveToHTMLElementByDataTestId(Dashboard.IMPORT_AREA.getValue());
- WebElement imoprtVFButton = GeneralUIUtils.getWebElementByDataTestId(elementType.getValue());
- imoprtVFButton.sendKeys(filePath + fileName);
- };
- retryMethodOnException(openImportTask);
-
- }
-
- public static ResourceReqDetails importVfcInUI(User user, String filePath, String fileName) {
- ResourceReqDetails defineResourceDetails = defineResourceDetails();
- openImportWithFile(filePath, fileName, DataTestIdEnum.Dashboard.IMPORT_VFC_FILE);
- // Fill the general page fields.
- GeneralUIUtils.waitForLoader();
- fillGeneralInformationPage(defineResourceDetails, user);
- GeneralUIUtils.clickCreateButton();
- return defineResourceDetails;
- }
-
- /**
- * Import VF
- *
- * @param user
- * @param filePath
- * @param fileName
- * @return
- */
- public static ResourceReqDetails importVfInUI(User user, String filePath, String fileName) {
- ResourceReqDetails defineResourceDetails = defineResourceDetails();
- openImportWithFile(filePath, fileName, DataTestIdEnum.Dashboard.IMPORT_VF_FILE);
- // Fill the general page fields.
- GeneralUIUtils.waitForLoader();
- fillGeneralInformationPage(defineResourceDetails, user);
-
- GeneralUIUtils.clickSaveButton();
-
- return defineResourceDetails;
- }
-
- public static ResourceReqDetails importVfInUIWithoutCheckin(User user, String filePath, String fileName) {
- ResourceReqDetails defineResourceDetails = defineResourceDetails();
- openImportWithFile(filePath, fileName, DataTestIdEnum.Dashboard.IMPORT_VF_FILE);
- // Fill the general page fields.
- GeneralUIUtils.waitForLoader();
- fillGeneralInformationPage(defineResourceDetails, user);
- GeneralUIUtils.clickSaveButton();
- GeneralUIUtils.waitForLoader(40);
- // String okButtonId=DataTestIdEnum.ModalItems.OK.getValue();
- // ResourceUIUtils.clickButton(okButtonId);
- // ResourceUIUtils.Waitfunctionforbuttons("//*[@data-tests-id='"+okButtonId+"']",10);
- // ResourceUIUtils.clickButton(okButtonId);
- return defineResourceDetails;
- }
-
- public static ResourceReqDetails importVfFromOnBoardingModalWithoutCheckin(User user, String fileName) {
- ResourceReqDetails defineResourceDetails = defineResourceDetails();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.OPEN_MODAL_BUTTON.getValue()).click();
- GeneralUIUtils.getWebElementWaitForVisible(fileName).click();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.IMPORT_ICON.getValue()).click();
-
- // Fill the general page fields.
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.clickSaveButton();
- GeneralUIUtils.waitForLoader();
- return defineResourceDetails;
- }
-
- @SuppressWarnings("deprecation")
- public static void updateVfCsar(String filePath, String fileName) {
- retryMethodOnException(
- () -> GeneralUIUtils.getWebElementByDataTestId(DataTestIdEnum.GeneralSection.BROWSE_BUTTON.getValue())
- .sendKeys(filePath + fileName));
- GeneralUIUtils.clickSaveButton();
- GeneralUIUtils.waitForLoader();
- }
-
- public static void updateVfCsarFromOnBoarding() {
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.GeneralSection.BROWSE_BUTTON.getValue()).click();
- GeneralUIUtils.getWebElementsListWaitForVisible(DataTestIdEnum.OnBoardingTable.CSAR_ROW.getValue()).get(0)
- .click();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.UPDATE_ICON.getValue()).click();
- GeneralUIUtils.clickSaveButton();
- GeneralUIUtils.waitForLoader();
- }
-
- public static ResourceReqDetails defineResourceDetails() {
- ResourceReqDetails resource = new ResourceReqDetails();
- resource = ElementFactory.getDefaultResource(NormativeTypesEnum.ROOT,
- ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS);
- resource.setVersion(INITIAL_VERSION);
- resource.setIcon(ICON_RESOURCE_NAME);
- resource.setResourceType(ResourceTypeEnum.VF.toString());
- resource.setName(getRandomComponentName(RESOURCE_NAME_PREFIX));
-
- return resource;
- }
-
- protected static String getRandomComponentName(String prefix) {
- return prefix + new Random().nextInt(10000);
- }
-
- public static ImmutablePair<String, String> getRIPosition(ResourceReqDetails createResourceInUI, User user) {
- GeneralUIUtils.sleep(1000);
- String responseAfterDrag = RestCDUtils.getResource(createResourceInUI).getResponse();
- JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag);
- String xPosPostDrag = (String) ((JSONObject) ((JSONArray) jsonResource.get("componentInstances")).get(0))
- .get("posX");
- String yPosPostDrag = (String) ((JSONObject) ((JSONArray) jsonResource.get("componentInstances")).get(0))
- .get("posY");
- return new ImmutablePair<String, String>(xPosPostDrag, yPosPostDrag);
-
- }
-
- public static void fillinDeploymentArtifactFormAndClickDone(
- org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails details, String filePath) {
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ArtifactModal.LABEL.getValue())
- .sendKeys(details.getArtifactLabel());
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.DESCRIPTION.getValue())
- .sendKeys(details.getDescription());
- GeneralUIUtils.getSelectList(details.getArtifactType(), DataTestIdEnum.ArtifactModal.TYPE.getValue());
- retryMethodOnException(() -> GeneralUIUtils
- .getWebElementByDataTestId(DataTestIdEnum.GeneralSection.BROWSE_BUTTON.getValue()).sendKeys(filePath));
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.DONE.getValue()).click();
- GeneralUIUtils.waitForLoader();
- }
-
- /**
- * Tests and Accept resource or service
- *
- * @param createResourceInUI
- */
- public static void testAndAcceptElement(ComponentReqDetails createResourceInUI) {
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.getWebElementWaitForVisible(createResourceInUI.getName()).click();
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.LifeCyleChangeButtons.START_TESTING.getValue())
- .click();
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.LifeCyleChangeButtons.ACCEPT.getValue()).click();
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.ACCEP_TESTING_MESSAGE.getValue())
- .sendKeys("resource " + createResourceInUI.getName() + " tested successfuly");
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.OK.getValue()).click();
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.waitForElementToDisappear(DataTestIdEnum.ModalItems.OK.getValue());
- }
-
- /**
- * Waits Until resource changed to requested lifeCycle State
- *
- * @param createResourceInUI
- * @param requestedLifeCycleState
- * @return
- */
- public static Resource waitForState(ResourceReqDetails createResourceInUI,
- LifecycleStateEnum requestedLifeCycleState) {
- Supplier<Resource> resourceGetter = () -> {
- String resourceString = RestCDUtils.getResource(createResourceInUI).getResponse();
- return ResponseParser.convertResourceResponseToJavaObject(resourceString);
- };
- Function<Resource, Boolean> verifier = res -> res.getLifecycleState() == requestedLifeCycleState;
- return FunctionalInterfaces.retryMethodOnResult(resourceGetter, verifier);
-
- }
-
-}
diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/RestCDUtils.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/RestCDUtils.java
deleted file mode 100644
index 8b602e305d..0000000000
--- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/RestCDUtils.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package org.openecomp.sdc.uici.tests.utilities;
-
-import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.retryMethodOnResult;
-import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.swallowException;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.function.Supplier;
-
-import org.apache.http.HttpStatus;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONObject;
-
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
-
-public class RestCDUtils {
-
- private static void setResourceUniqueIdAndUUID(ComponentReqDetails element, RestResponse getResourceResponse) {
- element.setUniqueId(ResponseParser.getUniqueIdFromResponse(getResourceResponse));
- element.setUUID(ResponseParser.getUuidFromResponse(getResourceResponse));
- }
-
- public static RestResponse getResourceByNameAndVersionRetryOnFail(String userId, String resourceName,
- String resourceVersion) {
- Supplier<RestResponse> resourceGetter = () -> swallowException(
- () -> ResourceRestUtils.getResourceByNameAndVersion(userId, resourceName, resourceVersion));
- Function<RestResponse, Boolean> validator = restRes -> restRes.getErrorCode() == HttpStatus.SC_OK;
- return retryMethodOnResult(resourceGetter, validator);
- }
-
- public static RestResponse getResource(ResourceReqDetails resource) {
- try {
- System.out.println("trying to get resource");
- RestResponse getResourceResponse = null;
- String reourceUniqueId = resource.getUniqueId();
-
- if (reourceUniqueId != null) {
- GeneralUIUtils.sleep(1000);
- getResourceResponse = ResourceRestUtils.getResource(reourceUniqueId);
- if (getResourceResponse.getErrorCode().intValue() == HttpStatus.SC_OK) {
- System.out.println("succeeded to get resource");
- }
- return getResourceResponse;
- }
- JSONObject getResourceJSONObject = null;
- getResourceResponse = getResourceByNameAndVersionRetryOnFail(UserRoleEnum.ADMIN.getUserId(),
- resource.getName(), resource.getVersion());
- if (getResourceResponse.getErrorCode().intValue() == HttpStatus.SC_OK) {
- JSONArray jArray = new JSONArray(getResourceResponse.getResponse());
- for (int i = 0; i < jArray.length(); i++) {
- getResourceJSONObject = jArray.getJSONObject(i);
- String resourceType = ResponseParser.getValueFromJsonResponse(getResourceJSONObject.toString(),
- "resourceType");
- if (resourceType.equals(resource.getResourceType())) {
- getResourceResponse.setResponse(getResourceJSONObject.toString());
- setResourceUniqueIdAndUUID(resource, getResourceResponse);
- System.out.println("succeeded to get resource");
- return getResourceResponse;
- }
- }
- }
-
- return getResourceResponse;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static RestResponse getService(ServiceReqDetails service, User user) {
- Supplier<RestResponse> serviceFetcher = () -> swallowException(
- () -> ServiceRestUtils.getServiceByNameAndVersion(user, service.getName(), service.getVersion()));
- Function<RestResponse, Boolean> verifier = restResponse -> restResponse.getErrorCode()
- .intValue() == HttpStatus.SC_OK;
- RestResponse getServiceResponse = retryMethodOnResult(serviceFetcher, verifier);
-
- if (getServiceResponse.getErrorCode().intValue() == HttpStatus.SC_OK) {
- setResourceUniqueIdAndUUID(service, getServiceResponse);
- }
- return getServiceResponse;
- }
-
- public static RestResponse getProduct(ProductReqDetails product, User user) throws Exception {
- Thread.sleep(3500);
- RestResponse getProductResponse = ProductRestUtils.getProductByNameAndVersion(product.getName(),
- product.getVersion(), user.getUserId());
- if (getProductResponse.getErrorCode().intValue() == 200) {
- setResourceUniqueIdAndUUID(product, getProductResponse);
- }
- return getProductResponse;
- }
-
- public static Map<String, String> getAllElementVersionsFromResponse(RestResponse getResource) throws Exception {
- Map<String, String> versionsMap = new HashMap<String, String>();
- try {
- ObjectMapper mapper = new ObjectMapper();
-
- JSONObject object = new JSONObject(getResource.getResponse());
- versionsMap = mapper.readValue(object.get("allVersions").toString(), Map.class);
-
- } catch (Exception e) {
- e.printStackTrace();
- return versionsMap;
-
- }
-
- return versionsMap;
- }
-
- public static void deleteElementVersions(Map<String, String> elementVersions, boolean isBeforeTest, Object clazz,
- User user) throws Exception {
- Iterator<String> iterator = elementVersions.keySet().iterator();
- while (iterator.hasNext()) {
- String singleVersion = iterator.next();
- String uniqueId = elementVersions.get(singleVersion);
- RestResponse deleteResponse = null;
- if (clazz instanceof ServiceReqDetails) {
- deleteResponse = ServiceRestUtils.deleteServiceById(uniqueId, user.getUserId());
- } else if (clazz instanceof ResourceReqDetails) {
- deleteResponse = ResourceRestUtils.deleteResource(uniqueId, user.getUserId());
- } else if (clazz instanceof ProductReqDetails) {
- deleteResponse = ProductRestUtils.deleteProduct(uniqueId, user.getUserId());
- }
-
- if (isBeforeTest) {
- assertTrue(deleteResponse.getErrorCode().intValue() == 204
- || deleteResponse.getErrorCode().intValue() == 404);
- } else {
- assertTrue(deleteResponse.getErrorCode().intValue() == 204);
- }
- }
- }
-
- public static void deleteAllResourceVersionsAfterTest(ComponentReqDetails componentDetails,
- RestResponse getObjectResponse, User user) throws Exception {
- deleteAllComponentVersion(false, componentDetails, getObjectResponse, user);
- }
-
- public static void deleteAllResourceVersionsBeforeTest(ComponentReqDetails componentDetails,
- RestResponse getObjectResponse, User user) throws Exception {
- deleteAllComponentVersion(true, componentDetails, getObjectResponse, user);
- }
-
- public static void deleteAllComponentVersion(boolean isBeforeTest, ComponentReqDetails componentDetails,
- RestResponse getObjectResponse, User user) throws Exception {
- if (getObjectResponse.getErrorCode().intValue() == 404)
- return;
- Map<String, String> componentVersionsMap = getAllElementVersionsFromResponse(getObjectResponse);
- System.out.println("deleting...");
- deleteElementVersions(componentVersionsMap, isBeforeTest, componentDetails, user);
- componentDetails.setUniqueId(null);
- }
-
-} \ No newline at end of file
diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ServiceUIUtils.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ServiceUIUtils.java
deleted file mode 100644
index 0130b710a0..0000000000
--- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/ServiceUIUtils.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package org.openecomp.sdc.uici.tests.utilities;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.function.Function;
-import java.util.function.Supplier;
-
-import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum;
-import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.GeneralSection;
-import org.openqa.selenium.Keys;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.Select;
-
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
-import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
-import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
-import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
-
-public final class ServiceUIUtils {
-
- public static final String SERVICE_NAME_PREFIX = "ServiceCDTest-";
- public static final String INITIAL_VERSION = "0.1";
- public static final String ICON_SERVICE_NAME = "mobility";
-
- private ServiceUIUtils() {
- throw new UnsupportedOperationException();
- }
-
- public static String defineServiceName(String serviceName) {
- WebElement serviceNameElement = GeneralUIUtils.getWebElementWaitForVisible(GeneralSection.NAME.getValue());
- serviceNameElement.clear();
- serviceNameElement.sendKeys(serviceName);
- return serviceName;
- }
-
- public static void defineTagsList(ServiceReqDetails service, String[] serviceTags) {
- List<String> taglist = new ArrayList<String>();
- ;
- WebElement serviceTagsTextbox = GeneralUIUtils.getWebElementWaitForVisible("i-sdc-tag-input");
- for (String tag : serviceTags) {
- serviceTagsTextbox.clear();
- serviceTagsTextbox.sendKeys(tag);
- serviceTagsTextbox.sendKeys(Keys.ENTER);
- taglist.add(tag);
- }
- taglist.add(0, service.getName());
- service.setTags(taglist);
- }
-
- public static Select defineServiceCategory(String category) {
-
- return GeneralUIUtils.getSelectList(category, "selectGeneralCategory");
- }
-
- private static void defineServiceProjectCode(String projectCode) {
- WebElement attProjectCodeTextbox = GeneralUIUtils.getWebElementWaitForVisible("projectCode");
- attProjectCodeTextbox.clear();
- attProjectCodeTextbox.sendKeys(projectCode);
- }
-
- private static void fillServiceGeneralPage(ServiceReqDetails service, User user) {
- service.setContactId(user.getUserId());
- service.setCreatorUserId(user.getUserId());
- service.setCreatorFullName(user.getFullName());
- defineServiceName(service.getName());
- defineServiceCategory(service.getCategories().get(0).getName());
- GeneralUIUtils.defineDescription(service.getDescription());
- defineTagsList(service,
- new String[] { service.getName(), "This-is-tag", "another-tag", "Test-automation-tag" });
- GeneralUIUtils.defineUserId(service.getCreatorUserId());
- defineServiceProjectCode(service.getProjectCode());
-
- }
-
- public static ServiceReqDetails createServiceInUI(User user) {
-
- ServiceReqDetails defineServiceetails = defineServiceDetails(user);
- GeneralUIUtils.clickAddComponent(DataTestIdEnum.Dashboard.BUTTON_ADD_SERVICE);
-
- GeneralUIUtils.waitForLoader();
- fillServiceGeneralPage(defineServiceetails, user);
-
- GeneralUIUtils.clickCreateButton();
-
- return defineServiceetails;
-
- }
-
- public static ServiceReqDetails defineServiceDetails(User user) {
- ServiceReqDetails service = new ServiceReqDetails();
- service = ElementFactory.getDefaultService(ServiceCategoriesEnum.MOBILITY, user);
- service.setVersion(INITIAL_VERSION);
- service.setIcon(ICON_SERVICE_NAME);
- service.setName(getRandomComponentName(SERVICE_NAME_PREFIX));
-
- return service;
- }
-
- protected static String getRandomComponentName(String prefix) {
- return prefix + new Random().nextInt(10000);
- }
-
- /**
- * Waits Until service changed to requested lifeCycle State
- *
- * @param createServiceInUI
- * @param requestedLifeCycleState
- * @param user
- * @return
- */
- public static Service waitForState(ServiceReqDetails createServiceInUI, LifecycleStateEnum requestedLifeCycleState,
- User user) {
- Supplier<Service> serviceGetter = () -> {
- String resourceString = RestCDUtils.getService(createServiceInUI, user).getResponse();
- return ResponseParser.convertServiceResponseToJavaObject(resourceString);
- };
- Function<Service, Boolean> verifier = res -> res.getLifecycleState() == requestedLifeCycleState;
- return FunctionalInterfaces.retryMethodOnResult(serviceGetter, verifier);
-
- }
-
- /**
- * This Method Approves service for distribution<br>
- * It assumes governor role is already logged in
- *
- * @param createServiceInUI
- */
- public static void approveServiceForDistribution(ServiceReqDetails createServiceInUI) {
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.getWebElementWaitForVisible(createServiceInUI.getName()).click();
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.LifeCyleChangeButtons.APPROVE.getValue()).click();
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.ACCEP_TESTING_MESSAGE.getValue())
- .sendKeys("Service " + createServiceInUI.getName() + " Approved For Distribution");
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.OK.getValue()).click();
- GeneralUIUtils.waitForLoader();
- GeneralUIUtils.waitForElementToDisappear(DataTestIdEnum.ModalItems.OK.getValue());
- }
-
-}