diff options
Diffstat (limited to 'ui-ci-dev/src/main/java/org')
29 files changed, 0 insertions, 4625 deletions
diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/scripts/CreateVfsFromOnboarding.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/scripts/CreateVfsFromOnboarding.java deleted file mode 100644 index b11f8d19ef..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/scripts/CreateVfsFromOnboarding.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.openecomp.sdc.uici.scripts; - -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.openecomp.sdc.uici.tests.datatypes.CleanTypeEnum; -import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest; -import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.uici.tests.utilities.OnboardUtility; - -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.common.datastructure.FunctionalInterfaces; -import com.google.gson.GsonBuilder; - -/** - * This Class functions to load mass zip files to vfs through onboarding.<br> - * It uses both BE & UI APIs - * - * @author mshitrit - * - */ -public class CreateVfsFromOnboarding extends SetupCDTest { - public static void main(String[] args) { - CreateVfsFromOnboarding manager = new CreateVfsFromOnboarding(); - - FunctionalInterfaces.swallowException(() -> manager.setEnvParameters(CleanTypeEnum.NONE.name())); - // String folderPath = args[0]; - String folderPath = "C:\\onboardingTest\\onBoardingZips"; - File folder = new File(folderPath); - File[] listOfFiles = folder.listFiles(); - List<String> zipFileNames = Arrays.asList(listOfFiles).stream().map(file -> file.getName()) - .filter(fileName -> fileName.endsWith(".zip")).collect(Collectors.toList()); - Map<String, String> filesSuccessMap = new HashMap<>(); - for (String fileName : zipFileNames) { - try { - // Before - manager.beforeState(null); - manager.setBrowserBeforeTest(); - createSingleVfFromOnboarding(folderPath, fileName); - filesSuccessMap.put(fileName, "SUCCESS"); - - } catch (Exception e) { - filesSuccessMap.put(fileName, "FAIL"); - } finally { - FunctionalInterfaces.swallowException(() -> manager.afterState(null)); - manager.quitAfterTest(); - } - } - Path file = Paths.get("RunResults.txt"); - String stringDataModel = new GsonBuilder().setPrettyPrinting().create().toJson(filesSuccessMap); - FunctionalInterfaces.swallowException(() -> Files.write(file, stringDataModel.getBytes())); - } - - private static void createSingleVfFromOnboarding(String filePath, String zipFileName) { - String userId = UserRoleEnum.DESIGNER.getUserId(); - OnboardUtility.createVfFromOnboarding(userId, zipFileName, filePath); - GeneralUIUtils.submitForTestingElement("Vf From Onboarding"); - - } -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CanvasElement.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CanvasElement.java deleted file mode 100644 index c23d05ab23..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CanvasElement.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.openecomp.sdc.uici.tests.datatypes; - -import org.apache.commons.lang3.tuple.ImmutablePair; - -public final class CanvasElement { - private final String uniqueId; - private ImmutablePair<Integer, Integer> location; - private String elementName; - - public String getElementName() { - return elementName; - } - - public CanvasElement(String uniqueId, String elementName, ImmutablePair<Integer, Integer> location) { - super(); - this.uniqueId = uniqueId; - this.location = location; - this.elementName = elementName; - } - - public String getUniqueId() { - return uniqueId; - } - - public ImmutablePair<Integer, Integer> getLocation() { - return location; - } - - public void setLocation(ImmutablePair<Integer, Integer> location) { - this.location = location; - } - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CanvasManager.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CanvasManager.java deleted file mode 100644 index 5ef8c7a56a..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CanvasManager.java +++ /dev/null @@ -1,206 +0,0 @@ -package org.openecomp.sdc.uici.tests.datatypes; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.UUID; -import java.util.stream.Collectors; - -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; -import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; - -public final class CanvasManager { - private Map<String, CanvasElement> canvasElements; - private Actions actions; - private WebElement canvas; - private int reduceCanvasWidthFactor; - // Offsets Are used to find upper right corner of canvas element in order to - // connect links - private static final int CANVAS_ELEMENT_Y_OFFSET = 40; - private static final int CANVAS_ELEMENT_X_OFFSET = 21; // 14 - 27 - - private CanvasManager() { - canvasElements = new HashMap<>(); - actions = new Actions(GeneralUIUtils.getDriver()); - canvas = GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.GeneralCanvasItems.CANVAS.getValue()); - try { - WebElement webElement = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.GeneralCanvasItems.CANVAS_RIGHT_PANEL.getValue()); - reduceCanvasWidthFactor = webElement.getSize().width; - } catch (Exception e) { - reduceCanvasWidthFactor = 0; - } - } - - public static CanvasManager getCanvasManager() { - return new CanvasManager(); - } - - public List<CanvasElement> getCanvasElements() { - return canvasElements.values().stream().collect(Collectors.toList()); - } - - private void addCanvasElement(CanvasElement element) { - canvasElements.put(element.getUniqueId(), element); - } - - private void moveElementOnCanvas(CanvasElement canvasElement, ImmutablePair<Integer, Integer> newLocation) { - GeneralUIUtils.waitForLoader(); - GeneralUIUtils.sleep(500); - actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); - actions.clickAndHold(); - actions.moveToElement(canvas, newLocation.left, newLocation.right); - actions.release(); - actions.perform(); - canvasElement.setLocation(newLocation); - GeneralUIUtils.waitForLoader(); - - } - - public void moveElementOnCanvas(CanvasElement canvasElement) { - moveElementOnCanvas(canvasElement, getFreePosition()); - } - - public void deleteElementFromCanvas(CanvasElement canvasElement) { - GeneralUIUtils.waitForLoader(); - actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); - actions.click(); - actions.perform(); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.GeneralCanvasItems.DELETE_INSTANCE_BUTTON.getValue()) - .click(); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.OK.getValue()).click(); - canvasElements.remove(canvasElement.getUniqueId()); - GeneralUIUtils.waitForLoader(); - } - - public void selectElementFromCanvas(CanvasElement canvasElement) { - GeneralUIUtils.waitForLoader(); - actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); - actions.click(); - actions.perform(); - GeneralUIUtils.waitForLoader(); - } - - public CanvasElement createElementOnCanvas(LeftPanelCanvasItems canvasItem) { - return createElementOnCanvas(canvasItem.getValue(), false); - } - - /** - * Creates Element on the Canvas - use the element name. - * - * @param elementName - * @return - */ - public CanvasElement createElementOnCanvas(String elementName) { - return createElementOnCanvas(elementName, true); - } - - private CanvasElement createElementOnCanvas(String elementName, boolean addPrefix) { - if (addPrefix) { - elementName = DataTestIdEnum.LEFT_PANEL_PREFIX + elementName; - } - GeneralUIUtils.waitForLoader(); - WebElement element = GeneralUIUtils.getWebElementWaitForVisible(elementName); - ImmutablePair<Integer, Integer> freePosition = getFreePosition(); - actions.moveToElement(element, 0, 0); - actions.clickAndHold(); - actions.moveToElement(canvas, freePosition.left, freePosition.right); - actions.release(); - actions.perform(); - - String uniqueId = elementName + "_" + UUID.randomUUID().toString(); - CanvasElement canvasElement = new CanvasElement(uniqueId, elementName, freePosition); - addCanvasElement(canvasElement); - GeneralUIUtils.waitForLoader(); - return canvasElement; - } - - public CanvasElement createUniqueVFOnCanvas(LeftPanelCanvasItems canvasItem) { - GeneralUIUtils.waitForLoader(); - WebElement element = GeneralUIUtils.getWebElementWaitForVisible(canvasItem.getValue()); - ImmutablePair<Integer, Integer> freePosition = getFreePosition(); - actions.moveToElement(element, 0, 0); - actions.clickAndHold(); - actions.moveToElement(canvas, freePosition.left, freePosition.right); - actions.release(); - actions.perform(); - - String uniqueId = canvasItem.name() + "_" + UUID.randomUUID().toString(); - CanvasElement canvasElement = new CanvasElement(uniqueId, canvasItem.getValue(), freePosition); - addCanvasElement(canvasElement); - GeneralUIUtils.waitForLoader(); - return canvasElement; - } - - private ImmutablePair<Integer, Integer> getFreePosition() { - // TODO ui-ci use better method - ImmutablePair<Integer, Integer> randomPosition = null; - boolean freePosition = false; - int minSpace = 150; - while (!freePosition) { - ImmutablePair<Integer, Integer> tempRandomPosition = getRandomPosition(); - freePosition = !canvasElements.values().stream().map(e -> e.getLocation()) - .filter(e -> Math.abs(e.left - tempRandomPosition.left) < minSpace - && Math.abs(e.right - tempRandomPosition.right) < minSpace) - .findAny().isPresent(); - randomPosition = tempRandomPosition; - } - return randomPosition; - } - - private ImmutablePair<Integer, Integer> getRandomPosition() { - int edgeBuffer = 50; - Random random = new Random(); - int xElement = random.nextInt(canvas.getSize().width - 2 * edgeBuffer - reduceCanvasWidthFactor) + edgeBuffer; - int yElement = random.nextInt(canvas.getSize().height - 2 * edgeBuffer) + edgeBuffer; - return new ImmutablePair<Integer, Integer>(xElement, yElement); - } - - /** - * Links two elements on canvas.<br> - * Currently Supports Only elements in the default size.<br> - * Will not work for container type or smaller elements (cp, vl etc...)<br> - * - * @param firstElement - * @param secondElement - */ - public void linkElements(CanvasElement firstElement, CanvasElement secondElement) { - GeneralUIUtils.waitForLoader(); - drawSimpleLink(firstElement, secondElement); - selectReqAndCapAndConnect(); - - GeneralUIUtils.waitForLoader(); - - } - - private void selectReqAndCapAndConnect() { - // Select First Cap - GeneralUIUtils.getWebElementsListWaitForVisible(DataTestIdEnum.LinkMenuItems.LINK_ITEM_CAP.getValue()).get(0) - .click(); - // Select First Req - GeneralUIUtils.getWebElementsListWaitForVisible(DataTestIdEnum.LinkMenuItems.LINK_ITEM_REQ.getValue()).get(0) - .click(); - // Connect - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.LinkMenuItems.CONNECT_BUTTON.getValue()).click(); - - } - - private void drawSimpleLink(CanvasElement firstElement, CanvasElement secondElement) { - - int yOffset = CANVAS_ELEMENT_Y_OFFSET; - int xOffset = CANVAS_ELEMENT_X_OFFSET; - actions.moveToElement(canvas, firstElement.getLocation().left + xOffset, - firstElement.getLocation().right - yOffset); - - actions.clickAndHold(); - actions.moveToElement(canvas, secondElement.getLocation().left + xOffset, - secondElement.getLocation().right - yOffset); - actions.release(); - actions.perform(); - GeneralUIUtils.waitForLoader(); - } -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CleanTypeEnum.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CleanTypeEnum.java deleted file mode 100644 index f0691b89fc..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CleanTypeEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.openecomp.sdc.uici.tests.datatypes; - -import java.util.Arrays; -import java.util.Optional; - -/** - * enum that represents possible methods to clean DB before and after tests. - * - * @author mshitrit - * - */ -public enum CleanTypeEnum { - FULL, - /** Unreliable should be only used in dev **/ - PARTIAL, NONE; - - /** - * Returns CleanType enum by it name - * - * @param cleanType - * @return - */ - public static CleanTypeEnum findByName(String cleanType) { - final Optional<CleanTypeEnum> findAny = Arrays.asList(CleanTypeEnum.values()).stream() - .filter(e -> e.name().equals(cleanType)).findAny(); - return findAny.get(); - } -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CreateAndImportButtonsEnum.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CreateAndImportButtonsEnum.java deleted file mode 100644 index 382584a48d..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CreateAndImportButtonsEnum.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.openecomp.sdc.uici.tests.datatypes; - -public enum CreateAndImportButtonsEnum { - - IMPORT_VF, IMPORT_VFC, IMPORT_CP, IMPORT_VL, CREATE_VF, CREATE_SERVICE, CREATE_PRODUCT; - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CreateAndUpdateStepsEnum.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CreateAndUpdateStepsEnum.java deleted file mode 100644 index ad0281dd74..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/CreateAndUpdateStepsEnum.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.openecomp.sdc.uici.tests.datatypes; - -public enum CreateAndUpdateStepsEnum { - GENERAL("Generalstep"), - ICON("Iconstep"), - DEPLOYMENT_ARTIFACT("Deployment Artifactstep"), - INFORMATION_ARTIFACT("Information Artifactstep"), - PROPERTIES("Propertiesstep"), - ATTRIBUTES("Attributesstep"), - COMPOSITION("Compositionstep"), - DEPLOYMENT("Deploymentstep"), - REQUIREMENTS_AND_CAPABILITIES("Req. & Capabilitiesstep"), - INPUTS("Inputsstep"); - - private String value; - - public String getValue() { - return value; - } - - private CreateAndUpdateStepsEnum(String value) { - this.value = value; - } - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/DataTestIdEnum.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/DataTestIdEnum.java deleted file mode 100644 index 64db12a422..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/DataTestIdEnum.java +++ /dev/null @@ -1,428 +0,0 @@ -package org.openecomp.sdc.uici.tests.datatypes; - -public final class DataTestIdEnum { - private DataTestIdEnum() { - }; - - public enum Dashboard { - IMPORT_AREA("importButtonsArea"), - BUTTON_ADD_VF("createResourceButton"), - BUTTON_ADD_SERVICE("createServiceButton"), - IMPORT_VFC("importVFCbutton"), - IMPORT_VF("importVFbutton"), - IMPORT_VFC_FILE("file-importVFCbutton"), - IMPORT_VF_FILE("file-importVFbutton"); - - private String value; - - public String getValue() { - return value; - } - - private Dashboard(String value) { - this.value = value; - } - } - - public enum LifeCyleChangeButtons { - CREATE("create/save"), - CHECK_IN("check_in"), - SUBMIT_FOR_TESTING("submit_for_testing"), - START_TESTING("start_testing"), - ACCEPT("accept"), - APPROVE("approve"), - DISTRIBUTE("distribute"); - - private String value; - - public String getValue() { - return value; - } - - private LifeCyleChangeButtons(String value) { - this.value = value; - } - } - - /** - * Artifacts Related Elements - * - * @author mshitrit - * - */ - public enum Artifatcs { - ADD_DEPLOYMENT_ARTIFACT("add-deployment-artifact-button"), - SELECT_ARTIFACT_DROPDOWN("selectArtifact"), - ARTIFACT_TYPE_DROPDOWN("artifacttype"), - ARTIFACT_DESCRIPTION("description"), - ARTIFACT_LABEL("artifactLabel"), - BROWSE_BUTTON("browseButton"), - ADD_BUTTON("Add"); - - private String value; - - public String getValue() { - return value; - } - - private Artifatcs(String value) { - this.value = value; - } - - } - - public enum InformationalArtifatcs { - CLOUD_QUESTIONNAIRE("Cloud Questionnaire (completed)"), - FEATURES("Features"), - VENDOR_TEST_RESULT("Vendor Test Result"), - TEST_SCRIPTS("Test Scripts"), - HEAT_TEMPLATE_FROM_VENDOR("HEAT Template from Vendor"), - CAPACITY("Capacity"); - - private String value; - - public String getValue() { - return value; - } - - private InformationalArtifatcs(String value) { - this.value = value; - } - - } - - public enum ArtifactModal { - LABEL("artifact-label"), TYPE("artifacttype"),; - - private String value; - - public String getValue() { - return value; - } - - private ArtifactModal(String value) { - this.value = value; - } - } - - public enum ModalItems { - BROWSE_BUTTON("browseButton"), - ADD("Add"), - DESCRIPTION("description"), - SUMBIT_FOR_TESTING_MESSAGE("changeLifeCycleMessage"), - OK("OK"), - CANCEL("Cancel"), - ACCEP_TESTING_MESSAGE("checkindialog"), - MESSAGE_TEXT("message"), - DONE("Done"); - - private String value; - - public String getValue() { - return value; - } - - private ModalItems(String value) { - this.value = value; - } - } - - public static final String LEFT_PANEL_PREFIX = "leftbar-section-content-item-"; - - public enum LeftPanelCanvasItems { - BLOCK_STORAGE(LEFT_PANEL_PREFIX + "BlockStorage"), - CINDER_VOLUME(LEFT_PANEL_PREFIX + "CinderVolume"), - COMPUTE(LEFT_PANEL_PREFIX + "Compute"), - LOAD_BALANCER(LEFT_PANEL_PREFIX + "LoadBalancer"), - NOVA_SERVER(LEFT_PANEL_PREFIX + "NovaServer"), - OBJECT_STORAGE(LEFT_PANEL_PREFIX + "ObjectStorage"), - // NEUTRON_PORT(LEFT_PANEL_PREFIX + "-NeutronPort"), - // PORT(LEFT_PANEL_PREFIX + "-Port"), - DATABASE(LEFT_PANEL_PREFIX + "-Database"), - VMMC(LEFT_PANEL_PREFIX + "vmmc_work"); - - private String value; - - public String getValue() { - return value; - } - - private LeftPanelCanvasItems(String value) { - this.value = value; - } - } - - public enum RightBar { - PROPERTIES_AND_ATTRIBUTES("properties-and-attributes-tab"), - DEPLOYMENT_ARTIFACTS("deployment-artifact-tab"), - ARTIFACT_NAME("artifactName"), - ADD_ARTIFACT_BUTTON("add_Artifact_Button"), - DELETE_ARTIFACT_BUTTON("delete"), - MYATTR_ATTR_FROM_LIST("my_attr-attr"), - MYATTR_ATTR_VALUE_FROM_LIST("value-of-my_attr"),; - - private String value; - - public String getValue() { - return value; - } - - private RightBar(String value) { - this.value = value; - } - } - - // for now we use index to work with the breadcrumbs - // any change in the breadcrumbs position will require an update here also - public enum BreadcrumbsButtonsEnum { - HOME("breadcrumbs-button-0"), - COMPONENT("breadcrumbs-button-1"); - - private String value; - - public String getValue() { - return value; - } - - private BreadcrumbsButtonsEnum(String value) { - this.value = value; - } - } - - public enum InputsEnum { - VF_INSTANCE("inputs-vf-instance-0"), - FIRST_INPUT_CHECKBOX("inputs-checkbox-0"), - SECOND_INPUT_CHECKBOX("inputs-checkbox-1"), - ADD_INPUTS_BUTTON("add-inputs-to-service-button"), - SERVICE_INPUT("service-input-0"), - DELETE_INPUT("delete-input-0"); - - private String value; - - public String getValue() { - return value; - } - - private InputsEnum(String value) { - this.value = value; - } - - } - - public enum TabsBar { - HIERARCHY_TAB("hierarchy-tab"), - SELECTED_TAB("selected-tab"), - TAB_HEADER("tab-header"), - TAB_SUB_HEADER("tab-sub-header"), - HIERARCHY_MODULE("hierarchy-module-0"), - HIERARCHY_MODULE_TITLE("hierarchy-module-0-title"), - HIERARCHY_SELECTED_MODULE_DATA("selected-module-data"), - HIERARCHY_SELECTED_MODULE_NAME("selected-module-name"), - HIERARCHY_SELECTED_MODULE_UUID("selected-module-group-uuid"), - HIERARCHY_SELECTED_MODULE_VERSION("selected-module-version"), - HIERARCHY_SELECTED_MODULE_IS_BASE("selected-module-is-base"), - HIERARCHY_SELECTED_MODULE_ARTIFACT_NAME("selected-module-artifact-name"), - HIERARCHY_SELECTED_MODULE_ARTIFACT_UUID("selected-module-artifact-uuid"), - HIERARCHY_SELECTED_MODULE_ARTIFACT_VERSION("selected-module-artifact-version"); - - private String value; - - public String getValue() { - return value; - } - - private TabsBar(String value) { - this.value = value; - } - } - - public enum UpdateNamePopover { - OPEN_POPOVER_ICON("edit-name-popover-icon"), - POPOVER_FORM("popover-form"), - POPOVER_SAVE_BUTTON("popover-save-button"), - POPOVER_INSTANCE_NAME("popover-vfinstance-name"), - POPOVER_HEAT_NAME("popover-heat-name"), - POPOVER_MODULE_NAME("popover-module-name"), - POPOVER_CLOSE_BUTTON("popover-close-button"), - POPOVER_X_BUTTON("popover-x-button"); - - private String value; - - public String getValue() { - return value; - } - - private UpdateNamePopover(String value) { - this.value = value; - } - } - - public enum LinkMenuItems { - CANCEL_BUTTON("link-menu-button-cancel"), - CONNECT_BUTTON("link-menu-button-connect"), - LINK_ITEM_CAP("link-item-capabilities"), - LINK_ITEM_REQ("link-item-requirements"), - LINK_MENU("link-menu-open"); - - private String value; - - public String getValue() { - return value; - } - - private LinkMenuItems(String value) { - this.value = value; - } - } - - public enum GeneralCanvasItems { - CANVAS("canvas"), - CANVAS_RIGHT_PANEL("w-sdc-designer-sidebar-head"), - DELETE_INSTANCE_BUTTON("e-sdc-small-icon-delete"); - - private String value; - - public String getValue() { - return value; - } - - private GeneralCanvasItems(String value) { - this.value = value; - } - } - - public enum AttributesSection { - TABLE_ROWS("attributes-table-row"), - EDIT_BUTTON_FOR_NETWORK_ATTR("edit_networks"), - DELETE_BUTTON_FOR_NETWORK_ATTR("delete_networks"), - ADD_BUTTON("add-attribute-button"); - - private String value; - - public String getValue() { - return value; - } - - private AttributesSection(String value) { - this.value = value; - } - } - - public enum AttributeForm { - NAME_FIELD("attributeName"), - DESCRIPTION_FIELD("description"), - TYPE_FIELD("type-field"), - DEFAULT_VAL_FIELD("defaultvalue"), - BOOL_DEFAULT_VAL_FIELD("booleantype"), - SCHEMA_FIELD("schema"), - BOOL_VALUE_FIELD("boolean-type-value"), - HIDDEN_FIELD("hidden"), - UPDATE_BUTTON("Update"), - DONE_BUTTON("Done"), - ADD_BUTTON("Add"); - - private String value; - - public String getValue() { - return value; - } - - private AttributeForm(String value) { - this.value = value; - } - } - - public enum PropertiesSection { - ADD_BUTTON("addGrey"),; - - private String value; - - public String getValue() { - return value; - } - - private PropertiesSection(String value) { - this.value = value; - } - } - - public enum PropertyForm { - FORM_CONTAINER("sdc-edit-property-container"), - NAME_FIELD("propertyName"), - DESCRIPTION_FIELD("description"), - TYPE_FIELD("propertyType"), - SCHEMA_FIELD("schema-type"), - SIMPLE_TYPE_DEFAULT_VAL_FIELD("defaultvalue"), - SIMPLE_TYPE_BOOL_DEFAULT_VAL_FIELD("booleantype"), - LIST_TYPE_DEFAULT_VAL_FIELD("listNewItem-1"), - MAP_TYPE_DEFAULT_VAL_KEY_FIELD_FOR_FIRST_ITEM("mapKey-10"), - MAP_TYPE_DEFAULT_VAL_VALUE_FIELD_FOR_FIRST_ITEM("mapValue-10"), - MAP_TYPE_DEFAULT_VAL_KEY_FIELD_FOR_SECOND_ITEM("mapKey-11"), - MAP_TYPE_DEFAULT_VAL_VALUE_FIELD_FOR_SECOND_ITEM("mapValue-11"), - ADD_ITEM_TO_LIST_BUTTON("add-list-item-1"), - ADD_ITEM_TO_MAP_BUTTON("add-map-item"), - DELETE_FIRST_ITEM_FROM_MAP_BUTTON("delete-map-item-10"), - START_PORT_FIELD_FOR_PORT_PAIRS_DT("-1start_port"), - SAVE_BUTTON("Save"); - - private String value; - - public String getValue() { - return value; - } - - private PropertyForm(String value) { - this.value = value; - } - } - - public enum GeneralSection { - BROWSE_BUTTON("browseButton"), FILE_NAME("filename"), NAME("name"), LOADER("tlv-loader"); - - private String value; - - public String getValue() { - return value; - } - - private GeneralSection(String value) { - this.value = value; - } - } - - public enum ReqAndCapabilitiesSection { - SEARCH_BOX("search-box"), CAP_TAB("cap-tab"), REQ_TAB("req-tab"); - - private String value; - - public String getValue() { - return value; - } - - private ReqAndCapabilitiesSection(String value) { - this.value = value; - } - } - - public enum OnBoardingTable { - OPEN_MODAL_BUTTON("repository-icon"), - VENDOR_HEADER_COL("Vendor"), - NAME_HEADER_COL("Name"), - CATEGORY_HEADER_COL("Category"), - VERSION_HEADER_COL("Version"), - IMPORT_ICON("import-csar"), - UPDATE_ICON("update-csar"), - CSAR_ROW("csar-row"), - ONBOARDING_SEARCH("onboarding-search"); - - private String value; - - public String getValue() { - return value; - } - - private OnBoardingTable(String value) { - this.value = value; - } - } -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/MenuOptionsEnum.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/MenuOptionsEnum.java deleted file mode 100644 index 4c45858de0..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/MenuOptionsEnum.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.openecomp.sdc.uici.tests.datatypes; - -public enum MenuOptionsEnum { - - EDIT("Edit"), CHECK_IN("Check in"), CHECK_OUT("Check out"), VIEW("View"), SUBMIT_FOR_TEST("Submit For Test"), ACCEPT("Accept"), REJECT("Reject"), START_TEST("Start test"), DISTREBUTE("Distribute"); - - private String value; - - public String getValue() { - return value; - } - - private MenuOptionsEnum(String value) { - this.value = value; - } - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/UserCredentials.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/UserCredentials.java deleted file mode 100644 index 0d94529b89..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/datatypes/UserCredentials.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.openecomp.sdc.uici.tests.datatypes; - -import org.openecomp.sdc.be.model.User; - -public class UserCredentials extends User { - - private String password; - - public UserCredentials(String userId, String password, String firstname, String lastname) { - super(); - setUserId(userId); - this.password = password; - setFirstName(firstname); - setLastName(lastname); - } - - public UserCredentials() { - super(); - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/base/SetupCDTest.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/base/SetupCDTest.java deleted file mode 100644 index 42e9f137ec..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/base/SetupCDTest.java +++ /dev/null @@ -1,408 +0,0 @@ -package org.openecomp.sdc.uici.tests.execute.base; - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.apache.commons.lang.NotImplementedException; -import org.apache.log4j.Logger; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.rules.TestName; -import org.openecomp.sdc.uici.tests.datatypes.CleanTypeEnum; -import org.openecomp.sdc.uici.tests.datatypes.UserCredentials; -import org.openecomp.sdc.uici.tests.utilities.FileHandling; -import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Optional; -import org.testng.annotations.Parameters; - -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.api.ComponentBaseTest; -import org.openecomp.sdc.ci.tests.config.Config; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.run.StartTest; -import org.openecomp.sdc.ci.tests.utils.Utils; -import org.openecomp.sdc.common.datastructure.FunctionalInterfaces; -import com.google.common.collect.Lists; -import com.thinkaurelius.titan.core.TitanGraph; - -public abstract class SetupCDTest extends ComponentBaseTest { - - private TitanSnapshot snapshot; - private static CleanTypeEnum cleanType; - - public SetupCDTest() { - super(new TestName(), SetupCDTest.class.getName()); - } - - public SetupCDTest(TestName name, String className) { - super(name, className); - } - - public static Logger logger = Logger.getLogger(SetupCDTest.class.getName()); - - /**************** CONSTANTS ****************/ - private static final String CREDENTIALS_FILE = "src/main/resources/ci/conf/credentials.yaml"; - public static final String SELENIUM_NODE_URL = "http://%s:%s/wd/hub"; - - /**************** PRIVATES ****************/ - public static Config config; - private Map<?, ?> credentialsYamlFileMap; - - private static String devUrl, cdUrl; - - /**************** - * BEFORE - * - * @throws FileNotFoundException - ****************/ - - @BeforeSuite(alwaysRun = true) - @Parameters({ "clean-type" }) - public void setEnvParameters(@Optional("PARTIAL") String cleanType) throws FileNotFoundException { - this.cleanType = CleanTypeEnum.findByName(cleanType); - System.out.println("setup before class"); - config = Utils.getConfig(); - loadCredentialsFile(); - setUrl(); - } - - @BeforeMethod(alwaysRun = true) - public void setBrowserBeforeTest() { - setBrowserBeforeTest(getRole()); - } - - /**************** AFTER ****************/ - @AfterMethod(alwaysRun = true) - public void quitAfterTest() { - System.out.println("closing browser"); - GeneralUIUtils.getDriver().quit(); - } - - @BeforeMethod(alwaysRun = true) - public void beforeState() throws Exception { - CleanTypeEnum cleanType = getCleanMode(); - switch (cleanType) { - case FULL: { - super.beforeState(null); - break; - } - case PARTIAL: { - takeTitanSnapshot(); - break; - } - case NONE: { - // No Clean Up - break; - } - default: { - throw new NotImplementedException("Enum Value:" + cleanType.name() + " Is not handled"); - } - } - - } - - @AfterMethod(alwaysRun = true) - public void afterState() throws Exception { - CleanTypeEnum cleanType = getCleanMode(); - switch (cleanType) { - case FULL: { - super.afterState(null); - break; - } - case PARTIAL: { - resetToOriginalSnapshot(); - break; - } - case NONE: { - // No Clean Up - break; - } - default: { - throw new NotImplementedException("Enum Value:" + cleanType.name() + " Is not handled"); - } - } - - } - - private void takeTitanSnapshot() { - List<Edge> edgeList = Lists.newArrayList(getTitanGraph().edges(null)); - List<Vertex> verList = Lists.newArrayList(getTitanGraph().vertices(null)); - setSnapshot(new TitanSnapshot(edgeList, verList)); - - } - - private static class TitanSnapshot { - List<Edge> edges; - List<Vertex> vertices; - - public List<Edge> getEdges() { - return edges; - } - - public List<Vertex> getVertices() { - return vertices; - } - - private TitanSnapshot(List<Edge> edges, List<Vertex> vertices) { - super(); - this.edges = edges; - this.vertices = vertices; - } - } - - private void resetToOriginalSnapshot() { - - List<Edge> joinedEdges = new ArrayList<>(); - List<Vertex> joinedVertices = new ArrayList<>(); - TitanSnapshot original = getSnapshot(); - takeTitanSnapshot(); - TitanSnapshot current = getSnapshot(); - - original.getEdges().stream().forEach(e -> addIfIdInList(e, current.getEdges(), joinedEdges, e2 -> e2.id())); - original.getVertices().stream() - .forEach(e -> addIfIdInList(e, current.getVertices(), joinedVertices, e2 -> e2.id())); - - List<Edge> edgesToRemove = removeFromList(current.getEdges(), joinedEdges, e2 -> e2.id()); - List<Vertex> verticesToRemove = removeFromList(current.getVertices(), joinedVertices, e2 -> e2.id()); - - List<Edge> edgesToAdd = removeFromList(original.getEdges(), joinedEdges, e2 -> e2.id()); - List<Vertex> verticesToAdd = removeFromList(original.getVertices(), joinedVertices, e2 -> e2.id()); - - if (edgesToAdd.isEmpty() && verticesToAdd.isEmpty()) { - edgesToRemove.stream().forEach(e -> e.remove()); - verticesToRemove.stream().forEach(v -> v.remove()); - } - - } - - private <Element, ID> List<Element> removeFromList(List<Element> listToRemoveFrom, List<Element> elementsToRemove, - Function<Element, ID> idGetter) { - Set<ID> idSet = new HashSet<>(); - // Fill The Set - elementsToRemove.stream().map(e -> idGetter.apply(e)).forEach(e2 -> idSet.add(e2)); - return listToRemoveFrom.stream().filter(p -> !idSet.contains(idGetter.apply(p))).collect(Collectors.toList()); - - } - - private <Element, ID> void addIfIdInList(Element e, List<Element> listToCheck, List<Element> listToAddTo, - Function<Element, ID> idGetter) { - Stream<Element> matchingElements = listToCheck.stream() - .filter(p -> idGetter.apply(e).equals(idGetter.apply(p))); - listToAddTo.addAll(matchingElements.collect(Collectors.toList())); - } - - /**************** MAIN ****************/ - public static void main(String[] args) { - System.out.println("---------------------"); - System.out.println("running test from CLI"); - System.out.println("---------------------"); - args = new String[] { "ui-ci.xml" }; - StartTest.main(args); - } - - /***********************************************************************************/ - - protected void setBrowserBeforeTest(UserRoleEnum role) { - System.out.println("setup before test"); - GeneralUIUtils.initDriver(); - setDevUrl(role); - loginWithUser(role); - } - - protected void setUrl() { - cdUrl = config.getUrl(); - setDevUrl(getRole()); - } - - private Map<String, String> loadCredentialsFile() { - final String credintialsFile = (System.getProperty("credentials.file") != null) - ? System.getProperty("credentials.file") : CREDENTIALS_FILE; - System.out.println("credentials file is : " + credintialsFile); - FunctionalInterfaces.swallowException( - () -> credentialsYamlFileMap = (Map<String, String>) FileHandling.parseYamlFile(credintialsFile)); - System.out.println(credentialsYamlFileMap.toString()); - return (Map<String, String>) credentialsYamlFileMap; - } - - protected UserCredentials getUserCredentialsFromFile(String userRole) throws Exception { - Map<String, String> credentialsMap = (Map<String, String>) credentialsYamlFileMap.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); - } - - public void navigateToUrl(String url) throws InterruptedException { - WebDriver driver = GeneralUIUtils.getDriver(); - System.out.println("navigating to URL :" + url); - driver.navigate().to(url); - driver.manage().window().maximize(); - driver.manage().deleteAllCookies(); - } - - protected void loginToSystem(UserCredentials credentials) throws Exception { - - sendUserAndPasswordKeys(credentials); - WebElement submitButton = GeneralUIUtils.getDriver().findElement(By.name("btnSubmit")); - submitButton.click(); - WebElement buttonOK = GeneralUIUtils.getDriver().findElement(By.name("successOK")); - AssertJUnit.assertTrue(buttonOK.isDisplayed()); - buttonOK.click(); - System.out.println("Entering to design studio"); - Thread.sleep(2000); - WebElement enterToUserWorkspaceButton = GeneralUIUtils.getDriver() - .findElement(By.xpath("//button[@data-tests-id='Design Studio']")); - enterToUserWorkspaceButton.click(); - } - - private void sendUserAndPasswordKeys(UserCredentials userId) { - System.out.println("Login to system with user : " + userId.getUserId()); - WebElement userNameTextbox = GeneralUIUtils.getDriver().findElement(By.name("userid")); - userNameTextbox.sendKeys(userId.getUserId()); - WebElement passwordTextbox = GeneralUIUtils.getDriver().findElement(By.name("password")); - passwordTextbox.sendKeys(userId.getPassword()); - } - - public String getUrl() { - String url; - final CleanTypeEnum workMode = getCleanMode(); - switch (workMode) { - case FULL: { - url = devUrl; - break; - } - case PARTIAL: { - url = devUrl; - break; - } - case NONE: { - url = cdUrl; - break; - } - default: { - throw new NotImplementedException(workMode.name()); - } - - } - return url; - } - - public static void setDevUrl(UserRoleEnum role) { - String url = SetupCDTest.devUrl; - switch (role) { - case ADMIN: { - url = "http://localhost:8181/sdc1/proxy-admin1#/dashboard"; - break; - } - case DESIGNER: { - url = "http://localhost:8181/sdc1/proxy-designer1#/dashboard"; - // url = "http://localhost:9000/#/dashboard"; - break; - } - case GOVERNOR: { - url = "http://localhost:8181/sdc1/proxy-governor1#/dashboard"; - break; - } - case OPS: { - url = "http://localhost:8181/sdc1/proxy-ops1#/dashboard"; - break; - } - case TESTER: { - url = "http://localhost:8181/sdc1/proxy-tester1#/dashboard"; - break; - } - default: { - break; - } - } - SetupCDTest.devUrl = url; - } - - public static Config getConfig() { - return config; - } - - private User user; - - public void loginWithUser(UserRoleEnum role) { - - setUser(role); - String url = getUrl(); - System.out.println("URL is : " + url); - try { - navigateToUrl(url); - if (url.contains("https://www.e-access")) { - System.out.println("going to update designer user to mechIDs form..."); - UserCredentials credentials = getUserCredentialsFromFile(role.name().toLowerCase()); - loginToSystem(credentials); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private void setUser(UserRoleEnum role) { - user = new User(); - user.setUserId(role.getUserId()); - user.setFirstName(role.getFirstName()); - user.setRole(role.name()); - } - - /** - * Current User Role - * - * @return - */ - public UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } - - /** - * To change clean type update configuration.<br> - * Do not override this method. - * - * @return - */ - protected final CleanTypeEnum getCleanMode() { - return cleanType; - } - - public User getUser() { - return user; - } - - protected void quitAndReLogin(UserRoleEnum role) { - quitAfterTest(); - setBrowserBeforeTest(role); - GeneralUIUtils.waitForLoader(30); - } - - public TitanSnapshot getSnapshot() { - return snapshot; - } - - public void setSnapshot(TitanSnapshot snapshot) { - this.snapshot = snapshot; - } - - public static TitanGraph getTitanGraph() { - return titanGraph; - } - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/service/ServiceBasicTests.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/service/ServiceBasicTests.java deleted file mode 100644 index e42de862b7..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/service/ServiceBasicTests.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.openecomp.sdc.uici.tests.execute.service; - -import static org.testng.AssertJUnit.assertTrue; - -import java.util.Arrays; - -import org.apache.http.HttpStatus; -import org.openecomp.sdc.uici.tests.datatypes.CanvasElement; -import org.openecomp.sdc.uici.tests.datatypes.CanvasManager; -import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; -import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest; -import org.openecomp.sdc.uici.tests.utilities.ArtifactUIUtils; -import org.openecomp.sdc.uici.tests.utilities.FileHandling; -import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.uici.tests.utilities.ResourceUIUtils; -import org.openecomp.sdc.uici.tests.utilities.RestCDUtils; -import org.openecomp.sdc.uici.tests.utilities.ServiceUIUtils; -import org.openecomp.sdc.uici.tests.verificator.ServiceVerificator; -import org.openecomp.sdc.uici.tests.verificator.VfVerificator; -import org.openqa.selenium.WebElement; -import org.testng.annotations.Test; - -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.common.api.ArtifactTypeEnum; - -public class ServiceBasicTests extends SetupCDTest { - - @Test - public void testCreateService() { - ServiceReqDetails createServiceInUI = ServiceUIUtils.createServiceInUI(getUser()); - ServiceVerificator.verifyServiceCreated(createServiceInUI, getUser()); - } - - @Test - public void testLinkTwoRI() { - - // create 1st VF - ResourceReqDetails resourceOne = ResourceUIUtils.createResourceInUI(getUser()); - assertTrue(RestCDUtils.getResource(resourceOne).getErrorCode() == HttpStatus.SC_OK); - // add LoadBalancer to resource - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - canvasManager.createElementOnCanvas(LeftPanelCanvasItems.OBJECT_STORAGE); - GeneralUIUtils.checkIn(); - - // create 2nd VF - ResourceReqDetails resourceTwo = ResourceUIUtils.createResourceInUI(getUser()); - assertTrue(RestCDUtils.getResource(resourceTwo).getErrorCode() == HttpStatus.SC_OK); - // add ObjectStorage to resource - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - canvasManager = CanvasManager.getCanvasManager(); - canvasManager.createElementOnCanvas(LeftPanelCanvasItems.LOAD_BALANCER); - GeneralUIUtils.checkIn(); - - // create service - ServiceReqDetails createServiceInUI = ServiceUIUtils.createServiceInUI(getUser()); - // Verify Service is Created - ServiceVerificator.verifyServiceCreated(createServiceInUI, getUser()); - - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - canvasManager = CanvasManager.getCanvasManager(); - - // adding two resource instances - CanvasElement vfOne = canvasManager.createElementOnCanvas(resourceOne.getName()); - - CanvasElement vfTwo = canvasManager.createElementOnCanvas(resourceTwo.getName()); - // link elements - canvasManager.linkElements(vfOne, vfTwo); - - // check results - ServiceVerificator.verifyServiceCreated(createServiceInUI, getUser()); - ServiceVerificator.verifyLinkCreated(createServiceInUI, getUser()); - - } - - /** - * This method tests the following: <br> - * 1. Import of VF <br> - * 2. Certification Of Vf <br> - * 3. Adding deployment artifact to VF <br> - * 4. Creation of Service <br> - * 5. Adding Vf instance to Service <br> - * 6. Service Certification <br> - * 7. Approving Service to distribution by Governor <br> - * 8. Making sure service is ready to distribute by ops <br> - */ - @Test - public void testBuildServiceForDistribution() { - ResourceReqDetails importedVf = ResourceUIUtils.importVfInUI(getUser(), FileHandling.getResourcesFilesPath(), - "valid_vf.csar"); - GeneralUIUtils.waitForLoader(20); - // Verify Import - VfVerificator.verifyResourceIsCreated(importedVf); - - // Create Deployment Artifact - ArtifactUIUtils.createDeploymentArtifactOnVf(FileHandling.getResourcesFilesPath() + "myYang.xml", - ArtifactTypeEnum.YANG_XML); - VfVerificator.verifyResourceContainsDeploymentArtifacts(importedVf, - Arrays.asList(new ArtifactTypeEnum[] { ArtifactTypeEnum.YANG_XML })); - - // Submit For Testing Process VF - GeneralUIUtils.submitForTestingElement(importedVf.getName()); - - // Certify The VF - quitAndReLogin(UserRoleEnum.TESTER); - ResourceUIUtils.testAndAcceptElement(importedVf); - - // Verify Certification - GeneralUIUtils.waitForLoader(); - VfVerificator.verifyResourceIsCertified(importedVf); - - // Create Service - quitAndReLogin(UserRoleEnum.DESIGNER); - ServiceReqDetails createServiceInUI = ServiceUIUtils.createServiceInUI(getUser()); - ServiceVerificator.verifyServiceCreated(createServiceInUI, getUser()); - - // Drag the VF To the Service - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - canvasManager.createElementOnCanvas(importedVf.getName()); - - // Submit For Testing Process Service - GeneralUIUtils.submitForTestingElement(null); - - // Certify The Service - quitAndReLogin(UserRoleEnum.TESTER); - ResourceUIUtils.testAndAcceptElement(createServiceInUI); - ServiceVerificator.verifyServiceCertified(createServiceInUI, getUser()); - - // Approve with governor - quitAndReLogin(UserRoleEnum.GOVERNOR); - ServiceUIUtils.approveServiceForDistribution(createServiceInUI); - - // Log in with Ops and verify that can distribute - quitAndReLogin(UserRoleEnum.OPS); - GeneralUIUtils.getWebElementWaitForVisible(createServiceInUI.getName()).click(); - WebElement distributeWebElement = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.LifeCyleChangeButtons.DISTRIBUTE.getValue()); - assertTrue(distributeWebElement != null); - - } - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/service/ServiceInputsTests.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/service/ServiceInputsTests.java deleted file mode 100644 index b3e8e023ca..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/service/ServiceInputsTests.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.openecomp.sdc.uici.tests.execute.service; - -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.assertFalse; - -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.uici.tests.datatypes.CanvasElement; -import org.openecomp.sdc.uici.tests.datatypes.CanvasManager; -import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.BreadcrumbsButtonsEnum; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.InputsEnum; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.ModalItems; -import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest; -import org.openecomp.sdc.uici.tests.utilities.FileHandling; -import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.uici.tests.utilities.ResourceUIUtils; -import org.openecomp.sdc.uici.tests.utilities.ServiceUIUtils; -import org.openecomp.sdc.uici.tests.verificator.ServiceVerificator; -import org.testng.annotations.Test; - -public class ServiceInputsTests extends SetupCDTest { - - public String serviceName = ""; - - @Test - private void testSelectingInputAndAddingItToTheService() { - ServiceInputsTestsSetUp(); - - assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled")); - assertTrue(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue())); - } - - @Test - private void testDeletingAnInputFromTheService() { - ServiceInputsTestsSetUp(); - - // clicking on the delete input button and accepting the delete - GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.DELETE_INPUT.getValue()).click(); - GeneralUIUtils.getWebElementWaitForClickable(ModalItems.OK.getValue()).click(); - - assertFalse(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled")); - assertFalse(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue())); - } - - @Test - private void testCheckingInTheServiceAndButtonsAreDisabled() throws Exception { - ServiceInputsTestsSetUp(); - - // Checking in the service and accessing it again in the home - GeneralUIUtils.checkIn(); - GeneralUIUtils.closeNotificatin(); - GeneralUIUtils.findComponentAndClick(serviceName); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.INPUTS); - GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.VF_INSTANCE.getValue()).click(); - - assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled")); - assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.SECOND_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled")); - assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.DELETE_INPUT.getValue()).getAttribute("class").contains("disabled")); - } - - @Test - private void testInputsSanity() throws Exception { - ServiceInputsTestsSetUp(); - - assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled")); - assertTrue(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue())); - - // clicking on the delete input button and accepting the delete - GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.DELETE_INPUT.getValue()).click(); - GeneralUIUtils.getWebElementWaitForClickable(ModalItems.OK.getValue()).click(); - - assertFalse(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled")); - assertFalse(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue())); - - // adding the input to the service again - GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).click(); - GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.ADD_INPUTS_BUTTON.getValue()).click(); - - // Checking in the service and accessing it again in the home - GeneralUIUtils.checkIn(); - GeneralUIUtils.closeNotificatin(); - GeneralUIUtils.findComponentAndClick(serviceName); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.INPUTS); - GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.VF_INSTANCE.getValue()).click(); - - assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled")); - assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.SECOND_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled")); - } - - private void ServiceInputsTestsSetUp() { - // create vf - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "service_with_inputs.csar"; - ResourceReqDetails importVfREsourceInUI = ResourceUIUtils.importVfInUIWithoutCheckin(getUser(), filePath, fileName); - GeneralUIUtils.waitForLoader(); - GeneralUIUtils.closeNotificatin(); - GeneralUIUtils.checkIn(); - GeneralUIUtils.closeNotificatin(); - - // create service - ServiceReqDetails createServiceInUI = ServiceUIUtils.createServiceInUI(getUser()); - ServiceVerificator.verifyServiceCreated(createServiceInUI, getUser()); - serviceName = createServiceInUI.getName(); - - // go to composition - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - - // drag vf into canvas - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement canvasElement = canvasManager.createElementOnCanvas(importVfREsourceInUI.getName()); - canvasManager.selectElementFromCanvas(canvasElement); - GeneralUIUtils.waitForLoader(); - - // moving to inputs view - GeneralUIUtils.getWebElementWaitForClickable(BreadcrumbsButtonsEnum.COMPONENT.getValue()).click(); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.INPUTS); - - // adding the input to the service - GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.VF_INSTANCE.getValue()).click(); - GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).click(); - GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.ADD_INPUTS_BUTTON.getValue()).click(); - } -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfBasicTests.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfBasicTests.java deleted file mode 100644 index 918ac934c6..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfBasicTests.java +++ /dev/null @@ -1,234 +0,0 @@ -package org.openecomp.sdc.uici.tests.execute.vf; - -import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.retryMethodOnException; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.util.Map; - -import org.apache.http.HttpStatus; -import org.openecomp.sdc.uici.tests.datatypes.CanvasElement; -import org.openecomp.sdc.uici.tests.datatypes.CanvasManager; -import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; -import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest; -import org.openecomp.sdc.uici.tests.utilities.ArtifactUIUtils; -import org.openecomp.sdc.uici.tests.utilities.FileHandling; -import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.uici.tests.utilities.ResourceUIUtils; -import org.openecomp.sdc.uici.tests.utilities.RestCDUtils; -import org.openecomp.sdc.uici.tests.verificator.VfVerificator; -import org.testng.annotations.Test; - -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject; -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.general.Convertor; -import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; - -public class VfBasicTests extends SetupCDTest { - - @Test - public void testImportVfTableColumns() { - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.OPEN_MODAL_BUTTON.getValue()).click(); - - assertTrue(GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.VENDOR_HEADER_COL.getValue()) != null); - assertTrue(GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.NAME_HEADER_COL.getValue()) != null); - assertTrue(GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.CATEGORY_HEADER_COL.getValue()) != null); - - assertTrue(GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.OnBoardingTable.VERSION_HEADER_COL.getValue()) != null); - } - - @Test - public void testUpdateVfCreatedFromCsar() throws Exception { - // create vf - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "Sample_CSAR.csar"; - ResourceReqDetails importVfResourceInUI = ResourceUIUtils.importVfInUIWithoutCheckin(getUser(), filePath, - fileName); - // update csar - fileName = "Sample_CSAR2.csar"; - ResourceUIUtils.updateVfCsar(filePath, fileName); - VfVerificator.verifyNumOfComponentInstances(importVfResourceInUI, 4); - } - - @Test - public void testImportVf() { - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "Sample_CSAR.csar"; - ResourceReqDetails importVfResourceInUI = ResourceUIUtils.importVfInUI(getUser(), filePath, fileName); - GeneralUIUtils.waitForLoader(); - assertTrue(RestCDUtils.getResource(importVfResourceInUI).getErrorCode() == HttpStatus.SC_OK); - } - - @Test - public void testCreateVf() { - ResourceReqDetails createResourceInUI = ResourceUIUtils.createResourceInUI(getUser()); - assertTrue(RestCDUtils.getResource(createResourceInUI).getErrorCode() == HttpStatus.SC_OK); - } - - @Test - public void testDeleteInstanceFromCanvas() { - ResourceReqDetails createResourceInUI = ResourceUIUtils.createResourceInUI(getUser()); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - - canvasManager.createElementOnCanvas(LeftPanelCanvasItems.BLOCK_STORAGE); - CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - VfVerificator.verifyNumOfComponentInstances(createResourceInUI, 2); - canvasManager.deleteElementFromCanvas(computeElement); - VfVerificator.verifyNumOfComponentInstances(createResourceInUI, 1); - - } - - @Test - public void testUpdateInstanceAttributeValue() { - // creare vfc with attrs - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "VFCWithAttributes.yml"; - ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName); - GeneralUIUtils.checkIn(); - // create vf - ResourceReqDetails createResourceInUI = ResourceUIUtils.createResourceInUI(getUser()); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - // add vfc to canvas - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement canvasElement = canvasManager.createElementOnCanvas(importVfcResourceInUI.getName()); - canvasManager.selectElementFromCanvas(canvasElement); - // edit value of vfc attr - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.RightBar.PROPERTIES_AND_ATTRIBUTES.getValue()) - .click(); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.RightBar.MYATTR_ATTR_FROM_LIST.getValue()).click(); - - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.DEFAULT_VAL_FIELD.getValue()) - .sendKeys("2"); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.DONE_BUTTON.getValue()).click(); - String newValue = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.RightBar.MYATTR_ATTR_VALUE_FROM_LIST.getValue()).getText(); - assertEquals("2", newValue); - } - - @Test(enabled = false) - public void testAddInfomratinalArtifact() throws Exception { - ResourceReqDetails createResourceInUI = ResourceUIUtils.createResourceInUI(getUser()); - - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.INFORMATION_ARTIFACT); - - ArtifactReqDetails informationalArtifact = ElementFactory.getDefaultArtifact(); - final String FILE_PATH = System.getProperty("user.dir") + "\\src\\main\\resources\\Files\\"; - final String FILE_NAME = "Valid_tosca_Mycompute.yml"; - - ArtifactUIUtils.addInformationArtifact(informationalArtifact, FILE_PATH + FILE_NAME, - DataTestIdEnum.InformationalArtifatcs.FEATURES); - ArtifactUIUtils.addInformationArtifact(informationalArtifact, FILE_PATH + FILE_NAME, - DataTestIdEnum.InformationalArtifatcs.CAPACITY); - - RestResponse getResourceResponse = RestCDUtils.getResource(createResourceInUI); - assertEquals("Did not succeed to get resource after create", HttpStatus.SC_OK, - getResourceResponse.getErrorCode().intValue()); - - Map<String, Map<String, Object>> artifactsListFromResponse = ArtifactUIUtils - .getArtifactsListFromResponse(getResourceResponse.getResponse(), "artifacts"); - Map<String, Object> map = artifactsListFromResponse.get("Features"); - - assertTrue(artifactsListFromResponse.size() >= 2); - - } - - @Test - public void testVfCertification() throws IOException { - // Create VF - ResourceReqDetails createResourceInUI = ResourceUIUtils.createResourceInUI(getUser()); - assertTrue(RestCDUtils.getResource(createResourceInUI).getErrorCode() == HttpStatus.SC_OK); - - // Submit For Testing Process - GeneralUIUtils.submitForTestingElement(createResourceInUI.getName()); - - // Tester - quitAndReLogin(UserRoleEnum.TESTER); - ResourceUIUtils.testAndAcceptElement(createResourceInUI); - - // Verification - GeneralUIUtils.waitForLoader(); - VfVerificator.verifyResourceIsCertified(createResourceInUI); - - } - - @Test - public void testDeploymentArtifactForVFi() { - User user = getUser(); - // create vf - ResourceReqDetails createResourceInUI = ResourceUIUtils.createResourceInUI(user); - GeneralUIUtils.checkIn(); - GeneralUIUtils.waitForLoader(); - // create service - GeneralUIUtils.clickOnCreateEntityFromDashboard(DataTestIdEnum.Dashboard.BUTTON_ADD_SERVICE.getValue()); - ResourceUIUtils.defineResourceName("serv"); - GeneralUIUtils.defineDescription("description"); - GeneralUIUtils.waitForLoader(); - ResourceUIUtils.defineResourceCategory("Mobility", "selectGeneralCategory"); - ResourceUIUtils.defineProjectCode("012345"); - GeneralUIUtils.clickSaveButton(); - GeneralUIUtils.waitForLoader(); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - GeneralUIUtils.waitForLoader(); - // add vf to canvas - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement canvasElement = canvasManager.createElementOnCanvas(createResourceInUI.getName()); - canvasManager.selectElementFromCanvas(canvasElement); - GeneralUIUtils.waitForLoader(); - // add artifact - GeneralUIUtils.getWebElementWaitForClickable(DataTestIdEnum.RightBar.DEPLOYMENT_ARTIFACTS.getValue()).click(); - GeneralUIUtils.getWebElementWaitForClickable(DataTestIdEnum.RightBar.ADD_ARTIFACT_BUTTON.getValue()).click(); - String newArtifactLabel = "newArtifact"; - ArtifactReqDetails details = new ArtifactReqDetails("new_atifact", "DCAE_INVENTORY_EVENT", "desc", "", - newArtifactLabel); - ResourceUIUtils.fillinDeploymentArtifactFormAndClickDone(details, - FileHandling.getResourcesFilesPath() + "yamlSample.yml"); - assertTrue(GeneralUIUtils.isElementPresent("artifact_Display_Name-" + newArtifactLabel)); - // edit artifact - GeneralUIUtils.getWebElementWaitForClickable("artifact_Display_Name-" + newArtifactLabel).click(); - String newFileName = "yamlSample2.yml"; - retryMethodOnException( - () -> GeneralUIUtils.getWebElementByDataTestId(DataTestIdEnum.GeneralSection.BROWSE_BUTTON.getValue()) - .sendKeys(FileHandling.getResourcesFilesPath() + newFileName)); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.DONE.getValue()).click(); - GeneralUIUtils.waitForLoader(); - assertEquals(newFileName, - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.RightBar.ARTIFACT_NAME.getValue()).getText()); - // delete artifact - GeneralUIUtils.moveToHTMLElementByDataTestId("artifact_Display_Name-" + newArtifactLabel); - GeneralUIUtils.getWebElementWaitForClickable(DataTestIdEnum.RightBar.DELETE_ARTIFACT_BUTTON.getValue()).click(); - GeneralUIUtils.getWebElementWaitForClickable(DataTestIdEnum.ModalItems.OK.getValue()).click(); - GeneralUIUtils.waitForLoader(); - assertTrue(!GeneralUIUtils.isElementPresent("artifact_Display_Name-" + newArtifactLabel)); - } - - protected ArtifactReqDetails defineInformationalArtifact() throws IOException, Exception { - return ElementFactory.getDefaultArtifact(); - } - - protected ResourceRespJavaObject buildResourceJavaObject(ResourceReqDetails resource, RestResponse restResponse, - User user) { - ResourceRespJavaObject resourceObject = new ResourceRespJavaObject(); - resourceObject = Convertor.constructFieldsForRespValidation(resource, resource.getVersion(), user); - resourceObject.setLifecycleState((LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT).toString()); - resourceObject.setAbstractt("false"); - resourceObject.setIcon(resource.getIcon().replace(" ", "")); - resourceObject.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse)); - return resourceObject; - } - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfCanvasTests.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfCanvasTests.java deleted file mode 100644 index 73b09666ae..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfCanvasTests.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.openecomp.sdc.uici.tests.execute.vf; - -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.uici.tests.datatypes.CanvasElement; -import org.openecomp.sdc.uici.tests.datatypes.CanvasManager; -import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; -import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest; -import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.uici.tests.utilities.ResourceUIUtils; -import org.openecomp.sdc.uici.tests.verificator.VfVerificator; -import org.testng.annotations.Test; - -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; - -public class VfCanvasTests extends SetupCDTest { - - @Test - public void testCanvasDrag() { - ResourceReqDetails createResourceInUI = ResourceUIUtils.createResourceInUI(getUser()); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement createElementOnCanvas = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.BLOCK_STORAGE); - - ImmutablePair<String, String> preMovePos = ResourceUIUtils.getRIPosition(createResourceInUI, getUser()); - - canvasManager.moveElementOnCanvas(createElementOnCanvas); - - VfVerificator.verifyRILocationChanged(createResourceInUI, preMovePos, getUser()); - - } - - @Test - public void testCanvasConnectComponents() { - ResourceReqDetails createResourceInUI = ResourceUIUtils.createResourceInUI(getUser()); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement bsElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.BLOCK_STORAGE); - CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - - canvasManager.linkElements(bsElement, computeElement); - - VfVerificator.verifyLinkCreated(createResourceInUI); - - } - - @Test - public void testCanvasVFSanity() { - ResourceReqDetails createResourceInUI = ResourceUIUtils.createResourceInUI(getUser()); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - - CanvasElement bsElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.BLOCK_STORAGE); - CanvasElement compElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - - ImmutablePair<String, String> preMovePos = ResourceUIUtils.getRIPosition(createResourceInUI, getUser()); - canvasManager.moveElementOnCanvas(bsElement); - canvasManager.moveElementOnCanvas(compElement); - - VfVerificator.verifyRILocationChanged(createResourceInUI, preMovePos, getUser()); - - CanvasElement bsElement2 = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.BLOCK_STORAGE); - - canvasManager.linkElements(bsElement2, compElement); - - VfVerificator.verifyLinkCreated(createResourceInUI); - - VfVerificator.verifyNumOfComponentInstances(createResourceInUI, 3); - - canvasManager.moveElementOnCanvas(compElement); - - canvasManager.deleteElementFromCanvas(bsElement); - - VfVerificator.verifyNumOfComponentInstances(createResourceInUI, 2); - - } - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfDeploymentTests.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfDeploymentTests.java deleted file mode 100644 index 47344b7c68..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfDeploymentTests.java +++ /dev/null @@ -1,340 +0,0 @@ -package org.openecomp.sdc.uici.tests.execute.vf; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.IOException; -import java.util.regex.Pattern; - -import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum; -import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest; -import org.openecomp.sdc.uici.tests.utilities.FileHandling; -import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.uici.tests.utilities.ResourceUIUtils; -import org.openecomp.sdc.uici.tests.utilities.RestCDUtils; -import org.openqa.selenium.WebElement; -import org.testng.annotations.Test; - -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; - -public class VfDeploymentTests extends SetupCDTest { - - // *****************************EditNamePopoverTests*****************************// - @Test - public void ClickingOnEditNamePopoverIconShouldOpenTheEditNamePopoverForm() { - EditNamePopoverTestsSetUp(); - - assertTrue(GeneralUIUtils.isElementPresent(DataTestIdEnum.UpdateNamePopover.POPOVER_FORM.getValue())); - } - - @Test - public void ModuleDataShouldBeDisplayedInTheEditNameForm() { - EditNamePopoverTestsSetUp(); - - WebElement instanceName = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_INSTANCE_NAME.getValue()); - WebElement heatName = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_HEAT_NAME.getValue()); - WebElement moduleName = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_MODULE_NAME.getValue()); - - String moduleNameToDivide = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE.getValue()).getText(); - - String[] dividedModuleName = moduleNameToDivide.split(Pattern.quote("..")); - - assertEquals(dividedModuleName[0], instanceName.getText()); - assertEquals(dividedModuleName[1], heatName.getAttribute("value")); - assertEquals(dividedModuleName[2], moduleName.getText()); - - } - - @Test - public void CloseButtonShouldCloseThePopover() { - EditNamePopoverTestsSetUp(); - - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_CLOSE_BUTTON.getValue()) - .click(); - - assertFalse(GeneralUIUtils.isElementPresent(DataTestIdEnum.UpdateNamePopover.POPOVER_FORM.getValue())); - } - - @Test - public void XButtonShouldCloseThePopover() { - EditNamePopoverTestsSetUp(); - - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_X_BUTTON.getValue()) - .click(); - - assertFalse(GeneralUIUtils.isElementPresent(DataTestIdEnum.UpdateNamePopover.POPOVER_FORM.getValue())); - } - - @Test - public void SaveButtonShouldBeDisabledWhileTheNameHasNotBeenChanged() { - EditNamePopoverTestsSetUp(); - - WebElement popoverSaveButton = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_SAVE_BUTTON.getValue()); - - assertTrue(popoverSaveButton.getAttribute("class").contains("disabled")); - } - - @Test - public void ClickingOnTheSaveButtonShouldUpdateTheModuleName() { - EditNamePopoverTestsSetUp(); - - String newName = "testName"; - - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_HEAT_NAME.getValue()) - .clear(); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_HEAT_NAME.getValue()) - .sendKeys(newName); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_SAVE_BUTTON.getValue()) - .click(); - - GeneralUIUtils.waitForLoader(); - - String moduleName = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE.getValue()).getText(); - - String[] dividedModuleName = moduleName.split(Pattern.quote("..")); - - assertEquals(dividedModuleName[1], newName); - } - - @Test - public void testUpdateModuleNameSanity() { - EditNamePopoverTestsSetUp(); - - String newName = "testName"; - - WebElement instanceName = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_INSTANCE_NAME.getValue()); - WebElement heatName = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_HEAT_NAME.getValue()); - WebElement moduleName = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_MODULE_NAME.getValue()); - - String moduleNameToDivide = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE.getValue()).getText(); - - String[] dividedModuleName = moduleNameToDivide.split(Pattern.quote("..")); - - assertEquals(dividedModuleName[0], instanceName.getText()); - assertEquals(dividedModuleName[1], heatName.getAttribute("value")); - assertEquals(dividedModuleName[2], moduleName.getText()); - - WebElement popoverSaveButton = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.POPOVER_SAVE_BUTTON.getValue()); - - assertTrue(popoverSaveButton.getAttribute("class").contains("disabled")); - - heatName.clear(); - heatName.sendKeys(newName); - - popoverSaveButton.click(); - - GeneralUIUtils.waitForLoader(); - - moduleNameToDivide = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE.getValue()).getText(); - dividedModuleName = moduleNameToDivide.split(Pattern.quote("..")); - - assertEquals(dividedModuleName[1], newName); - } - - // *****************************DeploymentTabsTests*****************************// - - @Test - public void testTabIsBeingDisplayedAtDeploymentView() { - DeploymentTestsSetUp(); - - assertTrue(GeneralUIUtils.isElementPresent(DataTestIdEnum.TabsBar.HIERARCHY_TAB.getValue())); - } - - @Test - public void testClickingOnTabSetsItAsSelected() { - DeploymentTestsSetUp(); - - WebElement hierarchyTab = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_TAB.getValue()); - hierarchyTab.click(); - - assertTrue(hierarchyTab.getAttribute("class").contains("selected")); - } - - @Test - public void testTabNameIsBeingDisplayedInTheSelectedTabHeader() { - DeploymentTestsSetUp(); - - // select the hierarchy tab and check the header - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_TAB.getValue()).click(); - WebElement tabHeader = GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.TabsBar.TAB_HEADER.getValue()); - - assertEquals(tabHeader.getText(), "HIERARCHY"); - } - - @Test - public void testSelectingModuleNameInTheHierarchyTabShouldSelectIt() { - DeploymentTestsSetUp(); - - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_TAB.getValue()).click(); - WebElement hierarchyModule = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE_TITLE.getValue()); - - hierarchyModule.click(); - - assertTrue(hierarchyModule.getAttribute("class").contains("selected")); - } - - @Test - public void testSelectingModuleNameInTheHierarchyTabShouldExpandIt() { - DeploymentTestsSetUp(); - - // select hierarchy tab - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_TAB.getValue()).click(); - WebElement hierarchyModule = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE.getValue()); - - hierarchyModule.click(); - - assertTrue(hierarchyModule.getAttribute("class").contains("expanded")); - } - - @Test - public void testSelectingModuleNameInTheHierarchyTabShouldDisplayItsData() { - DeploymentTestsSetUp(); - - // select hierarchy tab - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_TAB.getValue()).click(); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE.getValue()).click(); - - assertTrue(GeneralUIUtils.isElementPresent(DataTestIdEnum.TabsBar.HIERARCHY_SELECTED_MODULE_DATA.getValue())); - } - - @Test(enabled = false) - public void testResourceNameIsBeingDisplayedInTheSelectedTabSubHeader() { - DeploymentTestsSetUp(); - - // select the hierarchy tab and check the header - // WebElement tabSubHeader = - // getWebElement(DataTestIdEnum.TabsBar.TAB_SUB_HEADER.getValue()); - - // assertEquals(tabSubHeader.getText(), vmmcCsar.getName()); - } - - @Test(enabled = false) - public void testSelectingModuleNameInTheHierarchyTabShouldDisplayItsInformation() throws IOException { - DeploymentTestsSetUp(); - - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_TAB.getValue()).click(); - WebElement hierarchyModule = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE.getValue()); - - // get the module - // String component = RestCDUtils.getResource(vmmcCsar).getResponse(); - // TODO idana fix test - /* - * GroupDefinitionInfo module = getModuleById(component, - * hierarchyModule.getText()); - * - * hierarchyModule.click(); - * - * assertModuleDetails(module, hierarchyModule); - */ - - } - - @Test(enabled = false) - public void testSelectingModuleNameInTheHierarchyTabShouldDisplayItsArtifacts() throws IOException { - DeploymentTestsSetUp(); - - GeneralUIUtils.getWebElementWaitForClickable(DataTestIdEnum.TabsBar.HIERARCHY_TAB.getValue()).click(); - WebElement hierarchyModule = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE.getValue()); - - // TODO idana fix test - // Get the artifact from the module - /* - * String component = RestCDUtils.getResource(vmmcCsar, - * getUser()).getResponse(); GroupDefinitionInfo module = - * getModuleById(component, hierarchyModule.getText()); - * ArtifactDefinitionInfo artifact = module.getArtifacts().get(0); - * - * hierarchyModule.click(); - * - * assertModuleArtifactDetails(artifact); - */ - } - - @Test - public void testTabsViewSanity() throws IOException { - DeploymentTestsSetUp(); - - WebElement hierarchyTab = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_TAB.getValue()); - - assertTrue(hierarchyTab != null); - - hierarchyTab.click(); - - assertTrue(hierarchyTab.getAttribute("class").contains("selected")); - - WebElement tabHeader = GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.TabsBar.TAB_HEADER.getValue()); - WebElement tabSubHeader = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.TAB_SUB_HEADER.getValue()); - - assertEquals(tabHeader.getText(), "HIERARCHY"); - // assertEquals(tabSubHeader.getText(), vmmcCsar.getName()); - - WebElement hierarchyModule = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE.getValue()); - WebElement hierarchyModuleTitle = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE_TITLE.getValue()); - hierarchyModule.click(); - WebElement selectedModuleData = GeneralUIUtils - .getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_SELECTED_MODULE_DATA.getValue()); - - assertTrue(hierarchyModuleTitle.getAttribute("class").contains("selected")); - assertTrue(hierarchyModule.getAttribute("class").contains("expanded")); - assertTrue(selectedModuleData.getAttribute("ng-if") != null); - // TODO idana fix test - /* - * String component = RestCDUtils.getResource(vmmcCsar, - * getUser()).getResponse(); GroupDefinitionInfo module = - * getModuleById(component, hierarchyModule.getText()); - * ArtifactDefinitionInfo artifact = module.getArtifacts().get(0); - * - * assertModuleDetails(module, hierarchyModule); - * - * assertModuleArtifactDetails(artifact); - */ - - } - - // ************************DeploymentTestsSetUpFunction************************// - - private void EditNamePopoverTestsSetUp() { - DeploymentTestsSetUp(); - - // clicking on a module and opening the edit name popover - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_TAB.getValue()).click(); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.TabsBar.HIERARCHY_MODULE.getValue()).click(); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.UpdateNamePopover.OPEN_POPOVER_ICON.getValue()) - .click(); - } - - private void DeploymentTestsSetUp() { - // import csar - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "vf_with_groups.csar"; - ResourceUIUtils.importVfInUI(getUser(), filePath, fileName); - - GeneralUIUtils.waitForLoader(20); - - // moving to deployment view - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.DEPLOYMENT); - } -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfOnboardingTests.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfOnboardingTests.java deleted file mode 100644 index a81d854630..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vf/VfOnboardingTests.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.openecomp.sdc.uici.tests.execute.vf; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest; -import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.uici.tests.utilities.OnboardUtility; -import org.openecomp.sdc.uici.tests.utilities.ResourceUIUtils; -import org.testng.annotations.Test; - -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import com.google.gson.GsonBuilder; - -public class VfOnboardingTests extends SetupCDTest { - - @Test - public void testUpdateVfCreatedOnBoarding() { - // create vf - ResourceReqDetails importVfResourceInUI = ResourceUIUtils.importVfFromOnBoardingModalWithoutCheckin(getUser(), - "mock_vf"); - // update vf - ResourceUIUtils.updateVfCsarFromOnBoarding(); - } - - @Test - public void createVfsFromOnboarding() throws IOException { - String folderPath = "C:\\onboardingTest\\onBoardingZips"; - File folder = new File(folderPath); - File[] listOfFiles = folder.listFiles(); - List<String> zipFileNames = Arrays.asList(listOfFiles).stream().map(file -> file.getName()) - .filter(fileName -> fileName.endsWith(".zip")).collect(Collectors.toList()); - Map<String, String> filesSuccessMap = new HashMap<>(); - for (String fileName : zipFileNames) { - try { - createSingleVfFromOnboarding(folderPath, fileName); - filesSuccessMap.put(fileName, "SUCCESS"); - } catch (Exception e) { - filesSuccessMap.put(fileName, "FAIL"); - } - } - Path file = Paths.get("RunResults.txt"); - String stringDataModel = new GsonBuilder().setPrettyPrinting().create().toJson(filesSuccessMap); - Files.write(file, stringDataModel.getBytes()); - } - - private static void createSingleVfFromOnboarding(String filePath, String zipFileName) { - String userId = UserRoleEnum.DESIGNER.getUserId(); - OnboardUtility.createVfFromOnboarding(userId, zipFileName, filePath); - GeneralUIUtils.submitForTestingElement("Vf From Onboarding"); - - } - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vfc/VfcBasicTests.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vfc/VfcBasicTests.java deleted file mode 100644 index ef21e40c61..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/execute/vfc/VfcBasicTests.java +++ /dev/null @@ -1,219 +0,0 @@ -package org.openecomp.sdc.uici.tests.execute.vfc; - -import static org.testng.AssertJUnit.assertTrue; - -import java.util.List; -import java.util.function.Function; -import java.util.function.Supplier; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.http.HttpStatus; -import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum; -import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum; -import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest; -import org.openecomp.sdc.uici.tests.utilities.FileHandling; -import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.uici.tests.utilities.ResourceUIUtils; -import org.openecomp.sdc.uici.tests.utilities.RestCDUtils; -import org.openecomp.sdc.uici.tests.verificator.VfVerificator; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.Select; -import org.testng.annotations.Test; - -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.common.datastructure.FunctionalInterfaces; - -public class VfcBasicTests extends SetupCDTest { - - @Test - public void testRequirementsAndCapabilitiesSectionOfVfc() { - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "mycompute.yml"; - ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.REQUIREMENTS_AND_CAPABILITIES); - // all expected requirements - assertTrue("Not all expected requirements are displayed.", GeneralUIUtils.isElementPresent("dependency") && GeneralUIUtils.isElementPresent("local_storage")); - // filter requirements - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ReqAndCapabilitiesSection.SEARCH_BOX.getValue()).sendKeys("root"); - Supplier<Boolean> supplier = () -> !GeneralUIUtils.isElementPresent("local_storage"); - Function<Boolean, Boolean> resultVerifier = isNotPresent -> isNotPresent; - Boolean isFilteredRowNotPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier); - assertTrue("The new property was not inserted to the properties table.", isFilteredRowNotPresent); - assertTrue("Filter problem.", GeneralUIUtils.isElementPresent("dependency") && isFilteredRowNotPresent); - // move to cap tab - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ReqAndCapabilitiesSection.CAP_TAB.getValue()).click(); - GeneralUIUtils.getWebElementWaitForVisible("endpoint").click(); - GeneralUIUtils.getWebElementWaitForVisible("initiator").click(); - supplier = () -> GeneralUIUtils.isElementPresent(DataTestIdEnum.PropertyForm.FORM_CONTAINER.getValue()); - resultVerifier = isPresent -> isPresent; - Boolean isPopupOpen = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier); - assertTrue("The update property popup was not opened.", isPopupOpen); - } - - @Test - public void testCreatePropertyTypeListForVfc() { - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "VFCWithAttributes.yml"; - ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.PROPERTIES); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertiesSection.ADD_BUTTON.getValue()).click(); - // fill in fields - String newPropName = "listProperty"; - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.NAME_FIELD.getValue()).sendKeys(newPropName); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.DESCRIPTION_FIELD.getValue()).sendKeys("desc"); - Select typeField = new Select(GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.TYPE_FIELD.getValue())); - typeField.selectByVisibleText("list"); - Select schemaTypeField = new Select(GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.SCHEMA_FIELD.getValue())); - schemaTypeField.selectByVisibleText("string"); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.LIST_TYPE_DEFAULT_VAL_FIELD.getValue()).sendKeys("first"); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.ADD_ITEM_TO_LIST_BUTTON.getValue()).click(); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.LIST_TYPE_DEFAULT_VAL_FIELD.getValue()).sendKeys("second"); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.ADD_ITEM_TO_LIST_BUTTON.getValue()).click(); - // save - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.SAVE_BUTTON.getValue()).click(); - Supplier<Boolean> supplier = () -> GeneralUIUtils.isElementPresent(newPropName); - Function<Boolean, Boolean> resultVerifier = isPresent -> isPresent; - Boolean isPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier); - assertTrue("The new property was not inserted to the properties table.", isPresent); - } - - @Test - public void testCreatePropertyTypeMapForVfc() { - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "VFCWithAttributes.yml"; - ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.PROPERTIES); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertiesSection.ADD_BUTTON.getValue()).click(); - // fill in fields - String newPropName = "mapProperty"; - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.NAME_FIELD.getValue()).sendKeys(newPropName); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.DESCRIPTION_FIELD.getValue()).sendKeys("desc"); - Select typeField = new Select(GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.TYPE_FIELD.getValue())); - typeField.selectByVisibleText("map"); - Select schemaTypeField = new Select(GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.SCHEMA_FIELD.getValue())); - schemaTypeField.selectByVisibleText("string"); - // insert item to map - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.MAP_TYPE_DEFAULT_VAL_KEY_FIELD_FOR_FIRST_ITEM.getValue()).sendKeys("key1"); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.MAP_TYPE_DEFAULT_VAL_VALUE_FIELD_FOR_FIRST_ITEM.getValue()).sendKeys("val1"); - // insert item to map - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.ADD_ITEM_TO_MAP_BUTTON.getValue()).click(); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.MAP_TYPE_DEFAULT_VAL_KEY_FIELD_FOR_SECOND_ITEM.getValue()).sendKeys("key2"); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.MAP_TYPE_DEFAULT_VAL_VALUE_FIELD_FOR_SECOND_ITEM.getValue()).sendKeys("val2"); - // delete item from map - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.DELETE_FIRST_ITEM_FROM_MAP_BUTTON.getValue()).click(); - // save - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.SAVE_BUTTON.getValue()).click(); - Supplier<Boolean> supplier = () -> GeneralUIUtils.isElementPresent(newPropName); - Function<Boolean, Boolean> resultVerifier = isPresent -> isPresent; - Boolean isPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier); - assertTrue("The new property was not inserted to the properties table.", isPresent); - } - - @Test - public void testCreatePropertyTypeDTForVfc() { - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "VFCWithAttributes.yml"; - ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.PROPERTIES); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertiesSection.ADD_BUTTON.getValue()).click(); - // fill in fields - String newPropName = "dt"; - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.NAME_FIELD.getValue()).sendKeys(newPropName); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.DESCRIPTION_FIELD.getValue()).sendKeys("desc"); - Select typeField = new Select(GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.TYPE_FIELD.getValue())); - typeField.selectByValue("org.openecomp.datatypes.heat.contrail.network.rule.PortPairs"); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.START_PORT_FIELD_FOR_PORT_PAIRS_DT.getValue()).sendKeys("first"); - // save - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.SAVE_BUTTON.getValue()).click(); - Supplier<Boolean> supplier = () -> GeneralUIUtils.isElementPresent(newPropName); - Function<Boolean, Boolean> resultVerifier = isPresent -> isPresent; - Boolean isPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier); - assertTrue("The new property was not inserted to the properties table.", isPresent); - } - - @Test - public void testViewAttributesTabForVfc() { - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "VFCWithAttributes.yml"; - ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.ATTRIBUTES); - - List<WebElement> attributesRows = GeneralUIUtils.getWebElementsListWaitForVisible(DataTestIdEnum.AttributesSection.TABLE_ROWS.getValue()); - assertTrue("There is not any row in the table.", !CollectionUtils.isEmpty(attributesRows)); - // display editable buttons - assertTrue("The Add button is not dispaly.", GeneralUIUtils.isElementPresent(DataTestIdEnum.AttributesSection.ADD_BUTTON.getValue())); - assertTrue("The Edit button is not dispaly for 'network' attribute.", GeneralUIUtils.isElementPresent(DataTestIdEnum.AttributesSection.EDIT_BUTTON_FOR_NETWORK_ATTR.getValue())); - assertTrue("The Remove button is not dispaly for 'network' attribute.", GeneralUIUtils.isElementPresent(DataTestIdEnum.AttributesSection.DELETE_BUTTON_FOR_NETWORK_ATTR.getValue())); - // click checkin - GeneralUIUtils.checkIn(); - // enter again - GeneralUIUtils.getWebElementWaitForVisible(importVfcResourceInUI.getName()).click(); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.ATTRIBUTES); - // the editable buttons disappear - assertTrue("The Add button is not dispaly.", !GeneralUIUtils.isElementPresent(DataTestIdEnum.AttributesSection.ADD_BUTTON.getValue())); - assertTrue("The Edit button is not dispaly for 'network' attribute.", !GeneralUIUtils.isElementPresent(DataTestIdEnum.AttributesSection.EDIT_BUTTON_FOR_NETWORK_ATTR.getValue())); - assertTrue("The Remove button is not dispaly for 'network' attribute.", !GeneralUIUtils.isElementPresent(DataTestIdEnum.AttributesSection.DELETE_BUTTON_FOR_NETWORK_ATTR.getValue())); - } - - @Test - public void testCreateAttributeForVfc() { - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "VFCWithAttributes.yml"; - ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.ATTRIBUTES); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributesSection.ADD_BUTTON.getValue()).click(); - // fill in fields - String newAttrName = "attr"; - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.NAME_FIELD.getValue()).sendKeys(newAttrName); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.DESCRIPTION_FIELD.getValue()).sendKeys("desc"); - Select typeField = new Select(GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.TYPE_FIELD.getValue())); - typeField.selectByVisibleText("integer"); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.DEFAULT_VAL_FIELD.getValue()).sendKeys("2"); - // click ok - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.DONE_BUTTON.getValue()).click(); - Supplier<Boolean> supplier = () -> GeneralUIUtils.isElementPresent(newAttrName); - Function<Boolean, Boolean> resultVerifier = isPresent -> isPresent; - Boolean isPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier); - assertTrue("The new attribute was not inserted to the attributes table.", isPresent); - } - - @Test - public void testUpdateTypeForAttributeOfVfc() { - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "VFCWithAttributes.yml"; - ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName); - VfVerificator.verifyResourceIsCreated(importVfcResourceInUI); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.ATTRIBUTES); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributesSection.EDIT_BUTTON_FOR_NETWORK_ATTR.getValue()).click(); - // fill in fields - Select typeField = new Select(GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.TYPE_FIELD.getValue())); - typeField.selectByVisibleText("float"); - // click ok - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.DONE_BUTTON.getValue()).click(); - Supplier<Boolean> supplier = () -> GeneralUIUtils.isElementPresent("float"); - Function<Boolean, Boolean> resultVerifier = isPresent -> isPresent; - Boolean isPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier); - assertTrue("The attribute type was not updated.", isPresent); - } - - @Test - public void testDeleteAttributeForVfc() { - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "VFCWithAttributes.yml"; - ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName); - GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.ATTRIBUTES); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributesSection.DELETE_BUTTON_FOR_NETWORK_ATTR.getValue()).click(); - GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.OK.getValue()).click(); - GeneralUIUtils.waitForLoader(); - Boolean retryResult = FunctionalInterfaces.retryMethodOnResult(() -> !GeneralUIUtils.isElementPresent("networks"), boolResult -> boolResult); - assertTrue("The attribute is shown in the attributes table.", retryResult); - } - - @Test - public void testImportVfc() { - String filePath = FileHandling.getResourcesFilesPath(); - String fileName = "CP.yml"; - ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName); - assertTrue(RestCDUtils.getResource(importVfcResourceInUI).getErrorCode() == HttpStatus.SC_OK); - } -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/run/StartTest.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/run/StartTest.java deleted file mode 100644 index 8232738660..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/run/StartTest.java +++ /dev/null @@ -1,394 +0,0 @@ -package org.openecomp.sdc.uici.tests.run; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; -import org.testng.TestNG; - -import org.openecomp.sdc.ci.tests.config.Config; -import org.openecomp.sdc.ci.tests.utils.Utils; - -public class StartTest { - - public static long timeOfTest = 0; - - public static boolean debug = false; - - public static AtomicBoolean loggerInitialized = new AtomicBoolean(false); - - protected static Logger logger = null; - - public static void main(String[] args) { - // TODO ui-ci add jar building - String debugEnabled = System.getProperty("debug"); - if (debugEnabled != null && debugEnabled.equalsIgnoreCase("true")) { - debug = true; - } - System.out.println("Debug mode is " + (debug ? "enabled" : "disabled")); - - enableLogger(); - - Config config = null; - try { - config = Utils.getConfig(); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - if (config == null) { - logger.error("Failed to configuration file of ci tests."); - System.exit(1); - } - - TestNG testng = new TestNG(); - - List<String> suites = new ArrayList<String>(); - suites.add("testSuites/" + args[0]); - testng.setTestSuites(suites); - // testng.setUseDefaultListeners(true); - testng.setOutputDirectory("target/"); - - testng.run(); - - } - - public StartTest() { - logger = Logger.getLogger(StartTest.class.getName()); - } - - public static void enableLogger() { - - if (false == loggerInitialized.get()) { - - loggerInitialized.set(true); - - String log4jPropsFile = System.getProperty("log4j.configuration"); - if (System.getProperty("os.name").contains("Windows")) { - String logProps = "src/main/resources/ci/conf/log4j.properties"; - if (log4jPropsFile == null) { - System.setProperty("targetlog", "target/"); - log4jPropsFile = logProps; - } - - } - PropertyConfigurator.configureAndWatch(log4jPropsFile); - - } - } - - // public void start(List<String> packages, boolean exitOnFailure) { - // - // boolean success = true; - // StringBuilder results = new StringBuilder(); - //// Result result; - // - // if (packages == null) { - // return; - // } - // - //// for (String packageName : packages) { - //// //List<Class> classesForPackage = - // getClassesForPackage("org.openecomp.sdc.ci.tests.execute"); - //// List<Class> classesForPackage = getClassesForPackage(packageName); - //// if (classesForPackage != null && false == classesForPackage.isEmpty()) - // { - //// for (Class testUnit : classesForPackage) { - //// testClasses.add(testUnit); - //// } - //// } - //// } - //// - //// System.out.println(testClasses); - // - // // tsetClasses.add(LogValidatorTest.class); - // // tsetClasses.add(AttNorthboundTest.class); - // - //// results.append("<Html><head><style>th{background-color: gray;color: - // white;height: 30px;}td {color: black;height: 30px;}.fail - // {background-color: #FF5555;width: 100px;text-align: center;}.success - // {background-color: #00FF00;width: 100px;text-align: center;}.name {width: - // 200px;background-color: #F0F0F0;}.message {width: 300px;background-color: - // #F0F0F0;}</style></head><body>"); - // - // Calendar calendar = Calendar.getInstance(); - // timeOfTest = calendar.getTimeInMillis(); - // SimpleDateFormat date_format = new SimpleDateFormat( - // "MMM dd yyyy HH:mm:ss"); - // results.append("<br/><h2> This report generated on " - // + date_format.format(calendar.getTime()) + "</h2><br/>"); - // - // results.append("<table>"); - // addTableHead(results); - // - //// int size = testClasses.size(); - // int index = 0; - // - // int totalRunTests = 0; - // int totalFailureTests = 0; - // int totalIgnoreTests = 0; - // int numOfFailureClasses = 0; - // for (Class<? extends AttSdcTest> testClass : testClasses) { - // - // index ++; - // - // StringBuilder builder = new StringBuilder(); - // String str = - // "***************************************************************************"; - // builder.append(str + "\n"); - // String current = "class " + index + "/" + size + " failure(" - // + numOfFailureClasses + ") + RUNS(" + totalRunTests + ")" - // + " FAILURES(" + totalFailureTests + ") IGNORED(" - // + totalIgnoreTests + ")"; - // int interval = ((str.length() - current.length() - 2)/ 2); - // String substring = str.substring(0, interval); - // builder.append(substring + " " + current + " " + substring + "\n"); - // builder.append(str + "\n"); - // - // System.out.println(builder.toString()); - // - // logger.debug(builder.toString()); - // logger.debug("Going to run test class " + testClass.getName()); - // - // result = JUnitCore.runClasses(testClass); - // if (result.wasSuccessful() == false) { - // numOfFailureClasses++; - // } - // logger.debug("Test class " + testClass.getName() + " finished " + - // (result.wasSuccessful() ? "OK." : " WITH ERROR.")); - // List<Failure> failures = result.getFailures(); - // if (failures != null) { - // for (Failure failure : failures) { - // logger.error("Test class " + testClass.getName() + " failure test " + - // failure.getTestHeader() + "-" + failure.getTrace()); - // } - // } - // int runsPerClass = result.getRunCount(); - // int failuresPerClass = result.getFailureCount(); - // int ignoredPerClass = result.getIgnoreCount(); - // - // totalRunTests += runsPerClass; - // totalFailureTests += failuresPerClass; - // totalIgnoreTests += ignoredPerClass; - // - // logger.debug("class " + testClass.getName() + " Failed tests " + - // (failuresPerClass * 1.0) / runsPerClass * 100 + " %"); - // logger.debug("class " + testClass.getName() + " Ignored tests " + - // (ignoredPerClass * 1.0) / runsPerClass * 100 + " %"); - // - // - //// List<Failure> failures = result.getFailures(); - //// if (failures != null) { - //// for (Failure failure : failures) { - //// System.err.println("9999999999" + failure.getTestHeader()); - //// } - //// } - // - // addUnitTestResult(results, testClass, result); - // success &= result.wasSuccessful(); - // - // if (numOfFailureClasses > 0) { - // //if (exitOnFailure) { - // if (exitOnFailure) { - // break; - // } - // } - // } - // - // results.append("</table>"); - // results.append("<br/><h2> Tests Summary: </h2><br/>"); - // results.append("Total Runs : " + totalRunTests + "<br/>"); - // results.append("Total Failure : " + totalFailureTests + "<br/>"); - // results.append("Total: " + totalFailureTests + "/" + totalRunTests + - // "<br/>"); - // results.append("</html>"); - // - // FileUtils.writeToFile(Config.instance().getOutputFolder() - // + File.separator + Config.instance().getReportName(), - // results.toString()); - // - // if (!success) { - // System.out.println("FAILURE"); - // logger.error("Failure tests : " + ((totalFailureTests + totalIgnoreTests) - // * 1.0)/ (totalRunTests + totalIgnoreTests) + " %"); - // logger.error("Ignored tests : " + (totalIgnoreTests * 1.0)/ - // (totalRunTests + totalIgnoreTests) + " %"); - // System.exit(1); - // } - // - // System.out.println("SUCCESS"); - // } - - private List<Class> getClassesForPackage(String pkgname) { - - List<Class> classes = new ArrayList<Class>(); - - // Get a File object for the package - File directory = null; - String fullPath; - String relPath = pkgname.replace('.', '/'); - - // System.out.println("ClassDiscovery: Package: " + pkgname + - // " becomes Path:" + relPath); - - URL resource = ClassLoader.getSystemClassLoader().getResource(relPath); - - // System.out.println("ClassDiscovery: Resource = " + resource); - if (resource == null) { - throw new RuntimeException("No resource for " + relPath); - } - fullPath = resource.getFile(); - // System.out.println("ClassDiscovery: FullPath = " + resource); - - if (debug) { - System.out.println("fullPath is " + fullPath); - } - - try { - directory = new File(resource.toURI()); - } catch (URISyntaxException e) { - throw new RuntimeException( - pkgname + " (" + resource - + ") does not appear to be a valid URL / URI. Strange, since we got it from the system...", - e); - } catch (IllegalArgumentException e) { - directory = null; - } - // System.out.println("ClassDiscovery: Directory = " + directory); - - if (directory != null && directory.exists()) { - - // Get the list of the files contained in the package - String[] files = directory.list(); - for (int i = 0; i < files.length; i++) { - - // we are only interested in .class files - if (files[i].endsWith(".class") && false == files[i].contains("$")) { - - // removes the .class extension - String className = pkgname + '.' + files[i].substring(0, files[i].length() - 6); - - // System.out.println("ClassDiscovery: className = " + - // className); - - if (debug) { - System.out.println("ClassDiscovery: className = " + className); - } - - try { - Class clas = Class.forName(className); - boolean isAddToRun = false; - Method[] methods = clas.getMethods(); - for (Method method : methods) { - Annotation[] anns = method.getAnnotations(); - for (Annotation an : anns) { - if (an.annotationType().getSimpleName().equalsIgnoreCase("Test")) { - isAddToRun = true; - break; - } - } - } - if (isAddToRun) - classes.add(clas); - } catch (ClassNotFoundException e) { - throw new RuntimeException("ClassNotFoundException loading " + className); - } - } - } - } else { - try { - String jarPath = fullPath.replaceFirst("[.]jar[!].*", ".jar").replaceFirst("file:", ""); - - if (debug) { - System.out.println("jarPath is " + jarPath); - } - - JarFile jarFile = new JarFile(jarPath); - Enumeration<JarEntry> entries = jarFile.entries(); - while (entries.hasMoreElements()) { - JarEntry entry = entries.nextElement(); - String entryName = entry.getName(); - if (entryName.startsWith(relPath) && entryName.length() > (relPath.length() + "/".length())) { - - // System.out.println("ClassDiscovery: JarEntry: " + - // entryName); - String className = entryName.replace('/', '.').replace('\\', '.').replace(".class", ""); - - // System.out.println("ClassDiscovery: className = " + - // className); - - if (false == className.contains("$")) { - - if (debug) { - System.out.println("ClassDiscovery: className = " + className); - } - - try { - Class clas = Class.forName(className); - boolean isAddToRun = false; - Method[] methods = clas.getMethods(); - for (Method method : methods) { - Annotation[] anns = method.getAnnotations(); - for (Annotation an : anns) { - if (an.annotationType().getSimpleName().equalsIgnoreCase("Test")) { - isAddToRun = true; - break; - } - } - } - if (isAddToRun) - classes.add(clas); - } catch (ClassNotFoundException e) { - throw new RuntimeException("ClassNotFoundException loading " + className); - } - } - } - } - jarFile.close(); - - } catch (IOException e) { - throw new RuntimeException(pkgname + " (" + directory + ") does not appear to be a valid package", e); - } - } - return classes; - } - - private void addTableHead(StringBuilder results) { - results.append("<tr>"); - results.append("<th>").append("Unit Test").append("</th>"); - results.append("<th>").append("Result").append("</th>"); - results.append("</tr>"); - } - - // private void addUnitTestResult(StringBuilder results, - // Class<? extends AttSdcTest> testClass, Result unitTestResult) { - // - // boolean isSuccess = unitTestResult.wasSuccessful(); - // - // String result = (isSuccess) ? "success" : "fail"; - // String fileName = FileUtils.getFileName(testClass.getName()); - // results.append("<tr>"); - // // - // results.append("<td>").append(FileUtils.getFileName(testClass.getName())).append("</td>"); - // results.append("<td class=\"name\">") - // .append("<a href=\"" + fileName + timeOfTest + ".html\">" - // + fileName + "</a>").append("</td>"); - // results.append("<td class=\"" + result + "\">").append(result) - // .append("</td>"); - // results.append("</tr>"); - // } - -} 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 4414499f69..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/utilities/GeneralUIUtils.java +++ /dev/null @@ -1,346 +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(); - WebElement successNotification = driver.findElement(By.className("ui-notification")); - if (successNotification != null) { - successNotification.click(); - } - getWebElementWaitForVisible(DataTestIdEnum.LifeCyleChangeButtons.CHECK_IN.getValue()); - } - - public static void clickSaveButton() { - WebElement createButton = getWebElementWaitForClickable(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue()); - createButton.click(); - } - - public static void closeNotificatin() { - WebElement notification = driver.findElement(By.className("ui-notification")); - if (notification != null) { - notification.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("userId"); - 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 477cc0c3bb..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(); - // 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 abcc3b3ade..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 projectCodeTextbox = GeneralUIUtils.getWebElementWaitForVisible("projectCode"); - projectCodeTextbox.clear(); - projectCodeTextbox.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()); - } - -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/verificator/ServiceVerificator.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/verificator/ServiceVerificator.java deleted file mode 100644 index 0306df0638..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/verificator/ServiceVerificator.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.openecomp.sdc.uici.tests.verificator; - -import static org.testng.AssertJUnit.assertTrue; - -import java.util.function.Function; -import java.util.function.Supplier; - -import org.apache.http.HttpStatus; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.openecomp.sdc.uici.tests.utilities.RestCDUtils; - -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; -import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; -import org.openecomp.sdc.common.datastructure.FunctionalInterfaces; - -public class ServiceVerificator { - public static void verifyNumOfComponentInstances(ServiceReqDetails createServiceInUI, int numOfVFC, User user) { - String responseAfterDrag = RestCDUtils.getService(createServiceInUI, user).getResponse(); - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - int size = ((JSONArray) jsonResource.get("componentInstances")).size(); - assertTrue(size == numOfVFC); - } - - public static void verifyLinkCreated(ServiceReqDetails createServiceInUI, User user) { - String responseAfterDrag = RestCDUtils.getService(createServiceInUI, user).getResponse(); - JSONObject jsonService = (JSONObject) JSONValue.parse(responseAfterDrag); - assertTrue(((JSONArray) jsonService.get("componentInstancesRelations")).size() == 1); - - } - - public static void verifyServiceCreated(ServiceReqDetails createServiceInUI, User user) { - assertTrue(RestCDUtils.getService(createServiceInUI, user).getErrorCode() == HttpStatus.SC_OK); - - } - - /** - * Verifies service is certified with version 1.0 - * - * @param createServiceInUI - * @param user - */ - public static void verifyServiceCertified(ServiceReqDetails createServiceInUI, User user) { - Supplier<RestResponse> serviceGetter = () -> FunctionalInterfaces.swallowException( - () -> ServiceRestUtils.getServiceByNameAndVersion(user, createServiceInUI.getName(), "1.0")); - Function<RestResponse, Boolean> serviceVerificator = restResp -> restResp.getErrorCode() == HttpStatus.SC_OK; - RestResponse certifiedResourceResopnse = FunctionalInterfaces.retryMethodOnResult(serviceGetter, - serviceVerificator); - assertTrue(certifiedResourceResopnse.getErrorCode() == HttpStatus.SC_OK); - - } -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/verificator/VerificatorUtil.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/verificator/VerificatorUtil.java deleted file mode 100644 index 9e983b44d3..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/verificator/VerificatorUtil.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.openecomp.sdc.uici.tests.verificator; - -import static org.testng.AssertJUnit.assertTrue; - -import java.util.function.Function; -import java.util.function.Supplier; - -import org.openecomp.sdc.common.datastructure.FunctionalInterfaces; - -/** - * Util Class For Verificators - * - * @author mshitrit - * - */ -public final class VerificatorUtil { - - private VerificatorUtil() { - throw new IllegalAccessError(); - } - - public static void verifyWithRetry(Supplier<Boolean> verificator) { - Function<Boolean, Boolean> retryVerificationLogic = isVerified -> isVerified; - Boolean isVerifiedAfterRetries = FunctionalInterfaces.retryMethodOnResult(verificator, retryVerificationLogic); - assertTrue(isVerifiedAfterRetries); - } -} diff --git a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/verificator/VfVerificator.java b/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/verificator/VfVerificator.java deleted file mode 100644 index a1c7ca002b..0000000000 --- a/ui-ci-dev/src/main/java/org/openecomp/sdc/uici/tests/verificator/VfVerificator.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.openecomp.sdc.uici.tests.verificator; - -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.http.HttpStatus; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.openecomp.sdc.uici.tests.utilities.ResourceUIUtils; -import org.openecomp.sdc.uici.tests.utilities.RestCDUtils; - -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.ResourceReqDetails; -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.ResponseParser; -import org.openecomp.sdc.common.api.ArtifactTypeEnum; -import org.openecomp.sdc.common.datastructure.FunctionalInterfaces; - -/** - * Class to hold Test Verifications relevant for VF - * - * @author mshitrit - * - */ -public final class VfVerificator { - private VfVerificator() { - throw new UnsupportedOperationException(); - } - - /** - * Verifies that the resource contains a certain number of component - * instances - * - * @param createResourceInUI - * @param numOfVFC - */ - public static void verifyNumOfComponentInstances(ResourceReqDetails createResourceInUI, int numOfVFC) { - Supplier<Boolean> verificator = () -> { - String responseAfterDrag = RestCDUtils.getResource(createResourceInUI).getResponse(); - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - int size = ((JSONArray) jsonResource.get("componentInstances")).size(); - return size == numOfVFC; - }; - VerificatorUtil.verifyWithRetry(verificator); - } - - /** - * Verifies That the createResourceInUI is different that prevRIPos. - * - * @param createResourceInUI - * @param prevRIPos - * @param user - */ - public static void verifyRILocationChanged(ResourceReqDetails createResourceInUI, - ImmutablePair<String, String> prevRIPos, User user) { - Supplier<Boolean> verificator = () -> { - ImmutablePair<String, String> currRIPos = ResourceUIUtils.getRIPosition(createResourceInUI, user); - final boolean isXLocationChanged = !prevRIPos.left.equals(currRIPos.left); - final boolean isYLocationChange = !prevRIPos.right.equals(currRIPos.right); - return isXLocationChanged || isYLocationChange; - }; - VerificatorUtil.verifyWithRetry(verificator); - } - - /** - * Verifies That resource contains two connected instances - * - * @param createResourceInUI - */ - public static void verifyLinkCreated(ResourceReqDetails createResourceInUI) { - Supplier<Boolean> verificator = () -> { - String responseAfterDrag = RestCDUtils.getResource(createResourceInUI).getResponse(); - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - return ((JSONArray) jsonResource.get("componentInstancesRelations")).size() == 1; - }; - VerificatorUtil.verifyWithRetry(verificator); - - } - - /** - * Verifies That the VF is certified to version 1.0 - * - * @param vfToVerify - */ - public static void verifyResourceIsCertified(ResourceReqDetails vfToVerify) { - RestResponse certifiedResourceResopnse = RestCDUtils - .getResourceByNameAndVersionRetryOnFail(UserRoleEnum.ADMIN.getUserId(), vfToVerify.getName(), "1.0"); - assertTrue(certifiedResourceResopnse.getErrorCode().equals(HttpStatus.SC_OK)); - - } - - /** - * Verifies That the VF exist - * - * @param vfToVerify - */ - public static void verifyResourceIsCreated(ResourceReqDetails vfToVerify) { - assertTrue(RestCDUtils.getResource(vfToVerify).getErrorCode() == HttpStatus.SC_OK); - } - - /** - * Verify the resource contains the deployment artifacts in the list - * - * @param vfToVerify - * @param artifactTypeEnums - */ - public static void verifyResourceContainsDeploymentArtifacts(ResourceReqDetails vfToVerify, - List<ArtifactTypeEnum> artifactTypeEnums) { - String resourceString = RestCDUtils.getResource(vfToVerify).getResponse(); - Resource resource = ResponseParser.convertResourceResponseToJavaObject(resourceString); - List<String> foundArtifacts = new ArrayList<>(); - if (resource.getDeploymentArtifacts() != null) { - foundArtifacts = resource.getDeploymentArtifacts().values().stream() - .map(artifact -> artifact.getArtifactType()).collect(Collectors.toList()); - } - List<String> excpectedArtifacts = artifactTypeEnums.stream().map(e -> e.getType()).collect(Collectors.toList()); - assertTrue(foundArtifacts.containsAll(excpectedArtifacts)); - - } - - /** - * Verifies The life cycle State of the resource - * - * @param createResourceInUI - * @param requestedLifeCycleState - */ - public static void verifyState(ResourceReqDetails createResourceInUI, LifecycleStateEnum requestedLifeCycleState) { - Resource resource = ResourceUIUtils.waitForState(createResourceInUI, requestedLifeCycleState); - assertTrue(resource.getLifecycleState() == requestedLifeCycleState); - - } - -} |