From 692dec121aa5ea408c6170325a63b393b755fdf1 Mon Sep 17 00:00:00 2001 From: Bartosz Gardziejewski Date: Mon, 22 Jul 2019 08:25:10 +0200 Subject: fixing warnings from checkstyle in ui-ci Issue-ID: SDC-2454 Signed-off-by: Bartosz Gardziejewski Change-Id: I84b1c0206b7a7c5e12d40582d97411b138eebc4e --- .../US/AddComponentInstancesArtifactsInCsar.java | 568 +++--- ...portUpdateInformationalDeploymentArtifacts.java | 362 ++-- .../java/org/openecomp/sdc/ci/tests/US/Inputs.java | 342 ++-- .../sdc/ci/tests/US/LocalGeneralUtilities.java | 97 +- .../tests/US/MIBsArtifactsOnResourceInstance.java | 420 ++-- .../org/openecomp/sdc/ci/tests/US/MobProxy.java | 194 +- .../sdc/ci/tests/US/NewArtifactTypeGuide.java | 155 +- .../US/RemoveRestrictionOfDeploymentArtifacts.java | 136 +- .../sdc/ci/tests/US/Service_Tests_UI.java | 122 +- .../org/openecomp/sdc/ci/tests/US/Testing.java | 203 +- .../org/openecomp/sdc/ci/tests/US/VfModule.java | 183 +- .../org/openecomp/sdc/ci/tests/US/Vf_Tests_UI.java | 35 +- ...ndNode_TemplatePropertiesWithDefaultValues.java | 478 ++--- .../tests/businesslogic/ArtifactBusinessLogic.java | 352 ++-- .../tests/dataProvider/OnbordingDataProviders.java | 122 +- .../sdc/ci/tests/datatypes/ArtifactInfo.java | 162 +- .../sdc/ci/tests/datatypes/CanvasElement.java | 144 +- .../sdc/ci/tests/datatypes/CanvasManager.java | 1067 +++++----- .../tests/datatypes/CatalogFilterTitlesEnum.java | 20 +- .../sdc/ci/tests/datatypes/CheckBoxStatusEnum.java | 48 +- .../datatypes/ConnectionWizardPopUpObject.java | 16 +- .../datatypes/CreateAndImportButtonsEnum.java | 6 +- .../sdc/ci/tests/datatypes/DataTestIdEnum.java | 2079 ++++++++++---------- .../ci/tests/datatypes/ErrorMessageProperties.java | 60 +- .../ci/tests/datatypes/GeneralCanvasItemsEnum.java | 24 +- .../tests/datatypes/HeatAndHeatEnvNamesPair.java | 74 +- .../datatypes/HeatWithParametersDefinition.java | 149 +- .../sdc/ci/tests/datatypes/LifeCycleStateEnum.java | 40 +- .../sdc/ci/tests/datatypes/MenuOptionsEnum.java | 20 +- .../PortMirrioringConfigurationObject.java | 10 +- .../sdc/ci/tests/datatypes/PortMirroringEnum.java | 6 +- .../sdc/ci/tests/datatypes/PropertyInfo.java | 80 +- .../datatypes/ResourceCategoriesNameEnum.java | 36 +- .../tests/datatypes/ServiceCategoriesNameEnum.java | 20 +- .../sdc/ci/tests/datatypes/ServiceContainer.java | 4 +- .../sdc/ci/tests/datatypes/TopMenuButtonsEnum.java | 26 +- .../sdc/ci/tests/datatypes/TypesEnum.java | 20 +- .../sdc/ci/tests/datatypes/UserCredentials.java | 56 +- .../sdc/ci/tests/datatypes/UserManagementTab.java | 172 +- .../sdc/ci/tests/datatypes/VFCArtifact.java | 78 +- .../datatypes/VendorSoftwareProductObject.java | 108 +- .../execute/AmdocsComplexService/CreatePath.java | 20 +- .../AmdocsComplexService/ElementsChanges.java | 94 +- .../AmdocsComplexService/OnboardItemObject.java | 20 +- .../OnboardItemObjectReqDetails.java | 12 +- .../execute/AmdocsComplexService/PathName.java | 10 +- .../execute/AmdocsComplexService/PathUrls.java | 14 +- .../AmdocsComplexService/PathUtilities.java | 111 +- .../AmdocsComplexService/PathValidations.java | 89 +- .../tests/execute/sanity/AdminUserManagment.java | 464 ++--- .../sdc/ci/tests/execute/sanity/Annotation.java | 64 +- .../tests/execute/sanity/ArchiveRestoreTest.java | 31 +- .../tests/execute/sanity/CatalogLeftPanelTest.java | 371 ++-- .../sanity/CatalogLeftPanelTestWithTime.java | 409 ++-- .../sdc/ci/tests/execute/sanity/Categories.java | 321 ++- .../ci/tests/execute/sanity/CustomizationUUID.java | 608 +++--- .../tests/execute/sanity/DeploymentViewTests.java | 460 ++--- .../sdc/ci/tests/execute/sanity/ImportDCAE.java | 1206 ++++++------ .../ci/tests/execute/sanity/ImportVFCAsset.java | 612 +++--- .../ci/tests/execute/sanity/OnboardViaApis.java | 184 +- .../execute/sanity/OnboardingFlowsThroughAPI.java | 676 +++---- .../ci/tests/execute/sanity/OnboardingFlowsUI.java | 107 +- .../openecomp/sdc/ci/tests/execute/sanity/PNF.java | 686 +++---- .../sdc/ci/tests/execute/sanity/PortMirroring.java | 87 +- .../sdc/ci/tests/execute/sanity/Product.java | 59 +- .../tests/execute/sanity/PropertiesAssignment.java | 252 ++- .../sanity/PropertiesAssignmentUpdateFlow.java | 128 +- .../sanity/PropertiesAssignmentUpdateFlow_New.java | 185 +- .../sdc/ci/tests/execute/sanity/Service.java | 1339 ++++++------- .../tests/execute/sanity/ToscaValidationTest.java | 90 +- .../ci/tests/execute/sanity/UpgradeServices.java | 616 +++--- .../sdc/ci/tests/execute/sanity/VFCArtifacts.java | 642 +++--- .../openecomp/sdc/ci/tests/execute/sanity/Vf.java | 963 ++++----- .../sdc/ci/tests/execute/sanity/VfAPI.java | 1038 +++++----- .../sdc/ci/tests/execute/sanity/VfArtifacts.java | 656 +++--- .../sanity/VfDeploymentInformationalArtifacts.java | 1189 ++++++----- .../execute/setup/ArtifactsCorrelationManager.java | 82 +- .../sdc/ci/tests/execute/setup/AttFtpClient.java | 308 +-- .../sdc/ci/tests/execute/setup/DriverFactory.java | 178 +- .../sdc/ci/tests/execute/setup/ExtentManager.java | 244 ++- .../ci/tests/execute/setup/ExtentTestActions.java | 155 +- .../ci/tests/execute/setup/ExtentTestManager.java | 65 +- .../sdc/ci/tests/execute/setup/MobProxy.java | 184 +- .../ci/tests/execute/setup/OnboardCSVReport.java | 70 +- .../execute/setup/ReportAfterTestManager.java | 199 +- .../sdc/ci/tests/execute/setup/Retry.java | 6 +- .../sdc/ci/tests/execute/setup/SetupCDTest.java | 996 +++++----- .../sdc/ci/tests/execute/setup/TestFtp.java | 120 +- .../ci/tests/execute/setup/WebDriverThread.java | 230 +-- .../sdc/ci/tests/execute/setup/WindowTest.java | 109 +- .../ci/tests/execute/setup/WindowTestManager.java | 52 +- .../sdc/ci/tests/pages/AdminGeneralPage.java | 191 +- .../sdc/ci/tests/pages/ComponentLeftMenu.java | 4 +- .../sdc/ci/tests/pages/CompositionPage.java | 402 ++-- .../sdc/ci/tests/pages/DeploymentArtifactPage.java | 481 +++-- .../sdc/ci/tests/pages/DeploymentPage.java | 392 ++-- .../sdc/ci/tests/pages/GeneralPageElements.java | 42 +- .../sdc/ci/tests/pages/GovernorOperationPage.java | 28 +- .../sdc/ci/tests/pages/HeatParamNameBuilder.java | 9 +- .../org/openecomp/sdc/ci/tests/pages/HomePage.java | 147 +- .../org/openecomp/sdc/ci/tests/pages/IconPage.java | 38 +- .../ci/tests/pages/InformationalArtifactPage.java | 73 +- .../openecomp/sdc/ci/tests/pages/InputsPage.java | 230 ++- .../sdc/ci/tests/pages/OpsOperationPage.java | 243 +-- .../sdc/ci/tests/pages/ProductGeneralPage.java | 153 +- .../sdc/ci/tests/pages/ProductLeftMenu.java | 35 +- .../ci/tests/pages/PropertiesAssignmentPage.java | 522 +++-- .../sdc/ci/tests/pages/PropertiesPage.java | 96 +- .../sdc/ci/tests/pages/PropertyNameBuilder.java | 52 +- .../sdc/ci/tests/pages/PropertyPopup.java | 154 +- .../sdc/ci/tests/pages/ResourceGeneralPage.java | 308 +-- .../sdc/ci/tests/pages/ResourceLeftMenu.java | 74 +- .../sdc/ci/tests/pages/ServiceGeneralPage.java | 202 +- .../sdc/ci/tests/pages/ServiceLeftMenu.java | 12 +- .../sdc/ci/tests/pages/TesterOperationPage.java | 126 +- .../sdc/ci/tests/pages/ToscaArtifactsPage.java | 62 +- .../sdc/ci/tests/pages/UpgradeServicesPopup.java | 13 +- .../sdc/ci/tests/pages/UploadArtifactPopup.java | 155 +- .../sdc/ci/tests/pages/VspValidationPage.java | 21 +- .../ci/tests/pages/VspValidationResultsPage.java | 5 +- .../ci/tests/utilities/AdditionalConditions.java | 152 +- .../tests/utilities/AdminWorkspaceUIUtilies.java | 49 +- .../sdc/ci/tests/utilities/ArtifactUIUtils.java | 14 +- .../sdc/ci/tests/utilities/CatalogUIUtilitis.java | 173 +- .../sdc/ci/tests/utilities/DownloadManager.java | 60 +- .../sdc/ci/tests/utilities/FileHandling.java | 29 +- .../sdc/ci/tests/utilities/GeneralUIUtils.java | 228 ++- .../sdc/ci/tests/utilities/HomeUtils.java | 4 +- .../sdc/ci/tests/utilities/OnboardingUiUtils.java | 23 +- .../sdc/ci/tests/utilities/PortMirroringUtils.java | 73 +- .../sdc/ci/tests/utilities/ProductUIUtils.java | 96 +- .../sdc/ci/tests/utilities/PropertiesUIUtils.java | 120 +- .../sdc/ci/tests/utilities/ResourceUIUtils.java | 685 +++---- .../sdc/ci/tests/utilities/RestCDUtils.java | 31 +- .../sdc/ci/tests/utilities/ServiceUIUtils.java | 6 +- .../ci/tests/verificator/CatalogVerificator.java | 256 +-- .../verificator/CustomizationUUIDVerificator.java | 35 +- .../verificator/DeploymentViewVerificator.java | 566 +++--- .../verificator/ErrorMessageUIVerificator.java | 58 +- .../verificator/PortMirroringVerificator.java | 38 +- .../PropertiesAssignmentVerificator.java | 63 +- .../ci/tests/verificator/PropertyVerificator.java | 21 +- .../ci/tests/verificator/ServiceVerificator.java | 602 +++--- .../sdc/ci/tests/verificator/ToscaValidation.java | 1004 +++++----- .../verificator/UserManagementVerificator.java | 217 +- .../tests/verificator/VFCArtifactVerificator.java | 601 +++--- .../sdc/ci/tests/verificator/VFCverificator.java | 19 +- .../ci/tests/verificator/VfModuleVerificator.java | 220 ++- .../sdc/ci/tests/verificator/VfVerificator.java | 456 ++--- 149 files changed, 17765 insertions(+), 17509 deletions(-) (limited to 'ui-ci/src') diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/AddComponentInstancesArtifactsInCsar.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/AddComponentInstancesArtifactsInCsar.java index c8f281f5d4..fd23fbed3a 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/AddComponentInstancesArtifactsInCsar.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/AddComponentInstancesArtifactsInCsar.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,9 +21,18 @@ package org.openecomp.sdc.ci.tests.US; import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.http.HttpStatus; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.*; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; @@ -45,280 +54,287 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Random; public class AddComponentInstancesArtifactsInCsar extends SetupCDTest { - public static final String DEPLOYMENT = "Deployment"; - public static final String INFORMATIONAL = "Informational"; - private String filePath; - @BeforeClass - public void beforeClass(){ - filePath = System.getProperty("filePath"); - if (filePath == null && System.getProperty("os.name").contains("Windows")) { - filePath = FileHandling.getResourcesFilesPath() + "AddComponentInstancesArtifactsInCsar"+ File.separator; - } - else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){ - filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator + "AddComponentInstancesArtifactsInCsar"+ File.separator; - } - } - - // US847439 - Story [BE] - Add Component Instance's artifacts in CSAR - // TC1521795 - VF CSAR - The Flow - @Test - public void vfAndServiceCsarTheFlow() throws Exception{ - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - String vnfFile = "FDNT.zip"; - String snmpFile = "Fault-alarms-ASDC-vprobes-vLB.zip"; - - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceReqDetails, vnfFile, filePath, getUser(), amdocsLicenseMembers); - String vspName = createVSP.getName(); - resourceMetaData.setName(vspName); - VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, createVSP, getUser()); - VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true); - - HomePage.showVspRepository(); - OnboardingUiUtils.importVSP(createVSP); - resourceMetaData.setVersion("0.1"); - Resource vfResource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), resourceMetaData.getVersion()); - - Map artifacts = getArtifactsOfComponentAndComponentsInstance(vfResource); - - List> artifactsUploadedToComponentInstance = new LinkedList<>(); - Random random = new Random(); - for(int i=0; i uploadArtifactOnRandomVfc = uploadArtifactOnRandomRI(vfResource); - - if(uploadArtifactOnRandomVfc.getRight().getArtifactName() != null) { - artifactsUploadedToComponentInstance.add(uploadArtifactOnRandomVfc); - } - } - - if(!artifactsUploadedToComponentInstance.isEmpty()) { - Map artifactsOfResourceInstance = getArtifactsOfResourceInstance(artifactsUploadedToComponentInstance); - artifacts.put("Resources", artifactsOfResourceInstance); - } - - ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); - ToscaArtifactsPage.downloadCsar(); - File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); - Map combineHeatArtifacstWithFolderArtifacsToMap = ArtifactFromCsar.getVFCArtifacts(latestFilefromDir.getAbsolutePath()); - - compareArtifactFromFileStructureToArtifactsFromJavaObject(artifacts, combineHeatArtifacstWithFolderArtifacsToMap); - - } - - public void compareArtifactFromFileStructureToArtifactsFromJavaObject(Map artifactFromJavaObject, Map artifactsFromFileStructure) { - for(String key: artifactFromJavaObject.keySet()) { - if((!key.equals(DEPLOYMENT)) && (!key.equals(INFORMATIONAL))) { - Map newArtifactFromJavaObject = (Map) artifactFromJavaObject.get(key); - Map newArtifactsFromFileStructure = (Map) artifactsFromFileStructure.get(key); - compareArtifactFromFileStructureToArtifactsFromJavaObject(newArtifactFromJavaObject, newArtifactsFromFileStructure); - } else { - compareArtifacts(artifactFromJavaObject.get(key), artifactsFromFileStructure.get(key)); - } - } - } - - - private void compareArtifacts(Object artifactFromJavaObject, Object artifactsFromFileStructure) { - Map> artifactsMap = (Map>) artifactFromJavaObject; - List artifactsList = (List) artifactsFromFileStructure; - - for(HeatMetaFirstLevelDefinition heatMetaFirstLevelDefinition: artifactsList) { - Assert.assertTrue(artifactsMap.get(heatMetaFirstLevelDefinition.getType()).contains(heatMetaFirstLevelDefinition.getFileName()), - "Expected that artifacts will be the same. Not exists: " + heatMetaFirstLevelDefinition.getFileName() + " of type: " + heatMetaFirstLevelDefinition.getType()); - } - - for(String key: artifactsMap.keySet()) { - List artifacts = artifactsMap.get(key); - - for(HeatMetaFirstLevelDefinition heatMetaFirstLevelDefinition: artifactsList) { - if(heatMetaFirstLevelDefinition.getType().equals(key)) { - if(artifacts.contains(heatMetaFirstLevelDefinition.getFileName())) { - artifacts.remove(heatMetaFirstLevelDefinition.getFileName()); - } - } - } - - Assert.assertEquals(artifacts.size(), 0, "Expected that all artifacts equal. There is artifacts which not equal: " + artifacts.toString()); - } - } - - - public Map getArtifactsOfResourceInstance(List> riList) { - Map artifacts = new HashMap<>(); - - for(ImmutablePair ri: riList) { - ArtifactDefinition artifactDefinition = ri.getRight(); - ComponentInstance componentInstance = ri.getLeft(); - if(artifacts.containsKey(componentInstance.getNormalizedName())) { - if( ((Map>)((Map)artifacts.get(componentInstance.getNormalizedName())).get(DEPLOYMENT)).containsKey(artifactDefinition.getArtifactType()) ) { - - ((Map>)((Map) artifacts.get(componentInstance.getNormalizedName())).get(DEPLOYMENT)).get(artifactDefinition.getArtifactType()).add(artifactDefinition.getArtifactName()); - - } else { - ArrayList list = new ArrayList<>(); - list.add(artifactDefinition.getArtifactName()); - ((Map>)((Map) artifacts.get(componentInstance.getNormalizedName())).get(DEPLOYMENT)).put(artifactDefinition.getArtifactType(), list); - } - - } else { - try { - - - ArrayList list = new ArrayList<>(); - list.add(artifactDefinition.getArtifactName()); - - Map> map = new HashMap<>(); - map.put(artifactDefinition.getArtifactType(), list); - - Map>> addMap = new HashMap<>(); - addMap.put(DEPLOYMENT, map); - - artifacts.put(componentInstance.getNormalizedName(), addMap); - } catch (Exception e) { - Assert.fail("Artifact name is null for componentInstance: " + componentInstance.getNormalizedName()); - } - } - } - return artifacts; - } - - public Map getArtifactsOfComponentAndComponentsInstance(Component component) { - Map artifacts = getArtifactsOfComponent(component); - - for(ComponentInstance componentInstance: component.getComponentInstances()) { - Map artifactsOfComponentInstance = getArtifactsOfComponentInstance(componentInstance); - if(!artifactsOfComponentInstance.isEmpty()) { - artifacts.put(componentInstance.getToscaComponentName() + "." + componentInstance.getComponentVersion(), artifactsOfComponentInstance); - } - } - - return artifacts; - } - - public Map getArtifactsOfComponentInstance(ComponentInstance componentInstance) { - Map map = new HashMap<>(); - - if(componentInstance.getArtifacts() != null) { - Map informationalArtifacts = getArtifacts(componentInstance.getArtifacts()); - if(!informationalArtifacts.isEmpty()) { - map.put(INFORMATIONAL, informationalArtifacts); - } - } - - if(componentInstance.getDeploymentArtifacts() != null) { - Map deploymentArtifacts = getArtifacts(componentInstance.getDeploymentArtifacts()); - if(!deploymentArtifacts.isEmpty()) { - map.put(DEPLOYMENT, deploymentArtifacts); - } - } - - return map; - } - - public Map getArtifactsOfComponent(Component component) { - Map map = new HashMap<>(); - - if(component.getArtifacts() != null) { - Map informationalArtifacts = getArtifacts(component.getArtifacts()); - if(!informationalArtifacts.isEmpty()) { - map.put(INFORMATIONAL, informationalArtifacts); - } - } - - if(component.getDeploymentArtifacts() != null) { - Map deploymentArtifacts = getArtifacts(component.getDeploymentArtifacts()); - if(!deploymentArtifacts.isEmpty()) { - map.put(DEPLOYMENT, deploymentArtifacts); - } - } - - return map; - } - - public Map getArtifacts(Map artifacts) { - Map map = new HashMap<>(); - - for(String artifact: artifacts.keySet()) { - ArtifactDefinition artifactDefinition = artifacts.get(artifact); - if((artifactDefinition.getEsId() != null) && (!artifactDefinition.getEsId().equals("")) && (!artifactDefinition.getArtifactType().equals("HEAT_ENV"))) { - if(map.containsKey(artifactDefinition.getArtifactType())) { - ((List) map.get(artifactDefinition.getArtifactType())).add(artifactDefinition.getArtifactName()); - } else { - ArrayList list = new ArrayList<>(); - list.add(artifactDefinition.getArtifactName()); - map.put(artifactDefinition.getArtifactType(), list); - } - } - } - - return map; - } - - public ImmutablePair uploadArtifactOnRandomRI(Component component) throws Exception { - ArtifactReqDetails artifactReqDetails = getRandomArtifact(); - Random random = new Random(); - int randInt = random.nextInt(component.getComponentInstances().size()); - User defaultUser = ElementFactory.getDefaultUser(getRole()); - ComponentInstance componentInstance = component.getComponentInstances().get(randInt); - - RestResponse uploadArtifactRestResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, defaultUser, artifactReqDetails, componentInstance); - - // Check response of external API - Integer responseCode = uploadArtifactRestResponse.getErrorCode(); - Assert.assertEquals(responseCode, (Integer)200, "Response code is not correct."); - - ImmutablePair pair = ImmutablePair.of(componentInstance, ResponseParser.convertArtifactDefinitionResponseToJavaObject(uploadArtifactRestResponse.getResponse())); - - return pair; - } - - public ImmutablePair uploadArtifactOnRandomRI(Resource resource) throws Exception { - ArtifactReqDetails artifactReqDetails = getRandomVfcArtifact(); - Random random = new Random(); - int randInt = random.nextInt(resource.getComponentInstances().size()); - User defaultUser = ElementFactory.getDefaultUser(getRole()); - ComponentInstance componentInstance = resource.getComponentInstances().get(randInt); - - RestResponse uploadArtifactRestResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(resource, defaultUser, artifactReqDetails, componentInstance); - // Check response of external API - Integer responseCode = uploadArtifactRestResponse.getErrorCode(); - Assert.assertEquals(responseCode, (Integer)200, "Response code is not correct."); - ImmutablePair pair = ImmutablePair.of(componentInstance, ResponseParser.convertArtifactDefinitionResponseToJavaObject(uploadArtifactRestResponse.getResponse())); - return pair; - } - - public ArtifactReqDetails getRandomArtifact() throws Exception { - List artifactsTypeList = Arrays.asList("Other"); - return getRandomArtifact(artifactsTypeList); - } - - public ArtifactReqDetails getRandomVfcArtifact() throws Exception { - List vfcArtifactsTypeList = Arrays.asList( - ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), - ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), - ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), - ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), - ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), - ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), - ArtifactTypeEnum.SNMP_POLL.getType(), - ArtifactTypeEnum.SNMP_TRAP.getType()); - return getRandomArtifact(vfcArtifactsTypeList); - } - - public ArtifactReqDetails getRandomArtifact(List artifactType) throws Exception { - Random random = new Random(); - return ElementFactory.getArtifactByType("ci", artifactType.get(random.nextInt(artifactType.size())), true, false); - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + public static final String DEPLOYMENT = "Deployment"; + public static final String INFORMATIONAL = "Informational"; + private String filePath; + + @BeforeClass + public void beforeClass() { + filePath = System.getProperty("filePath"); + if (filePath == null && System.getProperty("os.name").contains("Windows")) { + filePath = FileHandling.getResourcesFilesPath() + "AddComponentInstancesArtifactsInCsar" + File.separator; + } else if (filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")) { + filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator + "AddComponentInstancesArtifactsInCsar" + File.separator; + } + } + + // US847439 - Story [BE] - Add Component Instance's artifacts in CSAR + // TC1521795 - VF CSAR - The Flow + @Test + public void vfAndServiceCsarTheFlow() throws Exception { + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + String vnfFile = "FDNT.zip"; + String snmpFile = "Fault-alarms-ASDC-vprobes-vLB.zip"; + + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceReqDetails, vnfFile, filePath, getUser(), amdocsLicenseMembers); + String vspName = createVSP.getName(); + resourceMetaData.setName(vspName); + VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, createVSP, getUser()); + VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true); + + HomePage.showVspRepository(); + OnboardingUiUtils.importVSP(createVSP); + resourceMetaData.setVersion("0.1"); + Resource vfResource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), resourceMetaData.getVersion()); + + Map artifacts = getArtifactsOfComponentAndComponentsInstance(vfResource); + + List> artifactsUploadedToComponentInstance = new LinkedList<>(); + Random random = new Random(); + final int randomIntForLoop = random.nextInt(10) + 10; + for (int i = 0; i < randomIntForLoop; i++) { + ImmutablePair uploadArtifactOnRandomVfc = uploadArtifactOnRandomRI(vfResource); + + if (uploadArtifactOnRandomVfc.getRight().getArtifactName() != null) { + artifactsUploadedToComponentInstance.add(uploadArtifactOnRandomVfc); + } + } + + if (!artifactsUploadedToComponentInstance.isEmpty()) { + Map artifactsOfResourceInstance = getArtifactsOfResourceInstance(artifactsUploadedToComponentInstance); + artifacts.put("Resources", artifactsOfResourceInstance); + } + + ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); + ToscaArtifactsPage.downloadCsar(); + File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); + Map combineHeatArtifacstWithFolderArtifacsToMap = ArtifactFromCsar.getVFCArtifacts(latestFilefromDir.getAbsolutePath()); + + compareArtifactFromFileStructureToArtifactsFromJavaObject(artifacts, combineHeatArtifacstWithFolderArtifacsToMap); + + } + + public void compareArtifactFromFileStructureToArtifactsFromJavaObject(Map artifactFromJavaObject, Map artifactsFromFileStructure) { + for (String key : artifactFromJavaObject.keySet()) { + if ((!key.equals(DEPLOYMENT)) && (!key.equals(INFORMATIONAL))) { + Map newArtifactFromJavaObject = (Map) artifactFromJavaObject.get(key); + Map newArtifactsFromFileStructure = (Map) artifactsFromFileStructure.get(key); + compareArtifactFromFileStructureToArtifactsFromJavaObject(newArtifactFromJavaObject, newArtifactsFromFileStructure); + } else { + compareArtifacts(artifactFromJavaObject.get(key), artifactsFromFileStructure.get(key)); + } + } + } + + + private void compareArtifacts(Object artifactFromJavaObject, Object artifactsFromFileStructure) { + Map> artifactsMap = (Map>) artifactFromJavaObject; + List artifactsList = (List) artifactsFromFileStructure; + + for (HeatMetaFirstLevelDefinition heatMetaFirstLevelDefinition : artifactsList) { + Assert.assertTrue(artifactsMap.get(heatMetaFirstLevelDefinition.getType()).contains(heatMetaFirstLevelDefinition.getFileName()), + "Expected that artifacts will be the same. Not exists: " + heatMetaFirstLevelDefinition.getFileName() + " of type: " + heatMetaFirstLevelDefinition.getType()); + } + + for (String key : artifactsMap.keySet()) { + List artifacts = artifactsMap.get(key); + + for (HeatMetaFirstLevelDefinition heatMetaFirstLevelDefinition : artifactsList) { + if (heatMetaFirstLevelDefinition.getType().equals(key)) { + if (artifacts.contains(heatMetaFirstLevelDefinition.getFileName())) { + artifacts.remove(heatMetaFirstLevelDefinition.getFileName()); + } + } + } + + Assert.assertEquals(artifacts.size(), 0, "Expected that all artifacts equal. There is artifacts which not equal: " + artifacts.toString()); + } + } + + + public Map getArtifactsOfResourceInstance(List> riList) { + Map artifacts = new HashMap<>(); + + for (ImmutablePair ri : riList) { + ArtifactDefinition artifactDefinition = ri.getRight(); + ComponentInstance componentInstance = ri.getLeft(); + if (artifacts.containsKey(componentInstance.getNormalizedName())) { + if (((Map>) ((Map) artifacts.get(componentInstance.getNormalizedName())).get(DEPLOYMENT)).containsKey(artifactDefinition.getArtifactType())) { + + ((Map>) ((Map) artifacts.get(componentInstance.getNormalizedName())).get(DEPLOYMENT)).get(artifactDefinition.getArtifactType()).add(artifactDefinition.getArtifactName()); + + } else { + ArrayList list = new ArrayList<>(); + list.add(artifactDefinition.getArtifactName()); + ((Map>) ((Map) artifacts.get(componentInstance.getNormalizedName())).get(DEPLOYMENT)).put(artifactDefinition.getArtifactType(), list); + } + + } else { + try { + + + ArrayList list = new ArrayList<>(); + list.add(artifactDefinition.getArtifactName()); + + Map> map = new HashMap<>(); + map.put(artifactDefinition.getArtifactType(), list); + + Map>> addMap = new HashMap<>(); + addMap.put(DEPLOYMENT, map); + + artifacts.put(componentInstance.getNormalizedName(), addMap); + } catch (Exception e) { + Assert.fail("Artifact name is null for componentInstance: " + componentInstance.getNormalizedName()); + } + } + } + return artifacts; + } + + public Map getArtifactsOfComponentAndComponentsInstance(Component component) { + Map artifacts = getArtifactsOfComponent(component); + + for (ComponentInstance componentInstance : component.getComponentInstances()) { + Map artifactsOfComponentInstance = getArtifactsOfComponentInstance(componentInstance); + if (!artifactsOfComponentInstance.isEmpty()) { + artifacts.put(componentInstance.getToscaComponentName() + "." + componentInstance.getComponentVersion(), artifactsOfComponentInstance); + } + } + + return artifacts; + } + + public Map getArtifactsOfComponentInstance(ComponentInstance componentInstance) { + Map map = new HashMap<>(); + + if (componentInstance.getArtifacts() != null) { + Map informationalArtifacts = getArtifacts(componentInstance.getArtifacts()); + if (!informationalArtifacts.isEmpty()) { + map.put(INFORMATIONAL, informationalArtifacts); + } + } + + if (componentInstance.getDeploymentArtifacts() != null) { + Map deploymentArtifacts = getArtifacts(componentInstance.getDeploymentArtifacts()); + if (!deploymentArtifacts.isEmpty()) { + map.put(DEPLOYMENT, deploymentArtifacts); + } + } + + return map; + } + + public Map getArtifactsOfComponent(Component component) { + Map map = new HashMap<>(); + + if (component.getArtifacts() != null) { + Map informationalArtifacts = getArtifacts(component.getArtifacts()); + if (!informationalArtifacts.isEmpty()) { + map.put(INFORMATIONAL, informationalArtifacts); + } + } + + if (component.getDeploymentArtifacts() != null) { + Map deploymentArtifacts = getArtifacts(component.getDeploymentArtifacts()); + if (!deploymentArtifacts.isEmpty()) { + map.put(DEPLOYMENT, deploymentArtifacts); + } + } + + return map; + } + + public Map getArtifacts(Map artifacts) { + Map map = new HashMap<>(); + + for (String artifact : artifacts.keySet()) { + ArtifactDefinition artifactDefinition = artifacts.get(artifact); + if ((artifactDefinition.getEsId() != null) && (!artifactDefinition.getEsId().equals("")) && (!artifactDefinition.getArtifactType().equals("HEAT_ENV"))) { + if (map.containsKey(artifactDefinition.getArtifactType())) { + ((List) map.get(artifactDefinition.getArtifactType())).add(artifactDefinition.getArtifactName()); + } else { + ArrayList list = new ArrayList<>(); + list.add(artifactDefinition.getArtifactName()); + map.put(artifactDefinition.getArtifactType(), list); + } + } + } + + return map; + } + + public ImmutablePair uploadArtifactOnRandomRI(Component component) throws Exception { + ArtifactReqDetails artifactReqDetails = getRandomArtifact(); + Random random = new Random(); + int randInt = random.nextInt(component.getComponentInstances().size()); + User defaultUser = ElementFactory.getDefaultUser(getRole()); + ComponentInstance componentInstance = component.getComponentInstances().get(randInt); + + RestResponse uploadArtifactRestResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(component, defaultUser, artifactReqDetails, componentInstance); + + // Check response of external API + Integer responseCode = uploadArtifactRestResponse.getErrorCode(); + Assert.assertEquals(responseCode, (Integer) HttpStatus.SC_OK, "Response code is not correct."); + + ImmutablePair pair = ImmutablePair.of(componentInstance, ResponseParser.convertArtifactDefinitionResponseToJavaObject(uploadArtifactRestResponse.getResponse())); + + return pair; + } + + public ImmutablePair uploadArtifactOnRandomRI(Resource resource) throws Exception { + ArtifactReqDetails artifactReqDetails = getRandomVfcArtifact(); + Random random = new Random(); + int randInt = random.nextInt(resource.getComponentInstances().size()); + User defaultUser = ElementFactory.getDefaultUser(getRole()); + ComponentInstance componentInstance = resource.getComponentInstances().get(randInt); + + RestResponse uploadArtifactRestResponse = ArtifactRestUtils.externalAPIUploadArtifactOfComponentInstanceOnAsset(resource, defaultUser, artifactReqDetails, componentInstance); + // Check response of external API + Integer responseCode = uploadArtifactRestResponse.getErrorCode(); + Assert.assertEquals(responseCode, (Integer) HttpStatus.SC_OK, "Response code is not correct."); + ImmutablePair pair = ImmutablePair.of(componentInstance, ResponseParser.convertArtifactDefinitionResponseToJavaObject(uploadArtifactRestResponse.getResponse())); + return pair; + } + + public ArtifactReqDetails getRandomArtifact() throws Exception { + List artifactsTypeList = Arrays.asList("Other"); + return getRandomArtifact(artifactsTypeList); + } + + public ArtifactReqDetails getRandomVfcArtifact() throws Exception { + List vfcArtifactsTypeList = Arrays.asList( + ArtifactTypeEnum.DCAE_INVENTORY_TOSCA.getType(), + ArtifactTypeEnum.DCAE_INVENTORY_JSON.getType(), + ArtifactTypeEnum.DCAE_INVENTORY_POLICY.getType(), + ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType(), + ArtifactTypeEnum.DCAE_INVENTORY_BLUEPRINT.getType(), + ArtifactTypeEnum.DCAE_INVENTORY_EVENT.getType(), + ArtifactTypeEnum.SNMP_POLL.getType(), + ArtifactTypeEnum.SNMP_TRAP.getType()); + return getRandomArtifact(vfcArtifactsTypeList); + } + + public ArtifactReqDetails getRandomArtifact(List artifactType) throws Exception { + Random random = new Random(); + return ElementFactory.getArtifactByType("ci", artifactType.get(random.nextInt(artifactType.size())), true, false); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/ImportUpdateInformationalDeploymentArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/ImportUpdateInformationalDeploymentArtifacts.java index a711d4ce4e..42dd59b05b 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/ImportUpdateInformationalDeploymentArtifacts.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/ImportUpdateInformationalDeploymentArtifacts.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,188 +36,192 @@ import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.testng.annotations.Test; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; import static org.testng.AssertJUnit.assertTrue; public class ImportUpdateInformationalDeploymentArtifacts extends SetupCDTest { - - private String folder ="US747946"; - - // US747946 - Import artifacts to component instances - // TC1407822 - Import VFC Artifacts - Deployment Artifacts - Multiple Artifacts, Multiple Types - @Test - public void importVfvArtifactsDeploymentArtifactsMultipleArtifactsMultipleTypes() throws Exception { - - String filePath = FileHandling.getFilePath(folder); - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - String fileName = "TC1407822.csar"; - - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); - - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); - - List snmpPollArtifactList = Stream - .of("base_cgi_frwl.mib", "base_vIECCF_volume.yml", "node_userdata_script.sh", "vendor-license-model.xml") - .collect(Collectors.toList()); - List snmpTrapArtifactList = Stream - .of("module_1_ixlt.mib", "module_1_ixlt.yaml") - .collect(Collectors.toList()); - - - List filteredArtifactNames = - //Stream of component Instances - resource.getComponentInstances().stream() - //filter out all nulls - .filter( e -> e.getDeploymentArtifacts() != null ) - //Stream of all the artifacts on all the component instances - .flatMap( e -> e.getDeploymentArtifacts().values().stream()) - //filter relevant artifact types - .filter( e -> e.getArtifactType().equals(ArtifactTypeEnum.SNMP_TRAP.getType()) || e.getArtifactType().equals(ArtifactTypeEnum.SNMP_POLL.getType())) - //collect to list - .collect(Collectors.toList()); - - assertTrue("Not contain all SNMP TRAP artifacts.", filteredArtifactNames.stream() - .filter(e -> e.getArtifactType().equals(ArtifactTypeEnum.SNMP_TRAP.getType())) - .map(e -> e.getArtifactName()) - .collect(Collectors.toList()) - .containsAll(snmpTrapArtifactList)); - - assertTrue("Not contain all SNMP POLL artifacts.", filteredArtifactNames.stream() - .filter(e -> e.getArtifactType().equals(ArtifactTypeEnum.SNMP_POLL.getType())) - .map(e -> e.getArtifactName()) - .collect(Collectors.toList()) - .containsAll(snmpPollArtifactList)); - - filteredArtifactNames.stream() - .map(e->e.getArtifactDisplayName()) - .collect(Collectors.toList()) - .forEach(e -> { - assertTrue("Wrong artifact appear on deployment artifact UI page.", - !GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + e)); - }); - - } - - // TODO: Note there is performance issue with this CSAR - // US747946 - Import artifacts to component instances - // TC1407998 - Import VFC Artifacts - Deployment & Informational Artifacts - Multiple VFCs - @Test - public void importVfcArtifactsDeploymentAndInformationalArtifactsMultipleVfcs() throws Exception { - - String filePath = FileHandling.getFilePath(folder); - String fileName = "TC1407998.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); - - resource.getComponentInstances().forEach(e -> { - - if(e.getToscaComponentName().endsWith("heat.cm")) { - Map> deployArtifactsMap = new HashMap>() { - { - put(ArtifactTypeEnum.SNMP_POLL.getType(), Arrays.asList("PS_DEPL_Poll1.mib", "PS_DEPL_Poll2.xml", "PS_DEPL_Poll3.yaml")); - put(ArtifactTypeEnum.SNMP_TRAP.getType(), Arrays.asList("PS_DEPL_Trap1.mib", "PS_DEPL_Trap2.xml", "PS_DEPL_Trap3.sh", "PS_DEPL_Trap4.yml")); - } - }; - validateDeploymentArtifactOnComponetInstance(e, deployArtifactsMap, "heat.cm"); - - } else if (e.getToscaComponentName().endsWith("heat.sm")) { - Map> deployArtifactsMap = new HashMap>() { - { - put(ArtifactTypeEnum.SNMP_POLL.getType(), Arrays.asList("SM_DEPL_Poll1.mib", "SM_DEPL_Poll2.mib", "SM_DEPL_Poll3.xml")); - put(ArtifactTypeEnum.SNMP_TRAP.getType(), Arrays.asList("SM_DEPL_Trap1.mib", "SM_DEPL_Trap2.xml")); - } - }; - validateDeploymentArtifactOnComponetInstance(e, deployArtifactsMap, "heat.sm"); - } - }); - - } - - // US747946 - Import artifacts to component instances - // TC1410352 - Import VFC Artifacts - Deployment Artifacts - Extra folder Under VFC-Identification - @Test - public void importVfcArtifactsDeploymentArtifactsExtraFolderUnderVfcIdentification() throws Exception { - - String filePath = FileHandling.getFilePath(folder); - String fileName = "TC1410352.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); - - resource.getComponentInstances().forEach(e -> { - - if(e.getToscaComponentName().endsWith("heat.ltm")) { - Map> deployArtifactsMap = new HashMap>() { - { - put(ArtifactTypeEnum.SNMP_POLL.getType(), Arrays.asList("Poll1.mib", "Poll2.xml", "Poll3.sh", "Poll4.yml")); - put(ArtifactTypeEnum.SNMP_TRAP.getType(), Arrays.asList("Trap1.mib", "Trap2.yaml")); - } - }; - validateDeploymentArtifactOnComponetInstance(e, deployArtifactsMap, "heat.ltm"); - } - }); - } - - - // US747946 - Import artifacts to component instances - // TC1410352 - Import VFC Artifacts - Deployment Artifacts - Invalid Artifact Type - @Test - public void importVfcArtifactsDeploymentArtifactsInvalidArtifactType() throws Exception { - - String filePath = FileHandling.getFilePath(folder); - String fileName = "TC1425032.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); - - resource.getComponentInstances().forEach(e -> { - - if(e.getToscaComponentName().endsWith("heat.ltm")) { - Map> deployArtifactsMap = new HashMap>() { - { - put(ArtifactTypeEnum.SNMP_POLL.getType(), Arrays.asList("DeploySNMPPoll1.mib", "DeploySNMPPoll2.yml", "DeploySNMPPoll3.sh", "DeploySNMPPoll4.xml")); - put(ArtifactTypeEnum.OTHER.getType(), Arrays.asList("DeploySNMPTrapB1.mib", "DeploySNMPTrapB2.yaml")); - } - }; - validateDeploymentArtifactOnComponetInstance(e, deployArtifactsMap, "heat.ltm"); - } - }); - } - - private void validateDeploymentArtifactOnComponetInstance(ComponentInstance instance, Map> artifactsMap, String endswith){ - if(instance.getToscaComponentName().endsWith(endswith) ){ - Set types = artifactsMap.keySet(); - - Map> collect = instance.getDeploymentArtifacts().values().stream() - .filter( a -> types.contains(a.getArtifactType())) - .collect(Collectors.groupingBy( e -> e.getArtifactType())); - - types.forEach(m -> { - if(collect.containsKey(m)){ - List found = collect.get(m).stream().map(e -> e.getArtifactName()).collect(Collectors.toList()); - boolean isValid = found.containsAll(artifactsMap.get(m)) && artifactsMap.get(m).containsAll(found); - assertTrue("Not contain all artifact of type: " + m, isValid); - } else{ - assertTrue("Contains deployment artifact which not in provided list", false); - } - }); - } - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + + private String folder = "US747946"; + + // US747946 - Import artifacts to component instances + // TC1407822 - Import VFC Artifacts - Deployment Artifacts - Multiple Artifacts, Multiple Types + @Test + public void importVfvArtifactsDeploymentArtifactsMultipleArtifactsMultipleTypes() throws Exception { + + String filePath = FileHandling.getFilePath(folder); + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + String fileName = "TC1407822.csar"; + + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); + + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); + + List snmpPollArtifactList = Stream + .of("base_cgi_frwl.mib", "base_vIECCF_volume.yml", "node_userdata_script.sh", "vendor-license-model.xml") + .collect(Collectors.toList()); + List snmpTrapArtifactList = Stream + .of("module_1_ixlt.mib", "module_1_ixlt.yaml") + .collect(Collectors.toList()); + + + List filteredArtifactNames = + //Stream of component Instances + resource.getComponentInstances().stream() + //filter out all nulls + .filter(e -> e.getDeploymentArtifacts() != null) + //Stream of all the artifacts on all the component instances + .flatMap(e -> e.getDeploymentArtifacts().values().stream()) + //filter relevant artifact types + .filter(e -> e.getArtifactType().equals(ArtifactTypeEnum.SNMP_TRAP.getType()) || e.getArtifactType().equals(ArtifactTypeEnum.SNMP_POLL.getType())) + //collect to list + .collect(Collectors.toList()); + + assertTrue("Not contain all SNMP TRAP artifacts.", filteredArtifactNames.stream() + .filter(e -> e.getArtifactType().equals(ArtifactTypeEnum.SNMP_TRAP.getType())) + .map(e -> e.getArtifactName()) + .collect(Collectors.toList()) + .containsAll(snmpTrapArtifactList)); + + assertTrue("Not contain all SNMP POLL artifacts.", filteredArtifactNames.stream() + .filter(e -> e.getArtifactType().equals(ArtifactTypeEnum.SNMP_POLL.getType())) + .map(e -> e.getArtifactName()) + .collect(Collectors.toList()) + .containsAll(snmpPollArtifactList)); + + filteredArtifactNames.stream() + .map(e -> e.getArtifactDisplayName()) + .collect(Collectors.toList()) + .forEach(e -> { + assertTrue("Wrong artifact appear on deployment artifact UI page.", + !GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + e)); + }); + + } + + // TODO: Note there is performance issue with this CSAR + // US747946 - Import artifacts to component instances + // TC1407998 - Import VFC Artifacts - Deployment & Informational Artifacts - Multiple VFCs + @Test + public void importVfcArtifactsDeploymentAndInformationalArtifactsMultipleVfcs() throws Exception { + + String filePath = FileHandling.getFilePath(folder); + String fileName = "TC1407998.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); + + resource.getComponentInstances().forEach(e -> { + + if (e.getToscaComponentName().endsWith("heat.cm")) { + Map> deployArtifactsMap = new HashMap>() { + { + put(ArtifactTypeEnum.SNMP_POLL.getType(), Arrays.asList("PS_DEPL_Poll1.mib", "PS_DEPL_Poll2.xml", "PS_DEPL_Poll3.yaml")); + put(ArtifactTypeEnum.SNMP_TRAP.getType(), Arrays.asList("PS_DEPL_Trap1.mib", "PS_DEPL_Trap2.xml", "PS_DEPL_Trap3.sh", "PS_DEPL_Trap4.yml")); + } + }; + validateDeploymentArtifactOnComponetInstance(e, deployArtifactsMap, "heat.cm"); + + } else if (e.getToscaComponentName().endsWith("heat.sm")) { + Map> deployArtifactsMap = new HashMap>() { + { + put(ArtifactTypeEnum.SNMP_POLL.getType(), Arrays.asList("SM_DEPL_Poll1.mib", "SM_DEPL_Poll2.mib", "SM_DEPL_Poll3.xml")); + put(ArtifactTypeEnum.SNMP_TRAP.getType(), Arrays.asList("SM_DEPL_Trap1.mib", "SM_DEPL_Trap2.xml")); + } + }; + validateDeploymentArtifactOnComponetInstance(e, deployArtifactsMap, "heat.sm"); + } + }); + + } + + // US747946 - Import artifacts to component instances + // TC1410352 - Import VFC Artifacts - Deployment Artifacts - Extra folder Under VFC-Identification + @Test + public void importVfcArtifactsDeploymentArtifactsExtraFolderUnderVfcIdentification() throws Exception { + + String filePath = FileHandling.getFilePath(folder); + String fileName = "TC1410352.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); + + resource.getComponentInstances().forEach(e -> { + + if (e.getToscaComponentName().endsWith("heat.ltm")) { + Map> deployArtifactsMap = new HashMap>() { + { + put(ArtifactTypeEnum.SNMP_POLL.getType(), Arrays.asList("Poll1.mib", "Poll2.xml", "Poll3.sh", "Poll4.yml")); + put(ArtifactTypeEnum.SNMP_TRAP.getType(), Arrays.asList("Trap1.mib", "Trap2.yaml")); + } + }; + validateDeploymentArtifactOnComponetInstance(e, deployArtifactsMap, "heat.ltm"); + } + }); + } + + + // US747946 - Import artifacts to component instances + // TC1410352 - Import VFC Artifacts - Deployment Artifacts - Invalid Artifact Type + @Test + public void importVfcArtifactsDeploymentArtifactsInvalidArtifactType() throws Exception { + + String filePath = FileHandling.getFilePath(folder); + String fileName = "TC1425032.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); + + resource.getComponentInstances().forEach(e -> { + + if (e.getToscaComponentName().endsWith("heat.ltm")) { + Map> deployArtifactsMap = new HashMap>() { + { + put(ArtifactTypeEnum.SNMP_POLL.getType(), Arrays.asList("DeploySNMPPoll1.mib", "DeploySNMPPoll2.yml", "DeploySNMPPoll3.sh", "DeploySNMPPoll4.xml")); + put(ArtifactTypeEnum.OTHER.getType(), Arrays.asList("DeploySNMPTrapB1.mib", "DeploySNMPTrapB2.yaml")); + } + }; + validateDeploymentArtifactOnComponetInstance(e, deployArtifactsMap, "heat.ltm"); + } + }); + } + + private void validateDeploymentArtifactOnComponetInstance(ComponentInstance instance, Map> artifactsMap, String endswith) { + if (instance.getToscaComponentName().endsWith(endswith)) { + Set types = artifactsMap.keySet(); + + Map> collect = instance.getDeploymentArtifacts().values().stream() + .filter(a -> types.contains(a.getArtifactType())) + .collect(Collectors.groupingBy(e -> e.getArtifactType())); + + types.forEach(m -> { + if (collect.containsKey(m)) { + List found = collect.get(m).stream().map(e -> e.getArtifactName()).collect(Collectors.toList()); + boolean isValid = found.containsAll(artifactsMap.get(m)) && artifactsMap.get(m).containsAll(found); + assertTrue("Not contain all artifact of type: " + m, isValid); + } else { + assertTrue("Contains deployment artifact which not in provided list", false); + } + }); + } + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Inputs.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Inputs.java index 5ce439091f..2f0cc302f4 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Inputs.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Inputs.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,180 +47,168 @@ import java.util.List; import java.util.Map; public class Inputs extends SetupCDTest { - - private static final String DESCRIPTION = "kuku"; - private static final String ARTIFACT_LABEL = "artifact3"; - private static final String ARTIFACT_LABEL_UPDATE = "artifactUpdate"; - private static final String GET_ARTIFACT_LIST_BY_CLASS_NAME = "i-sdc-designer-sidebar-section-content-item-artifact"; - private static final String HEAT_FILE_YAML_NAME = "Heat-File.yaml"; - private static final String HEAT_FILE_YAML_UPDATE_NAME = "Heat-File-Update.yaml"; - private String filePath; - - @BeforeMethod - public void beforeTest(){ - filePath = FileHandling.getFilePath(""); - } - - // TODO: There is defect that imported VFC checkin not appear in service until refresh - // TODO: add support for CP (there is no normative CP's with complex properties which can be selected - import one) - importVFCWithComplexProperty.yml - // TC1508249 - // Delete Input declared from VLi/CPi in service level - Deleting an Input that was declared from Complex property. - @Test - public void deletingAnInputThatWasDeclaredFromComplexProperty() throws Exception{ - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - Map> resourceInstanceToProperty = new HashMap<>(); - CompositionPage.searchForElement("ExtVL"); - CanvasElement computeElement = canvasManager.createElementOnCanvas("ExtVL"); - canvasManager.clickOnCanvaElement(computeElement); - resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), Arrays.asList("network_homing", "instance_node_target")); - -// CompositionPage.searchForElement("ExtCP"); -// computeElement = canvasManager.createElementOnCanvas("ExtCP"); -// canvasManager.clickOnCanvaElement(computeElement); -// resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), "order"); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - DeploymentArtifactPage.getLeftMenu().moveToInputsScreen(); - - - for(String element: resourceInstanceToProperty.keySet()) { - String propertyName = resourceInstanceToProperty.get(element).get(0); - String innerPropertyName = resourceInstanceToProperty.get(element).get(1); - String dataTestIdPropertyCheckbox = DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + propertyName; - - GeneralUIUtils.clickOnElementByText(element); - GeneralUIUtils.ultimateWait(); - - InputsPage.clickOnProperty(propertyName); - - PropertyPopup propertyPopup = new PropertyPopup(); - propertyPopup.selectPropertyRadioButton(innerPropertyName); - propertyPopup.clickSave(); - - InputsPage.clickOnAddInputButton(); - - // Verify that input checkbox selected - verifyPropertyCheckBoxSelected(dataTestIdPropertyCheckbox); - - InputsPage.deleteServiceInput(element, propertyName + "_" + innerPropertyName); - - // Trying to find deleted service input - try{ - InputsPage.getServiceInput(element, propertyName + "_" + innerPropertyName); - assert(false); - } catch(TestException e){ - System.out.println("Verfied that service input deleted"); - } - - // Verify that input checkbox not selected - verifyPropertyCheckBoxNotSelected(dataTestIdPropertyCheckbox); - - GeneralUIUtils.clickOnElementByText(element); - GeneralUIUtils.ultimateWait(); - } - - } - - - // TC1508248 - // Delete inputs who come from CP/VL properties - @Test - public void deleteInputsWhoComeFromCpVlProperties() throws Exception{ - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - Map resourceInstanceToProperty = new HashMap<>(); - CompositionPage.searchForElement("ExtVL"); - CanvasElement computeElement = canvasManager.createElementOnCanvas("ExtVL"); - canvasManager.clickOnCanvaElement(computeElement); - resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), "network_role"); - - CompositionPage.searchForElement("ExtCP"); - computeElement = canvasManager.createElementOnCanvas("ExtCP"); - canvasManager.clickOnCanvaElement(computeElement); - resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), "order"); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - DeploymentArtifactPage.getLeftMenu().moveToInputsScreen(); - - - for(String element: resourceInstanceToProperty.keySet()) { - GeneralUIUtils.clickOnElementByText(element); - GeneralUIUtils.ultimateWait(); - - WebElement webElementByTestID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + resourceInstanceToProperty.get(element)); - InputsPage.clickOnVFInputCheckbox(webElementByTestID); - - InputsPage.clickOnAddInputButton(); - - // Verify that input checkbox selected - verifyPropertyCheckBoxSelected(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + resourceInstanceToProperty.get(element)); - - InputsPage.deleteServiceInput(element, resourceInstanceToProperty.get(element)); - - // Trying to find deleted service input - try{ - InputsPage.getServiceInput(element, resourceInstanceToProperty.get(element)); - assert(false); - } catch(TestException e){ - System.out.println("Verfied that service input deleted"); - } - - // Verify that input checkbox not selected - verifyPropertyCheckBoxNotSelected(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + resourceInstanceToProperty.get(element)); - - GeneralUIUtils.clickOnElementByText(element); - GeneralUIUtils.ultimateWait(); - } - - } - - - - - - - - public String verifyPropertyCheckBox(String dataTestId) { - WebElement webElementByTestID = GeneralUIUtils.getWebElementByTestID(dataTestId); - webElementByTestID = webElementByTestID.findElement(By.className("tlv-checkbox-i")); - if(webElementByTestID.getAttribute("checked") == null) { - return "false"; - } - return "true"; - } - - public void verifyPropertyCheckBoxSelected(String dataTestId) { - if(!verifyPropertyCheckBox(dataTestId).equals("true")) { - Assert.assertEquals(true, false, "Expected that checkbox will be selected."); - } - } - - public void verifyPropertyCheckBoxNotSelected(String dataTestId) { - if(!verifyPropertyCheckBox(dataTestId).equals("false")) { - Assert.assertEquals(false, true, "Expected that checkbox will not be selected."); - } - } - - public String getNormalizedName(String notNormalizedName) { - String normalizedName = notNormalizedName.toLowerCase(); - normalizedName = normalizedName.replaceAll(" ", ""); - - return normalizedName; - } - - - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + + private static final String DESCRIPTION = "kuku"; + private static final String ARTIFACT_LABEL = "artifact3"; + private static final String ARTIFACT_LABEL_UPDATE = "artifactUpdate"; + private static final String GET_ARTIFACT_LIST_BY_CLASS_NAME = "i-sdc-designer-sidebar-section-content-item-artifact"; + private static final String HEAT_FILE_YAML_NAME = "Heat-File.yaml"; + private static final String HEAT_FILE_YAML_UPDATE_NAME = "Heat-File-Update.yaml"; + private String filePath; + + @BeforeMethod + public void beforeTest() { + filePath = FileHandling.getFilePath(""); + } + + // TODO: There is defect that imported VFC checkin not appear in service until refresh + // TODO: add support for CP (there is no normative CP's with complex properties which can be selected - import one) - importVFCWithComplexProperty.yml + // TC1508249 + // Delete Input declared from VLi/CPi in service level - Deleting an Input that was declared from Complex property. + @Test + public void deletingAnInputThatWasDeclaredFromComplexProperty() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + Map> resourceInstanceToProperty = new HashMap<>(); + CompositionPage.searchForElement("ExtVL"); + CanvasElement computeElement = canvasManager.createElementOnCanvas("ExtVL"); + canvasManager.clickOnCanvaElement(computeElement); + resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), Arrays.asList("network_homing", "instance_node_target")); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + DeploymentArtifactPage.getLeftMenu().moveToInputsScreen(); + + + for (String element : resourceInstanceToProperty.keySet()) { + String propertyName = resourceInstanceToProperty.get(element).get(0); + String innerPropertyName = resourceInstanceToProperty.get(element).get(1); + String dataTestIdPropertyCheckbox = DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + propertyName; + + GeneralUIUtils.clickOnElementByText(element); + GeneralUIUtils.ultimateWait(); + + InputsPage.clickOnProperty(propertyName); + + PropertyPopup propertyPopup = new PropertyPopup(); + propertyPopup.selectPropertyRadioButton(innerPropertyName); + propertyPopup.clickSave(); + + InputsPage.clickOnAddInputButton(); + + // Verify that input checkbox selected + verifyPropertyCheckBoxSelected(dataTestIdPropertyCheckbox); + + InputsPage.deleteServiceInput(element, propertyName + "_" + innerPropertyName); + + // Trying to find deleted service input + try { + InputsPage.getServiceInput(element, propertyName + "_" + innerPropertyName); + assert false; + } catch (TestException e) { + System.out.println("Verfied that service input deleted"); + } + + // Verify that input checkbox not selected + verifyPropertyCheckBoxNotSelected(dataTestIdPropertyCheckbox); + + GeneralUIUtils.clickOnElementByText(element); + GeneralUIUtils.ultimateWait(); + } + + } + + + // TC1508248 + // Delete inputs who come from CP/VL properties + @Test + public void deleteInputsWhoComeFromCpVlProperties() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + Map resourceInstanceToProperty = new HashMap<>(); + CompositionPage.searchForElement("ExtVL"); + CanvasElement computeElement = canvasManager.createElementOnCanvas("ExtVL"); + canvasManager.clickOnCanvaElement(computeElement); + resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), "network_role"); + + CompositionPage.searchForElement("ExtCP"); + computeElement = canvasManager.createElementOnCanvas("ExtCP"); + canvasManager.clickOnCanvaElement(computeElement); + resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), "order"); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + DeploymentArtifactPage.getLeftMenu().moveToInputsScreen(); + + + for (String element : resourceInstanceToProperty.keySet()) { + GeneralUIUtils.clickOnElementByText(element); + GeneralUIUtils.ultimateWait(); + + WebElement webElementByTestID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + resourceInstanceToProperty.get(element)); + InputsPage.clickOnVFInputCheckbox(webElementByTestID); + + InputsPage.clickOnAddInputButton(); + + // Verify that input checkbox selected + verifyPropertyCheckBoxSelected(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + resourceInstanceToProperty.get(element)); + + InputsPage.deleteServiceInput(element, resourceInstanceToProperty.get(element)); + + // Trying to find deleted service input + try { + InputsPage.getServiceInput(element, resourceInstanceToProperty.get(element)); + assert false; + } catch (TestException e) { + System.out.println("Verfied that service input deleted"); + } + + // Verify that input checkbox not selected + verifyPropertyCheckBoxNotSelected(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + resourceInstanceToProperty.get(element)); + + GeneralUIUtils.clickOnElementByText(element); + GeneralUIUtils.ultimateWait(); + } + + } + + + public String verifyPropertyCheckBox(String dataTestId) { + WebElement webElementByTestID = GeneralUIUtils.getWebElementByTestID(dataTestId); + webElementByTestID = webElementByTestID.findElement(By.className("tlv-checkbox-i")); + if (webElementByTestID.getAttribute("checked") == null) { + return "false"; + } + return "true"; + } + + public void verifyPropertyCheckBoxSelected(String dataTestId) { + if (!verifyPropertyCheckBox(dataTestId).equals("true")) { + Assert.assertEquals(true, false, "Expected that checkbox will be selected."); + } + } + + public void verifyPropertyCheckBoxNotSelected(String dataTestId) { + if (!verifyPropertyCheckBox(dataTestId).equals("false")) { + Assert.assertEquals(false, true, "Expected that checkbox will not be selected."); + } + } + + public String getNormalizedName(String notNormalizedName) { + String normalizedName = notNormalizedName.toLowerCase(); + normalizedName = normalizedName.replaceAll(" ", ""); + + return normalizedName; + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/LocalGeneralUtilities.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/LocalGeneralUtilities.java index ab1917bf78..38a347e712 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/LocalGeneralUtilities.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/LocalGeneralUtilities.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,59 +42,60 @@ import java.util.List; public class LocalGeneralUtilities { - public LocalGeneralUtilities() { - } - public static final String FILE_PATH = FileHandling.getBasePath() + "\\src\\main\\resources\\Files\\VNFs\\"; - public static final String Env_FILE_PATH = FileHandling.getBasePath() + "\\src\\main\\resources\\Files\\Env_files\\"; - public static String downloadPath = "C:\\Users\\th0695\\Downloads"; + public LocalGeneralUtilities() { + } -public static String getValueFromJsonResponse(String response, String fieldName) { - try { - JSONObject jsonResp = (JSONObject) JSONValue.parse(response); - Object fieldValue = jsonResp.get(fieldName); - return fieldValue.toString(); + public static final String FILE_PATH = FileHandling.getBasePath() + "\\src\\main\\resources\\Files\\VNFs\\"; + public static final String Env_FILE_PATH = FileHandling.getBasePath() + "\\src\\main\\resources\\Files\\Env_files\\"; + public static String downloadPath = "C:\\Users\\th0695\\Downloads"; - } catch (Exception e) { - return null; - } + public static String getValueFromJsonResponse(String response, String fieldName) { + try { + JSONObject jsonResp = (JSONObject) JSONValue.parse(response); + Object fieldValue = jsonResp.get(fieldName); + return fieldValue.toString(); -} + } catch (Exception e) { + return null; + } -public static List getValuesFromJsonArray(RestResponse message) throws Exception { - List artifactTypesArrayFromApi = new ArrayList(); + } - org.json.JSONObject responseObject = new org.json.JSONObject(message.getResponse()); - JSONArray jArr = responseObject.getJSONArray("componentInstances"); + public static List getValuesFromJsonArray(RestResponse message) throws Exception { + List artifactTypesArrayFromApi = new ArrayList(); - for (int i = 0; i < jArr.length(); i++) { - org.json.JSONObject jObj = jArr.getJSONObject(i); - String value = jObj.get("uniqueId").toString(); + org.json.JSONObject responseObject = new org.json.JSONObject(message.getResponse()); + JSONArray jArr = responseObject.getJSONArray("componentInstances"); - artifactTypesArrayFromApi.add(value); - } - return artifactTypesArrayFromApi; -} + for (int i = 0; i < jArr.length(); i++) { + org.json.JSONObject jObj = jArr.getJSONObject(i); + String value = jObj.get("uniqueId").toString(); -public static String simpleOnBoarding(ResourceReqDetails resourceReqDetails, String fileName, String filePath,User user) throws Exception { - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(user); - VendorSoftwareProductObject createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, fileName, filePath, user, amdocsLicenseMembers); - String vspName = createVendorSoftwareProduct.getName(); - HomePage.showVspRepository(); - OnboardingUiUtils.importVSP(createVendorSoftwareProduct); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()).click(); - GeneralUIUtils.waitForLoader(); - return vspName; -} + artifactTypesArrayFromApi.add(value); + } + return artifactTypesArrayFromApi; + } -//check if file downloaded successfully. -public static boolean isFileDownloaded(String downloadPath, String fileName) { - boolean flag = false; - File dir = new File(downloadPath); - File[] dir_contents = dir.listFiles(); - for (int i = 0; i < dir_contents.length; i++) { - if (dir_contents[i].getName().equals(fileName)) - return flag = true; - } - return flag; -} + public static String simpleOnBoarding(ResourceReqDetails resourceReqDetails, String fileName, String filePath, User user) throws Exception { + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(user); + VendorSoftwareProductObject createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, fileName, filePath, user, amdocsLicenseMembers); + String vspName = createVendorSoftwareProduct.getName(); + HomePage.showVspRepository(); + OnboardingUiUtils.importVSP(createVendorSoftwareProduct); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()).click(); + GeneralUIUtils.waitForLoader(); + return vspName; + } + + //check if file downloaded successfully. + public static boolean isFileDownloaded(String downloadPath, String fileName) { + File dir = new File(downloadPath); + File[] dir_contents = dir.listFiles(); + for (File dir_content : dir_contents) { + if (dir_content.getName().equals(fileName)) { + return true; + } + } + return false; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MIBsArtifactsOnResourceInstance.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MIBsArtifactsOnResourceInstance.java index f1d2551344..58d4899d1e 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MIBsArtifactsOnResourceInstance.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MIBsArtifactsOnResourceInstance.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,12 @@ package org.openecomp.sdc.ci.tests.US; import org.apache.commons.io.FileUtils; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +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.execute.setup.SetupCDTest; @@ -31,7 +36,11 @@ import org.openecomp.sdc.ci.tests.pages.CompositionPage; import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; import org.openecomp.sdc.ci.tests.pages.UploadArtifactPopup; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; @@ -47,213 +56,212 @@ import static org.testng.AssertJUnit.assertTrue; public class MIBsArtifactsOnResourceInstance extends SetupCDTest { - - private String folder =""; - - @DataProvider(name="mibsArtifactCRUDUi") - public static Object[][] dataProviderMibsArtifactCRUDUi() { - return new Object[][] { - {"mibsvFW_VFC.yml", ResourceTypeEnum.VFC}, - {"mibsVL.yml", ResourceTypeEnum.VL}, - {"mibsCP.yml", ResourceTypeEnum.CP} - }; - } - - // US820414 - // Artifact UI CRUD on VFC/VL/CP - // TODO: Change download validation from download artifact via external API to UI - @Test(dataProvider="mibsArtifactCRUDUi") - public void mibsArtifactCRUDUi(String fileName, ResourceTypeEnum resourceTypeEnum) throws Exception { - setLog(fileName); - String filePath = FileHandling.getFilePath(folder); - - // import Resource - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); - ResourceUIUtils.importVfc(resourceMetaData, filePath, fileName, getUser()); - - // get resourceUUID from BE - String resourceUUID = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1").getUUID(); - - // 2. Upload MIBs artifacts - SNMP_TRAP & SNMP_POLL. - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - - List deploymentArtifactList = new ArrayList<>(); - deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "SNMP_TRAP")); - deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "SNMP_POLL")); - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true)); - - assertTrue("Only created artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); - - String artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + deploymentArtifact.getArtifactLabel()).getText(); - ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(deploymentArtifact.getArtifactLabel(), null, "1", deploymentArtifact.getArtifactType(), true, true, true, false); - - // Verify that uploaded correct file by download artifact via external api - RestResponse restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceUUID, artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE.toString()); - File file = new File(deploymentArtifact.getFilepath() + deploymentArtifact.getFilename()); - - String readFileToString = FileUtils.readFileToString(file); - Assert.assertEquals(restResponse.getResponse(), readFileToString); - - DeploymentArtifactPage.clickEditArtifact(deploymentArtifact.getArtifactLabel()); - UploadArtifactPopup artifactPopup = new UploadArtifactPopup(true); - artifactPopup.loadFile(filePath, "CP.yml"); - artifactPopup.clickDoneButton(); - - assertTrue("Only updated artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); - Assert.assertNotEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + deploymentArtifact.getArtifactLabel()).getText(), artifactUUID); - ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(deploymentArtifact.getArtifactLabel(), null, "2", deploymentArtifact.getArtifactType(), true, true, true, false); - - // Verify that updated correct file by download artifact via external api - artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + deploymentArtifact.getArtifactLabel()).getText(); - restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceUUID, artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE.toString()); - file = new File(deploymentArtifact.getFilepath() + "CP.yml"); - readFileToString = FileUtils.readFileToString(file); - Assert.assertEquals(restResponse.getResponse(), readFileToString); - - DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifact.getArtifactLabel()); - DeploymentArtifactPage.clickOK(); - - assertTrue("No artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(0)); - } - - } - - @DataProvider(name="mibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption") - public static Object[][] dataProviderMibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption() { - return new Object[][] { + + private String folder = ""; + + @DataProvider(name = "mibsArtifactCRUDUi") + public static Object[][] dataProviderMibsArtifactCRUDUi() { + return new Object[][]{ + {"mibsvFW_VFC.yml", ResourceTypeEnum.VFC}, + {"mibsVL.yml", ResourceTypeEnum.VL}, + {"mibsCP.yml", ResourceTypeEnum.CP} + }; + } + + // US820414 + // Artifact UI CRUD on VFC/VL/CP + // TODO: Change download validation from download artifact via external API to UI + @Test(dataProvider = "mibsArtifactCRUDUi") + public void mibsArtifactCRUDUi(String fileName, ResourceTypeEnum resourceTypeEnum) throws Exception { + setLog(fileName); + String filePath = FileHandling.getFilePath(folder); + + // import Resource + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); + ResourceUIUtils.importVfc(resourceMetaData, filePath, fileName, getUser()); + + // get resourceUUID from BE + String resourceUUID = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1").getUUID(); + + // 2. Upload MIBs artifacts - SNMP_TRAP & SNMP_POLL. + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + List deploymentArtifactList = new ArrayList<>(); + deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "SNMP_TRAP")); + deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "SNMP_POLL")); + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true)); + + assertTrue("Only created artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); + + String artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + deploymentArtifact.getArtifactLabel()).getText(); + ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(deploymentArtifact.getArtifactLabel(), null, "1", deploymentArtifact.getArtifactType(), true, true, true, false); + + // Verify that uploaded correct file by download artifact via external api + RestResponse restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceUUID, artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE.toString()); + File file = new File(deploymentArtifact.getFilepath() + deploymentArtifact.getFilename()); + + String readFileToString = FileUtils.readFileToString(file); + Assert.assertEquals(restResponse.getResponse(), readFileToString); + + DeploymentArtifactPage.clickEditArtifact(deploymentArtifact.getArtifactLabel()); + UploadArtifactPopup artifactPopup = new UploadArtifactPopup(true); + artifactPopup.loadFile(filePath, "CP.yml"); + artifactPopup.clickDoneButton(); + + assertTrue("Only updated artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); + Assert.assertNotEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + deploymentArtifact.getArtifactLabel()).getText(), artifactUUID); + ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(deploymentArtifact.getArtifactLabel(), null, "2", deploymentArtifact.getArtifactType(), true, true, true, false); + + // Verify that updated correct file by download artifact via external api + artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + deploymentArtifact.getArtifactLabel()).getText(); + restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceUUID, artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE.toString()); + file = new File(deploymentArtifact.getFilepath() + "CP.yml"); + readFileToString = FileUtils.readFileToString(file); + Assert.assertEquals(restResponse.getResponse(), readFileToString); + + DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifact.getArtifactLabel()); + DeploymentArtifactPage.clickOK(); + + assertTrue("No artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(0)); + } + + } + + @DataProvider(name = "mibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption") + public static Object[][] dataProviderMibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption() { + return new Object[][]{ // {"mibs1vFW_VFC.yml", ResourceTypeEnum.VFC}, - // TODO: delete comment below when we will have support for VL on canvas + // TODO: delete comment below when we will have support for VL on canvas // {"mibs1VL.yml", ResourceTypeEnum.VL}, - {"mibs1CP.yml", ResourceTypeEnum.CP} - }; - } - - // US820414 - // Import VFC/VL/CP, upload MIBs artifacts then drag it on VF & verify that deployment artifact have only download option - @Test(dataProvider="mibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption") - public void mibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption(String fileName, ResourceTypeEnum resourceTypeEnum) throws Exception { - + {"mibs1CP.yml", ResourceTypeEnum.CP} + }; + } + + // US820414 + // Import VFC/VL/CP, upload MIBs artifacts then drag it on VF & verify that deployment artifact have only download option + @Test(dataProvider = "mibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption") + public void mibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption(String fileName, ResourceTypeEnum resourceTypeEnum) throws Exception { + // if(resourceTypeEnum.equals(ResourceTypeEnum.CP)){ // throw new SkipException("Open bug 322930"); // } - setLog(fileName); - - String filePath = FileHandling.getFilePath(folder); - - // import Resource - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); - ResourceUIUtils.importVfc(resourceMetaData, filePath, fileName, getUser()); - - // 2. Upload MIBs artifacts - SNMP_TRAP & SNMP_POLL. - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - - List deploymentArtifactList = new ArrayList(); - deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "SNMP_TRAP")); - deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "SNMP_POLL")); - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true)); - } - assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); - - // 3. Check-in DataProvider resource. - ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); - - // 4. Create VF. - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - // 5. Click on composition. - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - // 6. Drag created DataProvider resource to canvas. - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(resourceMetaData.getName()); - CanvasElement resourceInstance = vfCanvasManager.createElementOnCanvas(resourceMetaData.getName()); - - // 7. Click on DataProvider resource. - vfCanvasManager.clickOnCanvaElement(resourceInstance); - - // 8. Click on deployment artifacts in right menu. - CompositionPage.showDeploymentArtifactTab(); - - // 9. Verify that each uploaded MIBs artifacts shows in deployment artifacts. - // 10. Verify that only have download option. - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - // Hover over webelement -> check that only dowload button displayed - GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel()); - Assert.assertEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DOWNLOAD.getValue() + deploymentArtifact.getArtifactLabel()).isDisplayed(), true); - Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + deploymentArtifact.getArtifactLabel()), false); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel()); - Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.ArtifactPopup.MODAL_WINDOW.getValue()), false); - } - - - } - - // US820414 - // Create VF, upload MIBs artifacts then drag it on service & verify that deployment artifact have only download option - @Test - public void mibsArtifacsOnVFInstanceShouldOnlyHaveDownloadOption() throws Exception { - String filePath = FileHandling.getFilePath(folder); - - // 1. Create VF. - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(resourceMetaData, getUser()); - - // 2. Upload MIBs artifacts - SNMP_TRAP & SNMP_POLL. - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - - List deploymentArtifactList = new ArrayList(); - deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "SNMP_TRAP")); - deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "SNMP_POLL")); - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true)); - } - assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); - - // 3. Check-in VF. - ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); - - // 4. Create service. - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - // 5. Click on composition. - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - // 6. Drag created DataProvider s to canvas. - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(resourceMetaData.getName()); - CanvasElement resourceInstance = canvasManager.createElementOnCanvas(resourceMetaData.getName()); - - // 7. Click on DataProvider resource. - canvasManager.clickOnCanvaElement(resourceInstance); - - // 8. Click on deployment artifacts in right menu. - CompositionPage.showDeploymentArtifactTab(); - - // 9. Verify that each uploaded MIBs artifacts shows in deployment artifacts. - // 10. Verify that only have download option. - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - // Hover over webelement -> check that only dowload button displayed - GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel()); - Assert.assertEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DOWNLOAD.getValue() + deploymentArtifact.getArtifactLabel()).isDisplayed(), true); - Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + deploymentArtifact.getArtifactLabel()), false); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel()); - Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.ArtifactPopup.MODAL_WINDOW.getValue()), false); - } - } - - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + setLog(fileName); + + String filePath = FileHandling.getFilePath(folder); + + // import Resource + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); + ResourceUIUtils.importVfc(resourceMetaData, filePath, fileName, getUser()); + + // 2. Upload MIBs artifacts - SNMP_TRAP & SNMP_POLL. + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + List deploymentArtifactList = new ArrayList(); + deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "SNMP_TRAP")); + deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "SNMP_POLL")); + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true)); + } + assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); + + // 3. Check-in DataProvider resource. + ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); + + // 4. Create VF. + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + // 5. Click on composition. + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + // 6. Drag created DataProvider resource to canvas. + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(resourceMetaData.getName()); + CanvasElement resourceInstance = vfCanvasManager.createElementOnCanvas(resourceMetaData.getName()); + + // 7. Click on DataProvider resource. + vfCanvasManager.clickOnCanvaElement(resourceInstance); + + // 8. Click on deployment artifacts in right menu. + CompositionPage.showDeploymentArtifactTab(); + + // 9. Verify that each uploaded MIBs artifacts shows in deployment artifacts. + // 10. Verify that only have download option. + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + // Hover over webelement -> check that only dowload button displayed + GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel()); + Assert.assertEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DOWNLOAD.getValue() + deploymentArtifact.getArtifactLabel()).isDisplayed(), true); + Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + deploymentArtifact.getArtifactLabel()), false); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel()); + Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.ArtifactPopup.MODAL_WINDOW.getValue()), false); + } + + + } + + // US820414 + // Create VF, upload MIBs artifacts then drag it on service & verify that deployment artifact have only download option + @Test + public void mibsArtifacsOnVFInstanceShouldOnlyHaveDownloadOption() throws Exception { + String filePath = FileHandling.getFilePath(folder); + + // 1. Create VF. + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(resourceMetaData, getUser()); + + // 2. Upload MIBs artifacts - SNMP_TRAP & SNMP_POLL. + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + List deploymentArtifactList = new ArrayList(); + deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "SNMP_TRAP")); + deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "SNMP_POLL")); + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true)); + } + assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); + + // 3. Check-in VF. + ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); + + // 4. Create service. + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + // 5. Click on composition. + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + // 6. Drag created DataProvider s to canvas. + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(resourceMetaData.getName()); + CanvasElement resourceInstance = canvasManager.createElementOnCanvas(resourceMetaData.getName()); + + // 7. Click on DataProvider resource. + canvasManager.clickOnCanvaElement(resourceInstance); + + // 8. Click on deployment artifacts in right menu. + CompositionPage.showDeploymentArtifactTab(); + + // 9. Verify that each uploaded MIBs artifacts shows in deployment artifacts. + // 10. Verify that only have download option. + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + // Hover over webelement -> check that only dowload button displayed + GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel()); + Assert.assertEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DOWNLOAD.getValue() + deploymentArtifact.getArtifactLabel()).isDisplayed(), true); + Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + deploymentArtifact.getArtifactLabel()), false); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel()); + Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.ArtifactPopup.MODAL_WINDOW.getValue()), false); + } + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MobProxy.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MobProxy.java index 13f68e43ad..a335ad6514 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MobProxy.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/MobProxy.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,98 +39,104 @@ import org.testng.annotations.Test; import java.io.File; import java.io.IOException; -import java.net.*; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.SocketAddress; +import java.net.URI; import java.util.List; - + public class MobProxy { - public static WebDriver driver; - public static BrowserMobProxyServer server; - - @BeforeClass - public void setup() throws Exception { - - ProxySearch proxySearch = new ProxySearch(); - proxySearch.addStrategy(Strategy.OS_DEFAULT); - proxySearch.addStrategy(Strategy.JAVA); - proxySearch.addStrategy(Strategy.BROWSER); - ProxySelector proxySelector = proxySearch.getProxySelector(); - - ProxySelector.setDefault(proxySelector); - URI home = URI.create("http://www.google.com"); - System.out.println("ProxySelector: " + proxySelector); - System.out.println("URI: " + home); - List proxyList = proxySelector.select(home); - String host = null; - String port = null; - if (proxyList != null && !proxyList.isEmpty()) { - for (Proxy proxy : proxyList) { - System.out.println(proxy); - SocketAddress address = proxy.address(); - if (address instanceof InetSocketAddress) { - host = ((InetSocketAddress) address).getHostName(); - port = Integer.toString(((InetSocketAddress) address).getPort()); - System.setProperty("http.proxyHost", host); - System.setProperty("http.proxyPort", port); - } - } - } - - server = new BrowserMobProxyServer(); - InetSocketAddress address = new InetSocketAddress(host, Integer.parseInt(port)); - server.setChainedProxy(address); - server.start(); - int port1 = server.getPort(); - DesiredCapabilities seleniumCapabilities = new DesiredCapabilities(); - seleniumCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); - seleniumCapabilities.setCapability(CapabilityType.PROXY, ClientUtil.createSeleniumProxy(server)); - driver = new FirefoxDriver(seleniumCapabilities); - server.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT); - System.out.println("Port started:" + port1); - } - - @Test - public void first_test1() throws InterruptedException { - - server.newHar("asdc.har"); - - driver.get("https://www.e-access.att.com/QA-SCRUM1/sdc1/portal#/dashboard"); - driver.manage().window().maximize(); - - WebElement userNameTextbox = driver.findElement(By.name("userid")); - userNameTextbox.sendKeys("m99121"); - WebElement passwordTextbox = driver.findElement(By.name("password")); - passwordTextbox.sendKeys("66-Percent"); - - WebElement submitButton = driver.findElement(By.name("btnSubmit")); - submitButton.click(); - Thread.sleep(300); - WebElement buttonOK = driver.findElement(By.name("successOK")); - AssertJUnit.assertTrue(buttonOK.isDisplayed()); - buttonOK.click(); - Thread.sleep(2000); - driver.findElement(By.xpath(getXpath("main-menu-button-catalog"))).click(); - Thread.sleep(2000); - driver.findElement(By.xpath(getXpath("checkbox-service"))).click(); - Thread.sleep(2000); - } - - public static String getXpath(String dataTestId){ - return String.format("//*[@data-tests-id='%s']", dataTestId); - } - - @AfterClass - public void shutdown() { - try { - - // Get the HAR data - Har har = server.getHar(); - File harFile = new File("C:\\temp\\asdc.har"); - har.writeTo(harFile); - - } catch (IOException ioe) { - ioe.printStackTrace(); - } - driver.quit(); - server.stop(); - } + private static final int THREAD_SLEEP_TIME = 2000; + public static WebDriver driver; + public static BrowserMobProxyServer server; + + @BeforeClass + public void setup() throws Exception { + + ProxySearch proxySearch = new ProxySearch(); + proxySearch.addStrategy(Strategy.OS_DEFAULT); + proxySearch.addStrategy(Strategy.JAVA); + proxySearch.addStrategy(Strategy.BROWSER); + ProxySelector proxySelector = proxySearch.getProxySelector(); + + ProxySelector.setDefault(proxySelector); + URI home = URI.create("http://www.google.com"); + System.out.println("ProxySelector: " + proxySelector); + System.out.println("URI: " + home); + List proxyList = proxySelector.select(home); + String host = null; + String port = null; + if (proxyList != null && !proxyList.isEmpty()) { + for (Proxy proxy : proxyList) { + System.out.println(proxy); + SocketAddress address = proxy.address(); + if (address instanceof InetSocketAddress) { + host = ((InetSocketAddress) address).getHostName(); + port = Integer.toString(((InetSocketAddress) address).getPort()); + System.setProperty("http.proxyHost", host); + System.setProperty("http.proxyPort", port); + } + } + } + + server = new BrowserMobProxyServer(); + InetSocketAddress address = new InetSocketAddress(host, Integer.parseInt(port)); + server.setChainedProxy(address); + server.start(); + int port1 = server.getPort(); + DesiredCapabilities seleniumCapabilities = new DesiredCapabilities(); + seleniumCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); + seleniumCapabilities.setCapability(CapabilityType.PROXY, ClientUtil.createSeleniumProxy(server)); + driver = new FirefoxDriver(seleniumCapabilities); + server.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT); + System.out.println("Port started:" + port1); + } + + @Test + public void first_test1() throws InterruptedException { + final int shortSleepTime = 300; + + server.newHar("asdc.har"); + + driver.get("https://www.e-access.att.com/QA-SCRUM1/sdc1/portal#/dashboard"); + driver.manage().window().maximize(); + + WebElement userNameTextbox = driver.findElement(By.name("userid")); + userNameTextbox.sendKeys("m99121"); + WebElement passwordTextbox = driver.findElement(By.name("password")); + passwordTextbox.sendKeys("66-Percent"); + + WebElement submitButton = driver.findElement(By.name("btnSubmit")); + submitButton.click(); + Thread.sleep(shortSleepTime); + WebElement buttonOK = driver.findElement(By.name("successOK")); + AssertJUnit.assertTrue(buttonOK.isDisplayed()); + buttonOK.click(); + Thread.sleep(THREAD_SLEEP_TIME); + driver.findElement(By.xpath(getXpath("main-menu-button-catalog"))).click(); + Thread.sleep(THREAD_SLEEP_TIME); + driver.findElement(By.xpath(getXpath("checkbox-service"))).click(); + Thread.sleep(THREAD_SLEEP_TIME); + } + + public static String getXpath(String dataTestId) { + return String.format("//*[@data-tests-id='%s']", dataTestId); + } + + @AfterClass + public void shutdown() { + try { + + // Get the HAR data + Har har = server.getHar(); + File harFile = new File("C:\\temp\\asdc.har"); + har.writeTo(harFile); + + } catch (IOException ioe) { + ioe.printStackTrace(); + } + driver.quit(); + server.stop(); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/NewArtifactTypeGuide.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/NewArtifactTypeGuide.java index c772847411..59a82b52ff 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/NewArtifactTypeGuide.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/NewArtifactTypeGuide.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,81 +42,80 @@ import static org.testng.AssertJUnit.assertTrue; public class NewArtifactTypeGuide extends SetupCDTest { - - private String folder =""; - - // US820276 - // Upload information artifact of type GUIDE to VF - @Test - public void crudGuideInformationArtifactForVf() throws Exception { - String filePath = FileHandling.getFilePath(folder); - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(resourceMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - ArtifactInfo informationArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "GUIDE"); - - InformationalArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(informationArtifact); - - assertTrue("Only created artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); - - String artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText(); - ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "1", informationArtifact.getArtifactType(), true, true, true, false); - - InformationalArtifactPage.clickEditArtifact(informationArtifact.getArtifactLabel()); - UploadArtifactPopup artifactPopup = new UploadArtifactPopup(); - artifactPopup.loadFile(filePath, "CP.yml"); - artifactPopup.clickDoneButton(); - - assertTrue("Only updated artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); - Assert.assertNotEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText(), artifactUUID); - ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "2", informationArtifact.getArtifactType(), true, true, true, false); - - InformationalArtifactPage.clickDeleteArtifact(informationArtifact.getArtifactLabel()); - InformationalArtifactPage.clickOK(); - } - - // US820276 - // Upload information artifact of type GUIDE to VFC - @Test - public void crudGuideInformationArtifactForVfc() throws Exception { - String filePath = FileHandling.getFilePath(folder); - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VFC, getUser()); - ResourceUIUtils.importVfc(resourceMetaData, filePath, "guidevFW_VFC.yml", getUser()); - - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - ArtifactInfo informationArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "GUIDE"); - - InformationalArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(informationArtifact); - - assertTrue("Only created artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); - String artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText(); - ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "1", informationArtifact.getArtifactType(), true, true, true, false); - - InformationalArtifactPage.clickEditArtifact(informationArtifact.getArtifactLabel()); - UploadArtifactPopup artifactPopup = new UploadArtifactPopup(); - artifactPopup.loadFile(filePath, "CP.yml"); - artifactPopup.clickDoneButton(); - - assertTrue("Only updated artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); - Assert.assertNotEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText(), artifactUUID); - ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "2", informationArtifact.getArtifactType(), true, true, true, false); - - InformationalArtifactPage.clickDeleteArtifact(informationArtifact.getArtifactLabel()); - InformationalArtifactPage.clickOK(); - } - - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + + private String folder = ""; + + // US820276 + // Upload information artifact of type GUIDE to VF + @Test + public void crudGuideInformationArtifactForVf() throws Exception { + String filePath = FileHandling.getFilePath(folder); + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(resourceMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + + ArtifactInfo informationArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "GUIDE"); + + InformationalArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(informationArtifact); + + assertTrue("Only created artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); + + String artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText(); + ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "1", informationArtifact.getArtifactType(), true, true, true, false); + + InformationalArtifactPage.clickEditArtifact(informationArtifact.getArtifactLabel()); + UploadArtifactPopup artifactPopup = new UploadArtifactPopup(); + artifactPopup.loadFile(filePath, "CP.yml"); + artifactPopup.clickDoneButton(); + + assertTrue("Only updated artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); + Assert.assertNotEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText(), artifactUUID); + ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "2", informationArtifact.getArtifactType(), true, true, true, false); + + InformationalArtifactPage.clickDeleteArtifact(informationArtifact.getArtifactLabel()); + InformationalArtifactPage.clickOK(); + } + + // US820276 + // Upload information artifact of type GUIDE to VFC + @Test + public void crudGuideInformationArtifactForVfc() throws Exception { + String filePath = FileHandling.getFilePath(folder); + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VFC, getUser()); + ResourceUIUtils.importVfc(resourceMetaData, filePath, "guidevFW_VFC.yml", getUser()); + + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + + ArtifactInfo informationArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "GUIDE"); + + InformationalArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(informationArtifact); + + assertTrue("Only created artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); + String artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText(); + ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "1", informationArtifact.getArtifactType(), true, true, true, false); + + InformationalArtifactPage.clickEditArtifact(informationArtifact.getArtifactLabel()); + UploadArtifactPopup artifactPopup = new UploadArtifactPopup(); + artifactPopup.loadFile(filePath, "CP.yml"); + artifactPopup.clickDoneButton(); + + assertTrue("Only updated artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1)); + Assert.assertNotEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText(), artifactUUID); + ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "2", informationArtifact.getArtifactType(), true, true, true, false); + + InformationalArtifactPage.clickDeleteArtifact(informationArtifact.getArtifactLabel()); + InformationalArtifactPage.clickOK(); + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/RemoveRestrictionOfDeploymentArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/RemoveRestrictionOfDeploymentArtifacts.java index c8e8110fc8..7c913d9782 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/RemoveRestrictionOfDeploymentArtifacts.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/RemoveRestrictionOfDeploymentArtifacts.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,8 +21,12 @@ package org.openecomp.sdc.ci.tests.US; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; +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.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage; @@ -40,73 +44,73 @@ import java.util.List; public class RemoveRestrictionOfDeploymentArtifacts extends SetupCDTest { - - private String folder =""; - - // US833330 - Story [BE] - remove restriction of deployment artifacts - // Create service without resource instance and without deployment artifacts and verify it can submit for testing - @Test - public void createServiceWithoutRIAndArtifacts() throws Exception { - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - } - - - // US833330 - Story [BE] - remove restriction of deployment artifacts - // Create service with VL resource instance and without deployment artifacts and verify it can submit for testing - @Test - public void createServiceWithVlAndWithoutArtfiacts() throws Exception { - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - canvasManager.createElementOnCanvas(LeftPanelCanvasItems.NETWORK); - canvasManager.createElementOnCanvas(LeftPanelCanvasItems.NETWORK); - canvasManager.createElementOnCanvas(LeftPanelCanvasItems.NETWORK); - - ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - } - - // US833330 - Story [BE] - remove restriction of deployment artifacts - // Create service with VF with informational artifacts and verify it can submit for testing - @Test - public void createServiceWithInformationalArtifacts() throws Exception { - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(resourceMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - String filePath = FileHandling.getFilePath(folder); - List informationalArtifactList = new ArrayList(); - informationalArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); - informationalArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "GUIDE")); - for (ArtifactInfo informationalArtifact : informationalArtifactList) { - InformationalArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact, new UploadArtifactPopup(true)); - } - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(resourceMetaData.getName()); + + private String folder = ""; + + // US833330 - Story [BE] - remove restriction of deployment artifacts + // Create service without resource instance and without deployment artifacts and verify it can submit for testing + @Test + public void createServiceWithoutRIAndArtifacts() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + } + + + // US833330 - Story [BE] - remove restriction of deployment artifacts + // Create service with VL resource instance and without deployment artifacts and verify it can submit for testing + @Test + public void createServiceWithVlAndWithoutArtfiacts() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + canvasManager.createElementOnCanvas(LeftPanelCanvasItems.NETWORK); + canvasManager.createElementOnCanvas(LeftPanelCanvasItems.NETWORK); + canvasManager.createElementOnCanvas(LeftPanelCanvasItems.NETWORK); + + ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + } + + // US833330 - Story [BE] - remove restriction of deployment artifacts + // Create service with VF with informational artifacts and verify it can submit for testing + @Test + public void createServiceWithInformationalArtifacts() throws Exception { + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(resourceMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + + String filePath = FileHandling.getFilePath(folder); + List informationalArtifactList = new ArrayList(); + informationalArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); + informationalArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "GUIDE")); + for (ArtifactInfo informationalArtifact : informationalArtifactList) { + InformationalArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact, new UploadArtifactPopup(true)); + } + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(resourceMetaData.getName()); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); TesterOperationPage.certifyComponent(resourceMetaData.getName()); reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement resourceInstance = canvasManager.createElementOnCanvas(resourceMetaData.getName()); - - ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CanvasElement resourceInstance = canvasManager.createElementOnCanvas(resourceMetaData.getName()); + + ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Service_Tests_UI.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Service_Tests_UI.java index 79cb6aa7f6..31df507184 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Service_Tests_UI.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Service_Tests_UI.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,8 +20,13 @@ package org.openecomp.sdc.ci.tests.US; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.StepsEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; @@ -37,64 +42,65 @@ import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; -public class Service_Tests_UI extends SetupCDTest{ +public class Service_Tests_UI extends SetupCDTest { - public Service_Tests_UI() { - } - - // US839610 - E2E Declare VL / CP properties as inputs in service level - @Test - public void declareVL_CP_InputsInServiceLevel() throws Exception { - String vnfFile = "FDNT.zip"; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); - ServiceReqDetails servicemetadata = ElementFactory.getDefaultService(getUser()); - ServiceUIUtils.createService(servicemetadata, getUser()); - GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); - CanvasManager service_CanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(vendorSoftwareProductObject.getName()); - GeneralUIUtils.waitForLoader(); - CanvasElement vfi_Element = service_CanvasManager.createElementOnCanvas(vendorSoftwareProductObject.getName()); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()) - .click(); - GeneralUIUtils.findComponentAndClick(servicemetadata.getName()); - GeneralUIUtils.moveToStep(StepsEnum.INPUTS); - GeneralUIUtils.getWebElementByTestID("inputs-vf-instance-1").click(); + public Service_Tests_UI() { + } + + // US839610 - E2E Declare VL / CP properties as inputs in service level + @Test + public void declareVL_CP_InputsInServiceLevel() throws Exception { + String vnfFile = "FDNT.zip"; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); + ServiceReqDetails servicemetadata = ElementFactory.getDefaultService(getUser()); + ServiceUIUtils.createService(servicemetadata, getUser()); + GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); + CanvasManager service_CanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(vendorSoftwareProductObject.getName()); + GeneralUIUtils.waitForLoader(); + CanvasElement vfi_Element = service_CanvasManager.createElementOnCanvas(vendorSoftwareProductObject.getName()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()) + .click(); + GeneralUIUtils.findComponentAndClick(servicemetadata.getName()); + GeneralUIUtils.moveToStep(StepsEnum.INPUTS); + GeneralUIUtils.getWebElementByTestID("inputs-vf-instance-1").click(); // GeneralUIUtils.onNameClicked(input); - } - @Test - public void CreateServiceWithCpInstance() throws Exception { - String vnfFile = "FDNT.zip"; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); - ServiceReqDetails servicemetadata = ElementFactory.getDefaultService(getUser()); - ServiceUIUtils.createService(servicemetadata, getUser()); - GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); - CanvasManager service_CanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(vendorSoftwareProductObject.getName()); - GeneralUIUtils.waitForLoader(); - CanvasElement vfi_Element = service_CanvasManager.createElementOnCanvas(vendorSoftwareProductObject.getName()); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()) - .click(); - GeneralUIUtils.findComponentAndClick(servicemetadata.getName()); - GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_VIEW); - String version = GeneralUIUtils.getWebElementByTestID("versionHeader").getText(); - RestResponse service = ServiceRestUtils.getServiceByNameAndVersion(getUser(), servicemetadata.getName(), - version.substring(1)); - List serviceResponseArray = new ArrayList<>(); - serviceResponseArray =LocalGeneralUtilities.getValuesFromJsonArray(service); - servicemetadata.setUniqueId(serviceResponseArray.get(0)); - RestResponse serviceResponse = ServiceRestUtils.getService(servicemetadata, getUser()); - if (serviceResponseArray.get(0).contains("VL")) { - System.out.println("OK"); - } + } + + @Test + public void CreateServiceWithCpInstance() throws Exception { + String vnfFile = "FDNT.zip"; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); + ServiceReqDetails servicemetadata = ElementFactory.getDefaultService(getUser()); + ServiceUIUtils.createService(servicemetadata, getUser()); + GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); + CanvasManager service_CanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(vendorSoftwareProductObject.getName()); + GeneralUIUtils.waitForLoader(); + CanvasElement vfi_Element = service_CanvasManager.createElementOnCanvas(vendorSoftwareProductObject.getName()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()) + .click(); + GeneralUIUtils.findComponentAndClick(servicemetadata.getName()); + GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_VIEW); + String version = GeneralUIUtils.getWebElementByTestID("versionHeader").getText(); + RestResponse service = ServiceRestUtils.getServiceByNameAndVersion(getUser(), servicemetadata.getName(), + version.substring(1)); + List serviceResponseArray = new ArrayList<>(); + serviceResponseArray = LocalGeneralUtilities.getValuesFromJsonArray(service); + servicemetadata.setUniqueId(serviceResponseArray.get(0)); + RestResponse serviceResponse = ServiceRestUtils.getService(servicemetadata, getUser()); + if (serviceResponseArray.get(0).contains("VL")) { + System.out.println("OK"); + } + + } - } + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } - } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Testing.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Testing.java index 3238e66765..9949d63686 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Testing.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Testing.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,10 +35,6 @@ import java.util.Map; import java.util.Set; - - - - public class Testing { // public static void main(String[] args) throws Exception { @@ -75,111 +71,91 @@ public class Testing { // // // } - - - - private static void validateNodeTemplatesProperties(Map> predefinedMap, ToscaDefinition toscaDefinition) { - - for(String key: predefinedMap.keySet()) { - Map nodeTemplateProperties = getNodeTemplatePropertiesByNodeTemplateType(key, toscaDefinition); - - predefinedMap.get(key).forEach((i,j) -> { - Assert.assertEquals(nodeTemplateProperties.get(i), j, "Expected that the properties will be equal"); - }); - } - - } - - // Get properties by type - private static Map getNodeTemplatePropertiesByNodeTemplateType(String nodeTemplateType, ToscaDefinition toscaDefinition) { - Map propertiesMap = null; - - Set nodeTemplates = getNodeTemplates(toscaDefinition); - - for(String nodeTemplate: nodeTemplates) { - String currentNodeTemplateType = getNodeTemplateType(toscaDefinition, nodeTemplate); - currentNodeTemplateType = currentNodeTemplateType.substring(currentNodeTemplateType.lastIndexOf(".") + 1); - if(currentNodeTemplateType.equals(nodeTemplateType)) { - propertiesMap = getNodeTemplateProperties(toscaDefinition, nodeTemplate); - break; - } - } - - return propertiesMap; - } - - // Get node templates - private static Set getNodeTemplates(ToscaDefinition toscaDefinition) { - Set resourceInstanceArray = toscaDefinition.getTopology_template().getNode_templates().keySet(); - return resourceInstanceArray; - } - - // Get type of node template - private static String getNodeTemplateType(ToscaDefinition toscaDefinition, String nodeTemplate) { - return toscaDefinition.getTopology_template().getNode_templates().get(nodeTemplate).getType(); - } - - // Get properties of node template - private static Map getNodeTemplateProperties(ToscaDefinition toscaDefinition, String nodeTemplate) { - Map propertiesMap = toscaDefinition.getTopology_template().getNode_templates().get(nodeTemplate).getProperties(); - return propertiesMap; - } - - - - - - - - - - - - - - - - - - - - public static void main(String[] args) throws Exception { - ToscaDefinition toscaMainAmdocsDefinition, toscaMainVfDefinition, toscaMainServiceDefinition; - File filesFolder = new File("C:/Users/al714h/Downloads/Design/"); - File importToscaFilesFolder = new File("C:/Git_work/sdc/catalog-be/src/main/resources/import/tosca/"); - - File dataTypesLocation = new File(importToscaFilesFolder.getPath() + "/data-types/dataTypes.yml"); - - File genericVfFileLocation = new File(importToscaFilesFolder.getPath() + "/heat-types/Generic_VF/Generic_VF.yml"); - File genericVfcFileLocation = new File (importToscaFilesFolder.getPath() + "/heat-types/Generic_VFC/Generic_VFC.yml"); - File genericPnfFileLocation = new File (importToscaFilesFolder.getPath() + "/heat-types/Generic_PNF/Generic_PNF.yml"); - File genericServiceFileLocation = new File (importToscaFilesFolder.getPath() + "/heat-types/Generic_Service/Generic_Service.yml"); - - File amdocsCsarFileName = new File("/77e6b842669f441db20a83489da3f4be.csar"); - File VfCsarFileName = new File("/resource-Civfonboarded2016012VmxAv301072E2e1424cb9d-csar.csar"); - File serviceCsarFileName = new File("/service-Ciservicefeba0521131d-csar.csar"); - - Map parseDataTypesYaml = FileHandling.parseDataTypesYaml(dataTypesLocation.getAbsoluteFile().toString()); - System.out.println("start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date())); - - toscaMainAmdocsDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + amdocsCsarFileName)); - toscaMainVfDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + VfCsarFileName)); - toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + serviceCsarFileName)); - ToscaTopologyTemplateDefinition topologyTemplate = toscaMainAmdocsDefinition.getTopology_template(); - ToscaDefinition objectHelper = ToscaParserUtils.parseToscaYamlToJavaObject(genericVfFileLocation); - - Map additionalInputs = new HashMap<>(); - Set keySet = objectHelper.getNode_types().keySet(); - if(keySet != null){ - for(String key: keySet){ - additionalInputs = objectHelper.getNode_types().get(key).getProperties(); - } - } + + + private static void validateNodeTemplatesProperties(Map> predefinedMap, ToscaDefinition toscaDefinition) { + + for (String key : predefinedMap.keySet()) { + Map nodeTemplateProperties = getNodeTemplatePropertiesByNodeTemplateType(key, toscaDefinition); + + predefinedMap.get(key).forEach((i, j) -> { + Assert.assertEquals(nodeTemplateProperties.get(i), j, "Expected that the properties will be equal"); + }); + } + + } + + // Get properties by type + private static Map getNodeTemplatePropertiesByNodeTemplateType(String nodeTemplateType, ToscaDefinition toscaDefinition) { + Map propertiesMap = null; + + Set nodeTemplates = getNodeTemplates(toscaDefinition); + + for (String nodeTemplate : nodeTemplates) { + String currentNodeTemplateType = getNodeTemplateType(toscaDefinition, nodeTemplate); + currentNodeTemplateType = currentNodeTemplateType.substring(currentNodeTemplateType.lastIndexOf(".") + 1); + if (currentNodeTemplateType.equals(nodeTemplateType)) { + propertiesMap = getNodeTemplateProperties(toscaDefinition, nodeTemplate); + break; + } + } + + return propertiesMap; + } + + // Get node templates + private static Set getNodeTemplates(ToscaDefinition toscaDefinition) { + Set resourceInstanceArray = toscaDefinition.getTopology_template().getNode_templates().keySet(); + return resourceInstanceArray; + } + + // Get type of node template + private static String getNodeTemplateType(ToscaDefinition toscaDefinition, String nodeTemplate) { + return toscaDefinition.getTopology_template().getNode_templates().get(nodeTemplate).getType(); + } + + // Get properties of node template + private static Map getNodeTemplateProperties(ToscaDefinition toscaDefinition, String nodeTemplate) { + Map propertiesMap = toscaDefinition.getTopology_template().getNode_templates().get(nodeTemplate).getProperties(); + return propertiesMap; + } + + + public static void main(String[] args) throws Exception { + ToscaDefinition toscaMainAmdocsDefinition, toscaMainVfDefinition, toscaMainServiceDefinition; + File filesFolder = new File("C:/Users/al714h/Downloads/Design/"); + File importToscaFilesFolder = new File("C:/Git_work/sdc/catalog-be/src/main/resources/import/tosca/"); + + File dataTypesLocation = new File(importToscaFilesFolder.getPath() + "/data-types/dataTypes.yml"); + + File genericVfFileLocation = new File(importToscaFilesFolder.getPath() + "/heat-types/Generic_VF/Generic_VF.yml"); + File genericVfcFileLocation = new File(importToscaFilesFolder.getPath() + "/heat-types/Generic_VFC/Generic_VFC.yml"); + File genericPnfFileLocation = new File(importToscaFilesFolder.getPath() + "/heat-types/Generic_PNF/Generic_PNF.yml"); + File genericServiceFileLocation = new File(importToscaFilesFolder.getPath() + "/heat-types/Generic_Service/Generic_Service.yml"); + + File amdocsCsarFileName = new File("/77e6b842669f441db20a83489da3f4be.csar"); + File VfCsarFileName = new File("/resource-Civfonboarded2016012VmxAv301072E2e1424cb9d-csar.csar"); + File serviceCsarFileName = new File("/service-Ciservicefeba0521131d-csar.csar"); + + Map parseDataTypesYaml = FileHandling.parseDataTypesYaml(dataTypesLocation.getAbsoluteFile().toString()); + System.out.println("start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date())); + + toscaMainAmdocsDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + amdocsCsarFileName)); + toscaMainVfDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + VfCsarFileName)); + toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + serviceCsarFileName)); + ToscaTopologyTemplateDefinition topologyTemplate = toscaMainAmdocsDefinition.getTopology_template(); + ToscaDefinition objectHelper = ToscaParserUtils.parseToscaYamlToJavaObject(genericVfFileLocation); + + Map additionalInputs = new HashMap<>(); + Set keySet = objectHelper.getNode_types().keySet(); + if (keySet != null) { + for (String key : keySet) { + additionalInputs = objectHelper.getNode_types().get(key).getProperties(); + } + } // topologyTemplate.addInputs(additionalInputs); - - - + // toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(path); System.out.println("listTypeHeatMetaDefinition start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date())); // List listTypeHeatMetaDefinition = CsarParserUtils.getListTypeHeatMetaDefinition(csarPath); @@ -194,12 +170,9 @@ public class Testing { // } System.out.println("Finished"); System.out.println("get service start " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date())); - - - - } - - + + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/VfModule.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/VfModule.java index 2109c42e5d..5286d22800 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/VfModule.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/VfModule.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,23 +23,42 @@ package org.openecomp.sdc.ci.tests.US; import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ToscaArtifactsScreenEnum; +import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.devCI.ArtifactFromCsar; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.HomePage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.DownloadManager; import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; +import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utils.CsarParserUtils; import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils; -import org.openecomp.sdc.ci.tests.utils.general.*; +import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; +import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; +import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator; import org.openecomp.sdc.ci.tests.verificator.VfModuleVerificator; import org.testng.annotations.Test; -import java.awt.*; +import java.awt.AWTException; import java.io.File; import java.util.LinkedList; import java.util.List; @@ -49,99 +68,97 @@ import static org.testng.AssertJUnit.assertNotNull; /** * @author al714h - * */ public class VfModule extends SetupCDTest { - @Test - public void checkVfModulesCountAndStructure() throws Exception, AWTException { + @Test + public void checkVfModulesCountAndStructure() throws Exception, AWTException { // String filePath = "src\\main\\resources\\Files\\VNFs"; - String filepath = FileHandling.getVnfRepositoryPath(); + String filepath = FileHandling.getVnfRepositoryPath(); // String vnfFile = "LDSA.zip"; // String vnfFile = "FDNT.zip"; - List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); - List newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder); - String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); - String vnfFile = newRandomFileNamesFromFolder.get(0); - getExtendTest().log(Status.INFO, String.format("Going to onboard the VNF %s......", vnfFile)); - System.out.println(String.format("Going to onboard the VNF %s......", vnfFile)); - - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, getUser(), amdocsLicenseMembers); - String vspName = createVendorSoftwareProduct.getName(); - // - DownloadManager.downloadCsarByNameFromVSPRepository(vspName, createVendorSoftwareProduct.getVspId()); - File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); - List listTypeHeatMetaDefinition = CsarParserUtils.getListTypeHeatMetaDefinition(latestFilefromDir); - // - getExtendTest().log(Status.INFO, String.format("Searching for onboarded %s", vnfFile)); - HomePage.showVspRepository(); - getExtendTest().log(Status.INFO, String.format("Going to import %s......", vnfFile.substring(0, vnfFile.indexOf(".")))); - - OnboardingUiUtils.importVSP(createVendorSoftwareProduct); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - - // Verify deployment artifacts - Map combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(latestFilefromDir.getAbsolutePath()); - LinkedList deploymentArtifacts = ((LinkedList) combinedMap.get("Deployment")); - for(HeatMetaFirstLevelDefinition deploymentArtifact: deploymentArtifacts) { - if(deploymentArtifact.getType().equals("HEAT_ENV")) { - continue; - } - System.out.println("--------------"); - System.out.println(deploymentArtifact.getFileName()); - System.out.println(deploymentArtifact.getType()); + List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); + List newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder); + String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); + String vnfFile = newRandomFileNamesFromFolder.get(0); + getExtendTest().log(Status.INFO, String.format("Going to onboard the VNF %s......", vnfFile)); + System.out.println(String.format("Going to onboard the VNF %s......", vnfFile)); + + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, getUser(), amdocsLicenseMembers); + String vspName = createVendorSoftwareProduct.getName(); + // + DownloadManager.downloadCsarByNameFromVSPRepository(vspName, createVendorSoftwareProduct.getVspId()); + File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); + List listTypeHeatMetaDefinition = CsarParserUtils.getListTypeHeatMetaDefinition(latestFilefromDir); + // + getExtendTest().log(Status.INFO, String.format("Searching for onboarded %s", vnfFile)); + HomePage.showVspRepository(); + getExtendTest().log(Status.INFO, String.format("Going to import %s......", vnfFile.substring(0, vnfFile.indexOf(".")))); + + OnboardingUiUtils.importVSP(createVendorSoftwareProduct); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + // Verify deployment artifacts + Map combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(latestFilefromDir.getAbsolutePath()); + LinkedList deploymentArtifacts = ((LinkedList) combinedMap.get("Deployment")); + for (HeatMetaFirstLevelDefinition deploymentArtifact : deploymentArtifacts) { + if (deploymentArtifact.getType().equals("HEAT_ENV")) { + continue; + } + System.out.println("--------------"); + System.out.println(deploymentArtifact.getFileName()); + System.out.println(deploymentArtifact.getType()); // System.out.println(deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().lastIndexOf("."))); - if(deploymentArtifact.getFileName().contains(".")) { - ArtifactUIUtils.validateArtifactNameVersionType(deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().lastIndexOf(".")), "1", deploymentArtifact.getType()); - } else { - ArtifactUIUtils.validateArtifactNameVersionType(deploymentArtifact.getFileName().trim(), "1", deploymentArtifact.getType()); - } - - } - - DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, vnfFile); + if (deploymentArtifact.getFileName().contains(".")) { + ArtifactUIUtils.validateArtifactNameVersionType(deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().lastIndexOf(".")), "1", deploymentArtifact.getType()); + } else { + ArtifactUIUtils.validateArtifactNameVersionType(deploymentArtifact.getFileName().trim(), "1", deploymentArtifact.getType()); + } + + } + + DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, vnfFile); //TODO Andrey should click on certify button - DeploymentArtifactPage.clickCertifyButton(vspName); - - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CompositionPage.searchForElement(vspName); - CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager(); - CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vspName); - assertNotNull(vfElement); - ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser()); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); - GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_TEMPLATE.getValue()); - latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); - + DeploymentArtifactPage.clickCertifyButton(vspName); + + // create service + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CompositionPage.searchForElement(vspName); + CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vspName); + assertNotNull(vfElement); + ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser()); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); + GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_TEMPLATE.getValue()); + latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); + // verification - Service service = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, serviceMetadata.getName(), serviceMetadata.getVersion()); - ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(latestFilefromDir); + Service service = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, serviceMetadata.getName(), serviceMetadata.getVersion()); + ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(latestFilefromDir); // compare number of vf modules defined in HEAT.meta file vs Service TOSCA yaml - VfModuleVerificator.compareNumberOfVfModules(listTypeHeatMetaDefinition, toscaDefinition); - VfModuleVerificator.verifyGroupMetadata(toscaDefinition, service); + VfModuleVerificator.compareNumberOfVfModules(listTypeHeatMetaDefinition, toscaDefinition); + VfModuleVerificator.verifyGroupMetadata(toscaDefinition, service); - getExtendTest().log(Status.INFO, String.format("Onboarding %s test is passed ! ", vnfFile)); + getExtendTest().log(Status.INFO, String.format("Onboarding %s test is passed ! ", vnfFile)); - } + } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Vf_Tests_UI.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Vf_Tests_UI.java index c3d980163e..e878fec9e2 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Vf_Tests_UI.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/Vf_Tests_UI.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,18 +27,19 @@ import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -public class Vf_Tests_UI extends SetupCDTest{ +public class Vf_Tests_UI extends SetupCDTest { - public Vf_Tests_UI() { - } - public void uploadHeatEnvVFLevel() throws Exception { - - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - } - -// @Test + public Vf_Tests_UI() { + } + + public void uploadHeatEnvVFLevel() throws Exception { + + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + } + + // @Test // // Download ENV file from VF level. // public void downloadEnvVFLevel() throws AWTException, Exception { // String firstEnvArtifact = "base_stsi_dnt_frwl.env"; @@ -63,8 +64,8 @@ public class Vf_Tests_UI extends SetupCDTest{ // } // } // } - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/extendNode_TemplatePropertiesWithDefaultValues.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/extendNode_TemplatePropertiesWithDefaultValues.java index 103bf64b3e..7c448d5b86 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/extendNode_TemplatePropertiesWithDefaultValues.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/US/extendNode_TemplatePropertiesWithDefaultValues.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,12 @@ import org.openecomp.sdc.ci.tests.pages.CompositionPage; import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.PropertiesUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.RestCDUtils; +import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.testng.Assert; @@ -49,244 +54,243 @@ import java.util.Set; public class extendNode_TemplatePropertiesWithDefaultValues extends SetupCDTest { - @DataProvider(name="customizeServiceVfUsedVlsCps") - public static Object[][] dataProviderCustomizeServiceVfUsedVlsCps() { - return new Object[][] { + @DataProvider(name = "customizeServiceVfUsedVlsCps") + public static Object[][] dataProviderCustomizeServiceVfUsedVlsCps() { + return new Object[][]{ // {"VL_US831517_1.yml", "VL_US831517_2.yml", "VL_US831517_3.yml", ResourceTypeEnum.VL, ComponentTypeEnum.SERVICE}, - {"CP_US831517_1.yml", "CP_US831517_2.yml", "CP_US831517_3.yml", ResourceTypeEnum.CP, ComponentTypeEnum.SERVICE}, - {"VL_US831517_1.yml", "VL_US831517_2.yml", "VL_US831517_3.yml", ResourceTypeEnum.VL, ComponentTypeEnum.RESOURCE}, - {"CP_US831517_1.yml", "CP_US831517_2.yml", "CP_US831517_3.yml", ResourceTypeEnum.CP, ComponentTypeEnum.RESOURCE}, - }; - } - - // US831517 - Story [BE] - Extend node_template properties with default values - @Test(dataProvider="customizeServiceVfUsedVlsCps") - public void customizeServiceVfUsedVlsCps(String fileName_vl1, String fileName_vl2, String fileName_vl3, ResourceTypeEnum resourceTypeEnum, ComponentTypeEnum componentTypeEnum) throws Exception { - setLog("Extend node_template properties with default values"); - - // import Resource - LinkedList assetsName = importThreeAsset(fileName_vl1, fileName_vl2, fileName_vl3, resourceTypeEnum); - - if(ComponentTypeEnum.SERVICE == componentTypeEnum) { - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - } else { - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(resourceMetaData, getUser()); - } - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement resourceInstance1 = canvasManager.createElementOnCanvas(assetsName.get(0)); - CanvasElement resourceInstance2 = canvasManager.createElementOnCanvas(assetsName.get(1)); - CanvasElement resourceInstance3 = canvasManager.createElementOnCanvas(assetsName.get(2)); - - canvasManager.clickOnCanvaElement(resourceInstance1); - CompositionPage.showPropertiesAndAttributesTab(); - PropertiesUIUtils.changePropertyDefaultValueInComposition("property_1", "false"); - - canvasManager.clickOnCanvaElement(resourceInstance2); - CompositionPage.showPropertiesAndAttributesTab(); - PropertiesUIUtils.changePropertyDefaultValueInComposition("property_3", "customize"); - - canvasManager.clickOnCanvaElement(resourceInstance3); - CompositionPage.showPropertiesAndAttributesTab(); - PropertiesUIUtils.changePropertyDefaultValueInComposition("property_2", "customize derived"); - PropertiesUIUtils.changePropertyDefaultValueInComposition("property_5", "customize new"); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); - GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_TEMPLATE.getValue()); - - // TODO: Replace it by automatic download to path - // TODO: After it remove - File path = new File("C:\\Users\\rp955r\\Desktop\\US\\US831517\\TCExport\\TC1459238.yml"); - ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(path); - - Map vl_us831517_1 = new HashMap(); - vl_us831517_1.put("property_1", false); - vl_us831517_1.put("property_2", "init_value_2"); - vl_us831517_1.put("property_3", "init_value_3"); - - - Map vl_us831517_2 = new HashMap(); - vl_us831517_2.put("property_1", false); - vl_us831517_2.put("property_2", "init_value_2"); - vl_us831517_2.put("property_3", "customize"); - - Map vl_us831517_3 = new HashMap(); - vl_us831517_3.put("property_1", true); - vl_us831517_3.put("property_2", "customize derived"); - vl_us831517_3.put("property_3", "init_value_3"); - vl_us831517_3.put("property_4", false); - vl_us831517_3.put("property_5", "customize new"); - - Map> predefinedProperties = new HashMap>(); - predefinedProperties.put("VL_US831517_1", vl_us831517_1); - predefinedProperties.put("VL_US831517_2", vl_us831517_2); - predefinedProperties.put("VL_US831517_3", vl_us831517_3); - - validateNodeTemplatesProperties(predefinedProperties, toscaDefinition); - - RestCDUtils.deleteOnDemand(); - } - - @DataProvider(name="serviceVfUsedVlsCps") - public static Object[][] dataProviderServiceVfUsedVlsCps() { - return new Object[][] { - {"VL_US831517_1.yml", "VL_US831517_2.yml", "VL_US831517_3.yml", ResourceTypeEnum.VL, ComponentTypeEnum.SERVICE}, - {"CP_US831517_1.yml", "CP_US831517_2.yml", "CP_US831517_3.yml", ResourceTypeEnum.CP, ComponentTypeEnum.SERVICE}, - {"VL_US831517_1.yml", "VL_US831517_2.yml", "VL_US831517_3.yml", ResourceTypeEnum.VL, ComponentTypeEnum.RESOURCE}, - {"CP_US831517_1.yml", "CP_US831517_2.yml", "CP_US831517_3.yml", ResourceTypeEnum.CP, ComponentTypeEnum.RESOURCE}, - }; - } - - - // US831517 - Story [BE] - Extend node_template properties with default values - @Test(dataProvider="serviceVfUsedVlsCps") - public void serviceVfUsedVlsCps(String fileName_vl1, String fileName_vl2, String fileName_vl3, ResourceTypeEnum resourceTypeEnum, ComponentTypeEnum componentTypeEnum) throws Exception { - setLog("Extend node_template properties with default values"); - - // import Resource - LinkedList assetsName = importThreeAsset(fileName_vl1, fileName_vl2, fileName_vl3, resourceTypeEnum); - - if(ComponentTypeEnum.SERVICE == componentTypeEnum) { - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - } else { - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(resourceMetaData, getUser()); - } - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - canvasManager.createElementOnCanvas(assetsName.get(0)); - canvasManager.createElementOnCanvas(assetsName.get(1)); - canvasManager.createElementOnCanvas(assetsName.get(2)); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); - GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_TEMPLATE.getValue()); - - // TODO: Replace it by automatic download to path - // TODO: After it remove - File path = new File("C:\\Users\\rp955r\\Desktop\\US\\US831517\\TCExport\\TC1459238.yml"); - ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(path); - - Map vl_us831517_1 = new HashMap(); - vl_us831517_1.put("property_1", true); - vl_us831517_1.put("property_2", "init_value_2"); - vl_us831517_1.put("property_3", "init_value_3"); - - - Map vl_us831517_2 = new HashMap(); - vl_us831517_2.put("property_1", false); - vl_us831517_2.put("property_2", "init_value_2"); - vl_us831517_2.put("property_3", "new_value_3"); - - Map vl_us831517_3 = new HashMap(); - vl_us831517_3.put("property_1", true); - vl_us831517_3.put("property_2", "init_value_2"); - vl_us831517_3.put("property_3", "init_value_3"); - vl_us831517_3.put("property_4", false); - vl_us831517_3.put("property_5", "init_value_5"); - - Map> predefinedProperties = new HashMap>(); - predefinedProperties.put("VL_US831517_1", vl_us831517_1); - predefinedProperties.put("VL_US831517_2", vl_us831517_2); - predefinedProperties.put("VL_US831517_3", vl_us831517_3); - - validateNodeTemplatesProperties(predefinedProperties, toscaDefinition); - - RestCDUtils.deleteOnDemand(); - } - - private LinkedList importThreeAsset(String fileName_vl1, String fileName_vl2, String fileName_vl3, ResourceTypeEnum resourceTypeEnum) throws Exception { - LinkedList assetsNames = new LinkedList(); - - String filePath = System.getProperty("filepath"); - if (filePath == null && System.getProperty("os.name").contains("Windows")) { - filePath = FileHandling.getResourcesFilesPath() + File.separator + "US831517" + File.separator; - } - else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){ - filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator + "US831517" + File.separator; - } - - // import Resource - ResourceReqDetails resourceMetaDataVl1 = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); - assetsNames.add(resourceMetaDataVl1.getName()); - ResourceUIUtils.importVfc(resourceMetaDataVl1, filePath, fileName_vl1, getUser()); - //TODO Andrey should click on certify button - GeneralPageElements.clickCertifyButton(resourceMetaDataVl1.getName()); + {"CP_US831517_1.yml", "CP_US831517_2.yml", "CP_US831517_3.yml", ResourceTypeEnum.CP, ComponentTypeEnum.SERVICE}, + {"VL_US831517_1.yml", "VL_US831517_2.yml", "VL_US831517_3.yml", ResourceTypeEnum.VL, ComponentTypeEnum.RESOURCE}, + {"CP_US831517_1.yml", "CP_US831517_2.yml", "CP_US831517_3.yml", ResourceTypeEnum.CP, ComponentTypeEnum.RESOURCE}, + }; + } + + // US831517 - Story [BE] - Extend node_template properties with default values + @Test(dataProvider = "customizeServiceVfUsedVlsCps") + public void customizeServiceVfUsedVlsCps(String fileName_vl1, String fileName_vl2, String fileName_vl3, ResourceTypeEnum resourceTypeEnum, ComponentTypeEnum componentTypeEnum) throws Exception { + setLog("Extend node_template properties with default values"); + + // import Resource + LinkedList assetsName = importThreeAsset(fileName_vl1, fileName_vl2, fileName_vl3, resourceTypeEnum); + + if (ComponentTypeEnum.SERVICE == componentTypeEnum) { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + } else { + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(resourceMetaData, getUser()); + } + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CanvasElement resourceInstance1 = canvasManager.createElementOnCanvas(assetsName.get(0)); + CanvasElement resourceInstance2 = canvasManager.createElementOnCanvas(assetsName.get(1)); + CanvasElement resourceInstance3 = canvasManager.createElementOnCanvas(assetsName.get(2)); + + canvasManager.clickOnCanvaElement(resourceInstance1); + CompositionPage.showPropertiesAndAttributesTab(); + PropertiesUIUtils.changePropertyDefaultValueInComposition("property_1", "false"); + + canvasManager.clickOnCanvaElement(resourceInstance2); + CompositionPage.showPropertiesAndAttributesTab(); + PropertiesUIUtils.changePropertyDefaultValueInComposition("property_3", "customize"); + + canvasManager.clickOnCanvaElement(resourceInstance3); + CompositionPage.showPropertiesAndAttributesTab(); + PropertiesUIUtils.changePropertyDefaultValueInComposition("property_2", "customize derived"); + PropertiesUIUtils.changePropertyDefaultValueInComposition("property_5", "customize new"); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); + GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_TEMPLATE.getValue()); + + // TODO: Replace it by automatic download to path + // TODO: After it remove + File path = new File("C:\\Users\\rp955r\\Desktop\\US\\US831517\\TCExport\\TC1459238.yml"); + ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(path); + + Map vl_us831517_1 = new HashMap(); + vl_us831517_1.put("property_1", false); + vl_us831517_1.put("property_2", "init_value_2"); + vl_us831517_1.put("property_3", "init_value_3"); + + + Map vl_us831517_2 = new HashMap(); + vl_us831517_2.put("property_1", false); + vl_us831517_2.put("property_2", "init_value_2"); + vl_us831517_2.put("property_3", "customize"); + + Map vl_us831517_3 = new HashMap(); + vl_us831517_3.put("property_1", true); + vl_us831517_3.put("property_2", "customize derived"); + vl_us831517_3.put("property_3", "init_value_3"); + vl_us831517_3.put("property_4", false); + vl_us831517_3.put("property_5", "customize new"); + + Map> predefinedProperties = new HashMap>(); + predefinedProperties.put("VL_US831517_1", vl_us831517_1); + predefinedProperties.put("VL_US831517_2", vl_us831517_2); + predefinedProperties.put("VL_US831517_3", vl_us831517_3); + + validateNodeTemplatesProperties(predefinedProperties, toscaDefinition); + + RestCDUtils.deleteOnDemand(); + } + + @DataProvider(name = "serviceVfUsedVlsCps") + public static Object[][] dataProviderServiceVfUsedVlsCps() { + return new Object[][]{ + {"VL_US831517_1.yml", "VL_US831517_2.yml", "VL_US831517_3.yml", ResourceTypeEnum.VL, ComponentTypeEnum.SERVICE}, + {"CP_US831517_1.yml", "CP_US831517_2.yml", "CP_US831517_3.yml", ResourceTypeEnum.CP, ComponentTypeEnum.SERVICE}, + {"VL_US831517_1.yml", "VL_US831517_2.yml", "VL_US831517_3.yml", ResourceTypeEnum.VL, ComponentTypeEnum.RESOURCE}, + {"CP_US831517_1.yml", "CP_US831517_2.yml", "CP_US831517_3.yml", ResourceTypeEnum.CP, ComponentTypeEnum.RESOURCE}, + }; + } + + + // US831517 - Story [BE] - Extend node_template properties with default values + @Test(dataProvider = "serviceVfUsedVlsCps") + public void serviceVfUsedVlsCps(String fileName_vl1, String fileName_vl2, String fileName_vl3, ResourceTypeEnum resourceTypeEnum, ComponentTypeEnum componentTypeEnum) throws Exception { + setLog("Extend node_template properties with default values"); + + // import Resource + LinkedList assetsName = importThreeAsset(fileName_vl1, fileName_vl2, fileName_vl3, resourceTypeEnum); + + if (ComponentTypeEnum.SERVICE == componentTypeEnum) { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + } else { + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(resourceMetaData, getUser()); + } + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + canvasManager.createElementOnCanvas(assetsName.get(0)); + canvasManager.createElementOnCanvas(assetsName.get(1)); + canvasManager.createElementOnCanvas(assetsName.get(2)); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); + GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_TEMPLATE.getValue()); + + // TODO: Replace it by automatic download to path + // TODO: After it remove + File path = new File("C:\\Users\\rp955r\\Desktop\\US\\US831517\\TCExport\\TC1459238.yml"); + ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(path); + + Map vl_us831517_1 = new HashMap(); + vl_us831517_1.put("property_1", true); + vl_us831517_1.put("property_2", "init_value_2"); + vl_us831517_1.put("property_3", "init_value_3"); + + + Map vl_us831517_2 = new HashMap(); + vl_us831517_2.put("property_1", false); + vl_us831517_2.put("property_2", "init_value_2"); + vl_us831517_2.put("property_3", "new_value_3"); + + Map vl_us831517_3 = new HashMap(); + vl_us831517_3.put("property_1", true); + vl_us831517_3.put("property_2", "init_value_2"); + vl_us831517_3.put("property_3", "init_value_3"); + vl_us831517_3.put("property_4", false); + vl_us831517_3.put("property_5", "init_value_5"); + + Map> predefinedProperties = new HashMap>(); + predefinedProperties.put("VL_US831517_1", vl_us831517_1); + predefinedProperties.put("VL_US831517_2", vl_us831517_2); + predefinedProperties.put("VL_US831517_3", vl_us831517_3); + + validateNodeTemplatesProperties(predefinedProperties, toscaDefinition); + + RestCDUtils.deleteOnDemand(); + } + + private LinkedList importThreeAsset(String fileName_vl1, String fileName_vl2, String fileName_vl3, ResourceTypeEnum resourceTypeEnum) throws Exception { + LinkedList assetsNames = new LinkedList(); + + String filePath = System.getProperty("filepath"); + if (filePath == null && System.getProperty("os.name").contains("Windows")) { + filePath = FileHandling.getResourcesFilesPath() + File.separator + "US831517" + File.separator; + } else if (filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")) { + filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator + "US831517" + File.separator; + } + + // import Resource + ResourceReqDetails resourceMetaDataVl1 = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); + assetsNames.add(resourceMetaDataVl1.getName()); + ResourceUIUtils.importVfc(resourceMetaDataVl1, filePath, fileName_vl1, getUser()); + //TODO Andrey should click on certify button + GeneralPageElements.clickCertifyButton(resourceMetaDataVl1.getName()); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(resourceMetaDataVl1.getName()); TesterOperationPage.certifyComponent(resourceMetaDataVl1.getName()); reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - - ResourceReqDetails resourceMetaDataVl2 = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); - assetsNames.add(resourceMetaDataVl2.getName()); - ResourceUIUtils.importVfc(resourceMetaDataVl2, filePath, fileName_vl2, getUser()); - GeneralPageElements.clickCheckinButton(resourceMetaDataVl2.getName()); - - ResourceReqDetails resourceMetaDataVl3 = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); - assetsNames.add(resourceMetaDataVl3.getName()); - ResourceUIUtils.importVfc(resourceMetaDataVl3, filePath, fileName_vl3, getUser()); - GeneralPageElements.clickCheckinButton(resourceMetaDataVl2.getName()); - - return assetsNames; - } - - - private static void validateNodeTemplatesProperties(Map> predefinedMap, ToscaDefinition toscaDefinition) { - - for(String key: predefinedMap.keySet()) { - Map nodeTemplateProperties = getNodeTemplatePropertiesByNodeTemplateType(key, toscaDefinition); - - predefinedMap.get(key).forEach((i,j) -> { - Assert.assertEquals(nodeTemplateProperties.get(i), j, "Expected that the properties will be equal"); - }); - } - - } - - // Get properties by type - private static Map getNodeTemplatePropertiesByNodeTemplateType(String nodeTemplateType, ToscaDefinition toscaDefinition) { - Map propertiesMap = null; - - Set nodeTemplates = getNodeTemplates(toscaDefinition); - - for(String nodeTemplate: nodeTemplates) { - String currentNodeTemplateType = getNodeTemplateType(toscaDefinition, nodeTemplate); - currentNodeTemplateType = currentNodeTemplateType.substring(currentNodeTemplateType.lastIndexOf(".") + 1); - if(currentNodeTemplateType.equals(nodeTemplateType)) { - propertiesMap = getNodeTemplateProperties(toscaDefinition, nodeTemplate); - break; - } - } - - return propertiesMap; - } - - // Get node templates - private static Set getNodeTemplates(ToscaDefinition toscaDefinition) { - Set resourceInstanceArray = toscaDefinition.getTopology_template().getNode_templates().keySet(); - return resourceInstanceArray; - } - - // Get type of node template - private static String getNodeTemplateType(ToscaDefinition toscaDefinition, String nodeTemplate) { - return toscaDefinition.getTopology_template().getNode_templates().get(nodeTemplate).getType(); - } - - // Get properties of node template - private static Map getNodeTemplateProperties(ToscaDefinition toscaDefinition, String nodeTemplate) { - Map propertiesMap = toscaDefinition.getTopology_template().getNode_templates().get(nodeTemplate).getProperties(); - return propertiesMap; - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + + ResourceReqDetails resourceMetaDataVl2 = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); + assetsNames.add(resourceMetaDataVl2.getName()); + ResourceUIUtils.importVfc(resourceMetaDataVl2, filePath, fileName_vl2, getUser()); + GeneralPageElements.clickCheckinButton(resourceMetaDataVl2.getName()); + + ResourceReqDetails resourceMetaDataVl3 = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser()); + assetsNames.add(resourceMetaDataVl3.getName()); + ResourceUIUtils.importVfc(resourceMetaDataVl3, filePath, fileName_vl3, getUser()); + GeneralPageElements.clickCheckinButton(resourceMetaDataVl2.getName()); + + return assetsNames; + } + + + private static void validateNodeTemplatesProperties(Map> predefinedMap, ToscaDefinition toscaDefinition) { + + for (String key : predefinedMap.keySet()) { + Map nodeTemplateProperties = getNodeTemplatePropertiesByNodeTemplateType(key, toscaDefinition); + + predefinedMap.get(key).forEach((i, j) -> { + Assert.assertEquals(nodeTemplateProperties.get(i), j, "Expected that the properties will be equal"); + }); + } + + } + + // Get properties by type + private static Map getNodeTemplatePropertiesByNodeTemplateType(String nodeTemplateType, ToscaDefinition toscaDefinition) { + Map propertiesMap = null; + + Set nodeTemplates = getNodeTemplates(toscaDefinition); + + for (String nodeTemplate : nodeTemplates) { + String currentNodeTemplateType = getNodeTemplateType(toscaDefinition, nodeTemplate); + currentNodeTemplateType = currentNodeTemplateType.substring(currentNodeTemplateType.lastIndexOf(".") + 1); + if (currentNodeTemplateType.equals(nodeTemplateType)) { + propertiesMap = getNodeTemplateProperties(toscaDefinition, nodeTemplate); + break; + } + } + + return propertiesMap; + } + + // Get node templates + private static Set getNodeTemplates(ToscaDefinition toscaDefinition) { + Set resourceInstanceArray = toscaDefinition.getTopology_template().getNode_templates().keySet(); + return resourceInstanceArray; + } + + // Get type of node template + private static String getNodeTemplateType(ToscaDefinition toscaDefinition, String nodeTemplate) { + return toscaDefinition.getTopology_template().getNode_templates().get(nodeTemplate).getType(); + } + + // Get properties of node template + private static Map getNodeTemplateProperties(ToscaDefinition toscaDefinition, String nodeTemplate) { + Map propertiesMap = toscaDefinition.getTopology_template().getNode_templates().get(nodeTemplate).getProperties(); + return propertiesMap; + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/businesslogic/ArtifactBusinessLogic.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/businesslogic/ArtifactBusinessLogic.java index 7514b67864..9b3611ced5 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/businesslogic/ArtifactBusinessLogic.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/businesslogic/ArtifactBusinessLogic.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,181 +34,187 @@ import org.openecomp.sdc.ci.tests.utilities.FileHandling; import java.io.File; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; import static org.junit.Assert.assertTrue; public class ArtifactBusinessLogic { - private final static String[] okFileExtensions = new String[] {"yaml", "yml", "env"}; - private static final String PARAMETERS = "parameters"; - private static final String DEPLOYMENT = "Deployment"; - - public static synchronized Map createEnvFilesListFromCsar(String vspName, String filePath) throws Exception{ - Map generatedEnvFiles = new HashMap<>(); - File csarFile= HomePage.downloadVspCsarToDefaultDirectory(vspName); - FileHandling.unzip(csarFile.toString(), filePath); - List yamlList = getHeatFilesCreatedFromCsar(csarFile, filePath); - Map filesPairMap = getFilesPairMap(yamlList); - generatedEnvFiles = generateDefaultEnvFiles(filesPairMap, filePath); - return generatedEnvFiles; - } - - public static synchronized List getHeatFilesCreatedFromCsar(File pathToDirectory, String filePath) throws Exception { - List fileList = new ArrayList<>(); - String artifactsFilePath = filePath + "Artifacts" + File.separator; - List fileListFromArtifactsDirectory = FileHandling.getHeatAndHeatEnvArtifactsFromZip(new File(artifactsFilePath), okFileExtensions); - Map combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(pathToDirectory.toString()); - LinkedList deploymentArtifacts = (LinkedList) combinedMap.get(DEPLOYMENT); - for(HeatMetaFirstLevelDefinition deploymentArtifact : deploymentArtifacts){ - String type = deploymentArtifact.getType(); - if(type.equals(ArtifactTypeEnum.HEAT.getType()) || - type.equals(ArtifactTypeEnum.HEAT_ENV.getType()) || - type.equals(ArtifactTypeEnum.HEAT_VOL.getType()) || - type.equals(ArtifactTypeEnum.HEAT_NET.getType())){ - File file = new File(artifactsFilePath + deploymentArtifact.getFileName()); - if(fileListFromArtifactsDirectory.contains(file)){ - fileList.add(file); - }else{ - assertTrue("File " + file + " does not exist", false); - } - } - } - return fileList; - } - public static synchronized Map getFilesPairMap(List generatedEnvFiles) { - - Map heatAndHeatEnvPairs= new HashMap<>(); - for(File file : generatedEnvFiles){ - String[] fileName = file.getName().split("\\."); - String currentKey = fileName[0]; - String currentExtension = fileName[1]; - HeatAndHeatEnvNamesPair pair; - if(!heatAndHeatEnvPairs.containsKey(currentKey)){ - pair = new HeatAndHeatEnvNamesPair(); - heatAndHeatEnvPairs.put(currentKey, pair); - }else{ - pair = heatAndHeatEnvPairs.get(currentKey); - } - setFileToPair(file, currentExtension, pair); - } - return heatAndHeatEnvPairs; - } - - /** - * The method fill list of HeatWithParametersDefinition parameters - * @param deploymentArtifacts - * @return - */ - public static synchronized List extractHeatWithParametersDefinition(Map deploymentArtifacts) { - - List heatAndEnvLabelList = new ArrayList<>(); - - for (Entry artifactDefinitionChild : deploymentArtifacts.entrySet()){ - if(artifactDefinitionChild.getValue().getArtifactType().equals(ArtifactTypeEnum.HEAT_ENV.getType())){ - for(Entry artifactDefinitionParent : deploymentArtifacts.entrySet()){ - if(artifactDefinitionChild.getValue().getGeneratedFromId().equals(artifactDefinitionParent.getValue().getUniqueId())){ - String heatLabel = artifactDefinitionParent.getValue().getArtifactLabel(); - String heatArtifactType = artifactDefinitionParent.getValue().getArtifactType(); - String heatArtifactDisplayName = artifactDefinitionParent.getValue().getArtifactDisplayName(); - List heatParameterDefinition = artifactDefinitionParent.getValue().getHeatParameters(); - String heatEnvLabel = artifactDefinitionChild.getValue().getArtifactLabel(); - String heatEnvArtifactType = artifactDefinitionChild.getValue().getArtifactType(); - heatAndEnvLabelList.add(new HeatWithParametersDefinition(heatLabel, heatEnvLabel, heatArtifactType, heatEnvArtifactType, heatArtifactDisplayName, heatParameterDefinition)); - break; - } - } - } - } - return heatAndEnvLabelList; - } - - - public static synchronized void setFileToPair(File file, String currentExtension, HeatAndHeatEnvNamesPair pair) { - if(!currentExtension.equals("env")){ - pair.setHeatFileName(file); - }else{ - pair.setHeatEnvFileName(file); - } - } - - public static synchronized Map generateDefaultEnvFiles(Map filesPairMap, String filePath) throws Exception { - - Map generatedEnvFilesMap = new HashMap<>(); - for(Entry pair : filesPairMap.entrySet()){ - Map> envParametersMap = getEnvParametersMap(pair); - File generatedEnvFile = createEnvFile(envParametersMap, new File(filePath + pair.getKey() + ".env")); - generatedEnvFilesMap.put(pair.getKey(), generatedEnvFile); - } - return generatedEnvFilesMap; - } - - public static synchronized File createEnvFile(Map> envParametersMap, File fileToWrite) throws IOException { - - FileHandling.writeToFile(fileToWrite, PARAMETERS+":", 0); - FileHandling.writeToFile(fileToWrite, envParametersMap, 2); - return fileToWrite; - } - - public static synchronized Map> getEnvParametersMap(Entry pair) throws Exception { - File heatFileName = pair.getValue().getHeatFileName(); - File heatEnvFileName = pair.getValue().getHeatEnvFileName(); - Map> envParametersMap = new HashMap<>(); - fillParametersMapFromHeatFile(heatFileName, envParametersMap); - fillParametersMapFromHeatEnvFile(heatEnvFileName, envParametersMap); - return envParametersMap; - } - - public static synchronized void fillParametersMapFromHeatEnvFile(File heatEnvFileName, Map> envParametersMap) throws Exception { - if(heatEnvFileName != null){ - Map mapHeatEnvFileParameters = FileHandling.parseYamlFileToMapByPattern(heatEnvFileName, PARAMETERS); - for (Map.Entry parameter : mapHeatEnvFileParameters.entrySet()){ - String key = parameter.getKey(); - Pair pair; - if(envParametersMap.containsKey(key)){ - if(envParametersMap.get(key).left.equals("string") && parameter.getValue() != null){ - pair = Pair.create(envParametersMap.get(key).left, "\"" + parameter.getValue() + "\""); - }else if(envParametersMap.get(key).left.equals("string") && parameter.getValue() == null){ - pair = Pair.create(envParametersMap.get(key).left, ""); - }else if(parameter.getValue() == null) { - pair = Pair.create(envParametersMap.get(key).left, ""); - } else if(envParametersMap.get(key).left.equals("json") && parameter.getValue() != null){ - String pairValue = ""; - Gson gson = new Gson(); - if(parameter.getValue() instanceof java.util.LinkedHashMap){ - pairValue = gson.toJson(parameter.getValue()); - } - pair = Pair.create(envParametersMap.get(key).left, pairValue ); - - }else if(envParametersMap.get(key).left.equals("json") && parameter.getValue() == null){ - pair = Pair.create(envParametersMap.get(key).left, ""); - }else{ - pair = Pair.create(envParametersMap.get(key).left, parameter.getValue()); - } - envParametersMap.put(key, pair); - } - } - } - } - - @SuppressWarnings("unchecked") - public static synchronized void fillParametersMapFromHeatFile(File heatFileName, Map> envParametersMap) throws Exception { - Map mapHeatFileParameters = FileHandling.parseYamlFileToMapByPattern(heatFileName, PARAMETERS); - for (Map.Entry parameter : mapHeatFileParameters.entrySet()){ - Map value = (Map) parameter.getValue(); - Pair pair; - if(value.get("type").toString().equals("string") && value.get("default") != null ){ - pair = Pair.create(value.get("type").toString(), "\"" + value.get("default") + "\""); - }else if(value.get("type").toString().equals("string") && value.get("default") == null){ - pair = Pair.create(value.get("type").toString(), ""); - }else if(value.get("default") == null){ - pair = Pair.create(value.get("type").toString(), ""); - }else{ - pair = Pair.create(value.get("type").toString(), value.get("default")); - } - envParametersMap.put(parameter.getKey(), pair); - } - } - + private static final String[] OK_FILE_EXTENSIONS = new String[]{"yaml", "yml", "env"}; + private static final String PARAMETERS = "parameters"; + private static final String DEPLOYMENT = "Deployment"; + + public static synchronized Map createEnvFilesListFromCsar(String vspName, String filePath) throws Exception { + Map generatedEnvFiles; + File csarFile = HomePage.downloadVspCsarToDefaultDirectory(vspName); + FileHandling.unzip(csarFile.toString(), filePath); + List yamlList = getHeatFilesCreatedFromCsar(csarFile, filePath); + Map filesPairMap = getFilesPairMap(yamlList); + generatedEnvFiles = generateDefaultEnvFiles(filesPairMap, filePath); + return generatedEnvFiles; + } + + public static synchronized List getHeatFilesCreatedFromCsar(File pathToDirectory, String filePath) throws Exception { + List fileList = new ArrayList<>(); + String artifactsFilePath = filePath + "Artifacts" + File.separator; + List fileListFromArtifactsDirectory = FileHandling.getHeatAndHeatEnvArtifactsFromZip(new File(artifactsFilePath), OK_FILE_EXTENSIONS); + Map combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(pathToDirectory.toString()); + LinkedList deploymentArtifacts = (LinkedList) combinedMap.get(DEPLOYMENT); + for (HeatMetaFirstLevelDefinition deploymentArtifact : deploymentArtifacts) { + String type = deploymentArtifact.getType(); + if (type.equals(ArtifactTypeEnum.HEAT.getType()) + || type.equals(ArtifactTypeEnum.HEAT_ENV.getType()) + || type.equals(ArtifactTypeEnum.HEAT_VOL.getType()) + || type.equals(ArtifactTypeEnum.HEAT_NET.getType())) { + File file = new File(artifactsFilePath + deploymentArtifact.getFileName()); + if (fileListFromArtifactsDirectory.contains(file)) { + fileList.add(file); + } else { + assertTrue("File " + file + " does not exist", false); + } + } + } + return fileList; + } + + private static synchronized Map getFilesPairMap(List generatedEnvFiles) { + + Map heatAndHeatEnvPairs = new HashMap<>(); + for (File file : generatedEnvFiles) { + String[] fileName = file.getName().split("\\."); + String currentKey = fileName[0]; + String currentExtension = fileName[1]; + HeatAndHeatEnvNamesPair pair; + if (!heatAndHeatEnvPairs.containsKey(currentKey)) { + pair = new HeatAndHeatEnvNamesPair(); + heatAndHeatEnvPairs.put(currentKey, pair); + } else { + pair = heatAndHeatEnvPairs.get(currentKey); + } + setFileToPair(file, currentExtension, pair); + } + return heatAndHeatEnvPairs; + } + + /** + * The method fill list of HeatWithParametersDefinition parameters + * + * @param deploymentArtifacts + * @return + */ + public static synchronized List extractHeatWithParametersDefinition(Map deploymentArtifacts) { + + List heatAndEnvLabelList = new ArrayList<>(); + + for (Entry artifactDefinitionChild : deploymentArtifacts.entrySet()) { + if (artifactDefinitionChild.getValue().getArtifactType().equals(ArtifactTypeEnum.HEAT_ENV.getType())) { + for (Entry artifactDefinitionParent : deploymentArtifacts.entrySet()) { + if (artifactDefinitionChild.getValue().getGeneratedFromId().equals(artifactDefinitionParent.getValue().getUniqueId())) { + String heatLabel = artifactDefinitionParent.getValue().getArtifactLabel(); + String heatArtifactType = artifactDefinitionParent.getValue().getArtifactType(); + String heatArtifactDisplayName = artifactDefinitionParent.getValue().getArtifactDisplayName(); + List heatParameterDefinition = artifactDefinitionParent.getValue().getHeatParameters(); + String heatEnvLabel = artifactDefinitionChild.getValue().getArtifactLabel(); + String heatEnvArtifactType = artifactDefinitionChild.getValue().getArtifactType(); + heatAndEnvLabelList.add(new HeatWithParametersDefinition(heatLabel, heatEnvLabel, heatArtifactType, heatEnvArtifactType, heatArtifactDisplayName, heatParameterDefinition)); + break; + } + } + } + } + return heatAndEnvLabelList; + } + + + private static synchronized void setFileToPair(File file, String currentExtension, HeatAndHeatEnvNamesPair pair) { + if (!currentExtension.equals("env")) { + pair.setHeatFileName(file); + } else { + pair.setHeatEnvFileName(file); + } + } + + private static synchronized Map generateDefaultEnvFiles(Map filesPairMap, String filePath) throws Exception { + + Map generatedEnvFilesMap = new HashMap<>(); + for (Entry pair : filesPairMap.entrySet()) { + Map> envParametersMap = getEnvParametersMap(pair); + File generatedEnvFile = createEnvFile(envParametersMap, new File(filePath + pair.getKey() + ".env")); + generatedEnvFilesMap.put(pair.getKey(), generatedEnvFile); + } + return generatedEnvFilesMap; + } + + private static synchronized File createEnvFile(Map> envParametersMap, File fileToWrite) throws IOException { + + FileHandling.writeToFile(fileToWrite, PARAMETERS + ":", 0); + FileHandling.writeToFile(fileToWrite, envParametersMap, 2); + return fileToWrite; + } + + private static synchronized Map> getEnvParametersMap(Entry pair) throws Exception { + File heatFileName = pair.getValue().getHeatFileName(); + File heatEnvFileName = pair.getValue().getHeatEnvFileName(); + Map> envParametersMap = new HashMap<>(); + fillParametersMapFromHeatFile(heatFileName, envParametersMap); + fillParametersMapFromHeatEnvFile(heatEnvFileName, envParametersMap); + return envParametersMap; + } + + private static synchronized void fillParametersMapFromHeatEnvFile(File heatEnvFileName, Map> envParametersMap) throws Exception { + if (heatEnvFileName != null) { + Map mapHeatEnvFileParameters = FileHandling.parseYamlFileToMapByPattern(heatEnvFileName, PARAMETERS); + for (Map.Entry parameter : mapHeatEnvFileParameters.entrySet()) { + String key = parameter.getKey(); + Pair pair; + if (envParametersMap.containsKey(key)) { + if (envParametersMap.get(key).left.equals("string") && parameter.getValue() != null) { + pair = Pair.create(envParametersMap.get(key).left, "\"" + parameter.getValue() + "\""); + } else if (envParametersMap.get(key).left.equals("string") && parameter.getValue() == null) { + pair = Pair.create(envParametersMap.get(key).left, ""); + } else if (parameter.getValue() == null) { + pair = Pair.create(envParametersMap.get(key).left, ""); + } else if (envParametersMap.get(key).left.equals("json") && parameter.getValue() != null) { + String pairValue = ""; + Gson gson = new Gson(); + if (parameter.getValue() instanceof java.util.LinkedHashMap) { + pairValue = gson.toJson(parameter.getValue()); + } + pair = Pair.create(envParametersMap.get(key).left, pairValue); + + } else if (envParametersMap.get(key).left.equals("json") && parameter.getValue() == null) { + pair = Pair.create(envParametersMap.get(key).left, ""); + } else { + pair = Pair.create(envParametersMap.get(key).left, parameter.getValue()); + } + envParametersMap.put(key, pair); + } + } + } + } + + @SuppressWarnings("unchecked") + private static synchronized void fillParametersMapFromHeatFile(File heatFileName, Map> envParametersMap) throws Exception { + Map mapHeatFileParameters = FileHandling.parseYamlFileToMapByPattern(heatFileName, PARAMETERS); + for (Map.Entry parameter : mapHeatFileParameters.entrySet()) { + Map value = (Map) parameter.getValue(); + Pair pair; + if (value.get("type").toString().equals("string") && value.get("default") != null) { + pair = Pair.create(value.get("type").toString(), "\"" + value.get("default") + "\""); + } else if (value.get("type").toString().equals("string") && value.get("default") == null) { + pair = Pair.create(value.get("type").toString(), ""); + } else if (value.get("default") == null) { + pair = Pair.create(value.get("type").toString(), ""); + } else { + pair = Pair.create(value.get("type").toString(), value.get("default")); + } + envParametersMap.put(parameter.getKey(), pair); + } + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProvider/OnbordingDataProviders.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProvider/OnbordingDataProviders.java index 3465d714f6..6594049fc5 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProvider/OnbordingDataProviders.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/dataProvider/OnbordingDataProviders.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,80 +31,80 @@ import java.util.List; public class OnbordingDataProviders { - protected static String filepath = FileHandling.getVnfRepositoryPath(); + private static final int NUMBER_OF_RANDOMLY_ONBOARD_VNF = 3; + protected static String filepath = FileHandling.getVnfRepositoryPath(); -// -----------------------dataProviders----------------------------------------- - @DataProvider(name = "randomVNF_List", parallel = false) - private static final Object[][] randomVnfList() throws Exception { - int randomElementNumber = 3; //how many VNFs to onboard randomly - List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); - List newRandomFileNamesFromFolder = getRandomElements(randomElementNumber, fileNamesFromFolder); - System.out.println(String.format("There are %s zip file(s) to test", newRandomFileNamesFromFolder.size())); - return provideData(newRandomFileNamesFromFolder, filepath); - } - - @DataProvider(name = "VNF_List" , parallel = true) - private static final Object[][] VnfList() throws Exception { - - List fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF); + // -----------------------dataProviders----------------------------------------- + @DataProvider(name = "randomVNF_List", parallel = false) + private static Object[][] randomVnfList() throws Exception { + int randomElementNumber = NUMBER_OF_RANDOMLY_ONBOARD_VNF; //how many VNFs to onboard randomly + List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); + List newRandomFileNamesFromFolder = getRandomElements(randomElementNumber, fileNamesFromFolder); + System.out.println(String.format("There are %s zip file(s) to test", newRandomFileNamesFromFolder.size())); + return provideData(newRandomFileNamesFromFolder, filepath); + } - System.out.println(String.format("There are %s zip file(s) to test", fileNamesFromFolder.size())); - return provideData(fileNamesFromFolder, filepath); - } + @DataProvider(name = "VNF_List", parallel = true) + private static Object[][] VnfList() throws Exception { - @DataProvider(name = "updateList") - private static final Object[][] updateList() throws Exception { + List fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF); - Object[][] objectArr = new Object[2][]; + System.out.println(String.format("There are %s zip file(s) to test", fileNamesFromFolder.size())); + return provideData(fileNamesFromFolder, filepath); + } - Object[][] filteredArObject = null; + @DataProvider(name = "updateList") + private static Object[][] updateList() throws Exception { - objectArr[0] = new Object[]{ "1-2016-20-visbc3vf-(VOIP)_v2.1.zip", "2-2016-20-visbc3vf-(VOIP)_v2.1_RenameResourceToShay.zip" }; - objectArr[1] = new Object[]{ "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip", "2-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0_Added2TestParameters.zip" }; + Object[][] objectArr = new Object[2][]; - filteredArObject = OnboardingUtils.filterObjectArrWithExcludedVnfs(objectArr); + Object[][] filteredArObject = null; - return filteredArObject; + objectArr[0] = new Object[]{"1-2016-20-visbc3vf-(VOIP)_v2.1.zip", "2-2016-20-visbc3vf-(VOIP)_v2.1_RenameResourceToShay.zip"}; + objectArr[1] = new Object[]{"1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip", "2-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0_Added2TestParameters.zip"}; + filteredArObject = OnboardingUtils.filterObjectArrWithExcludedVnfs(objectArr); - } + return filteredArObject; - // -----------------------factories----------------------------------------- + + } + + // -----------------------factories----------------------------------------- // @Factory(dataProvider = "VNF_List") // public Object[] OnbordingDataProviders(String filepath, String vnfFile){ // return new Object[] { new ToscaValidationTest(filepath, vnfFile)}; // } - - - -// -----------------------methods----------------------------------------- - public static Object[][] provideData(List fileNamesFromFolder, String filepath) { - - Object[][] arObject = new Object[fileNamesFromFolder.size()][]; - int index = 0; - for (Object obj : fileNamesFromFolder) { - arObject[index++] = new Object[] { filepath, obj }; - } - return arObject; - } - - public static List getRandomElements(int randomElementNumber, List fileNamesFromFolder) { - if(fileNamesFromFolder.size() == 0 || fileNamesFromFolder.size() < randomElementNumber){ - return null; - }else{ - List indexList = new ArrayList<>(); - List newRandomFileNamesFromFolder = new ArrayList<>(); - for(int i = 0; i < fileNamesFromFolder.size(); i++){ - indexList.add(i); - } - Collections.shuffle(indexList); - Integer[] randomArray = indexList.subList(0, randomElementNumber).toArray(new Integer[randomElementNumber]); - for(int i = 0; i < randomArray.length; i++){ - newRandomFileNamesFromFolder.add(fileNamesFromFolder.get(randomArray[i])); - } - return newRandomFileNamesFromFolder; - } - } + + + // -----------------------methods----------------------------------------- + static Object[][] provideData(List fileNamesFromFolder, String filepath) { + + Object[][] arObject = new Object[fileNamesFromFolder.size()][]; + int index = 0; + for (Object obj : fileNamesFromFolder) { + arObject[index++] = new Object[]{filepath, obj}; + } + return arObject; + } + + static List getRandomElements(int randomElementNumber, List fileNamesFromFolder) { + if (fileNamesFromFolder.size() == 0 || fileNamesFromFolder.size() < randomElementNumber) { + return null; + } else { + List indexList = new ArrayList<>(); + List newRandomFileNamesFromFolder = new ArrayList<>(); + for (int i = 0; i < fileNamesFromFolder.size(); i++) { + indexList.add(i); + } + Collections.shuffle(indexList); + Integer[] randomArray = indexList.subList(0, randomElementNumber).toArray(new Integer[randomElementNumber]); + for (Integer integer : randomArray) { + newRandomFileNamesFromFolder.add(fileNamesFromFolder.get(integer)); + } + return newRandomFileNamesFromFolder; + } + } // private static String[][] arrangeFilesVersionPairs(List filesArr) { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ArtifactInfo.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ArtifactInfo.java index 1302cb52af..db44155615 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ArtifactInfo.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ArtifactInfo.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,84 +22,84 @@ package org.openecomp.sdc.ci.tests.datatypes; public class ArtifactInfo { - private String filepath; - private String filename; - private String description; - private String artifactType; - private String artifactLabel; - private String artifactVersion; - - public ArtifactInfo(String filepath, String filename, String description, String artifactLabel, - String artifactType) { - super(); - this.filepath = filepath; - this.filename = filename; - this.description = description; - this.artifactType = artifactType; - this.artifactLabel = artifactLabel; - } - - public ArtifactInfo(String filepath, String filename, String description, String artifactLabel, - String artifactType, String artifactVersion) { - super(); - this.filepath = filepath; - this.filename = filename; - this.description = description; - this.artifactType = artifactType; - this.artifactLabel = artifactLabel; - this.artifactVersion = artifactVersion; - } - - public ArtifactInfo() { - super(); - } - - public String getArtifactVersion() { - return artifactVersion; - } - - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } - - public String getFilepath() { - return filepath; - } - - public void setFilepath(String filepath) { - this.filepath = filepath; - } - - public String getFilename() { - return filename; - } - - public void setFilename(String filename) { - this.filename = filename; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getArtifactType() { - return artifactType; - } - - public void setArtifactType(String artifactType) { - this.artifactType = artifactType; - } - - public String getArtifactLabel() { - return artifactLabel; - } - - public void setArtifactLabel(String artifactLabel) { - this.artifactLabel = artifactLabel; - } + private String filepath; + private String filename; + private String description; + private String artifactType; + private String artifactLabel; + private String artifactVersion; + + public ArtifactInfo(String filepath, String filename, String description, String artifactLabel, + String artifactType) { + super(); + this.filepath = filepath; + this.filename = filename; + this.description = description; + this.artifactType = artifactType; + this.artifactLabel = artifactLabel; + } + + public ArtifactInfo(String filepath, String filename, String description, String artifactLabel, + String artifactType, String artifactVersion) { + super(); + this.filepath = filepath; + this.filename = filename; + this.description = description; + this.artifactType = artifactType; + this.artifactLabel = artifactLabel; + this.artifactVersion = artifactVersion; + } + + public ArtifactInfo() { + super(); + } + + public String getArtifactVersion() { + return artifactVersion; + } + + public void setArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + } + + public String getFilepath() { + return filepath; + } + + public void setFilepath(String filepath) { + this.filepath = filepath; + } + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getArtifactType() { + return artifactType; + } + + public void setArtifactType(String artifactType) { + this.artifactType = artifactType; + } + + public String getArtifactLabel() { + return artifactLabel; + } + + public void setArtifactLabel(String artifactLabel) { + this.artifactLabel = artifactLabel; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CanvasElement.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CanvasElement.java index f0f22c4eb7..0ecc04bac5 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CanvasElement.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CanvasElement.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,76 +24,76 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; public final class CanvasElement { - private final String uniqueId; - private ImmutablePair location; - private LeftPanelCanvasItems normativeElementType; - private String elementType; - private String elementNameOnCanvas; - - CanvasElement(String name, ImmutablePair location, LeftPanelCanvasItems canvasItem) { - super(); - this.uniqueId = name; - this.location = location; - normativeElementType = canvasItem; - this.elementNameOnCanvas = generateCanvasName(name); - } - - CanvasElement(String name, ImmutablePair location, String canvasItem) { - super(); - this.uniqueId = name; - this.location = location; - elementType = canvasItem; - this.elementNameOnCanvas = generateCanvasNameFromCanvasItem(canvasItem); - } - - public CanvasElement(String name, ImmutablePair location) { - super(); - this.uniqueId = name; - this.location = location; - this.elementNameOnCanvas = generateCanvasName(name); - } - - public String generateCanvasName(String name) { - if(name.toLowerCase().contains("service")){ - return name.toLowerCase().substring(0, name.indexOf("_")) + "_proxy 0"; - } - return name.substring(0, name.indexOf("_")) + " 0"; - } - - public String generateCanvasNameFromCanvasItem(String name) { - if(name.toLowerCase().contains("service")){ - return name.toLowerCase() + "_proxy 0"; - } - return name + " 0"; - } - - public String getUniqueId() { - return uniqueId; - } - - public ImmutablePair getLocation() { - return location; - } - - public void setLocation(ImmutablePair location) { - this.location = location; - } - - public LeftPanelCanvasItems getNormativeElementType() { - return normativeElementType; - } - - public String getElementType() { - return elementType; - } - - public String getElementNameOnCanvas() { - return elementNameOnCanvas; - } - - public void setElementNameOnCanvas(String newName) { - elementNameOnCanvas = newName; - } + private final String uniqueId; + private ImmutablePair location; + private LeftPanelCanvasItems normativeElementType; + private String elementType; + private String elementNameOnCanvas; + + CanvasElement(String name, ImmutablePair location, LeftPanelCanvasItems canvasItem) { + super(); + this.uniqueId = name; + this.location = location; + normativeElementType = canvasItem; + this.elementNameOnCanvas = generateCanvasName(name); + } + + CanvasElement(String name, ImmutablePair location, String canvasItem) { + super(); + this.uniqueId = name; + this.location = location; + elementType = canvasItem; + this.elementNameOnCanvas = generateCanvasNameFromCanvasItem(canvasItem); + } + + public CanvasElement(String name, ImmutablePair location) { + super(); + this.uniqueId = name; + this.location = location; + this.elementNameOnCanvas = generateCanvasName(name); + } + + public String generateCanvasName(String name) { + if (name.toLowerCase().contains("service")) { + return name.toLowerCase().substring(0, name.indexOf("_")) + "_proxy 0"; + } + return name.substring(0, name.indexOf("_")) + " 0"; + } + + public String generateCanvasNameFromCanvasItem(String name) { + if (name.toLowerCase().contains("service")) { + return name.toLowerCase() + "_proxy 0"; + } + return name + " 0"; + } + + public String getUniqueId() { + return uniqueId; + } + + public ImmutablePair getLocation() { + return location; + } + + public void setLocation(ImmutablePair location) { + this.location = location; + } + + public LeftPanelCanvasItems getNormativeElementType() { + return normativeElementType; + } + + public String getElementType() { + return elementType; + } + + public String getElementNameOnCanvas() { + return elementNameOnCanvas; + } + + public void setElementNameOnCanvas(String newName) { + elementNameOnCanvas = newName; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CanvasManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CanvasManager.java index b3bf6c9fcb..985c84246d 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CanvasManager.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CanvasManager.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,497 +40,492 @@ import org.openqa.selenium.interactions.Actions; import org.testng.Assert; import org.testng.SkipException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; public final class CanvasManager { - private Map canvasElements; - private Actions actions; - private WebElement canvas; - private int reduceCanvasWidthFactor; - private CanvasElement canvasElement; - // Offsets Are used to find upper right corner of canvas element in order to - // connect links - private static final int CANVAS_VF_Y_OFFSET = 30; - private static final int CANVAS_VF_X_OFFSET = 18; // 14 - 27 - - private static final int CANVAS_NORMATIVE_ELEMENT_Y_OFFSET = 12; - private static final int CANVAS_NORMATIVE_ELEMENT_X_OFFSET = 7; + public static final int VIEW_BUTTON_X_DELTA = 30; + public static final int VIEW_BUTTON_Y_DELTA = 11; + public static final int DELTET_BUTTON_X_DELTA = 30; + public static final int CANVAS_ELEMENT_TYPE_SPLITER = 4; + public static final int MAX_WAIT_DIVIDER = 1000; + public static final int THREAD_SLEEP_TIME = 5000; + private Map canvasElements; + private Actions actions; + private WebElement canvas; + private int reduceCanvasWidthFactor; + private CanvasElement canvasElement; + // Offsets Are used to find upper right corner of canvas element in order to + // connect links + private static final int CANVAS_VF_Y_OFFSET = 30; + private static final int CANVAS_VF_X_OFFSET = 18; // 14 - 27 + + private static final int CANVAS_NORMATIVE_ELEMENT_Y_OFFSET = 12; + private static final int CANVAS_NORMATIVE_ELEMENT_X_OFFSET = 7; private static final int CANVAS_SERVICE_Y_OFFSET = 27; - private static final int CANVAS_SERVICE_X_OFFSET = 16; - - private CanvasManager() { - canvasElements = new HashMap<>(); - actions = new Actions(GeneralUIUtils.getDriver()); - canvas = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.CANVAS.getValue()); - try { - WebElement webElement = GeneralUIUtils - .getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.CANVAS_RIGHT_PANEL.getValue()); - reduceCanvasWidthFactor = webElement.getSize().width; - } catch (Exception e) { - reduceCanvasWidthFactor = 0; - } - } - - public static CanvasManager getCanvasManager() { - return new CanvasManager(); - } - - public List getCanvasElements() { - return canvasElements.values().stream().collect(Collectors.toList()); - } - - private void addCanvasElement(CanvasElement element) { - String prefix = element.getElementType(); - List canvasElementsFromSameTemplate = new ArrayList<>(); - - // collect all elements from from same template - for(CanvasElement currElement:canvasElements.values()){ - if(currElement.getElementNameOnCanvas().toLowerCase().startsWith(prefix.toLowerCase())){ - canvasElementsFromSameTemplate.add(currElement); - } - } - - // match element name to actual name on canvas - if( canvasElementsFromSameTemplate.size() > 0){ - String newName = prefix + " " + canvasElementsFromSameTemplate.size(); - element.setElementNameOnCanvas(newName); - } - - canvasElements.put(element.getUniqueId(), element); - } - - private void moveElementOnCanvas(CanvasElement canvasElement, ImmutablePair newLocation) - throws Exception { - GeneralUIUtils.waitForLoader(); - 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 moveToFreeLocation(String containerName) { - int maxWait = 5000; - int sumOfWaiting = 0; - int napPeriod = 200; - boolean isKeepWaiting = false; - while (!isKeepWaiting) { - ImmutablePair freePosition = getFreePosition(); - actions.moveToElement(canvas, freePosition.left, freePosition.right); - actions.clickAndHold(); - actions.release(); - actions.perform(); - isKeepWaiting = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText() - .equals(containerName); - sumOfWaiting += napPeriod; - if (sumOfWaiting > maxWait) { - Assert.fail("Can't click on VF"); - } - } - } - - public void clickOnCanvaElement(CanvasElement canvasElement) { -// actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); - ImmutablePair coordinates = getElementCoordinates(canvasElement.getElementNameOnCanvas()); - actions.moveToElement(canvas, coordinates.left, coordinates.right); - actions.clickAndHold(); - actions.release(); - actions.perform(); - GeneralUIUtils.ultimateWait(); - actions.click().perform(); - GeneralUIUtils.ultimateWait(); - - validateInstanceSelected(canvasElement); - ExtentTestActions.log(Status.INFO, String.format("Canvas element %s selected", canvasElement.getElementType())); - } - - public void openLinkPopupReqsCapsConnection(CanvasElement canvasElement) - { - ExtentTestActions.log(Status.INFO, "Open Link popup"); - clickOnCanvasLink(canvasElement); - int x = canvasElement.getLocation().getLeft() + 30; // view button x delta - int y = canvasElement.getLocation().getRight() + 11; // view button y delta - clickOnCanvasPosition(x,y); - GeneralUIUtils.ultimateWait(); - } - - public void openLinkPopupReqsCapsConnection(CanvasElement sourceElement, CanvasElement destElement) - { - ExtentTestActions.log(Status.INFO, "Open Link popup"); - ImmutablePair sourceCoordinates = getElementCoordinates(sourceElement.getElementNameOnCanvas()); - ImmutablePair destCoordinates = getElementCoordinates(destElement.getElementNameOnCanvas()); - ImmutablePair linkPosition = calcMidOfLink(sourceCoordinates, destCoordinates); - - clickOnCanvasPosition(linkPosition.left, linkPosition.right); // click on link - int x = linkPosition.left + 30; - int y = linkPosition.right + 11; - clickOnCanvasPosition(x,y); // click on view popup - GeneralUIUtils.ultimateWait(); - } - - public void closeLinkPopupReqsCapsConnection() - { - GeneralUIUtils.clickOnElementByTestId("Cancel"); -// GeneralUIUtils.ultimateWait(); - } - - public void clickSaveOnLinkPopup() - { - ExtentTestActions.log(Status.INFO, "Click save on link popup"); - GeneralUIUtils.clickOnElementByTestId("Save"); -// GeneralUIUtils.ultimateWait(); - } - - public void deleteLinkPopupReqsCapsConnection(CanvasElement canvasElement) - { - ExtentTestActions.log(Status.INFO, "Delete Link "); - clickOnCanvasLink(canvasElement); - int x = canvasElement.getLocation().getLeft() + 30; // delete button x delta - int y = canvasElement.getLocation().getRight() + 30; // delete button x delta - clickOnCanvasPosition(x,y); - } - - public void deleteLinkPopupReqsCapsConnection(CanvasElement sourceElement, CanvasElement destElement) - { - ExtentTestActions.log(Status.INFO, "Delete Link "); - ImmutablePair sourceCoordinates = getElementCoordinates(sourceElement.getElementNameOnCanvas()); - ImmutablePair destCoordinates = getElementCoordinates(destElement.getElementNameOnCanvas()); - ImmutablePair linkPosition = calcMidOfLink(sourceCoordinates, destCoordinates); - clickOnCanvasPosition(linkPosition.left, linkPosition.right); // click on link - int x = linkPosition.left + 30; // delete button x delta - int y = linkPosition.right + 30; // delete button y delta - clickOnCanvasPosition(x,y); - } - - public void clickOnCanvasLink(CanvasElement canvasElement) { - actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); - actions.click().perform(); - GeneralUIUtils.ultimateWait(); - } - - public void clickOnCanvasPosition(int x, int y) { - - try { - actions.moveToElement(canvas, x, y); - actions.click(); - actions.perform(); - GeneralUIUtils.ultimateWait(); - } - catch (Exception e) - { - System.out.println(e); - } - } - - public void moveElementOnCanvas(CanvasElement canvasElement) throws Exception { - moveElementOnCanvas(canvasElement, getFreePosition()); - } - - public void deleteElementFromCanvas(CanvasElement canvasElement) throws Exception { - GeneralUIUtils.waitForLoader(); - actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); - actions.click(); - actions.perform(); - ExtentTestActions.log(Status.INFO, String.format("Removing canvas element %s ", canvasElement.getElementType())); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.DELETE_INSTANCE_BUTTON.getValue()) - .click(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.DELETE_INSTANCE_CANCEL.getValue()).click(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.DELETE_INSTANCE_BUTTON.getValue()) - .click(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.DELETE_INSTANCE_OK.getValue()).click(); - canvasElements.remove(canvasElement.getUniqueId()); - GeneralUIUtils.ultimateWait(); - if (canvasElement.getElementType().contains("-")){ - ExtentTestActions.log(Status.INFO, String.format("Canvas element %s is removed", canvasElement.getElementType().split("-")[4])); - } - else{ - ExtentTestActions.log(Status.INFO, String.format("Canvas element %s is removed", canvasElement.getElementType())); - } - } - - private WebElement findClickElement(String dataTestId) { - int attempts = 0; - while (attempts < 2) { - try { - return GeneralUIUtils.getWebElementByTestID(dataTestId); - } catch (StaleElementReferenceException e) { - } - attempts++; - } - return null; - } - - public CanvasElement createElementOnCanvas(String elementName) throws Exception { - String actionDuration = GeneralUIUtils.getActionDuration(() -> { - try { - canvasElement = createElementOnCanvasWithoutDuration(elementName); - } catch (Exception e) { - e.printStackTrace(); - } - }); - - if (canvasElement != null){ - ExtentTestActions.log(Status.INFO, String.format("The element %s should now be on the canvas", elementName), actionDuration); - } - return canvasElement; - } - - private CanvasElement createElementOnCanvasWithoutDuration(String elementDataTestId) throws Exception { - try { - CompositionPage.searchForElement(elementDataTestId); - WebElement element = findClickElement(elementDataTestId); - ImmutablePair freePosition = getFreePosition(); - actions.moveToElement(element, 20, 20); - actions.clickAndHold(); - actions.moveToElement(canvas, freePosition.left, freePosition.right); - actions.release(); - actions.perform(); - GeneralUIUtils.ultimateWait(); - String uniqueId = elementDataTestId + "_" + UUID.randomUUID().toString(); - CanvasElement canvasElement = new CanvasElement(uniqueId, freePosition, elementDataTestId); - addCanvasElement(canvasElement); - GeneralUIUtils.ultimateWait(); - return canvasElement; - } - catch (Exception e) { - System.out.println("Can't create element on canvas"); - e.printStackTrace(); - } - return null; - } - - public CanvasElement createElementOnCanvas(LeftPanelCanvasItems canvasItem) throws Exception { - return createElementOnCanvas(canvasItem.getValue()); - } - - private ImmutablePair getFreePosition() { - ImmutablePair randomPosition = null; - boolean freePosition = false; - int minSpace = 150; - while (!freePosition) { - ImmutablePair 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 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(xElement, yElement); - } - - // Will work only if 2 elements are big sized (VF size), if one of the elements is Small use the function linkElements - public void linkElements(CanvasElement firstElement, CanvasElement secondElement) throws Exception { - ExtentTestActions.log(Status.INFO, String.format("Linking between the %s instance and the %s instance.", firstElement.getElementType(), secondElement.getElementType())); - drawSimpleLink(firstElement.getElementNameOnCanvas(), secondElement.getElementNameOnCanvas()); - selectReqAndCapAndConnect(); - ExtentTestActions.log(Status.INFO, String.format("The instances %s and %s should now be connected.", firstElement.getElementType(), secondElement.getElementType())); - } - - // old version, depricated - public void linkElements(CanvasElement firstElement, CircleSize firstElementSize, CanvasElement secondElement, CircleSize secondElementSize) throws Exception { - drawSimpleLink(firstElement,firstElementSize, secondElement,secondElementSize); - selectReqAndCapAndConnect(); - ExtentTestActions.log(Status.INFO, String.format("The instances %s and %s should now be connected.", firstElement.getElementType(), secondElement.getElementType())); - } - - public void linkElements(String firstElement, String secondElement) throws Exception { - drawSimpleLink(firstElement, secondElement); - selectReqAndCapAndConnect(); - ExtentTestActions.log(Status.INFO, String.format("The instances %s and %s should now be connected.", firstElement, secondElement)); - } - - // use JS to get coordinates of elements - private void drawSimpleLink(String firstElement, String secondElement) { - ImmutablePair firstElementCoordinates = getGreenDotCoordinatesOfElement(firstElement); - ImmutablePair secondElementCoordinates = getElementCoordinates(secondElement); - - actions.moveToElement(canvas, firstElementCoordinates.left, firstElementCoordinates.right); - actions.perform(); - actions.moveToElement(canvas, firstElementCoordinates.left, firstElementCoordinates.right); - actions.clickAndHold(); - actions.moveToElement(canvas, secondElementCoordinates.left, secondElementCoordinates.right); - actions.release(); - actions.perform(); - GeneralUIUtils.ultimateWait(); - } - - private void selectReqAndCapAndConnect() throws Exception { - addFirstReqOrCapAndPressNext(); - addFirstReqOrCapAndPressNext(); - linkMenuClickOnFinishButton(); - } - - private void addFirstReqOrCapAndPressNext() throws Exception { - addFirstReqOrCap(); - linkMenuClickOnNextButton(); - } - - private void addFirstReqOrCap() { - GeneralUIUtils.getWebElementsListByClassName(DataTestIdEnum.LinkMenuItems.LINK_ITEM_CAP_Or_REQ.getValue()).get(0).click(); - } - - private void linkMenuClickOnNextButton() throws Exception { - GeneralUIUtils.clickOnElementByText("Next"); - GeneralUIUtils.ultimateWait(); - } - - private void linkMenuClickOnFinishButton() throws Exception { - GeneralUIUtils.clickOnElementByText("Finish"); - GeneralUIUtils.ultimateWait(); - } - - - private void drawSimpleLink(CanvasElement firstElement, CanvasElement secondElement) throws Exception { - int yOffset = CANVAS_VF_Y_OFFSET; - int xOffset = CANVAS_VF_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.ultimateWait(); - } - - private void drawSimpleLink(CanvasElement firstElement, CircleSize firstElementSize, CanvasElement secondElement, CircleSize secondElementSize) throws Exception { - ExtentTestActions.log(Status.INFO, String.format("Linking between the %s instance and the %s instance.", firstElement.getElementType(), secondElement.getElementType())); - Integer yOffset = getCircleOffset(firstElementSize).right; - Integer xOffset = getCircleOffset(firstElementSize).left; - firstElement.getElementType(); - - - actions.moveToElement(canvas, firstElement.getLocation().left + xOffset, - firstElement.getLocation().right - yOffset); - - actions.clickAndHold(); - - yOffset = getCircleOffset(secondElementSize).right; - xOffset = getCircleOffset(secondElementSize).left; - - actions.moveToElement(canvas, secondElement.getLocation().left + xOffset, secondElement.getLocation().right - yOffset); - actions.release(); - actions.build(); - actions.perform(); - GeneralUIUtils.ultimateWait(); - } - - private Pair getCircleOffset(CircleSize circleSize) - { - Pair circleSizes; - if(circleSize.equals(CircleSize.VF)) - { - circleSizes = new Pair (CANVAS_VF_X_OFFSET,CANVAS_VF_Y_OFFSET); - } - else if (circleSize.equals(CircleSize.NORMATIVE)) - { - circleSizes = new Pair (CANVAS_NORMATIVE_ELEMENT_X_OFFSET,CANVAS_NORMATIVE_ELEMENT_Y_OFFSET); - } - else - { - circleSizes = new Pair (CANVAS_SERVICE_X_OFFSET,CANVAS_SERVICE_Y_OFFSET); - } - return circleSizes; - } - - public String updateElementNameInCanvas(CanvasElement canvasElement, String newInstanceName) throws Exception { - GeneralUIUtils.ultimateWait();; - clickOnCanvaElement(canvasElement); - GeneralUIUtils.getWebElementBy(By.id("editPencil")).click(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.RENAME_INSTANCE_CANCEL.getValue()).click(); - GeneralUIUtils.getWebElementBy(By.id("editPencil")).click(); - WebElement instanceNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.INSTANCE_NAME_FIELD.getValue()); - String oldInstanceName = instanceNameField.getAttribute("value"); - instanceNameField.clear(); - instanceNameField.sendKeys(newInstanceName); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.RENAME_INSTANCE_OK.getValue()).click(); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("w-sdc-modal-resource-instance-name")); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Name of element instance changed from %s to %s", oldInstanceName, newInstanceName)); - return oldInstanceName; - } - - /** - * @param canvasElement - * Validate that instance was selected on right sidebar - */ - public void validateInstanceSelected(CanvasElement canvasElement) { - long maxWait = 5000; - long sumOfWaiting = 0; - long napPeriod = 200; - boolean isInstanceSelected; - do { - isInstanceSelected = CompositionPage.getSelectedInstanceName().toLowerCase().contains(canvasElement.getElementType().toLowerCase()); - - if (!isInstanceSelected) { - try { - TimeUnit.MILLISECONDS.sleep(napPeriod); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - sumOfWaiting += napPeriod; - if (sumOfWaiting > maxWait) { - throw new SkipException(String.format("Bug 342260, can't select instance properly, waited for %s seconds after click on instance", (int) (maxWait/1000))); - } - } while (!isInstanceSelected); - } - - public void validateLinkIsSelected() { - long maxWait = 5000; - long sumOfWaiting = 0; - long napPeriod = 200; - boolean isInstanceSelected; - do { - isInstanceSelected = GeneralUIUtils.isWebElementExistByClass("w-sdc-menu-item w-sdc-canvas-menu-item-view"); - - if (!isInstanceSelected) { - try { - TimeUnit.MILLISECONDS.sleep(napPeriod); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - sumOfWaiting += napPeriod; - if (sumOfWaiting > maxWait) { - Assert.fail(String.format("Can't select link properly, waited for %s seconds", (int) (maxWait/1000))); - } - } while (!isInstanceSelected); - } - - private void selectReqCapByName(String reqCapName) - { - GeneralUIUtils.clickOnElementByText(reqCapName); + private static final int CANVAS_SERVICE_X_OFFSET = 16; + + private CanvasManager() { + canvasElements = new HashMap<>(); + actions = new Actions(GeneralUIUtils.getDriver()); + canvas = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.CANVAS.getValue()); + try { + WebElement webElement = GeneralUIUtils + .getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.CANVAS_RIGHT_PANEL.getValue()); + reduceCanvasWidthFactor = webElement.getSize().width; + } catch (Exception e) { + reduceCanvasWidthFactor = 0; + } + } + + public static CanvasManager getCanvasManager() { + return new CanvasManager(); + } + + public List getCanvasElements() { + return canvasElements.values().stream().collect(Collectors.toList()); + } + + private void addCanvasElement(CanvasElement element) { + String prefix = element.getElementType(); + List canvasElementsFromSameTemplate = new ArrayList<>(); + + // collect all elements from from same template + for (CanvasElement currElement : canvasElements.values()) { + if (currElement.getElementNameOnCanvas().toLowerCase().startsWith(prefix.toLowerCase())) { + canvasElementsFromSameTemplate.add(currElement); + } + } + + // match element name to actual name on canvas + if (canvasElementsFromSameTemplate.size() > 0) { + String newName = prefix + " " + canvasElementsFromSameTemplate.size(); + element.setElementNameOnCanvas(newName); + } + + canvasElements.put(element.getUniqueId(), element); + } + + private void moveElementOnCanvas(CanvasElement canvasElement, ImmutablePair newLocation) + throws Exception { + GeneralUIUtils.waitForLoader(); + 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 moveToFreeLocation(String containerName) { + final int maxWait = 5000; + final int napPeriod = 200; + int sumOfWaiting = 0; + boolean isKeepWaiting = false; + while (!isKeepWaiting) { + ImmutablePair freePosition = getFreePosition(); + actions.moveToElement(canvas, freePosition.left, freePosition.right); + actions.clickAndHold(); + actions.release(); + actions.perform(); + isKeepWaiting = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText() + .equals(containerName); + sumOfWaiting += napPeriod; + if (sumOfWaiting > maxWait) { + Assert.fail("Can't click on VF"); + } + } + } + + public void clickOnCanvaElement(CanvasElement canvasElement) { + ImmutablePair coordinates = getElementCoordinates(canvasElement.getElementNameOnCanvas()); + actions.moveToElement(canvas, coordinates.left, coordinates.right); + actions.clickAndHold(); + actions.release(); + actions.perform(); + GeneralUIUtils.ultimateWait(); + actions.click().perform(); + GeneralUIUtils.ultimateWait(); + + validateInstanceSelected(canvasElement); + ExtentTestActions.log(Status.INFO, String.format("Canvas element %s selected", canvasElement.getElementType())); + } + + public void openLinkPopupReqsCapsConnection(CanvasElement canvasElement) { + ExtentTestActions.log(Status.INFO, "Open Link popup"); + clickOnCanvasLink(canvasElement); + int x = canvasElement.getLocation().getLeft() + VIEW_BUTTON_X_DELTA; + int y = canvasElement.getLocation().getRight() + VIEW_BUTTON_Y_DELTA; + clickOnCanvasPosition(x, y); + GeneralUIUtils.ultimateWait(); + } + + public void openLinkPopupReqsCapsConnection(CanvasElement sourceElement, CanvasElement destElement) { + ExtentTestActions.log(Status.INFO, "Open Link popup"); + ImmutablePair sourceCoordinates = getElementCoordinates(sourceElement.getElementNameOnCanvas()); + ImmutablePair destCoordinates = getElementCoordinates(destElement.getElementNameOnCanvas()); + ImmutablePair linkPosition = calcMidOfLink(sourceCoordinates, destCoordinates); + + clickOnCanvasPosition(linkPosition.left, linkPosition.right); // click on link + int x = linkPosition.left + VIEW_BUTTON_X_DELTA; + int y = linkPosition.right + VIEW_BUTTON_Y_DELTA; + clickOnCanvasPosition(x, y); // click on view popup + GeneralUIUtils.ultimateWait(); + } + + public void closeLinkPopupReqsCapsConnection() { + GeneralUIUtils.clickOnElementByTestId("Cancel"); + //GeneralUIUtils.ultimateWait(); + } + + public void clickSaveOnLinkPopup() { + ExtentTestActions.log(Status.INFO, "Click save on link popup"); + GeneralUIUtils.clickOnElementByTestId("Save"); + //GeneralUIUtils.ultimateWait(); + } + + public void deleteLinkPopupReqsCapsConnection(CanvasElement canvasElement) { + ExtentTestActions.log(Status.INFO, "Delete Link "); + clickOnCanvasLink(canvasElement); + int x = canvasElement.getLocation().getLeft() + DELTET_BUTTON_X_DELTA; + int y = canvasElement.getLocation().getRight() + DELTET_BUTTON_X_DELTA; + clickOnCanvasPosition(x, y); + } + + public void deleteLinkPopupReqsCapsConnection(CanvasElement sourceElement, CanvasElement destElement) { + ExtentTestActions.log(Status.INFO, "Delete Link "); + ImmutablePair sourceCoordinates = getElementCoordinates(sourceElement.getElementNameOnCanvas()); + ImmutablePair destCoordinates = getElementCoordinates(destElement.getElementNameOnCanvas()); + ImmutablePair linkPosition = calcMidOfLink(sourceCoordinates, destCoordinates); + clickOnCanvasPosition(linkPosition.left, linkPosition.right); // click on link + int x = linkPosition.left + DELTET_BUTTON_X_DELTA; + int y = linkPosition.right + DELTET_BUTTON_X_DELTA; + clickOnCanvasPosition(x, y); + } + + public void clickOnCanvasLink(CanvasElement canvasElement) { + actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); + actions.click().perform(); GeneralUIUtils.ultimateWait(); } - private void selectTypeOfReqCap(String dataTestId, String reqCapType) - { + public void clickOnCanvasPosition(int x, int y) { + + try { + actions.moveToElement(canvas, x, y); + actions.click(); + actions.perform(); + GeneralUIUtils.ultimateWait(); + } catch (Exception e) { + System.out.println(e); + } + } + + public void moveElementOnCanvas(CanvasElement canvasElement) throws Exception { + moveElementOnCanvas(canvasElement, getFreePosition()); + } + + public void deleteElementFromCanvas(CanvasElement canvasElement) throws Exception { + GeneralUIUtils.waitForLoader(); + actions.moveToElement(canvas, canvasElement.getLocation().left, canvasElement.getLocation().right); + actions.click(); + actions.perform(); + ExtentTestActions.log(Status.INFO, String.format("Removing canvas element %s ", canvasElement.getElementType())); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.DELETE_INSTANCE_BUTTON.getValue()) + .click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.DELETE_INSTANCE_CANCEL.getValue()).click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.DELETE_INSTANCE_BUTTON.getValue()) + .click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.DELETE_INSTANCE_OK.getValue()).click(); + canvasElements.remove(canvasElement.getUniqueId()); + GeneralUIUtils.ultimateWait(); + if (canvasElement.getElementType().contains("-")) { + ExtentTestActions.log(Status.INFO, String.format( + "Canvas element %s is removed", + canvasElement.getElementType().split("-")[CANVAS_ELEMENT_TYPE_SPLITER])); + } else { + ExtentTestActions.log(Status.INFO, String.format( + "Canvas element %s is removed", + canvasElement.getElementType())); + } + } + + private WebElement findClickElement(String dataTestId) { + int attempts = 0; + while (attempts < 2) { + try { + return GeneralUIUtils.getWebElementByTestID(dataTestId); + } catch (StaleElementReferenceException e) { + } + attempts++; + } + return null; + } + + public CanvasElement createElementOnCanvas(String elementName) throws Exception { + String actionDuration = GeneralUIUtils.getActionDuration(() -> { + try { + canvasElement = createElementOnCanvasWithoutDuration(elementName); + } catch (Exception e) { + e.printStackTrace(); + } + }); + + if (canvasElement != null) { + ExtentTestActions.log(Status.INFO, String.format("The element %s should now be on the canvas", elementName), actionDuration); + } + return canvasElement; + } + + private CanvasElement createElementOnCanvasWithoutDuration(String elementDataTestId) throws Exception { + final int offset = 20; + try { + CompositionPage.searchForElement(elementDataTestId); + WebElement element = findClickElement(elementDataTestId); + ImmutablePair freePosition = getFreePosition(); + actions.moveToElement(element, offset, offset); + actions.clickAndHold(); + actions.moveToElement(canvas, freePosition.left, freePosition.right); + actions.release(); + actions.perform(); + GeneralUIUtils.ultimateWait(); + String uniqueId = elementDataTestId + "_" + UUID.randomUUID().toString(); + CanvasElement canvasElement = new CanvasElement(uniqueId, freePosition, elementDataTestId); + addCanvasElement(canvasElement); + GeneralUIUtils.ultimateWait(); + return canvasElement; + } catch (Exception e) { + System.out.println("Can't create element on canvas"); + e.printStackTrace(); + } + return null; + } + + public CanvasElement createElementOnCanvas(LeftPanelCanvasItems canvasItem) throws Exception { + return createElementOnCanvas(canvasItem.getValue()); + } + + private ImmutablePair getFreePosition() { + ImmutablePair randomPosition = null; + boolean freePosition = false; + final int minSpace = 150; + while (!freePosition) { + ImmutablePair 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 getRandomPosition() { + final 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(xElement, yElement); + } + + // Will work only if 2 elements are big sized (VF size), if one of the elements is Small use the function linkElements + public void linkElements(CanvasElement firstElement, CanvasElement secondElement) throws Exception { + ExtentTestActions.log(Status.INFO, String.format("Linking between the %s instance and the %s instance.", firstElement.getElementType(), secondElement.getElementType())); + drawSimpleLink(firstElement.getElementNameOnCanvas(), secondElement.getElementNameOnCanvas()); + selectReqAndCapAndConnect(); + ExtentTestActions.log(Status.INFO, String.format("The instances %s and %s should now be connected.", firstElement.getElementType(), secondElement.getElementType())); + } + + // old version, depricated + public void linkElements(CanvasElement firstElement, CircleSize firstElementSize, CanvasElement secondElement, CircleSize secondElementSize) throws Exception { + drawSimpleLink(firstElement, firstElementSize, secondElement, secondElementSize); + selectReqAndCapAndConnect(); + ExtentTestActions.log(Status.INFO, String.format("The instances %s and %s should now be connected.", firstElement.getElementType(), secondElement.getElementType())); + } + + public void linkElements(String firstElement, String secondElement) throws Exception { + drawSimpleLink(firstElement, secondElement); + selectReqAndCapAndConnect(); + ExtentTestActions.log(Status.INFO, String.format("The instances %s and %s should now be connected.", firstElement, secondElement)); + } + + // use JS to get coordinates of elements + private void drawSimpleLink(String firstElement, String secondElement) { + ImmutablePair firstElementCoordinates = getGreenDotCoordinatesOfElement(firstElement); + ImmutablePair secondElementCoordinates = getElementCoordinates(secondElement); + + actions.moveToElement(canvas, firstElementCoordinates.left, firstElementCoordinates.right); + actions.perform(); + actions.moveToElement(canvas, firstElementCoordinates.left, firstElementCoordinates.right); + actions.clickAndHold(); + actions.moveToElement(canvas, secondElementCoordinates.left, secondElementCoordinates.right); + actions.release(); + actions.perform(); + GeneralUIUtils.ultimateWait(); + } + + private void selectReqAndCapAndConnect() throws Exception { + addFirstReqOrCapAndPressNext(); + addFirstReqOrCapAndPressNext(); + linkMenuClickOnFinishButton(); + } + + private void addFirstReqOrCapAndPressNext() throws Exception { + addFirstReqOrCap(); + linkMenuClickOnNextButton(); + } + + private void addFirstReqOrCap() { + GeneralUIUtils.getWebElementsListByClassName(DataTestIdEnum.LinkMenuItems.LINK_ITEM_CAP_Or_REQ.getValue()).get(0).click(); + } + + private void linkMenuClickOnNextButton() throws Exception { + GeneralUIUtils.clickOnElementByText("Next"); + GeneralUIUtils.ultimateWait(); + } + + private void linkMenuClickOnFinishButton() throws Exception { + GeneralUIUtils.clickOnElementByText("Finish"); + GeneralUIUtils.ultimateWait(); + } + + + private void drawSimpleLink(CanvasElement firstElement, CanvasElement secondElement) throws Exception { + int yOffset = CANVAS_VF_Y_OFFSET; + int xOffset = CANVAS_VF_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.ultimateWait(); + } + + private void drawSimpleLink(CanvasElement firstElement, CircleSize firstElementSize, CanvasElement secondElement, CircleSize secondElementSize) throws Exception { + ExtentTestActions.log(Status.INFO, String.format("Linking between the %s instance and the %s instance.", firstElement.getElementType(), secondElement.getElementType())); + Integer yOffset = getCircleOffset(firstElementSize).right; + Integer xOffset = getCircleOffset(firstElementSize).left; + firstElement.getElementType(); + + + actions.moveToElement(canvas, firstElement.getLocation().left + xOffset, + firstElement.getLocation().right - yOffset); + + actions.clickAndHold(); + + yOffset = getCircleOffset(secondElementSize).right; + xOffset = getCircleOffset(secondElementSize).left; + + actions.moveToElement(canvas, secondElement.getLocation().left + xOffset, secondElement.getLocation().right - yOffset); + actions.release(); + actions.build(); + actions.perform(); + GeneralUIUtils.ultimateWait(); + } + + private Pair getCircleOffset(CircleSize circleSize) { + Pair circleSizes; + if (circleSize.equals(CircleSize.VF)) { + circleSizes = new Pair(CANVAS_VF_X_OFFSET, CANVAS_VF_Y_OFFSET); + } else if (circleSize.equals(CircleSize.NORMATIVE)) { + circleSizes = new Pair(CANVAS_NORMATIVE_ELEMENT_X_OFFSET, CANVAS_NORMATIVE_ELEMENT_Y_OFFSET); + } else { + circleSizes = new Pair(CANVAS_SERVICE_X_OFFSET, CANVAS_SERVICE_Y_OFFSET); + } + return circleSizes; + } + + public String updateElementNameInCanvas(CanvasElement canvasElement, String newInstanceName) { + GeneralUIUtils.ultimateWait(); + clickOnCanvaElement(canvasElement); + GeneralUIUtils.getWebElementBy(By.id("editPencil")).click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.RENAME_INSTANCE_CANCEL.getValue()).click(); + GeneralUIUtils.getWebElementBy(By.id("editPencil")).click(); + WebElement instanceNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralCanvasItems.INSTANCE_NAME_FIELD.getValue()); + String oldInstanceName = instanceNameField.getAttribute("value"); + instanceNameField.clear(); + instanceNameField.sendKeys(newInstanceName); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.RENAME_INSTANCE_OK.getValue()).click(); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("w-sdc-modal-resource-instance-name")); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Name of element instance changed from %s to %s", oldInstanceName, newInstanceName)); + return oldInstanceName; + } + + /** + * @param canvasElement Validate that instance was selected on right sidebar + */ + private void validateInstanceSelected(CanvasElement canvasElement) { + final long maxWait = 5000; + final long napPeriod = 200; + long sumOfWaiting = 0; + boolean isInstanceSelected; + do { + isInstanceSelected = CompositionPage.getSelectedInstanceName().toLowerCase().contains(canvasElement.getElementType().toLowerCase()); + + if (!isInstanceSelected) { + try { + TimeUnit.MILLISECONDS.sleep(napPeriod); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + sumOfWaiting += napPeriod; + if (sumOfWaiting > maxWait) { + throw new SkipException(String.format("Bug 342260, can't select instance properly, waited for %s seconds after click on instance", (int) (maxWait / MAX_WAIT_DIVIDER))); + } + } while (!isInstanceSelected); + } + + public void validateLinkIsSelected() { + final long maxWait = 5000; + final long napPeriod = 200; + long sumOfWaiting = 0; + boolean isInstanceSelected; + do { + isInstanceSelected = GeneralUIUtils.isWebElementExistByClass("w-sdc-menu-item w-sdc-canvas-menu-item-view"); + + if (!isInstanceSelected) { + try { + TimeUnit.MILLISECONDS.sleep(napPeriod); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + sumOfWaiting += napPeriod; + if (sumOfWaiting > maxWait) { + Assert.fail(String.format("Can't select link properly, waited for %s seconds", (int) (maxWait / MAX_WAIT_DIVIDER))); + } + } while (!isInstanceSelected); + } + + private void selectReqCapByName(String reqCapName) { + GeneralUIUtils.clickOnElementByText(reqCapName); + GeneralUIUtils.ultimateWait(); + } + + private void selectTypeOfReqCap(String dataTestId, String reqCapType) { GeneralUIUtils.selectByValueTextContained(dataTestId, reqCapType); - } + } - public void linkElementsAndSelectCapReqTypeAndCapReqName(CanvasElement firstElement, CanvasElement secondElement, ConnectionWizardPopUpObject connectionWizardPopUpObject) throws Exception { + public void linkElementsAndSelectCapReqTypeAndCapReqName(CanvasElement firstElement, CanvasElement secondElement, ConnectionWizardPopUpObject connectionWizardPopUpObject) throws Exception { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating link between %s and %s", firstElement.getElementType(), secondElement.getElementType())); -// drawSimpleLink(firstElement, firstElementSize, secondElement, secondElementSize); drawSimpleLink(firstElement.getElementNameOnCanvas(), secondElement.getElementNameOnCanvas()); - selectTypeOfReqCap(DataTestIdEnum.LinkMenuItems.REQ_CAP_SELECT_DATA_TESTS_ID.getValue(),connectionWizardPopUpObject.getCapabilityTypeSecondItem()); + selectTypeOfReqCap(DataTestIdEnum.LinkMenuItems.REQ_CAP_SELECT_DATA_TESTS_ID.getValue(), connectionWizardPopUpObject.getCapabilityTypeSecondItem()); addFirstReqOrCapAndPressNext(); selectReqCapByName(connectionWizardPopUpObject.getCapabilityNameSecondItem()); linkMenuClickOnNextButton(); @@ -540,27 +535,26 @@ public final class CanvasManager { public Map linkElementsWithCapPropAssignment(CanvasElement firstElement, CanvasElement secondElement, ConnectionWizardPopUpObject connectionWizardPopUpObject) throws Exception { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating link between %s and %s", firstElement.getElementType(), secondElement.getElementType())); drawSimpleLink(firstElement.getElementNameOnCanvas(), secondElement.getElementNameOnCanvas()); - selectTypeOfReqCap(DataTestIdEnum.LinkMenuItems.REQ_CAP_SELECT_DATA_TESTS_ID.getValue(),connectionWizardPopUpObject.getCapabilityTypeSecondItem()); + selectTypeOfReqCap(DataTestIdEnum.LinkMenuItems.REQ_CAP_SELECT_DATA_TESTS_ID.getValue(), connectionWizardPopUpObject.getCapabilityTypeSecondItem()); addFirstReqOrCapAndPressNext(); selectReqCapByName(connectionWizardPopUpObject.getCapabilityNameSecondItem()); linkMenuClickOnNextButton(); Map mapOfValues = connectionWizardAssignCapPropValues(); linkMenuClickOnFinishButton(); - Thread.sleep(5000); - return mapOfValues; + Thread.sleep(THREAD_SLEEP_TIME); + return mapOfValues; } - - public Map connectionWizardAssignCapPropValues() throws Exception{ - //get list of capability property value fields data-tests-ids in connection wizard - List valueField = getListOfValueFieldIDs(); + public Map connectionWizardAssignCapPropValues() throws Exception { + //get list of capability property value fields data-tests-ids in connection wizard + List valueField = getListOfValueFieldIDs(); //get map of field ids and their values, fill in values if empty - Map propValues = getMapOfCapPropValues(valueField, true); + Map propValues = getMapOfCapPropValues(valueField, true); return propValues; } - public Map connectionWizardCollectCapPropValues() throws Exception{ + public Map connectionWizardCollectCapPropValues() throws Exception { //get list of capability property value fields data-tests-ids in connection wizard List valueField = getListOfValueFieldIDs(); //get map of field ids and their values, collect existing values @@ -568,27 +562,27 @@ public final class CanvasManager { return propValues; } - private List getListOfValueFieldIDs() { - String propName = GeneralUIUtils.getWebElementsListByContainsClassName("multiline-ellipsis-content").get(0).getText(); - List valueNameElement = GeneralUIUtils.findElementsByXpath("//div[@class='dynamic-property-row nested-level-1']/div[1]"); - List valueName = new ArrayList<>(); - for(int i=0; i < valueNameElement.size(); i++){ - valueName.add(valueNameElement.get(i).getText()); - } - //get list of value field names as appear in data-tests-id - List valueField = new ArrayList<>(); - for(int i=0; i < valueName.size(); i++){ - valueField.add(PropertyNameBuilder.buildIComplexField(propName, valueName.get(i))); - } - return valueField; - } - - private Map getMapOfCapPropValues(List valueField, boolean isValueAssign) throws Exception { + private List getListOfValueFieldIDs() { + String propName = GeneralUIUtils.getWebElementsListByContainsClassName("multiline-ellipsis-content").get(0).getText(); + List valueNameElement = GeneralUIUtils.findElementsByXpath("//div[@class='dynamic-property-row nested-level-1']/div[1]"); + List valueName = new ArrayList<>(); + for (int i = 0; i < valueNameElement.size(); i++) { + valueName.add(valueNameElement.get(i).getText()); + } + //get list of value field names as appear in data-tests-id + List valueField = new ArrayList<>(); + for (int i = 0; i < valueName.size(); i++) { + valueField.add(PropertyNameBuilder.buildIComplexField(propName, valueName.get(i))); + } + return valueField; + } + + private Map getMapOfCapPropValues(List valueField, boolean isValueAssign) throws Exception { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Assigning values to properties of capabilities and/or collecting existing ones")); - Map propValues = new HashMap<>(); - for(int i=0; i < valueField.size(); i++){ + Map propValues = new HashMap<>(); + for (int i = 0; i < valueField.size(); i++) { String fieldId = valueField.get(i); - if(GeneralUIUtils.getWebElementByTestID(fieldId).getAttribute("value").isEmpty() && isValueAssign) { + if (GeneralUIUtils.getWebElementByTestID(fieldId).getAttribute("value").isEmpty() && isValueAssign) { //add value and put into map propValues.put(fieldId, "value" + i); PropertiesAssignmentPage.editPropertyValue(fieldId, "value" + i); @@ -597,33 +591,32 @@ public final class CanvasManager { propValues.put(fieldId, GeneralUIUtils.getWebElementByTestID(valueField.get(i)).getAttribute("value")); } } - return propValues; - } - - - public ImmutablePair calcMidOfLink(ImmutablePair location1, ImmutablePair location2) - { - int x = (location1.getLeft()+location2.getLeft())/2; - int y = (location1.getRight()+location2.getRight())/2; - - ImmutablePair location = new ImmutablePair<>(x,y); - return location; - } - - public ImmutablePair getElementCoordinates(String elementName){ - Object position = GeneralUIUtils.getElementPositionOnCanvas(elementName); - return converJSJsonToCoordinates(position); - } - - public ImmutablePair getGreenDotCoordinatesOfElement(String elementName){ - Object position = GeneralUIUtils.getElementGreenDotPositionOnCanvas(elementName); - return converJSJsonToCoordinates(position); - } - - public ImmutablePair converJSJsonToCoordinates(Object position) { - JsonElement root = new JsonParser().parse(position.toString()); - int xElement = root.getAsJsonObject().get("x").getAsInt(); - int yElement = root.getAsJsonObject().get("y").getAsInt(); - return new ImmutablePair(xElement, yElement); - } + return propValues; + } + + + public ImmutablePair calcMidOfLink(ImmutablePair location1, ImmutablePair location2) { + int x = (location1.getLeft() + location2.getLeft()) / 2; + int y = (location1.getRight() + location2.getRight()) / 2; + + ImmutablePair location = new ImmutablePair<>(x, y); + return location; + } + + public ImmutablePair getElementCoordinates(String elementName) { + Object position = GeneralUIUtils.getElementPositionOnCanvas(elementName); + return converJSJsonToCoordinates(position); + } + + public ImmutablePair getGreenDotCoordinatesOfElement(String elementName) { + Object position = GeneralUIUtils.getElementGreenDotPositionOnCanvas(elementName); + return converJSJsonToCoordinates(position); + } + + public ImmutablePair converJSJsonToCoordinates(Object position) { + JsonElement root = new JsonParser().parse(position.toString()); + int xElement = root.getAsJsonObject().get("x").getAsInt(); + int yElement = root.getAsJsonObject().get("y").getAsInt(); + return new ImmutablePair(xElement, yElement); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CatalogFilterTitlesEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CatalogFilterTitlesEnum.java index 1335b51788..44c445380d 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CatalogFilterTitlesEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CatalogFilterTitlesEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,16 +22,16 @@ package org.openecomp.sdc.ci.tests.datatypes; public enum CatalogFilterTitlesEnum { - TYPE("typeFilterTitle"), CATEGORIES("categoriesFilterTitle"), STATUS("statusFilterTitle"); + TYPE("typeFilterTitle"), CATEGORIES("categoriesFilterTitle"), STATUS("statusFilterTitle"); - private String value; + private String value; - public String getValue() { - return value; - } + public String getValue() { + return value; + } - private CatalogFilterTitlesEnum(String value) { - this.value = value; - } + CatalogFilterTitlesEnum(String value) { + this.value = value; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CheckBoxStatusEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CheckBoxStatusEnum.java index ec3cb975ac..1363010fd6 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CheckBoxStatusEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CheckBoxStatusEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,30 +21,30 @@ package org.openecomp.sdc.ci.tests.datatypes; public enum CheckBoxStatusEnum { - CHECKOUT("", "checkbox-checkout"), - CHECKIN("", "checkbox-checkin"), - READY_FOR_TESTING("checkbox-readyforcertification","checkbox-1"), - IN_TESTING("checkbox-incertification", "checkbox-2"), - WAITING_FOR_DISTRIBUTION("", "checkbox-waitingforapproval"), - DISTRIBUTION_REJECTED("", "checkbox-distributionrejected"), - DISTRIBUTION_APPROVED("", "checkbox-distributionapproved"), - CERTIFIED("checkbox-certified", "checkbox-3"), - DISTRIBUTED("checkbox-distributed", "checkbox-4"), - IN_DESIGN("checkbox-indesign", "checkbox-0"); + CHECKOUT("", "checkbox-checkout"), + CHECKIN("", "checkbox-checkin"), + READY_FOR_TESTING("checkbox-readyforcertification", "checkbox-1"), + IN_TESTING("checkbox-incertification", "checkbox-2"), + WAITING_FOR_DISTRIBUTION("", "checkbox-waitingforapproval"), + DISTRIBUTION_REJECTED("", "checkbox-distributionrejected"), + DISTRIBUTION_APPROVED("", "checkbox-distributionapproved"), + CERTIFIED("checkbox-certified", "checkbox-3"), + DISTRIBUTED("checkbox-distributed", "checkbox-4"), + IN_DESIGN("checkbox-indesign", "checkbox-0"); - private String value; - private String value2; + private String value; + private String value2; - public String getValue() { - return value; - } + public String getValue() { + return value; + } - public String getCatalogValue() { - return value2; - } + public String getCatalogValue() { + return value2; + } - private CheckBoxStatusEnum(String value, String value2) { - this.value = value; - this.value2 = value2; - } + CheckBoxStatusEnum(String value, String value2) { + this.value = value; + this.value2 = value2; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ConnectionWizardPopUpObject.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ConnectionWizardPopUpObject.java index 85ed56603a..c6146479d0 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ConnectionWizardPopUpObject.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ConnectionWizardPopUpObject.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -68,11 +68,11 @@ public class ConnectionWizardPopUpObject { @Override public String toString() { - return "ConnectionWizardPopUpObject{" + - "capabilityTypeFirstItem='" + capabilityTypeFirstItem + '\'' + - ", capabilityTypeSecondItem='" + capabilityTypeSecondItem + '\'' + - ", capabilityNameFirstItem='" + capabilityNameFirstItem + '\'' + - ", capabilityNameSecondItem='" + capabilityNameSecondItem + '\'' + - '}'; + return "ConnectionWizardPopUpObject{" + + "capabilityTypeFirstItem='" + capabilityTypeFirstItem + '\'' + + ", capabilityTypeSecondItem='" + capabilityTypeSecondItem + '\'' + + ", capabilityNameFirstItem='" + capabilityNameFirstItem + '\'' + + ", capabilityNameSecondItem='" + capabilityNameSecondItem + '\'' + + '}'; } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CreateAndImportButtonsEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CreateAndImportButtonsEnum.java index a49c5024a6..aeef7d98d3 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CreateAndImportButtonsEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CreateAndImportButtonsEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,6 +22,6 @@ package org.openecomp.sdc.ci.tests.datatypes; public enum CreateAndImportButtonsEnum { - IMPORT_VF, IMPORT_VFC, IMPORT_CP, IMPORT_VL, CREATE_VF, CREATE_SERVICE, CREATE_PRODUCT; + IMPORT_VF, IMPORT_VFC, IMPORT_CP, IMPORT_VL, CREATE_VF, CREATE_SERVICE, CREATE_PRODUCT; } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java index f259672448..f099bab6f8 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,1052 +24,1047 @@ import java.util.Arrays; import java.util.List; public final class DataTestIdEnum { - private DataTestIdEnum() { - } - - public enum Dashboard { - IMPORT_AREA("importButtonsArea"), - ADD_AREA("AddButtonsArea"), - BUTTON_ADD_VF("createResourceButton"), - BUTTON_ADD_SERVICE("createServiceButton"), - IMPORT_VFC("importVFCbutton"), - IMPORT_VF("importVFbutton"), - IMPORT_VFC_FILE("file-importVFCbutton"), - IMPORT_VF_FILE("file-importVFbutton"), - BUTTON_ADD_PRODUCT("createProductButton"), - BUTTON_ADD_PNF("createPNFButton"), - BUTTON_ADD_CR("createCRButton"), - ; - - 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"), - CERTIFY("certify"), - CHECKOUT("check_out"); - - private String value; - - public String getValue() { - return value; - } - - private LifeCyleChangeButtons(String value) { - this.value = value; - } - } - - public enum DistributionChangeButtons { - APPROVE("approve"), - REJECT("reject"), - DISTRIBUTE("distribute"), - MONITOR("monitor"), - APPROVE_MESSAGE("checkindialog"), - RE_DISTRIBUTE("redistribute"); - - private String value; - - public String getValue() { - return value; - } - - private DistributionChangeButtons(String value) { - this.value = value; - } - } - - public enum InformationalArtifactsPlaceholders { - CLOUD_QUESTIONNAIRE("Cloud Questionnaire (completed)"), - FEATURES("Features"), - VENDOR_TEST_RESULT("Vendor Test Result"), - TEST_SCRIPTS("Test Scripts"), - RESOURCE_SECURITY_TEMPLATE("Resource Security Template"), - HEAT_TEMPLATE_FROM_VENDOR("HEAT Template from Vendor"), - CAPACITY("Capacity"); - - private String value; - - public String getValue() { - return value; - } - - private InformationalArtifactsPlaceholders(String value) { - this.value = value; - } - } - - public enum ModalItems { - BROWSE_BUTTON("browseButton"), - ADD("Add"), - DESCRIPTION("description"), - SUMBIT_FOR_TESTING_MESSAGE("changeLifeCycleMessage"), - OK("OK"), - CANCEL("Cancel"), - DELETE_INSTANCE_OK("deleteInstanceModal-button-ok"), - DELETE_INSTANCE_CANCEL("deleteInstanceModal-button-cancel"), - RENAME_INSTANCE_OK("renameInstanceModal-button-ok"), - RENAME_INSTANCE_CANCEL("renameInstanceModal-button-cancel"), - UPGRADE_SERVICES_CANCEL("upgradeVspModal-close"), - UPGRADE_SERVICES_OK("upgradeVspModal-button-upgrade"), - UPDATE_SERVICES_OK("upgradeVspModal-button-update"), - UPGRADE_SERVICES_CLOSE("upgradeVspModal-button-close"), - ACCEPT_TESTING_MESSAGE("checkindialog"); - - private String value; - - public String getValue() { - return value; - } - - private ModalItems(String value) { - this.value = value; - } - } - - public enum LeftPanelCanvasItems { - BLOCK_STORAGE("BlockStorage"), - CINDER_VOLUME("CinderVolume"), - COMPUTE("Compute"), - LOAD_BALANCER("LoadBalancer"), - NOVA_SERVER("NovaServer"), - OBJECT_STORAGE("ObjectStorage"), - NEUTRON_PORT("NeutronPort"), - PORT("Port"), DATABASE("Database"), - NETWORK("Network"), - CONTRAIL_PORT("ContrailPort"), - CONTRAIL_VIRTUAL_NETWORK("ContrailVirtualNetwork"); - - private String value; - - public String getValue() { - return value; - } - - private LeftPanelCanvasItems(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"); - LINK_ITEM_CAP_Or_REQ("req-or-cap-item"), -// REQ_CAP_SELECT_DATA_TESTS_ID("SelectType"); - REQ_CAP_SELECT_DATA_TESTS_ID("value-select"); - - 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("deleteInstance"), - UPDATE_INSTANCE_NAME("e-sdc-small-icon-update"), - INSTANCE_NAME_FIELD("instanceName"); - - private String value; - - public String getValue() { - return value; - } - - private GeneralCanvasItems(String value) { - this.value = value; - } - } - - public enum ResourceMetadataEnum { - RESOURCE_NAME("name"), - DESCRIPTION("description"), - CATEGORY("selectGeneralCategory"), - VENDOR_NAME("vendorName"), - VENDOR_RELEASE("vendorRelease"), - TAGS("i-sdc-tag-input"), - CONTACT_ID("contactId"), - ICON(" iconBox"), - TAGS_TABLE("i-sdc-tag-text"), - SELECT_VSP("filename"); - private String value; - - public String getValue() { - return value; - } - - private ResourceMetadataEnum(String value) { - this.value = value; - } - } - - public enum GeneralElementsEnum { - CREATE_BUTTON("create/save"), - CHECKIN_BUTTON("check_in"), - CHECKOUT_BUTTON("check_out"), - SUBMIT_FOR_TESTING_BUTTON("submit_for_testing"), - DELETE_VERSION_BUTTON("delete_version"), - REVERT_BUTTON("revert"), - LIFECYCLE_STATE("formlifecyclestate"), - VERSION_HEADER("versionHeader"), - OK("OK"), - UPDATE_SERVICES_BUTTON("open-upgrade-vsp-popup"), - UPLOAD_FILE_INPUT("browseButton"), -// RESTORE_BUTTON("restore"), - RESTORE_BUTTON("restore-component-button"), -// ARCHIVE_BUTTON("archive"); - ARCHIVE_BUTTON("archive-component-button"); - private String value; - - public String getValue() { - return value; - } - - private GeneralElementsEnum(String value) { - this.value = value; - } - } - - public enum ArtifactPageEnum { - ADD_DEPLOYMENT_ARTIFACT("add-deployment-artifact-button"), - ADD_INFORMATIONAL_ARTIFACT("add-information-artifact-button"), - DOWNLOAD_ARTIFACT_ENV("download_env_"), - ADD_ANOTHER_ARTIFACT("add-another-artifact-button"), - EDIT_ARTIFACT("edit_"), //upload env file by its label(via deployment artifact view)/displayName(via Canvas) - DELETE_ARTIFACT("delete_"), - DOWNLOAD_ARTIFACT("download_"), - BROWSE_ARTIFACT("gab-"), - GET_DEPLOYMENT_ARTIFACT_DESCRIPTION("description"), - GET_INFORMATIONAL_ARTIFACT_DESCRIPTION("Description"), - OK("OK"), - TYPE("artifactType_"), - DEPLOYMENT_TIMEOUT("timeout_"), - VERSION("artifactVersion_"), - UUID("artifactUUID_"), - EDIT_PARAMETERS_OF_ARTIFACT("edit-parameters-of-"), - DELETE_PARAMETER_OF_ARTIFACT("delete-"), - ARTIFACT_NAME("artifactDisplayName_"), - UPLOAD_HEAT_ENV_PARAMETERS("uplaodEnv_"), - VERSION_ENV("artifactEnvVersion_"), - ADD_OTHER_ARTIFACT_BUTTON("//button[@class='add-button ng-scope']"); - private String value; - - public String getValue() { - return value; - } - - private ArtifactPageEnum(String value) { - this.value = value; - } - } - - public enum PropertiesPageEnum { - - ADD_NEW_PROPERTY("addGrey"), - EDIT_PROPERTY("edit_"), - DELETE_PROPERTY("delete_"), - DELETE_PROPERTY_POPUP("delete_property"), - PROPERTY_NAME("propertyName_"), - PROPERTY_DESCRIPTION("propertyDescription_"), - PROPERTY_TYPE("propertyType_"), - ENTRY_SCHEMA("propertySchema_"), - ADD("Add"), CANCEL("Cancel"), - DONE("Done"), - PROPERTY_ROW("propertyRow"), - SAVE("Save"), - POPUP_FORM("sdc-edit-property-container"); - private String value; - - public String getValue() { - return value; - } - - private PropertiesPageEnum(String value) { - this.value = value; - } - } - - public enum PropertiesPopupEnum { - - PROPERTY_NAME("propertyName"), - PROPERTY_VALUE("defaultvalue"), - PROPERTY_BOOLEAN_VALUE("booleantype"), - PROPERTY_DESCRIPTION("description"), - PROPERTY_TYPE("propertyType"), - ENTRY_SCHEMA("schema-type"), - CANCEL("Cancel"), - SAVE("Save"), - POPUP_FORM("sdc-edit-property-container"), - ADD("Add"), - DONE("Done"), - PROPERTY_RADIO_BUTTON_CONTAINER("propertyRadioButton_"), - RADIO_BUTTON_CLASS("tlv-radio-label"); - private String value; - - public String getValue() { - return value; - } - - private PropertiesPopupEnum(String value) { - this.value = value; - } - } - - public enum AdminPageTabs { - USER_MANAGEMENT("usermanagmenttab"), - CATEGORY_MANAGEMENT("categorymanagmenttab"); - - private String value; - - public String getValue() { - return value; - } - - private AdminPageTabs(String value) { - this.value = value; - } - } - - public enum UserManagementEnum { - - SEARCH_BOX("searchbox"), - NEW_USER_FIELD("newuserId"), - ROLE_SELECT("selectrole"), - CREATE_BUTTON("creategreen"), - CLASS__USER_MANAGEMENT_TABLE("sdc-user-management-table"), - ROW_TABLE("row_"), - FIRST_NAME("firstName_"), - LAST_NAME("lastName__"), - USER_ID("userId_"), - EMAIL("email_"), - ROLE("role_"), - LAST_ACTIVE("lastActive_"), - UPDATE_ROLE("selectRole_"), - UPDATE_USER_BUTTON("updateUser_"), - SAVE_USER("save_"), - DELETE_USER("delete_"), - ; - - - private String value; - - public String getValue() { - return value; - } - - private UserManagementEnum(String value) { - this.value = value; - } - } - - public enum CategoryManagement { - - SERVICE_CATEGORY_HEADER("servicecategoryheader"), - RESOURCE_CATEGORY_HEADER("resourcecategoryheader"), - SERVICE_CATEGORY_LIST("servicecategory"), - RESOURCE_CATEGORY_LIST("resourcecategory"), - NEW_CATEGORY_BUTTON("newcategory"), - NEW_SUB_CATEGORY_BUTTON("newsubcategory"), - NEW_CATEGORY_NAME("i-sdc-form-input"); - - private String value; - - public String getValue() { - return value; - } - - private CategoryManagement(String value) { - this.value = value; - } - } - - - - public enum MainMenuButtons { - HOME_BUTTON("main-menu-button-home"), - CATALOG_BUTTON("main-menu-button-catalog"), - ONBOARD_BUTTON("main-menu-button-onboard"), - SEARCH_BOX("main-menu-input-search"), - REPOSITORY_ICON("repository-icon"); - private String value; - - public String getValue() { - return value; - } - - private MainMenuButtons(String value) { - this.value = value; - } - } - - public enum CatalogSwitchButtons { - CATALOG_SWITCH_BUTTON("catalog-selector-button"), // get possible catalog types(active/archive) - CATALOG_ACTIVE_ITEMS("catalog-selector-0"), // select active catalog - CATALOG_ARCHIVE("catalog-selector-1"); // select archive catalog - private String value; - - public String getValue() { - return value; - } - private CatalogSwitchButtons(String value) { - this.value = value; - } - } - - public enum MainMenuButtonsFromInsideFrame { - HOME_BUTTON("breadcrumbs-button-0"); - private String value; - - public String getValue() { - return value; - } - - private MainMenuButtonsFromInsideFrame(String value) { - this.value = value; - } - } - - 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; - } - } - - public enum StepsEnum { - GENERAL("GeneralLeftSideMenu"), - ICON("Iconstep"), - DEPLOYMENT_ARTIFACT("Deployment ArtifactLeftSideMenu"), - INFORMATION_ARTIFACT("Information ArtifactLeftSideMenu"), - PROPERTIES("PropertiesLeftSideMenu"), - COMPOSITION("CompositionLeftSideMenu"), - ACTIVITY_LOG("Activity LogLeftSideMenu"), - DEPLOYMENT_VIEW("DeploymentLeftSideMenu"), - TOSCA_ARTIFACTS("TOSCA ArtifactsLeftSideMenu"), - MONITOR("DistributionLeftSideMenu"), - MANAGEMENT_WORKFLOW("Management WorkflowLeftSideMenu"), - INPUTS("Inputs"), - HIERARCHY("Hierarchy"), - PROPERTIES_ASSIGNMENT("Properties AssignmentLeftSideMenu"); - - private String value; - - public String getValue() { - return value; - } - - private StepsEnum(String value) { - this.value = value; - } - } - - public enum ArtifactPopup { - - BROWSE("browseButton"), - ARTIFACT_DESCRIPTION("description"), - ARTIFACT_LABEL("artifactLabel"), - ARTIFACT_TYPE("artifacttype"), - OK("OK"), - SAVE("Save"), - DONE_BUTTON("Done"), - CANCEL_BUTTON("Cancel"), - URL("input[class^='i-sdc-form-input']"), - MODAL_WINDOW("sdc-add-artifact"); - - private String value; - - public String getValue() { - return value; - } - - private ArtifactPopup(String value) { - this.value = value; - } - } - - public enum ServiceMetadataEnum { - SERVICE_NAME("name"), - DESCRIPTION("description"), - CATEGORY("selectGeneralCategory"), - PROJECT_CODE("projectCode"), - TAGS("i-sdc-tag-input"), - CONTACT_ID("contactId"), - ICON(" iconBox"), - INSTANTIATION_TYPE("selectInstantiationType"); - - private String value; - - public String getValue() { - return value; - } - - private ServiceMetadataEnum(String value) { - this.value = value; - } - } - - public enum ProductMetadataEnum { - PRODUCT_NAME("name"), - FULL_NAME("fullName"), - DESCRIPTION("description"), - PROJECT_CODE("projectCode"), - TAGS("i-sdc-tag-input"), - ATT_CONTACT("attContact"), - ICON(" iconBox"); - - private String value; - - public String getValue() { - return value; - } - - private ProductMetadataEnum(String value) { - this.value = value; - } - } - - public enum DashboardCardEnum { - ASSET_TYPE("asset-type"), LIFECYCLE_STATE("span[class^='w-sdc-dashboard-card-info-lifecycleState']"), - INFO_NAME("div.sdc-tile-info-line"), - VERSION("div[class^='w-sdc-dashboard-card-info-user']"), - DASHBOARD_CARD("div[class^='w-sdc-dashboard-card ']"), - INFO_TITLE_XPATH("//div[contains(@class,'sdc-tile-info-line title')]"), - ASSET_TYPE_CSS("span[data-tests-id='asset-type']"); - - private String value; - - public String getValue() { - return value; - } - - private DashboardCardEnum(String value) { - this.value = value; - } - } - - public enum CatalogPageLeftPanelCategoryCheckbox { - GENERIC_CHECKBOX("span[data-tests-id='checkbox-resourcenewcategory.generic']"), - NETWORK_L2_3("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3']"), - NETWORK_L4_PLUS("span[data-tests-id='checkbox-resourcenewcategory.networkl4+']"), - NETWORK_CONNECTIVITY("span[data-tests-id='checkbox-resourcenewcategory.networkconnectivity']"), - APPLICATION_L4_PLUS("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+']"), - DCAE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent']"); - - private String value; - - public String getValue() { - return value; - } - - private CatalogPageLeftPanelCategoryCheckbox(String value) { - this.value = value; - } - } - - public enum CatalogPageLeftPanelFilterTitle { - TYPE("span[data-tests-id='typeFilterTitle']"), - CATEGORIES("span[data-tests-id='categoriesFilterTitle']"), - STATUS("span[data-tests-id='statusFilterTitle']"); - - private String value; - - public String getValue() { - return value; - } - - private CatalogPageLeftPanelFilterTitle(String value) { - this.value = value; - } - } - - public enum CatalogPageLeftPanelSubCategoryCheckbox { - COMMON_NETWORK_RESOURCES("span[data-tests-id='checkbox-resourcenewcategory.networkl4+.commonnetworkresources']"), - ROUTER("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.router']"), - WAN_CONNECTORS("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.wanconnectors']"), - LAN_CONNECTORS("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.lanconnectors']"), - INFRASTRUCTERE_NETWORKl2_3("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.infrastructure']"), - GATEWAY("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.gateway']"), - NETWORK_ELEMENTS("span[data-tests-id='checkbox-resourcenewcategory.generic.networkelements']"), - ABSTRACT("span[data-tests-id='checkbox-resourcenewcategory.generic.abstract']"), - RULES("span[data-tests-id='checkbox-resourcenewcategory.generic.rules']"), - DATABASE("span[data-tests-id='checkbox-resourcenewcategory.generic.database']"), - INFRASTRUCTERE_GENERIC("span[data-tests-id='checkbox-resourcenewcategory.generic.infrastructure']"), - VIRTUAL_LINKS("span[data-tests-id='checkbox-resourcenewcategory.networkconnectivity.virtuallinks']"), - CONNECTION_POINTS("span[data-tests-id='checkbox-resourcenewcategory.networkconnectivity.connectionpoints']"), - APPLICATION_SERVER("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.applicationserver']"), - CALL_CONTROL("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.callcontrol']"), - MEDIASERVERS("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.mediaservers']"), - WEBSERVER("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.webserver']"), - LOAD_BALANCER("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.loadbalancer']"), - BORDER_ELEMENT("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.borderelement']"), - DATABASE_APPLIVATION_L4_PLUS("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.database']"), - FIREWALL("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.firewall']"), - DATABASE_DCAE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.database']"), - POLICY("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.policy']"), - MICROSERVICE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.microservice']"), - SOURCE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.source']"), - COLLECTOR("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.collector']"), - UTILITY("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.utility']"), - ANALYTICS("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.analytics']"); - - private String value; - - public String getValue() { - return value; - } - - private CatalogPageLeftPanelSubCategoryCheckbox(String value) { - this.value = value; - } - } - - public enum CompositionScreenEnum { - - CHANGE_VERSION("changeVersion", Arrays.asList()), - DEPLOYMENT_ARTIFACT_TAB("deployment-artifact-tab", Arrays.asList("Deployment Artifacts")), - ADD_ARTIFACT("add_Artifact_Button", Arrays.asList()), - SEARCH_ASSET("searchAsset", Arrays.asList()), - PROPERTIES_AND_ATTRIBUTES_TAB("properties-and-attributes-tab",Arrays.asList()), - MENU_INPUTS("sub-menu-button-inputs",Arrays.asList()), - MENU_ONBOARD("sub-menu-button-onboard",Arrays.asList()), - MENU_HOME("sub-menu-button-home",Arrays.asList()), - MENU_PROPERTIES_ASSIGNMENT("sub-menu-button-properties assignment",Arrays.asList()), - MENU_TRIANGLE_DROPDOWN("triangle-dropdown", Arrays.asList()), - ARTIFACTS_LIST("artifactName", Arrays.asList()), - INFORMATION_ARTIFACTS("button[tooltip-content='Information Artifacts']", Arrays.asList("Informational Artifacts")), - API("button[tooltip-content='API']", Arrays.asList("API Artifacts")), - INFORMATION("button[tooltip-content='Information']", Arrays.asList("General Info", "Additional Information", "Tags")), - COMPOSITION("button[tooltip-content='Composition']", Arrays.asList("Composition")), - INPUTS("button[tooltip-content='Inputs']", Arrays.asList("")), - REQUIREMENTS_AND_CAPABILITIES("button[tooltip-content='Requirements and Capabilities']", Arrays.asList()), - INFORMATION_TAB("information-tab", Arrays.asList()), - CUSTOMIZATION_UUID("rightTab_customizationModuleUUID", Arrays.asList()); - - private String value; - private List title; - - public String getValue() { - return value; - } - - public List getTitle() { - return title; - } - - private CompositionScreenEnum(String value, List title) { - this.value = value; - this.title = title; - } - } - - public enum ToscaArtifactsScreenEnum { - - TOSCA_MODEL("download-Tosca Model"), - TOSCA_TEMPLATE("download-Tosca Template"), - ARTIFACT_VERSION("version-"), - ARTIFACT_NAME("name-"), - ARTIFACT_TYPE("type-"), - ARTIFACT_DETAILS("details-"), - DOWNLOAD_ARTIFACT("download-"), - DOWNLOAD_CSAR("download-Tosca Model"); - - private String value; - - public String getValue() { - return value; - } - - private ToscaArtifactsScreenEnum(String value) { - this.value = value; - } - } - - public enum InformationalArtifactsService { - AFFINITY_RULES("artifact_Display_Name-Affinity Rules"), - CONTROL_LOOP_FUNCTIONS("artifact_Display_Name-Control Loop Functions"), - DEPLOYMENT_VOTING_RECORD("artifact_Display_Name-Deployment Voting Record"), - DIMENSIONING_INFO("artifact_Display_Name-Dimensioning Info"), - DISTRIBUTION_INSTRUCTION("artifact_Display_Name-Distribution Instructions"), - ENGINEERING_RULES("artifact_Display_Name-Engineering Rules (ERD)"), - OPERATIONAL_POLICES("artifact_Display_Name-Operational Policies"), - SERVICE_ARTIFACT_PLAN("artifact_Display_Name-Service Artifact Plan"), - SERVICE_QUESTIONNAIRE("artifact_Display_Name-Service Questionnaire"), - SERVICE_SECURITY_TEMPLATE("artifact_Display_Name-Service Security Template"), - SERVICE_SPECIFIC_POLICIES("artifact_Display_Name-Service-specific Policies"), - SUMMARY_OF_IMPACTS_TO_ECOMP("artifact_Display_Name-Summary of impacts to ECOMP elements,OSSs, BSSs"), - TD_CERTIFICATION_TEST_RESULTS("artifact_Display_Name-TD Certification Test Results"); - - private String value; - - public String getValue() { - return value; - } - - private InformationalArtifactsService(String value) { - this.value = value; - } - } - - public enum APIArtifactsService { - - CONFIGURATION("artifact_Display_Name-Configuration"), - INSTANTIATION("artifact_Display_Name-Instantiation"), - LOGGING("artifact_Display_Name-Logging"), - MONITORING("artifact_Display_Name-Monitoring"), - REPORTING("artifact_Display_Name-Reporting"), - TESTING("artifact_Display_Name-Testing"); - - private String value; - - public String getValue() { - return value; - } - - private APIArtifactsService(String value) { - this.value = value; - } - } - - public enum DeploymentArtifactCompositionRightMenu { - ARTIFACT_NAME("artifactName-"), - ARTIFACT_DISPLAY_NAME("artifact_Display_Name-"), - DOWNLOAD("download_"), - DELETE("delete_"), - ADD_ARTIFACT_BUTTON("add_Artifact_Button"), - EDIT_PARAMETERS_OF_ARTIFACT("edit-parameters-of-"), - ARTIFACT_ITEM("artifact-item-"), - ARTIFACT_ENV("heat_env_"); - - private String value; - - public String getValue() { - return value; - } - - private DeploymentArtifactCompositionRightMenu(String value) { - this.value = value; - } - - } - - public enum InputsScreenService { - ADD_SELECTED_INPUTS_BTN("add-inputs-to-service-button"), - VF_INSTANCE_ROWS("expand-collapse[expanded-selector^='.vf-instance-list.']"), - VF_INSTANCE_ROW_NAME("span[class^='title-text']"), - VF_INSTANCE_INPUTS("div[class^='vf-instance-list ']"), - VF_INSTANCE_INPUT("div[class^='input-row ng-scope']"), - VF_INSTNCE_PROPERTY_NAME("div[class^='title-text']"), - INPUT_CHECKBOX("span[class^='tlv-checkbox-label']"), - SERVICE_INPUT_ROW("div[class^='service-input-row input-row']"), - DELETE_INPUT_BTN("span[class$='remove-input-icon']"), - RESOURCE_INSTANCE_PROPERTY_NAME("propertyName_"), - RESOURCE_INSTANCE_PROPERTY_TYPE("propertyType_"), - RESOURCE_INSTANCE_PROPERTY_CHECKBOX("propertyCheckbox_"), - SERVICE_INPUTS_DELETE_BUTTON("deleteInput_") - ; - - private String value; - - public String getValue() { - return value; - } - - private InputsScreenService(String value) { - this.value = value; - } - - } - - public enum DeploymentScreen { - MODULES("span[class^='expand-collapse-title-text']"), - MEMBERS("div[class^='expand-collapse-sub-title']"), - PROPERTIES("list-of-Properties"), - ARTIFACTS("list-of-Artifacts"), - BUTTON_PROPERTIES("div[data-tests-id='list-of-Properties'] span[class^='hand']"), - BUTTON_ARTIFACTS("div[data-tests-id='list-of-Artifacts'] span[class^='hand']"), - PROPERTY_NAMES("div[data-tests-id='selected-module-property-name'] span"), - PROPERTY_TYPES("selected-module-property-type"), - PROPERTY_SCHEMA_TYPE("selected-module-property-schema-type"), - ARTIFACT_NAME("selected-module-artifact-name"), - ARTIFACT_UUID("selected-module-artifact-uuid"), - ARTIFACT_VERSION("selected-module-artifact-version"), - PENCIL_ICON("edit-name-popover-icon"), - MODULE_NAME("selected-module-name"), - MODULE_ID("selected-module-group-uuid"), - RESOURCE_NAME_ON_POPOVER("popover-vfinstance-name"), - MODULE_NAME_ON_POPOVER("popover-module-name"), - NAME_INPUT("popover-heat-name"), - SAVE("popover-save-button"), - CANCEL("popover-close-button"), - X_BUTTON("popover-x-button"); - - private String value; - - public String getValue() { - return value; - } - - private DeploymentScreen(String value) { - this.value = value; - } - } - - public enum PropertiesAssignmentScreen { - - PROPERTIES_TAB("Properties"), - INPUTS_TAB("Inputs"), - COMPOSITION_TAB("Composition"), - PROPERTY_STRUCTURE_TAB("Property Structure"), - SEARCH_BOX("search-box"), - FILTER_BOX("filter-box"), - SAVE_BUTTON("properties-save-button"), - DISCARD_BUTTON("properties-reverse-button"), - DECLARE_BUTTON("declare-button"), - SEARCH_BUTTON("search-button"), - FILTER_BUTTON("filter-button"), - EXPAND_BUTTON ("expand-"), - CLEAR_FILTER_BUTTON("clear-filter-button"), - INPUT_DELETE_BUTTON("delete-input-button"), - INPUT_DELETE_DIALOG_DELETE("Delete"), - INPUT_DELETE_DIALOG_CLOSE("Close"), - SAVE_DIALOG_CANCEL("id-button-cancel"), + private DataTestIdEnum() { + } + + public enum Dashboard { + IMPORT_AREA("importButtonsArea"), + ADD_AREA("AddButtonsArea"), + BUTTON_ADD_VF("createResourceButton"), + BUTTON_ADD_SERVICE("createServiceButton"), + IMPORT_VFC("importVFCbutton"), + IMPORT_VF("importVFbutton"), + IMPORT_VFC_FILE("file-importVFCbutton"), + IMPORT_VF_FILE("file-importVFbutton"), + BUTTON_ADD_PRODUCT("createProductButton"), + BUTTON_ADD_PNF("createPNFButton"), + BUTTON_ADD_CR("createCRButton"); + + private String value; + + public String getValue() { + return value; + } + + 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"), + CERTIFY("certify"), + CHECKOUT("check_out"); + + private String value; + + public String getValue() { + return value; + } + + LifeCyleChangeButtons(String value) { + this.value = value; + } + } + + public enum DistributionChangeButtons { + APPROVE("approve"), + REJECT("reject"), + DISTRIBUTE("distribute"), + MONITOR("monitor"), + APPROVE_MESSAGE("checkindialog"), + RE_DISTRIBUTE("redistribute"); + + private String value; + + public String getValue() { + return value; + } + + DistributionChangeButtons(String value) { + this.value = value; + } + } + + public enum InformationalArtifactsPlaceholders { + CLOUD_QUESTIONNAIRE("Cloud Questionnaire (completed)"), + FEATURES("Features"), + VENDOR_TEST_RESULT("Vendor Test Result"), + TEST_SCRIPTS("Test Scripts"), + RESOURCE_SECURITY_TEMPLATE("Resource Security Template"), + HEAT_TEMPLATE_FROM_VENDOR("HEAT Template from Vendor"), + CAPACITY("Capacity"); + + private String value; + + public String getValue() { + return value; + } + + InformationalArtifactsPlaceholders(String value) { + this.value = value; + } + } + + public enum ModalItems { + BROWSE_BUTTON("browseButton"), + ADD("Add"), + DESCRIPTION("description"), + SUMBIT_FOR_TESTING_MESSAGE("changeLifeCycleMessage"), + OK("OK"), + CANCEL("Cancel"), + DELETE_INSTANCE_OK("deleteInstanceModal-button-ok"), + DELETE_INSTANCE_CANCEL("deleteInstanceModal-button-cancel"), + RENAME_INSTANCE_OK("renameInstanceModal-button-ok"), + RENAME_INSTANCE_CANCEL("renameInstanceModal-button-cancel"), + UPGRADE_SERVICES_CANCEL("upgradeVspModal-close"), + UPGRADE_SERVICES_OK("upgradeVspModal-button-upgrade"), + UPDATE_SERVICES_OK("upgradeVspModal-button-update"), + UPGRADE_SERVICES_CLOSE("upgradeVspModal-button-close"), + ACCEPT_TESTING_MESSAGE("checkindialog"); + + private String value; + + public String getValue() { + return value; + } + + ModalItems(String value) { + this.value = value; + } + } + + public enum LeftPanelCanvasItems { + BLOCK_STORAGE("BlockStorage"), + CINDER_VOLUME("CinderVolume"), + COMPUTE("Compute"), + LOAD_BALANCER("LoadBalancer"), + NOVA_SERVER("NovaServer"), + OBJECT_STORAGE("ObjectStorage"), + NEUTRON_PORT("NeutronPort"), + PORT("Port"), DATABASE("Database"), + NETWORK("Network"), + CONTRAIL_PORT("ContrailPort"), + CONTRAIL_VIRTUAL_NETWORK("ContrailVirtualNetwork"); + + private String value; + + public String getValue() { + return value; + } + + LeftPanelCanvasItems(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"); + LINK_ITEM_CAP_Or_REQ("req-or-cap-item"), + // REQ_CAP_SELECT_DATA_TESTS_ID("SelectType"); + REQ_CAP_SELECT_DATA_TESTS_ID("value-select"); + + private String value; + + public String getValue() { + return value; + } + + LinkMenuItems(String value) { + this.value = value; + } + } + + + public enum GeneralCanvasItems { + CANVAS("canvas"), + CANVAS_RIGHT_PANEL("w-sdc-designer-sidebar-head"), + DELETE_INSTANCE_BUTTON("deleteInstance"), + UPDATE_INSTANCE_NAME("e-sdc-small-icon-update"), + INSTANCE_NAME_FIELD("instanceName"); + + private String value; + + public String getValue() { + return value; + } + + GeneralCanvasItems(String value) { + this.value = value; + } + } + + public enum ResourceMetadataEnum { + RESOURCE_NAME("name"), + DESCRIPTION("description"), + CATEGORY("selectGeneralCategory"), + VENDOR_NAME("vendorName"), + VENDOR_RELEASE("vendorRelease"), + TAGS("i-sdc-tag-input"), + CONTACT_ID("contactId"), + ICON(" iconBox"), + TAGS_TABLE("i-sdc-tag-text"), + SELECT_VSP("filename"); + private String value; + + public String getValue() { + return value; + } + + ResourceMetadataEnum(String value) { + this.value = value; + } + } + + public enum GeneralElementsEnum { + CREATE_BUTTON("create/save"), + CHECKIN_BUTTON("check_in"), + CHECKOUT_BUTTON("check_out"), + SUBMIT_FOR_TESTING_BUTTON("submit_for_testing"), + DELETE_VERSION_BUTTON("delete_version"), + REVERT_BUTTON("revert"), + LIFECYCLE_STATE("formlifecyclestate"), + VERSION_HEADER("versionHeader"), + OK("OK"), + UPDATE_SERVICES_BUTTON("open-upgrade-vsp-popup"), + UPLOAD_FILE_INPUT("browseButton"), + // RESTORE_BUTTON("restore"), + RESTORE_BUTTON("restore-component-button"), + // ARCHIVE_BUTTON("archive"); + ARCHIVE_BUTTON("archive-component-button"); + private String value; + + public String getValue() { + return value; + } + + GeneralElementsEnum(String value) { + this.value = value; + } + } + + public enum ArtifactPageEnum { + ADD_DEPLOYMENT_ARTIFACT("add-deployment-artifact-button"), + ADD_INFORMATIONAL_ARTIFACT("add-information-artifact-button"), + DOWNLOAD_ARTIFACT_ENV("download_env_"), + ADD_ANOTHER_ARTIFACT("add-another-artifact-button"), + EDIT_ARTIFACT("edit_"), //upload env file by its label(via deployment artifact view)/displayName(via Canvas) + DELETE_ARTIFACT("delete_"), + DOWNLOAD_ARTIFACT("download_"), + BROWSE_ARTIFACT("gab-"), + GET_DEPLOYMENT_ARTIFACT_DESCRIPTION("description"), + GET_INFORMATIONAL_ARTIFACT_DESCRIPTION("Description"), + OK("OK"), + TYPE("artifactType_"), + DEPLOYMENT_TIMEOUT("timeout_"), + VERSION("artifactVersion_"), + UUID("artifactUUID_"), + EDIT_PARAMETERS_OF_ARTIFACT("edit-parameters-of-"), + DELETE_PARAMETER_OF_ARTIFACT("delete-"), + ARTIFACT_NAME("artifactDisplayName_"), + UPLOAD_HEAT_ENV_PARAMETERS("uplaodEnv_"), + VERSION_ENV("artifactEnvVersion_"), + ADD_OTHER_ARTIFACT_BUTTON("//button[@class='add-button ng-scope']"); + private String value; + + public String getValue() { + return value; + } + + ArtifactPageEnum(String value) { + this.value = value; + } + } + + public enum PropertiesPageEnum { + + ADD_NEW_PROPERTY("addGrey"), + EDIT_PROPERTY("edit_"), + DELETE_PROPERTY("delete_"), + DELETE_PROPERTY_POPUP("delete_property"), + PROPERTY_NAME("propertyName_"), + PROPERTY_DESCRIPTION("propertyDescription_"), + PROPERTY_TYPE("propertyType_"), + ENTRY_SCHEMA("propertySchema_"), + ADD("Add"), CANCEL("Cancel"), + DONE("Done"), + PROPERTY_ROW("propertyRow"), + SAVE("Save"), + POPUP_FORM("sdc-edit-property-container"); + private String value; + + public String getValue() { + return value; + } + + PropertiesPageEnum(String value) { + this.value = value; + } + } + + public enum PropertiesPopupEnum { + + PROPERTY_NAME("propertyName"), + PROPERTY_VALUE("defaultvalue"), + PROPERTY_BOOLEAN_VALUE("booleantype"), + PROPERTY_DESCRIPTION("description"), + PROPERTY_TYPE("propertyType"), + ENTRY_SCHEMA("schema-type"), + CANCEL("Cancel"), + SAVE("Save"), + POPUP_FORM("sdc-edit-property-container"), + ADD("Add"), + DONE("Done"), + PROPERTY_RADIO_BUTTON_CONTAINER("propertyRadioButton_"), + RADIO_BUTTON_CLASS("tlv-radio-label"); + private String value; + + public String getValue() { + return value; + } + + PropertiesPopupEnum(String value) { + this.value = value; + } + } + + public enum AdminPageTabs { + USER_MANAGEMENT("usermanagmenttab"), + CATEGORY_MANAGEMENT("categorymanagmenttab"); + + private String value; + + public String getValue() { + return value; + } + + AdminPageTabs(String value) { + this.value = value; + } + } + + public enum UserManagementEnum { + + SEARCH_BOX("searchbox"), + NEW_USER_FIELD("newuserId"), + ROLE_SELECT("selectrole"), + CREATE_BUTTON("creategreen"), + CLASS__USER_MANAGEMENT_TABLE("sdc-user-management-table"), + ROW_TABLE("row_"), + FIRST_NAME("firstName_"), + LAST_NAME("lastName__"), + USER_ID("userId_"), + EMAIL("email_"), + ROLE("role_"), + LAST_ACTIVE("lastActive_"), + UPDATE_ROLE("selectRole_"), + UPDATE_USER_BUTTON("updateUser_"), + SAVE_USER("save_"), + DELETE_USER("delete_"); + + + private String value; + + public String getValue() { + return value; + } + + UserManagementEnum(String value) { + this.value = value; + } + } + + public enum CategoryManagement { + + SERVICE_CATEGORY_HEADER("servicecategoryheader"), + RESOURCE_CATEGORY_HEADER("resourcecategoryheader"), + SERVICE_CATEGORY_LIST("servicecategory"), + RESOURCE_CATEGORY_LIST("resourcecategory"), + NEW_CATEGORY_BUTTON("newcategory"), + NEW_SUB_CATEGORY_BUTTON("newsubcategory"), + NEW_CATEGORY_NAME("i-sdc-form-input"); + + private String value; + + public String getValue() { + return value; + } + + CategoryManagement(String value) { + this.value = value; + } + } + + + public enum MainMenuButtons { + HOME_BUTTON("main-menu-button-home"), + CATALOG_BUTTON("main-menu-button-catalog"), + ONBOARD_BUTTON("main-menu-button-onboard"), + SEARCH_BOX("main-menu-input-search"), + REPOSITORY_ICON("repository-icon"); + private String value; + + public String getValue() { + return value; + } + + MainMenuButtons(String value) { + this.value = value; + } + } + + public enum CatalogSwitchButtons { + CATALOG_SWITCH_BUTTON("catalog-selector-button"), // get possible catalog types(active/archive) + CATALOG_ACTIVE_ITEMS("catalog-selector-0"), // select active catalog + CATALOG_ARCHIVE("catalog-selector-1"); // select archive catalog + private String value; + + public String getValue() { + return value; + } + + CatalogSwitchButtons(String value) { + this.value = value; + } + } + + public enum MainMenuButtonsFromInsideFrame { + HOME_BUTTON("breadcrumbs-button-0"); + private String value; + + public String getValue() { + return value; + } + + MainMenuButtonsFromInsideFrame(String value) { + this.value = value; + } + } + + 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; + } + + MenuOptionsEnum(String value) { + this.value = value; + } + } + + public enum StepsEnum { + GENERAL("GeneralLeftSideMenu"), + ICON("Iconstep"), + DEPLOYMENT_ARTIFACT("Deployment ArtifactLeftSideMenu"), + INFORMATION_ARTIFACT("Information ArtifactLeftSideMenu"), + PROPERTIES("PropertiesLeftSideMenu"), + COMPOSITION("CompositionLeftSideMenu"), + ACTIVITY_LOG("Activity LogLeftSideMenu"), + DEPLOYMENT_VIEW("DeploymentLeftSideMenu"), + TOSCA_ARTIFACTS("TOSCA ArtifactsLeftSideMenu"), + MONITOR("DistributionLeftSideMenu"), + MANAGEMENT_WORKFLOW("Management WorkflowLeftSideMenu"), + INPUTS("Inputs"), + HIERARCHY("Hierarchy"), + PROPERTIES_ASSIGNMENT("Properties AssignmentLeftSideMenu"); + + private String value; + + public String getValue() { + return value; + } + + StepsEnum(String value) { + this.value = value; + } + } + + public enum ArtifactPopup { + + BROWSE("browseButton"), + ARTIFACT_DESCRIPTION("description"), + ARTIFACT_LABEL("artifactLabel"), + ARTIFACT_TYPE("artifacttype"), + OK("OK"), + SAVE("Save"), + DONE_BUTTON("Done"), + CANCEL_BUTTON("Cancel"), + URL("input[class^='i-sdc-form-input']"), + MODAL_WINDOW("sdc-add-artifact"); + + private String value; + + public String getValue() { + return value; + } + + ArtifactPopup(String value) { + this.value = value; + } + } + + public enum ServiceMetadataEnum { + SERVICE_NAME("name"), + DESCRIPTION("description"), + CATEGORY("selectGeneralCategory"), + PROJECT_CODE("projectCode"), + TAGS("i-sdc-tag-input"), + CONTACT_ID("contactId"), + ICON(" iconBox"), + INSTANTIATION_TYPE("selectInstantiationType"); + + private String value; + + public String getValue() { + return value; + } + + ServiceMetadataEnum(String value) { + this.value = value; + } + } + + public enum ProductMetadataEnum { + PRODUCT_NAME("name"), + FULL_NAME("fullName"), + DESCRIPTION("description"), + PROJECT_CODE("projectCode"), + TAGS("i-sdc-tag-input"), + ATT_CONTACT("attContact"), + ICON(" iconBox"); + + private String value; + + public String getValue() { + return value; + } + + ProductMetadataEnum(String value) { + this.value = value; + } + } + + public enum DashboardCardEnum { + ASSET_TYPE("asset-type"), LIFECYCLE_STATE("span[class^='w-sdc-dashboard-card-info-lifecycleState']"), + INFO_NAME("div.sdc-tile-info-line"), + VERSION("div[class^='w-sdc-dashboard-card-info-user']"), + DASHBOARD_CARD("div[class^='w-sdc-dashboard-card ']"), + INFO_TITLE_XPATH("//div[contains(@class,'sdc-tile-info-line title')]"), + ASSET_TYPE_CSS("span[data-tests-id='asset-type']"); + + private String value; + + public String getValue() { + return value; + } + + DashboardCardEnum(String value) { + this.value = value; + } + } + + public enum CatalogPageLeftPanelCategoryCheckbox { + GENERIC_CHECKBOX("span[data-tests-id='checkbox-resourcenewcategory.generic']"), + NETWORK_L2_3("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3']"), + NETWORK_L4_PLUS("span[data-tests-id='checkbox-resourcenewcategory.networkl4+']"), + NETWORK_CONNECTIVITY("span[data-tests-id='checkbox-resourcenewcategory.networkconnectivity']"), + APPLICATION_L4_PLUS("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+']"), + DCAE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent']"); + + private String value; + + public String getValue() { + return value; + } + + CatalogPageLeftPanelCategoryCheckbox(String value) { + this.value = value; + } + } + + public enum CatalogPageLeftPanelFilterTitle { + TYPE("span[data-tests-id='typeFilterTitle']"), + CATEGORIES("span[data-tests-id='categoriesFilterTitle']"), + STATUS("span[data-tests-id='statusFilterTitle']"); + + private String value; + + public String getValue() { + return value; + } + + CatalogPageLeftPanelFilterTitle(String value) { + this.value = value; + } + } + + public enum CatalogPageLeftPanelSubCategoryCheckbox { + COMMON_NETWORK_RESOURCES("span[data-tests-id='checkbox-resourcenewcategory.networkl4+.commonnetworkresources']"), + ROUTER("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.router']"), + WAN_CONNECTORS("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.wanconnectors']"), + LAN_CONNECTORS("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.lanconnectors']"), + INFRASTRUCTERE_NETWORKl2_3("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.infrastructure']"), + GATEWAY("span[data-tests-id='checkbox-resourcenewcategory.networkl2-3.gateway']"), + NETWORK_ELEMENTS("span[data-tests-id='checkbox-resourcenewcategory.generic.networkelements']"), + ABSTRACT("span[data-tests-id='checkbox-resourcenewcategory.generic.abstract']"), + RULES("span[data-tests-id='checkbox-resourcenewcategory.generic.rules']"), + DATABASE("span[data-tests-id='checkbox-resourcenewcategory.generic.database']"), + INFRASTRUCTERE_GENERIC("span[data-tests-id='checkbox-resourcenewcategory.generic.infrastructure']"), + VIRTUAL_LINKS("span[data-tests-id='checkbox-resourcenewcategory.networkconnectivity.virtuallinks']"), + CONNECTION_POINTS("span[data-tests-id='checkbox-resourcenewcategory.networkconnectivity.connectionpoints']"), + APPLICATION_SERVER("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.applicationserver']"), + CALL_CONTROL("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.callcontrol']"), + MEDIASERVERS("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.mediaservers']"), + WEBSERVER("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.webserver']"), + LOAD_BALANCER("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.loadbalancer']"), + BORDER_ELEMENT("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.borderelement']"), + DATABASE_APPLIVATION_L4_PLUS("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.database']"), + FIREWALL("span[data-tests-id='checkbox-resourcenewcategory.applicationl4+.firewall']"), + DATABASE_DCAE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.database']"), + POLICY("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.policy']"), + MICROSERVICE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.microservice']"), + SOURCE("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.source']"), + COLLECTOR("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.collector']"), + UTILITY("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.utility']"), + ANALYTICS("span[data-tests-id='checkbox-resourcenewcategory.dcaecomponent.analytics']"); + + private String value; + + public String getValue() { + return value; + } + + CatalogPageLeftPanelSubCategoryCheckbox(String value) { + this.value = value; + } + } + + public enum CompositionScreenEnum { + + CHANGE_VERSION("changeVersion", Arrays.asList()), + DEPLOYMENT_ARTIFACT_TAB("deployment-artifact-tab", Arrays.asList("Deployment Artifacts")), + ADD_ARTIFACT("add_Artifact_Button", Arrays.asList()), + SEARCH_ASSET("searchAsset", Arrays.asList()), + PROPERTIES_AND_ATTRIBUTES_TAB("properties-and-attributes-tab", Arrays.asList()), + MENU_INPUTS("sub-menu-button-inputs", Arrays.asList()), + MENU_ONBOARD("sub-menu-button-onboard", Arrays.asList()), + MENU_HOME("sub-menu-button-home", Arrays.asList()), + MENU_PROPERTIES_ASSIGNMENT("sub-menu-button-properties assignment", Arrays.asList()), + MENU_TRIANGLE_DROPDOWN("triangle-dropdown", Arrays.asList()), + ARTIFACTS_LIST("artifactName", Arrays.asList()), + INFORMATION_ARTIFACTS("button[tooltip-content='Information Artifacts']", Arrays.asList("Informational Artifacts")), + API("button[tooltip-content='API']", Arrays.asList("API Artifacts")), + INFORMATION("button[tooltip-content='Information']", Arrays.asList("General Info", "Additional Information", "Tags")), + COMPOSITION("button[tooltip-content='Composition']", Arrays.asList("Composition")), + INPUTS("button[tooltip-content='Inputs']", Arrays.asList("")), + REQUIREMENTS_AND_CAPABILITIES("button[tooltip-content='Requirements and Capabilities']", Arrays.asList()), + INFORMATION_TAB("information-tab", Arrays.asList()), + CUSTOMIZATION_UUID("rightTab_customizationModuleUUID", Arrays.asList()); + + private String value; + private List title; + + public String getValue() { + return value; + } + + public List getTitle() { + return title; + } + + CompositionScreenEnum(String value, List title) { + this.value = value; + this.title = title; + } + } + + public enum ToscaArtifactsScreenEnum { + + TOSCA_MODEL("download-Tosca Model"), + TOSCA_TEMPLATE("download-Tosca Template"), + ARTIFACT_VERSION("version-"), + ARTIFACT_NAME("name-"), + ARTIFACT_TYPE("type-"), + ARTIFACT_DETAILS("details-"), + DOWNLOAD_ARTIFACT("download-"), + DOWNLOAD_CSAR("download-Tosca Model"); + + private String value; + + public String getValue() { + return value; + } + + ToscaArtifactsScreenEnum(String value) { + this.value = value; + } + } + + public enum InformationalArtifactsService { + AFFINITY_RULES("artifact_Display_Name-Affinity Rules"), + CONTROL_LOOP_FUNCTIONS("artifact_Display_Name-Control Loop Functions"), + DEPLOYMENT_VOTING_RECORD("artifact_Display_Name-Deployment Voting Record"), + DIMENSIONING_INFO("artifact_Display_Name-Dimensioning Info"), + DISTRIBUTION_INSTRUCTION("artifact_Display_Name-Distribution Instructions"), + ENGINEERING_RULES("artifact_Display_Name-Engineering Rules (ERD)"), + OPERATIONAL_POLICES("artifact_Display_Name-Operational Policies"), + SERVICE_ARTIFACT_PLAN("artifact_Display_Name-Service Artifact Plan"), + SERVICE_QUESTIONNAIRE("artifact_Display_Name-Service Questionnaire"), + SERVICE_SECURITY_TEMPLATE("artifact_Display_Name-Service Security Template"), + SERVICE_SPECIFIC_POLICIES("artifact_Display_Name-Service-specific Policies"), + SUMMARY_OF_IMPACTS_TO_ECOMP("artifact_Display_Name-Summary of impacts to ECOMP elements,OSSs, BSSs"), + TD_CERTIFICATION_TEST_RESULTS("artifact_Display_Name-TD Certification Test Results"); + + private String value; + + public String getValue() { + return value; + } + + InformationalArtifactsService(String value) { + this.value = value; + } + } + + public enum APIArtifactsService { + + CONFIGURATION("artifact_Display_Name-Configuration"), + INSTANTIATION("artifact_Display_Name-Instantiation"), + LOGGING("artifact_Display_Name-Logging"), + MONITORING("artifact_Display_Name-Monitoring"), + REPORTING("artifact_Display_Name-Reporting"), + TESTING("artifact_Display_Name-Testing"); + + private String value; + + public String getValue() { + return value; + } + + APIArtifactsService(String value) { + this.value = value; + } + } + + public enum DeploymentArtifactCompositionRightMenu { + ARTIFACT_NAME("artifactName-"), + ARTIFACT_DISPLAY_NAME("artifact_Display_Name-"), + DOWNLOAD("download_"), + DELETE("delete_"), + ADD_ARTIFACT_BUTTON("add_Artifact_Button"), + EDIT_PARAMETERS_OF_ARTIFACT("edit-parameters-of-"), + ARTIFACT_ITEM("artifact-item-"), + ARTIFACT_ENV("heat_env_"); + + private String value; + + public String getValue() { + return value; + } + + DeploymentArtifactCompositionRightMenu(String value) { + this.value = value; + } + + } + + public enum InputsScreenService { + ADD_SELECTED_INPUTS_BTN("add-inputs-to-service-button"), + VF_INSTANCE_ROWS("expand-collapse[expanded-selector^='.vf-instance-list.']"), + VF_INSTANCE_ROW_NAME("span[class^='title-text']"), + VF_INSTANCE_INPUTS("div[class^='vf-instance-list ']"), + VF_INSTANCE_INPUT("div[class^='input-row ng-scope']"), + VF_INSTNCE_PROPERTY_NAME("div[class^='title-text']"), + INPUT_CHECKBOX("span[class^='tlv-checkbox-label']"), + SERVICE_INPUT_ROW("div[class^='service-input-row input-row']"), + DELETE_INPUT_BTN("span[class$='remove-input-icon']"), + RESOURCE_INSTANCE_PROPERTY_NAME("propertyName_"), + RESOURCE_INSTANCE_PROPERTY_TYPE("propertyType_"), + RESOURCE_INSTANCE_PROPERTY_CHECKBOX("propertyCheckbox_"), + SERVICE_INPUTS_DELETE_BUTTON("deleteInput_"); + + private String value; + + public String getValue() { + return value; + } + + InputsScreenService(String value) { + this.value = value; + } + + } + + public enum DeploymentScreen { + MODULES("span[class^='expand-collapse-title-text']"), + MEMBERS("div[class^='expand-collapse-sub-title']"), + PROPERTIES("list-of-Properties"), + ARTIFACTS("list-of-Artifacts"), + BUTTON_PROPERTIES("div[data-tests-id='list-of-Properties'] span[class^='hand']"), + BUTTON_ARTIFACTS("div[data-tests-id='list-of-Artifacts'] span[class^='hand']"), + PROPERTY_NAMES("div[data-tests-id='selected-module-property-name'] span"), + PROPERTY_TYPES("selected-module-property-type"), + PROPERTY_SCHEMA_TYPE("selected-module-property-schema-type"), + ARTIFACT_NAME("selected-module-artifact-name"), + ARTIFACT_UUID("selected-module-artifact-uuid"), + ARTIFACT_VERSION("selected-module-artifact-version"), + PENCIL_ICON("edit-name-popover-icon"), + MODULE_NAME("selected-module-name"), + MODULE_ID("selected-module-group-uuid"), + RESOURCE_NAME_ON_POPOVER("popover-vfinstance-name"), + MODULE_NAME_ON_POPOVER("popover-module-name"), + NAME_INPUT("popover-heat-name"), + SAVE("popover-save-button"), + CANCEL("popover-close-button"), + X_BUTTON("popover-x-button"); + + private String value; + + public String getValue() { + return value; + } + + DeploymentScreen(String value) { + this.value = value; + } + } + + public enum PropertiesAssignmentScreen { + + PROPERTIES_TAB("Properties"), + INPUTS_TAB("Inputs"), + COMPOSITION_TAB("Composition"), + PROPERTY_STRUCTURE_TAB("Property Structure"), + SEARCH_BOX("search-box"), + FILTER_BOX("filter-box"), + SAVE_BUTTON("properties-save-button"), + DISCARD_BUTTON("properties-reverse-button"), + DECLARE_BUTTON("declare-button"), + SEARCH_BUTTON("search-button"), + FILTER_BUTTON("filter-button"), + EXPAND_BUTTON("expand-"), + CLEAR_FILTER_BUTTON("clear-filter-button"), + INPUT_DELETE_BUTTON("delete-input-button"), + INPUT_DELETE_DIALOG_DELETE("Delete"), + INPUT_DELETE_DIALOG_CLOSE("Close"), + SAVE_DIALOG_CANCEL("id-button-cancel"), SAVE_DIALOG_DISCARD("id-button-discard"), SAVE_DIALOG_SAVE("id-button-save"), - PROPERTY_KEY_FIELD_PREFIX("value-prop-key-"), - PROPERTY_VALUE_FIELD_PREFIX("value-prop-"), + PROPERTY_KEY_FIELD_PREFIX("value-prop-key-"), + PROPERTY_VALUE_FIELD_PREFIX("value-prop-"), INPUT_VALUE_FIELD_PREFIX("value-input-"), POPUP_VALUE_FIELD_PREFIX("edit-button-prop-"), - ADD_TO_LIST_BUTTON("add-to-list-"), - DELETE_FROM_LIST_BUTTON("delete-from-list-"), - FILTER_CHECKBOX_ALL("filter-checkbox-all"), - FILTER_CHECKBOX_CP("filter-checkbox-cp"), - FILTER_CHECKBOX_VFC("filter-checkbox-vfc"), - FILTER_CHECKBOX_VL("filter-checkbox-vl"), - FILTER_APPLY_BUTTON("filter-apply-button"), - FILTER_CLOSE_BUTTON("filter-close-button"), - FILTER_SET_BUTTON("filter-set-button"), - PROPERTY_NAME_COLUMN("property-name"); - - - private String value; - - public String getValue() { - return value; - } - - private PropertiesAssignmentScreen(String value) { - this.value = value; - } - - } - - public enum ImportVfRepository { - SEARCH("onboarding-search"), - IMPORT_VSP("import-csar"), - DOWNLOAD_CSAR("download-csar"), - UPDATE_VSP("update-csar"); - - private String value; - - public String getValue() { - return value; - } - - private ImportVfRepository(String value) { - this.value = value; - } - } - - public enum EnvParameterView { - SEARCH_ENV_PARAM_NAME("search-env-param-name"), - ENV_CURRENT_VALUE("value-field-of-"),//value-field-of-oam_volume_name_0 - parameter name - ENV_DEFAULT_VALUE("default-value-of-");// default-value-of-vnf_name - - private String value; - - public String getValue() { - return value; - } - - private EnvParameterView(String value) { - this.value = value; - } - } - - public enum ComplexServiceAmdocs { - CREATE_BUTTON("Create"), - DELETE_COMPONENT("deleteInstance"), - PATH_LIST_BUTTON("pathsListMenuItem"), - UPDATE_VF("create/save"), - PATH_LIST_NAME("path-name"), - PATH_LIST_EDIT("update-service-path-btn"), - PATH_LIST_DELETE("delete-service-path-btn"), - CREATE_PATH_MENU_BUTTON("createPathMenuItem"), - PATH_NAME("pathName"), - PATH_PROTOCOL("pathProtocol"), - PATH_PORT_NUMBER("pathPortNumbers"), - PATH_MENU_BUTTON("pathsMenuBtn"), - SAVE("Save"), - SEARCH("expandable-input-closed"), - LINK_SOURCE("linkSrc"), - LINK_SOURCE_CP("linkSrcCP"), - LINK_TARGET("linkTarget"), - LINK_TARGET_CP("linkTargetCP"), - SERVICE_PATH_SELECTOR("service-path-selector"), - SUBMIT_FOR_TESTING("submit_for_testing"), - CHANGE_LIFE_CYCLE_MESSAGE("changeLifeCycleMessage"), - REMOVE_LINK("removeLnk"), - OK("OK"), - ONBOARD_CATALOG("onboard-onboard-tab"), - CLOSE("Close"), - HOME_FROM_COMPOSITION("breadcrumbs-button-0"), - NEW_VSP_VERSION_DESCRIPTION("new-version-description"), - SUBMIT_NEW_VSP_VERSION_DESCRIPTION("form-submit-button"), - EXTEND_BUTTON("extendPathlnk"); - - private String value; - - public String getValue() { - return value; - } - - private ComplexServiceAmdocs(String value) { - this.value = value; - } - } - - - public enum PortMirroring { - COLLECTOR_NODE("collector_node"), - EQUIP_MODEL("equip_model"), - EQUIP_VENDOR("equip_vendor"), - PMC_NAME_IN_PALLETE("Port Mirroring Configuration"), - PMCP_NAME_IN_PALLETE("Port Mirroring Configuration By Policy"); - - private String value; - - public String getValue() { - return value; - } - - private PortMirroring(String value) { - this.value = value; - } - } - - public enum CompositionRightPanel_GenerInfo { - TYPE("rightTab_componentType"), - RESOURCE_TYPE("rightTab_resourceType"), - SELECT_VERSION("changeVersion"), - CATEGORY("rightTab_category"), - SUB_CATEGORY("rightTab_subCategory"); - - private String value; - - public String getValue() { - return value; - } - - private CompositionRightPanel_GenerInfo(String value) { - this.value = value; - } - } - - public enum CompositionRightPanel { - - COMPONENT_TITLE("selectedCompTitle"), - REQS_AND_CAPS_TAB("requirements-and-capabilities"), - EDIT_PENCIL("editPencil"), - INSTANCE_NAME_TEXTBOX("instanceName"), - DELETE_ITEM("deleteInstance"), - REQS_AND_CAPS_TAB_XPATH("//button[@tooltip-content='Requirements and Capabilities']"); - - private String value; - - public String getValue() { - return value; - } - - private CompositionRightPanel(String value) { - this.value = value; - } - } - - public enum VspValidationPage { - - VSP_VALIDATION_PAGE_NAVBAR("navbar-group-item-SOFTWARE_PRODUCT_VALIDATION"), - VSP_VALIDATION_PAGE_BREADCRUMBS("sub-menu-button-validation"), - VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON("go-to-vsp-validation-inputs"), - VSP_VALIDATION_PAGE_PROCEED_TO_SETUP_BUTTON("go-to-vsp-validation-setup"), - VSP_VALIDATION_PAGE_INPUT("%s_%s_input"), - VSP_VALIDATION_PAGE_PROCEED_TO_RESULTS_BUTTON("proceed-to-validation-results-btn"), - VSP_VALIDATION_PAGE_COMPLIANCE_CHECKBOX_TREE("vsp-validation-compliance-checks-checkbox-tree"), - VSP_VALIDATION_PAGE_CERTIFICATION_CHECKBOX_TREE("vsp-validation-certifications-query-checkbox-tree"); - - private String value; - - public String getValue() { - return value; - } - - private VspValidationPage(String value) { - this.value = value; - } - } - - public enum VspValidationResultsPage { - - VSP_VALIDATION_RESULTS_PAGE_NAVBAR("navbar-group-item-SOFTWARE_PRODUCT_VALIDATION_RESULTS"), - VSP_VALIDATION_RESULTS_PAGE_BREADCRUMBS("sub-menu-button-validation results"); + ADD_TO_LIST_BUTTON("add-to-list-"), + DELETE_FROM_LIST_BUTTON("delete-from-list-"), + FILTER_CHECKBOX_ALL("filter-checkbox-all"), + FILTER_CHECKBOX_CP("filter-checkbox-cp"), + FILTER_CHECKBOX_VFC("filter-checkbox-vfc"), + FILTER_CHECKBOX_VL("filter-checkbox-vl"), + FILTER_APPLY_BUTTON("filter-apply-button"), + FILTER_CLOSE_BUTTON("filter-close-button"), + FILTER_SET_BUTTON("filter-set-button"), + PROPERTY_NAME_COLUMN("property-name"); + + + private String value; + + public String getValue() { + return value; + } + + PropertiesAssignmentScreen(String value) { + this.value = value; + } + + } + + public enum ImportVfRepository { + SEARCH("onboarding-search"), + IMPORT_VSP("import-csar"), + DOWNLOAD_CSAR("download-csar"), + UPDATE_VSP("update-csar"); + + private String value; + + public String getValue() { + return value; + } + + ImportVfRepository(String value) { + this.value = value; + } + } + + public enum EnvParameterView { + SEARCH_ENV_PARAM_NAME("search-env-param-name"), + ENV_CURRENT_VALUE("value-field-of-"), //value-field-of-oam_volume_name_0 - parameter name + ENV_DEFAULT_VALUE("default-value-of-"); // default-value-of-vnf_name + + private String value; + + public String getValue() { + return value; + } + + EnvParameterView(String value) { + this.value = value; + } + } + + public enum ComplexServiceAmdocs { + CREATE_BUTTON("Create"), + DELETE_COMPONENT("deleteInstance"), + PATH_LIST_BUTTON("pathsListMenuItem"), + UPDATE_VF("create/save"), + PATH_LIST_NAME("path-name"), + PATH_LIST_EDIT("update-service-path-btn"), + PATH_LIST_DELETE("delete-service-path-btn"), + CREATE_PATH_MENU_BUTTON("createPathMenuItem"), + PATH_NAME("pathName"), + PATH_PROTOCOL("pathProtocol"), + PATH_PORT_NUMBER("pathPortNumbers"), + PATH_MENU_BUTTON("pathsMenuBtn"), + SAVE("Save"), + SEARCH("expandable-input-closed"), + LINK_SOURCE("linkSrc"), + LINK_SOURCE_CP("linkSrcCP"), + LINK_TARGET("linkTarget"), + LINK_TARGET_CP("linkTargetCP"), + SERVICE_PATH_SELECTOR("service-path-selector"), + SUBMIT_FOR_TESTING("submit_for_testing"), + CHANGE_LIFE_CYCLE_MESSAGE("changeLifeCycleMessage"), + REMOVE_LINK("removeLnk"), + OK("OK"), + ONBOARD_CATALOG("onboard-onboard-tab"), + CLOSE("Close"), + HOME_FROM_COMPOSITION("breadcrumbs-button-0"), + NEW_VSP_VERSION_DESCRIPTION("new-version-description"), + SUBMIT_NEW_VSP_VERSION_DESCRIPTION("form-submit-button"), + EXTEND_BUTTON("extendPathlnk"); + + private String value; + + public String getValue() { + return value; + } + + ComplexServiceAmdocs(String value) { + this.value = value; + } + } + + + public enum PortMirroring { + COLLECTOR_NODE("collector_node"), + EQUIP_MODEL("equip_model"), + EQUIP_VENDOR("equip_vendor"), + PMC_NAME_IN_PALLETE("Port Mirroring Configuration"), + PMCP_NAME_IN_PALLETE("Port Mirroring Configuration By Policy"); + + private String value; + + public String getValue() { + return value; + } + + PortMirroring(String value) { + this.value = value; + } + } + + public enum CompositionRightPanelGeneralInfo { + TYPE("rightTab_componentType"), + RESOURCE_TYPE("rightTab_resourceType"), + SELECT_VERSION("changeVersion"), + CATEGORY("rightTab_category"), + SUB_CATEGORY("rightTab_subCategory"); + + private String value; + + public String getValue() { + return value; + } + + CompositionRightPanelGeneralInfo(String value) { + this.value = value; + } + } + + public enum CompositionRightPanel { + + COMPONENT_TITLE("selectedCompTitle"), + REQS_AND_CAPS_TAB("requirements-and-capabilities"), + EDIT_PENCIL("editPencil"), + INSTANCE_NAME_TEXTBOX("instanceName"), + DELETE_ITEM("deleteInstance"), + REQS_AND_CAPS_TAB_XPATH("//button[@tooltip-content='Requirements and Capabilities']"); + + private String value; + + public String getValue() { + return value; + } + + CompositionRightPanel(String value) { + this.value = value; + } + } + + public enum VspValidationPage { + + VSP_VALIDATION_PAGE_NAVBAR("navbar-group-item-SOFTWARE_PRODUCT_VALIDATION"), + VSP_VALIDATION_PAGE_BREADCRUMBS("sub-menu-button-validation"), + VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON("go-to-vsp-validation-inputs"), + VSP_VALIDATION_PAGE_PROCEED_TO_SETUP_BUTTON("go-to-vsp-validation-setup"), + VSP_VALIDATION_PAGE_INPUT("%s_%s_input"), + VSP_VALIDATION_PAGE_PROCEED_TO_RESULTS_BUTTON("proceed-to-validation-results-btn"), + VSP_VALIDATION_PAGE_COMPLIANCE_CHECKBOX_TREE("vsp-validation-compliance-checks-checkbox-tree"), + VSP_VALIDATION_PAGE_CERTIFICATION_CHECKBOX_TREE("vsp-validation-certifications-query-checkbox-tree"); + + private String value; + + public String getValue() { + return value; + } + + VspValidationPage(String value) { + this.value = value; + } + } + + public enum VspValidationResultsPage { + + VSP_VALIDATION_RESULTS_PAGE_NAVBAR("navbar-group-item-SOFTWARE_PRODUCT_VALIDATION_RESULTS"), + VSP_VALIDATION_RESULTS_PAGE_BREADCRUMBS("sub-menu-button-validation results"); - private String value; + private String value; - public String getValue() { - return value; - } + public String getValue() { + return value; + } - private VspValidationResultsPage(String value) { - this.value = value; - } - } + VspValidationResultsPage(String value) { + this.value = value; + } + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ErrorMessageProperties.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ErrorMessageProperties.java index a7d2551683..1538543e91 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ErrorMessageProperties.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ErrorMessageProperties.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,33 +21,33 @@ package org.openecomp.sdc.ci.tests.datatypes; public class ErrorMessageProperties { - - private String messageId ; - private String code; - - public ErrorMessageProperties() { - - } - - public ErrorMessageProperties(String messageId, String code) { - this.messageId = messageId; - this.code = code; - } - - public String getMessageId() { - return messageId; - } - - public void setMessageId(String messageId) { - this.messageId = messageId; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } + + private String messageId; + private String code; + + public ErrorMessageProperties() { + + } + + public ErrorMessageProperties(String messageId, String code) { + this.messageId = messageId; + this.code = code; + } + + public String getMessageId() { + return messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/GeneralCanvasItemsEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/GeneralCanvasItemsEnum.java index 14c022a740..a612dc7a9a 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/GeneralCanvasItemsEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/GeneralCanvasItemsEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,18 +21,18 @@ package org.openecomp.sdc.ci.tests.datatypes; public enum GeneralCanvasItemsEnum { - CANVAS("canvas"), - CANVAS_RIGHT_PANEL("w-sdc-designer-sidebar-head"), - DELETE_INSTANCE_BUTTON("deleteInstance"); + CANVAS("canvas"), + CANVAS_RIGHT_PANEL("w-sdc-designer-sidebar-head"), + DELETE_INSTANCE_BUTTON("deleteInstance"); - private String value; + private String value; - public String getValue() { - return value; - } + public String getValue() { + return value; + } - private GeneralCanvasItemsEnum(String value) { - this.value = value; - } + GeneralCanvasItemsEnum(String value) { + this.value = value; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/HeatAndHeatEnvNamesPair.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/HeatAndHeatEnvNamesPair.java index 1df61b734c..4986bca883 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/HeatAndHeatEnvNamesPair.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/HeatAndHeatEnvNamesPair.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,40 +23,40 @@ package org.openecomp.sdc.ci.tests.datatypes; import java.io.File; public class HeatAndHeatEnvNamesPair { - - private File heatFileName; - private File heatEnvFileName; - - public HeatAndHeatEnvNamesPair() { - super(); - } - - public HeatAndHeatEnvNamesPair(File heatFileName, File heatEnvFileName) { - super(); - this.heatFileName = heatFileName; - this.heatEnvFileName = heatEnvFileName; - } - - public File getHeatFileName() { - return heatFileName; - } - - public void setHeatFileName(File heatFileName) { - this.heatFileName = heatFileName; - } - - public File getHeatEnvFileName() { - return heatEnvFileName; - } - - public void setHeatEnvFileName(File heatEnvFileName) { - this.heatEnvFileName = heatEnvFileName; - } - - @Override - public String toString() { - return "HeatHeatEnvNamesPair [heatFileName=" + heatFileName + ", heatEnvFileName=" + heatEnvFileName + "]"; - } - + + private File heatFileName; + private File heatEnvFileName; + + public HeatAndHeatEnvNamesPair() { + super(); + } + + public HeatAndHeatEnvNamesPair(File heatFileName, File heatEnvFileName) { + super(); + this.heatFileName = heatFileName; + this.heatEnvFileName = heatEnvFileName; + } + + public File getHeatFileName() { + return heatFileName; + } + + public void setHeatFileName(File heatFileName) { + this.heatFileName = heatFileName; + } + + public File getHeatEnvFileName() { + return heatEnvFileName; + } + + public void setHeatEnvFileName(File heatEnvFileName) { + this.heatEnvFileName = heatEnvFileName; + } + + @Override + public String toString() { + return "HeatHeatEnvNamesPair [heatFileName=" + heatFileName + ", heatEnvFileName=" + heatEnvFileName + "]"; + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/HeatWithParametersDefinition.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/HeatWithParametersDefinition.java index 5a73712b2a..7b9223bc84 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/HeatWithParametersDefinition.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/HeatWithParametersDefinition.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,77 +26,76 @@ import java.util.List; public class HeatWithParametersDefinition { - private String heatLabel; - private String heatEnvLabel; - private String heatArtifactType; - private String heatEnvArtifactType; - private String heatArtifactDisplayName; - private List heatParameterDefinition; - - public HeatWithParametersDefinition(String heatLabel, String heatEnvLabel, String heatArtifactType, String heatEnvArtifactType, String heatArtifactDisplayName, List heatParameterDefinition) { - super(); - this.heatLabel = heatLabel; - this.heatEnvLabel = heatEnvLabel; - this.heatArtifactType = heatArtifactType; - this.heatEnvArtifactType = heatEnvArtifactType; - this.heatArtifactDisplayName = heatArtifactDisplayName; - this.heatParameterDefinition = heatParameterDefinition; - } - - public String getHeatArtifactDisplayName() { - return heatArtifactDisplayName; - } - - public void setHeatArtifactDisplayName(String heatArtifactDisplayName) { - this.heatArtifactDisplayName = heatArtifactDisplayName; - } - - public String getHeatLabel() { - return heatLabel; - } - - public void setHeatLabel(String heatLabel) { - this.heatLabel = heatLabel; - } - - public String getHeatEnvLabel() { - return heatEnvLabel; - } - - public void setHeatEnvLabel(String heatEnvLabel) { - this.heatEnvLabel = heatEnvLabel; - } - - public String getHeatArtifactType() { - return heatArtifactType; - } - - public void setHeatArtifactType(String heatArtifactType) { - this.heatArtifactType = heatArtifactType; - } - - public String getHeatEnvArtifactType() { - return heatEnvArtifactType; - } - - public void setHeatEnvArtifactType(String heatEnvArtifactType) { - this.heatEnvArtifactType = heatEnvArtifactType; - } - - public List getHeatParameterDefinition() { - return heatParameterDefinition; - } - - public void setHeatParameterDefinition(List heatParameterDefinition) { - this.heatParameterDefinition = heatParameterDefinition; - } - - @Override - public String toString() { - return "HeatWithParametersDefinition [heatLabel=" + heatLabel + ", heatEnvLabel=" + heatEnvLabel + ", heatArtifactType=" + heatArtifactType + ", heatEnvArtifactType=" + heatEnvArtifactType + ", heatArtifactDisplayName=" - + heatArtifactDisplayName + ", heatParameterDefinition=" + heatParameterDefinition + "]"; - } - - - + private String heatLabel; + private String heatEnvLabel; + private String heatArtifactType; + private String heatEnvArtifactType; + private String heatArtifactDisplayName; + private List heatParameterDefinition; + + public HeatWithParametersDefinition(String heatLabel, String heatEnvLabel, String heatArtifactType, String heatEnvArtifactType, String heatArtifactDisplayName, List heatParameterDefinition) { + super(); + this.heatLabel = heatLabel; + this.heatEnvLabel = heatEnvLabel; + this.heatArtifactType = heatArtifactType; + this.heatEnvArtifactType = heatEnvArtifactType; + this.heatArtifactDisplayName = heatArtifactDisplayName; + this.heatParameterDefinition = heatParameterDefinition; + } + + public String getHeatArtifactDisplayName() { + return heatArtifactDisplayName; + } + + public void setHeatArtifactDisplayName(String heatArtifactDisplayName) { + this.heatArtifactDisplayName = heatArtifactDisplayName; + } + + public String getHeatLabel() { + return heatLabel; + } + + public void setHeatLabel(String heatLabel) { + this.heatLabel = heatLabel; + } + + public String getHeatEnvLabel() { + return heatEnvLabel; + } + + public void setHeatEnvLabel(String heatEnvLabel) { + this.heatEnvLabel = heatEnvLabel; + } + + public String getHeatArtifactType() { + return heatArtifactType; + } + + public void setHeatArtifactType(String heatArtifactType) { + this.heatArtifactType = heatArtifactType; + } + + public String getHeatEnvArtifactType() { + return heatEnvArtifactType; + } + + public void setHeatEnvArtifactType(String heatEnvArtifactType) { + this.heatEnvArtifactType = heatEnvArtifactType; + } + + public List getHeatParameterDefinition() { + return heatParameterDefinition; + } + + public void setHeatParameterDefinition(List heatParameterDefinition) { + this.heatParameterDefinition = heatParameterDefinition; + } + + @Override + public String toString() { + return "HeatWithParametersDefinition [heatLabel=" + heatLabel + ", heatEnvLabel=" + heatEnvLabel + ", heatArtifactType=" + heatArtifactType + ", heatEnvArtifactType=" + heatEnvArtifactType + ", heatArtifactDisplayName=" + + heatArtifactDisplayName + ", heatParameterDefinition=" + heatParameterDefinition + "]"; + } + + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/LifeCycleStateEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/LifeCycleStateEnum.java index 773cb57b2e..b45a3328b9 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/LifeCycleStateEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/LifeCycleStateEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,26 +22,26 @@ package org.openecomp.sdc.ci.tests.datatypes; public enum LifeCycleStateEnum { - CHECKOUT("IN DESIGN CHECK OUT"), - CHECKIN("IN DESIGN CHECK IN"), - READY_FOR_TESTING("READY FOR TESTING"), - IN_TESTING("IN TESTING"), - WAITING_FOR_DISTRIBUTION("WAITING FOR DISTRIBUTION"), - DISTRIBUTION_REJECTED("DISTRIBUTION REJECTED"), - DISTRIBUTION_APPROVED("DISTRIBUTION APPROVED"), - CERTIFIED("CERTIFIED"), - DISTRIBUTED("DISTRIBUTED"), - IN_DESIGN("IN DESIGN"); + CHECKOUT("IN DESIGN CHECK OUT"), + CHECKIN("IN DESIGN CHECK IN"), + READY_FOR_TESTING("READY FOR TESTING"), + IN_TESTING("IN TESTING"), + WAITING_FOR_DISTRIBUTION("WAITING FOR DISTRIBUTION"), + DISTRIBUTION_REJECTED("DISTRIBUTION REJECTED"), + DISTRIBUTION_APPROVED("DISTRIBUTION APPROVED"), + CERTIFIED("CERTIFIED"), + DISTRIBUTED("DISTRIBUTED"), + IN_DESIGN("IN DESIGN"); - private String value; - private String value2; + private String value; + private String value2; - public String getValue() { - return value; - } + public String getValue() { + return value; + } - private LifeCycleStateEnum(String value) { - this.value = value; - } + LifeCycleStateEnum(String value) { + this.value = value; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/MenuOptionsEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/MenuOptionsEnum.java index 63171a6c78..f644db2c47 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/MenuOptionsEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/MenuOptionsEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,16 +22,16 @@ package org.openecomp.sdc.ci.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"); + 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; + private String value; - public String getValue() { - return value; - } + public String getValue() { + return value; + } - private MenuOptionsEnum(String value) { - this.value = value; - } + MenuOptionsEnum(String value) { + this.value = value; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PortMirrioringConfigurationObject.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PortMirrioringConfigurationObject.java index 31d8cb431d..8475d0602b 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PortMirrioringConfigurationObject.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PortMirrioringConfigurationObject.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ public class PortMirrioringConfigurationObject { private CanvasManager canvasManager; private CanvasElement serviceElementVmmeSourceName; private CanvasElement serviceElementVprobeCollector; - private CanvasElement portMirroringConfigurationElement; + private CanvasElement portMirroringConfigurationElement; private Service service; private Service serviceContainerVmme_Source; private Service serviceContainerVprobe_Collector; @@ -48,12 +48,10 @@ public class PortMirrioringConfigurationObject { } - public PortMirrioringConfigurationObject(ServiceReqDetails serviceReqDetails, String vmmeSourceName, String vprobeSourceName, CanvasManager canvasManager, CanvasElement serviceElementVmmeSourceName, CanvasElement serviceElementVprobeCollector, Service service, CanvasElement portMirroringConfigurationElement, - Service serviceContainerVmme_Source, Service serviceContainerVprobe_Collector ) - { + Service serviceContainerVmme_Source, Service serviceContainerVprobe_Collector) { this.serviceReqDetails = serviceReqDetails; this.vmmeSourceName = vmmeSourceName; this.vprobeSourceName = vprobeSourceName; diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PortMirroringEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PortMirroringEnum.java index 356d1ea5d4..2c51c26d24 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PortMirroringEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PortMirroringEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -61,7 +61,7 @@ public enum PortMirroringEnum { return value; } - private PortMirroringEnum(String value) { + PortMirroringEnum(String value) { this.value = value; } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PropertyInfo.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PropertyInfo.java index 785a355e13..e78e09da79 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PropertyInfo.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/PropertyInfo.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,53 +24,53 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum; public class PropertyInfo { - public PropertyInfo() { - super(); - } + public PropertyInfo() { + super(); + } - public PropertyInfo(PropertyTypeEnum prop) { - super(); - this.name = prop.getName(); - this.value = prop.getValue(); - this.type = prop.getType(); - this.description = prop.getDescription(); - } + public PropertyInfo(PropertyTypeEnum prop) { + super(); + this.name = prop.getName(); + this.value = prop.getValue(); + this.type = prop.getType(); + this.description = prop.getDescription(); + } - private String name; - private String value; - private String type; - private String description; + private String name; + private String value; + private String type; + private String description; - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getValue() { - return value; - } + public String getValue() { + return value; + } - public void setValue(String value) { - this.value = value; - } + public void setValue(String value) { + this.value = value; + } - public String getType() { - return type; - } + public String getType() { + return type; + } - public void setType(String type) { - this.type = type; - } + public void setType(String type) { + this.type = type; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceCategoriesNameEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceCategoriesNameEnum.java index 2c49c8718b..465609c02b 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceCategoriesNameEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ResourceCategoriesNameEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,24 +22,24 @@ package org.openecomp.sdc.ci.tests.datatypes; public enum ResourceCategoriesNameEnum { - GENERIC("checkbox-resourcenewcategory.generic"), NETWORK_CONNECTIVITY("checkbox-resourcenewcategory.networkconnectivity"), NETWORK_ELEMENTS("checkbox-resourcenewcategory.generic.networkelements"), - ABSTRACT("checkbox-resourcenewcategory.generic.abstract"), DATABASE_GENERIC("checkbox-resourcenewcategory.generic.database"), INFRASTRUCTURE("checkbox-resourcenewcategory.generic.infrastructure"), - VIRTUAL_LINKS("checkbox-resourcenewcategory.networkconnectivity.virtuallinks"), CONNECTION_POINTS("checkbox-resourcenewcategory.networkconnectivity.connectionpoints"), NETWORKL4("checkbox-resourcenewcategory.networkl4+"), - COMMON_NETWORK_RESOURCES("checkbox-resourcenewcategory.networkl4+.commonnetworkresources"), APPLICATIONL4("checkbox-resourcenewcategory.applicationl4+"), WEB_SERVER("checkbox-resourcenewcategory.applicationl4+.webserver"), - APPLICATION_SERVER("checkbox-resourcenewcategory.applicationl4+.applicationserver"), CALL_CONTROL("checkbox-resourcenewcategory.applicationl4+.callcontrol"), BORDER_ELEMENT("checkbox-resourcenewcategory.applicationl4+.borderelement"), - MEDIA_SERVERS("checkbox-resourcenewcategory.applicationl4+.mediaservers"), DATABASE("checkbox-resourcenewcategory.applicationl4+.database"), FIREWALL("checkbox-resourcenewcategory.applicationl4+.firewall"), - LOAD_BALANCER("checkbox-resourcenewcategory.applicationl4+.loadbalancer"), NETWORK_L23("checkbox-resourcenewcategory.networkl2-3"), Router("checkbox-resourcenewcategory.networkl2-3.router"), - WAN_Connectors("checkbox-resourcenewcategory.networkl2-3.wanconnectors"), LAN_CONNECTORS("checkbox-resourcenewcategory.networkl2-3.lanconnectors"), GATEWAY("checkbox-resourcenewcategory.networkl2-3.gateway"), - INFRASTRUCTUREL23("checkbox-resourcenewcategory.networkl2-3.infrastructure"); + GENERIC("checkbox-resourcenewcategory.generic"), NETWORK_CONNECTIVITY("checkbox-resourcenewcategory.networkconnectivity"), NETWORK_ELEMENTS("checkbox-resourcenewcategory.generic.networkelements"), + ABSTRACT("checkbox-resourcenewcategory.generic.abstract"), DATABASE_GENERIC("checkbox-resourcenewcategory.generic.database"), INFRASTRUCTURE("checkbox-resourcenewcategory.generic.infrastructure"), + VIRTUAL_LINKS("checkbox-resourcenewcategory.networkconnectivity.virtuallinks"), CONNECTION_POINTS("checkbox-resourcenewcategory.networkconnectivity.connectionpoints"), NETWORKL4("checkbox-resourcenewcategory.networkl4+"), + COMMON_NETWORK_RESOURCES("checkbox-resourcenewcategory.networkl4+.commonnetworkresources"), APPLICATIONL4("checkbox-resourcenewcategory.applicationl4+"), WEB_SERVER("checkbox-resourcenewcategory.applicationl4+.webserver"), + APPLICATION_SERVER("checkbox-resourcenewcategory.applicationl4+.applicationserver"), CALL_CONTROL("checkbox-resourcenewcategory.applicationl4+.callcontrol"), BORDER_ELEMENT("checkbox-resourcenewcategory.applicationl4+.borderelement"), + MEDIA_SERVERS("checkbox-resourcenewcategory.applicationl4+.mediaservers"), DATABASE("checkbox-resourcenewcategory.applicationl4+.database"), FIREWALL("checkbox-resourcenewcategory.applicationl4+.firewall"), + LOAD_BALANCER("checkbox-resourcenewcategory.applicationl4+.loadbalancer"), NETWORK_L23("checkbox-resourcenewcategory.networkl2-3"), Router("checkbox-resourcenewcategory.networkl2-3.router"), + WAN_Connectors("checkbox-resourcenewcategory.networkl2-3.wanconnectors"), LAN_CONNECTORS("checkbox-resourcenewcategory.networkl2-3.lanconnectors"), GATEWAY("checkbox-resourcenewcategory.networkl2-3.gateway"), + INFRASTRUCTUREL23("checkbox-resourcenewcategory.networkl2-3.infrastructure"); - private String value; + private String value; - public String getValue() { - return value; - } + public String getValue() { + return value; + } - private ResourceCategoriesNameEnum(String value) { - this.value = value; - } + ResourceCategoriesNameEnum(String value) { + this.value = value; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceCategoriesNameEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceCategoriesNameEnum.java index b90e311f72..05de740013 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceCategoriesNameEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceCategoriesNameEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,15 +22,15 @@ package org.openecomp.sdc.ci.tests.datatypes; public enum ServiceCategoriesNameEnum { - NETWORK_L13("checkbox-servicenewcategory.networkl1-3"), VOIPCALL_CONTROL("checkbox-servicenewcategory.voipcallcontrol"), NETWORKL4("checkbox-servicenewcategory.networkl4+"), MOBILITY("checkbox-servicenewcategory.mobility"); + NETWORK_L13("checkbox-servicenewcategory.networkl1-3"), VOIPCALL_CONTROL("checkbox-servicenewcategory.voipcallcontrol"), NETWORKL4("checkbox-servicenewcategory.networkl4+"), MOBILITY("checkbox-servicenewcategory.mobility"); - private String value; + private String value; - public String getValue() { - return value; - } + public String getValue() { + return value; + } - private ServiceCategoriesNameEnum(String value) { - this.value = value; - } + private ServiceCategoriesNameEnum(String value) { + this.value = value; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceContainer.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceContainer.java index 41c1d082c4..90d9661717 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceContainer.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/ServiceContainer.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/TopMenuButtonsEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/TopMenuButtonsEnum.java index 71f444c179..4b6eec10b6 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/TopMenuButtonsEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/TopMenuButtonsEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,19 +22,19 @@ package org.openecomp.sdc.ci.tests.datatypes; public enum TopMenuButtonsEnum { - HOME("main-menu-button-home"), - CATALOG("main-menu-button-catalog"), - ON_BOARDING("main-menu-button-onboard"); + HOME("main-menu-button-home"), + CATALOG("main-menu-button-catalog"), + ON_BOARDING("main-menu-button-onboard"); - private String value; - private String value2; + private String value; + private String value2; - public String getButton() { - return value; - } + public String getButton() { + return value; + } - private TopMenuButtonsEnum(String value) { - this.value = value; - } + TopMenuButtonsEnum(String value) { + this.value = value; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/TypesEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/TypesEnum.java index 4249f9cd68..a553538758 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/TypesEnum.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/TypesEnum.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,15 +22,15 @@ package org.openecomp.sdc.ci.tests.datatypes; public enum TypesEnum { - RESOURCE("checkbox-resource"), VF("checkbox-vf"), VFC("checkbox-vfc"), PNF("checkbox-pnf"), CP("checkbox-cp"), VL("checkbox-vl"), SERVICE("checkbox-service"), PRODUCT("checkbox-product"); - private String value; + RESOURCE("checkbox-resource"), VF("checkbox-vf"), VFC("checkbox-vfc"), PNF("checkbox-pnf"), CP("checkbox-cp"), VL("checkbox-vl"), SERVICE("checkbox-service"), PRODUCT("checkbox-product"); + private String value; - public String getValue() { - return value; - } + public String getValue() { + return value; + } - private TypesEnum(String value) { - this.value = value; - } + TypesEnum(String value) { + this.value = value; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserCredentials.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserCredentials.java index 2de872504f..c5f4640b05 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserCredentials.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserCredentials.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,35 +24,27 @@ import org.openecomp.sdc.be.model.User; public class UserCredentials extends User { - // private String userName; - private String password; - - public UserCredentials(String userId, String password, String firstname, String lastname, String role) { - super(); - setUserId(userId); - // this.userName = userName; - this.password = password; - setFirstName(firstname); - setLastName(lastname); - setRole(role); - } - - public UserCredentials() { - super(); - } - - // public String getUserName() { - // return userName; - // } - // public void setUserName(String userName) { - // this.userName = userName; - // } - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } + private String password; + + public UserCredentials(String userId, String password, String firstname, String lastname, String role) { + super(); + setUserId(userId); + this.password = password; + setFirstName(firstname); + setLastName(lastname); + setRole(role); + } + + public UserCredentials() { + super(); + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserManagementTab.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserManagementTab.java index 60d279267b..b7b235befd 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserManagementTab.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/UserManagementTab.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,88 +31,88 @@ import java.util.List; public class UserManagementTab { - public void searchUser(String searchCriterion){ - ExtentTestActions.log(Status.INFO, "Searching a user by the value : " + searchCriterion); - WebElement searchBoxWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.SEARCH_BOX.getValue()); - searchBoxWebElement.clear(); - searchBoxWebElement.sendKeys(searchCriterion); - GeneralUIUtils.ultimateWait(); - } - - public void setNewUserBox(String user){ - ExtentTestActions.log(Status.INFO, "Inserting userid " + user); - WebElement createNewUserWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.NEW_USER_FIELD.getValue()); - createNewUserWebElement.clear(); - createNewUserWebElement.sendKeys(user); - GeneralUIUtils.ultimateWait(); - } - - public void selectUserRole(UserRoleEnum userRole){ - String role = userRole.name().toLowerCase(); - ExtentTestActions.log(Status.INFO, "Selecting role " + userRole.name()); - GeneralUIUtils.getSelectList(role, DataTestIdEnum.UserManagementEnum.ROLE_SELECT.getValue()); - } - - public void updateUserRole(UserRoleEnum userRole, int rowIndx){ - String role = userRole.name().toLowerCase(); - ExtentTestActions.log(Status.INFO, "Updating the user role to " + userRole.name()); - GeneralUIUtils.getSelectList(role, DataTestIdEnum.UserManagementEnum.UPDATE_ROLE.getValue() + rowIndx); - } - - public void clickCreateButton(){ - ExtentTestActions.log(Status.INFO, "Clicking on 'Create' button."); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.CREATE_BUTTON.getValue()); - } - - public WebElement getRow(int index){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.ROW_TABLE.getValue() + index); - } - - public WebElement getFirstName(int index){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.FIRST_NAME.getValue() + index); - } - - public WebElement getLastName(int index){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.LAST_NAME.getValue() + index); - } - - public WebElement getUserId(int index){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.USER_ID.getValue() + index); - } - - public WebElement getEmail(int index){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.EMAIL.getValue() + index); - } - - public WebElement getRole(int index){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.ROLE.getValue() + index); - } - - public WebElement getLastActive(int index){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.LAST_ACTIVE.getValue() + index); - } - - public void updateUser(int index){ - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.UPDATE_USER_BUTTON.getValue() + index); - } - - public void deleteUser(int index){ - ExtentTestActions.log(Status.INFO, "Deleting the user in row " + (index + 1)); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.DELETE_USER.getValue() + index); -// GeneralUIUtils.ultimateWait(); - GeneralPageElements.clickOKButton(); - } - - public void saveAfterUpdateUser(int index){ - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.SAVE_USER.getValue() + index); - } - - public List getAllRowsDisplayed(){ - return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.UserManagementEnum.ROW_TABLE.getValue()); - } - - + public void searchUser(String searchCriterion) { + ExtentTestActions.log(Status.INFO, "Searching a user by the value : " + searchCriterion); + WebElement searchBoxWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.SEARCH_BOX.getValue()); + searchBoxWebElement.clear(); + searchBoxWebElement.sendKeys(searchCriterion); + GeneralUIUtils.ultimateWait(); + } + + public void setNewUserBox(String user) { + ExtentTestActions.log(Status.INFO, "Inserting userid " + user); + WebElement createNewUserWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.NEW_USER_FIELD.getValue()); + createNewUserWebElement.clear(); + createNewUserWebElement.sendKeys(user); + GeneralUIUtils.ultimateWait(); + } + + public void selectUserRole(UserRoleEnum userRole) { + String role = userRole.name().toLowerCase(); + ExtentTestActions.log(Status.INFO, "Selecting role " + userRole.name()); + GeneralUIUtils.getSelectList(role, DataTestIdEnum.UserManagementEnum.ROLE_SELECT.getValue()); + } + + public void updateUserRole(UserRoleEnum userRole, int rowIndx) { + String role = userRole.name().toLowerCase(); + ExtentTestActions.log(Status.INFO, "Updating the user role to " + userRole.name()); + GeneralUIUtils.getSelectList(role, DataTestIdEnum.UserManagementEnum.UPDATE_ROLE.getValue() + rowIndx); + } + + public void clickCreateButton() { + ExtentTestActions.log(Status.INFO, "Clicking on 'Create' button."); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.CREATE_BUTTON.getValue()); + } + + public WebElement getRow(int index) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.ROW_TABLE.getValue() + index); + } + + public WebElement getFirstName(int index) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.FIRST_NAME.getValue() + index); + } + + public WebElement getLastName(int index) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.LAST_NAME.getValue() + index); + } + + public WebElement getUserId(int index) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.USER_ID.getValue() + index); + } + + public WebElement getEmail(int index) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.EMAIL.getValue() + index); + } + + public WebElement getRole(int index) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.ROLE.getValue() + index); + } + + public WebElement getLastActive(int index) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.LAST_ACTIVE.getValue() + index); + } + + public void updateUser(int index) { + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.UPDATE_USER_BUTTON.getValue() + index); + } + + public void deleteUser(int index) { + ExtentTestActions.log(Status.INFO, "Deleting the user in row " + (index + 1)); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.DELETE_USER.getValue() + index); + //GeneralUIUtils.ultimateWait(); + GeneralPageElements.clickOKButton(); + } + + public void saveAfterUpdateUser(int index) { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.SAVE_USER.getValue() + index); + } + + public List getAllRowsDisplayed() { + return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.UserManagementEnum.ROW_TABLE.getValue()); + } + + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VFCArtifact.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VFCArtifact.java index 540a36ad18..8039771a56 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VFCArtifact.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VFCArtifact.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,50 +22,50 @@ package org.openecomp.sdc.ci.tests.datatypes; public class VFCArtifact { - String artifactUUID; - String artifactVersion; - String artifactname; - String artifacttype; - + private String artifactUUID; + private String artifactVersion; + private String artifactname; + private String artifacttype; - public VFCArtifact(String artifactName, String artifactType, String uuid, String version){ - artifactname = artifactName; - artifactUUID = uuid; - artifactVersion = version; - artifacttype = artifactType; - } - - public String getArtifactUUID() { - return artifactUUID; - } - public void setArtifactUUID(String artifactUUID) { - this.artifactUUID = artifactUUID; - } + public VFCArtifact(String artifactName, String artifactType, String uuid, String version) { + artifactname = artifactName; + artifactUUID = uuid; + artifactVersion = version; + artifacttype = artifactType; + } - public String getArtifactVersion() { - return artifactVersion; - } + public String getArtifactUUID() { + return artifactUUID; + } - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } + public void setArtifactUUID(String artifactUUID) { + this.artifactUUID = artifactUUID; + } - public String getArtifactname() { - return artifactname; - } + public String getArtifactVersion() { + return artifactVersion; + } - public void setArtifactname(String artifactname) { - this.artifactname = artifactname; - } + public void setArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + } - public String getArtifacttype() { - return artifacttype; - } + public String getArtifactname() { + return artifactname; + } + + public void setArtifactname(String artifactname) { + this.artifactname = artifactname; + } + + public String getArtifacttype() { + return artifacttype; + } + + public void setArtifacttype(String artifacttype) { + this.artifacttype = artifacttype; + } - public void setArtifacttype(String artifacttype) { - this.artifacttype = artifacttype; - } - } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObject.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObject.java index 96308b3e54..45a1fffdf5 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObject.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/VendorSoftwareProductObject.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,67 +22,69 @@ package org.openecomp.sdc.ci.tests.datatypes; public class VendorSoftwareProductObject extends VendorSoftwareProductObjectReqDetails { - private String vspId; - private String componentId; - private String attContact; - private String version; + private String vspId; + private String componentId; + private String attContact; + private String version; - public VendorSoftwareProductObject(){super();} + public VendorSoftwareProductObject() { + super(); + } - public VendorSoftwareProductObject(String vspId, String componentId, String attContact, String version) { - this.vspId = vspId; - this.componentId = componentId; - this.attContact = attContact; - this.version = version; - } + public VendorSoftwareProductObject(String vspId, String componentId, String attContact, String version) { + this.vspId = vspId; + this.componentId = componentId; + this.attContact = attContact; + this.version = version; + } - public VendorSoftwareProductObject(String name, String description, String category, String subCategory, String vendorId, String vendorName, String licensingVersion, LicensingData licensingData, String onboardingMethod, String networkPackageName, String onboardingOrigin, String icon, String vspId, String componentId, String attContact, String version) { - super(name, description, category, subCategory, vendorId, vendorName, licensingVersion, licensingData, onboardingMethod, networkPackageName, onboardingOrigin, icon); - this.vspId = vspId; - this.componentId = componentId; - this.attContact = attContact; - this.version = version; - } + public VendorSoftwareProductObject(String name, String description, String category, String subCategory, String vendorId, String vendorName, String licensingVersion, LicensingData licensingData, String onboardingMethod, String networkPackageName, String onboardingOrigin, String icon, String vspId, String componentId, String attContact, String version) { + super(name, description, category, subCategory, vendorId, vendorName, licensingVersion, licensingData, onboardingMethod, networkPackageName, onboardingOrigin, icon); + this.vspId = vspId; + this.componentId = componentId; + this.attContact = attContact; + this.version = version; + } - public String getVspId() { - return vspId; - } + public String getVspId() { + return vspId; + } - public void setVspId(String vspId) { - this.vspId = vspId; - } + public void setVspId(String vspId) { + this.vspId = vspId; + } - public String getComponentId() { - return componentId; - } + public String getComponentId() { + return componentId; + } - public void setComponentId(String componentId) { - this.componentId = componentId; - } + public void setComponentId(String componentId) { + this.componentId = componentId; + } - public String getAttContact() { - return attContact; - } + public String getAttContact() { + return attContact; + } - public void setAttContact(String attContact) { - this.attContact = attContact; - } + public void setAttContact(String attContact) { + this.attContact = attContact; + } - public String getVersion() { - return version; - } + public String getVersion() { + return version; + } - public void setVersion(String version) { - this.version = version; - } + public void setVersion(String version) { + this.version = version; + } - @Override - public String toString() { - return "VendorSoftwareProductObject{" + - "vspId='" + vspId + '\'' + - ", componentId='" + componentId + '\'' + - ", attContact='" + attContact + '\'' + - ", version='" + version + '\'' + - '}'; - } + @Override + public String toString() { + return "VendorSoftwareProductObject{" + + "vspId='" + vspId + '\'' + + ", componentId='" + componentId + '\'' + + ", attContact='" + attContact + '\'' + + ", version='" + version + '\'' + + '}'; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/CreatePath.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/CreatePath.java index d8d28e4afa..57d709261f 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/CreatePath.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/CreatePath.java @@ -22,12 +22,22 @@ package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; import com.aventstack.extentreports.Status; import com.clearspring.analytics.util.Pair; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.CircleSize; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GovernorOperationPage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.TesterOperationPage; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; @@ -89,7 +99,7 @@ public class CreatePath extends SetupCDTest { ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile); reloginWithNewRole(UserRoleEnum.DESIGNER); - String serviceName = PathUtilities.createService(getUser()).getName(); + String serviceName = PathUtilities.createService(getUser()).getName(); String pathName = PathUtilities.createPath("Test3", vspName); // @@ check in @@ @@ -125,7 +135,7 @@ public class CreatePath extends SetupCDTest { Pair complex = CreatePathComplexServiceFlow(filePath, vnfFiles); String serviceName = complex.left; String pathName = complex.right; - PathValidations.validateServicePath(serviceName,pathName); + PathValidations.validateServicePath(serviceName, pathName); SetupCDTest.getExtendTest().log(Status.INFO, "path with complex service has been created"); } @@ -286,4 +296,4 @@ public class CreatePath extends SetupCDTest { return UserRoleEnum.DESIGNER; } -} \ No newline at end of file +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/ElementsChanges.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/ElementsChanges.java index 147748d00e..828c37d40c 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/ElementsChanges.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/ElementsChanges.java @@ -22,13 +22,24 @@ package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; import com.aventstack.extentreports.Status; import com.clearspring.analytics.util.Pair; +import org.apache.http.HttpStatus; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GovernorOperationPage; +import org.openecomp.sdc.ci.tests.pages.HomePage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.TesterOperationPage; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; @@ -50,6 +61,7 @@ import static org.testng.AssertJUnit.assertNotSame; public class ElementsChanges extends SetupCDTest { + private static final int NUMBER_OF_LINKS = 3; protected static String filePath = FileHandling.getFilePath("ComplexService"); private static String fullCompositionFile = "fullComposition.zip"; private static String test = "test.zip"; @@ -75,7 +87,7 @@ ElementsChanges extends SetupCDTest { String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile); reloginWithNewRole(UserRoleEnum.DESIGNER); ServiceReqDetails serviceMetadata = PathUtilities.createService(getUser()); - List VFs = PathUtilities.linkVFs(vspName, 3); + List VFs = PathUtilities.linkVFs(vspName, NUMBER_OF_LINKS); String pathName = PathUtilities.createPathWithoutLink("DeleteComponent", vspName); PathUtilities.deleteComponents(VFs); PathValidations.validatePathListIsEmpty(); @@ -106,12 +118,12 @@ ElementsChanges extends SetupCDTest { GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.HOME_FROM_COMPOSITION.getValue()); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.MainMenuButtons.ONBOARD_BUTTON.getValue()); /// GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.ONBOARD_CATALOG.getValue()); - ResourceUIUtils.clickOnElementByText(vspName,null); + ResourceUIUtils.clickOnElementByText(vspName, null); ResourceUIUtils.clickOnElementByText("Create New Version", null); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ComplexServiceAmdocs.NEW_VSP_VERSION_DESCRIPTION.getValue()).sendKeys("new vsap version for service path"); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.SUBMIT_NEW_VSP_VERSION_DESCRIPTION.getValue()); - // VendorSoftwareProductObject v = new VendorSoftwareProductObject(); + // VendorSoftwareProductObject v = new VendorSoftwareProductObject(); //VendorSoftwareProductRestUtils.uploadHeatPackage(filePath,fullCompositionFile,v,getUser()); //upload new heat +commit submit //go to home @@ -119,7 +131,7 @@ ElementsChanges extends SetupCDTest { GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // CanvasManager.getCanvasManager().clickOnCanvaElement(vf); + // CanvasManager.getCanvasManager().clickOnCanvaElement(vf); //update version //validate path still exist certifyServiceAsTester(serviceMetadata); @@ -146,13 +158,13 @@ ElementsChanges extends SetupCDTest { String pathName = "path1"; List VFs = PathUtilities.linkVFs(vspName, 2); CanvasManager canvasManager = CanvasManager.getCanvasManager(); - for (CanvasElement element: VFs) { + for (CanvasElement element : VFs) { CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); } PathUtilities.openCreatePath(); PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); PathUtilities.selectFirstLineParam(); - PathValidations.extendPath(3); + PathValidations.extendPath(NUMBER_OF_LINKS); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); ///////////////// @@ -160,10 +172,10 @@ ElementsChanges extends SetupCDTest { ///////////////// // validate version change has no effect - for (CanvasElement element: VFs) { + for (CanvasElement element : VFs) { RestResponse ServiceForwardingPathsResponse = PathUtilities.getServiceForwardingPathsAPI(service.getName()); // change to version with different capabiliteis - CompositionPage.changeComponentVersion(canvasManager, element, "3.0",false); + CompositionPage.changeComponentVersion(canvasManager, element, "3.0", false); // click on warning message GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.OK.getValue() + "']").get(0).click(); GeneralUIUtils.ultimateWait(); @@ -176,7 +188,7 @@ ElementsChanges extends SetupCDTest { // validate there are no error messages PathValidations.ValidateThereIsNoErrorMessage(); - CompositionPage.changeComponentVersion(canvasManager, element, "1.0",false); + CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.OK.getValue() + "']").get(0).click(); GeneralUIUtils.ultimateWait(); // validate paths hasn't changed @@ -219,13 +231,13 @@ ElementsChanges extends SetupCDTest { String pathName = "path1"; List VFs = PathUtilities.linkVFs(vspName, 2); CanvasManager canvasManager = CanvasManager.getCanvasManager(); - for (CanvasElement element: VFs) { + for (CanvasElement element : VFs) { CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); } PathUtilities.openCreatePath(); PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); PathUtilities.selectFirstLineParam(); - PathValidations.extendPath(3); + PathValidations.extendPath(NUMBER_OF_LINKS); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); ///////////////// @@ -233,10 +245,10 @@ ElementsChanges extends SetupCDTest { ///////////////// // validate version change has no effect - for (CanvasElement element: VFs) { + for (CanvasElement element : VFs) { RestResponse ServiceForwardingPathsResponse = PathUtilities.getServiceForwardingPathsAPI(service.getName()); - CompositionPage.changeComponentVersion(canvasManager, element, "2.0",false); + CompositionPage.changeComponentVersion(canvasManager, element, "2.0", false); // validate paths hasn't changed RestResponse ServiceForwardingPathsResponse2 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); assertEquals( @@ -246,7 +258,7 @@ ElementsChanges extends SetupCDTest { // validate there are no error messages PathValidations.ValidateThereIsNoErrorMessage(); - CompositionPage.changeComponentVersion(canvasManager, element, "1.0",false); + CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); // validate paths hasn't changed RestResponse ServiceForwardingPathsResponse3 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); assertEquals( @@ -287,13 +299,13 @@ ElementsChanges extends SetupCDTest { String pathName = "path1"; List VFs = PathUtilities.linkVFs(vspName, 2); CanvasManager canvasManager = CanvasManager.getCanvasManager(); - for (CanvasElement element: VFs) { + for (CanvasElement element : VFs) { CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); } PathUtilities.openCreatePath(); PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); PathUtilities.selectFirstLineParam(); - PathValidations.extendPath(3); + PathValidations.extendPath(NUMBER_OF_LINKS); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); ///////////////// @@ -301,10 +313,10 @@ ElementsChanges extends SetupCDTest { ///////////////// // validate version change has no effect - for (CanvasElement element: VFs) { + for (CanvasElement element : VFs) { RestResponse ServiceForwardingPathsResponse = PathUtilities.getServiceForwardingPathsAPI(service.getName()); // change to version with different capabiliteis - CompositionPage.changeComponentVersion(canvasManager, element, "3.0",false); + CompositionPage.changeComponentVersion(canvasManager, element, "3.0", false); // click on warning message GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.OK.getValue() + "']").get(0).click(); GeneralUIUtils.ultimateWait(); @@ -317,7 +329,7 @@ ElementsChanges extends SetupCDTest { // validate there are no error messages PathValidations.ValidateThereIsNoErrorMessage(); - CompositionPage.changeComponentVersion(canvasManager, element, "1.0",false); + CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.OK.getValue() + "']").get(0).click(); GeneralUIUtils.ultimateWait(); // validate paths hasn't changed @@ -360,13 +372,13 @@ ElementsChanges extends SetupCDTest { String pathName = "path1"; List VFs = PathUtilities.linkVFs(vspName, 2); CanvasManager canvasManager = CanvasManager.getCanvasManager(); - for (CanvasElement element: VFs) { + for (CanvasElement element : VFs) { CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); } PathUtilities.openCreatePath(); PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); PathUtilities.selectFirstLineParam(); - PathValidations.extendPath(3); + PathValidations.extendPath(NUMBER_OF_LINKS); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); ///////////////// @@ -374,10 +386,10 @@ ElementsChanges extends SetupCDTest { ///////////////// // validate version change has no effect - for (CanvasElement element: VFs) { + for (CanvasElement element : VFs) { RestResponse ServiceForwardingPathsResponse = PathUtilities.getServiceForwardingPathsAPI(service.getName()); // change to version with different capabiliteis - CompositionPage.changeComponentVersion(canvasManager, element, "3.0",false); + CompositionPage.changeComponentVersion(canvasManager, element, "3.0", false); // click on warning message to cancel GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ModalItems.CANCEL.getValue() + "']").get(0).click(); GeneralUIUtils.ultimateWait(); @@ -390,7 +402,7 @@ ElementsChanges extends SetupCDTest { // validate there are no error messages PathValidations.ValidateThereIsNoErrorMessage(); - CompositionPage.changeComponentVersion(canvasManager, element, "3.0",true); + CompositionPage.changeComponentVersion(canvasManager, element, "3.0", true); // click on warning message GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.OK.getValue() + "']").get(0).click(); GeneralUIUtils.ultimateWait(); @@ -434,13 +446,13 @@ ElementsChanges extends SetupCDTest { String pathName = "path1"; List VFs = PathUtilities.linkVFs(vspName, 2); CanvasManager canvasManager = CanvasManager.getCanvasManager(); - for (CanvasElement element: VFs) { + for (CanvasElement element : VFs) { CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); } PathUtilities.openCreatePath(); PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); PathUtilities.selectFirstLineParam(); - PathValidations.extendPath(3); + PathValidations.extendPath(NUMBER_OF_LINKS); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); // certify Service @@ -459,10 +471,10 @@ ElementsChanges extends SetupCDTest { ///////////////// // validate version change has no effect - for (CanvasElement element: VFs) { + for (CanvasElement element : VFs) { RestResponse ServiceForwardingPathsResponse = PathUtilities.getServiceForwardingPathsAPI(service.getName()); // change to version with different capabilities - CompositionPage.changeComponentVersion(canvasManager, element, "3.0",false); + CompositionPage.changeComponentVersion(canvasManager, element, "3.0", false); // click on warning message GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.OK.getValue() + "']").get(0).click(); GeneralUIUtils.ultimateWait(); @@ -475,7 +487,7 @@ ElementsChanges extends SetupCDTest { // validate there are no error messages PathValidations.ValidateThereIsNoErrorMessage(); - CompositionPage.changeComponentVersion(canvasManager, element, "1.0",false); + CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.OK.getValue() + "']").get(0).click(); GeneralUIUtils.ultimateWait(); // validate paths hasn't changed @@ -588,7 +600,7 @@ ElementsChanges extends SetupCDTest { } public static List createComplexPath(String service) throws Exception { - List services = PathUtilities.linkServices(service, service, 3); + List services = PathUtilities.linkServices(service, service, NUMBER_OF_LINKS); PathUtilities.createPathWithoutLink("name1", service); PathUtilities.createPathWithoutLink("name2", service); return services; @@ -607,7 +619,8 @@ ElementsChanges extends SetupCDTest { GeneralUIUtils.ultimateWait(); //tester - reloginWithNewRole(UserRoleEnum.TESTER);GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName()); + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName()); TesterOperationPage.certifyComponent(serviceMetadata1.getName()); //governor @@ -644,14 +657,14 @@ ElementsChanges extends SetupCDTest { vendorSoftwareProduct.getVspId(), vendorSoftwareProduct.getComponentId(), "version with different description", user); - assertEquals("did not succeed to create new item version", 200, newItemVersion.left.getErrorCode().intValue()); + assertEquals("did not succeed to create new item version", HttpStatus.SC_OK, newItemVersion.left.getErrorCode().intValue()); vendorSoftwareProduct.setVersion(newItemVersion.right.getItemId()); vendorSoftwareProduct.setComponentId(newItemVersion.right.getItemId()); // update vsp description vendorSoftwareProduct.setDescription(descriptionV2); RestResponse restResponse = PathUtilities.updateVendorSoftwareProduct(vendorSoftwareProduct, user); - assertEquals("did not succeed to update vsp", 200, restResponse.getErrorCode().intValue()); + assertEquals("did not succeed to update vsp", HttpStatus.SC_OK, restResponse.getErrorCode().intValue()); // commit & submit vsp VendorSoftwareProductRestUtils.prepareVspForUse(user, vendorSoftwareProduct, false); @@ -678,16 +691,16 @@ ElementsChanges extends SetupCDTest { vendorSoftwareProduct.getVspId(), vendorSoftwareProduct.getVersion(), "version with different heat", user); - assertEquals("did not succeed to create new item version", 200, newItemVersion.left.getErrorCode().intValue()); + assertEquals("did not succeed to create new item version", HttpStatus.SC_OK, newItemVersion.left.getErrorCode().intValue()); vendorSoftwareProduct.setVersion(newItemVersion.right.getItemId()); vendorSoftwareProduct.setComponentId(newItemVersion.right.getItemId()); // upload new heat RestResponse uploadHeatPackage = VendorSoftwareProductRestUtils.uploadHeatPackage(filepath, vnfFileV3, vendorSoftwareProduct, user); - assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue()); + assertEquals("did not succeed to upload HEAT package", HttpStatus.SC_OK, uploadHeatPackage.getErrorCode().intValue()); RestResponse validateUpload = VendorSoftwareProductRestUtils.validateUpload(vendorSoftwareProduct, user); - assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), 200, validateUpload.getErrorCode().intValue()); + assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), HttpStatus.SC_OK, validateUpload.getErrorCode().intValue()); // commit & submit vsp VendorSoftwareProductRestUtils.prepareVspForUse(user, vendorSoftwareProduct, false); @@ -708,7 +721,7 @@ ElementsChanges extends SetupCDTest { return vendorSoftwareProduct; } - public void certifyServiceAsTester (ServiceReqDetails serviceMetaData) throws Exception{ + public void certifyServiceAsTester(ServiceReqDetails serviceMetaData) throws Exception { PathUtilities.submitForTesting(); reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(serviceMetaData.getName()); @@ -719,5 +732,4 @@ ElementsChanges extends SetupCDTest { protected UserRoleEnum getRole() { return UserRoleEnum.DESIGNER; } - -} \ No newline at end of file +} diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/OnboardItemObject.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/OnboardItemObject.java index e1da907e68..516cc3aea5 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/OnboardItemObject.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/OnboardItemObject.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,9 @@ public class OnboardItemObject extends OnboardItemObjectReqDetails { private String baseId; private String status; - public OnboardItemObject(){super();} + public OnboardItemObject() { + super(); + } public OnboardItemObject(String itemId, String name, String baseId, String status) { this.itemId = itemId; @@ -71,11 +73,11 @@ public class OnboardItemObject extends OnboardItemObjectReqDetails { @Override public String toString() { - return "OnboardItemObject{" + - "itemId='" + itemId + '\'' + - ", name='" + name + '\'' + - ", baseId='" + baseId + '\'' + - ", status='" + status + '\'' + - '}'; + return "OnboardItemObject{" + + "itemId='" + itemId + '\'' + + ", name='" + name + '\'' + + ", baseId='" + baseId + '\'' + + ", status='" + status + '\'' + + '}'; } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/OnboardItemObjectReqDetails.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/OnboardItemObjectReqDetails.java index 15eb921e1a..181dc434ca 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/OnboardItemObjectReqDetails.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/OnboardItemObjectReqDetails.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -52,9 +52,9 @@ public class OnboardItemObjectReqDetails { @Override public String toString() { - return "OnboardItemObjectReqDetails{" + - "creationMethod='" + creationMethod + '\'' + - ", description='" + description + '\'' + - '}'; + return "OnboardItemObjectReqDetails{" + + "creationMethod='" + creationMethod + '\'' + + ", description='" + description + '\'' + + '}'; } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathName.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathName.java index 374cb9a3b3..16c5553fbc 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathName.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathName.java @@ -62,8 +62,8 @@ public class PathName extends SetupCDTest { String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile); reloginWithNewRole(UserRoleEnum.DESIGNER); PathUtilities.createService(getUser()); - String firstPathName = PathUtilities.createPath("Oren",vspName); - PathUtilities.createPathWithoutLink(firstPathName,vspName); + String firstPathName = PathUtilities.createPath("Oren", vspName); + PathUtilities.createPathWithoutLink(firstPathName, vspName); try { GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); } catch (Exception e) { @@ -78,9 +78,9 @@ public class PathName extends SetupCDTest { String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile); reloginWithNewRole(UserRoleEnum.DESIGNER); PathUtilities.createService(getUser()); - String firstPathName = PathUtilities.createPath("Oren",vspName); - String secondPathName = PathUtilities.createPathWithoutLink("blabla",vspName); - PathValidations.validateEditToExistingName(firstPathName,secondPathName); + String firstPathName = PathUtilities.createPath("Oren", vspName); + String secondPathName = PathUtilities.createPathWithoutLink("blabla", vspName); + PathValidations.validateEditToExistingName(firstPathName, secondPathName); } // Test#10 Jira issue 6411 diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUrls.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUrls.java index 583540796c..de1150c110 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUrls.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUrls.java @@ -25,13 +25,13 @@ import org.openecomp.sdc.ci.tests.utils.Utils; public interface PathUrls { - final static String SDC_HTTP_METHOD = Utils.getConfigHandleException() == null ? "http" : Utils.getConfigHandleException().getSdcHttpMethod(); - final String AMDOCS_HTTP_METHOD = SDC_HTTP_METHOD; + String SDC_HTTP_METHOD = Utils.getConfigHandleException() == null ? "http" : Utils.getConfigHandleException().getSdcHttpMethod(); + String AMDOCS_HTTP_METHOD = SDC_HTTP_METHOD; // onboard - final String CREATE_NEW_ITEM_VERSION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/items/%s/versions/%s/"; - final String UPDATE_VENDOR_SOFTWARE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s"; - final String GET_SERVICE_PATHS = SDC_HTTP_METHOD + "://%s:%s/sdc1/feProxy/rest/v1/catalog/services/%s/filteredDataByParams?include=componentInstancesRelations&include=componentInstances&include=forwardingPaths"; - final String SERVICE_PATH_LINK_MAP = SDC_HTTP_METHOD + "://%s:%s/sdc1/rest/v1/catalog/services/%s/linksMap"; - final String SERVICE_FORWARDING_PATHS = SDC_HTTP_METHOD + "://%s:%s/sdc1/rest/v1/catalog/services/%s/filteredDataByParams?include=componentInstancesRelations&include=componentInstances&include=forwardingPaths"; + String CREATE_NEW_ITEM_VERSION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/items/%s/versions/%s/"; + String UPDATE_VENDOR_SOFTWARE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s"; + String GET_SERVICE_PATHS = SDC_HTTP_METHOD + "://%s:%s/sdc1/feProxy/rest/v1/catalog/services/%s/filteredDataByParams?include=componentInstancesRelations&include=componentInstances&include=forwardingPaths"; + String SERVICE_PATH_LINK_MAP = SDC_HTTP_METHOD + "://%s:%s/sdc1/rest/v1/catalog/services/%s/linksMap"; + String SERVICE_FORWARDING_PATHS = SDC_HTTP_METHOD + "://%s:%s/sdc1/rest/v1/catalog/services/%s/filteredDataByParams?include=componentInstancesRelations&include=componentInstances&include=forwardingPaths"; } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUtilities.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUtilities.java index bfccbc44f8..f181b4f868 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUtilities.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUtilities.java @@ -23,10 +23,15 @@ package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; import com.aventstack.extentreports.Status; import com.clearspring.analytics.util.Pair; import com.google.gson.Gson; +import org.apache.http.HttpStatus; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.config.Config; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; @@ -57,7 +62,10 @@ import static org.testng.AssertJUnit.assertEquals; public class PathUtilities { - public static void openPathList() throws Exception { + private static final int WAITING_FOR_LOADRE_TIME_OUT = 60 * 10; + private static final int NUMBER_OF_LINKS = 3; + + static void openPathList() throws Exception { GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_MENU_BUTTON.getValue()); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_BUTTON.getValue()); } @@ -70,14 +78,14 @@ public class PathUtilities { return serviceMetadata; } - public static List linkVFs(String vspName, int linksNum)throws Exception { + public static List linkVFs(String vspName, int linksNum) throws Exception { CompositionPage.searchForElement(vspName); GeneralUIUtils.ultimateWait(); CanvasManager canvasManager = CanvasManager.getCanvasManager(); GeneralUIUtils.ultimateWait(); - List VFs = new ArrayList(); + List VFs = new ArrayList(); VFs.add(canvasManager.createElementOnCanvas(vspName)); - for (int i = 1; i linkServices(String Service1, String Service2, int linksNum)throws Exception { + public static List linkServices(String service1, String service2, int linksNum) throws Exception { CanvasManager canvasManager = CanvasManager.getCanvasManager(); - List VFs = new ArrayList(); + List VFs = new ArrayList(); // get first service - CompositionPage.searchForElement(Service1); - VFs.add(canvasManager.createElementOnCanvas(Service1)); + CompositionPage.searchForElement(service1); + VFs.add(canvasManager.createElementOnCanvas(service1)); - String service = Service2; - for (int i = 1; i(numOfLines+1)) + if (GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET_CP + "']//option").size() > (numOfLines + 1)) { throw new Exception("Path element was not deleted"); + } GeneralUIUtils.ultimateWait(); return numOfLines; } public static String createPath(String pathName, String vspName) throws Exception { - linkVFs(vspName, 3); + linkVFs(vspName, NUMBER_OF_LINKS); openCreatePath(); insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); selectFirstLineParam(); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); - SetupCDTest.getExtendTest().log(Status.INFO, "path" +pathName+" has been created"); + SetupCDTest.getExtendTest().log(Status.INFO, "path" + pathName + " has been created"); return pathName; } - public static void deleteComponents(List elements)throws Exception { - for(CanvasElement element: elements) - { + public static void deleteComponents(List elements) throws Exception { + for (CanvasElement element : elements) { CanvasManager.getCanvasManager().clickOnCanvaElement(element); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.DELETE_COMPONENT.getValue()); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); @@ -190,7 +200,7 @@ public class PathUtilities { public static void updateVF(String vspName, VendorSoftwareProductObject vendorSoftwareProduct) throws Exception { boolean vspFound = HomePage.searchForVSP(vspName); - if (vspFound){ + if (vspFound) { List elementsFromTable = HomePage.getElemenetsFromTable(); elementsFromTable.get(1).click(); GeneralUIUtils.waitForLoader(); @@ -204,24 +214,25 @@ public class PathUtilities { ExtentTestActions.log(Status.INFO, "Clicking create/update VNF"); String duration = GeneralUIUtils.getActionDuration(() -> waitUntilVnfCreated()); ExtentTestActions.log(Status.INFO, "Succeeded in importing/updating " + vspName, duration); + } else { + Assert.fail("Did not find VSP named " + vspName); } - else Assert.fail("Did not find VSP named " + vspName); } public static void waitUntilVnfCreated() { GeneralUIUtils.clickOnElementByTestIdWithoutWait(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); - GeneralUIUtils.waitForLoader(60*10); + GeneralUIUtils.waitForLoader(WAITING_FOR_LOADRE_TIME_OUT); GeneralUIUtils.waitForAngular(); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); } - public static void deleteComponent(CanvasElement element)throws Exception { + public static void deleteComponent(CanvasElement element) throws Exception { CanvasManager.getCanvasManager().clickOnCanvaElement(element); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.DELETE_COMPONENT.getValue()); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); } - public static void submitForTesting(){ + public static void submitForTesting() { GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.SUBMIT_FOR_TESTING.getValue()); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ComplexServiceAmdocs.CHANGE_LIFE_CYCLE_MESSAGE.getValue()).sendKeys("new service to certify"); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); @@ -232,7 +243,7 @@ public class PathUtilities { insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); selectFirstLineParam(); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); - SetupCDTest.getExtendTest().log(Status.INFO, "path" +pathName+" has been created"); + SetupCDTest.getExtendTest().log(Status.INFO, "path" + pathName + " has been created"); return pathName; } @@ -240,7 +251,11 @@ public class PathUtilities { private static String getServiceUUIDfromCompositionURL() throws Exception { String url = SetupCDTest.getDriver().getCurrentUrl(); String[] result = url.split("/"); - for(int i = 0; i < result.length; i++) if (result[i].equals("workspace")) return result[i + 1]; + for (int i = 0; i < result.length; i++) { + if (result[i].equals("workspace")) { + return result[i + 1]; + } + } throw new Exception("service uuid not found in the url"); } @@ -267,7 +282,7 @@ public class PathUtilities { public static RestResponse createServiceAPI(User sdncUserDetails, ServiceReqDetails serviceDetails) throws Exception { String serviceBaseVersion = "0.1"; RestResponse restResponse = ServiceRestUtils.createService(serviceDetails, sdncUserDetails); - assertEquals("Check API response code for CreateServiceAPI call", 201, restResponse.getErrorCode().intValue()); + assertEquals("Check API response code for CreateServiceAPI call", HttpStatus.SC_CREATED, restResponse.getErrorCode().intValue()); return restResponse; } @@ -282,7 +297,7 @@ public class PathUtilities { // get service RestResponse restResponse = ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails, serviceDetails.getName(), serviceBaseVersion); - assertEquals("Check API response code for GetServiceAPI call", 200, restResponse.getErrorCode().intValue()); + assertEquals("Check API response code for GetServiceAPI call", HttpStatus.SC_OK, restResponse.getErrorCode().intValue()); Service service = ResponseParser.convertServiceResponseToJavaObject(restResponse.getResponse()); String uniqueId = service.getUniqueId(); @@ -311,7 +326,7 @@ public class PathUtilities { HttpRequest http = new HttpRequest(); RestResponse restResponse = http.httpSendGet(url, headersMap); - assertEquals("Check API response code for GetServiceForwardingPathsAPI call", 200, restResponse.getErrorCode().intValue()); + assertEquals("Check API response code for GetServiceForwardingPathsAPI call", HttpStatus.SC_OK, restResponse.getErrorCode().intValue()); return restResponse; } @@ -336,7 +351,7 @@ public class PathUtilities { HttpRequest http = new HttpRequest(); RestResponse restResponse = http.httpSendGet(url, headersMap); - assertEquals("Check API response code for GetServiceForwardingPathsAPI call", 200, restResponse.getErrorCode().intValue()); + assertEquals("Check API response code for GetServiceForwardingPathsAPI call", HttpStatus.SC_OK, restResponse.getErrorCode().intValue()); return restResponse; } @@ -359,7 +374,7 @@ public class PathUtilities { HttpRequest http = new HttpRequest(); RestResponse restResponse = http.httpSendGet(url, headersMap); - assertEquals("Check API response code for GetServiceForwardingPathsAPI call", 200, restResponse.getErrorCode().intValue()); + assertEquals("Check API response code for GetServiceForwardingPathsAPI call", HttpStatus.SC_OK, restResponse.getErrorCode().intValue()); return new Pair<>(restResponse, servicePaths.right); } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathValidations.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathValidations.java index 0e24bc43e0..5396d75dae 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathValidations.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathValidations.java @@ -54,15 +54,20 @@ import static org.testng.AssertJUnit.assertNotSame; public class PathValidations { + + public static final int NUMBER_OF_LINKS = 5; + public static final int NUMBER_OF_LINES = 3; + public static final int NUMBER_OF_LINES_TO_DELETE = 1; + public static String[] validateServiceExtendedPath(String vspName) throws Exception { - PathUtilities.linkVFs(vspName, 5); + PathUtilities.linkVFs(vspName, NUMBER_OF_LINKS); PathUtilities.openCreatePath(); String pathName = "name1"; PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); PathUtilities.selectFirstLineParam(); - PathValidations.extendPath(3); + PathValidations.extendPath(NUMBER_OF_LINES); //delete line - PathUtilities.deleteLines(1, 3); + PathUtilities.deleteLines(NUMBER_OF_LINES_TO_DELETE, NUMBER_OF_LINES); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); ExtentTestActions.log(Status.INFO, "path has been created"); PathValidations.checkPathFilter(pathName, true); @@ -91,19 +96,18 @@ public class PathValidations { SetupCDTest.getExtendTest().log(Status.INFO, "Path has been created"); // check that path got deleted in the path filter list PathValidations.checkPathFilter(newPathName, false); - return new String[] {pathName, newPathName}; + return new String[]{pathName, newPathName}; } public static String[] validateComplexExtendedPath(String[] services) throws Exception { - PathUtilities.linkServices(services[0], services[1], 5); + PathUtilities.linkServices(services[0], services[1], NUMBER_OF_LINKS); PathUtilities.openCreatePath(); String pathName = "name1"; PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers"); PathUtilities.selectFirstLineParam(); - int numOfLines = 3; - PathValidations.extendPath(numOfLines); + PathValidations.extendPath(NUMBER_OF_LINES); //delete line - PathUtilities.deleteLines(1, numOfLines); + PathUtilities.deleteLines(NUMBER_OF_LINES_TO_DELETE, NUMBER_OF_LINES); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); ExtentTestActions.log(Status.INFO, "path has been created"); PathUtilities.openPathList(); @@ -130,12 +134,13 @@ public class PathValidations { PathValidations.validateServicePath(services[2], pathName); PathValidations.validateServicePath(services[2], newPathName); SetupCDTest.getExtendTest().log(Status.INFO, "Paths have been validated"); - return new String[] {pathName, newPathName}; + return new String[]{pathName, newPathName}; } - public static void createPathNumOfRows(int numOfPathRows)throws Exception{ + public static void createPathNumOfRows(int numOfPathRows) throws Exception { + final int numberOfRandomCharacters = 8; PathUtilities.openCreatePath(); - PathUtilities.insertValues("extended" + RandomStringUtils.randomAlphanumeric(8),"pathProtocol1", "pathPortNumbers1"); + PathUtilities.insertValues("extended" + RandomStringUtils.randomAlphanumeric(numberOfRandomCharacters), "pathProtocol1", "pathPortNumbers1"); PathUtilities.selectFirstLineParam(); extendPath(numOfPathRows); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); @@ -143,15 +148,15 @@ public class PathValidations { } public static void extendPath(int numOfLines) throws Exception { - for (int i=0; i < numOfLines; i++) { + for (int i = 0; i < numOfLines; i++) { String check; String index = Integer.toString(i + 2); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.EXTEND_BUTTON.getValue()); - List linkSrcs = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_SOURCE.getValue()+"']//select"); - List linkSrcCPs = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_SOURCE_CP.getValue()+"']//select"); - List linkTargets = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET.getValue()+"']//select"); - List linkTargetCPs = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET_CP.getValue()+"']//select"); + List linkSrcs = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.LINK_SOURCE.getValue() + "']//select"); + List linkSrcCPs = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.LINK_SOURCE_CP.getValue() + "']//select"); + List linkTargets = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET.getValue() + "']//select"); + List linkTargetCPs = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET_CP.getValue() + "']//select"); for (int j = 0; j < i + 2; j++) { validateExtendedPathDisabledButtons(linkSrcs, j, "Source should be disabled. open bug to UI team"); check = linkSrcCPs.get(j).getAttribute("class"); @@ -163,14 +168,14 @@ public class PathValidations { check = linkTargetCPs.get(j).getAttribute("class"); validateElementDisabledAttribute(check, "Target connection point"); } - List choices = GeneralUIUtils.findElementsByXpath("//*[" + index + "]/*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET.getValue()+"']//option"); + List choices = GeneralUIUtils.findElementsByXpath("//*[" + index + "]/*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET.getValue() + "']//option"); choices.get((new Random()).nextInt(choices.size())).click(); - choices = GeneralUIUtils.findElementsByXpath("//*[" + index + "]/*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET_CP.getValue()+"']//option"); + choices = GeneralUIUtils.findElementsByXpath("//*[" + index + "]/*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET_CP.getValue() + "']//option"); choices.get((new Random()).nextInt(choices.size())).click(); } } - public static void validateElementDisabledAttribute(String check, String param) throws Exception{ + public static void validateElementDisabledAttribute(String check, String param) throws Exception { assertEquals(param + " of last lines should be disabled", check.contains("disabled"), true); } @@ -183,16 +188,14 @@ public class PathValidations { PathUtilities.openPathList(); try { GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_DELETE.getValue()); - } - catch (Exception e) - { + } catch (Exception e) { SetupCDTest.getExtendTest().log(Status.INFO, "path list is empty"); } GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CLOSE.getValue()); } - public static void AssertNameChangeFromPathList(String PathListName1, String PathListName2) throws Exception { - assertNotSame("path name is expected to change after edit", PathListName1, PathListName2); + public static void AssertNameChangeFromPathList(String pathListName1, String pathListName2) throws Exception { + assertNotSame("path name is expected to change after edit", pathListName1, pathListName2); } public static void ValidateAndDeletePathFromPathList(String pathName) throws Exception { @@ -216,22 +219,28 @@ public class PathValidations { paths_after_deletion++; } } - } catch (Exception ignore) {} + } catch (Exception ignore) { + } // assert deletion assertNotSame("path is expected to be deleted", paths_after_deletion, paths_before_deletion); } - public static void checkPathFilter(String pathName, boolean isFound) throws Exception{ - List pathFilterList = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.SERVICE_PATH_SELECTOR.getValue()+"']//option"); + public static void checkPathFilter(String pathName, boolean isFound) throws Exception { + List pathFilterList = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.SERVICE_PATH_SELECTOR.getValue() + "']//option"); GeneralUIUtils.ultimateWait(); - if (isFound) for (int i = 0; i < pathFilterList.size(); i++) { - String element_text = pathFilterList.get(i).getText(); - if (element_text.equals(pathName)) break; - assertNotSame("path filter list is missing a path", i, pathFilterList.size() - 1); - } - else for (WebElement aPathFilterList : pathFilterList) { - String element_text = aPathFilterList.getText(); - assertNotSame("path filter list is has a path that should be deleted", element_text, pathName); + if (isFound) { + for (int i = 0; i < pathFilterList.size(); i++) { + String element_text = pathFilterList.get(i).getText(); + if (element_text.equals(pathName)) { + break; + } + assertNotSame("path filter list is missing a path", i, pathFilterList.size() - 1); + } + } else { + for (WebElement aPathFilterList : pathFilterList) { + String element_text = aPathFilterList.getText(); + assertNotSame("path filter list is has a path that should be deleted", element_text, pathName); + } } SetupCDTest.getExtendTest().log(Status.INFO, "path list filter check passed"); } @@ -266,8 +275,8 @@ public class PathValidations { JSONObject jsonResponse = new JSONObject(response); JSONObject forwardingPaths = jsonResponse.getJSONObject("forwardingPaths"); Boolean validation_complete = Boolean.FALSE; - for (Object key : forwardingPaths.keySet()){ - String keyStr = (String)key; + for (Object key : forwardingPaths.keySet()) { + String keyStr = (String) key; JSONObject forwardingPath = forwardingPaths.getJSONObject(keyStr); if (forwardingPath.getString("name").equals(name)) { JSONObject pathElements = forwardingPath.getJSONObject("pathElements"); @@ -292,7 +301,7 @@ public class PathValidations { } } - public static void validateEditToExistingName(String firstPathName, String secondPathName)throws Exception { + public static void validateEditToExistingName(String firstPathName, String secondPathName) throws Exception { PathUtilities.openPathList(); PathUtilities.editPathName(secondPathName, firstPathName); try { @@ -308,7 +317,7 @@ public class PathValidations { throw new Exception("space in beggining or end does not count. when creating another path with duplicate name, expected error did not appear"); } PathUtilities.openPathList(); - PathUtilities.editPathName(secondPathName," " + firstPathName); + PathUtilities.editPathName(secondPathName, " " + firstPathName); try { GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); } catch (Exception e) { @@ -318,7 +327,7 @@ public class PathValidations { PathUtilities.editPathProtocol(secondPathName, "pathProtocol2"); } - public static void validateNameWithSpaces(String pathName, String vspName) throws Exception{ + public static void validateNameWithSpaces(String pathName, String vspName) throws Exception { PathUtilities.createPath(pathName + " ", vspName); PathUtilities.openPathList(); PathUtilities.editPathName(pathName, "newName"); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java index 9ef7c83370..b1a5b5060e 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/AdminUserManagment.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,6 +21,7 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; +import org.apache.http.HttpStatus; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.User; @@ -49,253 +50,216 @@ import java.io.IOException; import java.util.List; public class AdminUserManagment extends SetupCDTest { - - @DataProvider(name = "searchValues") - private final Object[][] searchString(){ - User newUser = createNewUserUsingAPI(); - GeneralUIUtils.getDriver().navigate().refresh(); - return new Object[][]{{newUser.getUserId(), newUser}, {newUser.getFirstName(), newUser}, {newUser.getLastName(), newUser}, {newUser.getEmail(), newUser}}; - } - - //TC915101 - @Test(dataProvider = "searchValues") - public void searchUserByCriterionsTest(String searchCriterion, User user) throws IOException{ - setLog(searchCriterion); - AdminWorkspaceUIUtilies.searchForUser(searchCriterion); - UserManagementVerificator.validateFirstRowDisplayedCorrectly(user); - } - - //TC915100 - @Test - public void createNewUserTest() throws Exception { - - String userId = generateValidUserId(); - UserRoleEnum userRole = UserRoleEnum.DESIGNER; - AdminWorkspaceUIUtilies.createNewUser(userId, userRole); - GeneralUIUtils.ultimateWait(); - UserManagementVerificator.validateUserCreated(userId, userRole); - } - - //TC922253 - @Test - public void createNewUser_MacIdTest() throws Exception { - - String macId = generateValidMacId(); - UserRoleEnum userRole = UserRoleEnum.DESIGNER; - AdminWorkspaceUIUtilies.createNewUser(macId, userRole); - GeneralUIUtils.ultimateWait(); - UserManagementVerificator.validateUserCreated(macId, userRole); - } - - //TC922253 - @Test - public void createExistingUserTest(){ - String userId = generateValidUserId(); - UserRoleEnum userRole = UserRoleEnum.DESIGNER; - AdminWorkspaceUIUtilies.createNewUser(userId, userRole); - ExtentTestActions.log(Status.INFO, "Trying to create the same user once again."); - GeneralUIUtils.ultimateWait(); // extra wait, necessary for system with large user list - AdminWorkspaceUIUtilies.createNewUser(userId, userRole); - ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.USER_ALREADY_EXIST); - } - - - // design changed and now one letter user should exist - //TC922253 - @Test(enabled=false) - public void createInvalidMacIdTest(){ - - if(true){ -// throw new SkipException("Open bug 324032"); - ExtentTestActions.log(Status.INFO, "Open bug 324032"); - } - - String macId = generateValidMacId(); - StringBuilder invalidMacId = new StringBuilder(macId); - invalidMacId.setCharAt(0, 'a'); - UserRoleEnum userRole = UserRoleEnum.DESIGNER; - ExtentTestActions.log(Status.INFO, "Trying to create an invalid macId."); - AdminWorkspaceUIUtilies.createNewUser(invalidMacId.toString(), userRole); - GeneralUIUtils.ultimateWait(); - ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.INVALID_USER_ID); - } - - //TC922253 - @Test - public void specialCharInUserIdTest(){ - String expectedErrorMsg = "User id not valid."; - String userId = generateValidUserId(); - StringBuilder invalidUserId = new StringBuilder(userId); - invalidUserId.setCharAt(1, '#'); - ExtentTestActions.log(Status.INFO, String.format("Trying to create an invalid user with special character (%s)", userId)); - AdminGeneralPage.getUserManagementTab().setNewUserBox(invalidUserId.toString()); - ExtentTestActions.log(Status.INFO, "Validating an error message is displayed as a result of invalid character."); - List inputErrors = null; - int inputErrorsSize = 0; - - try{ - WebElement inputField = GeneralUIUtils.getWebElementByClassName("input-error"); - ExtentTestActions.log(Status.INFO, String.format("Validating the message is : '%s'", expectedErrorMsg)); - inputErrors = inputField.findElements(By.className("ng-scope")); - inputErrorsSize = inputErrors.size(); - for (WebElement err : inputErrors){ - String actualErrorMessage = err.getText(); - if (actualErrorMessage.equals(expectedErrorMsg)){ - inputErrorsSize--; - } - } - } - catch(Exception e){ - ExtentTestActions.log(Status.INFO, "Did not find an error input."); - Assert.fail("Did not find an error message input."); - } - - Assert.assertEquals(inputErrors.size() - 1 , inputErrorsSize, "Did not find an error : " + expectedErrorMsg); - } - - - - //TC915101 - @Test - public void searchForUserByRoleTest(){ - String userId = generateValidUserId(); - UserRoleEnum userRole = UserRoleEnum.DESIGNER; - AdminWorkspaceUIUtilies.createNewUser(userId, userRole); - AdminWorkspaceUIUtilies.searchForUser(userRole.name()); - List allRows = GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.UserManagementEnum.USER_ID.getValue()); - ExtentTestActions.log(Status.INFO, String.format("Found %s rows, looking for the user %s.", allRows.size(), userId)); - int rowsCount = allRows.size(); - for (int i = 0 ; i < allRows.size() ; i++){ - String userIdFromTable = GeneralUIUtils.getTextContentAttributeValue(allRows.get(i)); - if (userIdFromTable.equals(userId)){ - rowsCount--; - break; - } - } - Assert.assertEquals(allRows.size() - 1 , rowsCount , "Did not find a row with the userId " + userId); - } - - //TC915102 - @Test - public void modifyUserRoleTest(){ - User user = new User(); - user.setUserId(generateValidUserId()); - UserRoleEnum userRole = UserRoleEnum.DESIGNER; - AdminWorkspaceUIUtilies.createNewUser(user.getUserId(), userRole); - UserRoleEnum updatedUserRole = UserRoleEnum.TESTER; - AdminWorkspaceUIUtilies.updateUserRole(0, updatedUserRole); - UserManagementVerificator.validateUserRoleUpdated(0, updatedUserRole); - UserManagementVerificator.validateUserRoleUpdatedViaRest(user, getUser(), updatedUserRole); - } - - //TC915103 - @Test - public void deleteUserTest(){ - User user = new User(); - user.setUserId(generateValidUserId()); - UserRoleEnum userRole = UserRoleEnum.DESIGNER; - AdminWorkspaceUIUtilies.createNewUser(user.getUserId(), userRole); - AdminWorkspaceUIUtilies.deleteFirstRow(); - UserManagementVerificator.validateUserIdNotFound(user.getUserId()); - UserManagementVerificator.validateUserNotFoundViaRest(user, getUser()); - } - - //TC951428 - @Test - public void modifyUserRoleWithTaskInHand_Checkout() throws Exception{ - User newUser = new User(); - newUser.setUserId(generateValidUserId()); - UserRoleEnum userRole = UserRoleEnum.DESIGNER; - AdminWorkspaceUIUtilies.createNewUser(newUser.getUserId(), userRole); - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, newUser); - ExtentTestActions.log(Status.INFO, "Creating a new VF named " + resourceMetaData.getName() + " with the user " + newUser.getUserId()); - RestResponse createResourceResp = ResourceRestUtils.createResource(resourceMetaData, newUser); - Assert.assertEquals(createResourceResp.getErrorCode().intValue(), 201, "Did not succeed to create a VF"); - - UserRoleEnum updatedUserRole = UserRoleEnum.TESTER; - AdminWorkspaceUIUtilies.updateUserRole(0, updatedUserRole); - - ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS); - } - - //obsolete test since no more start certification request - /*@Test - public void modifyUserRoleWithTaskInHand_InTesting() throws Exception{ - User newTesterUser = new User(); - newTesterUser.setUserId(generateValidUserId()); - UserRoleEnum userTesterRole = UserRoleEnum.TESTER; - userTesterRole.setUserId(newTesterUser.getUserId()); - AdminWorkspaceUIUtilies.createNewUser(newTesterUser.getUserId(), userTesterRole); - - reloginWithNewRole(UserRoleEnum.DESIGNER); - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ExtentTestActions.log(Status.INFO, "Creating a new VF named " + resourceMetaData.getName()); - ResourceUIUtils.createVF(resourceMetaData, getUser()); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickSubmitForTestingButton(resourceMetaData.getName()); - Resource resourceObjectByNameAndVersion = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); - ExtentTestActions.log(Status.INFO, "Getting the VF to 'In Testing' state."); - AtomicOperationUtils.changeComponentState(resourceObjectByNameAndVersion, userTesterRole, LifeCycleStatesEnum.STARTCERTIFICATION, true); - ExtentTestActions.log(Status.INFO, "Succeeded - The VF is in testing state."); - - reloginWithNewRole(UserRoleEnum.ADMIN); - UserRoleEnum updatedUserRole = UserRoleEnum.DESIGNER; - AdminWorkspaceUIUtilies.searchForUser(newTesterUser.getUserId()); - AdminWorkspaceUIUtilies.updateUserRole(0, updatedUserRole); - - ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS); - }*/ - - - private static String generateValidUserId() { - String charsPattern = "abcdefghijklmnopqrstuvwxyz"; - String digitPatter = "0123456789"; - String chars = ResourceUIUtils.buildStringFromPattern(charsPattern, 2); - String digits = ResourceUIUtils.buildStringFromPattern(digitPatter, 4); - return chars + digits; - } - - private String generateValidMacId() { - String digitPatter = "0123456789"; - String digits = ResourceUIUtils.buildStringFromPattern(digitPatter, 5); - return "m" + digits; - } - - private User createNewUserUsingAPI() { - UserRoleEnum role = UserRoleEnum.DESIGNER; - String userId = generateValidUserId(); - User userByEnv = new User(generateValidUserId(), generateValidUserId(), userId, generateValidUserId()+"@intl.sdc.com", role.name(), null); - User adminUser = getUserByEnv(UserRoleEnum.ADMIN); - try { - RestResponse createUserResp = UserRestUtils.createUser(userByEnv, adminUser); - Assert.assertEquals(createUserResp.getErrorCode().intValue(), 201, "Did not succeed to create a new user using API."); - } catch (IOException e) { - e.printStackTrace(); - } - return userByEnv; - } - - - private User getUserByEnv(UserRoleEnum userRole) { - try{ -// if (!getConfig().getUrl().contains("localhost") && !getConfig().getUrl().contains("127.0.0.1")) { -// return getUserFromFileByRole(userRole); -// } -// else{ - return getUser(userRole); -// } - } - catch (Exception e){ - throw new RuntimeException(e); - } - } - - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.ADMIN; - } + + @DataProvider(name = "searchValues") + private Object[][] searchString() { + User newUser = createNewUserUsingAPI(); + GeneralUIUtils.getDriver().navigate().refresh(); + return new Object[][]{{newUser.getUserId(), newUser}, {newUser.getFirstName(), newUser}, {newUser.getLastName(), newUser}, {newUser.getEmail(), newUser}}; + } + + //TC915101 + @Test(dataProvider = "searchValues") + public void searchUserByCriterionsTest(String searchCriterion, User user) throws IOException { + setLog(searchCriterion); + AdminWorkspaceUIUtilies.searchForUser(searchCriterion); + UserManagementVerificator.validateFirstRowDisplayedCorrectly(user); + } + + //TC915100 + @Test + public void createNewUserTest() throws Exception { + + String userId = generateValidUserId(); + UserRoleEnum userRole = UserRoleEnum.DESIGNER; + AdminWorkspaceUIUtilies.createNewUser(userId, userRole); + GeneralUIUtils.ultimateWait(); + UserManagementVerificator.validateUserCreated(userId, userRole); + } + + //TC922253 + @Test + public void createNewUser_MacIdTest() throws Exception { + + String macId = generateValidMacId(); + UserRoleEnum userRole = UserRoleEnum.DESIGNER; + AdminWorkspaceUIUtilies.createNewUser(macId, userRole); + GeneralUIUtils.ultimateWait(); + UserManagementVerificator.validateUserCreated(macId, userRole); + } + + //TC922253 + @Test + public void createExistingUserTest() { + String userId = generateValidUserId(); + UserRoleEnum userRole = UserRoleEnum.DESIGNER; + AdminWorkspaceUIUtilies.createNewUser(userId, userRole); + ExtentTestActions.log(Status.INFO, "Trying to create the same user once again."); + GeneralUIUtils.ultimateWait(); // extra wait, necessary for system with large user list + AdminWorkspaceUIUtilies.createNewUser(userId, userRole); + ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.USER_ALREADY_EXIST); + } + + + // design changed and now one letter user should exist + //TC922253 + @Test(enabled = false) + public void createInvalidMacIdTest() { + + ExtentTestActions.log(Status.INFO, "Open bug 324032"); + + String macId = generateValidMacId(); + StringBuilder invalidMacId = new StringBuilder(macId); + invalidMacId.setCharAt(0, 'a'); + UserRoleEnum userRole = UserRoleEnum.DESIGNER; + ExtentTestActions.log(Status.INFO, "Trying to create an invalid macId."); + AdminWorkspaceUIUtilies.createNewUser(invalidMacId.toString(), userRole); + GeneralUIUtils.ultimateWait(); + ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.INVALID_USER_ID); + } + + //TC922253 + @Test + public void specialCharInUserIdTest() { + String expectedErrorMsg = "User id not valid."; + String userId = generateValidUserId(); + StringBuilder invalidUserId = new StringBuilder(userId); + invalidUserId.setCharAt(1, '#'); + ExtentTestActions.log(Status.INFO, String.format("Trying to create an invalid user with special character (%s)", userId)); + AdminGeneralPage.getUserManagementTab().setNewUserBox(invalidUserId.toString()); + ExtentTestActions.log(Status.INFO, "Validating an error message is displayed as a result of invalid character."); + List inputErrors = null; + int inputErrorsSize = 0; + + try { + WebElement inputField = GeneralUIUtils.getWebElementByClassName("input-error"); + ExtentTestActions.log(Status.INFO, String.format("Validating the message is : '%s'", expectedErrorMsg)); + inputErrors = inputField.findElements(By.className("ng-scope")); + inputErrorsSize = inputErrors.size(); + for (WebElement err : inputErrors) { + String actualErrorMessage = err.getText(); + if (actualErrorMessage.equals(expectedErrorMsg)) { + inputErrorsSize--; + } + } + } catch (Exception e) { + ExtentTestActions.log(Status.INFO, "Did not find an error input."); + Assert.fail("Did not find an error message input."); + } + + Assert.assertEquals(inputErrors.size() - 1, inputErrorsSize, "Did not find an error : " + expectedErrorMsg); + } + + + //TC915101 + @Test + public void searchForUserByRoleTest() { + String userId = generateValidUserId(); + UserRoleEnum userRole = UserRoleEnum.DESIGNER; + AdminWorkspaceUIUtilies.createNewUser(userId, userRole); + AdminWorkspaceUIUtilies.searchForUser(userRole.name()); + List allRows = GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.UserManagementEnum.USER_ID.getValue()); + ExtentTestActions.log(Status.INFO, String.format("Found %s rows, looking for the user %s.", allRows.size(), userId)); + int rowsCount = allRows.size(); + for (WebElement allRow : allRows) { + String userIdFromTable = GeneralUIUtils.getTextContentAttributeValue(allRow); + if (userIdFromTable.equals(userId)) { + rowsCount--; + break; + } + } + Assert.assertEquals(allRows.size() - 1, rowsCount, "Did not find a row with the userId " + userId); + } + + //TC915102 + @Test + public void modifyUserRoleTest() { + User user = new User(); + user.setUserId(generateValidUserId()); + UserRoleEnum userRole = UserRoleEnum.DESIGNER; + AdminWorkspaceUIUtilies.createNewUser(user.getUserId(), userRole); + UserRoleEnum updatedUserRole = UserRoleEnum.TESTER; + AdminWorkspaceUIUtilies.updateUserRole(0, updatedUserRole); + UserManagementVerificator.validateUserRoleUpdated(0, updatedUserRole); + UserManagementVerificator.validateUserRoleUpdatedViaRest(user, getUser(), updatedUserRole); + } + + //TC915103 + @Test + public void deleteUserTest() { + User user = new User(); + user.setUserId(generateValidUserId()); + UserRoleEnum userRole = UserRoleEnum.DESIGNER; + AdminWorkspaceUIUtilies.createNewUser(user.getUserId(), userRole); + AdminWorkspaceUIUtilies.deleteFirstRow(); + UserManagementVerificator.validateUserIdNotFound(user.getUserId()); + UserManagementVerificator.validateUserNotFoundViaRest(user, getUser()); + } + + //TC951428 + @Test + public void modifyUserRoleWithTaskInHand_Checkout() throws Exception { + User newUser = new User(); + newUser.setUserId(generateValidUserId()); + UserRoleEnum userRole = UserRoleEnum.DESIGNER; + AdminWorkspaceUIUtilies.createNewUser(newUser.getUserId(), userRole); + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, newUser); + ExtentTestActions.log(Status.INFO, "Creating a new VF named " + resourceMetaData.getName() + " with the user " + newUser.getUserId()); + RestResponse createResourceResp = ResourceRestUtils.createResource(resourceMetaData, newUser); + Assert.assertEquals(createResourceResp.getErrorCode().intValue(), HttpStatus.SC_CREATED, "Did not succeed to create a VF"); + + UserRoleEnum updatedUserRole = UserRoleEnum.TESTER; + AdminWorkspaceUIUtilies.updateUserRole(0, updatedUserRole); + + ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS); + } + + + private static String generateValidUserId() { + final int charsPatternLength = 2; + final int digitsPatternLength = 4; + String charsPattern = "abcdefghijklmnopqrstuvwxyz"; + String digitPatter = "0123456789"; + String chars = ResourceUIUtils.buildStringFromPattern(charsPattern, charsPatternLength); + String digits = ResourceUIUtils.buildStringFromPattern(digitPatter, digitsPatternLength); + return chars + digits; + } + + private String generateValidMacId() { + final int digitsPatternLength = 5; + String digitPatter = "0123456789"; + String digits = ResourceUIUtils.buildStringFromPattern(digitPatter, digitsPatternLength); + return "m" + digits; + } + + private User createNewUserUsingAPI() { + UserRoleEnum role = UserRoleEnum.DESIGNER; + String userId = generateValidUserId(); + User userByEnv = new User(generateValidUserId(), generateValidUserId(), userId, generateValidUserId() + "@intl.sdc.com", role.name(), null); + User adminUser = getUserByEnv(UserRoleEnum.ADMIN); + try { + RestResponse createUserResp = UserRestUtils.createUser(userByEnv, adminUser); + Assert.assertEquals(createUserResp.getErrorCode().intValue(), HttpStatus.SC_CREATED, "Did not succeed to create a new user using API."); + } catch (IOException e) { + e.printStackTrace(); + } + return userByEnv; + } + + + private User getUserByEnv(UserRoleEnum userRole) { + try { + return getUser(userRole); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.ADMIN; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Annotation.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Annotation.java index b38c1175b4..cbab0e9bf7 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Annotation.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Annotation.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -43,38 +43,38 @@ import java.io.File; import static org.assertj.core.api.Assertions.assertThat; public class Annotation extends SetupCDTest { - private String filePath; + private String filePath; - @BeforeMethod - public void beforeTest() { - filePath = FileHandling.getFilePath("SRIOV"); - } + @BeforeMethod + public void beforeTest() { + filePath = FileHandling.getFilePath("SRIOV"); + } - @Test - public void importCsarWithAnnotationVerifyDownloadYmlContainsAnnotationSection() throws Exception { - String fileName = "SIROV_annotations_VSP.csar"; - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, - NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfFromCsar(vfMetaData, filePath, fileName, getUser()); - getExtendTest().log(Status.INFO, "Csar with annotations imported successfully."); - ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); - GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_MODEL.getValue()); - File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); - ToscaDefinition toscaMainVfDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(latestFilefromDir); - assertTrueAnnotationTestSuite(toscaMainVfDefinition); - getExtendTest().log(Status.INFO, "Success to validate the ToscaMainYaml contains annotation type source with properties."); - } + @Test + public void importCsarWithAnnotationVerifyDownloadYmlContainsAnnotationSection() throws Exception { + String fileName = "SIROV_annotations_VSP.csar"; + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, + NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfFromCsar(vfMetaData, filePath, fileName, getUser()); + getExtendTest().log(Status.INFO, "Csar with annotations imported successfully."); + ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); + GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_MODEL.getValue()); + File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); + ToscaDefinition toscaMainVfDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(latestFilefromDir); + assertTrueAnnotationTestSuite(toscaMainVfDefinition); + getExtendTest().log(Status.INFO, "Success to validate the ToscaMainYaml contains annotation type source with properties."); + } - - public void assertTrueAnnotationTestSuite(ToscaDefinition toscaMainVfDefinition) { - assertThat(toscaMainVfDefinition.getTopology_template().getInputs().get("availabilityzone_name").annotations).containsKey("source"); - assertThat(toscaMainVfDefinition.getTopology_template().getInputs().get("availabilityzone_name").getAnnotations().get("source").getType()).isEqualTo("org.openecomp.annotations.Source"); - assertThat(toscaMainVfDefinition.getTopology_template().getInputs().get("availabilityzone_name").getAnnotations().get("source").getProperties().get("source_type")).isEqualTo("HEAT"); - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + + public void assertTrueAnnotationTestSuite(ToscaDefinition toscaMainVfDefinition) { + assertThat(toscaMainVfDefinition.getTopology_template().getInputs().get("availabilityzone_name").annotations).containsKey("source"); + assertThat(toscaMainVfDefinition.getTopology_template().getInputs().get("availabilityzone_name").getAnnotations().get("source").getType()).isEqualTo("org.openecomp.annotations.Source"); + assertThat(toscaMainVfDefinition.getTopology_template().getInputs().get("availabilityzone_name").getAnnotations().get("source").getProperties().get("source_type")).isEqualTo("HEAT"); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ArchiveRestoreTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ArchiveRestoreTest.java index 7c7dc3d3a3..f17d1860f4 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ArchiveRestoreTest.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ArchiveRestoreTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,14 +27,31 @@ import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; -import org.openecomp.sdc.ci.tests.utilities.*; -import org.openecomp.sdc.ci.tests.utils.general.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.GovernorOperationPage; +import org.openecomp.sdc.ci.tests.pages.HomePage; +import org.openecomp.sdc.ci.tests.pages.OpsOperationPage; +import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.HomeUtils; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; +import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; import org.testng.annotations.Test; import static org.testng.AssertJUnit.assertTrue; @@ -92,7 +109,7 @@ public class ArchiveRestoreTest extends SetupCDTest { GeneralPageElements.clickSubmitForTestingButton(service.getName()); } -// https://sdp.web.att.com/fa3qm1/web/console/Application_Development_Tools_QM_20.20.01#action=com.ibm.rqm.planning.home.actionDispatcher&subAction=viewTestScript&id=896098 + // https://sdp.web.att.com/fa3qm1/web/console/Application_Development_Tools_QM_20.20.01#action=com.ibm.rqm.planning.home.actionDispatcher&subAction=viewTestScript&id=896098 @Test public void certifyVF_WhenVSP_Archived() throws Exception { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTest.java index c1c9406cb6..76483a3e88 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTest.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,12 +22,22 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.CheckBoxStatusEnum; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.CatalogPageLeftPanelSubCategoryCheckbox; +import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.TypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.verificator.CatalogVerificator; import org.openqa.selenium.WebElement; @@ -41,194 +51,195 @@ import java.util.List; import static org.testng.AssertJUnit.assertTrue; @Test(singleThreaded = true) -public class CatalogLeftPanelTest extends SetupCDTest{ - - private String filePath; - @BeforeMethod - public void beforeTest(){ - filePath = FileHandling.getFilePath(""); - } - - public static String[] resourceTypes = Arrays.stream(ResourceTypeEnum.class.getEnumConstants()). - map(ResourceTypeEnum::name).toArray(String[]::new); - - public static String[] catalogTypes = {"RESOURCE", "SERVICE"}; - - public static Object[][] provideData(String[] arObj) { - Object[][] arObject = new Object[arObj.length][]; - - int index = 0; - for (Object obj : arObj) { - arObject[index++] = new Object[]{obj}; - } - return arObject; - } - - @DataProvider(name = "Resource_Type_List") - private static final Object[][] resourceTypeList(){ - // Extract names of constants from enum as array of Strings - ResourceTypeEnum[] resourceEnums = {ResourceTypeEnum.CP, ResourceTypeEnum.VF, ResourceTypeEnum.VFC, ResourceTypeEnum.VL}; - String[] resourcesForTest = Arrays.stream(resourceEnums).map(ResourceTypeEnum::name).toArray(String[]::new); - return provideData(resourcesForTest); - } - - @DataProvider(name = "Type_List") - private static final Object[][] typeList(){ - // Extract names of constants from enum as array of Strings - Object[][] arObject = new Object[catalogTypes.length][]; - int index = 0; +public class CatalogLeftPanelTest extends SetupCDTest { + + private String filePath; + + @BeforeMethod + public void beforeTest() { + filePath = FileHandling.getFilePath(""); + } + + private static String[] resourceTypes = Arrays.stream(ResourceTypeEnum.class.getEnumConstants()). + map(ResourceTypeEnum::name).toArray(String[]::new); + + private static String[] catalogTypes = {"RESOURCE", "SERVICE"}; + + private static Object[][] provideData(String[] arObj) { + Object[][] arObject = new Object[arObj.length][]; + + int index = 0; + for (Object obj : arObj) { + arObject[index++] = new Object[]{obj}; + } + return arObject; + } + + @DataProvider(name = "Resource_Type_List") + private static Object[][] resourceTypeList() { + // Extract names of constants from enum as array of Strings + ResourceTypeEnum[] resourceEnums = {ResourceTypeEnum.CP, ResourceTypeEnum.VF, ResourceTypeEnum.VFC, ResourceTypeEnum.VL}; + String[] resourcesForTest = Arrays.stream(resourceEnums).map(ResourceTypeEnum::name).toArray(String[]::new); + return provideData(resourcesForTest); + } + + @DataProvider(name = "Type_List") + private static Object[][] typeList() { + // Extract names of constants from enum as array of Strings + Object[][] arObject = new Object[catalogTypes.length][]; + int index = 0; for (String catalogType : catalogTypes) { - if (catalogType.equals("RESOURCE")){ - arObject[index++] = new Object[]{catalogType, resourceTypes}; - } else { - arObject[index++] = new Object[]{catalogType, new String[] {catalogType}}; - } - } - return arObject; - } - - @DataProvider(name = "Status_List") - private static final Object[][] statusList(){ - CheckBoxStatusEnum[] checkboxes = {CheckBoxStatusEnum.CERTIFIED, - CheckBoxStatusEnum.IN_DESIGN, - CheckBoxStatusEnum.DISTRIBUTED, - CheckBoxStatusEnum.IN_TESTING, - CheckBoxStatusEnum.READY_FOR_TESTING}; - Object[][] arObject = new Object[checkboxes.length][]; - int index = 0; - for (CheckBoxStatusEnum checkbox: checkboxes) { - if (checkbox.equals(CheckBoxStatusEnum.CERTIFIED)){ - arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.CERTIFIED, LifeCycleStateEnum.DISTRIBUTED, LifeCycleStateEnum.WAITING_FOR_DISTRIBUTION) }; - } else if (checkbox.equals(CheckBoxStatusEnum.IN_DESIGN)) { - arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.CHECKIN, LifeCycleStateEnum.CHECKOUT)}; - } else if (checkbox.equals(CheckBoxStatusEnum.DISTRIBUTED)) { - arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.DISTRIBUTED)}; - } else if (checkbox.equals(CheckBoxStatusEnum.IN_TESTING)) { - arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.IN_TESTING)}; - } else if (checkbox.equals(CheckBoxStatusEnum.READY_FOR_TESTING)) { - arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.READY_FOR_TESTING)}; - } - } - return arObject; - } - - // filter by Type Resource in catalog - @Test(dataProvider = "Type_List") - public void filterByType(String catalogType, String[] classValues ) throws Exception { - setLog(catalogType); + if (catalogType.equals("RESOURCE")) { + arObject[index++] = new Object[]{catalogType, resourceTypes}; + } else { + arObject[index++] = new Object[]{catalogType, new String[]{catalogType}}; + } + } + return arObject; + } + + @DataProvider(name = "Status_List") + private static Object[][] statusList() { + CheckBoxStatusEnum[] checkboxes = {CheckBoxStatusEnum.CERTIFIED, + CheckBoxStatusEnum.IN_DESIGN, + CheckBoxStatusEnum.DISTRIBUTED, + CheckBoxStatusEnum.IN_TESTING, + CheckBoxStatusEnum.READY_FOR_TESTING}; + Object[][] arObject = new Object[checkboxes.length][]; + int index = 0; + for (CheckBoxStatusEnum checkbox : checkboxes) { + if (checkbox.equals(CheckBoxStatusEnum.CERTIFIED)) { + arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.CERTIFIED, LifeCycleStateEnum.DISTRIBUTED, LifeCycleStateEnum.WAITING_FOR_DISTRIBUTION)}; + } else if (checkbox.equals(CheckBoxStatusEnum.IN_DESIGN)) { + arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.CHECKIN, LifeCycleStateEnum.CHECKOUT)}; + } else if (checkbox.equals(CheckBoxStatusEnum.DISTRIBUTED)) { + arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.DISTRIBUTED)}; + } else if (checkbox.equals(CheckBoxStatusEnum.IN_TESTING)) { + arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.IN_TESTING)}; + } else if (checkbox.equals(CheckBoxStatusEnum.READY_FOR_TESTING)) { + arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.READY_FOR_TESTING)}; + } + } + return arObject; + } + + // filter by Type Resource in catalog + @Test(dataProvider = "Type_List") + public void filterByType(String catalogType, String[] classValues) throws Exception { + setLog(catalogType); // getExtendTest().setDescription(catalogType); - - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf(catalogType)); - CatalogVerificator.validateType(TypesEnum.valueOf(catalogType)); - } - - @Test(dataProvider = "Resource_Type_List") - public void filterByResourceType(String resourceType) throws Exception { - setLog(resourceType); + + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf(catalogType)); + CatalogVerificator.validateType(TypesEnum.valueOf(catalogType)); + } + + @Test(dataProvider = "Resource_Type_List") + public void filterByResourceType(String resourceType) throws Exception { + setLog(resourceType); // getExtendTest().setDescription(resourceType); - - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf(resourceType)); - - CatalogVerificator.validateType(TypesEnum.valueOf(resourceType)); - } - - @Test(dataProvider = "Status_List") - public void filterByStatus(CheckBoxStatusEnum statusCheckbox, List lifecycleStates) throws Exception{ - setLog(statusCheckbox.name()); + + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf(resourceType)); + + CatalogVerificator.validateType(TypesEnum.valueOf(resourceType)); + } + + @Test(dataProvider = "Status_List") + public void filterByStatus(CheckBoxStatusEnum statusCheckbox, List lifecycleStates) throws Exception { + setLog(statusCheckbox.name()); // getExtendTest().setDescription(statusCheckbox.name()); - - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.CATEGORIES); - CatalogUIUtilitis.catalogFilterStatusChecBox(statusCheckbox); - //TODO check the test after removing lifecycle steps for resource - CatalogVerificator.validateStatus(lifecycleStates, statusCheckbox.name()); - } - - @Test - public void filterByUpperCategory() throws Exception{ - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE); - - WebElement categoryCheckbox = CatalogUIUtilitis.clickOnUpperCategoryCheckbox(); - - CatalogVerificator.validateCategory(categoryCheckbox.getAttribute("textContent").trim()); - } - - @Test - public void filterByGenericDatabaseSubCategory() throws Exception{ - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE); - - WebElement checkboxElement = GeneralUIUtils.getElementsByCSS(CatalogPageLeftPanelSubCategoryCheckbox.DATABASE.getValue()).get(0); - String checkboxElementName = checkboxElement.getAttribute("textContent").trim(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s subcategory ...", checkboxElementName)); - GeneralUIUtils.clickOnAreaJS(checkboxElement); - CatalogVerificator.validateSubCategory("Generic", checkboxElementName); - } - - @Test(priority = 1) - public void lastUpdatedService() throws Exception{ - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); - String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); - assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", serviceMetadata.getName(), firstElementName), serviceMetadata.getName().equals(firstElementName)); - } - - @Test(priority = 17) - public void lastUpdatedResource() throws Exception{ - // create resource - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); - String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); - assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", vfMetaData.getName(), firstElementName), vfMetaData.getName().equals(firstElementName)); - } - - @Test(priority = 5) - public void fromCatalogCheckout() throws Exception{ - // create resource - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); - - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - ResourceGeneralPage.clickCheckoutButton(); - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); - } + + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.CATEGORIES); + CatalogUIUtilitis.catalogFilterStatusChecBox(statusCheckbox); + //TODO check the test after removing lifecycle steps for resource + CatalogVerificator.validateStatus(lifecycleStates, statusCheckbox.name()); + } + + @Test + public void filterByUpperCategory() throws Exception { + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE); + + WebElement categoryCheckbox = CatalogUIUtilitis.clickOnUpperCategoryCheckbox(); + + CatalogVerificator.validateCategory(categoryCheckbox.getAttribute("textContent").trim()); + } @Test - public void keepSearchResultsInCatalogAfterBrowserBack() throws Exception{ - ResourceReqDetails resourceMetadata = ElementFactory.getDefaultResource(); - ResourceUIUtils.createVF(resourceMetadata, getUser()); - ResourceGeneralPage.clickCheckinButton(resourceMetadata.getName()); - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + public void filterByGenericDatabaseSubCategory() throws Exception { + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE); + + WebElement checkboxElement = GeneralUIUtils.getElementsByCSS(CatalogPageLeftPanelSubCategoryCheckbox.DATABASE.getValue()).get(0); + String checkboxElementName = checkboxElement.getAttribute("textContent").trim(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s subcategory ...", checkboxElementName)); + GeneralUIUtils.clickOnAreaJS(checkboxElement); + CatalogVerificator.validateSubCategory("Generic", checkboxElementName); + } + + @Test(priority = 1) + public void lastUpdatedService() throws Exception { + // create service + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); + String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); + assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", serviceMetadata.getName(), firstElementName), serviceMetadata.getName().equals(firstElementName)); + } + + @Test(priority = 17) + public void lastUpdatedResource() throws Exception { + // create resource + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); + String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); + assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", vfMetaData.getName(), firstElementName), vfMetaData.getName().equals(firstElementName)); + } + + @Test(priority = 5) + public void fromCatalogCheckout() throws Exception { + // create resource + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); + ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + } + + @Test + public void keepSearchResultsInCatalogAfterBrowserBack() throws Exception { + ResourceReqDetails resourceMetadata = ElementFactory.getDefaultResource(); + ResourceUIUtils.createVF(resourceMetadata, getUser()); + ResourceGeneralPage.clickCheckinButton(resourceMetadata.getName()); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); CatalogUIUtilitis.catalogSearchBox(resourceMetadata.getName()); GeneralUIUtils.findComponentAndClick(resourceMetadata.getName()); - GeneralUIUtils.clickOnBrowserBackButton(); + GeneralUIUtils.clickOnBrowserBackButton(); - int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader(); - assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 1, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 1 ); + int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader(); + assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 1, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 1); - List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); - String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); - assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", resourceMetadata.getName(), firstElementName), resourceMetadata.getName().equals(firstElementName)); + List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); + String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); + assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", resourceMetadata.getName(), firstElementName), resourceMetadata.getName().equals(firstElementName)); } - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTestWithTime.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTestWithTime.java index dda6dd438f..87c10688a8 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTestWithTime.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTestWithTime.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,12 +22,22 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.CheckBoxStatusEnum; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.CatalogPageLeftPanelSubCategoryCheckbox; +import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.TypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.verificator.CatalogVerificator; @@ -40,87 +50,90 @@ import java.util.Arrays; import java.util.List; import static org.testng.AssertJUnit.assertTrue; + @Test(singleThreaded = true) -public class CatalogLeftPanelTestWithTime extends SetupCDTest{ - - private String filePath; - @BeforeMethod - public void beforeTest(){ - filePath = FileHandling.getFilePath(""); - } - - public static String[] resourceTypes = Arrays.stream(ResourceTypeEnum.class.getEnumConstants()). - map(ResourceTypeEnum::name).toArray(String[]::new); - - public static String[] catalogTypes = {"RESOURCE", "SERVICE"}; - - public static Object[][] provideData(String[] arObj) { - Object[][] arObject = new Object[arObj.length][]; +public class CatalogLeftPanelTestWithTime extends SetupCDTest { + + private static final int REGULAR_TEST_RUN_TIME = 400; + private String filePath; + + @BeforeMethod + public void beforeTest() { + filePath = FileHandling.getFilePath(""); + } + + private static String[] resourceTypes = Arrays.stream(ResourceTypeEnum.class.getEnumConstants()). + map(ResourceTypeEnum::name).toArray(String[]::new); + + private static String[] catalogTypes = {"RESOURCE", "SERVICE"}; + + private static Object[][] provideData(String[] arObj) { + Object[][] arObject = new Object[arObj.length][]; + + int index = 0; + for (Object obj : arObj) { + arObject[index++] = new Object[]{obj}; + } + return arObject; + } + + @DataProvider(name = "Resource_Type_List") + private static Object[][] resourceTypeList() { + // Extract names of constants from enum as array of Strings + ResourceTypeEnum[] resourceEnums = {ResourceTypeEnum.CP, ResourceTypeEnum.VF, ResourceTypeEnum.VFC, ResourceTypeEnum.VL}; + String[] resourcesForTest = Arrays.stream(resourceEnums).map(ResourceTypeEnum::name).toArray(String[]::new); + return provideData(resourcesForTest); + } - int index = 0; - for (Object obj : arObj) { - arObject[index++] = new Object[]{obj}; - } - return arObject; - } - - @DataProvider(name = "Resource_Type_List") - private static final Object[][] resourceTypeList(){ - // Extract names of constants from enum as array of Strings - ResourceTypeEnum[] resourceEnums = {ResourceTypeEnum.CP, ResourceTypeEnum.VF, ResourceTypeEnum.VFC, ResourceTypeEnum.VL}; - String[] resourcesForTest = Arrays.stream(resourceEnums).map(ResourceTypeEnum::name).toArray(String[]::new); - return provideData(resourcesForTest); - } - - @DataProvider(name = "Type_List") - private static final Object[][] typeList(){ - // Extract names of constants from enum as array of Strings - Object[][] arObject = new Object[catalogTypes.length][]; - int index = 0; + @DataProvider(name = "Type_List") + private static Object[][] typeList() { + // Extract names of constants from enum as array of Strings + Object[][] arObject = new Object[catalogTypes.length][]; + int index = 0; for (String catalogType : catalogTypes) { - if (catalogType.equals("RESOURCE")){ - arObject[index++] = new Object[]{catalogType, resourceTypes}; - } else { - arObject[index++] = new Object[]{catalogType, new String[] {catalogType}}; - } - } - return arObject; - } - - @DataProvider(name = "Status_List") - private static final Object[][] statusList(){ - CheckBoxStatusEnum[] checkboxes = {CheckBoxStatusEnum.CERTIFIED, - CheckBoxStatusEnum.IN_DESIGN, - CheckBoxStatusEnum.DISTRIBUTED, - CheckBoxStatusEnum.IN_TESTING, - CheckBoxStatusEnum.READY_FOR_TESTING}; - Object[][] arObject = new Object[checkboxes.length][]; - int index = 0; - for (CheckBoxStatusEnum checkbox: checkboxes) { - if (checkbox.equals(CheckBoxStatusEnum.CERTIFIED)){ - arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.CERTIFIED, LifeCycleStateEnum.DISTRIBUTED, LifeCycleStateEnum.WAITING_FOR_DISTRIBUTION) }; - } else if (checkbox.equals(CheckBoxStatusEnum.IN_DESIGN)) { - arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.CHECKIN, LifeCycleStateEnum.CHECKOUT)}; - } else if (checkbox.equals(CheckBoxStatusEnum.DISTRIBUTED)) { - arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.DISTRIBUTED)}; - } else if (checkbox.equals(CheckBoxStatusEnum.IN_TESTING)) { - arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.IN_TESTING)}; - } else if (checkbox.equals(CheckBoxStatusEnum.READY_FOR_TESTING)) { - arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.READY_FOR_TESTING)}; - } - } - return arObject; - } + if (catalogType.equals("RESOURCE")) { + arObject[index++] = new Object[]{catalogType, resourceTypes}; + } else { + arObject[index++] = new Object[]{catalogType, new String[]{catalogType}}; + } + } + return arObject; + } + + @DataProvider(name = "Status_List") + private static Object[][] statusList() { + CheckBoxStatusEnum[] checkboxes = {CheckBoxStatusEnum.CERTIFIED, + CheckBoxStatusEnum.IN_DESIGN, + CheckBoxStatusEnum.DISTRIBUTED, + CheckBoxStatusEnum.IN_TESTING, + CheckBoxStatusEnum.READY_FOR_TESTING}; + Object[][] arObject = new Object[checkboxes.length][]; + int index = 0; + for (CheckBoxStatusEnum checkbox : checkboxes) { + if (checkbox.equals(CheckBoxStatusEnum.CERTIFIED)) { + arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.CERTIFIED, LifeCycleStateEnum.DISTRIBUTED, LifeCycleStateEnum.WAITING_FOR_DISTRIBUTION)}; + } else if (checkbox.equals(CheckBoxStatusEnum.IN_DESIGN)) { + arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.CHECKIN, LifeCycleStateEnum.CHECKOUT)}; + } else if (checkbox.equals(CheckBoxStatusEnum.DISTRIBUTED)) { + arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.DISTRIBUTED)}; + } else if (checkbox.equals(CheckBoxStatusEnum.IN_TESTING)) { + arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.IN_TESTING)}; + } else if (checkbox.equals(CheckBoxStatusEnum.READY_FOR_TESTING)) { + arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.READY_FOR_TESTING)}; + } + } + return arObject; + } - // filter by Type Resource in catalog - @Test(dataProvider = "Type_List") - public void filterByTypeWithTime(String catalogType, String[] classValues ) throws Exception { - setLog(catalogType); - //Load catalog + // filter by Type Resource in catalog + @Test(dataProvider = "Type_List") + public void filterByTypeWithTime(String catalogType, String[] classValues) throws Exception { + setLog(catalogType); + //Load catalog Long actualTestRunTime = GeneralUIUtils.getAndValidateActionDuration(() -> - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG), 400); - SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + - actualTestRunTime + " seconds"); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG), REGULAR_TEST_RUN_TIME); + SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + + actualTestRunTime + " seconds"); //Filter by type actualTestRunTime = Utils.getAndValidateActionDuration(() -> { try { @@ -128,80 +141,80 @@ public class CatalogLeftPanelTestWithTime extends SetupCDTest{ } catch (Exception e) { e.printStackTrace(); } - }, 400); - SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog filtering time is " + - actualTestRunTime + " seconds"); + }, REGULAR_TEST_RUN_TIME); + SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog filtering time is " + + actualTestRunTime + " seconds"); //Validate number of elements after filtering - CatalogVerificator.validateType(TypesEnum.valueOf(catalogType)); - } - - @Test(dataProvider = "Resource_Type_List") - public void filterByResourceTypeWithTime(String resourceType) throws Exception { - setLog(resourceType); - //Load catalog + CatalogVerificator.validateType(TypesEnum.valueOf(catalogType)); + } + + @Test(dataProvider = "Resource_Type_List") + public void filterByResourceTypeWithTime(String resourceType) throws Exception { + setLog(resourceType); + //Load catalog Long actualTestRunTime = Utils.getAndValidateActionDuration(() -> - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG), 400); - SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + - actualTestRunTime + " seconds"); - //Filter by resource type - actualTestRunTime = Utils.getAndValidateActionDuration(() -> { - try { - CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf(resourceType)); - } catch (Exception e) { - e.printStackTrace(); - } - }, 400); - SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog filtering time is " + - actualTestRunTime + " seconds"); - //Validate number of elements after filtering - CatalogVerificator.validateType(TypesEnum.valueOf(resourceType)); - } - - @Test(dataProvider = "Status_List") - public void filterByStatus(CheckBoxStatusEnum statusCheckbox, List lifecycleStates) throws Exception{ - setLog(statusCheckbox.name()); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG), REGULAR_TEST_RUN_TIME); + SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + + actualTestRunTime + " seconds"); + //Filter by resource type + actualTestRunTime = Utils.getAndValidateActionDuration(() -> { + try { + CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf(resourceType)); + } catch (Exception e) { + e.printStackTrace(); + } + }, REGULAR_TEST_RUN_TIME); + SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog filtering time is " + + actualTestRunTime + " seconds"); + //Validate number of elements after filtering + CatalogVerificator.validateType(TypesEnum.valueOf(resourceType)); + } + + @Test(dataProvider = "Status_List") + public void filterByStatus(CheckBoxStatusEnum statusCheckbox, List lifecycleStates) throws Exception { + setLog(statusCheckbox.name()); //Load catalog Long actualTestRunTime = Utils.getAndValidateActionDuration(() -> - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG), 400); - SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + - actualTestRunTime + " seconds"); - CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.CATEGORIES); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG), REGULAR_TEST_RUN_TIME); + SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + + actualTestRunTime + " seconds"); + CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.CATEGORIES); //Filter by resource type - actualTestRunTime = Utils.getAndValidateActionDuration(() -> CatalogUIUtilitis.catalogFilterStatusChecBox(statusCheckbox), 400); - SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog filtering time is " + - actualTestRunTime + " seconds"); - //TODO check the test after removing lifecycle steps for resource + actualTestRunTime = Utils.getAndValidateActionDuration(() -> CatalogUIUtilitis.catalogFilterStatusChecBox(statusCheckbox), REGULAR_TEST_RUN_TIME); + SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog filtering time is " + + actualTestRunTime + " seconds"); + //TODO check the test after removing lifecycle steps for resource //Validate number of elements after filtering - CatalogVerificator.validateStatus(lifecycleStates, statusCheckbox.name()); - } + CatalogVerificator.validateStatus(lifecycleStates, statusCheckbox.name()); + } - @Test - public void filterByUpperCategory() throws Exception{ + @Test + public void filterByUpperCategory() throws Exception { //Load catalog Long actualTestRunTime = Utils.getAndValidateActionDuration(() -> - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG), 400); - SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + - actualTestRunTime + " seconds"); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG), REGULAR_TEST_RUN_TIME); + SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + + actualTestRunTime + " seconds"); //Filter by Upper Category - CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE); - actualTestRunTime = Utils.getAndValidateActionDuration(() -> CatalogUIUtilitis.clickOnUpperCategoryCheckbox(), 400); - SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog filtering time is " + - actualTestRunTime + " seconds"); - WebElement categoryCheckbox = CatalogUIUtilitis.getCategoryCheckbox(); - CatalogVerificator.validateCategory(categoryCheckbox.getAttribute("textContent").trim()); - } + CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE); + actualTestRunTime = Utils.getAndValidateActionDuration(() -> CatalogUIUtilitis.clickOnUpperCategoryCheckbox(), REGULAR_TEST_RUN_TIME); + SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog filtering time is " + + actualTestRunTime + " seconds"); + WebElement categoryCheckbox = CatalogUIUtilitis.getCategoryCheckbox(); + CatalogVerificator.validateCategory(categoryCheckbox.getAttribute("textContent").trim()); + } - @Test - public void filterByGenericDatabaseSubCategory() throws Exception{ + @Test + public void filterByGenericDatabaseSubCategory() throws Exception { //Load catalog Long actualTestRunTime = Utils.getAndValidateActionDuration(() -> - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG), 400); - SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + - actualTestRunTime + " seconds"); - CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG), REGULAR_TEST_RUN_TIME); + SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + + actualTestRunTime + " seconds"); + CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE); WebElement checkboxElement = GeneralUIUtils.getElementsByCSS(CatalogPageLeftPanelSubCategoryCheckbox.DATABASE.getValue()).get(0); - String checkboxElementName = checkboxElement.getAttribute("textContent").trim(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s subcategory ...", checkboxElementName)); + String checkboxElementName = checkboxElement.getAttribute("textContent").trim(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s subcategory ...", checkboxElementName)); //Filter by sub category actualTestRunTime = Utils.getAndValidateActionDuration(() -> { try { @@ -209,74 +222,74 @@ public class CatalogLeftPanelTestWithTime extends SetupCDTest{ } catch (Exception e) { e.printStackTrace(); } - }, 400); - SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog filtering time is " + - actualTestRunTime + " seconds"); + }, REGULAR_TEST_RUN_TIME); + SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog filtering time is " + + actualTestRunTime + " seconds"); //Validate filtering results - CatalogVerificator.validateSubCategory("Generic", checkboxElementName); - } - - @Test(priority = 1) - public void lastUpdatedService() throws Exception{ - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); - String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); - assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", serviceMetadata.getName(), firstElementName), serviceMetadata.getName().equals(firstElementName)); - } - - @Test(priority = 17) - public void lastUpdatedResource() throws Exception{ - // create resource - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); - String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); - assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", vfMetaData.getName(), firstElementName), vfMetaData.getName().equals(firstElementName)); - } - - @Test(priority = 5) - public void fromCatalogCheckout() throws Exception{ - // create resource - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CatalogVerificator.validateSubCategory("Generic", checkboxElementName); + } + + @Test(priority = 1) + public void lastUpdatedService() throws Exception { + // create service + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); + String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); + assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", serviceMetadata.getName(), firstElementName), serviceMetadata.getName().equals(firstElementName)); + } + + @Test(priority = 17) + public void lastUpdatedResource() throws Exception { + // create resource + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); + String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); + assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", vfMetaData.getName(), firstElementName), vfMetaData.getName().equals(firstElementName)); + } + + @Test(priority = 5) + public void fromCatalogCheckout() throws Exception { + // create resource + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); //Search in catalog - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - ResourceGeneralPage.clickCheckoutButton(); - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); - } + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); + ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + } @Test - public void keepSearchResultsInCatalogAfterBrowserBack() throws Exception{ - ResourceReqDetails resourceMetadata = ElementFactory.getDefaultResource(); - ResourceUIUtils.createVF(resourceMetadata, getUser()); - ResourceGeneralPage.clickCheckinButton(resourceMetadata.getName()); - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + public void keepSearchResultsInCatalogAfterBrowserBack() throws Exception { + ResourceReqDetails resourceMetadata = ElementFactory.getDefaultResource(); + ResourceUIUtils.createVF(resourceMetadata, getUser()); + ResourceGeneralPage.clickCheckinButton(resourceMetadata.getName()); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); CatalogUIUtilitis.catalogSearchBox(resourceMetadata.getName()); GeneralUIUtils.findComponentAndClick(resourceMetadata.getName()); - GeneralUIUtils.clickOnBrowserBackButton(); + GeneralUIUtils.clickOnBrowserBackButton(); - int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader(); - assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 1, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 1 ); + int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader(); + assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 1, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 1); - List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); - String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); - assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", resourceMetadata.getName(), firstElementName), resourceMetadata.getName().equals(firstElementName)); + List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); + String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); + assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", resourceMetadata.getName(), firstElementName), resourceMetadata.getName().equals(firstElementName)); } - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Categories.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Categories.java index 6bbe9c8fdc..57b6baa5f5 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Categories.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Categories.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -43,169 +43,158 @@ import java.util.stream.Collectors; public class Categories extends SetupCDTest { - - @Test - public void createResourceCategory() throws Exception { - - AdminGeneralPage.selectCategoryManagmetTab(); - String newResourceCategory = ElementFactory.getDefaultCategory().getName(); - AdminGeneralPage.createNewResourceCategory(newResourceCategory); -// GeneralUIUtils.clickSomewhereOnPage(); - List resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); - List collect = resourceCategoriesList.stream().map(f -> f.getText()).collect(Collectors.toList()); - collect.contains(newResourceCategory); - - - } - - @Test - public void createServiceCategory() throws Exception { - - AdminGeneralPage.selectCategoryManagmetTab(); - String newserviceCategory = ElementFactory.getDefaultCategory().getName(); - AdminGeneralPage.createNewServiceCategory(newserviceCategory); -// GeneralUIUtils.clickSomewhereOnPage(); - List serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); - List collect = serviceCategoriesList.stream().map(f -> f.getText()).collect(Collectors.toList()); - collect.contains(newserviceCategory); - - } - - - @Test - public void createResourceSubCategory() throws Exception { - - AdminGeneralPage.selectCategoryManagmetTab(); - String newResourceCategory = ElementFactory.getDefaultCategory().getName(); - String newserviceCategory = ElementFactory.getDefaultCategory().getName(); - String newSubCategory = ElementFactory.getDefaultSubCategory().getName(); - AdminGeneralPage.createNewResourceCategory(newResourceCategory); - AdminGeneralPage.createNewServiceCategory(newserviceCategory); - List serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); - List resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); - AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory , newSubCategory); - GeneralUIUtils.waitForLoader(); -// GeneralUIUtils.clickSomewhereOnPage(); - } - - - @Test - public void createExistingResourceCategory() throws Exception { - - AdminGeneralPage.selectCategoryManagmetTab(); - String newResourceCategory = ElementFactory.getDefaultCategory().getName(); - AdminGeneralPage.createNewResourceCategory(newResourceCategory); - AdminGeneralPage.createNewResourceCategory(newResourceCategory); - - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); - - - } - - @Test - public void createExistingServiceCategory() throws Exception { - - AdminGeneralPage.selectCategoryManagmetTab(); - String newserviceCategory = ElementFactory.getDefaultCategory().getName(); - AdminGeneralPage.createNewServiceCategory(newserviceCategory); - AdminGeneralPage.createNewServiceCategory(newserviceCategory); -// AdminGeneralPage.selectUserManagmetTab(); - - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); - - } - - @Test - public void createExsitingResourceSubCategory() throws Exception { - - - AdminGeneralPage.selectCategoryManagmetTab(); - String newResourceCategory = ElementFactory.getDefaultCategory().getName(); - String newserviceCategory = ElementFactory.getDefaultCategory().getName(); - String newSubCategory = ElementFactory.getDefaultSubCategory().getName(); - AdminGeneralPage.createNewResourceCategory(newResourceCategory); - AdminGeneralPage.createNewServiceCategory(newserviceCategory); - List serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); - List resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); - AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory , newSubCategory); - AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory , newSubCategory); - GeneralUIUtils.waitForLoader(); - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.COMPONENT_SUB_CATEGORY_EXISTS_FOR_CATEGORY.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); - - } - - - @Test - public void createServiceWithNewCategory() throws Exception { - - AdminGeneralPage.selectCategoryManagmetTab(); - String newResourceCategory = ElementFactory.getDefaultCategory().getName(); - String newserviceCategory = ElementFactory.getDefaultCategory().getName(); - String newSubCategory = ElementFactory.getDefaultSubCategory().getName(); - AdminGeneralPage.createNewResourceCategory(newResourceCategory); - AdminGeneralPage.createNewServiceCategory(newserviceCategory); - List serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); - List resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); - AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory , newSubCategory); - GeneralUIUtils.waitForLoader(); - AdminGeneralPage.selectUserManagmetTab(); - reloginWithNewRole(UserRoleEnum.DESIGNER); - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - List categories = serviceMetadata.getCategories(); - categories.get(0).setName(newserviceCategory); - - ServiceUIUtils.createService(serviceMetadata, getUser()); - - } - - - @Test - public void createResourceWithNewCategory() throws Exception { - - AdminGeneralPage.selectCategoryManagmetTab(); - String newResourceCategory = ElementFactory.getDefaultCategory().getName(); - String newserviceCategory = ElementFactory.getDefaultCategory().getName(); - String newSubCategory = ElementFactory.getDefaultSubCategory().getName(); - AdminGeneralPage.createNewResourceCategory(newResourceCategory); - AdminGeneralPage.createNewServiceCategory(newserviceCategory); - List serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); - List resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); - AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory , newSubCategory); - GeneralUIUtils.waitForLoader(); - AdminGeneralPage.selectUserManagmetTab(); - reloginWithNewRole(UserRoleEnum.DESIGNER); - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - List categories = resourceMetaData.getCategories(); - CategoryDefinition categoryDefinition = categories.get(0); - categoryDefinition.setName(newResourceCategory); - SubCategoryDefinition subCategoryDefinition = categoryDefinition.getSubcategories().get(0); - subCategoryDefinition.setName(newSubCategory); - - ResourceUIUtils.createVF(resourceMetaData, getUser()); - - - } - - - - - - - - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.ADMIN; - } + + @Test + public void createResourceCategory() throws Exception { + + AdminGeneralPage.selectCategoryManagmetTab(); + String newResourceCategory = ElementFactory.getDefaultCategory().getName(); + AdminGeneralPage.createNewResourceCategory(newResourceCategory); + List resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); + List collect = resourceCategoriesList.stream().map(f -> f.getText()).collect(Collectors.toList()); + collect.contains(newResourceCategory); + + + } + + @Test + public void createServiceCategory() throws Exception { + + AdminGeneralPage.selectCategoryManagmetTab(); + String newserviceCategory = ElementFactory.getDefaultCategory().getName(); + AdminGeneralPage.createNewServiceCategory(newserviceCategory); + List serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); + List collect = serviceCategoriesList.stream().map(f -> f.getText()).collect(Collectors.toList()); + collect.contains(newserviceCategory); + + } + + + @Test + public void createResourceSubCategory() throws Exception { + + AdminGeneralPage.selectCategoryManagmetTab(); + String newResourceCategory = ElementFactory.getDefaultCategory().getName(); + String newserviceCategory = ElementFactory.getDefaultCategory().getName(); + String newSubCategory = ElementFactory.getDefaultSubCategory().getName(); + AdminGeneralPage.createNewResourceCategory(newResourceCategory); + AdminGeneralPage.createNewServiceCategory(newserviceCategory); + List serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); + List resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); + AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory, newSubCategory); + GeneralUIUtils.waitForLoader(); + } + + + @Test + public void createExistingResourceCategory() throws Exception { + + AdminGeneralPage.selectCategoryManagmetTab(); + String newResourceCategory = ElementFactory.getDefaultCategory().getName(); + AdminGeneralPage.createNewResourceCategory(newResourceCategory); + AdminGeneralPage.createNewResourceCategory(newResourceCategory); + + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS.name()); + Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + + + } + + @Test + public void createExistingServiceCategory() throws Exception { + + AdminGeneralPage.selectCategoryManagmetTab(); + String newserviceCategory = ElementFactory.getDefaultCategory().getName(); + AdminGeneralPage.createNewServiceCategory(newserviceCategory); + AdminGeneralPage.createNewServiceCategory(newserviceCategory); + + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS.name()); + Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + + } + + @Test + public void createExsitingResourceSubCategory() throws Exception { + + + AdminGeneralPage.selectCategoryManagmetTab(); + String newResourceCategory = ElementFactory.getDefaultCategory().getName(); + String newserviceCategory = ElementFactory.getDefaultCategory().getName(); + String newSubCategory = ElementFactory.getDefaultSubCategory().getName(); + AdminGeneralPage.createNewResourceCategory(newResourceCategory); + AdminGeneralPage.createNewServiceCategory(newserviceCategory); + List serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); + List resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); + AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory, newSubCategory); + AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory, newSubCategory); + GeneralUIUtils.waitForLoader(); + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.COMPONENT_SUB_CATEGORY_EXISTS_FOR_CATEGORY.name()); + Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + + } + + + @Test + public void createServiceWithNewCategory() throws Exception { + + AdminGeneralPage.selectCategoryManagmetTab(); + String newResourceCategory = ElementFactory.getDefaultCategory().getName(); + String newserviceCategory = ElementFactory.getDefaultCategory().getName(); + String newSubCategory = ElementFactory.getDefaultSubCategory().getName(); + AdminGeneralPage.createNewResourceCategory(newResourceCategory); + AdminGeneralPage.createNewServiceCategory(newserviceCategory); + List serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); + List resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); + AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory, newSubCategory); + GeneralUIUtils.waitForLoader(); + AdminGeneralPage.selectUserManagmetTab(); + reloginWithNewRole(UserRoleEnum.DESIGNER); + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + List categories = serviceMetadata.getCategories(); + categories.get(0).setName(newserviceCategory); + + ServiceUIUtils.createService(serviceMetadata, getUser()); + + } + + + @Test + public void createResourceWithNewCategory() throws Exception { + + AdminGeneralPage.selectCategoryManagmetTab(); + String newResourceCategory = ElementFactory.getDefaultCategory().getName(); + String newserviceCategory = ElementFactory.getDefaultCategory().getName(); + String newSubCategory = ElementFactory.getDefaultSubCategory().getName(); + AdminGeneralPage.createNewResourceCategory(newResourceCategory); + AdminGeneralPage.createNewServiceCategory(newserviceCategory); + List serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); + List resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); + AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory, newSubCategory); + GeneralUIUtils.waitForLoader(); + AdminGeneralPage.selectUserManagmetTab(); + reloginWithNewRole(UserRoleEnum.DESIGNER); + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + List categories = resourceMetaData.getCategories(); + CategoryDefinition categoryDefinition = categories.get(0); + categoryDefinition.setName(newResourceCategory); + SubCategoryDefinition subCategoryDefinition = categoryDefinition.getSubcategories().get(0); + subCategoryDefinition.setName(newSubCategory); + + ResourceUIUtils.createVF(resourceMetaData, getUser()); + + + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.ADMIN; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CustomizationUUID.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CustomizationUUID.java index cecda509a1..f41b32e5f6 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CustomizationUUID.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CustomizationUUID.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,14 +22,28 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.HomePage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; +import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.verificator.CustomizationUUIDVerificator; import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator; @@ -43,318 +57,276 @@ import java.util.ArrayList; import java.util.List; public class CustomizationUUID extends SetupCDTest { - - private static final String DESCRIPTION = "kuku"; - private static final String ARTIFACT_LABEL = "artifact3"; - private static final String ARTIFACT_LABEL_UPDATE = "artifactUpdate"; - private static final String GET_ARTIFACT_LIST_BY_CLASS_NAME = "i-sdc-designer-sidebar-section-content-item-artifact"; - private static final String HEAT_FILE_YAML_NAME = "Heat-File.yaml"; - private static final String HEAT_FILE_YAML_UPDATE_NAME = "Heat-File-Update.yaml"; - private String filePath; - - @BeforeMethod - public void beforeTest(){ - filePath = FileHandling.getFilePath(""); - } - - @Test - public void uniqueCustomizationUUIDforeachVFi() throws Exception { - - - ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); - - /* reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - TesterOperationPage.certifyComponent(vfMetaData.getName()); - - reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - - List customizationUUIDs = new ArrayList(); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager); - CanvasElement VFiElement2 = addElemntToCanvas(vfMetaData, canvasManager); - CanvasElement VFiElement3 = addElemntToCanvas(vfMetaData, canvasManager); - - - ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement2); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement3); - - ServiceGeneralPage.clickCheckoutButton(); - canvasManager = CanvasManager.getCanvasManager(); - CanvasElement VFiElement4 = addElemntToCanvas(vfMetaData, canvasManager); - CanvasElement VFiElement5 = addElemntToCanvas(vfMetaData, canvasManager); - CanvasElement VFiElement6 = addElemntToCanvas(vfMetaData, canvasManager); - - ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement4); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement5); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement6); - - CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs); - - - } - - - @Test - public void uniqueCustomizationUUIDafterArtifactCRUDofVFi() throws Exception { - - - ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); - - /*reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - TesterOperationPage.certifyComponent(vfMetaData.getName()); - - reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - - List customizationUUIDs = new ArrayList<>(); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager); - - ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); - - //add artifact to VFI - - ServiceGeneralPage.clickCheckoutButton(); - canvasManager = CanvasManager.getCanvasManager(); - - ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,ArtifactTypeEnum.SNMP_POLL.getType()); - - canvasManager.clickOnCanvaElement(VFiElement1); - CompositionPage.showDeploymentArtifactTab(); - CompositionPage.clickAddArtifactButton(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); - - - ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); - - - //delete VFI artifacts - - ServiceGeneralPage.clickCheckoutButton(); - canvasManager = CanvasManager.getCanvasManager(); - canvasManager.clickOnCanvaElement(VFiElement1); - CompositionPage.showDeploymentArtifactTab(); - List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); - GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ITEM.getValue() + ARTIFACT_LABEL); - SetupCDTest.getExtendTest().log(Status.INFO, "Going to delete " + HEAT_FILE_YAML_NAME + " artifact" + " and check if deleted"); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + ARTIFACT_LABEL); - GeneralPageElements.clickOKButton(); - - - ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); - - - CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs); - - } - - - @Test - public void uniqueCustomizationUUIDchangeVFiVersion() throws Exception { - - - ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); - - /*reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - TesterOperationPage.certifyComponent(vfMetaData.getName()); - - reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - - List customizationUUIDs = new ArrayList<>(); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager); - - ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); - - //change VF version - HomePage.navigateToHomePage(); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - ResourceGeneralPage.clickCheckoutButton(); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); - /*reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - TesterOperationPage.certifyComponent(vfMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - - //update VFI version - - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - ServiceGeneralPage.clickCheckoutButton(); - canvasManager = CanvasManager.getCanvasManager(); - canvasManager.clickOnCanvaElement(VFiElement1); - CompositionPage.changeComponentVersion(canvasManager, VFiElement1, "2.0"); - - ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); - - CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs); - - } - - - @Test - public void uniqueCustomizationUUIDaddRelation() throws Exception { - - - ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); - - /*reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - TesterOperationPage.certifyComponent(vfMetaData.getName()); - - reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - - List customizationUUIDs = new ArrayList<>(); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager); - - ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); - - //change VF version - HomePage.navigateToHomePage(); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - ResourceGeneralPage.clickCheckoutButton(); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); - /*reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - TesterOperationPage.certifyComponent(vfMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - - //update VFI version - - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - ServiceGeneralPage.clickCheckoutButton(); - canvasManager = CanvasManager.getCanvasManager(); -// CompositionPage.searchForElement(NormativeTypesEnum.PORT.getFolderName()); - CanvasElement contrailPortElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.CONTRAIL_PORT); - canvasManager.linkElements(contrailPortElement, VFiElement1); - - canvasManager.clickOnCanvaElement(VFiElement1); - - - ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); - addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); - - CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs); - - } - - - - public CanvasManager findServiceAndNavigateToCanvas(ServiceReqDetails serviceMetadata) throws Exception { - CanvasManager canvasManager; - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - canvasManager = CanvasManager.getCanvasManager(); - return canvasManager; - } - - public ResourceReqDetails createNewResourceWithArtifactCertifyState() throws Exception { - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - - List deploymentArtifactList = new ArrayList<>(); - deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); - deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML")); - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); - } - AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); - - String newDescription = "new description"; - DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel()); - DeploymentArtifactPage.artifactPopup().insertDescription(newDescription); - DeploymentArtifactPage.artifactPopup().clickDoneButton(); - String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel()); - AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); - - DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel()); - DeploymentArtifactPage.clickOK(); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - -// ResourceReqDetails vfcCompute = ElementFactory.getDefaultResource(NormativeTypesEnum.COMPUTE); - CompositionPage.searchForElement(NormativeTypesEnum.COMPUTE.name()); - CanvasManager canvasManagerVF = CanvasManager.getCanvasManager(); - CanvasElement VFiElement1 = canvasManagerVF.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); - return vfMetaData; - } - - public void addCanvasElementToList(List customizationUUIDs, CanvasManager canvasManager, CanvasElement VFiElement1) - throws Exception { - canvasManager.clickOnCanvaElement(VFiElement1); - WebElement VFi1customizationUUID = CompositionPage.getCustomizationUUID(); - customizationUUIDs.add(VFi1customizationUUID.getText()); - } - - public CanvasElement addElemntToCanvas(ResourceReqDetails vfMetaData, CanvasManager canvasManager) - throws Exception { - CompositionPage.searchForElement(vfMetaData.getName()); - CanvasElement VFiElement1 = canvasManager.createElementOnCanvas(vfMetaData.getName()); - return VFiElement1; - } - - public static void changeDeleteAndValidateVersionOnGeneralPage(String previousVersion, String currentVersion, String serviceName) throws Exception{ - GeneralPageElements.selectVersion("V" + previousVersion); - ServiceVerificator.verifyVersionUI(previousVersion); - GeneralUIUtils.clickJSOnElementByText("latest version"); - ServiceVerificator.verifyVersionUI(currentVersion); - GeneralPageElements.clickTrashButtonAndConfirm(); - GeneralUIUtils.findComponentAndClick(serviceName); - ServiceVerificator.verifyVersionUI(previousVersion); - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + + private static final String DESCRIPTION = "kuku"; + private static final String ARTIFACT_LABEL = "artifact3"; + private static final String ARTIFACT_LABEL_UPDATE = "artifactUpdate"; + private static final String GET_ARTIFACT_LIST_BY_CLASS_NAME = "i-sdc-designer-sidebar-section-content-item-artifact"; + private static final String HEAT_FILE_YAML_NAME = "Heat-File.yaml"; + private static final String HEAT_FILE_YAML_UPDATE_NAME = "Heat-File-Update.yaml"; + private String filePath; + + private CustomizationUUID() { + } + + @BeforeMethod + public void beforeTest() { + filePath = FileHandling.getFilePath(""); + } + + @Test + public void uniqueCustomizationUUIDforeachVFi() throws Exception { + + + ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); + + List customizationUUIDs = new ArrayList(); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager); + CanvasElement VFiElement2 = addElemntToCanvas(vfMetaData, canvasManager); + CanvasElement VFiElement3 = addElemntToCanvas(vfMetaData, canvasManager); + + + ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement2); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement3); + + ServiceGeneralPage.clickCheckoutButton(); + canvasManager = CanvasManager.getCanvasManager(); + CanvasElement VFiElement4 = addElemntToCanvas(vfMetaData, canvasManager); + CanvasElement VFiElement5 = addElemntToCanvas(vfMetaData, canvasManager); + CanvasElement VFiElement6 = addElemntToCanvas(vfMetaData, canvasManager); + + ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement4); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement5); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement6); + + CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs); + + + } + + + @Test + public void uniqueCustomizationUUIDafterArtifactCRUDofVFi() throws Exception { + + + ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); + + List customizationUUIDs = new ArrayList<>(); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager); + + ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); + + ServiceGeneralPage.clickCheckoutButton(); + canvasManager = CanvasManager.getCanvasManager(); + + ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, ArtifactTypeEnum.SNMP_POLL.getType()); + + canvasManager.clickOnCanvaElement(VFiElement1); + CompositionPage.showDeploymentArtifactTab(); + CompositionPage.clickAddArtifactButton(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); + + + ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); + + + ServiceGeneralPage.clickCheckoutButton(); + canvasManager = CanvasManager.getCanvasManager(); + canvasManager.clickOnCanvaElement(VFiElement1); + CompositionPage.showDeploymentArtifactTab(); + List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); + GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ITEM.getValue() + ARTIFACT_LABEL); + SetupCDTest.getExtendTest().log(Status.INFO, "Going to delete " + HEAT_FILE_YAML_NAME + " artifact" + " and check if deleted"); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + ARTIFACT_LABEL); + GeneralPageElements.clickOKButton(); + + + ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); + + + CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs); + + } + + + @Test + public void uniqueCustomizationUUIDchangeVFiVersion() throws Exception { + + + ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); + + List customizationUUIDs = new ArrayList<>(); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager); + + ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); + + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); + ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); + + + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + ServiceGeneralPage.clickCheckoutButton(); + canvasManager = CanvasManager.getCanvasManager(); + canvasManager.clickOnCanvaElement(VFiElement1); + CompositionPage.changeComponentVersion(canvasManager, VFiElement1, "2.0"); + + ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); + + CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs); + + } + + + @Test + public void uniqueCustomizationUUIDaddRelation() throws Exception { + + + ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); + + List customizationUUIDs = new ArrayList<>(); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager); + + ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); + + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); + + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + ServiceGeneralPage.clickCheckoutButton(); + canvasManager = CanvasManager.getCanvasManager(); + CanvasElement contrailPortElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.CONTRAIL_PORT); + canvasManager.linkElements(contrailPortElement, VFiElement1); + + canvasManager.clickOnCanvaElement(VFiElement1); + + + ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); + addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1); + + CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs); + + } + + + public CanvasManager findServiceAndNavigateToCanvas(ServiceReqDetails serviceMetadata) throws Exception { + CanvasManager canvasManager; + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + canvasManager = CanvasManager.getCanvasManager(); + return canvasManager; + } + + public ResourceReqDetails createNewResourceWithArtifactCertifyState() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + List deploymentArtifactList = new ArrayList<>(); + deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); + deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML")); + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); + } + AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); + + String newDescription = "new description"; + DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel()); + DeploymentArtifactPage.artifactPopup().insertDescription(newDescription); + DeploymentArtifactPage.artifactPopup().clickDoneButton(); + String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel()); + AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); + + DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel()); + DeploymentArtifactPage.clickOK(); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + CompositionPage.searchForElement(NormativeTypesEnum.COMPUTE.name()); + CanvasManager canvasManagerVF = CanvasManager.getCanvasManager(); + CanvasElement VFiElement1 = canvasManagerVF.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); + + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); + return vfMetaData; + } + + public void addCanvasElementToList(List customizationUUIDs, CanvasManager canvasManager, CanvasElement VFiElement1) + throws Exception { + canvasManager.clickOnCanvaElement(VFiElement1); + WebElement VFi1customizationUUID = CompositionPage.getCustomizationUUID(); + customizationUUIDs.add(VFi1customizationUUID.getText()); + } + + public CanvasElement addElemntToCanvas(ResourceReqDetails vfMetaData, CanvasManager canvasManager) + throws Exception { + CompositionPage.searchForElement(vfMetaData.getName()); + CanvasElement VFiElement1 = canvasManager.createElementOnCanvas(vfMetaData.getName()); + return VFiElement1; + } + + public static void changeDeleteAndValidateVersionOnGeneralPage(String previousVersion, String currentVersion, String serviceName) throws Exception { + GeneralPageElements.selectVersion("V" + previousVersion); + ServiceVerificator.verifyVersionUI(previousVersion); + GeneralUIUtils.clickJSOnElementByText("latest version"); + ServiceVerificator.verifyVersionUI(currentVersion); + GeneralPageElements.clickTrashButtonAndConfirm(); + GeneralUIUtils.findComponentAndClick(serviceName); + ServiceVerificator.verifyVersionUI(previousVersion); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java index 52dd381216..96db11c0db 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,230 +47,244 @@ import java.util.Map; import static org.testng.Assert.assertTrue; public class DeploymentViewTests extends SetupCDTest { - - private String filePath; - - @BeforeMethod - public void beforeTest(){ - filePath = FileHandling.getFilePath(""); - } - - @DataProvider(name = "CSAR_VF_Files", parallel = false) + + private static final int EXPECTED_NUMBER_OF_GROUPS = 3; + private String filePath; + + @BeforeMethod + public void beforeTest() { + filePath = FileHandling.getFilePath(""); + } + + @DataProvider(name = "CSAR_VF_Files", parallel = false) public Object[][] createDataX() { - return new Object[][] {{"vSeGWNew.csar"}, {"vSeGWNewDoubleMembers.csar"}, {"vSeGWNewSingleModule.csar"}}; + return new Object[][]{{"vSeGWNew.csar"}, {"vSeGWNewDoubleMembers.csar"}, {"vSeGWNewSingleModule.csar"}}; } - - - @Test(dataProvider = "CSAR_VF_Files") - public void deploymentScreenDCAEAssetImportCSARTest(String baseFileName) throws Exception{ - // - setLog(baseFileName); + + + @Test(dataProvider = "CSAR_VF_Files") + public void deploymentScreenDCAEAssetImportCSARTest(String baseFileName) throws Exception { + // + setLog(baseFileName); // getExtendTest().setDescription(baseFileName); - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen(); - List moduleRowsFromTable = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue()); - DeploymentViewVerificator verificator = new DeploymentViewVerificator(filePath + baseFileName); - verificator.verifyDeploymentPageModules(moduleRowsFromTable); - for(WebElement moduleRow : moduleRowsFromTable){ - String moduleRowText = moduleRow.getText(); - verificator.verifyDeploymentPageSubElements(moduleRowText.split("\\.\\.")[1]); - DeploymentPage.updateModuleName(moduleRowText, "updatedName"); - String updatedModuleName = DeploymentPage.reconstructModuleName(moduleRowText.split("\\.\\."), "updatedName"); - verificator.verifyComponentNameChanged( moduleRowText, updatedModuleName); - // Close module - GeneralUIUtils.clickOnElementByText(updatedModuleName); - } - } - - @Test - public void deploymentScreenDCAEAssetUpdateWithNewGroupCSAR_TC1368223_Test() throws Exception{ - String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; - String updateFileName = "baseUpdateFlowVF_NEW.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2)); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); - - Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); - metaDataFromUI.put("base_ldsa", new HashMap (){ {put("version", "0"); - put("moduleID", "primary");}}); - - // add new group, base_ldsa - ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now", 3)); - ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); - - DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName)); - DeploymentViewVerificator.validateModuleNameUpadate(); - }; - - @Test - public void deploymentScreenDCAEAssetDeleteGroupFromCSAR_TC1368281_Test() throws Exception{ - String baseFileName = "baseUpdateFlowVF_NEW.csar"; - String updateFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 3)); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); - - Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); - - // remove group base_ldsa - ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group should be removed", 2)); - ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); - - // validate that group was removed - DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName)); - - Map> metaDataFromUI2 = DeploymentPage.collectMetaDataFromUI(); - metaDataFromUI2.put("base_ldsa", new HashMap (){ {put("version", "0"); - put("moduleID", "primary");}}); - - ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); - // add group base_ldsa - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group should be added", 3)); - ResourceUIUtils.updateVfWithCsar(filePath, baseFileName); - - // validate that group was added - DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI2, new DeploymentViewVerificator(filePath + baseFileName)); - DeploymentViewVerificator.validateModuleNameUpadate(); - } - - @Test - public void deploymentScreenDCAEAssetUpdateWithNewGroupWithoutMembersCSAR_TC1368280_Test() throws Exception{ - - String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; - String updateFileName = "baseUpdateAddGroupNoMembersUpdateFlow_NEW.csar"; - String updateFileName2 = "baseUpdateFlowVF_NEW.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2)); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); - - // add new group without members, base_ldsa - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group without members", 3)); - ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); - - Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); - - // validate that group was added and no members exist - DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + updateFileName)); - - ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); - // add group base_ldsa with members - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group with members", 3)); - ResourceUIUtils.updateVfWithCsar(filePath, updateFileName2); - - // validate that member was added to base_ldsa group - DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName2)); - DeploymentViewVerificator.validateModuleNameUpadate(); - }; - - @Test - public void deploymentScreenDCAEAssetImportCSARWithArtifactSection_TC1368282_1_Test() throws Exception{ - String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", 3)); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); - - DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + baseFileName)); - DeploymentViewVerificator.validateModuleNameUpadate(); - }; - - @Test - public void deploymentScreenDCAEAssetImportCSARRemoveArtifact_TC1368282_2_Test() throws Exception{ - String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; - String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", 3)); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); - - Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); - - ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); - // remove artifact from every group - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be 3 artifacts in every group")); - ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); - - DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName)); - DeploymentViewVerificator.validateModuleNameUpadate(); - }; - - @Test - public void deploymentScreenDCAEAssetImportCSARAddArtifact_TC1368282_3_Test() throws Exception{ - String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; - String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 3 artifacts in every group ", 3)); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, updateFileName, getUser()); - - Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); - - ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); - // add artifact to every group - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be 4 artifacts in every group")); - ResourceUIUtils.updateVfWithCsar(filePath, baseFileName); - - DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + baseFileName)); - DeploymentViewVerificator.validateModuleNameUpadate(); - }; - - @Test - public void deploymentScreenDCAEAssetImportCSARMixArtifacts_TC1368282_4_Test() throws Exception{ - String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; - String updateFileName = "baseUpdateMixedArtifacts_NEW.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", 3)); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); - - Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); - - ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); - //mix artifacts between groups - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, mixing between artifacts and groups", 3)); - ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); - - DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator()); - DeploymentViewVerificator.validateModuleNameUpadate(); - }; - - @Test - public void deploymentScreenDCAEAssetUpdateVFModule_TC1296437_Test() throws Exception{ - String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; - String updateFileName = "baseUpdateFlowVF_NEW.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2)); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen(); + List moduleRowsFromTable = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue()); + DeploymentViewVerificator verificator = new DeploymentViewVerificator(filePath + baseFileName); + verificator.verifyDeploymentPageModules(moduleRowsFromTable); + for (WebElement moduleRow : moduleRowsFromTable) { + String moduleRowText = moduleRow.getText(); + verificator.verifyDeploymentPageSubElements(moduleRowText.split("\\.\\.")[1]); + DeploymentPage.updateModuleName(moduleRowText, "updatedName"); + String updatedModuleName = DeploymentPage.reconstructModuleName(moduleRowText.split("\\.\\."), "updatedName"); + verificator.verifyComponentNameChanged(moduleRowText, updatedModuleName); + // Close module + GeneralUIUtils.clickOnElementByText(updatedModuleName); + } + } + + @Test + public void deploymentScreenDCAEAssetUpdateWithNewGroupCSAR_TC1368223_Test() throws Exception { + String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; + String updateFileName = "baseUpdateFlowVF_NEW.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2)); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); + + Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); + metaDataFromUI.put("base_ldsa", new HashMap() { + { + put("version", "0"); + put("moduleID", "primary"); + } + }); + + // add new group, base_ldsa + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); + + DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName)); + DeploymentViewVerificator.validateModuleNameUpadate(); + } + + @Test + public void deploymentScreenDCAEAssetDeleteGroupFromCSAR_TC1368281_Test() throws Exception { + String baseFileName = "baseUpdateFlowVF_NEW.csar"; + String updateFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); + + Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); + + // remove group base_ldsa + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group should be removed", 2)); + ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); + + // validate that group was removed + DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName)); + + Map> metaDataFromUI2 = DeploymentPage.collectMetaDataFromUI(); + metaDataFromUI2.put("base_ldsa", new HashMap() { + { + put("version", "0"); + put("moduleID", "primary"); + } + }); + + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + // add group base_ldsa + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group should be added", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.updateVfWithCsar(filePath, baseFileName); + + // validate that group was added + DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI2, new DeploymentViewVerificator(filePath + baseFileName)); + DeploymentViewVerificator.validateModuleNameUpadate(); + } + + @Test + public void deploymentScreenDCAEAssetUpdateWithNewGroupWithoutMembersCSAR_TC1368280_Test() throws Exception { + + String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; + String updateFileName = "baseUpdateAddGroupNoMembersUpdateFlow_NEW.csar"; + String updateFileName2 = "baseUpdateFlowVF_NEW.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2)); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); + + // add new group without members, base_ldsa + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group without members", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); + + Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); + + // validate that group was added and no members exist + DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + updateFileName)); + + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + // add group base_ldsa with members + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group with members", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.updateVfWithCsar(filePath, updateFileName2); + + // validate that member was added to base_ldsa group + DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName2)); + DeploymentViewVerificator.validateModuleNameUpadate(); + } + + + @Test + public void deploymentScreenDCAEAssetImportCSARWithArtifactSection_TC1368282_1_Test() throws Exception { + String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); + + DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + baseFileName)); + DeploymentViewVerificator.validateModuleNameUpadate(); + } + + @Test + public void deploymentScreenDCAEAssetImportCSARRemoveArtifact_TC1368282_2_Test() throws Exception { + String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; + String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); + + Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); + + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + // remove artifact from every group + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be 3 artifacts in every group")); + ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); + + DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName)); + DeploymentViewVerificator.validateModuleNameUpadate(); + } + + @Test + public void deploymentScreenDCAEAssetImportCSARAddArtifact_TC1368282_3_Test() throws Exception { + String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; + String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 3 artifacts in every group ", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, updateFileName, getUser()); + + Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); + + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + // add artifact to every group + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be 4 artifacts in every group")); + ResourceUIUtils.updateVfWithCsar(filePath, baseFileName); + + DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + baseFileName)); + DeploymentViewVerificator.validateModuleNameUpadate(); + } + + @Test + public void deploymentScreenDCAEAssetImportCSARMixArtifacts_TC1368282_4_Test() throws Exception { + String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar"; + String updateFileName = "baseUpdateMixedArtifacts_NEW.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); + + Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); + + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + //mix artifacts between groups + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, mixing between artifacts and groups", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); + + DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator()); + DeploymentViewVerificator.validateModuleNameUpadate(); + } + + @Test + public void deploymentScreenDCAEAssetUpdateVFModule_TC1296437_Test() throws Exception { + String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar"; + String updateFileName = "baseUpdateFlowVF_NEW.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2)); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser()); // SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating %s group version, should be %s ", moduleRowText, metaDataFromUI.get(moduleRowText.split("\\.\\.")[1]))); - - Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); - metaDataFromUI.put("base_ldsa", new HashMap (){ {put("version", "0"); - put("moduleID", "primary");}}); - - DeploymentViewVerificator.validateEditPopover(); - - ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now", 3)); - ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); - - assertTrue(resourceMetaData.getName().equals(ResourceGeneralPage.getNameText())); - DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName)); - DeploymentViewVerificator.validateModuleNameUpadate(); - } - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + + Map> metaDataFromUI = DeploymentPage.collectMetaDataFromUI(); + metaDataFromUI.put("base_ldsa", new HashMap() { + { + put("version", "0"); + put("moduleID", "primary"); + } + }); + + DeploymentViewVerificator.validateEditPopover(); + + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now", EXPECTED_NUMBER_OF_GROUPS)); + ResourceUIUtils.updateVfWithCsar(filePath, updateFileName); + + assertTrue(resourceMetaData.getName().equals(ResourceGeneralPage.getNameText())); + DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName)); + DeploymentViewVerificator.validateModuleNameUpadate(); + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java index b1740b455a..f9cb233448 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,19 +21,39 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; -import static org.assertj.core.api.Assertions.assertThat; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InformationalArtifactsPlaceholders; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ResourceMetadataEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.*; +import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage; +import org.openecomp.sdc.ci.tests.pages.InputsPage; +import org.openecomp.sdc.ci.tests.pages.PropertiesPage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ToscaArtifactsPage; +import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.PropertiesUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.RestCDUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; @@ -46,613 +66,617 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import static org.assertj.core.api.Assertions.assertThat; import static org.testng.AssertJUnit.assertTrue; public class ImportDCAE extends SetupCDTest { - private static final String SERVICE_INPUT_TEST_VF2_CSAR = "service_input_test_VF2.csar"; - private String filePath; - - @BeforeMethod - public void beforeTest(){ - filePath = FileHandling.getFilePath(""); - } - - @Test - public void updateDCAEAsset() throws Exception { - ResourceReqDetails resourceMetaData = createDCAEAsset(); - - // update Resource - ResourceReqDetails updatedResource = new ResourceReqDetails(); - updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + resourceMetaData.getName()); - updatedResource.setDescription("kuku"); - updatedResource.setVendorName("updatedVendor"); - updatedResource.setVendorRelease("updatedRelease"); - updatedResource.setContactId("ab0001"); - updatedResource.setCategories(resourceMetaData.getCategories()); - updatedResource.setVersion("0.1"); - List newTags = resourceMetaData.getTags(); - newTags.remove(resourceMetaData.getName()); - newTags.add(updatedResource.getName()); - updatedResource.setTags(newTags); - ResourceUIUtils.updateResource(updatedResource, getUser()); - - VfVerificator.verifyVFMetadataInUI(updatedResource); - VfVerificator.verifyVFUpdated(updatedResource, getUser()); - } - - @Test - public void vfcLinkedToComputeInDCAEAssetFlowTest() throws Exception { - String fileName = "importVFC_VFC14.yml"; - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - - try{ - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); + private static final int CLICKING_ON_ELEMENT_TIMEOUT = 30; + + private static final String SERVICE_INPUT_TEST_VF2_CSAR = "service_input_test_VF2.csar"; + private String filePath; + + @BeforeMethod + public void beforeTest() { + filePath = FileHandling.getFilePath(""); + } + + @Test + public void updateDCAEAsset() throws Exception { + ResourceReqDetails resourceMetaData = createDCAEAsset(); + + // update Resource + ResourceReqDetails updatedResource = new ResourceReqDetails(); + updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + resourceMetaData.getName()); + updatedResource.setDescription("kuku"); + updatedResource.setVendorName("updatedVendor"); + updatedResource.setVendorRelease("updatedRelease"); + updatedResource.setContactId("ab0001"); + updatedResource.setCategories(resourceMetaData.getCategories()); + updatedResource.setVersion("0.1"); + List newTags = resourceMetaData.getTags(); + newTags.remove(resourceMetaData.getName()); + newTags.add(updatedResource.getName()); + updatedResource.setTags(newTags); + ResourceUIUtils.updateResource(updatedResource, getUser()); + + VfVerificator.verifyVFMetadataInUI(updatedResource); + VfVerificator.verifyVFUpdated(updatedResource, getUser()); + } + + @Test + public void vfcLinkedToComputeInDCAEAssetFlowTest() throws Exception { + final int expectedNumberOfComponentInstances = 4; + String fileName = "importVFC_VFC14.yml"; + ResourceReqDetails atomicResourceMetaData = + ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory( + ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + + try { + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); TesterOperationPage.certifyComponent(atomicResourceMetaData.getName()); reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - ResourceReqDetails resourceMetaData = createDCAEAsset(); - - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - CanvasElement cpElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - Assert.assertNotNull(cpElement); - ServiceVerificator.verifyNumOfComponentInstances(resourceMetaData, "0.1", 4, getUser()); - - canvasManager.linkElements(cpElement, computeElement); - - resourceMetaData.setVersion("0.1"); - VfVerificator.verifyLinkCreated(resourceMetaData, getUser(), 1); - } - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); - } - - } - - @Test - public void addUpdateDeleteDeploymentArtifactToDCAEAssetTest() throws Exception { - createDCAEAsset(); - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - - List deploymentArtifactList = new ArrayList<>(); - deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType())); - deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", ArtifactTypeEnum.YANG_XML.getType())); - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); - } - assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); - - String newDescription = "new description"; - DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel()); - DeploymentArtifactPage.artifactPopup().insertDescription(newDescription); - DeploymentArtifactPage.artifactPopup().clickDoneButton(); - String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel()); - assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); - - DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel()); - DeploymentArtifactPage.clickOK(); - assertTrue("artifact "+ deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1)); - - assertTrue("artifact "+ deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed()); - } - - @Test - public void addUpdateDeleteInformationalArtifactDCAEAssetTest() throws Exception { - createDCAEAsset(); - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType()); - InformationalArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); - - assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1)); - - String newDescription = "new description"; - InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel()); - InformationalArtifactPage.artifactPopup().insertDescription(newDescription); - InformationalArtifactPage.artifactPopup().clickDoneButton(); - String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel()); - assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); - - InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel()); - InformationalArtifactPage.clickOK(); - assertTrue("artifact "+ informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0)); - } - - @Test - public void addPropertiesToVfcInstanceInDCAEAssetTest() throws Exception { - - if(true){ + ResourceReqDetails resourceMetaData = createDCAEAsset(); + + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + CanvasElement cpElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + Assert.assertNotNull(cpElement); + ServiceVerificator.verifyNumOfComponentInstances( + resourceMetaData, "0.1", + expectedNumberOfComponentInstances, getUser()); + + canvasManager.linkElements(cpElement, computeElement); + + resourceMetaData.setVersion("0.1"); + VfVerificator.verifyLinkCreated(resourceMetaData, getUser(), 1); + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); + } + + } + + @Test + public void addUpdateDeleteDeploymentArtifactToDCAEAssetTest() throws Exception { + createDCAEAsset(); + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + List deploymentArtifactList = new ArrayList<>(); + deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType())); + deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", ArtifactTypeEnum.YANG_XML.getType())); + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); + } + assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); + + String newDescription = "new description"; + DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel()); + DeploymentArtifactPage.artifactPopup().insertDescription(newDescription); + DeploymentArtifactPage.artifactPopup().clickDoneButton(); + String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel()); + assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); + + DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel()); + DeploymentArtifactPage.clickOK(); + assertTrue("artifact " + deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1)); + + assertTrue("artifact " + deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed()); + } + + @Test + public void addUpdateDeleteInformationalArtifactDCAEAssetTest() throws Exception { + createDCAEAsset(); + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + + ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType()); + InformationalArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); + + assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1)); + + String newDescription = "new description"; + InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel()); + InformationalArtifactPage.artifactPopup().insertDescription(newDescription); + InformationalArtifactPage.artifactPopup().clickDoneButton(); + String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel()); + assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); + + InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel()); + InformationalArtifactPage.clickOK(); + assertTrue("artifact " + informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0)); + } + + @Test + public void addPropertiesToVfcInstanceInDCAEAssetTest() throws Exception { + + if (true) { // throw new SkipException("Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); - SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); - } - - String fileName = "importVFC_VFC15.yml"; - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - - try{ - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - - createDCAEAsset(); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - - vfCanvasManager.clickOnCanvaElement(vfcElement); - CompositionPage.showPropertiesAndAttributesTab(); - List properties = CompositionPage.getProperties(); - String propertyValue = "abc123"; - for (int i = 0; i < 2; i++) { - WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label")); - findElement.click(); - PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue); - PropertiesPage.getPropertyPopup().clickSave(); - - findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value")); - assertTrue(findElement.getText().equals(propertyValue)); - } - } - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); - } - } - - @Test - public void changeInstanceVersionDCAEAssetTest() throws Exception{ - ResourceReqDetails atomicResourceMetaData = null; - ResourceReqDetails vfMetaData = null; - CanvasManager vfCanvasManager; - CanvasElement vfcElement = null; - String fileName = "importVFC_VFC16.yml"; - try{ - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - //TODO Andrey changed to click on checkIn button - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - - vfMetaData = createDCAEAsset(); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - //TODO Andrey should click on certify button - CompositionPage.clickCertifyButton(vfMetaData.getName()); - assert(false); - } - catch(Exception e){ - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); - GeneralUIUtils.closeErrorMessage(); - GeneralPageElements.clickOnHomeButton(); - - GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); - ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); - - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - ResourceGeneralPage.clickCheckoutButton(); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - vfMetaData.setVersion("0.2"); - vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "1.0"); - - //verfication - VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0"); - } - - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); - } - - } + SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); + } - // future removed from ui - @Test(enabled = false) - public void addUpdateDeleteSimplePropertiesToDCAEAssetTest() throws Exception{ - createDCAEAsset(); - - ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); - List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER); - int propertiesCount = PropertiesPage.getElemenetsFromTable().size(); - for (PropertyTypeEnum prop : propertyList){ - PropertiesUIUtils.addNewProperty(prop); - } - assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable())); - VfVerificator.verifyPropertiesInUI(propertyList); - PropertiesPage.verifyTotalProperitesField(propertiesCount + propertyList.size()); - - PropertyTypeEnum prop = propertyList.get(0); - prop.setDescription("updatedDescription"); - prop.setValue("value"); - PropertiesUIUtils.updateProperty(prop); - - PropertiesPage.clickDeletePropertyArtifact(prop.getName()); - assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size() - 1, () -> PropertiesPage.getElemenetsFromTable())); - } - - // future removed from ui - @Test(enabled = false) - public void DCAEAssetInstancesInputScreenTest() throws Exception{ - createDCAEAsset(); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - - Map elementsIntancesMap = new HashMap(); - for (LeftPanelCanvasItems element : Arrays.asList(LeftPanelCanvasItems.DATABASE)){ - CanvasElement elementOnCanvas = vfCanvasManager.createElementOnCanvas(element); - vfCanvasManager.clickOnCanvaElement(elementOnCanvas); - String selectedInstanceName = CompositionPage.getSelectedInstanceName(); - elementsIntancesMap.put(selectedInstanceName, element.getValue()); - } - - CompositionPage.moveToInputsScreen(); - int canvasElementsSize = vfCanvasManager.getCanvasElements().size() + 2; - List inputsNamesFromTable = InputsPage.getVFCInstancesNamesFromTable(); - assertTrue(String.format("Instances count is not as Expected: %s Actual: %s", canvasElementsSize, inputsNamesFromTable.size()), inputsNamesFromTable.size() == canvasElementsSize); - - for (String instanceName :inputsNamesFromTable){ - String resourceName = instanceName.split(" ")[0]; - ResourceReqDetails resource = new ResourceReqDetails(); - resource.setName(resourceName); - resource.setVersion("1.0"); - if (resourceName.equals("Port")){ - resource.setResourceType(ResourceTypeEnum.CP.toString()); - } else { - resource.setResourceType(ResourceTypeEnum.VFC.toString()); - } - RestResponse restResponse = RestCDUtils.getResource(resource, getUser()); - Map propertiesNameTypeJson = ResponseParser.getPropertiesNameType(restResponse); - - List propertyRowsFromTable = InputsPage.getInstancePropertiesList(resourceName); - assertTrue("Some properties are missing in table. Instance name is : " + resourceName, propertyRowsFromTable.size() == propertiesNameTypeJson.size()); - VfVerificator.verifyVfInputs(instanceName, propertiesNameTypeJson, propertyRowsFromTable); - - GeneralUIUtils.clickOnElementByText(resourceName); - } - } - - @Test - public void addAllInformationalArtifactPlaceholdersInDCAEAssetTest() throws Exception{ - createDCAEAsset(); - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - int fileNameCounter = 0; - String fileName; - for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){ - fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; - ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, - FileHandling.getFilePath("uniqueFileNames"),fileName, informArtifact.getValue()); - fileNameCounter++; - } - - assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue(); - } - - @Test - public void verifyToscaArtifactsExistDCAEAssetTest() throws Exception{ - ResourceReqDetails vfMetaData = createDCAEAsset(); - - final int numOfToscaArtifacts = 2; - ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); - assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts)); - - for(int i = 0; i < numOfToscaArtifacts; i++){ - String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); - assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); - } - //TODO Andrey should click on certify button - ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName()); - vfMetaData.setVersion("1.0"); - VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser()); - } - - @Test - public void DCAEAssetCertificationTest() throws Exception{ - ResourceReqDetails vfMetaData = createDCAEAsset(); - - String vfName = vfMetaData.getName(); - - ResourceGeneralPage.clickCheckinButton(vfName); - GeneralUIUtils.findComponentAndClick(vfName); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(vfName); + String fileName = "importVFC_VFC15.yml"; + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + + try { + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + + createDCAEAsset(); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + + vfCanvasManager.clickOnCanvaElement(vfcElement); + CompositionPage.showPropertiesAndAttributesTab(); + List properties = CompositionPage.getProperties(); + String propertyValue = "abc123"; + for (int i = 0; i < 2; i++) { + WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label")); + findElement.click(); + PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue); + PropertiesPage.getPropertyPopup().clickSave(); + + findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value")); + assertTrue(findElement.getText().equals(propertyValue)); + } + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); + } + } + + @Test + public void changeInstanceVersionDCAEAssetTest() throws Exception { + ResourceReqDetails atomicResourceMetaData = null; + ResourceReqDetails vfMetaData = null; + CanvasManager vfCanvasManager; + CanvasElement vfcElement = null; + String fileName = "importVFC_VFC16.yml"; + try { + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + //TODO Andrey changed to click on checkIn button + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + + vfMetaData = createDCAEAsset(); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + //TODO Andrey should click on certify button + CompositionPage.clickCertifyButton(vfMetaData.getName()); + assert (false); + } catch (Exception e) { + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); + Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + GeneralUIUtils.closeErrorMessage(); + GeneralPageElements.clickOnHomeButton(); + + GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); + ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); + + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfMetaData.setVersion("0.2"); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "1.0"); + + //verfication + VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0"); + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); + } + + } + + // future removed from ui + @Test(enabled = false) + public void addUpdateDeleteSimplePropertiesToDCAEAssetTest() throws Exception { + createDCAEAsset(); + + ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); + List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER); + int propertiesCount = PropertiesPage.getElemenetsFromTable().size(); + for (PropertyTypeEnum prop : propertyList) { + PropertiesUIUtils.addNewProperty(prop); + } + assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable())); + VfVerificator.verifyPropertiesInUI(propertyList); + PropertiesPage.verifyTotalProperitesField(propertiesCount + propertyList.size()); + + PropertyTypeEnum prop = propertyList.get(0); + prop.setDescription("updatedDescription"); + prop.setValue("value"); + PropertiesUIUtils.updateProperty(prop); + + PropertiesPage.clickDeletePropertyArtifact(prop.getName()); + assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size() - 1, () -> PropertiesPage.getElemenetsFromTable())); + } + + // future removed from ui + @Test(enabled = false) + public void DCAEAssetInstancesInputScreenTest() throws Exception { + createDCAEAsset(); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + + Map elementsIntancesMap = new HashMap(); + for (LeftPanelCanvasItems element : Arrays.asList(LeftPanelCanvasItems.DATABASE)) { + CanvasElement elementOnCanvas = vfCanvasManager.createElementOnCanvas(element); + vfCanvasManager.clickOnCanvaElement(elementOnCanvas); + String selectedInstanceName = CompositionPage.getSelectedInstanceName(); + elementsIntancesMap.put(selectedInstanceName, element.getValue()); + } + + CompositionPage.moveToInputsScreen(); + int canvasElementsSize = vfCanvasManager.getCanvasElements().size() + 2; + List inputsNamesFromTable = InputsPage.getVFCInstancesNamesFromTable(); + assertTrue(String.format("Instances count is not as Expected: %s Actual: %s", canvasElementsSize, inputsNamesFromTable.size()), inputsNamesFromTable.size() == canvasElementsSize); + + for (String instanceName : inputsNamesFromTable) { + String resourceName = instanceName.split(" ")[0]; + ResourceReqDetails resource = new ResourceReqDetails(); + resource.setName(resourceName); + resource.setVersion("1.0"); + if (resourceName.equals("Port")) { + resource.setResourceType(ResourceTypeEnum.CP.toString()); + } else { + resource.setResourceType(ResourceTypeEnum.VFC.toString()); + } + RestResponse restResponse = RestCDUtils.getResource(resource, getUser()); + Map propertiesNameTypeJson = ResponseParser.getPropertiesNameType(restResponse); + + List propertyRowsFromTable = InputsPage.getInstancePropertiesList(resourceName); + assertTrue("Some properties are missing in table. Instance name is : " + resourceName, propertyRowsFromTable.size() == propertiesNameTypeJson.size()); + VfVerificator.verifyVfInputs(instanceName, propertiesNameTypeJson, propertyRowsFromTable); + + GeneralUIUtils.clickOnElementByText(resourceName); + } + } + + @Test + public void addAllInformationalArtifactPlaceholdersInDCAEAssetTest() throws Exception { + createDCAEAsset(); + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + int fileNameCounter = 0; + String fileName; + for (InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()) { + fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; + ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, + FileHandling.getFilePath("uniqueFileNames"), fileName, informArtifact.getValue()); + fileNameCounter++; + } + + assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue(); + } + + @Test + public void verifyToscaArtifactsExistDCAEAssetTest() throws Exception { + ResourceReqDetails vfMetaData = createDCAEAsset(); + + final int numOfToscaArtifacts = 2; + ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); + assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts)); + + for (int i = 0; i < numOfToscaArtifacts; i++) { + String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); + assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); + } + //TODO Andrey should click on certify button + ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName()); + vfMetaData.setVersion("1.0"); + VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser()); + } + + @Test + public void DCAEAssetCertificationTest() throws Exception { + ResourceReqDetails vfMetaData = createDCAEAsset(); + + String vfName = vfMetaData.getName(); + + ResourceGeneralPage.clickCheckinButton(vfName); + GeneralUIUtils.findComponentAndClick(vfName); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(vfName); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfName); TesterOperationPage.certifyComponent(vfName);*/ - - vfMetaData.setVersion("1.0"); - VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - - /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - GeneralUIUtils.findComponentAndClick(vfName); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); - } - - @Test - public void deleteDCAEAssetCheckedoutTest() throws Exception{ - ResourceReqDetails vfMetaData = createDCAEAsset(); - - GeneralPageElements.clickTrashButtonAndConfirm(); - - vfMetaData.setVersion("0.1"); - VfVerificator.verifyVfDeleted(vfMetaData, getUser()); - } - - @Test - public void revertDCAEAssetMetadataTest() throws Exception{ - ResourceReqDetails vfMetaData = createDCAEAsset(); - - ResourceReqDetails vfRevertDetails = new ResourceReqDetails(); - vfRevertDetails.setName("ciUpdatedName"); - vfRevertDetails.setDescription("kuku"); - vfRevertDetails.setCategories(vfMetaData.getCategories()); - vfRevertDetails.setVendorName("updatedVendor"); - vfRevertDetails.setVendorRelease("updatedRelease"); - ResourceUIUtils.fillResourceGeneralInformationPage(vfRevertDetails, getUser(), false); - - GeneralPageElements.clickRevertButton(); - - VfVerificator.verifyVFMetadataInUI(vfMetaData); - } - - @Test - public void addDeploymentArtifactInCompositionScreenDCAEAssetTest() throws Exception{ - createDCAEAsset(); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3",ArtifactTypeEnum.OTHER.getType()); - CompositionPage.showDeploymentArtifactTab(); - CompositionPage.clickAddArtifactButton(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); - - List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className("i-sdc-designer-sidebar-section-content-item-artifact")); - Assert.assertEquals(1, actualArtifactList.size()); - } - - // future removed from ui - @Test(enabled = false) - public void addPropertyInCompositionScreenDCAEAssetTest() throws Exception{ - createDCAEAsset(); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - CompositionPage.showPropertiesAndAttributesTab(); - List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER); - int propertiesCount = CompositionPage.getProperties().size(); - for (PropertyTypeEnum prop : propertyList){ - PropertiesUIUtils.addNewProperty(prop); - } - assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> CompositionPage.getProperties())); - } - - @Test - public void addDeploymentArtifactAndVerifyInCompositionScreenDCAEAssetTest() throws Exception{ - createDCAEAsset(); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType()); - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); - assertTrue(DeploymentArtifactPage.checkElementsCountInTable(1)); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - CompositionPage.showDeploymentArtifactTab(); - List deploymentArtifactsFromScreen = CompositionPage.getDeploymentArtifacts(); - assertTrue(1 == deploymentArtifactsFromScreen.size()); - - String actualArtifactFileName = deploymentArtifactsFromScreen.get(0).getText(); - assertTrue("asc_heat-0-2.yaml".equals(actualArtifactFileName)); - } - - @Test - public void checkoutDCAEAssetTest() throws Exception{ - ResourceReqDetails vfMetaData = createDCAEAsset(); - - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - GeneralPageElements.clickCheckoutButton(); - - vfMetaData.setVersion("0.2"); - VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); + vfMetaData.setVersion("1.0"); + VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); + + /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ + GeneralUIUtils.findComponentAndClick(vfName); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); + } + + @Test + public void deleteDCAEAssetCheckedoutTest() throws Exception { + ResourceReqDetails vfMetaData = createDCAEAsset(); + + GeneralPageElements.clickTrashButtonAndConfirm(); + + vfMetaData.setVersion("0.1"); + VfVerificator.verifyVfDeleted(vfMetaData, getUser()); + } + + @Test + public void revertDCAEAssetMetadataTest() throws Exception { + ResourceReqDetails vfMetaData = createDCAEAsset(); + + ResourceReqDetails vfRevertDetails = new ResourceReqDetails(); + vfRevertDetails.setName("ciUpdatedName"); + vfRevertDetails.setDescription("kuku"); + vfRevertDetails.setCategories(vfMetaData.getCategories()); + vfRevertDetails.setVendorName("updatedVendor"); + vfRevertDetails.setVendorRelease("updatedRelease"); + ResourceUIUtils.fillResourceGeneralInformationPage(vfRevertDetails, getUser(), false); + + GeneralPageElements.clickRevertButton(); + + VfVerificator.verifyVFMetadataInUI(vfMetaData); + } + + @Test + public void addDeploymentArtifactInCompositionScreenDCAEAssetTest() throws Exception { + createDCAEAsset(); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3", ArtifactTypeEnum.OTHER.getType()); + CompositionPage.showDeploymentArtifactTab(); + CompositionPage.clickAddArtifactButton(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); + + List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className("i-sdc-designer-sidebar-section-content-item-artifact")); + Assert.assertEquals(1, actualArtifactList.size()); + } + + // future removed from ui + @Test(enabled = false) + public void addPropertyInCompositionScreenDCAEAssetTest() throws Exception { + createDCAEAsset(); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + CompositionPage.showPropertiesAndAttributesTab(); + List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER); + int propertiesCount = CompositionPage.getProperties().size(); + for (PropertyTypeEnum prop : propertyList) { + PropertiesUIUtils.addNewProperty(prop); + } + assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> CompositionPage.getProperties())); + } + + @Test + public void addDeploymentArtifactAndVerifyInCompositionScreenDCAEAssetTest() throws Exception { + createDCAEAsset(); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType()); + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); + assertTrue(DeploymentArtifactPage.checkElementsCountInTable(1)); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + CompositionPage.showDeploymentArtifactTab(); + List deploymentArtifactsFromScreen = CompositionPage.getDeploymentArtifacts(); + assertTrue(1 == deploymentArtifactsFromScreen.size()); + + String actualArtifactFileName = deploymentArtifactsFromScreen.get(0).getText(); + assertTrue("asc_heat-0-2.yaml".equals(actualArtifactFileName)); + } + + @Test + public void checkoutDCAEAssetTest() throws Exception { + ResourceReqDetails vfMetaData = createDCAEAsset(); + + ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + GeneralPageElements.clickCheckoutButton(); + + vfMetaData.setVersion("0.2"); + VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); TesterOperationPage.certifyComponent(vfMetaData.getName()); reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - ResourceGeneralPage.clickCheckoutButton(); - - vfMetaData.setVersion("1.1"); - vfMetaData.setUniqueId(null); - VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - } - - @Test - public void deleteInstanceFromDCAEAssetCanvas() throws Exception{ - ResourceReqDetails vfMetaData = createDCAEAsset(); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CanvasElement computeElement = CompositionPage.addElementToCanvasScreen(LeftPanelCanvasItems.COMPUTE, vfCanvasManager); - - vfCanvasManager.clickOnCanvaElement(computeElement); - vfCanvasManager.deleteElementFromCanvas(computeElement); - - VfVerificator.verifyNumOfComponentInstances(vfMetaData, 2, getUser()); - } - - @Test - public void changeInstanceNameInDCAEAssetTest() throws Exception{ - createDCAEAsset(); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CanvasElement computeElement = CompositionPage.addElementToCanvasScreen(LeftPanelCanvasItems.COMPUTE, vfCanvasManager); - - String updatedInstanceName = "updatedName"; - vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName); - - String actualSelectedInstanceName = CompositionPage.getSelectedInstanceName(); - assertTrue(updatedInstanceName.equals(actualSelectedInstanceName)); - } - - @Test - public void submitDCAEAssetForTestingWithNonCertifiedAsset() throws Exception{ - String fileName = "importVFC_VFC17.yml"; - - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - //TODO Andrey changed to click on checkIn button - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - - ResourceReqDetails vfMetaData = createDCAEAsset(); - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.addElementToCanvasScreen(atomicResourceMetaData.getName(), canvasManager); - - try{ - //TODO Andrey should click on certify button - CompositionPage.clickCertifyButton(vfMetaData.getName()); - assert(false); - } - catch(Exception e){ - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); - } - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); - } - } - - @Test - public void isDisabledAndReadOnlyInCheckinDCAEAssetTest() throws Exception{ - ResourceReqDetails vfMetaData = createDCAEAsset(); - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - ResourceMetadataEnum[] fieldsForCheck = {ResourceMetadataEnum.RESOURCE_NAME, - ResourceMetadataEnum.DESCRIPTION, - ResourceMetadataEnum.VENDOR_NAME, - ResourceMetadataEnum.VENDOR_RELEASE, - ResourceMetadataEnum.CONTACT_ID, - ResourceMetadataEnum.CATEGORY, - ResourceMetadataEnum.TAGS}; - - for (ResourceMetadataEnum field: fieldsForCheck){ - VfVerificator.verifyIsElementDisabled(field.getValue(), field.name()); - } - VfVerificator.verifyIsElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue(), DataTestIdEnum.LifeCyleChangeButtons.CREATE.name()); - } - - @Test - public void removeFileFromGeneralPageDCAEAssetTest() throws Exception{ - String fileName2 = SERVICE_INPUT_TEST_VF2_CSAR; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - ResourceUIUtils.importVfFromCsarNoCreate(resourceMetaData, filePath, fileName2, getUser()); - GeneralPageElements.clickDeleteFile(); - - try{ - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), 30); - assert(false); - } - catch(Exception e){ - assert(true); - } - } - - @Test - public void activityLogDCAEAssetTest() throws Exception{ - createDCAEAsset(); - - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType()); - InformationalArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); - - ResourceGeneralPage.getLeftMenu().moveToActivityLogScreen(); - - int numberOfRows = GeneralUIUtils.getElementsByCSS("div[class^='flex-container']").size(); - assertTrue("Wrong rows number, should be 2", numberOfRows == 2); - } - - @Test - public void checkinCheckoutChangeDeleteVersionDCAEAssetTest() throws Exception{ - ResourceReqDetails atomicResourceMetaData = createDCAEAsset(); - - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); - GeneralPageElements.clickCheckoutButton(); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - - GeneralPageElements.selectVersion("V0.1"); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKIN); - GeneralUIUtils.clickJSOnElementByText("latest version"); - - GeneralPageElements.clickTrashButtonAndConfirm(); - GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); - String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText(); - assertTrue("Expected version: V0.1, Actual version: " + actualVersion, actualVersion.equals("V0.1")); - } - - @Test - public void badFileDCAEAssetTest() throws Exception { - String customFileName = "badVF.csar"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - try{ - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, customFileName, getUser()); - assert(false); - } - catch(Exception e){ - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.CSAR_INVALID.name()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating error messdge...")); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); - } - } - - @Test - public void validContactAfterCreateDCAEAssetTest() throws Exception{ - ResourceReqDetails resourceMetaData = createDCAEAsset(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating that userID equal to user that was logged in...")); - assertTrue("Wrong userId", resourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText())); - } - - public ResourceReqDetails createDCAEAsset() throws Exception{ - String fileName2 = SERVICE_INPUT_TEST_VF2_CSAR; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); - resourceMetaData.setVersion("0.1"); - return resourceMetaData; - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); + + vfMetaData.setVersion("1.1"); + vfMetaData.setUniqueId(null); + VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + } + + @Test + public void deleteInstanceFromDCAEAssetCanvas() throws Exception { + ResourceReqDetails vfMetaData = createDCAEAsset(); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement computeElement = CompositionPage.addElementToCanvasScreen(LeftPanelCanvasItems.COMPUTE, vfCanvasManager); + + vfCanvasManager.clickOnCanvaElement(computeElement); + vfCanvasManager.deleteElementFromCanvas(computeElement); + + VfVerificator.verifyNumOfComponentInstances(vfMetaData, 2, getUser()); + } + + @Test + public void changeInstanceNameInDCAEAssetTest() throws Exception { + createDCAEAsset(); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement computeElement = CompositionPage.addElementToCanvasScreen(LeftPanelCanvasItems.COMPUTE, vfCanvasManager); + + String updatedInstanceName = "updatedName"; + vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName); + + String actualSelectedInstanceName = CompositionPage.getSelectedInstanceName(); + assertTrue(updatedInstanceName.equals(actualSelectedInstanceName)); + } + + @Test + public void submitDCAEAssetForTestingWithNonCertifiedAsset() throws Exception { + String fileName = "importVFC_VFC17.yml"; + + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + //TODO Andrey changed to click on checkIn button + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + + ResourceReqDetails vfMetaData = createDCAEAsset(); + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.addElementToCanvasScreen(atomicResourceMetaData.getName(), canvasManager); + + try { + //TODO Andrey should click on certify button + CompositionPage.clickCertifyButton(vfMetaData.getName()); + assert (false); + } catch (Exception e) { + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); + Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); + } + } + + @Test + public void isDisabledAndReadOnlyInCheckinDCAEAssetTest() throws Exception { + ResourceReqDetails vfMetaData = createDCAEAsset(); + ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + ResourceMetadataEnum[] fieldsForCheck = {ResourceMetadataEnum.RESOURCE_NAME, + ResourceMetadataEnum.DESCRIPTION, + ResourceMetadataEnum.VENDOR_NAME, + ResourceMetadataEnum.VENDOR_RELEASE, + ResourceMetadataEnum.CONTACT_ID, + ResourceMetadataEnum.CATEGORY, + ResourceMetadataEnum.TAGS}; + + for (ResourceMetadataEnum field : fieldsForCheck) { + VfVerificator.verifyIsElementDisabled(field.getValue(), field.name()); + } + VfVerificator.verifyIsElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue(), DataTestIdEnum.LifeCyleChangeButtons.CREATE.name()); + } + + @Test + public void removeFileFromGeneralPageDCAEAssetTest() throws Exception { + String fileName2 = SERVICE_INPUT_TEST_VF2_CSAR; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + ResourceUIUtils.importVfFromCsarNoCreate(resourceMetaData, filePath, fileName2, getUser()); + GeneralPageElements.clickDeleteFile(); + + try { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), CLICKING_ON_ELEMENT_TIMEOUT); + assert (false); + } catch (Exception e) { + assert (true); + } + } + + @Test + public void activityLogDCAEAssetTest() throws Exception { + createDCAEAsset(); + + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + + ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType()); + InformationalArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); + + ResourceGeneralPage.getLeftMenu().moveToActivityLogScreen(); + + int numberOfRows = GeneralUIUtils.getElementsByCSS("div[class^='flex-container']").size(); + assertTrue("Wrong rows number, should be 2", numberOfRows == 2); + } + + @Test + public void checkinCheckoutChangeDeleteVersionDCAEAssetTest() throws Exception { + ResourceReqDetails atomicResourceMetaData = createDCAEAsset(); + + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); + GeneralPageElements.clickCheckoutButton(); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + + GeneralPageElements.selectVersion("V0.1"); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKIN); + GeneralUIUtils.clickJSOnElementByText("latest version"); + + GeneralPageElements.clickTrashButtonAndConfirm(); + GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); + String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText(); + assertTrue("Expected version: V0.1, Actual version: " + actualVersion, actualVersion.equals("V0.1")); + } + + @Test + public void badFileDCAEAssetTest() throws Exception { + String customFileName = "badVF.csar"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + try { + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, customFileName, getUser()); + assert (false); + } catch (Exception e) { + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.CSAR_INVALID.name()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating error messdge...")); + Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + } + } + + @Test + public void validContactAfterCreateDCAEAssetTest() throws Exception { + ResourceReqDetails resourceMetaData = createDCAEAsset(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating that userID equal to user that was logged in...")); + assertTrue("Wrong userId", resourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText())); + } + + public ResourceReqDetails createDCAEAsset() throws Exception { + String fileName2 = SERVICE_INPUT_TEST_VF2_CSAR; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); + resourceMetaData.setVersion("0.1"); + return resourceMetaData; + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java index 8a5667457d..a7d495a32d 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import static org.assertj.core.api.Assertions.assertThat; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.LifecycleStateEnum; @@ -34,8 +33,17 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage; +import org.openecomp.sdc.ci.tests.pages.PropertiesPage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.UploadArtifactPopup; +import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.PropertiesUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openecomp.sdc.ci.tests.verificator.PropertyVerificator; @@ -49,327 +57,315 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; import static org.testng.AssertJUnit.assertTrue; -@Test(singleThreaded=true) +@Test(singleThreaded = true) public class ImportVFCAsset extends SetupCDTest { - - private ResourceReqDetails atomicResourceMetaData; - private String filePath; - - @BeforeClass - public void beforeClass(){ - filePath = FileHandling.getFilePath(""); - } - - @DataProvider(name = "assetFiles", parallel = false) + + private static final int CLICKING_ON_ELEMENT_TIMEOUT = 30; + private ResourceReqDetails atomicResourceMetaData; + private String filePath; + + @BeforeClass + public void beforeClass() { + filePath = FileHandling.getFilePath(""); + } + + @DataProvider(name = "assetFiles", parallel = false) public Object[][] createDataX() { - return new Object[][] { { "importVFC_VFC9.yml" }, { "CP.yml" }, {"VL.yml"} }; + return new Object[][]{{"importVFC_VFC9.yml"}, {"CP.yml"}, {"VL.yml"}}; + } + + @Test + public void importVFCTest() throws Exception { + String fileName = "importVFC_VFC1.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + } + + @Test + public void importDuplicateVFCTest() throws Exception { + String fileName = "importVFC_VFC2.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + + ResourceReqDetails atomicResourceMetaDataDup = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_INFRASTRUCTURE, getUser()); + try { + ResourceUIUtils.importVfc(atomicResourceMetaDataDup, filePath, fileName, getUser()); + assert (false); + } catch (Exception e) { + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.RESOURCE_ALREADY_EXISTS.name()); + Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + } + } + + @Test + public void badFileVFCTest() throws Exception { + String fileName = "importVFC_VFC3.yml"; + String customFileName = "Heat-File 1.yaml"; + + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + try { + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customFileName, getUser()); + assert (false); + } catch (Exception e) { + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.INVALID_TOSCA_TEMPLATE.name()); + Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + } + } + + @Test + public void validContactAfterCreateVFCTest() throws Exception { + String fileName = "importVFC_VFC4.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + + assertTrue("wrong userId", atomicResourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText())); + } + + @Test + public void validContactAfterUpdateVFCTest() throws Exception { + String fileName = "importVFC_VFC5.yml"; + String userIdUpdated = "up1234"; + + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + + ResourceUIUtils.defineUserId(userIdUpdated); + assertTrue("userId is not updated", userIdUpdated.equals(ResourceGeneralPage.getContactIdText())); + } + + @Test + public void addUpdateDeleteDeploymentArtifactToVFCTest() throws Exception { + String fileName = "importVFC_VFC6.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + List deploymentArtifactList = new ArrayList(); + deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); + deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML")); + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true)); + } + assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); + + String newDescription = "new description"; + DeploymentArtifactPage.updateDescription(newDescription, deploymentArtifactList.get(0)); + String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel()); + assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); + + DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel()); + DeploymentArtifactPage.clickOK(); + assertTrue("artifact " + deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1)); + + assertTrue("artifact " + deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed()); } - - @Test - public void importVFCTest() throws Exception { - String fileName = "importVFC_VFC1.yml"; - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - } - - @Test - public void importDuplicateVFCTest() throws Exception { - String fileName = "importVFC_VFC2.yml"; - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - - ResourceReqDetails atomicResourceMetaDataDup = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_INFRASTRUCTURE, getUser()); - try{ - ResourceUIUtils.importVfc(atomicResourceMetaDataDup, filePath, fileName, getUser()); - assert(false); - } - catch(Exception e){ - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.RESOURCE_ALREADY_EXISTS.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); - } - } - - @Test - public void badFileVFCTest() throws Exception { - String fileName = "importVFC_VFC3.yml"; - String customFileName = "Heat-File 1.yaml"; - - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - try{ - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customFileName, getUser()); - assert(false); - } - catch(Exception e){ - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.INVALID_TOSCA_TEMPLATE.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); - } - } - - @Test - public void validContactAfterCreateVFCTest() throws Exception{ - String fileName = "importVFC_VFC4.yml"; - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - - assertTrue("wrong userId", atomicResourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText())); - } - - @Test - public void validContactAfterUpdateVFCTest() throws Exception{ - String fileName = "importVFC_VFC5.yml"; - String userIdUpdated = "up1234"; - - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - - ResourceUIUtils.defineUserId(userIdUpdated); - assertTrue("userId is not updated",userIdUpdated.equals(ResourceGeneralPage.getContactIdText())); - } - - @Test - public void addUpdateDeleteDeploymentArtifactToVFCTest() throws Exception { - String fileName = "importVFC_VFC6.yml"; - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - - List deploymentArtifactList = new ArrayList(); - deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); - deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML")); - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true) ); - } - assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); - - String newDescription = "new description"; - DeploymentArtifactPage.updateDescription(newDescription, deploymentArtifactList.get(0)); - String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel()); - assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); - - DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel()); - DeploymentArtifactPage.clickOK(); - assertTrue("artifact "+ deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1)); - - assertTrue("artifact "+ deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed()); - } - - @Test - public void addUpdateDeletePlaceholdersInformationalArtifactVFCTest() throws Exception{ - String fileName = "importVFC_VFC7.yml"; - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - + + @Test + public void addUpdateDeletePlaceholdersInformationalArtifactVFCTest() throws Exception { + String fileName = "importVFC_VFC7.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - // create artifacts + + // create artifacts List informationalArtifactList = new ArrayList(); informationalArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); informationalArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuuuuku", "artifact3", "HEAT")); for (ArtifactInfo informationalArtifact : informationalArtifactList) { - InformationalArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); - } - assertThat(InformationalArtifactPage.checkElementsCountInTable(informationalArtifactList.size())). + InformationalArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); + } + assertThat(InformationalArtifactPage.checkElementsCountInTable(informationalArtifactList.size())). as("Check that artifact table contains artifacts uploaded").isTrue(); - - // update artifact description - String newDescription = "new description"; - InformationalArtifactPage.clickEditArtifact(informationalArtifactList.get(0).getArtifactLabel()); - InformationalArtifactPage.artifactPopup().insertDescription(newDescription); - InformationalArtifactPage.artifactPopup().clickDoneButton(); - String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifactList.get(0).getArtifactLabel()); - assertThat(actualArtifactDescription).as("Check artifact description update").isEqualTo(newDescription); - - // delete artifacts - for (ArtifactInfo informationalArtifact : informationalArtifactList) { - InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel()); - InformationalArtifactPage.clickOK(); - } - - assertThat(InformationalArtifactPage.checkElementsCountInTable(0)). + + // update artifact description + String newDescription = "new description"; + InformationalArtifactPage.clickEditArtifact(informationalArtifactList.get(0).getArtifactLabel()); + InformationalArtifactPage.artifactPopup().insertDescription(newDescription); + InformationalArtifactPage.artifactPopup().clickDoneButton(); + String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifactList.get(0).getArtifactLabel()); + assertThat(actualArtifactDescription).as("Check artifact description update").isEqualTo(newDescription); + + // delete artifacts + for (ArtifactInfo informationalArtifact : informationalArtifactList) { + InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel()); + InformationalArtifactPage.clickOK(); + } + + assertThat(InformationalArtifactPage.checkElementsCountInTable(0)). as("Check that all artifacts were deleted").isTrue(); - // fill placeholders + // fill placeholders int fileNameCounter = 0; - for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){ + for (InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()) { fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, FileHandling.getFilePath("uniqueFileNames"), fileName, informArtifact.getValue()); fileNameCounter++; - } - assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue(); - } - - @Test - public void addSimplePropertiesToVFCTest() throws Exception{ - String fileName = "importVFC_VFC8.yml"; - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); - List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT); - int propertiesCount = PropertiesPage.getElemenetsFromTable().size(); - for (PropertyTypeEnum prop : propertyList){ - PropertiesUIUtils.addNewProperty(prop); - } - assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable())); - - } - - @Test - public void updateAfterCheckoutNewSimplePropertiesVFCTest() throws Exception{ - String fileName = "importVFC_VFC16.yml"; - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); - List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT); - int propertiesCount = PropertiesPage.getElemenetsFromTable().size(); - for (PropertyTypeEnum prop : propertyList){ - PropertiesUIUtils.addNewProperty(prop); - } - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); - GeneralPageElements.clickCheckoutButton(); - ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); - - for (PropertyTypeEnum prop : propertyList){ - PropertiesUIUtils.updateProperty(prop); - } - assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable())); - - for (PropertyTypeEnum prop : propertyList){ - PropertiesPage.clickOnProperty(prop.getName()); - PropertyVerificator.validateEditVFCPropertiesPopoverFields(prop); - PropertiesPage.getPropertyPopup().clickCancel(); - } - - } - - - @Test(dataProvider = "assetFiles") - public void checkinCheckoutChangeDeleteVersionVFCTest(String customfileName) throws Exception{ - setLog(customfileName); -// getExtendTest().setDescription(customfileName); - - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customfileName, getUser()); - - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); - GeneralPageElements.clickCheckoutButton(); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - - GeneralPageElements.selectVersion("V0.1"); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKIN); - GeneralUIUtils.clickJSOnElementByText("latest version"); - - GeneralPageElements.clickTrashButtonAndConfirm(); - GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); - String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText(); - assertTrue("Expected version: V0.1, Actual version: " + actualVersion, actualVersion.equals("V0.1")); - } - - @Test - public void certificationVFCTest() throws Exception{ - String fileName = "importVFC_VFC10.yml"; - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - - String vfName = atomicResourceMetaData.getName(); - - ResourceGeneralPage.clickCheckinButton(vfName); - GeneralUIUtils.findComponentAndClick(vfName); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(vfName); - - /*reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vfName); - TesterOperationPage.certifyComponent(vfName);*/ - - atomicResourceMetaData.setVersion("1.0"); - VfVerificator.verifyVFLifecycle(atomicResourceMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - - /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - GeneralUIUtils.findComponentAndClick(vfName); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); - } - - @Test - public void activityLogVFCTest() throws Exception{ - String fileName = "importVFC_VFC11.yml"; - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - + } + assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue(); + } + + @Test + public void addSimplePropertiesToVFCTest() throws Exception { + String fileName = "importVFC_VFC8.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); + List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT); + int propertiesCount = PropertiesPage.getElemenetsFromTable().size(); + for (PropertyTypeEnum prop : propertyList) { + PropertiesUIUtils.addNewProperty(prop); + } + assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable())); + + } + + @Test + public void updateAfterCheckoutNewSimplePropertiesVFCTest() throws Exception { + String fileName = "importVFC_VFC16.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); + List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT); + int propertiesCount = PropertiesPage.getElemenetsFromTable().size(); + for (PropertyTypeEnum prop : propertyList) { + PropertiesUIUtils.addNewProperty(prop); + } + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); + GeneralPageElements.clickCheckoutButton(); + ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); + + for (PropertyTypeEnum prop : propertyList) { + PropertiesUIUtils.updateProperty(prop); + } + assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable())); + + for (PropertyTypeEnum prop : propertyList) { + PropertiesPage.clickOnProperty(prop.getName()); + PropertyVerificator.validateEditVFCPropertiesPopoverFields(prop); + PropertiesPage.getPropertyPopup().clickCancel(); + } + + } + + + @Test(dataProvider = "assetFiles") + public void checkinCheckoutChangeDeleteVersionVFCTest(String customfileName) throws Exception { + setLog(customfileName); + + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customfileName, getUser()); + + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); + GeneralPageElements.clickCheckoutButton(); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + + GeneralPageElements.selectVersion("V0.1"); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKIN); + GeneralUIUtils.clickJSOnElementByText("latest version"); + + GeneralPageElements.clickTrashButtonAndConfirm(); + GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); + String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText(); + assertTrue("Expected version: V0.1, Actual version: " + actualVersion, actualVersion.equals("V0.1")); + } + + @Test + public void certificationVFCTest() throws Exception { + String fileName = "importVFC_VFC10.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + + String vfName = atomicResourceMetaData.getName(); + + ResourceGeneralPage.clickCheckinButton(vfName); + GeneralUIUtils.findComponentAndClick(vfName); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(vfName); + + atomicResourceMetaData.setVersion("1.0"); + VfVerificator.verifyVFLifecycle(atomicResourceMetaData, getUser(), LifecycleStateEnum.CERTIFIED); + + GeneralUIUtils.findComponentAndClick(vfName); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); + } + + @Test + public void activityLogVFCTest() throws Exception { + String fileName = "importVFC_VFC11.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); - InformationalArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); - - ResourceGeneralPage.getLeftMenu().moveToActivityLogScreen(); - - int numberOfRows = GeneralUIUtils.getElementsByCSS("div[class^='flex-container']").size(); - assertTrue("Wrong rows number, should be 2", numberOfRows == 2); - } - - @Test - public void removeFileFromGeneralPageVFCTest() throws Exception{ - String fileName = "importVFC_VFC12.yml"; - - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfcNoCreate(atomicResourceMetaData, filePath, fileName, getUser()); - - GeneralPageElements.clickDeleteFile(); - - try{ - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), 30); - assert(false); - } - catch(Exception e){ - assert(true); - } - } - - @Test - public void maxLengthGeneralInformationVFCTest() throws Exception{ - String fileName = "importVFC_VFC13.yml"; - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceUIUtils.fillMaxValueResourceGeneralInformationPage(atomicResourceMetaData); -// GeneralPageElements.clickUpdateButton(); -// VFCverificator.verifyVFCUpdatedInUI(atomicResourceMetaData); -// GeneralPageElements.clickDeleteVersionButton(); - // Validate that button disabled - assertTrue(GeneralUIUtils.checkForDisabledAttribute(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue())); - } - - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + + ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); + InformationalArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); + + ResourceGeneralPage.getLeftMenu().moveToActivityLogScreen(); + + int numberOfRows = GeneralUIUtils.getElementsByCSS("div[class^='flex-container']").size(); + assertTrue("Wrong rows number, should be 2", numberOfRows == 2); + } + + @Test + public void removeFileFromGeneralPageVFCTest() throws Exception { + String fileName = "importVFC_VFC12.yml"; + + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfcNoCreate(atomicResourceMetaData, filePath, fileName, getUser()); + + GeneralPageElements.clickDeleteFile(); + + try { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), CLICKING_ON_ELEMENT_TIMEOUT); + assert (false); + } catch (Exception e) { + assert (true); + } + } + + @Test + public void maxLengthGeneralInformationVFCTest() throws Exception { + String fileName = "importVFC_VFC13.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + ResourceUIUtils.fillMaxValueResourceGeneralInformationPage(atomicResourceMetaData); + assertTrue(GeneralUIUtils.checkForDisabledAttribute(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue())); + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java index 579bfb8b10..b595642b02 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,7 +36,11 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utilities.FileHandling; -import org.openecomp.sdc.ci.tests.utils.general.*; +import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; +import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -47,94 +51,90 @@ import java.util.List; import static org.testng.AssertJUnit.assertTrue; -public class OnboardViaApis{ - - - private static final String FULL_PATH = "C://tmp//CSARs//"; - protected static String filepath = FileHandling.getVnfRepositoryPath(); - -//------------------------------------------------------------------------------------------------------- - User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); -// ResourceReqDetails resourceDetails; - Timestamp timestamp = new Timestamp(System.currentTimeMillis()); - - - @BeforeMethod - public void before(){ - LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); - lc.getLogger("org.apache").setLevel(Level.OFF); - lc.getLogger("org.*").setLevel(Level.OFF); - lc.getLogger("org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest").setLevel(Level.OFF); -// resourceDetails = ElementFactory.getDefaultResource(); - } - - @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") - public void onboardVNFTestViaApis(String filepath, String vnfFile) throws Exception, Throwable { - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Service service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile); - } - - - @Test - public void onboardingAndParser() throws Exception { - Service service = null; - List fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath); - String vnfFile = fileNamesFromFolder.get(7); - System.err.println(timestamp + " Starting test with VNF: " + vnfFile); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile); - } - - @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") - public void updateVSPFullScenario(String filepath, String vnfFile) throws Exception - { - //CREATE DATA REQUIRED FOR TEST - boolean skipReport = true; - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, sdncDesignerDetails1, amdocsLicenseMembers); -// VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct); - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); -// serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, sdncDesignerDetails1); - Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - // TEST START - - VendorLicenseModelRestUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails1, false); - VendorLicenseModelRestUtils.validateVlmExist(amdocsLicenseMembers.getVendorId(), amdocsLicenseMembers.getVersion(), sdncDesignerDetails1); - - // Update the VSP With the VLM new version and submit the VSP - vendorSoftwareProductObject = VendorSoftwareProductRestUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject, amdocsLicenseMembers, sdncDesignerDetails1); - VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1); - Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); - assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); - System.out.println(distributeAndValidateService); - } - - public Service runOnboardViaApisOnly(ServiceReqDetails serviceReqDetails, ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception { - - VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filepath, vnfFile, sdncDesignerDetails1); - vendorSoftwareProductObject.setName(vendorSoftwareProductObject.getName()); - - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - -// serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, sdncDesignerDetails1); - Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - - Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); - - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - return service; - } +public class OnboardViaApis { + + + private static final String FULL_PATH = "C://tmp//CSARs//"; + protected static String filepath = FileHandling.getVnfRepositoryPath(); + + //------------------------------------------------------------------------------------------------------- + User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + // ResourceReqDetails resourceDetails; + Timestamp timestamp = new Timestamp(System.currentTimeMillis()); + + + @BeforeMethod + public void before() { + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + lc.getLogger("org.apache").setLevel(Level.OFF); + lc.getLogger("org.*").setLevel(Level.OFF); + lc.getLogger("org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest").setLevel(Level.OFF); + } + + @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") + public void onboardVNFTestViaApis(String filepath, String vnfFile) throws Exception, Throwable { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); //getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Service service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile); + } + + + @Test + public void onboardingAndParser() throws Exception { + final int fileFromFolderToGet =7; + Service service = null; + List fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath); + String vnfFile = fileNamesFromFolder.get(fileFromFolderToGet); + System.err.println(timestamp + " Starting test with VNF: " + vnfFile); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); //getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile); + } + + @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") + public void updateVSPFullScenario(String filepath, String vnfFile) throws Exception { + //CREATE DATA REQUIRED FOR TEST + boolean skipReport = true; + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, sdncDesignerDetails1, amdocsLicenseMembers); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); //getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + // TEST START + + VendorLicenseModelRestUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails1, false); + VendorLicenseModelRestUtils.validateVlmExist(amdocsLicenseMembers.getVendorId(), amdocsLicenseMembers.getVersion(), sdncDesignerDetails1); + + // Update the VSP With the VLM new version and submit the VSP + vendorSoftwareProductObject = VendorSoftwareProductRestUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject, amdocsLicenseMembers, sdncDesignerDetails1); + VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1); + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); + System.out.println(distributeAndValidateService); + } + + public Service runOnboardViaApisOnly(ServiceReqDetails serviceReqDetails, ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception { + + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filepath, vnfFile, sdncDesignerDetails1); + vendorSoftwareProductObject.setName(vendorSoftwareProductObject.getName()); + + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + + Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); + + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + return service; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlowsThroughAPI.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlowsThroughAPI.java index 0b0a8013a0..125023c926 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlowsThroughAPI.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlowsThroughAPI.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,10 +22,17 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; import fj.data.Either; -import org.openecomp.sdc.be.model.*; +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.CvfcTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; @@ -36,7 +43,13 @@ import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; -import org.openecomp.sdc.ci.tests.utils.general.*; +import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.FileHandling; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; +import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; +import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.verificator.CatalogVerificator; import org.testng.Assert; @@ -50,49 +63,49 @@ import java.util.Map.Entry; import static org.testng.AssertJUnit.assertTrue; -public class OnboardingFlowsThroughAPI extends SetupCDTest{ - - protected boolean skipReport = false; - protected User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); +public class OnboardingFlowsThroughAPI extends SetupCDTest { + + protected boolean skipReport = false; + private User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + - // https://sdp.web.att.com/fa3qm1/web/console/Application_Development_Tools_QM_20.20.01#action=com.ibm.rqm.planning.home.actionDispatcher&subAction=viewTestPlan&id=6184 - - @Test - public void addVesFileToVsp() throws Exception{ - String vnfFile = "vMME_Ericsson_small_v2.zip"; - String vesArtifactFile = "VES.zip"; - String filePath = FileHandling.getFilePath("VFCArtifacts"); - String vesArtifactFileLocation = filePath + File.separator + vesArtifactFile; - List vesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation); - List tempVesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation); - Map cvfcArtifacts = new HashMap<>(); - cvfcArtifacts.put(CvfcTypeEnum.VES_EVENTS, vesArtifactFileLocation); - getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); - - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, cvfcArtifacts); - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - List componentInstances = resource.getComponentInstances(); - for(ComponentInstance componentInstance : componentInstances){ - if(componentInstance.getDeploymentArtifacts() !=null && !componentInstance.getDeploymentArtifacts().isEmpty()){ - Map deploymentArtifacts = componentInstance.getDeploymentArtifacts(); - for(Entry entry : deploymentArtifacts.entrySet()){ - if(entry.getValue().getArtifactType().equals(CvfcTypeEnum.VES_EVENTS.getValue())){ - for(String vesArtifact : vesArtifacts){ - if(entry.getValue().getArtifactName().equals(vesArtifact)){ - tempVesArtifacts.remove(vesArtifact); - } - } - } - } - } - } - assertTrue("Not all VES_EVENTS artifact files are on the resource instance", tempVesArtifacts.isEmpty()); - } - + + @Test + public void addVesFileToVsp() throws Exception { + String vnfFile = "vMME_Ericsson_small_v2.zip"; + String vesArtifactFile = "VES.zip"; + String filePath = FileHandling.getFilePath("VFCArtifacts"); + String vesArtifactFileLocation = filePath + File.separator + vesArtifactFile; + List vesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation); + List tempVesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation); + Map cvfcArtifacts = new HashMap<>(); + cvfcArtifacts.put(CvfcTypeEnum.VES_EVENTS, vesArtifactFileLocation); + getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); + + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, cvfcArtifacts); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + List componentInstances = resource.getComponentInstances(); + for (ComponentInstance componentInstance : componentInstances) { + if (componentInstance.getDeploymentArtifacts() != null && !componentInstance.getDeploymentArtifacts().isEmpty()) { + Map deploymentArtifacts = componentInstance.getDeploymentArtifacts(); + for (Entry entry : deploymentArtifacts.entrySet()) { + if (entry.getValue().getArtifactType().equals(CvfcTypeEnum.VES_EVENTS.getValue())) { + for (String vesArtifact : vesArtifacts) { + if (entry.getValue().getArtifactName().equals(vesArtifact)) { + tempVesArtifacts.remove(vesArtifact); + } + } + } + } + } + } + assertTrue("Not all VES_EVENTS artifact files are on the resource instance", tempVesArtifacts.isEmpty()); + } + // 741433: Update Old VSP // 2. Updated VSP "JSA AUG 2017" with the attached zip from v3 to v4. Follow normal steps to update the VF // 3. Update the VSP "vHSS-EPC-RDM3-Lab-0830" using the attached zip. Follow the normal steps to update the VF @@ -100,113 +113,113 @@ public class OnboardingFlowsThroughAPI extends SetupCDTest{ // public void create2(String filePath, String vnfFile) throws Exception{ // setLog(vnfFile); // } - - -// 741509: E2E flow using old VLM - @Test - public void VlmReuse() throws Exception{ - List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); - List newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder); - String filePath = FileHandling.getVnfRepositoryPath(); - String vnfFile = newRandomFileNamesFromFolder.get(0); - getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); + + + // 741509: E2E flow using old VLM + @Test + public void VlmReuse() throws Exception { + List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); + List newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder); + String filePath = FileHandling.getVnfRepositoryPath(); + String vnfFile = newRandomFileNamesFromFolder.get(0); + getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); // setLog(vnfFile); - getExtendTest().log(Status.INFO, "Create Vendor License"); - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - getExtendTest().log(Status.INFO, "Create Vendor Software Product: " + resourceReqDetails.getName()); - VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - getExtendTest().log(Status.INFO, "Create Resource: " + resourceReqDetails.getName()); - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - getExtendTest().log(Status.INFO, "Certify the Resource: " + resourceReqDetails.getName()); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - - ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); - getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - - getExtendTest().log(Status.INFO, "Add VF to service"); - Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - addComponentInstanceToComponentContainer.left().value(); - getExtendTest().log(Status.INFO, "Certify the service"); - service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - getExtendTest().log(Status.INFO, "Start distributing the service"); - Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); - getExtendTest().log(Status.INFO, "Service distributed"); - assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); - + getExtendTest().log(Status.INFO, "Create Vendor License"); + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + getExtendTest().log(Status.INFO, "Create Vendor Software Product: " + resourceReqDetails.getName()); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + getExtendTest().log(Status.INFO, "Create Resource: " + resourceReqDetails.getName()); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + getExtendTest().log(Status.INFO, "Certify the Resource: " + resourceReqDetails.getName()); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); + getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + + getExtendTest().log(Status.INFO, "Add VF to service"); + Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, "Certify the service"); + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, "Start distributing the service"); + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + getExtendTest().log(Status.INFO, "Service distributed"); + assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); + // update - vnfFile = newRandomFileNamesFromFolder.get(1); - getExtendTest().log(Status.INFO, "Going to update VLM with new file " + vnfFile); - VendorLicenseModelRestUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails, false); - vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); - getExtendTest().log(Status.INFO, "Create new VSP: " + vendorSoftwareProductObject.getName()); - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - getExtendTest().log(Status.INFO, "Create new resource: " + resourceReqDetails.getName()); - resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - getExtendTest().log(Status.INFO, "Certify the resource"); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - - serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); - getExtendTest().log(Status.INFO, "Create new service: " + serviceReqDetails.getName()); - service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - - getExtendTest().log(Status.INFO, "Add VF to service"); - addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - addComponentInstanceToComponentContainer.left().value(); - getExtendTest().log(Status.INFO, "Certify the service"); - service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - getExtendTest().log(Status.INFO, "Start distributing the service"); - distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); - getExtendTest().log(Status.INFO, "Service distributed"); - assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); - } - - -// 741607: E2E flow using old VSP - @Test - public void updateVfiVersionOnServiceLevel() throws Throwable{ - List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); - List newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder); - String filePath = FileHandling.getVnfRepositoryPath(); - String vnfFile = newRandomFileNamesFromFolder.get(0); - getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - - ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - - Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); - service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); - assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); + vnfFile = newRandomFileNamesFromFolder.get(1); + getExtendTest().log(Status.INFO, "Going to update VLM with new file " + vnfFile); + VendorLicenseModelRestUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails, false); + vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + getExtendTest().log(Status.INFO, "Create new VSP: " + vendorSoftwareProductObject.getName()); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + getExtendTest().log(Status.INFO, "Create new resource: " + resourceReqDetails.getName()); + resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + getExtendTest().log(Status.INFO, "Certify the resource"); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); + getExtendTest().log(Status.INFO, "Create new service: " + serviceReqDetails.getName()); + service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + + getExtendTest().log(Status.INFO, "Add VF to service"); + addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, "Certify the service"); + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, "Start distributing the service"); + distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + getExtendTest().log(Status.INFO, "Service distributed"); + assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); + } + + + // 741607: E2E flow using old VSP + @Test + public void updateVfiVersionOnServiceLevel() throws Throwable { + List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); + List newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder); + String filePath = FileHandling.getVnfRepositoryPath(); + String vnfFile = newRandomFileNamesFromFolder.get(0); + getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + + Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); // update resource to v2.0 - String updateVnfFile = newRandomFileNamesFromFolder.get(1); - getExtendTest().log(Status.INFO, "Going to update VNF with file " + vnfFile); - VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails, filePath, updateVnfFile); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - resourceReqDetails.setUniqueId(resource.getUniqueId()); - resourceReqDetails.setVersion(resource.getVersion()); - resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - - service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); - - service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); - assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); - } - - + String updateVnfFile = newRandomFileNamesFromFolder.get(1); + getExtendTest().log(Status.INFO, "Going to update VNF with file " + vnfFile); + VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails, filePath, updateVnfFile); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resourceReqDetails.setUniqueId(resource.getUniqueId()); + resourceReqDetails.setVersion(resource.getVersion()); + resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService); + } + + // 741608: E2E flow using old Service // @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") // public void create5(String filePath, String vnfFile) throws Exception{ @@ -216,18 +229,17 @@ public class OnboardingFlowsThroughAPI extends SetupCDTest{ // // 3. Update old Service: fetch few new resources and few old resources -> Certify this Service - > Distribute // // 4. Service is distributed // } - -// 741633: Update HEAT parameter value - @Test() - public void updateHeatParametersValue() throws Throwable{ - String msg = "VfArtifacts-->checkDefaultCreatedEnvArtifactsAfterVspUpdate tests with data provider index 4(last one) check it fully"; - getExtendTest().log(Status.INFO, msg); - } - - // temporaly disabled, until fixed + + // 741633: Update HEAT parameter value + @Test() + public void updateHeatParametersValue() throws Throwable { + String msg = "VfArtifacts-->checkDefaultCreatedEnvArtifactsAfterVspUpdate tests with data provider index 4(last one) check it fully"; + getExtendTest().log(Status.INFO, msg); + } + + // temporaly disabled, until fixed @Test() - public void updateVSPNameTest() throws Throwable - { + public void updateVSPNameTest() throws Throwable { // External Defect: 430425 // Import VSP v1.0 List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); @@ -238,9 +250,9 @@ public class OnboardingFlowsThroughAPI extends SetupCDTest{ User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); getExtendTest().log(Status.INFO, "Create Vendor License Model " + amdocsLicenseMembers.getVendorLicenseName()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName()); - VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); // Create VF, certify - v1.0 is created resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); @@ -252,15 +264,15 @@ public class OnboardingFlowsThroughAPI extends SetupCDTest{ // Update VSP to v2.0 wih the zip from v1.0, update VSP name getExtendTest().log(Status.INFO, "Update VSP to version 2.0"); String origVspName = vendorSoftwareProductObject.getName(); - vendorSoftwareProductObject.setName("Upd" + ElementFactory.generateUUIDforSufix()); + vendorSoftwareProductObject.setName("Upd" + ElementFactory.generateUUIDforSufix()); vendorSoftwareProductObject = VendorSoftwareProductRestUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject, amdocsLicenseMembers, sdncDesignerDetails1); VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1); - //Validate that VF cannot be found by the updated VSP name + //Validate that VF cannot be found by the updated VSP name CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); CatalogUIUtilitis.catalogSearchBox(vendorSoftwareProductObject.getName()); - int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader(); - assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 0, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 0 ); + int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader(); + assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 0, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 0); //Update VF with the new VSP version GeneralUIUtils.findComponentAndClick(origVspName); @@ -277,202 +289,198 @@ public class OnboardingFlowsThroughAPI extends SetupCDTest{ Assert.assertTrue(origVspName.equals(ResourceGeneralPage.getNameText())); } - @Test() - public void UpdateVSPRevertToEarlierVersion() throws Throwable - { - // Test Case: 745821 + @Test() + public void UpdateVSPRevertToEarlierVersion() throws Throwable { + // Test Case: 745821 // 1. Import VSP v1.0 - List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); - List newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder); - String filePath = FileHandling.getVnfRepositoryPath(); - String vnfFile = newRandomFileNamesFromFolder.get(0); - getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); - User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); - getExtendTest().log(Status.INFO, "Create Vendor License Model " + amdocsLicenseMembers.getVendorLicenseName()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName()); - VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + List fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); + List newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder); + String filePath = FileHandling.getVnfRepositoryPath(); + String vnfFile = newRandomFileNamesFromFolder.get(0); + getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); + User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, "Create Vendor License Model " + amdocsLicenseMembers.getVendorLicenseName()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName()); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); // 2. Create VF, certify - v1.0 is created - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName()); - Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName()); - resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName()); + Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName()); + resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); // 3. Update VSP to v2.0 - getExtendTest().log(Status.INFO, "Update VSP to version 2.0"); - VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile); - VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1); + getExtendTest().log(Status.INFO, "Update VSP to version 2.0"); + VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile); + VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1); // 4. Update the VF with v2.0 of the VSP - getExtendTest().log(Status.INFO, "Checkout VF v1.1"); - resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - resourceReqDetails.setUniqueId(resource_v1.getUniqueId()); - resourceReqDetails.setVersion("1.1"); - resourceReqDetails.setCsarVersion("2.0"); - getExtendTest().log(Status.INFO, "Update VF to v2.0"); - resource_v1 = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value(); - getExtendTest().log(Status.INFO, "Certify VF"); - Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, "Checkout VF v1.1"); + resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resourceReqDetails.setUniqueId(resource_v1.getUniqueId()); + resourceReqDetails.setVersion("1.1"); + resourceReqDetails.setCsarVersion("2.0"); + getExtendTest().log(Status.INFO, "Update VF to v2.0"); + resource_v1 = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value(); + getExtendTest().log(Status.INFO, "Certify VF"); + Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); // 5. Update VSP to v3.0 wih the zip from v1.0 - getExtendTest().log(Status.INFO, "Update VSP to version 3.0"); - VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, false); - VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1); - getExtendTest().log(Status.INFO, "Checkout VF v2.1"); - resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - resourceReqDetails.setUniqueId(resource_v1.getUniqueId()); - resourceReqDetails.setVersion("2.1"); - resourceReqDetails.setCsarVersion("3.0"); - getExtendTest().log(Status.INFO, "Update VF to v3.0"); - ResourceRestUtils.updateResource(resourceReqDetails,sdncDesignerDetails1,resource_v1.getUniqueId()); + getExtendTest().log(Status.INFO, "Update VSP to version 3.0"); + VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, false); + VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1); + getExtendTest().log(Status.INFO, "Checkout VF v2.1"); + resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resourceReqDetails.setUniqueId(resource_v1.getUniqueId()); + resourceReqDetails.setVersion("2.1"); + resourceReqDetails.setCsarVersion("3.0"); + getExtendTest().log(Status.INFO, "Update VF to v3.0"); + ResourceRestUtils.updateResource(resourceReqDetails, sdncDesignerDetails1, resource_v1.getUniqueId()); // 6. Update VF to v3.0 - getExtendTest().log(Status.INFO, "Certify VF"); - Resource resource_v3 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, "Certify VF"); + Resource resource_v3 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); // 7. Compare versions v1.0 and v3.0 - should be the same // TODO: Shay add resource comparison. // 8. Add each of the versions to service, certify - OK - ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails1); - getExtendTest().log(Status.INFO, "Create Service " + serviceReqDetails.getName() ); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - getExtendTest().log(Status.INFO, "Add vf's v1 & v2 to service"); - Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v1, service, UserRoleEnum.DESIGNER, true); - Either addComponentInstanceToComponentContainer1 = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v3, service, UserRoleEnum.DESIGNER, true); - getExtendTest().log(Status.INFO, "Certify Service"); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - System.out.println(""); - } - - @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "updateList") - public void updateVSPFlowFromOnboardToDistribution(String vnfFile1, String vnfFile2) throws Throwable - { - setLog(String.format("Create VSP from %s , update VSP with %s ", vnfFile1, vnfFile2)); + ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, "Create Service " + serviceReqDetails.getName()); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, "Add vf's v1 & v2 to service"); + Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v1, service, UserRoleEnum.DESIGNER, true); + Either addComponentInstanceToComponentContainer1 = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v3, service, UserRoleEnum.DESIGNER, true); + getExtendTest().log(Status.INFO, "Certify Service"); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + System.out.println(""); + } + + @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "updateList") + public void updateVSPFlowFromOnboardToDistribution(String vnfFile1, String vnfFile2) throws Throwable { + setLog(String.format("Create VSP from %s , update VSP with %s ", vnfFile1, vnfFile2)); // 1. Import VSP v1.0 - String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath(); - User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); - getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); - getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1)); - VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath(); + User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1)); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); // 2. Create VF, certify - v1.0 is created - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); - getExtendTest().log(Status.INFO, String.format("Certify the VF")); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); + getExtendTest().log(Status.INFO, String.format("Certify the VF")); // 3. Create Service add to it the certified VF and certify the Service v1.0 - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); - Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); - Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); - getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - getExtendTest().log(Status.INFO, String.format("Certify the Service")); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); + Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Certify the Service")); // 4. Distribute the Service v1.0 - Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); - getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); - assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); // 5. Update VSP to v2.0 - getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2); - VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile2); - getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: " ,vnfFile2)); - VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1); + getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2); + VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile2); + getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: ", vnfFile2)); + VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1); // 6. Update the VF with v2.0 of the VSP and certify the VF - getExtendTest().log(Status.INFO, String.format("Checkout the VF %s v1.1 " ,resourceReqDetails.getName())); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - resourceReqDetails.setUniqueId(resource.getUniqueId()); - resourceReqDetails.setVersion("1.1"); - resourceReqDetails.setCsarVersion("2.0"); - getExtendTest().log(Status.INFO, String.format("Upgrade the VF %s v1.1 with the new VSP %s v2.0 " ,resourceReqDetails.getName(),vendorSoftwareProductObject.getName())); - resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value(); - getExtendTest().log(Status.INFO, String.format("Certify the VF to v2.0")); - Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Checkout the VF %s v1.1 ", resourceReqDetails.getName())); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resourceReqDetails.setUniqueId(resource.getUniqueId()); + resourceReqDetails.setVersion("1.1"); + resourceReqDetails.setCsarVersion("2.0"); + getExtendTest().log(Status.INFO, String.format("Upgrade the VF %s v1.1 with the new VSP %s v2.0 ", resourceReqDetails.getName(), vendorSoftwareProductObject.getName())); + resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Certify the VF to v2.0")); + Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); // 7. Update the Service with the VFi version 2.0 - getExtendTest().log(Status.INFO, String.format("Checkout the Service v1.1")); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - getExtendTest().log(Status.INFO, String.format("Change the instance of the VF in the service to VFi v2.0")); - AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); - getExtendTest().log(Status.INFO, String.format("Certify the Service to v2.0")); - service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Checkout the Service v1.1")); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Change the instance of the VF in the service to VFi v2.0")); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + getExtendTest().log(Status.INFO, String.format("Certify the Service to v2.0")); + service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); // 8. Distribute the service v2.0 - distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); - getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); - assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); - } - - @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "VNF_List") - public void fromOnboardToDistribution(String filePath, String vnfFile) throws Throwable - { + distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); + } + + @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "VNF_List") + public void fromOnboardToDistribution(String filePath, String vnfFile) throws Throwable { // String vnfFile1 = "1-2016-20-visbc3vf-(VOIP)_v2.1.zip"; // String vnfFile2 = "2-2016-20-visbc3vf-(VOIP)_v2.0.zip"; - setLog(String.format("%s", vnfFile)); + setLog(String.format("%s", vnfFile)); // 1. Import VSP v1.0 - //String filePath = FileHandling.getVnfRepositoryPath(); - User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); - getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); - getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile)); - VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers); + //String filePath = FileHandling.getVnfRepositoryPath(); + User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile)); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers); // VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct); // 2. Create VF, certify - v1.0 is created - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); - getExtendTest().log(Status.INFO, String.format("Certify the VF")); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); + getExtendTest().log(Status.INFO, String.format("Certify the VF")); // 3. Create Service add to it the certified VF and certify the Service v1.0 - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); - Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); - Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); - getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - getExtendTest().log(Status.INFO, String.format("Certify the Service")); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); + Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Certify the Service")); // 4. Distribute the Service v1.0 - Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); - getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); - assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); - } - - @Test() - public void onboardE2EviaAPI() throws Throwable - { + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); + } + + @Test() + public void onboardE2EviaAPI() throws Throwable { // 1. Import VSP v1.0 - String filePath = FileHandling.getVnfRepositoryPath(); - String vnfFile1 = "1-VF-vCSCF-StateDB-new-update_v3.0.zip"; - User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); - getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); - getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1)); - VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1, amdocsLicenseMembers); + String filePath = FileHandling.getVnfRepositoryPath(); + String vnfFile1 = "1-VF-vCSCF-StateDB-new-update_v3.0.zip"; + User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1)); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1, amdocsLicenseMembers); // VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile1, createVendorSoftwareProduct); // 2. Create VF, certify - v1.0 is created - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); - getExtendTest().log(Status.INFO, String.format("Certify the VF")); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); + getExtendTest().log(Status.INFO, String.format("Certify the VF")); // 3. Create Service add to it the certified VF and certify the Service v1.0 - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); - Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); - Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); - getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - getExtendTest().log(Status.INFO, String.format("Certify the Service")); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); + Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + getExtendTest().log(Status.INFO, String.format("Certify the Service")); // 4. Distribute the Service v1.0 - Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); - getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); - assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service")); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlowsUI.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlowsUI.java index 3461aa8af5..d883420942 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlowsUI.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlowsUI.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,13 +22,28 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.XnfTypeEnum; import org.openecomp.sdc.ci.tests.execute.setup.ArtifactsCorrelationManager; import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GovernorOperationPage; +import org.openecomp.sdc.ci.tests.pages.HomePage; +import org.openecomp.sdc.ci.tests.pages.OpsOperationPage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.TesterOperationPage; +import org.openecomp.sdc.ci.tests.pages.VspValidationPage; +import org.openecomp.sdc.ci.tests.pages.VspValidationResultsPage; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; @@ -59,7 +74,7 @@ import static org.testng.AssertJUnit.assertTrue; public class OnboardingFlowsUI extends SetupCDTest { protected static String filePath = FileHandling.getVnfRepositoryPath(); - protected String makeDistributionValue; + private String makeDistributionValue; @Parameters({"makeDistribution"}) @BeforeMethod @@ -70,8 +85,8 @@ public class OnboardingFlowsUI extends SetupCDTest { @Test public void onboardVNFTestSanityOneFile() throws Throwable { String vnfFile = "1-VF-vUSP-vCCF-DB_v11.1.zip"; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); //getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); } @@ -94,16 +109,16 @@ public class OnboardingFlowsUI extends SetupCDTest { public void onboardVNFTestSanity() throws Throwable { List fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF); String vnfFile = fileNamesFromFolder.get(0).toString(); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); //getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); } @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders.class, dataProvider = "Single_VNF") public void onapOnboardVNFflow(String filePath, String vnfFile) throws Exception, Throwable { setLog(vnfFile); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); //getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); System.out.println("print - >" + makeDistributionValue); runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); } @@ -112,7 +127,7 @@ public class OnboardingFlowsUI extends SetupCDTest { public void onapOnboardVSPValidationsSanityFlow(String filePath, String vnfFile) throws Exception, Throwable { setLog(vnfFile); String vspName = createNewVSP(filePath, vnfFile); - if(OnboardingUiUtils.getVspValidationCongiguration()){ + if (OnboardingUiUtils.getVspValidationCongiguration()) { goToVspScreen(true, vspName); //check links are available @@ -123,8 +138,7 @@ public class OnboardingFlowsUI extends SetupCDTest { VspValidationResultsPage.navigateToVspValidationResultsPageUsingNavbar(); GeneralUIUtils.ultimateWait(); assertNotNull(GeneralUIUtils.findByText("No Validation Checks Performed")); - } - else { + } else { goToVspScreen(true, vspName); //check links are not available @@ -137,7 +151,7 @@ public class OnboardingFlowsUI extends SetupCDTest { public void onapOnboardVSPValidationsConfigurationChangeCheck(String filePath, String vnfFile) throws Exception, Throwable { setLog(vnfFile); String vspName = createNewVSP(filePath, vnfFile); - if(OnboardingUiUtils.getVspValidationCongiguration()){ + if (OnboardingUiUtils.getVspValidationCongiguration()) { goToVspScreen(true, vspName); //check links are available checkVspValidationLinksVisibility(); @@ -147,8 +161,7 @@ public class OnboardingFlowsUI extends SetupCDTest { //check links are not available checkVspValidationLinksInvisibility(); - } - else { + } else { goToVspScreen(true, vspName); //check links are not available checkVspValidationLinksInvisibility(); @@ -164,17 +177,16 @@ public class OnboardingFlowsUI extends SetupCDTest { public void onapOnboardVSPCertificationQueryFlow(String filePath, String vnfFile) throws Exception, Throwable { setLog(vnfFile); String vspName = createNewVSP(filePath, vnfFile); - if(!OnboardingUiUtils.getVspValidationCongiguration()){ + if (!OnboardingUiUtils.getVspValidationCongiguration()) { //change config to true to test the feature changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration()); - } - else { + } else { goToVspScreen(true, vspName); } VspValidationPage.navigateToVspValidationPageUsingNavbar(); assertTrue("Next Button is enabled, it should have been disabled", VspValidationPage.checkNextButtonDisabled()); - if(VspValidationPage.checkCertificationQueryExists()){ + if (VspValidationPage.checkCertificationQueryExists()) { VspValidationPage.clickCertificationQueryAll(); GeneralUIUtils.ultimateWait(); assertTrue("Next Button is disabled, it should have been enabled", !VspValidationPage.checkNextButtonDisabled()); @@ -183,8 +195,7 @@ public class OnboardingFlowsUI extends SetupCDTest { VspValidationPage.clickOnSubmitButton(); GeneralUIUtils.waitForLoader(); assertTrue("Results are not available", VspValidationResultsPage.checkResultsExist()); - } - else { + } else { assertNotNull(GeneralUIUtils.findByText("No Certifications Query are Available")); } @@ -195,17 +206,16 @@ public class OnboardingFlowsUI extends SetupCDTest { setLog(vnfFile); String vspName = createNewVSP(filePath, vnfFile); final String complianceNotAvailableLabel = "No Compliance Checks are Available"; - if(!OnboardingUiUtils.getVspValidationCongiguration()){ + if (!OnboardingUiUtils.getVspValidationCongiguration()) { //change config to true to test the feature changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration()); - } - else { + } else { goToVspScreen(true, vspName); } VspValidationPage.navigateToVspValidationPageUsingNavbar(); assertTrue("Next Button is enabled, it should have been enabled", VspValidationPage.checkNextButtonDisabled()); - if(VspValidationPage.checkComplianceCheckExists()){ + if (VspValidationPage.checkComplianceCheckExists()) { VspValidationPage.clickComplianceChecksAll(); GeneralUIUtils.ultimateWait(); assertTrue("Next Button is disabled, it should have been enabled", !VspValidationPage.checkNextButtonDisabled()); @@ -214,8 +224,7 @@ public class OnboardingFlowsUI extends SetupCDTest { VspValidationPage.clickOnSubmitButton(); GeneralUIUtils.ultimateWait(); assertTrue("Results are not available", VspValidationResultsPage.checkResultsExist()); - } - else { + } else { assertNotNull(GeneralUIUtils.findByText(complianceNotAvailableLabel)); } @@ -225,17 +234,16 @@ public class OnboardingFlowsUI extends SetupCDTest { public void onapOnboardVSPComplianceCheckOperations(String filePath, String vnfFile) throws Exception { setLog(vnfFile); String vspName = createNewVSP(filePath, vnfFile); - if(!OnboardingUiUtils.getVspValidationCongiguration()){ + if (!OnboardingUiUtils.getVspValidationCongiguration()) { //change config to true to test the feature changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration()); - } - else { + } else { goToVspScreen(true, vspName); } VspValidationPage.navigateToVspValidationPageUsingNavbar(); assertTrue("Next Button is enabled, it should have been enabled", VspValidationPage.checkNextButtonDisabled()); - if(VspValidationPage.checkComplianceCheckExists()){ + if (VspValidationPage.checkComplianceCheckExists()) { assertTrue("The tests are already selected, the list should initially be empty", !VspValidationPage.checkSelectedComplianceCheckExists()); VspValidationPage.clickComplianceChecksAll(); GeneralUIUtils.ultimateWait(); @@ -243,8 +251,7 @@ public class OnboardingFlowsUI extends SetupCDTest { VspValidationPage.clickComplianceChecksAll(); GeneralUIUtils.ultimateWait(); assertTrue("The selected tests are not deleted from the list", !VspValidationPage.checkSelectedComplianceCheckExists()); - } - else { + } else { assertNotNull(GeneralUIUtils.findByText("No Compliance Checks are Available")); } @@ -254,17 +261,16 @@ public class OnboardingFlowsUI extends SetupCDTest { public void onapOnboardVSPCertificationQueryOperations(String filePath, String vnfFile) throws Exception { setLog(vnfFile); String vspName = createNewVSP(filePath, vnfFile); - if(!OnboardingUiUtils.getVspValidationCongiguration()){ + if (!OnboardingUiUtils.getVspValidationCongiguration()) { //change config to true to test the feature changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration()); - } - else { + } else { goToVspScreen(true, vspName); } VspValidationPage.navigateToVspValidationPageUsingNavbar(); assertTrue("Next Button is enabled, it should have been enabled", VspValidationPage.checkNextButtonDisabled()); - if(VspValidationPage.checkCertificationQueryExists()){ + if (VspValidationPage.checkCertificationQueryExists()) { assertTrue("The tests are already selected, the list should initially be empty", !VspValidationPage.checkSelectedCertificationQueryExists()); VspValidationPage.clickCertificationQueryAll(); GeneralUIUtils.ultimateWait(); @@ -272,31 +278,30 @@ public class OnboardingFlowsUI extends SetupCDTest { VspValidationPage.clickCertificationQueryAll(); GeneralUIUtils.ultimateWait(); assertTrue("The selected tests are not deleted from the list", !VspValidationPage.checkSelectedCertificationQueryExists()); - } - else { + } else { assertNotNull(GeneralUIUtils.findByText("No Compliance Checks are Available")); } } - private void checkVspValidationLinksVisibility(){ + private void checkVspValidationLinksVisibility() { //check links are available assertTrue("Validation Link is not available", GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR.getValue())); assertTrue("Validation Results Link is not available", GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_NAVBAR.getValue())); } - private void checkVspValidationLinksInvisibility(){ + private void checkVspValidationLinksInvisibility() { //check links not available assertTrue("Validation Link is still available", GeneralUIUtils.isElementInvisibleByTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR.getValue())); assertTrue("Validation Results Link is still available", GeneralUIUtils.isElementInvisibleByTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_NAVBAR.getValue())); } - private void changeVspValidationConfig(boolean isCurrentScreenCatalogPage, String vspName, boolean vspConfig) throws Exception{ + private void changeVspValidationConfig(boolean isCurrentScreenCatalogPage, String vspName, boolean vspConfig) throws Exception { //change config OnboardingUiUtils.putVspValidationCongiguration(!vspConfig); assertTrue(String.format("Failed to set Congiguration to %s", !vspConfig), OnboardingUiUtils.getVspValidationCongiguration() != vspConfig); - if(!isCurrentScreenCatalogPage){ + if (!isCurrentScreenCatalogPage) { GeneralUIUtils.refreshWebpage(); GeneralUIUtils.ultimateWait(); } @@ -308,9 +313,10 @@ public class OnboardingFlowsUI extends SetupCDTest { assertTrue(String.format("Failed to revert Congiguration to %s", vspConfig), OnboardingUiUtils.getVspValidationCongiguration() == vspConfig); } - private void goToVspScreen(boolean isCurrentScreenCatalogPage, String vspName) throws Exception{ - if(isCurrentScreenCatalogPage) + private void goToVspScreen(boolean isCurrentScreenCatalogPage, String vspName) throws Exception { + if (isCurrentScreenCatalogPage) { GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.MainMenuButtons.ONBOARD_BUTTON.getValue()); + } GeneralUIUtils.clickOnElementByText(vspName); GeneralUIUtils.ultimateWait(); } @@ -319,6 +325,7 @@ public class OnboardingFlowsUI extends SetupCDTest { ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); return OnboardingUiUtils.createVSP(resourceReqDetails, vnfFile, filePath, getUser()).getName(); } + public void runOnboardToDistributionFlow(ResourceReqDetails resourceReqDetails, ServiceReqDetails serviceMetadata, String filePath, String vnfFile) throws Exception { getExtendTest().log(Status.INFO, "Going to create resource with category: " + resourceReqDetails.getCategories().get(0).getName() + " subCategory: " + resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName() @@ -396,7 +403,7 @@ public class OnboardingFlowsUI extends SetupCDTest { public void onboardVNFShotFlow(String filePath, String vnfFile) throws Throwable { setLog(vnfFile); System.out.println("printttttttttttttt - >" + makeDistributionValue); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); onboardAndCertify(resourceReqDetails, filePath, vnfFile); } @@ -415,7 +422,7 @@ public class OnboardingFlowsUI extends SetupCDTest { public void onboardUpdateVNFTest() throws Throwable { List fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filePath); String vnfFile = fileNamesFromFolder.get(0); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser()); String vspName = vsp.getName(); ResourceGeneralPage.clickCertifyButton(vspName); @@ -486,7 +493,7 @@ public class OnboardingFlowsUI extends SetupCDTest { System.out.println(String.format("Going to onboard the VNF %s......", vnfFile)); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, pathFile, getUser(), amdocsLicenseMembers); getExtendTest().log(Status.INFO, String.format("Searching for onboarded %s", vnfFile)); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PNF.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PNF.java index 0ca304fc39..97a70100a3 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PNF.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PNF.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,15 +24,38 @@ import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; +import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.TypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.GovernorOperationPage; +import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage; +import org.openecomp.sdc.ci.tests.pages.OpsOperationPage; +import org.openecomp.sdc.ci.tests.pages.PropertiesPage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.TesterOperationPage; +import org.openecomp.sdc.ci.tests.pages.ToscaArtifactsPage; +import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; @@ -49,364 +72,361 @@ import java.util.List; import static org.testng.Assert.assertTrue; public class PNF extends SetupCDTest { - - private String filePath; - @BeforeClass - public void beforeClass(){ - filePath = FileHandling.getFilePath(""); - } - - @BeforeMethod - public void beforeTest(){ - System.out.println("File repository is : " + filePath); - getExtendTest().log(Status.INFO, "File repository is : " + filePath); - } - - @Test - public void updatePNF() throws Exception { - - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - - // update Resource - ResourceReqDetails updatedResource = new ResourceReqDetails(); - updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + pnfMetaData.getName()); - updatedResource.setDescription("kuku"); - updatedResource.setVendorName("updatedVendor"); - updatedResource.setVendorRelease("updatedRelease"); - updatedResource.setContactId("ab0001"); - updatedResource.setCategories(pnfMetaData.getCategories()); - updatedResource.setVersion("0.1"); - updatedResource.setResourceType(ResourceTypeEnum.VF.getValue()); - List newTags = pnfMetaData.getTags(); - newTags.remove(pnfMetaData.getName()); - newTags.add(updatedResource.getName()); - updatedResource.setTags(newTags); - ResourceUIUtils.updateResource(updatedResource, getUser()); - - VfVerificator.verifyVFMetadataInUI(updatedResource); - VfVerificator.verifyVFUpdated(updatedResource, getUser()); - } - - @Test - public void addUpdateDeleteInformationalArtifactPNFTest() throws Exception { - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); - InformationalArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); - - AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1)); - - String newDescription = "new description"; - InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel()); - InformationalArtifactPage.artifactPopup().insertDescription(newDescription); - InformationalArtifactPage.artifactPopup().clickDoneButton(); - String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel()); - AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); - - InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel()); - InformationalArtifactPage.clickOK(); - AssertJUnit.assertTrue("artifact "+ informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0)); - } - - @Test - public void addPropertiesToVfcInstanceInPNFTest() throws Exception { - - if(true){ + + private String filePath; + + @BeforeClass + public void beforeClass() { + filePath = FileHandling.getFilePath(""); + } + + @BeforeMethod + public void beforeTest() { + System.out.println("File repository is : " + filePath); + getExtendTest().log(Status.INFO, "File repository is : " + filePath); + } + + @Test + public void updatePNF() throws Exception { + + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + // update Resource + ResourceReqDetails updatedResource = new ResourceReqDetails(); + updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + pnfMetaData.getName()); + updatedResource.setDescription("kuku"); + updatedResource.setVendorName("updatedVendor"); + updatedResource.setVendorRelease("updatedRelease"); + updatedResource.setContactId("ab0001"); + updatedResource.setCategories(pnfMetaData.getCategories()); + updatedResource.setVersion("0.1"); + updatedResource.setResourceType(ResourceTypeEnum.VF.getValue()); + List newTags = pnfMetaData.getTags(); + newTags.remove(pnfMetaData.getName()); + newTags.add(updatedResource.getName()); + updatedResource.setTags(newTags); + ResourceUIUtils.updateResource(updatedResource, getUser()); + + VfVerificator.verifyVFMetadataInUI(updatedResource); + VfVerificator.verifyVFUpdated(updatedResource, getUser()); + } + + @Test + public void addUpdateDeleteInformationalArtifactPNFTest() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + + ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); + InformationalArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); + + AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1)); + + String newDescription = "new description"; + InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel()); + InformationalArtifactPage.artifactPopup().insertDescription(newDescription); + InformationalArtifactPage.artifactPopup().clickDoneButton(); + String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel()); + AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); + + InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel()); + InformationalArtifactPage.clickOK(); + AssertJUnit.assertTrue("artifact " + informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0)); + } + + @Test + public void addPropertiesToVfcInstanceInPNFTest() throws Exception { + + if (true) { // throw new SkipException("Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); - SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); - } - - String fileName = "CP02.yml"; - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - - try{ - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - CanvasElement cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - - vfCanvasManager.clickOnCanvaElement(cpElement); - CompositionPage.showPropertiesAndAttributesTab(); - List properties = CompositionPage.getProperties(); - String propertyValue = "abc123"; - for (int i = 0; i < 2; i++) { - WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label")); - findElement.click(); - PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue); - PropertiesPage.getPropertyPopup().clickSave(); - - findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value")); - SetupCDTest.getExtendTest().log(Status.INFO, "Validating properties"); - AssertJUnit.assertTrue(findElement.getText().equals(propertyValue)); - } - } - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); - } - } - - @Test - public void changeInstanceVersionPNFTest() throws Exception{ - - ResourceReqDetails atomicResourceMetaData = null; - ResourceReqDetails pnfMetaData = null; - CanvasManager vfCanvasManager; - CanvasElement cpElement = null; - String fileName = "CP03.yml"; - try{ - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); - - pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser()); - ResourceUIUtils.createPNF(pnfMetaData, getUser()); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - - //TODO Andrey should click on certify button - CompositionPage.clickCertifyButton(pnfMetaData.getName()); - assert(false); - } - catch(Exception e){ - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); - AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError)); + SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); + } + + String fileName = "CP02.yml"; + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + + try { + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + CanvasElement cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + + vfCanvasManager.clickOnCanvaElement(cpElement); + CompositionPage.showPropertiesAndAttributesTab(); + List properties = CompositionPage.getProperties(); + String propertyValue = "abc123"; + for (int i = 0; i < 2; i++) { + WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label")); + findElement.click(); + PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue); + PropertiesPage.getPropertyPopup().clickSave(); + + findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value")); + SetupCDTest.getExtendTest().log(Status.INFO, "Validating properties"); + AssertJUnit.assertTrue(findElement.getText().equals(propertyValue)); + } + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); + } + } + + @Test + public void changeInstanceVersionPNFTest() throws Exception { + + ResourceReqDetails atomicResourceMetaData = null; + ResourceReqDetails pnfMetaData = null; + CanvasManager vfCanvasManager; + CanvasElement cpElement = null; + String fileName = "CP03.yml"; + try { + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); + + pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser()); + ResourceUIUtils.createPNF(pnfMetaData, getUser()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + + //TODO Andrey should click on certify button + CompositionPage.clickCertifyButton(pnfMetaData.getName()); + assert (false); + } catch (Exception e) { + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); + AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError)); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); TesterOperationPage.certifyComponent(atomicResourceMetaData.getName()); reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.changeComponentVersion(vfCanvasManager, cpElement, "1.0"); - - //verfication - VfVerificator.verifyInstanceVersion(pnfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0"); - } - - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); - } - - } - - @Test - public void verifyToscaArtifactsExistPNFTest() throws Exception{ - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - - final int numOfToscaArtifacts = 2; - ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); - AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts)); - - for(int i = 0; i < numOfToscaArtifacts; i++){ - String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); - AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); - } - //TODO Andrey should click on certify button - ToscaArtifactsPage.clickCertifyButton(pnfMetaData.getName()); - pnfMetaData.setVersion("1.0"); - VfVerificator.verifyToscaArtifactsInfo(pnfMetaData, getUser()); - } - - @Test - public void pnfCertificationTest() throws Exception{ - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - - String vfName = pnfMetaData.getName(); - - ResourceGeneralPage.clickCheckinButton(vfName); - GeneralUIUtils.findComponentAndClick(vfName); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(vfName); + GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, cpElement, "1.0"); + + //verfication + VfVerificator.verifyInstanceVersion(pnfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0"); + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); + } + + } + + @Test + public void verifyToscaArtifactsExistPNFTest() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + final int numOfToscaArtifacts = 2; + ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); + AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts)); + + for (int i = 0; i < numOfToscaArtifacts; i++) { + String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); + AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); + } + //TODO Andrey should click on certify button + ToscaArtifactsPage.clickCertifyButton(pnfMetaData.getName()); + pnfMetaData.setVersion("1.0"); + VfVerificator.verifyToscaArtifactsInfo(pnfMetaData, getUser()); + } + + @Test + public void pnfCertificationTest() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + String vfName = pnfMetaData.getName(); + + ResourceGeneralPage.clickCheckinButton(vfName); + GeneralUIUtils.findComponentAndClick(vfName); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(vfName); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfName); TesterOperationPage.certifyComponent(vfName);*/ - - pnfMetaData.setVersion("1.0"); - VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - - /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - GeneralUIUtils.findComponentAndClick(vfName); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); - } - - @Test - public void deletePNFTest() throws Exception{ - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - - GeneralPageElements.clickTrashButtonAndConfirm(); - - pnfMetaData.setVersion("0.1"); - VfVerificator.verifyVfDeleted(pnfMetaData, getUser()); - } - - @Test - public void revertPNFMetadataTest() throws Exception{ - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - - ResourceReqDetails pvfRevertDetails = new ResourceReqDetails(); - pvfRevertDetails.setName("ciUpdatedName"); - pvfRevertDetails.setDescription("kuku"); - pvfRevertDetails.setCategories(pnfMetaData.getCategories()); - pvfRevertDetails.setVendorName("updatedVendor"); - pvfRevertDetails.setVendorRelease("updatedRelease"); - ResourceUIUtils.fillResourceGeneralInformationPage(pvfRevertDetails, getUser(), false); - - GeneralPageElements.clickRevertButton(); - - VfVerificator.verifyVFMetadataInUI(pnfMetaData); - } - @Test - public void checkoutPnfTest() throws Exception{ - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - - ResourceGeneralPage.clickCheckinButton(pnfMetaData.getName()); - GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); - GeneralPageElements.clickCheckoutButton(); - - pnfMetaData.setVersion("0.2"); - VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(pnfMetaData.getName()); + pnfMetaData.setVersion("1.0"); + VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); + + /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ + GeneralUIUtils.findComponentAndClick(vfName); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); + } + + @Test + public void deletePNFTest() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + GeneralPageElements.clickTrashButtonAndConfirm(); + + pnfMetaData.setVersion("0.1"); + VfVerificator.verifyVfDeleted(pnfMetaData, getUser()); + } + + @Test + public void revertPNFMetadataTest() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + ResourceReqDetails pvfRevertDetails = new ResourceReqDetails(); + pvfRevertDetails.setName("ciUpdatedName"); + pvfRevertDetails.setDescription("kuku"); + pvfRevertDetails.setCategories(pnfMetaData.getCategories()); + pvfRevertDetails.setVendorName("updatedVendor"); + pvfRevertDetails.setVendorRelease("updatedRelease"); + ResourceUIUtils.fillResourceGeneralInformationPage(pvfRevertDetails, getUser(), false); + + GeneralPageElements.clickRevertButton(); + + VfVerificator.verifyVFMetadataInUI(pnfMetaData); + } + + @Test + public void checkoutPnfTest() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + ResourceGeneralPage.clickCheckinButton(pnfMetaData.getName()); + GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); + GeneralPageElements.clickCheckoutButton(); + + pnfMetaData.setVersion("0.2"); + VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(pnfMetaData.getName()); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); TesterOperationPage.certifyComponent(pnfMetaData.getName()); reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); - ResourceGeneralPage.clickCheckoutButton(); - - pnfMetaData.setVersion("1.1"); - pnfMetaData.setUniqueId(null); - VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - } - - public ResourceReqDetails createPNFWithGenerateName() throws Exception { - ResourceReqDetails pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser()); - ResourceUIUtils.createPNF(pnfMetaData, getUser()); - return pnfMetaData; - } - - @Test - public void verifyPNF_UI_Limitations() throws Exception { - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - - SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Artifact Left Side Menu not exist"); - assertTrue(GeneralUIUtils.isElementInvisibleByTestId("Deployment ArtifactLeftSideMenu")); - SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Left Side Menu not exist"); - assertTrue(GeneralUIUtils.isElementInvisibleByTestId("DeploymentLeftSideMenu")); - } - - @Test - public void filteringCatalogByPNF() throws Exception { - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - - String pnfName = pnfMetaData.getName(); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(pnfName); + GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); + + pnfMetaData.setVersion("1.1"); + pnfMetaData.setUniqueId(null); + VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + } + + public ResourceReqDetails createPNFWithGenerateName() throws Exception { + ResourceReqDetails pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser()); + ResourceUIUtils.createPNF(pnfMetaData, getUser()); + return pnfMetaData; + } + + @Test + public void verifyPNF_UI_Limitations() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Artifact Left Side Menu not exist"); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId("Deployment ArtifactLeftSideMenu")); + SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Left Side Menu not exist"); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId("DeploymentLeftSideMenu")); + } + + @Test + public void filteringCatalogByPNF() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + + String pnfName = pnfMetaData.getName(); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(pnfName); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(pnfName); TesterOperationPage.certifyComponent(pnfName);*/ - pnfMetaData.setVersion("1.0"); - VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); + pnfMetaData.setVersion("1.0"); + VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf("PNF")); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating resource %s found", pnfName)); - GeneralUIUtils.clickOnElementByTestId(pnfName); - } + /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf("PNF")); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating resource %s found", pnfName)); + GeneralUIUtils.clickOnElementByTestId(pnfName); + } - @Test - public void addPNFtoServiceAndDistribute() throws Exception { - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + @Test + public void addPNFtoServiceAndDistribute() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement("ContrailPort"); - vfCanvasManager.createElementOnCanvas("ContrailPort"); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement("ContrailPort"); + vfCanvasManager.createElementOnCanvas("ContrailPort"); - String pnfName = pnfMetaData.getName(); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(pnfName); + String pnfName = pnfMetaData.getName(); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(pnfName); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(pnfName); TesterOperationPage.certifyComponent(pnfName);*/ - pnfMetaData.setVersion("1.0"); - VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - - /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(pnfName); - CanvasElement pnfElement = canvasManager.createElementOnCanvas(pnfName); - CanvasElement networkElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.CONTRAIL_VIRTUAL_NETWORK); - - canvasManager.linkElements(pnfElement, networkElement); - String serviceName = serviceMetadata.getName(); - ServiceGeneralPage.clickSubmitForTestingButton(serviceName); - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceName); - TesterOperationPage.certifyComponent(serviceName); - - reloginWithNewRole(UserRoleEnum.GOVERNOR); - GeneralUIUtils.findComponentAndClick(serviceName); - GovernorOperationPage.approveSerivce(serviceName); - - reloginWithNewRole(UserRoleEnum.OPS); - GeneralUIUtils.findComponentAndClick(serviceName); - OpsOperationPage.distributeService(); - } - - @Test - public void checkInfomationArtifactUploadLimitation() throws Exception { - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - List webElements = GeneralUIUtils.getWebElementsListBy(By.xpath(DataTestIdEnum.ArtifactPageEnum.ADD_OTHER_ARTIFACT_BUTTON.getValue())); - int numberOfElements = webElements.size(); - String buttonText = webElements.get(0).getText(); - SetupCDTest.getExtendTest().log(Status.INFO, "Verifying only one button exist: Add Other Artifact"); - assertTrue(buttonText.equalsIgnoreCase(("Add Other Artifact"))); - assertTrue(1==numberOfElements, "There should be only one option for uploading artifact in PNF"); - } - - @Test - public void checkNonCPVLObjectsNotExistInComosition() throws Exception { - ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - String pnfName = pnfMetaData.getName(); - // Searching for VFC element and make sure it not exist in PNF composition (Only VL/CP are allowed). - CompositionPage.searchForElement("BlockStorage"); - SetupCDTest.getExtendTest().log(Status.INFO, "Verifying Element found"); - assertTrue(GeneralUIUtils.isElementInvisibleByTestId("BlockStorage")); - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + pnfMetaData.setVersion("1.0"); + VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); + + /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(pnfName); + CanvasElement pnfElement = canvasManager.createElementOnCanvas(pnfName); + CanvasElement networkElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.CONTRAIL_VIRTUAL_NETWORK); + + canvasManager.linkElements(pnfElement, networkElement); + String serviceName = serviceMetadata.getName(); + ServiceGeneralPage.clickSubmitForTestingButton(serviceName); + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceName); + TesterOperationPage.certifyComponent(serviceName); + + reloginWithNewRole(UserRoleEnum.GOVERNOR); + GeneralUIUtils.findComponentAndClick(serviceName); + GovernorOperationPage.approveSerivce(serviceName); + + reloginWithNewRole(UserRoleEnum.OPS); + GeneralUIUtils.findComponentAndClick(serviceName); + OpsOperationPage.distributeService(); + } + + @Test + public void checkInfomationArtifactUploadLimitation() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + List webElements = GeneralUIUtils.getWebElementsListBy(By.xpath(DataTestIdEnum.ArtifactPageEnum.ADD_OTHER_ARTIFACT_BUTTON.getValue())); + int numberOfElements = webElements.size(); + String buttonText = webElements.get(0).getText(); + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying only one button exist: Add Other Artifact"); + assertTrue(buttonText.equalsIgnoreCase(("Add Other Artifact"))); + assertTrue(1 == numberOfElements, "There should be only one option for uploading artifact in PNF"); + } + + @Test + public void checkNonCPVLObjectsNotExistInComosition() throws Exception { + ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + String pnfName = pnfMetaData.getName(); + // Searching for VFC element and make sure it not exist in PNF composition (Only VL/CP are allowed). + CompositionPage.searchForElement("BlockStorage"); + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying Element found"); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId("BlockStorage")); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PortMirroring.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PortMirroring.java index 35f7f6f6c5..9f7f5adcd3 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PortMirroring.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PortMirroring.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,15 @@ import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.ConnectionWizardPopUpObject; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.PortMirrioringConfigurationObject; +import org.openecomp.sdc.ci.tests.datatypes.PortMirroringEnum; +import org.openecomp.sdc.ci.tests.datatypes.ServiceContainer; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; @@ -49,6 +57,8 @@ import static org.testng.Assert.assertTrue; public class PortMirroring extends SetupCDTest { + private static final int THREAD_SLEEP_TIME = 3000; + @Test public void createPortMirroringConfigurationServiceProxy() throws Throwable { PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false); @@ -89,15 +99,15 @@ public class PortMirroring extends SetupCDTest { } @Test - public void createPortMirroringByPolicyServiceProxy() throws Throwable { + public void createPortMirroringByPolicyServiceProxy() throws Throwable { //Using API onboard and certify 2 zip files Source: vmmme and Collector: Vprobe String filePath = FileHandling.getPortMirroringRepositoryPath(); ServiceContainer serviceContainerVmme_Source = PortMirroringUtils.createServiceFromHeatFile(filePath, "2016-227_vmme_vmme_30_1610_e2e.zip"); // create service with required pnf's and certify it - Resource resourceCisco = PortMirroringUtils.GeneratePNFAndUpdateInput(PortMirroringEnum.CISCO_VENDOR_NAME.getValue(), PortMirroringEnum.CISCO_VENDOR_MODEL_NUMBER.getValue(), getUser()); - Resource resourceAPCON1 = PortMirroringUtils.GeneratePNFAndUpdateInput(PortMirroringEnum.APCON1_VENDOR_NAME.getValue(), PortMirroringEnum.APCON1_VENDOR_MODEL_NUMBER.getValue(), getUser()); - Resource resourceAPCON2 = PortMirroringUtils.GeneratePNFAndUpdateInput(PortMirroringEnum.APCON2_VENDOR_NAME.getValue(), PortMirroringEnum.APCON2_VENDOR_MODEL_NUMBER.getValue(), getUser()); + Resource resourceCisco = PortMirroringUtils.generatePNFAndUpdateInput(PortMirroringEnum.CISCO_VENDOR_NAME.getValue(), PortMirroringEnum.CISCO_VENDOR_MODEL_NUMBER.getValue(), getUser()); + Resource resourceAPCON1 = PortMirroringUtils.generatePNFAndUpdateInput(PortMirroringEnum.APCON1_VENDOR_NAME.getValue(), PortMirroringEnum.APCON1_VENDOR_MODEL_NUMBER.getValue(), getUser()); + Resource resourceAPCON2 = PortMirroringUtils.generatePNFAndUpdateInput(PortMirroringEnum.APCON2_VENDOR_NAME.getValue(), PortMirroringEnum.APCON2_VENDOR_MODEL_NUMBER.getValue(), getUser()); ServiceReqDetails serviceReqDetailsCollector = ElementFactory.getDefaultService(); serviceReqDetailsCollector.setServiceType(PortMirroringEnum.SERVICE_TYPE.getValue()); @@ -152,15 +162,12 @@ public class PortMirroring extends SetupCDTest { PortMirroringVerificator.validatingProxyServiceNameAndType(vmmeSourceName, "0"); getExtendTest().log(Status.INFO, "Adding properties to PMCP"); - - if(true){ -// throw new SkipException("Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); - SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); - } + + SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); canvasManager.clickOnCanvaElement(portMirroringConfigurationByPolicyElement); CompositionPage.showPropertiesAndAttributesTab(); - CompositionPage.setSingleProperty(DataTestIdEnum.PortMirroring.COLLECTOR_NODE.getValue(), PortMirroringUtils.createProxyInstanceServiceName(collectorServiceName, "1")); + CompositionPage.setSingleProperty(DataTestIdEnum.PortMirroring.COLLECTOR_NODE.getValue(), PortMirroringUtils.createproxyinstanceservicename(collectorServiceName, "1")); CompositionPage.setSingleProperty(DataTestIdEnum.PortMirroring.EQUIP_MODEL.getValue(), PortMirroringEnum.CISCO_VENDOR_MODEL_NUMBER.getValue()); CompositionPage.setSingleProperty(DataTestIdEnum.PortMirroring.EQUIP_VENDOR.getValue(), PortMirroringEnum.CISCO_VENDOR_NAME.getValue()); @@ -219,7 +226,7 @@ public class PortMirroring extends SetupCDTest { @Test public void verifyPMCNotExistInVF() throws Exception { - Resource resource = PortMirroringUtils.getResourceByType(ResourceTypeEnum.VF, "VF", "VendorModel"); + Resource resource = PortMirroringUtils.getresourcebytype(ResourceTypeEnum.VF, "VF", "VendorModel"); CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); @@ -277,10 +284,7 @@ public class PortMirroring extends SetupCDTest { canvasManager.clickOnCanvaElement(portMirroringConfigurationByPolicyElement); getExtendTest().log(Status.INFO, "Edit PMCP Name"); -// GeneralUIUtils.clickOnElementById(DataTestIdEnum.CompositionRightPanel.EDIT_PENCIL.getValue()); -// GeneralUIUtils.setTextInElementByDataTestID(DataTestIdEnum.CompositionRightPanel.INSTANCE_NAME_TEXTBOX.getValue(), PortMirroringEnum.PMCP_NEWNAME.getValue()); -// GeneralUIUtils.clickOnElementByTestId("OK"); - canvasManager.updateElementNameInCanvas(portMirroringConfigurationByPolicyElement,PortMirroringEnum.PMCP_NEWNAME.getValue()); + canvasManager.updateElementNameInCanvas(portMirroringConfigurationByPolicyElement, PortMirroringEnum.PMCP_NEWNAME.getValue()); PortMirroringVerificator.validateElementName(PortMirroringEnum.PMCP_NEWNAME.getValue()); } @@ -305,8 +309,6 @@ public class PortMirroring extends SetupCDTest { canvasManager.clickOnCanvaElement(portMirroringConfigurationByPolicyElement); getExtendTest().log(Status.INFO, String.format("Delete element %s", portMirroringConfigurationByPolicyElement.getElementType())); -// GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionRightPanel.DELETE_ITEM.getValue()); -// GeneralUIUtils.clickOnElementByTestId("OK"); canvasManager.deleteElementFromCanvas(portMirroringConfigurationByPolicyElement); PortMirroringVerificator.validateElementName(service.getName()); @@ -333,19 +335,16 @@ public class PortMirroring extends SetupCDTest { CompositionPage.searchForElement(PortMirroringEnum.PMC_ELEMENT_IN_PALLETE.getValue()); CanvasElement portMirroringConfigurationElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMC_ELEMENT_IN_PALLETE.getValue()); -// ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME = new ConnectionWizardPopUpObject("", "", -// PortMirroringEnum.PM_REQ_TYPE.getValue(), PortMirroringEnum.PMC1_SOURCE_CAP.getValue()); - ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME = new ConnectionWizardPopUpObject("", "", - PortMirroringEnum.PM_REQ_TYPE.getValue(), PortMirroringEnum.PMC_SOURCE_CAP.getValue()); + PortMirroringEnum.PM_REQ_TYPE.getValue(), PortMirroringEnum.PMC_SOURCE_CAP.getValue()); getExtendTest().log(Status.INFO, "Connect VMME to PMC again"); - canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName,portMirroringConfigurationElement, - connectionWizardPopUpObjectVMME); + canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationElement, + connectionWizardPopUpObjectVMME); getExtendTest().log(Status.INFO, "Connect VMME to PMC again"); canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationElement, - connectionWizardPopUpObjectVMME); + connectionWizardPopUpObjectVMME); getExtendTest().log(Status.INFO, "Validating 4 links between elements exist"); ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 4); @@ -361,7 +360,7 @@ public class PortMirroring extends SetupCDTest { getExtendTest().log(Status.INFO, "Connect VMME to PMCP again"); canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationByPolicyElement, - connectionWizardPopUpObjectVMME_PMCP); + connectionWizardPopUpObjectVMME_PMCP); getExtendTest().log(Status.INFO, "Connect VMME to PMCP again"); canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationByPolicyElement, @@ -424,11 +423,8 @@ public class PortMirroring extends SetupCDTest { ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); CanvasManager canvasManager = CanvasManager.getCanvasManager(); GeneralUIUtils.ultimateWait(); -// canvasManager.clickOnCanvasPosition(portMirroringConfigurationElement.getLocation().getLeft(), portMirroringConfigurationElement.getLocation().getRight()); canvasManager.clickOnCanvaElement(portMirroringConfigurationElement); getExtendTest().log(Status.INFO, String.format("Delete element %s", portMirroringConfigurationElement.getElementType())); -// GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionRightPanel.DELETE_ITEM.getValue()); -// GeneralUIUtils.clickOnElementByTestId("OK"); canvasManager.deleteElementFromCanvas(portMirroringConfigurationElement); PortMirroringVerificator.validateElementName(service.getName()); @@ -472,7 +468,7 @@ public class PortMirroring extends SetupCDTest { CanvasManager canvasManager = CanvasManager.getCanvasManager(); getExtendTest().log(Status.INFO, String.format("Change vmme source %s instance to version 2.0", serviceContainerVmme_Source.getName())); - CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "2.0",false); + CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "2.0", false); getExtendTest().log(Status.INFO, String.format("Going to certify the Service")); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); @@ -523,18 +519,14 @@ public class PortMirroring extends SetupCDTest { canvasManager.openLinkPopupReqsCapsConnection(serviceElementVmmeSource, portMirroringConfigurationByPolicyElement); getExtendTest().log(Status.INFO, "Fill link properties with data"); - GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.NETWORK_ROLE_XPATH.getValue(),PortMirroringEnum.NETWORK_ROLE_VALUE.getValue()); - GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.NFC_TYPE_XPATH.getValue(),PortMirroringEnum.NFC_TYPE_VALUE.getValue()); - GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.PPS_CAPACITY_XPATH.getValue(),PortMirroringEnum.PPS_CAPACITY_VALUE.getValue()); - GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.NF_TYPE_XPATH.getValue(),PortMirroringEnum.NF_TYPE_VALUE.getValue()); + GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.NETWORK_ROLE_XPATH.getValue(), PortMirroringEnum.NETWORK_ROLE_VALUE.getValue()); + GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.NFC_TYPE_XPATH.getValue(), PortMirroringEnum.NFC_TYPE_VALUE.getValue()); + GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.PPS_CAPACITY_XPATH.getValue(), PortMirroringEnum.PPS_CAPACITY_VALUE.getValue()); + GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.NF_TYPE_XPATH.getValue(), PortMirroringEnum.NF_TYPE_VALUE.getValue()); GeneralUIUtils.ultimateWait(); - -// if(true){ -// throw new SkipException("Open bug 373765, Can't update link property on Port Mirroring connection"); -// } canvasManager.clickSaveOnLinkPopup(); - Thread.sleep(3000); //Temp solution. Don't remove. + Thread.sleep(THREAD_SLEEP_TIME); //Temp solution. Don't remove. canvasManager.openLinkPopupReqsCapsConnection(serviceElementVmmeSource, portMirroringConfigurationByPolicyElement); PortMirroringVerificator.validateLinkProperties(); @@ -563,14 +555,14 @@ public class PortMirroring extends SetupCDTest { CanvasManager canvasManager = CanvasManager.getCanvasManager(); getExtendTest().log(Status.INFO, String.format("Changing vmme source %s instance to version 2.0", serviceContainerVmme_Source.getName())); - CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "2.0",false); + CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "2.0", false); getExtendTest().log(Status.INFO, "Validating 1 link exist after change version to the vmme service (Newer version)"); ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 2); getExtendTest().log(Status.INFO, String.format("Changing vmme source %s instance to version 1.0", serviceContainerVmme_Source.getName())); - CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "1.0",false); - + CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "1.0", false); + ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 2); } @@ -598,18 +590,17 @@ public class PortMirroring extends SetupCDTest { ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); CanvasManager canvasManager = CanvasManager.getCanvasManager(); -// canvasManager.linkElements(vmmeCanvasElement, CircleSize.SERVICE, vprobeCanvasElement, CircleSize.SERVICE); canvasManager.linkElements(vmmeCanvasElement, vprobeCanvasElement); getExtendTest().log(Status.INFO, String.format("Changing vmme source %s instance to version 2.0", serviceContainerVmme_Source.getName())); - CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "2.0",false); + CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "2.0", false); getExtendTest().log(Status.INFO, "Validating 1 link exist after change version to the vmme service (Newer version)"); ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 3); getExtendTest().log(Status.INFO, String.format("Changing vmme source %s instance to version 1.0", serviceContainerVmme_Source.getName())); - CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "1.0",false); - + CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "1.0", false); + ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 3); } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Product.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Product.java index c12a8f220a..877858bece 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Product.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Product.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,38 +38,37 @@ import org.testng.annotations.Test; /** * @author al714h - * */ public class Product extends SetupCDTest { - - @Test - public void createProductAndAddCertifiedServiceInstance() throws Exception { - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); - - ServiceUIUtils.createService(serviceMetadata, getUser()); - GeneralPageElements.clickSubmitForTestingButton(serviceMetadata.getName()); - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - TesterOperationPage.certifyComponent(serviceMetadata.getName()); - reloginWithNewRole(UserRoleEnum.PRODUCT_MANAGER1); - ProductUIUtils.createProduct(productReqDetails, getUser()); - ProductGeneralPage.getProductLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement canvasElement = CompositionPage.addElementToCanvasScreen(serviceMetadata.getName(), canvasManager); - canvasManager.clickOnCanvaElement(canvasElement); - } - - @Test - public void loginAsProductStrateger() throws Exception { - reloginWithNewRole(UserRoleEnum.PRODUCT_STRATEGIST1); - } - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + @Test + public void createProductAndAddCertifiedServiceInstance() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ProductReqDetails productReqDetails = ElementFactory.getDefaultProduct(); + + ServiceUIUtils.createService(serviceMetadata, getUser()); + GeneralPageElements.clickSubmitForTestingButton(serviceMetadata.getName()); + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + TesterOperationPage.certifyComponent(serviceMetadata.getName()); + reloginWithNewRole(UserRoleEnum.PRODUCT_MANAGER1); + ProductUIUtils.createProduct(productReqDetails, getUser()); + ProductGeneralPage.getProductLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CanvasElement canvasElement = CompositionPage.addElementToCanvasScreen(serviceMetadata.getName(), canvasManager); + canvasManager.clickOnCanvaElement(canvasElement); + } + + @Test + public void loginAsProductStrateger() throws Exception { + reloginWithNewRole(UserRoleEnum.PRODUCT_STRATEGIST1); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignment.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignment.java index 06da130b94..2b35d3b4ed 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignment.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignment.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,11 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.HomePage; +import org.openecomp.sdc.ci.tests.pages.PropertiesAssignmentPage; +import org.openecomp.sdc.ci.tests.pages.PropertyNameBuilder; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; @@ -42,57 +46,55 @@ import org.testng.annotations.Test; public class PropertiesAssignment extends SetupCDTest { - private static String filePath; - private static String csarFile = "PCRF_OS_FIXED.csar"; + private static String filePath; + private static String csarFile = "PCRF_OS_FIXED.csar"; private static String csarFile1 = "437285.csar"; - - @BeforeClass - public void beforeClass(){ - filePath = FileHandling.getFilePath(""); - } - - @BeforeMethod - public void beforeTest(){ - System.out.println("File repository is : " + filePath); - getExtendTest().log(Status.INFO, "File repository is : " + filePath); - } - - - //VF - Simple Properties Tests - @Test - public void declareAndDeleteInputVfTest() throws Exception { - - String csarTestFile = csarFile; -// String componentName = "abstract_pcm"; + + @BeforeClass + public void beforeClass() { + filePath = FileHandling.getFilePath(""); + } + + @BeforeMethod + public void beforeTest() { + System.out.println("File repository is : " + filePath); + getExtendTest().log(Status.INFO, "File repository is : " + filePath); + } + + + //VF - Simple Properties Tests + @Test + public void declareAndDeleteInputVfTest() throws Exception { + + String csarTestFile = csarFile; String componentName = "abstract_psm"; -// String propertyName = "min_instances"; String propertyName = "service_template_filter"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - resourceMetaData.setVersion("0.1"); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarTestFile, getUser()); - + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + resourceMetaData.setVersion("0.1"); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarTestFile, getUser()); - ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); - PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); - PropertiesAssignmentPage.clickOnDeclareButton(); + + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); + PropertiesAssignmentPage.clickOnDeclareButton(); GeneralUIUtils.ultimateWait(); - AssertJUnit.assertTrue(PropertiesAssignmentPage.isPropertyChecked(propertyName)); - - PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentPage.findInput(componentName, propertyName); - PropertiesAssignmentPage.clickOnDeleteInputButton(); - PropertiesAssignmentPage.clickOnDeleteInputDialogConfirmationButton(); - PropertiesAssignmentPage.clickOnPropertiesTab(); - PropertiesAssignmentPage.findProperty(propertyName); - AssertJUnit.assertFalse(PropertiesAssignmentPage.isPropertyChecked(propertyName)); - + AssertJUnit.assertTrue(PropertiesAssignmentPage.isPropertyChecked(propertyName)); + + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.findInput(componentName, propertyName); + PropertiesAssignmentPage.clickOnDeleteInputButton(); + PropertiesAssignmentPage.clickOnDeleteInputDialogConfirmationButton(); + PropertiesAssignmentPage.clickOnPropertiesTab(); + PropertiesAssignmentPage.findProperty(propertyName); + AssertJUnit.assertFalse(PropertiesAssignmentPage.isPropertyChecked(propertyName)); - } + + } - @Test + @Test public void editAndSaveSimplePropertyValueTest() throws Exception { String csarTestFile = csarFile; @@ -111,7 +113,6 @@ public class PropertiesAssignment extends SetupCDTest { //Navigate to Properties Assignment screen, edit simple properties values and save ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); -// PropertiesAssignmentPage.editPropertyValue(propertyNameString, propertyValueString); PropertiesAssignmentPage.editPropertyValue(propertyNameString, propertyValueString); PropertiesAssignmentPage.editPropertyValue(propertyNameInt, propertyValueInt); PropertiesAssignmentPage.clickOnSaveButton(); @@ -121,8 +122,8 @@ public class PropertiesAssignment extends SetupCDTest { GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyValueString); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyValueInt); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString, propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt, propertyValueInt); } @Test @@ -151,8 +152,8 @@ public class PropertiesAssignment extends SetupCDTest { ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen(); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentVerificator.validateBooleanPropertyValue(propertyNameTrue,propertyValueTrue); - PropertiesAssignmentVerificator.validateBooleanPropertyValue(propertyNameFalse,propertyValueFalse); + PropertiesAssignmentVerificator.validateBooleanPropertyValue(propertyNameTrue, propertyValueTrue); + PropertiesAssignmentVerificator.validateBooleanPropertyValue(propertyNameFalse, propertyValueFalse); } @Test @@ -181,14 +182,11 @@ public class PropertiesAssignment extends SetupCDTest { PropertiesAssignmentPage.clickOnSaveButton(); //Verify that popup property value is saved -// HomePage.navigateToHomePage(); -// GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); -// ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen(); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); PropertiesAssignmentPage.clickOnEditButton(propertyName); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propertyName),propertyValue); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), propertyValue); } @@ -222,8 +220,8 @@ public class PropertiesAssignment extends SetupCDTest { GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyOrigValueString); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyOrigValueInt); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString, propertyOrigValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt, propertyOrigValueInt); } @Test @@ -250,8 +248,8 @@ public class PropertiesAssignment extends SetupCDTest { PropertiesAssignmentPage.clickOnDialogCancelButton(); //Verify that properties values are not removed - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyValueString); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyValueInt); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString, propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt, propertyValueInt); PropertiesAssignmentPage.clickOnInputTab(); PropertiesAssignmentPage.clickOnDialogSaveButton(); @@ -261,8 +259,8 @@ public class PropertiesAssignment extends SetupCDTest { GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyValueString); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyValueInt); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString, propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt, propertyValueInt); } @@ -292,8 +290,8 @@ public class PropertiesAssignment extends SetupCDTest { PropertiesAssignmentPage.clickOnDialogCancelButton(); ///Verify that properties values are not removed - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyValueString); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyValueInt); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString, propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt, propertyValueInt); PropertiesAssignmentPage.clickOnInputTab(); PropertiesAssignmentPage.clickOnDialogDiscardButton(); @@ -303,8 +301,8 @@ public class PropertiesAssignment extends SetupCDTest { GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyOrigValueString); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyOrigValueInt); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString, propertyOrigValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt, propertyOrigValueInt); } @@ -347,9 +345,9 @@ public class PropertiesAssignment extends SetupCDTest { ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyValueString); - PropertiesAssignmentVerificator.validatePropertyValue(propertyNameFloat,propertyValueFloat); - PropertiesAssignmentVerificator.validateBooleanPropertyValue(propertyNameBoolean,propertyValueBoolean); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString, propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameFloat, propertyValueFloat); + PropertiesAssignmentVerificator.validateBooleanPropertyValue(propertyNameBoolean, propertyValueBoolean); } //VF - List and Map Properties Tests @@ -374,11 +372,11 @@ public class PropertiesAssignment extends SetupCDTest { ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); PropertiesAssignmentPage.clickOnAddValueToList(propertyName); - PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedField(propertyName,1), propertyListValueOne); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedField(propertyName, 1), propertyListValueOne); PropertiesAssignmentPage.clickOnAddValueToList(propertyName); - PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedField(propertyName,2), propertyListValueTwo); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedField(propertyName, 2), propertyListValueTwo); PropertiesAssignmentPage.clickOnSaveButton(); - PropertiesAssignmentPage.clickODeleteValueFromList(propertyName,1); + PropertiesAssignmentPage.clickODeleteValueFromList(propertyName, 1); PropertiesAssignmentPage.clickOnSaveButton(); //Verify that properties values are saved @@ -387,8 +385,8 @@ public class PropertiesAssignment extends SetupCDTest { GeneralPageElements.clickCheckoutButton(); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIndexedField(propertyName,0),propertyListValueZero); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIndexedField(propertyName,1),propertyListValueTwo); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIndexedField(propertyName, 0), propertyListValueZero); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIndexedField(propertyName, 1), propertyListValueTwo); //Declare property as input, delete input @@ -408,7 +406,7 @@ public class PropertiesAssignment extends SetupCDTest { @Test public void editAndSaveListOfComplexPropertyValueTest() throws Exception { - //External Defect 437285 - PLEASE DON'T DELETE THE TEST!!!! + //External Defect 437285 - PLEASE DON'T DELETE THE TEST!!!! String csarTestFile = csarFile1; String componentName = "abstract_cdi"; @@ -425,10 +423,10 @@ public class PropertiesAssignment extends SetupCDTest { ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); PropertiesAssignmentPage.clickOnAddValueToList(propertyName); - PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIComplexListField(propertyName,nestedPropertyName,1),propertyListValue); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIComplexListField(propertyName, nestedPropertyName, 1), propertyListValue); PropertiesAssignmentPage.clickOnSaveButton(); - PropertiesAssignmentPage.clickOnExpandButton(propertyName,1); - PropertiesAssignmentPage.deletePropertyValue(PropertyNameBuilder.buildIComplexListField(propertyName,nestedPropertyName,1)); + PropertiesAssignmentPage.clickOnExpandButton(propertyName, 1); + PropertiesAssignmentPage.deletePropertyValue(PropertyNameBuilder.buildIComplexListField(propertyName, nestedPropertyName, 1)); PropertiesAssignmentPage.clickOnSaveButton(); //Verify that properties values are saved @@ -436,8 +434,8 @@ public class PropertiesAssignment extends SetupCDTest { GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentPage.clickOnExpandButton(propertyName,1); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIComplexListField(propertyName,nestedPropertyName,1),""); + PropertiesAssignmentPage.clickOnExpandButton(propertyName, 1); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIComplexListField(propertyName, nestedPropertyName, 1), ""); } @@ -463,31 +461,31 @@ public class PropertiesAssignment extends SetupCDTest { ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); PropertiesAssignmentPage.clickOnAddValueToList(propertyName); - PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedField(propertyName,0),propertyMapValueOne); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedField(propertyName, 0), propertyMapValueOne); //Verify that Save and Declare buttons are disabled when leaving Key value empty AssertJUnit.assertTrue(PropertiesAssignmentPage.isButtonDisabled(DataTestIdEnum.PropertiesAssignmentScreen.SAVE_BUTTON.getValue())); AssertJUnit.assertTrue(PropertiesAssignmentPage.isButtonDisabled(DataTestIdEnum.PropertiesAssignmentScreen.DECLARE_BUTTON.getValue())); - PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedKeyField(propertyName,0),propertyMapKeyOne); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedKeyField(propertyName, 0), propertyMapKeyOne); PropertiesAssignmentPage.clickOnSaveButton(); PropertiesAssignmentPage.clickOnAddValueToList(propertyName); - PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedKeyField(propertyName,1),propertyMapKeyTwo); - PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedField(propertyName,1),propertyMapValueTwo); - PropertiesAssignmentPage.clickODeleteValueFromList(propertyName,0); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedKeyField(propertyName, 1), propertyMapKeyTwo); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedField(propertyName, 1), propertyMapValueTwo); + PropertiesAssignmentPage.clickODeleteValueFromList(propertyName, 0); PropertiesAssignmentPage.clickOnSaveButton(); -// //Verify that properties values are saved + //Verify that properties values are saved ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); GeneralPageElements.clickCheckoutButton(); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIndexedKeyField(propertyName,0),propertyMapKeyTwo); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIndexedField(propertyName,0),propertyMapValueTwo); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIndexedKeyField(propertyName, 0), propertyMapKeyTwo); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIndexedField(propertyName, 0), propertyMapValueTwo); -// //Declare property as input, delete input + //Declare property as input, delete input PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); PropertiesAssignmentPage.clickOnDeclareButton(); AssertJUnit.assertTrue(PropertiesAssignmentPage.isPropertyChecked(propertyName)); @@ -524,9 +522,9 @@ public class PropertiesAssignment extends SetupCDTest { //Navigate to Properties Assignment screen, edit simple properties values and save ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIComplexField(propertyName,propertyNameString), propertyValueString); - PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIComplexField(propertyName,propertyNameInt), propertyValueInt); - PropertiesAssignmentPage.selectBooleanPropertyValue(PropertyNameBuilder.buildIComplexField(propertyName,propertyNameBoolean), propertyValueBoolean); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIComplexField(propertyName, propertyNameString), propertyValueString); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIComplexField(propertyName, propertyNameInt), propertyValueInt); + PropertiesAssignmentPage.selectBooleanPropertyValue(PropertyNameBuilder.buildIComplexField(propertyName, propertyNameBoolean), propertyValueBoolean); PropertiesAssignmentPage.clickOnSaveButton(); //Verify that properties values are saved @@ -535,49 +533,49 @@ public class PropertiesAssignment extends SetupCDTest { GeneralPageElements.clickCheckoutButton(); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIComplexField(propertyName,propertyNameString),propertyValueString); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIComplexField(propertyName,propertyNameInt),propertyValueInt); - PropertiesAssignmentVerificator.validateBooleanPropertyValue(PropertyNameBuilder.buildIComplexField(propertyName,propertyNameBoolean),propertyValueBoolean); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIComplexField(propertyName, propertyNameString), propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIComplexField(propertyName, propertyNameInt), propertyValueInt); + PropertiesAssignmentVerificator.validateBooleanPropertyValue(PropertyNameBuilder.buildIComplexField(propertyName, propertyNameBoolean), propertyValueBoolean); //Select complex property and declare as input PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); PropertiesAssignmentPage.clickOnDeclareButton(); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propertyName),PropertyNameBuilder.buildVfDeclaredPropValue(componentName, propertyName)); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), PropertyNameBuilder.buildVfDeclaredPropValue(componentName, propertyName)); } - - - //VF - Filter Tests + + + //VF - Filter Tests @Test - public void filterAllVfTest() throws Exception { - - String csarTestFile = csarFile; - String propertyName = "name"; - String propertyLocation = DataTestIdEnum.PropertiesAssignmentScreen.PROPERTY_NAME_COLUMN.getValue(); - int propertiesCountFilter = 22; - int propertiesCountWithoutFilter = 0; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - resourceMetaData.setVersion("0.1"); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarTestFile, getUser()); - - - ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); - //Count current properties number before filter is applied - propertiesCountWithoutFilter = GeneralUIUtils.getWebElementsListByContainsClassName(propertyLocation).size(); - PropertiesAssignmentPage.clickOnFilterButton(); - PropertiesAssignmentPage.clickOnFilterAllCheckbox(); - PropertiesAssignmentPage.findFilterBoxAndClick(propertyName); - PropertiesAssignmentPage.clickOnFilterApplyButton(); - PropertiesAssignmentVerificator.validateFilteredPropertiesCount(propertiesCountFilter, propertyLocation); - - PropertiesAssignmentPage.clickOnFilterClearAllButton(); - PropertiesAssignmentVerificator.validateFilteredPropertiesCount(propertiesCountWithoutFilter, propertyLocation); - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + public void filterAllVfTest() throws Exception { + final int propertiesCountFilter = 22; + int propertiesCountWithoutFilter; + + String csarTestFile = csarFile; + String propertyName = "name"; + String propertyLocation = DataTestIdEnum.PropertiesAssignmentScreen.PROPERTY_NAME_COLUMN.getValue(); + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + resourceMetaData.setVersion("0.1"); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarTestFile, getUser()); + + + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + //Count current properties number before filter is applied + propertiesCountWithoutFilter = GeneralUIUtils.getWebElementsListByContainsClassName(propertyLocation).size(); + PropertiesAssignmentPage.clickOnFilterButton(); + PropertiesAssignmentPage.clickOnFilterAllCheckbox(); + PropertiesAssignmentPage.findFilterBoxAndClick(propertyName); + PropertiesAssignmentPage.clickOnFilterApplyButton(); + PropertiesAssignmentVerificator.validateFilteredPropertiesCount(propertiesCountFilter, propertyLocation); + + PropertiesAssignmentPage.clickOnFilterClearAllButton(); + PropertiesAssignmentVerificator.validateFilteredPropertiesCount(propertiesCountWithoutFilter, propertyLocation); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignmentUpdateFlow.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignmentUpdateFlow.java index 7362ebb7f7..8610924daa 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignmentUpdateFlow.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignmentUpdateFlow.java @@ -27,19 +27,38 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.HeatParamNameBuilder; +import org.openecomp.sdc.ci.tests.pages.HomePage; +import org.openecomp.sdc.ci.tests.pages.PropertiesAssignmentPage; +import org.openecomp.sdc.ci.tests.pages.PropertiesPage; +import org.openecomp.sdc.ci.tests.pages.PropertyNameBuilder; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; -import org.openecomp.sdc.ci.tests.utils.general.*; +import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; +import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; import org.openecomp.sdc.ci.tests.verificator.PropertiesAssignmentVerificator; import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.testng.annotations.BeforeClass; @@ -63,19 +82,18 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { @BeforeClass - public void beforeClass(){ + public void beforeClass() { filePath = FileHandling.getFilePath(""); } @BeforeMethod - public void beforeTest(){ + public void beforeTest() { System.out.println("File repository is : " + filePath); -// SetupCDTest.getExtendTest().log(Status.INFO, "File repository is : " + filePath); } @DataProvider(name = "assetFilesInputs", parallel = false) public Object[][] createDataInputs() { - return new Object[][] { + return new Object[][]{ {"editInputValueTopChange.csar", ""}, {"editInputValueNoTopChange.csar", "Updated-SRE-Mgt"}}; } @@ -83,7 +101,8 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { /** * Topoplogy change in updated file - designer changes in inputs values are not kept after update * No topoplogy change in updated file - designer changes in inputs values are kept after update - * @param updFileName - csar for update + * + * @param updFileName - csar for update * @param validationValue - expected property value after update * @throws Exception */ @@ -128,17 +147,17 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName),validationValue); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName), validationValue); } @DataProvider(name = "assetFilesProperties", parallel = false) public Object[][] createDataProp() { - return new Object[][] { + return new Object[][]{ {"editedPropValueToEmpty.csar", "value-prop-vm_type_tag", "updated_by_designer"}, - {"newPropValueToEmpty.csar", "value-prop-high_availablity", "updated_by_designer"} , - {"editedPropValueToNew.csar", "value-prop-vm_type_tag", "updated_by_file"} , + {"newPropValueToEmpty.csar", "value-prop-high_availablity", "updated_by_designer"}, + {"editedPropValueToNew.csar", "value-prop-vm_type_tag", "updated_by_file"}, {"editedPropValueToEmptyTopChange.csar", "value-prop-vm_type_tag", ""}, {"newPropValueToEmptyTopChange.csar", "value-prop-high_availablity", ""}, {"editedPropValueToNewTopChange.csar", "value-prop-vm_type_tag", "updated_by_file"}}; @@ -161,12 +180,12 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { * prop1=null prop1=value1 prop1=null prop1=null * prop1=value1 prop1=value2 prop1=value3 prop1=value3 * - * @param updFileName - csar for update - * @param propertyName + * @param updFileName - csar for update + * @param propertyName * @param validationValue - expected property value after update * @throws Exception */ - @Test (dataProvider = "assetFilesProperties") + @Test(dataProvider = "assetFilesProperties") public void updatePropertyDefaultValueTest(String updFileName, String propertyName, String validationValue) throws Exception { setLog(updFileName); String origTestFile = origFile; @@ -203,7 +222,7 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { //Validate Input value ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentVerificator.validatePropertyValue(propertyName,validationValue); + PropertiesAssignmentVerificator.validatePropertyValue(propertyName, validationValue); } @@ -220,7 +239,7 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -241,8 +260,7 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -254,8 +272,10 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { PropertiesAssignmentPage.findSearchBoxAndClick(inputName); PropertiesAssignmentPage.clickOnDeclareButton(); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName,propertyName), propertyValue); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), + propertyValue + ); //Checkout VF, update input value and check in - v0.2 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); @@ -263,8 +283,10 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { GeneralUIUtils.findComponentAndClick(resourceReqDetails.getName()); ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildDeclaredInputField(componentName, propertyName), - propertyValueUpd); + PropertiesAssignmentPage.editPropertyValue( + PropertyNameBuilder.buildDeclaredInputField(componentName, propertyName), + propertyValueUpd + ); // PropertiesAssignmentPage.deletePropertyValue(PropertyNameBuilder.buildDeclaredInputField(componentName, propertyName)); PropertiesAssignmentPage.clickOnSaveButton(); ResourceGeneralPage.clickCheckinButton(resourceReqDetails.getName()); @@ -277,12 +299,15 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); CompositionPage.moveToPropertiesScreen(); PropertiesAssignmentPage.isPropertyChecked(inputName); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), - PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName )); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), + PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName) + ); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValueUpd); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), + propertyValueUpd + ); } @Test @@ -296,7 +321,7 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -305,8 +330,10 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, + UserRoleEnum.DESIGNER, true + ).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -319,9 +346,10 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { PropertiesAssignmentPage.clickOnSaveButton(); PropertiesAssignmentPage.clickOnDeclareButton(); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validateBooleanPropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), - propertyValueBoolean); + PropertiesAssignmentVerificator.validateBooleanPropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), + propertyValueBoolean + ); // //Checkout VF and check in - v0.2 AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); @@ -339,13 +367,14 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { PropertyNameBuilder.buildServiceDeclaredPropValueServiceLevel(componentInstance, propertyName)); PropertiesAssignmentPage.isPropertyChecked(propertyName); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validateBooleanPropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), - StringUtils.isEmpty(defaultPropertyValueBoolean) ? propertyValueBoolean : defaultPropertyValueBoolean); + PropertiesAssignmentVerificator.validateBooleanPropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), + StringUtils.isEmpty(defaultPropertyValueBoolean) ? propertyValueBoolean : defaultPropertyValueBoolean + ); } @Test - public void deletePropertyChangeVfiVersionTest() throws Throwable{ + public void deletePropertyChangeVfiVersionTest() throws Throwable { String vnfFile = "vIRC_FE_BE.zip"; String componentName = "abstract_virc_fe_be_1"; String propertyNameProp1 = "max_instances"; //empty property @@ -365,7 +394,7 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -390,8 +419,10 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, UserRoleEnum.DESIGNER, + true + ).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -573,7 +604,7 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -582,8 +613,10 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, + UserRoleEnum.DESIGNER, true + ).left().value(); CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); GeneralUIUtils.findComponentAndClick(service.getName()); ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); @@ -600,7 +633,7 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { //Checkout and check in VF - v0.2 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); //Change VFi version on Service canvas - v0.2 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); @@ -618,14 +651,14 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { DeploymentArtifactPage.clickCloseEnvParameters(); //Check out VF, delete heatparam value, check in VF - v0.3 - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); GeneralUIUtils.findComponentAndClick(resource.getName()); ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); DeploymentArtifactPage.clickEditEnvArtifact(artifactName); DeploymentArtifactPage.clickOnDeleteHeatParamValue(heatParamName); DeploymentArtifactPage.clickSaveEnvParameters(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); //Change VFi version on Service canvas - v0.3 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); @@ -644,7 +677,6 @@ public class PropertiesAssignmentUpdateFlow extends SetupCDTest { } - @Override protected UserRoleEnum getRole() { return UserRoleEnum.DESIGNER; diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignmentUpdateFlow_New.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignmentUpdateFlow_New.java index a748281c4b..17a936f0ee 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignmentUpdateFlow_New.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignmentUpdateFlow_New.java @@ -20,29 +20,44 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -//import com.sun.xml.internal.bind.v2.TODO; import com.aventstack.extentreports.Status; import fj.data.Either; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.HeatParamNameBuilder; +import org.openecomp.sdc.ci.tests.pages.HomePage; +import org.openecomp.sdc.ci.tests.pages.PropertiesAssignmentPage; +import org.openecomp.sdc.ci.tests.pages.PropertiesPage; +import org.openecomp.sdc.ci.tests.pages.PropertyNameBuilder; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; -import org.openecomp.sdc.ci.tests.utils.general.*; +import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; +import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; import org.openecomp.sdc.ci.tests.verificator.PropertiesAssignmentVerificator; import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.testng.annotations.BeforeClass; @@ -52,7 +67,9 @@ import org.testng.annotations.Test; import java.util.List; +import static org.testng.Assert.assertTrue; +//import com.sun.xml.internal.bind.v2.TODO; public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { @@ -60,16 +77,16 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { private static String filePath; private static String origFile = "virc_fe_be.csar"; private static String origFile1 = "virc.csar"; - protected User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + private User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); @BeforeClass - public void beforeClass(){ + public void beforeClass() { filePath = FileHandling.getFilePath(""); } @BeforeMethod - public void beforeTest(){ + public void beforeTest() { System.out.println("File repository is : " + filePath); // SetupCDTest.getExtendTest().log(Status.INFO, "File repository is : " + filePath); } @@ -77,7 +94,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { //Update VSP tests - validating VF properties/inputs values after updating VF with a new VSP @DataProvider(name = "assetFilesInputs", parallel = false) public Object[][] createDataInputs() { - return new Object[][] { + return new Object[][]{ {"editInputValueTopChange.csar", ""}, {"editInputValueNoTopChange.csar", "Updated-SRE-Mgt"}}; } @@ -85,7 +102,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { /** * Topoplogy change in updated file - designer changes in inputs values are not kept after update * No topoplogy change in updated file - designer changes in inputs values are kept after update - * @param updFileName - csar for update + * + * @param updFileName - csar for update * @param validationValue - expected property value after update * @throws Exception */ @@ -130,14 +148,14 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName),validationValue); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName), validationValue); } @DataProvider(name = "assetFilesProperties", parallel = false) public Object[][] createDataProp() { - return new Object[][] { + return new Object[][]{ {"editedPropValueToEmpty.csar", "value-prop-vm_type_tag", "updated_by_designer", "updated_by_designer", false}, //no topology change - simple {"newPropValueToEmpty.csar", "value-prop-high_availablity", "updated_by_designer", "updated_by_designer", false}, {"editedPropValueToNew.csar", "value-prop-vm_type_tag", "updated_by_designer", "updated_by_file", false}, @@ -175,12 +193,12 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { * prop1=value1 prop1=value2 prop1=value1 prop1=value1 * prop1=value1 prop1=null prop1=value1 prop1=value1 * - * @param updFileName - csar for update - * @param propertyName + * @param updFileName - csar for update + * @param propertyName * @param validationValue - expected property value after update * @throws Exception */ - @Test (dataProvider = "assetFilesProperties") + @Test(dataProvider = "assetFilesProperties") public void updatePropertyDefaultValueTest(String updFileName, String propertyName, String updValue, String validationValue, boolean userDeletesValue) throws Exception { setLog(updFileName); String origTestFile = origFile; @@ -196,10 +214,9 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { //Edit or delete Input value ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - if(userDeletesValue) { + if (userDeletesValue) { PropertiesAssignmentPage.deletePropertyValue(propertyName); - } - else { + } else { PropertiesAssignmentPage.editPropertyValue(propertyName, updValue); } PropertiesAssignmentPage.clickOnSaveButton(); @@ -220,21 +237,20 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { //Validate Input value ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnComponentInComposition(componentName); - PropertiesAssignmentVerificator.validatePropertyValue(propertyName,validationValue); + PropertiesAssignmentVerificator.validatePropertyValue(propertyName, validationValue); } - //ChangeVersion tests - validating service property values after changing VFi version on service @DataProvider(name = "assetFilesServiceProperties", parallel = false) public Object[][] createDataServiceProp() { - return new Object[][] { - {"max_instances", "", "111", "111"} , //edit service prop value, update with original empty value, keep user value after update + return new Object[][]{ + {"max_instances", "", "111", "111"}, //edit service prop value, update with original empty value, keep user value after update {"nfc_naming_code", "virc_fe_be", "updated_by_designer", "virc_fe_be"}}; //edit service prop value, update with original value, set original value after update } - @Test (dataProvider = "assetFilesServiceProperties") - public void changeVfiVersionServicePropertyEditValueTest(String propertyName, String origValue, String updValue, String expectedValue) throws Throwable{ + @Test(dataProvider = "assetFilesServiceProperties") + public void changeVfiVersionServicePropertyEditValueTest(String propertyName, String origValue, String updValue, String expectedValue) throws Throwable { setLog(propertyName); String vnfFile = "vIRC_FE_BE.zip"; String componentName = "abstract_virc_fe_be_1"; @@ -244,7 +260,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -257,8 +273,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -290,7 +306,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -303,8 +319,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -334,7 +350,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -343,8 +359,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -367,7 +383,6 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { } - //ChangeVersion tests - validating service input values after changing VFi version on service @Test public void changeVfiServiceInputEditValueTest() throws Throwable { @@ -382,7 +397,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -398,8 +413,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -407,8 +422,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { viewServiceProperties(serviceReqDetails); PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), propertyValue); findAndDeclareServiceProperty(inputName); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName,propertyName), propertyValue); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValue); //Checkout VF, update input value and check in - v0.2 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); @@ -427,12 +442,12 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); CompositionPage.moveToPropertiesScreen(); PropertiesAssignmentPage.isPropertyChecked(inputName); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), - PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName )); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), + PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName)); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValueUpd); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValueUpd); } @Test @@ -447,7 +462,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -456,8 +471,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -470,8 +485,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { PropertiesAssignmentPage.clickOnSaveButton(); PropertiesAssignmentPage.clickOnDeclareButton(); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validateBooleanPropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), + PropertiesAssignmentVerificator.validateBooleanPropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), updValue); // //Checkout VF and check in - v0.2 @@ -488,8 +503,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { PropertyNameBuilder.buildServiceDeclaredPropValueServiceLevel(componentInstance, propertyName)); PropertiesAssignmentPage.isPropertyChecked(propertyName); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validateBooleanPropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), + PropertiesAssignmentVerificator.validateBooleanPropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), origValue); } @@ -505,7 +520,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -521,8 +536,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -530,8 +545,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { viewServiceProperties(serviceReqDetails); PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), propertyValue); findAndDeclareServiceProperty(inputName); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName,propertyName), propertyValue); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValue); //Checkout VF, update input value and check in - v0.2 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); @@ -549,12 +564,12 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); CompositionPage.moveToPropertiesScreen(); PropertiesAssignmentPage.isPropertyChecked(inputName); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), - PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName )); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), + PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName)); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValue); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValue); } @Test @@ -569,7 +584,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -582,8 +597,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -591,8 +606,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { viewServiceProperties(serviceReqDetails); PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), ""); findAndDeclareServiceProperty(inputName); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName,propertyName), ""); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), ""); //Checkout VF, update input value and check in - v0.2 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); @@ -610,12 +625,12 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); CompositionPage.moveToPropertiesScreen(); PropertiesAssignmentPage.isPropertyChecked(inputName); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), - PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName )); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), + PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName)); PropertiesAssignmentPage.clickOnInputTab(); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValue); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValue); } @Test @@ -630,7 +645,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -646,8 +661,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); Either addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); @@ -655,8 +670,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { viewServiceProperties(serviceReqDetails); PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), propertyValue); findAndDeclareServiceProperty(inputName); - PropertiesAssignmentVerificator.validatePropertyValue - (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName,propertyName), propertyValue); + PropertiesAssignmentVerificator.validatePropertyValue( + PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValue); //Checkout VF, delete input and check in - v0.2 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); @@ -680,7 +695,6 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { } - //ChangeVersion test - validating VF input values after changing VFCi version on VF @Test public void updateVFCPropertyChangeVFCiVersionTest() throws Throwable { @@ -783,7 +797,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { String filePath = org.openecomp.sdc.ci.tests.utils.general.FileHandling.getVnfRepositoryPath(); getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -792,8 +806,8 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName()); - org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService - (serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService( + serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); GeneralUIUtils.findComponentAndClick(service.getName()); ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); @@ -810,7 +824,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { //Checkout and check in VF - v0.2 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); //Change VFi version on Service canvas - v0.2 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); @@ -828,14 +842,14 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { DeploymentArtifactPage.clickCloseEnvParameters(); //Check out VF, delete heatparam value, check in VF - v0.3 - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); GeneralUIUtils.findComponentAndClick(resource.getName()); ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); DeploymentArtifactPage.clickEditEnvArtifact(artifactName); DeploymentArtifactPage.clickOnDeleteHeatParamValue(heatParamName); DeploymentArtifactPage.clickSaveEnvParameters(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); //Change VFi version on Service canvas - v0.3 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); @@ -895,6 +909,7 @@ public class PropertiesAssignmentUpdateFlow_New extends SetupCDTest { ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); PropertiesAssignmentPage.clickOnInputTab(); } + @Override protected UserRoleEnum getRole() { return UserRoleEnum.DESIGNER; diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java index a44ffe092a..831e81131c 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Service.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,13 +28,37 @@ import org.openecomp.sdc.be.model.GroupDefinition; 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.*; +import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.CompositionScreenEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ServiceMetadataEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.*; +import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.HomePage; +import org.openecomp.sdc.ci.tests.pages.InputsPage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.TesterOperationPage; +import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; @@ -49,7 +73,7 @@ import org.testng.TestException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.awt.*; +import java.awt.AWTException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -58,692 +82,687 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.testng.AssertJUnit.assertTrue; public class Service extends SetupCDTest { - - private static final String DESCRIPTION = "kuku"; - private static final String ARTIFACT_LABEL = "artifact3"; - private static final String ARTIFACT_LABEL_UPDATE = "artifactUpdate"; - private static final String GET_ARTIFACT_LIST_BY_CLASS_NAME = "i-sdc-designer-sidebar-section-content-item-artifact"; - private static final String HEAT_FILE_YAML_NAME = "Heat-File.yaml"; - private static final String HEAT_FILE_YAML_UPDATE_NAME = "Heat-File-Update.yaml"; - private String filePath; - private static CanvasElement computeElement; - - public static CanvasElement getComputeElement(){ - return computeElement; - } - - @BeforeMethod - public void beforeTest(){ - filePath = FileHandling.getFilePath(""); - } - - - @Test - public void createService() throws Exception { - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - } - - @Test - public void validDefaultContactAndTagAfterCreateService() throws Exception{ - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createServiceWithDefaultTagAndUserId(serviceMetadata, getUser()); - - assertTrue("wrong userId", getUser().getUserId().equals(ResourceGeneralPage.getContactIdText())); - - List actualTags = Arrays.asList(ServiceGeneralPage.getTags()); - assertTrue("wrong tags", (actualTags.size() == 1) && actualTags.get(0).equals(serviceMetadata.getName())); - } - - @Test - public void updateService() throws Exception { - // Create Service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - + + private static final String DESCRIPTION = "kuku"; + private static final String ARTIFACT_LABEL = "artifact3"; + private static final String ARTIFACT_LABEL_UPDATE = "artifactUpdate"; + private static final String GET_ARTIFACT_LIST_BY_CLASS_NAME = "i-sdc-designer-sidebar-section-content-item-artifact"; + private static final String HEAT_FILE_YAML_NAME = "Heat-File.yaml"; + private static final String HEAT_FILE_YAML_UPDATE_NAME = "Heat-File-Update.yaml"; + private String filePath; + private static CanvasElement computeElement; + + public static CanvasElement getComputeElement() { + return computeElement; + } + + @BeforeMethod + public void beforeTest() { + filePath = FileHandling.getFilePath(""); + } + + + @Test + public void createService() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + } + + @Test + public void validDefaultContactAndTagAfterCreateService() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createServiceWithDefaultTagAndUserId(serviceMetadata, getUser()); + + assertTrue("wrong userId", getUser().getUserId().equals(ResourceGeneralPage.getContactIdText())); + + List actualTags = Arrays.asList(ServiceGeneralPage.getTags()); + assertTrue("wrong tags", (actualTags.size() == 1) && actualTags.get(0).equals(serviceMetadata.getName())); + } + + @Test + public void updateService() throws Exception { + // Create Service + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + // Update Service - ServiceGeneralPage.deleteOldTags(serviceMetadata); - serviceMetadata.setName(ElementFactory.getServicePrefix() + "UpdatedName" + serviceMetadata.getName()); - serviceMetadata.setDescription("updatedDescriptionSanity"); - serviceMetadata.setProjectCode("654321"); - serviceMetadata.setContactId("cs6543"); - serviceMetadata.getTags().addAll(Arrays.asList("updatedTag", "oneMoreUpdatedTag", "lastOne UpdatedTag")); - ServiceUIUtils.setServiceCategory(serviceMetadata, ServiceCategoriesEnum.VOIP); - ServiceUIUtils.fillServiceGeneralPage(serviceMetadata, getUser()); - GeneralPageElements.clickCreateButton(); - - ServiceVerificator.verifyServiceUpdatedInUI(serviceMetadata); - } - - @Test - public void deleteService() throws Exception { - - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - // Delete service - //GeneralUIUtils.HighlightMyElement(GeneralUIUtils.getWebButton("delete_version")); - GeneralPageElements.clickTrashButtonAndConfirm(); - - // Verification - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - CatalogUIUtilitis.catalogSearchBox(serviceMetadata.getName()); - ServiceVerificator.verifyServiceDeletedInUI(serviceMetadata); - } - - @Test - public void checkoutServiceTest() throws Exception{ - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - + ServiceGeneralPage.deleteOldTags(serviceMetadata); + serviceMetadata.setName(ElementFactory.getServicePrefix() + "UpdatedName" + serviceMetadata.getName()); + serviceMetadata.setDescription("updatedDescriptionSanity"); + serviceMetadata.setProjectCode("654321"); + serviceMetadata.setContactId("cs6543"); + serviceMetadata.getTags().addAll(Arrays.asList("updatedTag", "oneMoreUpdatedTag", "lastOne UpdatedTag")); + ServiceUIUtils.setServiceCategory(serviceMetadata, ServiceCategoriesEnum.VOIP); + ServiceUIUtils.fillServiceGeneralPage(serviceMetadata, getUser()); + GeneralPageElements.clickCreateButton(); + + ServiceVerificator.verifyServiceUpdatedInUI(serviceMetadata); + } + + @Test + public void deleteService() throws Exception { + + // create service + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + // Delete service + //GeneralUIUtils.HighlightMyElement(GeneralUIUtils.getWebButton("delete_version")); + GeneralPageElements.clickTrashButtonAndConfirm(); + + // Verification + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CatalogUIUtilitis.catalogSearchBox(serviceMetadata.getName()); + ServiceVerificator.verifyServiceDeletedInUI(serviceMetadata); + } + + @Test + public void checkoutServiceTest() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,"OTHER"); - CompositionPage.showDeploymentArtifactTab(); - CompositionPage.clickAddArtifactButton(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); - - ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - GeneralPageElements.clickCheckoutButton(); - - serviceMetadata.setVersion("0.2"); - ServiceVerificator.verifyServiceLifecycle(serviceMetadata, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - ServiceVerificator.verifyVersionUI(serviceMetadata.getVersion()); - - ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - TesterOperationPage.certifyComponent(serviceMetadata.getName()); - - reloginWithNewRole(UserRoleEnum.DESIGNER); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - ResourceGeneralPage.clickCheckoutButton(); - - serviceMetadata.setVersion("1.1"); - serviceMetadata.setUniqueId(null); - ServiceVerificator.verifyServiceLifecycle(serviceMetadata, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - ServiceVerificator.verifyVersionUI(serviceMetadata.getVersion()); - } - - @Test - public void submitServiceForTestingWithNonCertifiedAsset() throws Exception{ - - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.createVF(atomicResourceMetaData, getUser()); - //TODO Andrey changed to click on ceckIn button - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - - try{ - CompositionPage.clickSubmitForTestingButton(serviceMetadata.getName()); - assert(false); - } - catch(Exception e){ - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); - assertTrue(errorMessage.contains(checkUIResponseOnError)); - } - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); - } - - } - - @Test - public void createLinkService() throws Exception{ - String fileName2 = "vSeGW.csar"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); - ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); - - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(resourceMetaData.getName()); - CanvasElement firstElement = canvasManager.createElementOnCanvas(resourceMetaData.getName()); - CanvasElement secondElement = canvasManager.createElementOnCanvas(resourceMetaData.getName()); - canvasManager.linkElements(firstElement, secondElement); - } - - @Test - public void addDeploymentArtifactInCompositionScreenTest() throws Exception{ - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,"OTHER"); - CompositionPage.showDeploymentArtifactTab(); - CompositionPage.clickAddArtifactButton(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); - - List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); - AssertJUnit.assertEquals(1, actualArtifactList.size()); - - for(WebElement actualArtifactFileName : CompositionPage.getAllAddedArtifacts()){ - assertTrue(HEAT_FILE_YAML_NAME.equals(actualArtifactFileName.getText())); - } - - } - - @Test - public void addInformationArtifactInCompositionScreenTest() throws Exception{ - String descriptionText = DESCRIPTION; - List artifactFileNames = new ArrayList<>(); - - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - ArtifactInfo artifactInfo = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, descriptionText, ARTIFACT_LABEL,"OTHER"); - CompositionPage.showInformationArtifactTab(); - List beforeArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); - CompositionPage.clickAddArtifactButton(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(artifactInfo, CompositionPage.artifactPopup()); - - List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); - assertThat(actualArtifactList).as("Check number of artifacts").hasSize(beforeArtifactList.size() + 1); + + ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, "OTHER"); + CompositionPage.showDeploymentArtifactTab(); + CompositionPage.clickAddArtifactButton(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); + + ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + GeneralPageElements.clickCheckoutButton(); + + serviceMetadata.setVersion("0.2"); + ServiceVerificator.verifyServiceLifecycle(serviceMetadata, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + ServiceVerificator.verifyVersionUI(serviceMetadata.getVersion()); + + ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + TesterOperationPage.certifyComponent(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.DESIGNER); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + ResourceGeneralPage.clickCheckoutButton(); + + serviceMetadata.setVersion("1.1"); + serviceMetadata.setUniqueId(null); + ServiceVerificator.verifyServiceLifecycle(serviceMetadata, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + ServiceVerificator.verifyVersionUI(serviceMetadata.getVersion()); + } + + @Test + public void submitServiceForTestingWithNonCertifiedAsset() throws Exception { + + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.createVF(atomicResourceMetaData, getUser()); + //TODO Andrey changed to click on ceckIn button + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + + try { + CompositionPage.clickSubmitForTestingButton(serviceMetadata.getName()); + assert (false); + } catch (Exception e) { + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); + assertTrue(errorMessage.contains(checkUIResponseOnError)); + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); + } + + } + + @Test + public void createLinkService() throws Exception { + String fileName2 = "vSeGW.csar"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); + ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(resourceMetaData.getName()); + CanvasElement firstElement = canvasManager.createElementOnCanvas(resourceMetaData.getName()); + CanvasElement secondElement = canvasManager.createElementOnCanvas(resourceMetaData.getName()); + canvasManager.linkElements(firstElement, secondElement); + } + + @Test + public void addDeploymentArtifactInCompositionScreenTest() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, "OTHER"); + CompositionPage.showDeploymentArtifactTab(); + CompositionPage.clickAddArtifactButton(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); + + List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); + AssertJUnit.assertEquals(1, actualArtifactList.size()); + + for (WebElement actualArtifactFileName : CompositionPage.getAllAddedArtifacts()) { + assertTrue(HEAT_FILE_YAML_NAME.equals(actualArtifactFileName.getText())); + } + + } + + @Test + public void addInformationArtifactInCompositionScreenTest() throws Exception { + String descriptionText = DESCRIPTION; + List artifactFileNames = new ArrayList<>(); + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + ArtifactInfo artifactInfo = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, descriptionText, ARTIFACT_LABEL, "OTHER"); + CompositionPage.showInformationArtifactTab(); + List beforeArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); + CompositionPage.clickAddArtifactButton(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(artifactInfo, CompositionPage.artifactPopup()); + + List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); + assertThat(actualArtifactList).as("Check number of artifacts").hasSize(beforeArtifactList.size() + 1); int fileNameCounter = 0; - String fileName; - for(DataTestIdEnum.InformationalArtifactsService artifact: DataTestIdEnum.InformationalArtifactsService.values()){ - fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; - ArtifactUIUtils.fillPlaceHolderInformationalArtifact(artifact, - FileHandling.getFilePath("uniqueFileNames"), fileName, descriptionText); + String fileName; + for (DataTestIdEnum.InformationalArtifactsService artifact : DataTestIdEnum.InformationalArtifactsService.values()) { + fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; + ArtifactUIUtils.fillPlaceHolderInformationalArtifact(artifact, + FileHandling.getFilePath("uniqueFileNames"), fileName, descriptionText); artifactFileNames.add(fileName); - fileNameCounter++; - } + fileNameCounter++; + } artifactFileNames.add(HEAT_FILE_YAML_NAME); int numberOfFiles = CompositionPage.getAllAddedArtifacts().size(); - assertThat(numberOfFiles).as("Check number of artifacts").isEqualTo(beforeArtifactList.size() + 1); - - fileNameCounter = 0; - for(WebElement actualArtifact : CompositionPage.getAllAddedArtifacts()){ - assertThat(actualArtifact.getText()).isEqualTo(artifactFileNames.get(fileNameCounter)); - fileNameCounter++; - } - } - - @Test - public void addAPIArtifactInCompositionScreenTest() throws Exception{ - String fileName = HEAT_FILE_YAML_NAME, - descriptionText = DESCRIPTION, - url = "http://kuku.com"; - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - new ArtifactInfo(filePath, fileName, descriptionText, ARTIFACT_LABEL,"OTHER"); - CompositionPage.showAPIArtifactTab(); - - for(DataTestIdEnum.APIArtifactsService artifact: DataTestIdEnum.APIArtifactsService.values()){ - ArtifactUIUtils.fillPlaceHolderAPIArtifact(artifact, filePath, fileName, descriptionText, url); - } - int numberOfFiles = CompositionPage.getAllAddedArtifacts().size(), - numberOfPlacehoders = DataTestIdEnum.APIArtifactsService.values().length; - assertTrue(String.format("Wrong file count, should be %s files", numberOfPlacehoders), numberOfPlacehoders == numberOfFiles); - - for(WebElement actualArtifactFileName : CompositionPage.getAllAddedArtifacts()){ - assertTrue(fileName.equals(actualArtifactFileName.getText())); - } - } - - @Test - public void ManagmentWorkflowTest() throws Exception{ - String descriptionText = DESCRIPTION, - descriptionTextEdit = "kuku2"; - - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - ServiceGeneralPage.getServiceLeftMenu().moveToManagmentWorkflow(); - ServiceGeneralPage.fillAndAddNewWorkflow(descriptionText, descriptionText); - ServiceVerificator.verifyManagmentWorkflow(descriptionText, descriptionText); - - ServiceGeneralPage.clickAddWorkflow(); - ServiceGeneralPage.fillAndAddNewWorkflow(descriptionTextEdit, descriptionTextEdit); - } - - @Test - public void deleteChangeVersionTest() throws Exception{ - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - + assertThat(numberOfFiles).as("Check number of artifacts").isEqualTo(beforeArtifactList.size() + 1); + + fileNameCounter = 0; + for (WebElement actualArtifact : CompositionPage.getAllAddedArtifacts()) { + assertThat(actualArtifact.getText()).isEqualTo(artifactFileNames.get(fileNameCounter)); + fileNameCounter++; + } + } + + @Test + public void addAPIArtifactInCompositionScreenTest() throws Exception { + String fileName = HEAT_FILE_YAML_NAME, + descriptionText = DESCRIPTION, + url = "http://kuku.com"; + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,"OTHER"); - CompositionPage.showDeploymentArtifactTab(); - CompositionPage.clickAddArtifactButton(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); - - ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - GeneralPageElements.clickCheckoutButton(); - - changeDeleteAndValidateVersionOnGeneralPage("0.1", "0.2", serviceMetadata.getName()); - - GeneralPageElements.clickCheckoutButton(); - ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - TesterOperationPage.certifyComponent(serviceMetadata.getName()); - - reloginWithNewRole(UserRoleEnum.DESIGNER); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - ResourceGeneralPage.clickCheckoutButton(); - - changeDeleteAndValidateVersionOnGeneralPage("1.0", "1.1", serviceMetadata.getName()); - } - - @Test - public void compositionScreenRightSideButtonsTest() throws Exception{ - - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - CompositionPage.showInformationTab(); - ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.INFORMATION); - - //feature removed from UI + new ArtifactInfo(filePath, fileName, descriptionText, ARTIFACT_LABEL, "OTHER"); + CompositionPage.showAPIArtifactTab(); + + for (DataTestIdEnum.APIArtifactsService artifact : DataTestIdEnum.APIArtifactsService.values()) { + ArtifactUIUtils.fillPlaceHolderAPIArtifact(artifact, filePath, fileName, descriptionText, url); + } + int numberOfFiles = CompositionPage.getAllAddedArtifacts().size(), + numberOfPlacehoders = DataTestIdEnum.APIArtifactsService.values().length; + assertTrue(String.format("Wrong file count, should be %s files", numberOfPlacehoders), numberOfPlacehoders == numberOfFiles); + + for (WebElement actualArtifactFileName : CompositionPage.getAllAddedArtifacts()) { + assertTrue(fileName.equals(actualArtifactFileName.getText())); + } + } + + @Test + public void ManagmentWorkflowTest() throws Exception { + String descriptionText = DESCRIPTION, + descriptionTextEdit = "kuku2"; + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + ServiceGeneralPage.getServiceLeftMenu().moveToManagmentWorkflow(); + ServiceGeneralPage.fillAndAddNewWorkflow(descriptionText, descriptionText); + ServiceVerificator.verifyManagmentWorkflow(descriptionText, descriptionText); + + ServiceGeneralPage.clickAddWorkflow(); + ServiceGeneralPage.fillAndAddNewWorkflow(descriptionTextEdit, descriptionTextEdit); + } + + @Test + public void deleteChangeVersionTest() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, "OTHER"); + CompositionPage.showDeploymentArtifactTab(); + CompositionPage.clickAddArtifactButton(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); + + ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + GeneralPageElements.clickCheckoutButton(); + + changeDeleteAndValidateVersionOnGeneralPage("0.1", "0.2", serviceMetadata.getName()); + + GeneralPageElements.clickCheckoutButton(); + ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + TesterOperationPage.certifyComponent(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.DESIGNER); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + ResourceGeneralPage.clickCheckoutButton(); + + changeDeleteAndValidateVersionOnGeneralPage("1.0", "1.1", serviceMetadata.getName()); + } + + @Test + public void compositionScreenRightSideButtonsTest() throws Exception { + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + CompositionPage.showInformationTab(); + ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.INFORMATION); + + //feature removed from UI // CompositionPage.showCompositionTab(); // ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.COMPOSITION); - - CompositionPage.showDeploymentArtifactTab(); - ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB); - - CompositionPage.showInputsTab(); - assertTrue(CompositionPage.getOpenTabTitle().size() == 0); - - CompositionPage.showAPIArtifactTab(); - ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.API); - - CompositionPage.showInformationArtifactTab(); - ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.INFORMATION_ARTIFACTS); - - } - - @Test - public void addDeploymentArtifactToVFInstanceTest() throws Exception{ - - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,ArtifactTypeEnum.SNMP_POLL.getType()); - - CanvasElement computeElement = createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact); - checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); - checkInService(serviceMetadata); - clickOncanvasElement(computeElement); - CompositionPage.showDeploymentArtifactTab(); - checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); - } - - @Test - public void deleteDeploymentArtifactFromVFInstanceTest() throws Exception{ - - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,ArtifactTypeEnum.SNMP_POLL.getType()); - - createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact); - checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); - List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); - deleteAndVerifyArtifact(actualArtifactList); - - } - - @Test - public void deleteDeploymentArtifactFromVFInstanceNextVersionTest() throws Exception{ - + + CompositionPage.showDeploymentArtifactTab(); + ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB); + + CompositionPage.showInputsTab(); + assertTrue(CompositionPage.getOpenTabTitle().size() == 0); + + CompositionPage.showAPIArtifactTab(); + ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.API); + + CompositionPage.showInformationArtifactTab(); + ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.INFORMATION_ARTIFACTS); + + } + + @Test + public void addDeploymentArtifactToVFInstanceTest() throws Exception { + + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, ArtifactTypeEnum.SNMP_POLL.getType()); + + CanvasElement computeElement = createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact); + checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); + checkInService(serviceMetadata); + clickOncanvasElement(computeElement); + CompositionPage.showDeploymentArtifactTab(); + checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); + } + + @Test + public void deleteDeploymentArtifactFromVFInstanceTest() throws Exception { + + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, ArtifactTypeEnum.SNMP_POLL.getType()); + + createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact); + checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); + List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); + deleteAndVerifyArtifact(actualArtifactList); + + } + + @Test + public void deleteDeploymentArtifactFromVFInstanceNextVersionTest() throws Exception { + // if(true){ // throw new SkipException("Open bug 342260"); // } - - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,ArtifactTypeEnum.SNMP_POLL.getType()); - - CanvasElement computeElement = createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact); - checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); - checkInService(serviceMetadata); - ResourceGeneralPage.clickCheckoutButton(); - clickOncanvasElement(computeElement); - CompositionPage.showDeploymentArtifactTab(); - List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); - deleteAndVerifyArtifact(actualArtifactList); + + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, ArtifactTypeEnum.SNMP_POLL.getType()); + + CanvasElement computeElement = createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact); + checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); + checkInService(serviceMetadata); + ResourceGeneralPage.clickCheckoutButton(); + clickOncanvasElement(computeElement); + CompositionPage.showDeploymentArtifactTab(); + List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); + deleteAndVerifyArtifact(actualArtifactList); // change container version - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()); - GeneralPageElements.selectVersion("V0.1"); - clickOncanvasElement(computeElement); - CompositionPage.showDeploymentArtifactTab(); - checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); - - } + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()); + GeneralPageElements.selectVersion("V0.1"); + clickOncanvasElement(computeElement); + CompositionPage.showDeploymentArtifactTab(); + checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); + + } + + // service version V0.1 default artifact, service version V0.2 updated artifact + @Test + public void updateDeploymentArtifactOnVFInstanceNextVersionTest() throws Exception { -// service version V0.1 default artifact, service version V0.2 updated artifact - @Test - public void updateDeploymentArtifactOnVFInstanceNextVersionTest() throws Exception{ - // if(true){ // throw new SkipException("Open bug 322930"); // } - - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,ArtifactTypeEnum.SNMP_POLL.getType()); - ArtifactInfo artifactUpdate = new ArtifactInfo(filePath, HEAT_FILE_YAML_UPDATE_NAME, DESCRIPTION, ARTIFACT_LABEL_UPDATE,ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()); - - CanvasElement computeElement = createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact); - checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); - checkInService(serviceMetadata); - ResourceGeneralPage.clickCheckoutButton(); - clickOncanvasElement(computeElement); - CompositionPage.showDeploymentArtifactTab(); - List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); - deleteAndVerifyArtifact(actualArtifactList); + + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, ArtifactTypeEnum.SNMP_POLL.getType()); + ArtifactInfo artifactUpdate = new ArtifactInfo(filePath, HEAT_FILE_YAML_UPDATE_NAME, DESCRIPTION, ARTIFACT_LABEL_UPDATE, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType()); + + CanvasElement computeElement = createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact); + checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); + checkInService(serviceMetadata); + ResourceGeneralPage.clickCheckoutButton(); + clickOncanvasElement(computeElement); + CompositionPage.showDeploymentArtifactTab(); + List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); + deleteAndVerifyArtifact(actualArtifactList); // upload new artifact - addDeploymentArtifact(artifactUpdate, CanvasManager.getCanvasManager(), computeElement); - checkArtifactIfAdded(1, HEAT_FILE_YAML_UPDATE_NAME); + addDeploymentArtifact(artifactUpdate, CanvasManager.getCanvasManager(), computeElement); + checkArtifactIfAdded(1, HEAT_FILE_YAML_UPDATE_NAME); // change container version - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()); - GeneralPageElements.selectVersion("V0.1"); - clickOncanvasElement(computeElement); - CompositionPage.showDeploymentArtifactTab(); - checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); - - } - - public void clickOncanvasElement(CanvasElement computeElement) { - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - canvasManager.clickOnCanvaElement(computeElement); - } - - public void checkInService(ServiceReqDetails serviceMetadata) throws Exception { - ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - } - - public static void deleteAndVerifyArtifact(List actualArtifactList) { - if (actualArtifactList.size()>0){ - GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ITEM.getValue() + ARTIFACT_LABEL); - SetupCDTest.getExtendTest().log(Status.INFO, "Going to delete " + HEAT_FILE_YAML_NAME + " artifact" + " and check if deleted"); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + ARTIFACT_LABEL); - GeneralPageElements.clickOKButton(); - assertTrue("Artifact does not deleted", !GeneralUIUtils.waitForElementInVisibilityByTestId(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME))); - } - } - - - public void checkArtifactIfAdded(Integer expectedNumOfARtifacts, String expectedArtifactName) { - - List actualArtifactList; - actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); - assertTrue("Expected artifact count is: " + expectedNumOfARtifacts + ", but was " + actualArtifactList.size(),expectedNumOfARtifacts==actualArtifactList.size()); - - if(expectedNumOfARtifacts != 0){ - for(WebElement actualArtifactFileName : CompositionPage.getAllAddedArtifacts()){ - assertTrue("Artifact name does not match, expected " + expectedArtifactName + ", but was " + actualArtifactFileName.getText(), expectedArtifactName.equals(actualArtifactFileName.getText())); - } - } - - } + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()); + GeneralPageElements.selectVersion("V0.1"); + clickOncanvasElement(computeElement); + CompositionPage.showDeploymentArtifactTab(); + checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME); + } - public CanvasElement createServiceWithRiArtifact(ResourceReqDetails atomicResourceMetaData, ServiceReqDetails serviceMetadata, ArtifactInfo artifact) throws Exception, AWTException { - ResourceUIUtils.createVF(atomicResourceMetaData, getUser()); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); - - ServiceUIUtils.createService(serviceMetadata, getUser()); - - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - CanvasElement computeElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - addDeploymentArtifact(artifact, canvasManager, computeElement); - - return computeElement; - } - - - public void addDeploymentArtifact(ArtifactInfo artifact, CanvasManager canvasManager, CanvasElement computeElement) throws Exception { - canvasManager.clickOnCanvaElement(computeElement); - CompositionPage.showDeploymentArtifactTab(); - CompositionPage.clickAddArtifactButton(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); - } - - @Test - public void isDisabledAndReadOnlyInCheckin() throws Exception{ - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - GeneralPageElements.clickCheckinButton(serviceMetadata.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - - ServiceMetadataEnum[] fieldsForCheck = {ServiceMetadataEnum.SERVICE_NAME, - ServiceMetadataEnum.CONTACT_ID, - ServiceMetadataEnum.DESCRIPTION, - ServiceMetadataEnum.PROJECT_CODE, - ServiceMetadataEnum.TAGS}; - for (ServiceMetadataEnum field: fieldsForCheck){ - assertTrue(GeneralUIUtils.isElementReadOnly(field.getValue())); - } - - assertTrue(GeneralUIUtils.isElementDisabled(ServiceMetadataEnum.CATEGORY.getValue())); - assertTrue(GeneralUIUtils.isElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue())); - } - - // future removed from ui + public void clickOncanvasElement(CanvasElement computeElement) { + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + canvasManager.clickOnCanvaElement(computeElement); + } + + public void checkInService(ServiceReqDetails serviceMetadata) throws Exception { + ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + } + + public static void deleteAndVerifyArtifact(List actualArtifactList) { + if (actualArtifactList.size() > 0) { + GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ITEM.getValue() + ARTIFACT_LABEL); + SetupCDTest.getExtendTest().log(Status.INFO, "Going to delete " + HEAT_FILE_YAML_NAME + " artifact" + " and check if deleted"); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + ARTIFACT_LABEL); + GeneralPageElements.clickOKButton(); + assertTrue("Artifact does not deleted", !GeneralUIUtils.waitForElementInVisibilityByTestId(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME))); + } + } + + + public void checkArtifactIfAdded(Integer expectedNumOfARtifacts, String expectedArtifactName) { + + List actualArtifactList; + actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); + assertTrue("Expected artifact count is: " + expectedNumOfARtifacts + ", but was " + actualArtifactList.size(), expectedNumOfARtifacts == actualArtifactList.size()); + + if (expectedNumOfARtifacts != 0) { + for (WebElement actualArtifactFileName : CompositionPage.getAllAddedArtifacts()) { + assertTrue("Artifact name does not match, expected " + expectedArtifactName + ", but was " + actualArtifactFileName.getText(), expectedArtifactName.equals(actualArtifactFileName.getText())); + } + } + + } + + + public CanvasElement createServiceWithRiArtifact(ResourceReqDetails atomicResourceMetaData, ServiceReqDetails serviceMetadata, ArtifactInfo artifact) throws Exception, AWTException { + ResourceUIUtils.createVF(atomicResourceMetaData, getUser()); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); + + ServiceUIUtils.createService(serviceMetadata, getUser()); + + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + CanvasElement computeElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + addDeploymentArtifact(artifact, canvasManager, computeElement); + + return computeElement; + } + + + public void addDeploymentArtifact(ArtifactInfo artifact, CanvasManager canvasManager, CanvasElement computeElement) throws Exception { + canvasManager.clickOnCanvaElement(computeElement); + CompositionPage.showDeploymentArtifactTab(); + CompositionPage.clickAddArtifactButton(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); + } + + @Test + public void isDisabledAndReadOnlyInCheckin() throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + GeneralPageElements.clickCheckinButton(serviceMetadata.getName()); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + + ServiceMetadataEnum[] fieldsForCheck = {ServiceMetadataEnum.SERVICE_NAME, + ServiceMetadataEnum.CONTACT_ID, + ServiceMetadataEnum.DESCRIPTION, + ServiceMetadataEnum.PROJECT_CODE, + ServiceMetadataEnum.TAGS}; + for (ServiceMetadataEnum field : fieldsForCheck) { + assertTrue(GeneralUIUtils.isElementReadOnly(field.getValue())); + } + + assertTrue(GeneralUIUtils.isElementDisabled(ServiceMetadataEnum.CATEGORY.getValue())); + assertTrue(GeneralUIUtils.isElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue())); + } + + // future removed from ui @Test(enabled = false) - public void inputsTest() throws Exception{ - String fileName = "service_input_test_VF2.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); - GeneralPageElements.clickCheckinButton(resourceMetaData.getName()); - - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - String selectedInstanceName = addResourceToServiceInCanvas(resourceMetaData); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - DeploymentArtifactPage.getLeftMenu().moveToInputsScreen(); - - InputsPage.addInputToService(selectedInstanceName, "volume_id"); - InputsPage.deleteServiceInput(selectedInstanceName, "volume_id"); - - // Trying to find deleted service input - try{ - InputsPage.getServiceInput(selectedInstanceName, "volume_id"); - assert(false); - } - catch(TestException e){ - } - } - - @Test() - public void deploymentViewServiceTest() throws Exception{ - - User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - String fileName2 = "vSeGWNew.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); - - // update group property max_vf_module_instances of VF Module to 100 - List groups = resource.getGroups(); - for (GroupDefinition group : groups) { - if(group.getType().equals("org.openecomp.groups.VfModule")) { - for(PropertyDataDefinition property : group.getProperties()){ - if(property.getName().equals("max_vf_module_instances")) { + public void inputsTest() throws Exception { + String fileName = "service_input_test_VF2.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); + GeneralPageElements.clickCheckinButton(resourceMetaData.getName()); + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + String selectedInstanceName = addResourceToServiceInCanvas(resourceMetaData); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + DeploymentArtifactPage.getLeftMenu().moveToInputsScreen(); + + InputsPage.addInputToService(selectedInstanceName, "volume_id"); + InputsPage.deleteServiceInput(selectedInstanceName, "volume_id"); + + // Trying to find deleted service input + try { + InputsPage.getServiceInput(selectedInstanceName, "volume_id"); + assert (false); + } catch (TestException e) { + } + } + + @Test() + public void deploymentViewServiceTest() throws Exception { + + User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + String fileName2 = "vSeGWNew.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); + + // update group property max_vf_module_instances of VF Module to 100 + List groups = resource.getGroups(); + for (GroupDefinition group : groups) { + if (group.getType().equals("org.openecomp.groups.VfModule")) { + for (PropertyDataDefinition property : group.getProperties()) { + if (property.getName().equals("max_vf_module_instances")) { // property.setValue("100"); // List propertyList = new ArrayList<>(); // propertyList.add(property); // todo pass to method correct object instaed of value for custom json - AtomicOperationUtils.updateGroupPropertyOnResource("100", resource, group.getUniqueId(), user, true); - break; - } - } - } - } - - ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - addResourceToServiceInCanvas(resourceMetaData); - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - DeploymentArtifactPage.getLeftMenu().moveToDeploymentViewScreen(); - serviceMetadata.setVersion("0.1"); - List instanceRowsFromTable = GeneralUIUtils.getElementsByCSS("div[data-tests-id^='hierarchy-instance'] span[class^='expand-collapse-title-text']"); - for(WebElement instanceRow: instanceRowsFromTable){ - String instanceRowText = instanceRow.getText(); - List instanceModulesList = DeploymentPage.getInstanceModulesList(instanceRowText); - for (WebElement instanceModule: instanceModulesList){ - String instanceModuleText = instanceModule.getText(); - ResourceUIUtils.clickOnElementByText(instanceModuleText, "instance"); - ServiceVerificator.verifyDeploymentPageSubElements(instanceModuleText.split("\\.\\.")[2], new DeploymentViewVerificator(filePath + fileName2)); - ServiceVerificator.verifyDisabledServiceProperties(); - if(true){ -// throw new SkipException("Sent email to Edith Ronen, waiting for answer"); - SetupCDTest.getExtendTest().log(Status.INFO, "Sent email to Edith Ronen, waiting for answer"); - } - String isBaseValue = ServiceVerificator.getVFModulePropertyValue(serviceMetadata, "isBase", instanceModuleText); - if (isBaseValue.equals("false")) - ServiceVerificator.verifyEnabledServiceProperties(); - ResourceUIUtils.clickOnElementByText(instanceModuleText, "instance"); - } - } - } - - @Test - public void vfModuleCustomizationUUIDServiceTest() throws Exception{ - String fileName2 = "vSeGW.csar"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); - ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); - - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - addResourceToServiceInCanvas(resourceMetaData); - - serviceMetadata.setVersion("0.1"); - ServiceVerificator.verifyVFModuleCustomizationUUID(serviceMetadata); - } - - @Test - public void checkoutCertifyRemainSameCustomizationUUIDServiceTest() throws Exception{ - String fileName2 = "vSeGW.csar"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); - //TODO Andrey should click on certify button - ResourceGeneralPage.clickCertifyButton(resourceMetaData.getName()); + AtomicOperationUtils.updateGroupPropertyOnResource("100", resource, group.getUniqueId(), user, true); + break; + } + } + } + } + + ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + addResourceToServiceInCanvas(resourceMetaData); + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + DeploymentArtifactPage.getLeftMenu().moveToDeploymentViewScreen(); + serviceMetadata.setVersion("0.1"); + List instanceRowsFromTable = GeneralUIUtils.getElementsByCSS("div[data-tests-id^='hierarchy-instance'] span[class^='expand-collapse-title-text']"); + for (WebElement instanceRow : instanceRowsFromTable) { + String instanceRowText = instanceRow.getText(); + List instanceModulesList = DeploymentPage.getInstanceModulesList(instanceRowText); + for (WebElement instanceModule : instanceModulesList) { + String instanceModuleText = instanceModule.getText(); + ResourceUIUtils.clickOnElementByText(instanceModuleText, "instance"); + ServiceVerificator.verifyDeploymentPageSubElements(instanceModuleText.split("\\.\\.")[2], new DeploymentViewVerificator(filePath + fileName2)); + ServiceVerificator.verifyDisabledServiceProperties(); + SetupCDTest.getExtendTest().log(Status.INFO, "Sent email to Edith Ronen, waiting for answer"); + String isBaseValue = ServiceVerificator.getVFModulePropertyValue(serviceMetadata, "isBase", instanceModuleText); + if (isBaseValue.equals("false")) { + ServiceVerificator.verifyEnabledServiceProperties(); + } + ResourceUIUtils.clickOnElementByText(instanceModuleText, "instance"); + } + } + } + + @Test + public void vfModuleCustomizationUUIDServiceTest() throws Exception { + String fileName2 = "vSeGW.csar"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); + ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + addResourceToServiceInCanvas(resourceMetaData); + + serviceMetadata.setVersion("0.1"); + ServiceVerificator.verifyVFModuleCustomizationUUID(serviceMetadata); + } + + @Test + public void checkoutCertifyRemainSameCustomizationUUIDServiceTest() throws Exception { + String fileName2 = "vSeGW.csar"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser()); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(resourceMetaData.getName()); /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); TesterOperationPage.certifyComponent(resourceMetaData.getName()); reloginWithNewRole(UserRoleEnum.DESIGNER);*/ - - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - addResourceToServiceInCanvas(resourceMetaData); - - serviceMetadata.setVersion("0.1"); - ServiceVerificator.verifyVFModuleCustomizationUUID(serviceMetadata); - List allVFModuleCustomizationUUIDs = ServiceVerificator.getAllVFModuleCustomizationUUIDs(serviceMetadata); - - ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - GeneralPageElements.clickCheckoutButton(); - - serviceMetadata.setVersion("0.2"); - assertTrue(ServiceVerificator.isEqualCustomizationUUIDsAfterChanges(allVFModuleCustomizationUUIDs, ServiceVerificator.getAllVFModuleCustomizationUUIDs(serviceMetadata))); - - ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - TesterOperationPage.certifyComponent(serviceMetadata.getName()); - - reloginWithNewRole(UserRoleEnum.DESIGNER); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - ResourceGeneralPage.clickCheckoutButton(); - - serviceMetadata.setVersion("1.1"); - serviceMetadata.setUniqueId(null); - assertTrue(ServiceVerificator.isEqualCustomizationUUIDsAfterChanges(allVFModuleCustomizationUUIDs, ServiceVerificator.getAllVFModuleCustomizationUUIDs(serviceMetadata))); - } - - @Test - public void createServiceWithALaCarteInstanTypeAndCheckItsTosca() throws Exception { - getExtendTest().log(Status.INFO, "Starting the test: createServiceWithALaCarteInstanTypeAndCheckItsTosca."); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createServiceWithDefaultTagAndUserId(serviceMetadata, getUser()); - getExtendTest().log(Status.INFO, "Done creating service over the UI, " - + "about to move into Tosca Artifacts section."); - ResourceGeneralPage.moveToToscaArtifactsSectionAndDownloadTosca(); - getExtendTest().log(Status.INFO, "Downloaded Template YAML File."); - AssertJUnit.assertTrue(ServiceGeneralPage.parseToscaFileIntoServiceAndValidateProperties(serviceMetadata)); - getExtendTest().log(Status.INFO, "Test is successful."); - } - - @Test - public void createServiceWithALaCarteInstanTypeAndVerifyChosenValue() throws Exception { - getExtendTest().log(Status.INFO, "Starting the test: createServiceWithALaCarteInstanTypeAndVerifyChosenValue."); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createServiceWithDefaultTagAndUserId(serviceMetadata, getUser()); - getExtendTest().log(Status.INFO, "Done creating service over the UI, " - + "about to move into Home page."); - HomePage.navigateToHomePage(); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - assertTrue(serviceMetadata.getInstantiationType().equals(ServiceGeneralPage.getInstantiationTypeChosenValue())); - } - - - public static synchronized String addResourceToServiceInCanvas(ResourceReqDetails resourceMetaData) throws Exception { + + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + + addResourceToServiceInCanvas(resourceMetaData); + + serviceMetadata.setVersion("0.1"); + ServiceVerificator.verifyVFModuleCustomizationUUID(serviceMetadata); + List allVFModuleCustomizationUUIDs = ServiceVerificator.getAllVFModuleCustomizationUUIDs(serviceMetadata); + + ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName()); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + GeneralPageElements.clickCheckoutButton(); + + serviceMetadata.setVersion("0.2"); + assertTrue(ServiceVerificator.isEqualCustomizationUUIDsAfterChanges(allVFModuleCustomizationUUIDs, ServiceVerificator.getAllVFModuleCustomizationUUIDs(serviceMetadata))); + + ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + TesterOperationPage.certifyComponent(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.DESIGNER); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + ResourceGeneralPage.clickCheckoutButton(); + + serviceMetadata.setVersion("1.1"); + serviceMetadata.setUniqueId(null); + assertTrue(ServiceVerificator.isEqualCustomizationUUIDsAfterChanges(allVFModuleCustomizationUUIDs, ServiceVerificator.getAllVFModuleCustomizationUUIDs(serviceMetadata))); + } + + @Test + public void createServiceWithALaCarteInstanTypeAndCheckItsTosca() throws Exception { + getExtendTest().log(Status.INFO, "Starting the test: createServiceWithALaCarteInstanTypeAndCheckItsTosca."); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createServiceWithDefaultTagAndUserId(serviceMetadata, getUser()); + getExtendTest().log(Status.INFO, "Done creating service over the UI, " + + "about to move into Tosca Artifacts section."); + ResourceGeneralPage.moveToToscaArtifactsSectionAndDownloadTosca(); + getExtendTest().log(Status.INFO, "Downloaded Template YAML File."); + AssertJUnit.assertTrue(ServiceGeneralPage.parseToscaFileIntoServiceAndValidateProperties(serviceMetadata)); + getExtendTest().log(Status.INFO, "Test is successful."); + } + + @Test + public void createServiceWithALaCarteInstanTypeAndVerifyChosenValue() throws Exception { + getExtendTest().log(Status.INFO, "Starting the test: createServiceWithALaCarteInstanTypeAndVerifyChosenValue."); + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createServiceWithDefaultTagAndUserId(serviceMetadata, getUser()); + getExtendTest().log(Status.INFO, "Done creating service over the UI, " + + "about to move into Home page."); + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + assertTrue(serviceMetadata.getInstantiationType().equals(ServiceGeneralPage.getInstantiationTypeChosenValue())); + } + + + public static synchronized String addResourceToServiceInCanvas(ResourceReqDetails resourceMetaData) throws Exception { DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - if (computeElement == null) { - computeElement = createCanvasElement(resourceMetaData); - } - CanvasManager.getCanvasManager().clickOnCanvaElement(computeElement); - return CompositionPage.getSelectedInstanceName(); - } - - private static synchronized CanvasElement createCanvasElement(ResourceReqDetails resourceMetaData) throws Exception { + if (computeElement == null) { + computeElement = createCanvasElement(resourceMetaData); + } + CanvasManager.getCanvasManager().clickOnCanvaElement(computeElement); + return CompositionPage.getSelectedInstanceName(); + } + + private static synchronized CanvasElement createCanvasElement(ResourceReqDetails resourceMetaData) throws Exception { CompositionPage.searchForElement(resourceMetaData.getName()); - return CanvasManager.getCanvasManager().createElementOnCanvas(resourceMetaData.getName()); - } - - public static void changeDeleteAndValidateVersionOnGeneralPage(String previousVersion, String currentVersion, String serviceName) throws Exception{ - GeneralPageElements.selectVersion("V" + previousVersion); - ServiceVerificator.verifyVersionUI(previousVersion); - GeneralUIUtils.clickJSOnElementByText("latest version"); - ServiceVerificator.verifyVersionUI(currentVersion); - GeneralPageElements.clickTrashButtonAndConfirm(); - GeneralUIUtils.findComponentAndClick(serviceName); - ServiceVerificator.verifyVersionUI(previousVersion); - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + return CanvasManager.getCanvasManager().createElementOnCanvas(resourceMetaData.getName()); + } + + public static void changeDeleteAndValidateVersionOnGeneralPage(String previousVersion, String currentVersion, String serviceName) throws Exception { + GeneralPageElements.selectVersion("V" + previousVersion); + ServiceVerificator.verifyVersionUI(previousVersion); + GeneralUIUtils.clickJSOnElementByText("latest version"); + ServiceVerificator.verifyVersionUI(currentVersion); + GeneralPageElements.clickTrashButtonAndConfirm(); + GeneralUIUtils.findComponentAndClick(serviceName); + ServiceVerificator.verifyVersionUI(previousVersion); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ToscaValidationTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ToscaValidationTest.java index b40706bf22..9eb0a49a64 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ToscaValidationTest.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ToscaValidationTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,16 +29,35 @@ import org.onap.sdc.toscaparser.api.NodeTemplate; import org.onap.sdc.toscaparser.api.elements.Metadata; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.*; +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstanceInput; +import org.openecomp.sdc.be.model.GroupDefinition; +import org.openecomp.sdc.be.model.GroupInstance; +import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition; +import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TypeHeatMetaDefinition; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.tosca.datatypes.*; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaGroupPropertyDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaGroupsTopologyTemplateDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaInputsTopologyTemplateDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaServiceGroupsMetadataDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaTopologyTemplateDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.VfModuleDefinition; import org.openecomp.sdc.ci.tests.tosca.model.ToscaMetadataFieldsPresentationEnum; import org.openecomp.sdc.ci.tests.utilities.DownloadManager; import org.openecomp.sdc.ci.tests.utilities.FileHandling; @@ -55,7 +74,12 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; import static org.testng.Assert.assertFalse; @@ -78,7 +102,7 @@ public class ToscaValidationTest extends SetupCDTest { toscaMainAmdocsDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(amdocsCsarFileName); toscaMainVfDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File("C:\\Users\\al714h\\Downloads\\resource-Civfonboarded2016073VmxBv301072E2eE60f5c15-csar.csar")); */ - // vnfFile = "vRouter for DHV Test_Version_4.zip"; + // vnfFile = "vRouter for DHV Test_Version_4.zip"; setLog(vnfFile); List status = new ArrayList<>(); ISdcCsarHelper fdntCsarHelper; @@ -287,10 +311,11 @@ public class ToscaValidationTest extends SetupCDTest { } protected String getRandomString() { + final int LengthOfRandomString = 18; String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; StringBuilder salt = new StringBuilder(); Random rnd = new Random(); - while (salt.length() < 18) { // length of the random string. + while (salt.length() < LengthOfRandomString) { int index = (int) (rnd.nextFloat() * SALTCHARS.length()); salt.append(SALTCHARS.charAt(index)); } @@ -300,11 +325,10 @@ public class ToscaValidationTest extends SetupCDTest { } protected int getRandomInteger() { + final int low = 10; + final int high = 100; Random r = new Random(); - int low = 10; - int high = 100; - int integerValue = r.nextInt(high - low) + low; - return integerValue; + return r.nextInt(high - low) + low; } @@ -316,8 +340,9 @@ public class ToscaValidationTest extends SetupCDTest { //add resource metadata to expected object toscaMainAmdocsDefinition = addAndGenerateResourceMetadataToExpectedObject(toscaMainAmdocsDefinition, resourceReqDetails, resource); Either> resourceToscaMetadataValidator = ToscaValidation.resourceToscaMetadataValidator(toscaMainAmdocsDefinition, toscaMainVfDefinition); - if (resourceToscaMetadataValidator.isRight()) + if (resourceToscaMetadataValidator.isRight()) { status.add(false); + } return status; } @@ -325,8 +350,9 @@ public class ToscaValidationTest extends SetupCDTest { reportStartTestPrint("validateResourceNodeTemplateMetadata", vnfFile); Map> generateReosurceNodeTemplateMetadataToExpectedObject = generateResourceNodeTemplateMetadataToExpectedObject(resource); Boolean resourceToscaMetadataValidator = ToscaValidation.resourceToscaNodeTemplateMetadataValidator(generateReosurceNodeTemplateMetadataToExpectedObject, toscaMainVfDefinition); - if (!resourceToscaMetadataValidator) + if (!resourceToscaMetadataValidator) { status.add(false); + } return status; } @@ -335,8 +361,9 @@ public class ToscaValidationTest extends SetupCDTest { reportStartTestPrint("validateServiceMetadata", vnfFile); Map generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service); Either> serviceToscaMetadataValidator = ToscaValidation.serviceToscaMetadataValidator(generateServiceMetadataToExpectedObject, toscaMainServiceDefinition); - if (serviceToscaMetadataValidator.isRight()) + if (serviceToscaMetadataValidator.isRight()) { status.add(false); + } return status; } @@ -345,8 +372,9 @@ public class ToscaValidationTest extends SetupCDTest { reportStartTestPrint("validateServiceNodeTemplateMetadata", vnfFile); Map generateServiceNodeTemplateMetadataToExpectedObject = generateServiceNodeTemplateMetadataToExpectedObject(resourceReqDetails, resource, componentInstanceDefinition); Either> serviceToscaMetadataValidator = ToscaValidation.componentToscaNodeTemplateMetadataValidator(generateServiceNodeTemplateMetadataToExpectedObject, toscaMainServiceDefinition, componentInstanceDefinition.getName(), ComponentTypeEnum.SERVICE, componentInstanceDefinition.getName()); - if (serviceToscaMetadataValidator.isRight()) + if (serviceToscaMetadataValidator.isRight()) { status.add(false); + } return status; } @@ -368,8 +396,9 @@ public class ToscaValidationTest extends SetupCDTest { String artifactPayload = ArtifactRestUtils.getDecodedArtifactPayloadFromResponse(restResponse); Map actualVfModulesDefinitionObject = ResponseParser.convertVfModuleJsonResponseToJavaObject(artifactPayload); Either> vfModuleJsonFileValidator = ToscaValidation.vfModuleJsonFileValidator(expectedVfModulesDefinitionObject, actualVfModulesDefinitionObject); - if (vfModuleJsonFileValidator.isRight()) + if (vfModuleJsonFileValidator.isRight()) { status.add(false); + } return status; } @@ -382,8 +411,9 @@ public class ToscaValidationTest extends SetupCDTest { Map generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service); Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata(); Either> serviceToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceMetadataToExpectedObject, serviceMetadata); - if (serviceToscaMetadataValidatorAgainstParser.isRight()) + if (serviceToscaMetadataValidatorAgainstParser.isRight()) { status.add(false); + } } return status; } @@ -397,8 +427,9 @@ public class ToscaValidationTest extends SetupCDTest { List serviceNodeTemplates = fdntCsarHelper.getServiceNodeTemplates(); Metadata serviceNodeTemplateMetadata = serviceNodeTemplates.get(0).getMetaData(); Either> serviceNodeTemplateToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceNodeTemplateMetadataToExpectedObject, serviceNodeTemplateMetadata); - if (serviceNodeTemplateToscaMetadataValidatorAgainstParser.isRight()) + if (serviceNodeTemplateToscaMetadataValidatorAgainstParser.isRight()) { status.add(false); + } } return status; } @@ -411,8 +442,9 @@ public class ToscaValidationTest extends SetupCDTest { Map expectedInputsMap = toscaMainAmdocsDefinition.getTopology_template().getInputs(); Map actualInputsMap = toscaMainVfDefinition.getTopology_template().getInputs(); Either> toscaInputsValidator = ToscaValidation.toscaInputsValidator(expectedInputsMap, actualInputsMap); - if (toscaInputsValidator.isRight()) + if (toscaInputsValidator.isRight()) { status.add(false); + } return status; } @@ -423,8 +455,9 @@ public class ToscaValidationTest extends SetupCDTest { Map expectedInputsMap = toscaExpectedMainServiceDefinition.getTopology_template().getInputs(); Map actualInputsMap = toscaMainServiceDefinition.getTopology_template().getInputs(); Either> toscaInputsValidator = ToscaValidation.toscaInputsValidator(expectedInputsMap, actualInputsMap); - if (toscaInputsValidator.isRight()) + if (toscaInputsValidator.isRight()) { status.add(false); + } return status; } @@ -432,8 +465,9 @@ public class ToscaValidationTest extends SetupCDTest { reportStartTestPrint("validateServiceModuleMetadata", vnfFile); Either> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupMetadataValidator(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition); - if (toscaServiceModuleMetadataValidator.isRight()) + if (toscaServiceModuleMetadataValidator.isRight()) { status.add(false); + } return status; } @@ -441,8 +475,9 @@ public class ToscaValidationTest extends SetupCDTest { reportStartTestPrint("validateServiceModuleProperty", vnfFile); Either> toscaServiceModulePropertyValidator = ToscaValidation.serviceToscaGroupPropertyValidator(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition); - if (toscaServiceModulePropertyValidator.isRight()) + if (toscaServiceModulePropertyValidator.isRight()) { status.add(false); + } return status; } @@ -454,8 +489,9 @@ public class ToscaValidationTest extends SetupCDTest { reportStartTestPrint("validateServiceInputsUsingParser", vnfFile); Map expectedInputsMap = toscaExpectedMainServiceDefinition.getTopology_template().getInputs(); Either> toscaInputsValidator = ToscaValidation.toscaInputsValidatorAgainstParser(expectedInputsMap, fdntCsarHelper); - if (toscaInputsValidator.isRight()) + if (toscaInputsValidator.isRight()) { status.add(false); + } } return status; } @@ -465,8 +501,9 @@ public class ToscaValidationTest extends SetupCDTest { String customizationUUID = fdntCsarHelper.getServiceNodeTemplates().get(0).getMetaData().getValue("customizationUUID"); List actualGroups = fdntCsarHelper.getVfModulesByVf(customizationUUID); Either> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupMetadataValidatorUsingParser(expectedToscaServiceGroupsDefinitionObject, actualGroups); - if (toscaServiceModuleMetadataValidator.isRight()) + if (toscaServiceModuleMetadataValidator.isRight()) { status.add(false); + } return status; } @@ -475,8 +512,9 @@ public class ToscaValidationTest extends SetupCDTest { String customizationUUID = fdntCsarHelper.getServiceNodeTemplates().get(0).getMetaData().getValue("customizationUUID"); List actualGroups = fdntCsarHelper.getVfModulesByVf(customizationUUID); Either> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupPropertyValidatorUsingParser(expectedToscaServiceGroupsDefinitionObject, actualGroups); - if (toscaServiceModuleMetadataValidator.isRight()) + if (toscaServiceModuleMetadataValidator.isRight()) { status.add(false); + } return status; } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/UpgradeServices.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/UpgradeServices.java index 3a3de17ec7..3023c9bea8 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/UpgradeServices.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/UpgradeServices.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,18 +25,41 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.ConnectionWizardPopUpObject; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; +import org.openecomp.sdc.ci.tests.datatypes.PortMirrioringConfigurationObject; +import org.openecomp.sdc.ci.tests.datatypes.PortMirroringEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.PropertiesAssignmentPage; +import org.openecomp.sdc.ci.tests.pages.PropertyNameBuilder; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.TesterOperationPage; +import org.openecomp.sdc.ci.tests.pages.UpgradeServicesPopup; import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.PortMirroringUtils; import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; -import org.openecomp.sdc.ci.tests.utils.general.*; +import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.FileHandling; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; +import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; import org.openecomp.sdc.ci.tests.verificator.PropertiesAssignmentVerificator; import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator; import org.openecomp.sdc.ci.tests.verificator.VfVerificator; @@ -46,37 +69,38 @@ import org.testng.annotations.Test; import java.util.Map; -public class UpgradeServices extends SetupCDTest{ +public class UpgradeServices extends SetupCDTest { - protected User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); - private String filePath; + private static final int CREATIN_UPDATE_BUTTON_TIMEOUT = 10 * 60; + private User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + private String filePath; - @BeforeClass - public void beforeClass(){ - filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getFilePath(""); - } + @BeforeClass + public void beforeClass() { + filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getFilePath(""); + } - @Test - public void upgradeVfOnServiceLevel() throws Throwable{ - String vnfFile = "2016-227_vmme_vmme_30_1610_e2e.zip"; - //1. Import VSP, create VF, certify - Resource vfResource = createAndCertifyVFfromVSP(vnfFile); + @Test + public void upgradeVfOnServiceLevel() throws Throwable { + String vnfFile = "2016-227_vmme_vmme_30_1610_e2e.zip"; + //1. Import VSP, create VF, certify + Resource vfResource = createAndCertifyVFfromVSP(vnfFile); //2. Create CR, certify - ResourceReqDetails crMetaData = createCRAndCertify(); + ResourceReqDetails crMetaData = createCRAndCertify(); //3. Create PNF, certify - ResourceReqDetails pnfMetaData = createPnfAndCertify(); + ResourceReqDetails pnfMetaData = createPnfAndCertify(); //4. Create Service1. Service composition - add 2 VFi - Service service1 = createService(); + Service service1 = createService(); getExtendTest().log(Status.INFO, "Add VFi to service twice"); CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - CanvasManager canvasManager1 = createCanvasManager(service1); + CanvasManager canvasManager1 = createCanvasManager(service1); CanvasElement vfElementVmme1 = canvasManager1.createElementOnCanvas(vfResource.getName()); CanvasElement vfElementVmme11 = canvasManager1.createElementOnCanvas(vfResource.getName()); //5. Add CRi, PNFi and PMC to Service1 - getExtendTest().log(Status.INFO, "Add PMC element to service"); + getExtendTest().log(Status.INFO, "Add PMC element to service"); CompositionPage.searchForElement(PortMirroringEnum.PMC_ELEMENT_IN_PALLETE.getValue()); CanvasElement pmcElement = canvasManager1.createElementOnCanvas(PortMirroringEnum.PMC_ELEMENT_IN_PALLETE.getValue()); getExtendTest().log(Status.INFO, "Add CR and PNF elements to service"); @@ -86,41 +110,41 @@ public class UpgradeServices extends SetupCDTest{ //6. Link between VF and PMC. Give values to capability properties. Certify Service1. ConnectionWizardPopUpObject connectionWizardPopUpObject = new ConnectionWizardPopUpObject("", "", PortMirroringEnum.PM_REQ_TYPE.getValue(), PortMirroringEnum.PMC_SOURCE_CAP.getValue()); - Map capPropValues1 = canvasManager1.linkElementsWithCapPropAssignment(vfElementVmme1, - pmcElement, connectionWizardPopUpObject); //link elements, assign values to properties and save map of values for later validation - certifyServiceInUI(service1); - service1.setVersion("1.0"); - service1 = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, service1.getName(), service1.getVersion()); - String vf1CustUuidOrig = AtomicOperationUtils.getServiceComponentInstanceByName - (service1, vfElementVmme1.getElementNameOnCanvas(),true).getCustomizationUUID(); + Map capPropValues1 = canvasManager1.linkElementsWithCapPropAssignment(vfElementVmme1, + pmcElement, connectionWizardPopUpObject); //link elements, assign values to properties and save map of values for later validation + certifyServiceInUI(service1); + service1.setVersion("1.0"); + service1 = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, service1.getName(), service1.getVersion()); + String vf1CustUuidOrig = AtomicOperationUtils.getServiceComponentInstanceByName( + service1, vfElementVmme1.getElementNameOnCanvas(), true).getCustomizationUUID(); //7. Create Service2. Service composition - add VFi. Start certifying Service2 ("certification in progress" stage) - Service service2 = createService(); + Service service2 = createService(); getExtendTest().log(Status.INFO, "Add VFi to service"); - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - CanvasManager canvasManager2 = createCanvasManager(service2); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CanvasManager canvasManager2 = createCanvasManager(service2); CanvasElement vfElementVmme2 = canvasManager2.createElementOnCanvas(vfResource.getName()); getExtendTest().log(Status.INFO, "Start service certification"); AtomicOperationUtils.changeComponentState(service2, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.STARTCERTIFICATION, true).getLeft(); - service2 = AtomicOperationUtils.getServiceObject(service2.getUniqueId()); - String vf2CustUuidOrig = AtomicOperationUtils.getServiceComponentInstanceByName - (service2, vfElementVmme2.getElementNameOnCanvas(),true).getCustomizationUUID(); + service2 = AtomicOperationUtils.getServiceObject(service2.getUniqueId()); + String vf2CustUuidOrig = AtomicOperationUtils.getServiceComponentInstanceByName( + service2, vfElementVmme2.getElementNameOnCanvas(), true).getCustomizationUUID(); //8. Create Service3. Service composition - add VFi. Leave service in "checked out" state - Service service3 = createService(); + Service service3 = createService(); getExtendTest().log(Status.INFO, "Add VFi to service"); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - CanvasManager canvasManager3 = createCanvasManager(service3); + CanvasManager canvasManager3 = createCanvasManager(service3); CanvasElement vfElementVmme3 = canvasManager3.createElementOnCanvas(vfResource.getName()); - service3 = AtomicOperationUtils.getServiceObject(service3.getUniqueId()); //updated - String vf3CustUuidOrig = AtomicOperationUtils.getServiceComponentInstanceByName - (service3, vfElementVmme3.getElementNameOnCanvas(),true).getCustomizationUUID(); + service3 = AtomicOperationUtils.getServiceObject(service3.getUniqueId()); //updated + String vf3CustUuidOrig = AtomicOperationUtils.getServiceComponentInstanceByName( + service3, vfElementVmme3.getElementNameOnCanvas(), true).getCustomizationUUID(); //9. VF - checkout, save, click "certify" GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); GeneralUIUtils.findComponentAndClick(vfResource.getName()); GeneralPageElements.clickCheckoutButton(); - GeneralPageElements.clickCreateUpdateButton(10*60); + GeneralPageElements.clickCreateUpdateButton(CREATIN_UPDATE_BUTTON_TIMEOUT); GeneralPageElements.clickCertifyButtonNoUpgradePopupDismiss(vfResource.getName()); //10. Validate that Service1 can be upgraded (checked), Service2 and Service3 are locked @@ -135,98 +159,98 @@ public class UpgradeServices extends SetupCDTest{ GeneralUIUtils.findComponentAndClick(service1.getName()); ServiceVerificator.verifyVersionUI("1.1"); ServiceVerificator.verifyServiceLifecycleInUI(LifeCycleStateEnum.CHECKIN); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager4 = CanvasManager.getCanvasManager(); - canvasManager4.clickOnCanvaElement(vfElementVmme1); - ServiceVerificator.verifyResourceInstanceVersionUI("2.0"); - canvasManager4.clickOnCanvaElement(vfElementVmme11); - ServiceVerificator.verifyResourceInstanceVersionUI("2.0"); - - //13. Verify that VFi CustomizationID is different - service1.setVersion("1.1"); - service1 = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, service1.getName(), service1.getVersion()); //updated - String vf1CustUuidUpd = AtomicOperationUtils.getServiceComponentInstanceByName - (service1, vfElementVmme1.getElementNameOnCanvas(),true).getCustomizationUUID(); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager4 = CanvasManager.getCanvasManager(); + canvasManager4.clickOnCanvaElement(vfElementVmme1); + ServiceVerificator.verifyResourceInstanceVersionUI("2.0"); + canvasManager4.clickOnCanvaElement(vfElementVmme11); + ServiceVerificator.verifyResourceInstanceVersionUI("2.0"); + + //13. Verify that VFi CustomizationID is different + service1.setVersion("1.1"); + service1 = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, service1.getName(), service1.getVersion()); //updated + String vf1CustUuidUpd = AtomicOperationUtils.getServiceComponentInstanceByName( + service1, vfElementVmme1.getElementNameOnCanvas(), true).getCustomizationUUID(); Assert.assertTrue(!vf1CustUuidOrig.equals(vf1CustUuidUpd)); //14. Verify that capabilities properties assignment is kept - canvasManager4.openLinkPopupReqsCapsConnection(vfElementVmme1, pmcElement); //open connection wizard - Map capPropValues2 = canvasManager4.connectionWizardCollectCapPropValues(); //collect cap prop values - Assert.assertTrue(capPropValues1.equals(capPropValues2)); // compare cap prop values before and after changing VF version + canvasManager4.openLinkPopupReqsCapsConnection(vfElementVmme1, pmcElement); //open connection wizard + Map capPropValues2 = canvasManager4.connectionWizardCollectCapPropValues(); //collect cap prop values + Assert.assertTrue(capPropValues1.equals(capPropValues2)); // compare cap prop values before and after changing VF version canvasManager4.clickSaveOnLinkPopup(); - //15. Open Service2, verify version (0.1), state ("in testing"), VFi version (1.0) and VFi Customization UUID (hasn't changed) - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - GeneralUIUtils.findComponentAndClick(service2.getName()); - ServiceVerificator.verifyVersionUI("0.1"); - ServiceVerificator.verifyServiceLifecycleInUI(LifeCycleStateEnum.IN_TESTING); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager5 = CanvasManager.getCanvasManager(); - canvasManager5.clickOnCanvaElement(vfElementVmme2); - ServiceVerificator.verifyResourceInstanceVersionUI("1.0"); - service2 = AtomicOperationUtils.getServiceObject(service2.getUniqueId()); //updated - String vf2CustUuidUpd = AtomicOperationUtils.getServiceComponentInstanceByName - (service2, vfElementVmme2.getElementNameOnCanvas(),true).getCustomizationUUID(); + //15. Open Service2, verify version (0.1), state ("in testing"), VFi version (1.0) and VFi Customization UUID (hasn't changed) + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service2.getName()); + ServiceVerificator.verifyVersionUI("0.1"); + ServiceVerificator.verifyServiceLifecycleInUI(LifeCycleStateEnum.IN_TESTING); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager5 = CanvasManager.getCanvasManager(); + canvasManager5.clickOnCanvaElement(vfElementVmme2); + ServiceVerificator.verifyResourceInstanceVersionUI("1.0"); + service2 = AtomicOperationUtils.getServiceObject(service2.getUniqueId()); //updated + String vf2CustUuidUpd = AtomicOperationUtils.getServiceComponentInstanceByName( + service2, vfElementVmme2.getElementNameOnCanvas(), true).getCustomizationUUID(); Assert.assertTrue(vf2CustUuidOrig.equals(vf2CustUuidUpd)); - //16. Open Service3, verify version (0.1), state ("checked out"), VFi version (1.0) and VFi Customization UUID (hasn't changed) - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - GeneralUIUtils.findComponentAndClick(service3.getName()); - ServiceVerificator.verifyVersionUI("0.1"); - ServiceVerificator.verifyServiceLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager6 = CanvasManager.getCanvasManager(); - canvasManager6.clickOnCanvaElement(vfElementVmme3); - ServiceVerificator.verifyResourceInstanceVersionUI("1.0"); - service3 = AtomicOperationUtils.getServiceObject(service3.getUniqueId()); //updated - String vf3CustUuidUpd = AtomicOperationUtils.getServiceComponentInstanceByName - (service3, vfElementVmme3.getElementNameOnCanvas(),true).getCustomizationUUID(); + //16. Open Service3, verify version (0.1), state ("checked out"), VFi version (1.0) and VFi Customization UUID (hasn't changed) + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service3.getName()); + ServiceVerificator.verifyVersionUI("0.1"); + ServiceVerificator.verifyServiceLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager6 = CanvasManager.getCanvasManager(); + canvasManager6.clickOnCanvaElement(vfElementVmme3); + ServiceVerificator.verifyResourceInstanceVersionUI("1.0"); + service3 = AtomicOperationUtils.getServiceObject(service3.getUniqueId()); //updated + String vf3CustUuidUpd = AtomicOperationUtils.getServiceComponentInstanceByName( + service3, vfElementVmme3.getElementNameOnCanvas(), true).getCustomizationUUID(); Assert.assertTrue(vf3CustUuidOrig.equals(vf3CustUuidUpd)); - //17. Open CR, checkout, certify. Verify there is no upgrade popup - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - GeneralUIUtils.findComponentAndClick(crMetaData.getName()); - ResourceGeneralPage.clickCheckoutButton(); - ResourceGeneralPage.clickCertifyButton(crMetaData.getName()); + //17. Open CR, checkout, certify. Verify there is no upgrade popup + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(crMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); + ResourceGeneralPage.clickCertifyButton(crMetaData.getName()); Assert.assertTrue(!UpgradeServicesPopup.isUpgradePopupShown()); - //18. Open PNF, checkout, certify. Verify there is no upgrade popup - GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); - ResourceGeneralPage.clickCheckoutButton(); - ResourceGeneralPage.clickCertifyButton(pnfMetaData.getName()); + //18. Open PNF, checkout, certify. Verify there is no upgrade popup + GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); + ResourceGeneralPage.clickCertifyButton(pnfMetaData.getName()); Assert.assertTrue(!UpgradeServicesPopup.isUpgradePopupShown()); - } - - @Test - public void upgradeAllottedVfOnServiceLevel() throws Throwable { - String propUUID = "depending_service_uuid"; - String propInvUUID = "depending_service_invariant_uuid"; - String propName = "depending_service_name"; - - //1. Create Service1, certify - Service service1 = createService(); - getExtendTest().log(Status.INFO, "Certify Service1"); - AtomicOperationUtils.changeComponentState(service1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - String serviceName = service1.getName(); - String serviceInvUUID = service1.getInvariantUUID(); - String serviceUUIDv1 = service1.getUUID(); - - //2. Import AllottedResource yaml, create VFC, certify - String fileName = "Allottedresource.yml"; - ResourceReqDetails vfcMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, - ResourceCategoryEnum.ALLOTTED_RESOURCE, getUser()); - ResourceUIUtils.importVfc(vfcMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickCertifyButton(vfcMetaData.getName()); - - //3. Create VF, add VFCi to canvas - ResourceReqDetails vfMetaData = createVFviaAPI(ResourceCategoryEnum.ALLOTTED_RESOURCE_TUNNEL_XCONNECT); + } + + @Test + public void upgradeAllottedVfOnServiceLevel() throws Throwable { + String propUUID = "depending_service_uuid"; + String propInvUUID = "depending_service_invariant_uuid"; + String propName = "depending_service_name"; + + //1. Create Service1, certify + Service service1 = createService(); + getExtendTest().log(Status.INFO, "Certify Service1"); + AtomicOperationUtils.changeComponentState(service1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + String serviceName = service1.getName(); + String serviceInvUUID = service1.getInvariantUUID(); + String serviceUUIDv1 = service1.getUUID(); + + //2. Import AllottedResource yaml, create VFC, certify + String fileName = "Allottedresource.yml"; + ResourceReqDetails vfcMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.ALLOTTED_RESOURCE, getUser()); + ResourceUIUtils.importVfc(vfcMetaData, filePath, fileName, getUser()); + ResourceGeneralPage.clickCertifyButton(vfcMetaData.getName()); + + //3. Create VF, add VFCi to canvas + ResourceReqDetails vfMetaData = createVFviaAPI(ResourceCategoryEnum.ALLOTTED_RESOURCE_TUNNEL_XCONNECT); CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager1 = CanvasManager.getCanvasManager(); - CanvasElement vfcElement1 = canvasManager1.createElementOnCanvas(vfcMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager1 = CanvasManager.getCanvasManager(); + CanvasElement vfcElement1 = canvasManager1.createElementOnCanvas(vfcMetaData.getName()); - //4. VF Properties Assignment: edit values of depending service properties, certify VF + //4. VF Properties Assignment: edit values of depending service properties, certify VF CompositionPage.moveToPropertiesScreen(); PropertiesAssignmentPage.findSearchBoxAndClick(propName); PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(propName), serviceName); @@ -237,52 +261,52 @@ public class UpgradeServices extends SetupCDTest{ PropertiesAssignmentPage.findSearchBoxAndClick(propInvUUID); PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(propInvUUID), serviceInvUUID); PropertiesAssignmentPage.clickOnSaveButton(); - ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); - - //5. Create Service2, add VFi to Service2, certify Service2 - Service service2 = createService(); - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - CanvasManager canvasManager2 = createCanvasManager(service2); - CanvasElement vfElement1 = canvasManager2.createElementOnCanvas(vfMetaData.getName()); - getExtendTest().log(Status.INFO, "Certify Service2"); - AtomicOperationUtils.changeComponentState(service2, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - - //6. Create Service3, add VFi to Service3, leave Service3 in checked-out state - Service service3 = createService(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - CanvasManager canvasManager3 = createCanvasManager(service3); - CanvasElement vfElement2 = canvasManager3.createElementOnCanvas(vfMetaData.getName()); - - //7. Check out and certify Service1 (keep new UUID) - AtomicOperationUtils.changeComponentState(service1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - AtomicOperationUtils.changeComponentState(service1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - service1 = AtomicOperationUtils.getServiceObject(service1.getUniqueId()); - String serviceUUIDv2 = service1.getUUID(); - - //8. Open Service1 and click “Upgrade Services” button - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - GeneralUIUtils.findComponentAndClick(service1.getName()); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.UPDATE_SERVICES_BUTTON.getValue()).click(); - - //9. Validate that Service2 can be upgraded (checked), Service3 is locked - //TODO - add validation in UI - - //10. Click Upgrade button - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPDATE_SERVICES_OK.getValue()); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPGRADE_SERVICES_CLOSE.getValue()); - - //11. Open VF, verify that version is 2.0 - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - VfVerificator.verifyVersionUI("2.0"); - - //12. VF properties assignment - verify that UUID value is updated, other values are the same - ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propUUID),serviceUUIDv2); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propInvUUID),serviceInvUUID); - PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propName),serviceName); - - //13. Open Service2, verify version 1.1 and state "in design check in", select VFi, verify version 2.0 + ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); + + //5. Create Service2, add VFi to Service2, certify Service2 + Service service2 = createService(); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CanvasManager canvasManager2 = createCanvasManager(service2); + CanvasElement vfElement1 = canvasManager2.createElementOnCanvas(vfMetaData.getName()); + getExtendTest().log(Status.INFO, "Certify Service2"); + AtomicOperationUtils.changeComponentState(service2, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + //6. Create Service3, add VFi to Service3, leave Service3 in checked-out state + Service service3 = createService(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + CanvasManager canvasManager3 = createCanvasManager(service3); + CanvasElement vfElement2 = canvasManager3.createElementOnCanvas(vfMetaData.getName()); + + //7. Check out and certify Service1 (keep new UUID) + AtomicOperationUtils.changeComponentState(service1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + AtomicOperationUtils.changeComponentState(service1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + service1 = AtomicOperationUtils.getServiceObject(service1.getUniqueId()); + String serviceUUIDv2 = service1.getUUID(); + + //8. Open Service1 and click “Upgrade Services” button + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service1.getName()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.UPDATE_SERVICES_BUTTON.getValue()).click(); + + //9. Validate that Service2 can be upgraded (checked), Service3 is locked + //TODO - add validation in UI + + //10. Click Upgrade button + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPDATE_SERVICES_OK.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPGRADE_SERVICES_CLOSE.getValue()); + + //11. Open VF, verify that version is 2.0 + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + VfVerificator.verifyVersionUI("2.0"); + + //12. VF properties assignment - verify that UUID value is updated, other values are the same + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propUUID), serviceUUIDv2); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propInvUUID), serviceInvUUID); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propName), serviceName); + + //13. Open Service2, verify version 1.1 and state "in design check in", select VFi, verify version 2.0 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); GeneralUIUtils.findComponentAndClick(service2.getName()); ServiceVerificator.verifyVersionUI("1.1"); @@ -293,146 +317,142 @@ public class UpgradeServices extends SetupCDTest{ ServiceVerificator.verifyResourceInstanceVersionUI("2.0"); //14. Open Service3, select VFi in composition, verify version 1.0 - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - GeneralUIUtils.findComponentAndClick(service3.getName()); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager5 = CanvasManager.getCanvasManager(); - canvasManager5.clickOnCanvaElement(vfElement2); - ServiceVerificator.verifyResourceInstanceVersionUI("1.0"); - } - - @Test - public void upgradeServiceProxyOnServiceLevel() throws Throwable { - //1. Create Port Mirroring Service1, certify - PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(true); - Service service1 = portMirrioringConfigurationObject.getService(); - Service serviceSource = portMirrioringConfigurationObject.getServiceContainerVmme_Source(); - CanvasElement pmcElement = portMirrioringConfigurationObject.getPortMirroringConfigurationElement(); - CanvasElement sourceElement = portMirrioringConfigurationObject.getServiceElementVmmeSourceName(); - Map capPropValues1 = portMirrioringConfigurationObject.getCapPropValues(); - certifyServiceInUI(service1); - service1 = AtomicOperationUtils.getServiceObject(service1.getUniqueId()); - String serviceSourceName = portMirrioringConfigurationObject.getServiceElementVmmeSourceName().getElementNameOnCanvas(); - String sourceUuidOrig = AtomicOperationUtils.getServiceComponentInstanceByName - (service1, serviceSourceName,true).getCustomizationUUID(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service3.getName()); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager5 = CanvasManager.getCanvasManager(); + canvasManager5.clickOnCanvaElement(vfElement2); + ServiceVerificator.verifyResourceInstanceVersionUI("1.0"); + } + + @Test + public void upgradeServiceProxyOnServiceLevel() throws Throwable { + //1. Create Port Mirroring Service1, certify + PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(true); + Service service1 = portMirrioringConfigurationObject.getService(); + Service serviceSource = portMirrioringConfigurationObject.getServiceContainerVmme_Source(); + CanvasElement pmcElement = portMirrioringConfigurationObject.getPortMirroringConfigurationElement(); + CanvasElement sourceElement = portMirrioringConfigurationObject.getServiceElementVmmeSourceName(); + Map capPropValues1 = portMirrioringConfigurationObject.getCapPropValues(); + certifyServiceInUI(service1); + service1 = AtomicOperationUtils.getServiceObject(service1.getUniqueId()); + String serviceSourceName = portMirrioringConfigurationObject.getServiceElementVmmeSourceName().getElementNameOnCanvas(); + String sourceUuidOrig = AtomicOperationUtils.getServiceComponentInstanceByName( + service1, serviceSourceName, true).getCustomizationUUID(); //2. Create Service2, add source service to it Service service2 = createService(); - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); CanvasManager canvasManager1 = createCanvasManager(service2); CanvasElement serviceSourceElement = canvasManager1.createElementOnCanvas(serviceSource.getName()); //3. Checkout and certify serviceSource - AtomicOperationUtils.changeComponentState(serviceSource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); - AtomicOperationUtils.changeComponentState(serviceSource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - serviceSource = AtomicOperationUtils.getServiceObject(serviceSource.getUniqueId()); - - //4. Open Service2, click Update button - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - GeneralUIUtils.findComponentAndClick(serviceSource.getName()); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.UPDATE_SERVICES_BUTTON.getValue()).click(); - - //5. Validate that Service1 can be upgraded (checked), Service2 is locked - //TODO - add validation in UI - - //6. Click Upgrade button - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPDATE_SERVICES_OK.getValue()); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPGRADE_SERVICES_CLOSE.getValue()); - - //7. Open Service1, verify version 1.1 and state "in design check in", select VFi, verify version 2.0 - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - GeneralUIUtils.findComponentAndClick(service1.getName()); - ServiceVerificator.verifyVersionUI("1.1"); - ServiceVerificator.verifyServiceLifecycleInUI(LifeCycleStateEnum.CHECKIN); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager2 = CanvasManager.getCanvasManager(); - canvasManager2.clickOnCanvaElement(serviceSourceElement); - ServiceVerificator.verifyResourceInstanceVersionUI("2.0"); - - //8. Verify that capabilities properties values are kept - canvasManager2.openLinkPopupReqsCapsConnection(sourceElement, pmcElement); //open connection wizard - Map capPropValues2 = canvasManager2.connectionWizardCollectCapPropValues(); //collect cap prop values - Assert.assertTrue(capPropValues1.equals(capPropValues2)); // compare cap prop values before and after changing VF version - canvasManager2.clickSaveOnLinkPopup(); - - //9. Verify that CustomizationUUID of service source instance is changed - service1.setVersion("1.1");//updated - service1 = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, service1.getName(), service1.getVersion()); - String sourceUuidUpd = AtomicOperationUtils.getServiceComponentInstanceByName - (service1, serviceSourceName,true).getCustomizationUUID(); - Assert.assertTrue(!sourceUuidOrig.equals(sourceUuidUpd)); - - //10. Open Service3, select VFi in composition, verify version 1.0 - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - GeneralUIUtils.findComponentAndClick(service2.getName()); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager3 = CanvasManager.getCanvasManager(); - canvasManager3.clickOnCanvaElement(serviceSourceElement); - ServiceVerificator.verifyResourceInstanceVersionUI("1.0"); - } - - - - - - - - private CanvasManager createCanvasManager(Service service1) throws Exception { - GeneralUIUtils.findComponentAndClick(service1.getName()); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - return CanvasManager.getCanvasManager(); - } - - private void certifyServiceInUI(Service service1) throws Exception { - getExtendTest().log(Status.INFO, "Certify Service"); - ServiceGeneralPage.clickSubmitForTestingButton(service1.getName()); - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(service1.getName()); - TesterOperationPage.certifyComponent(service1.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); - } - - private Service createService() throws Exception { - ServiceReqDetails serviceReqDetails1 = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); - getExtendTest().log(Status.INFO, "Create Service " + serviceReqDetails1.getName() ); - return AtomicOperationUtils.createCustomService(serviceReqDetails1, UserRoleEnum.DESIGNER, true).left().value(); - } - - private ResourceReqDetails createPnfAndCertify() throws Exception { - ResourceReqDetails pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser()); - ResourceUIUtils.createPNF(pnfMetaData, getUser()); - ResourceGeneralPage.clickCertifyButton(pnfMetaData.getName()); - return pnfMetaData; - } - - private Resource createAndCertifyVFfromVSP(String vnfFile) throws Exception { - String filePath = FileHandling.getPortMirroringRepositoryPath(); - getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - Resource vfResource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - vfResource = (Resource) AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - return vfResource; - } - - private ResourceReqDetails createCRAndCertify() throws Exception { - ResourceReqDetails crMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.CR, getUser()); - ResourceUIUtils.createCR(crMetaData, getUser()); - ResourceGeneralPage.clickCertifyButton(crMetaData.getName()); - return crMetaData; - } - - private ResourceReqDetails createVFviaAPI(ResourceCategoryEnum resourceCategory) { - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, resourceCategory, getUser()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating VF %s", vfMetaData.getName())); - AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value(); - return vfMetaData; - } - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + AtomicOperationUtils.changeComponentState(serviceSource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + AtomicOperationUtils.changeComponentState(serviceSource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + serviceSource = AtomicOperationUtils.getServiceObject(serviceSource.getUniqueId()); + + //4. Open Service2, click Update button + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(serviceSource.getName()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.UPDATE_SERVICES_BUTTON.getValue()).click(); + + //5. Validate that Service1 can be upgraded (checked), Service2 is locked + //TODO - add validation in UI + + //6. Click Upgrade button + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPDATE_SERVICES_OK.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPGRADE_SERVICES_CLOSE.getValue()); + + //7. Open Service1, verify version 1.1 and state "in design check in", select VFi, verify version 2.0 + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service1.getName()); + ServiceVerificator.verifyVersionUI("1.1"); + ServiceVerificator.verifyServiceLifecycleInUI(LifeCycleStateEnum.CHECKIN); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager2 = CanvasManager.getCanvasManager(); + canvasManager2.clickOnCanvaElement(serviceSourceElement); + ServiceVerificator.verifyResourceInstanceVersionUI("2.0"); + + //8. Verify that capabilities properties values are kept + canvasManager2.openLinkPopupReqsCapsConnection(sourceElement, pmcElement); //open connection wizard + Map capPropValues2 = canvasManager2.connectionWizardCollectCapPropValues(); //collect cap prop values + Assert.assertTrue(capPropValues1.equals(capPropValues2)); // compare cap prop values before and after changing VF version + canvasManager2.clickSaveOnLinkPopup(); + + //9. Verify that CustomizationUUID of service source instance is changed + service1.setVersion("1.1"); //updated + service1 = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, service1.getName(), service1.getVersion()); + String sourceUuidUpd = AtomicOperationUtils.getServiceComponentInstanceByName( + service1, serviceSourceName, true).getCustomizationUUID(); + Assert.assertTrue(!sourceUuidOrig.equals(sourceUuidUpd)); + + //10. Open Service3, select VFi in composition, verify version 1.0 + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service2.getName()); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager3 = CanvasManager.getCanvasManager(); + canvasManager3.clickOnCanvaElement(serviceSourceElement); + ServiceVerificator.verifyResourceInstanceVersionUI("1.0"); + } + + + private CanvasManager createCanvasManager(Service service1) throws Exception { + GeneralUIUtils.findComponentAndClick(service1.getName()); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + return CanvasManager.getCanvasManager(); + } + + private void certifyServiceInUI(Service service1) throws Exception { + getExtendTest().log(Status.INFO, "Certify Service"); + ServiceGeneralPage.clickSubmitForTestingButton(service1.getName()); + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(service1.getName()); + TesterOperationPage.certifyComponent(service1.getName()); + reloginWithNewRole(UserRoleEnum.DESIGNER); + } + + private Service createService() throws Exception { + ServiceReqDetails serviceReqDetails1 = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails); + getExtendTest().log(Status.INFO, "Create Service " + serviceReqDetails1.getName()); + return AtomicOperationUtils.createCustomService(serviceReqDetails1, UserRoleEnum.DESIGNER, true).left().value(); + } + + private ResourceReqDetails createPnfAndCertify() throws Exception { + ResourceReqDetails pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser()); + ResourceUIUtils.createPNF(pnfMetaData, getUser()); + ResourceGeneralPage.clickCertifyButton(pnfMetaData.getName()); + return pnfMetaData; + } + + private Resource createAndCertifyVFfromVSP(String vnfFile) throws Exception { + String filePath = FileHandling.getPortMirroringRepositoryPath(); + getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile); + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource vfResource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + vfResource = (Resource) AtomicOperationUtils.changeComponentState(vfResource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + return vfResource; + } + + private ResourceReqDetails createCRAndCertify() throws Exception { + ResourceReqDetails crMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.CR, getUser()); + ResourceUIUtils.createCR(crMetaData, getUser()); + ResourceGeneralPage.clickCertifyButton(crMetaData.getName()); + return crMetaData; + } + + private ResourceReqDetails createVFviaAPI(ResourceCategoryEnum resourceCategory) { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, resourceCategory, getUser()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating VF %s", vfMetaData.getName())); + AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value(); + return vfMetaData; + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java index 1c4aadeda7..d0ca864ae0 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,6 +21,7 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; +import org.apache.http.HttpStatus; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; @@ -36,7 +37,11 @@ import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; import org.openecomp.sdc.ci.tests.pages.HomePage; import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.utilities.DownloadManager; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.RestCDUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; @@ -53,320 +58,321 @@ import java.util.stream.Collectors; import static org.testng.Assert.assertTrue; public class VFCArtifacts extends SetupCDTest { - - private static final String DEPLOYMENT = "Deployment"; - private static final String INFORMATIONAL = "Informational"; - private static final String ARTIFACTS = "artifacts"; - private static final String DEPLOYMENT_ARTIFACTS = "deploymentArtifacts"; - private String filePath; - @BeforeClass - public void beforeClass(){ - filePath = FileHandling.getFilePath("VFCArtifacts"); - } - - @Test - public void ImportMultiVFCTest_TC1407998() throws Exception{ - - String csarFile = "Import_Multi_VFC.csar"; - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - resourceMetaData.setVersion("0.1"); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); - - RestResponse getResponse = RestCDUtils.getResource(resourceMetaData, getUser()); - assertTrue(getResponse.getErrorCode().intValue() == 200); - - Map> expectedArtifactMap = verifyVfcArtifacts(filePath, csarFile, resourceMetaData, getResponse); - - VFCArtifactVerificator.verifyVFCArtifactsNotInVFArtifactList(resourceMetaData, getUser(), getResponse, expectedArtifactMap); - - - } - - @Test - public void updateCsarWithVFCArtifacts_ModifyArtifacts_TC1449482() throws Exception{ - - String csarFile = "LDSA-ORIG.csar"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - resourceMetaData.setVersion("0.1"); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); - - Map artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile); - List vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); - for (String key : vfcKeys){ - VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser()); - } - - String updatedCsarFile = "LDSA-MODIFY.csar"; - ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile); - - Map updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile); - List updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); - for (String key : updatedVfcKeys){ - verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key); - VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser()); - } - } - - @Test - public void updateCsarWithVFCArtifacts_DeleteAndAddArtifacts_TC1449473() throws Exception{ - - String csarFile = "LDSA-ORIG.csar"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - resourceMetaData.setVersion("0.1"); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); - - String updatedCsarFile = "LDSA-DELETE-ADD.csar"; - ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile); - - verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null); - } - - @Test - public void updateCsarWithVFCArtifacts_AddFirstVFCIdentifier_TC1425896() throws Exception{ - - String csarFile = "LDSA-ORIG-OLD_STRUCTURE.csar"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - resourceMetaData.setVersion("0.1"); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); - - VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile); - String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile); - DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen(); - - String updatedCsarFile = "LDSA-ADD.csar"; - ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile); - - verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate); - } - - - @Test - public void updateCsarWithVFCArtifacts_AddAdditionalVFCIdentifier_TC1425898() throws Exception{ - - String csarFile = "LDSA-SINGLE.csar"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - resourceMetaData.setVersion("0.1"); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); - - Map artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile); - List vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); - for (String key : vfcKeys){ - VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser()); - } - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile); - String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile); - DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen(); - - String updatedCsarFile = "LDSA-MULTI.csar"; - ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile); - - Map updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile); - List updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); - for (String key : updatedVfcKeys){ - verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key); - if (vfcKeys.contains(key)){ - VFCArtifactVerificator.verifyVFCArtifactNotChanged(key, resourceMetaData, getUser()); - } - } - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate); - } - - @Test - public void updateCsarWithVFCArtifacts_DeleteAll_TC1425581() throws Exception{ - - String csarFile = "LDSA-ORIG.csar"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); - resourceMetaData.setVersion("0.1"); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile); - String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile); - DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen(); - - String updatedCsarFile = "LDSA-DELETE-ALL.csar"; - ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile); - - VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate); - } - - @Test - public void importComplexVFCArtifacts_Onboarding_TC1484153() throws Exception{ - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; - String snmpFile = "Fault-alarms-ASDC-vprobes-vLB.zip"; - - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); - String vspName = createVSP.getName(); - resourceMetaData.setName(vspName); + + private static final String DEPLOYMENT = "Deployment"; + private static final String INFORMATIONAL = "Informational"; + private static final String ARTIFACTS = "artifacts"; + private static final String DEPLOYMENT_ARTIFACTS = "deploymentArtifacts"; + private String filePath; + + @BeforeClass + public void beforeClass() { + filePath = FileHandling.getFilePath("VFCArtifacts"); + } + + @Test + public void ImportMultiVFCTest_TC1407998() throws Exception { + + String csarFile = "Import_Multi_VFC.csar"; + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + resourceMetaData.setVersion("0.1"); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); + + RestResponse getResponse = RestCDUtils.getResource(resourceMetaData, getUser()); + assertTrue(getResponse.getErrorCode().intValue() == HttpStatus.SC_OK); + + Map> expectedArtifactMap = verifyVfcArtifacts(filePath, csarFile, resourceMetaData, getResponse); + + VFCArtifactVerificator.verifyVFCArtifactsNotInVFArtifactList(resourceMetaData, getUser(), getResponse, expectedArtifactMap); + + + } + + @Test + public void updateCsarWithVFCArtifacts_ModifyArtifacts_TC1449482() throws Exception { + + String csarFile = "LDSA-ORIG.csar"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + resourceMetaData.setVersion("0.1"); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); + + Map artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile); + List vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); + for (String key : vfcKeys) { + VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser()); + } + + String updatedCsarFile = "LDSA-MODIFY.csar"; + ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile); + + Map updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile); + List updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); + for (String key : updatedVfcKeys) { + verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key); + VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser()); + } + } + + @Test + public void updateCsarWithVFCArtifacts_DeleteAndAddArtifacts_TC1449473() throws Exception { + + String csarFile = "LDSA-ORIG.csar"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + resourceMetaData.setVersion("0.1"); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); + + String updatedCsarFile = "LDSA-DELETE-ADD.csar"; + ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile); + + verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null); + } + + @Test + public void updateCsarWithVFCArtifacts_AddFirstVFCIdentifier_TC1425896() throws Exception { + + String csarFile = "LDSA-ORIG-OLD_STRUCTURE.csar"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + resourceMetaData.setVersion("0.1"); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); + + VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile); + String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile); + DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen(); + + String updatedCsarFile = "LDSA-ADD.csar"; + ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile); + + verifyVfcArtifacts(filePath, updatedCsarFile, resourceMetaData, null); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate); + } + + + @Test + public void updateCsarWithVFCArtifacts_AddAdditionalVFCIdentifier_TC1425898() throws Exception { + + String csarFile = "LDSA-SINGLE.csar"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + resourceMetaData.setVersion("0.1"); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); + + Map artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + csarFile); + List vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); + for (String key : vfcKeys) { + VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser()); + } + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile); + String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile); + DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen(); + + String updatedCsarFile = "LDSA-MULTI.csar"; + ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile); + + Map updatedArtifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filePath + updatedCsarFile); + List updatedVfcKeys = updatedArtifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); + for (String key : updatedVfcKeys) { + verifyVfcInstanceArtifacts(resourceMetaData, null, updatedArtifactsFromCsar, key); + if (vfcKeys.contains(key)) { + VFCArtifactVerificator.verifyVFCArtifactNotChanged(key, resourceMetaData, getUser()); + } + } + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate); + } + + @Test + public void updateCsarWithVFCArtifacts_DeleteAll_TC1425581() throws Exception { + + String csarFile = "LDSA-ORIG.csar"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString()); + resourceMetaData.setVersion("0.1"); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, csarFile, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + String[] artifactNamesFromFile = ArtifactFromCsar.getArtifactNamesFromCsar(filePath, csarFile); + String[] artifactsFromFileBeforeUpdate = DeploymentArtifactPage.verifyArtifactsExistInTable(artifactNamesFromFile); + DeploymentArtifactPage.getLeftMenu().moveToGeneralScreen(); + + String updatedCsarFile = "LDSA-DELETE-ALL.csar"; + ResourceUIUtils.updateVfWithCsar(filePath, updatedCsarFile); + + VFCArtifactVerificator.verifyNoVfcArtifacts(resourceMetaData, getUser(), null); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + DeploymentArtifactPage.verifyArtifactsExistInTable(artifactsFromFileBeforeUpdate); + } + + @Test + public void importComplexVFCArtifacts_Onboarding_TC1484153() throws Exception { + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; + String snmpFile = "Fault-alarms-ASDC-vprobes-vLB.zip"; + + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); + VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); + String vspName = createVSP.getName(); + resourceMetaData.setName(vspName); // VendorSoftwareProductObject resourceMeta = createVSP.right; - String vspid = createVSP.getVspId(); - VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, createVSP, getUser()); - VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true); - - String downloadDirectory = getWindowTest().getDownloadDirectory(); - String csarFile = vspid + ".csar"; - - DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); - HomePage.showVspRepository(); - OnboardingUiUtils.importVSP(createVSP); - resourceMetaData.setVersion("0.1"); - - verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile); - - } - - @Test - public void updateComplexVFCArtifacts_AddRemove_Onboarding_TC1484185() throws Exception{ - - //check of version is 1 - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; - String snmpPollFile = "vprobes-vLB.zip"; - String updatedSnmpPollFile = "vprobes-vLBAgent.zip"; - - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); - String vspName = createVSP.getName(); - resourceMetaData.setName(vspName); - String vspid = createVSP.getVspId(); - String monitoringComponentId = VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpPollFile, null, createVSP, getUser()); - VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true); - - String downloadDirectory = getWindowTest().getDownloadDirectory(); - String csarFile = vspid + ".csar"; - - DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); - HomePage.showVspRepository(); - OnboardingUiUtils.importVSP(createVSP); - ResourceGeneralPage.clickCertifyButton(vspName); - - VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpPollFile, null, monitoringComponentId, getUser(), createVSP); - DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); - HomePage.showVspRepository(); - OnboardingUiUtils.updateVSP(createVSP); - resourceMetaData.setVersion("1.1"); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile); - - verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null); - - } - - @Test - public void updateComplexVFCArtifacts_Modify_Onboarding_TC1484195() throws Exception{ - - //check of version is 2 - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; - String snmpFile = "vprobes-vLB.zip"; - String updatedSnmpFile = "vprobes-vLB-Modified.zip"; - - AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); - String vspName = createVSP.getName(); - resourceMetaData.setName(vspName); - String vspid = createVSP.getVspId(); - String monitoringId = VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, createVSP, getUser()); - VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true); - - String downloadDirectory = getWindowTest().getDownloadDirectory(); - String csarFile = vspid + ".csar"; - - DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); - HomePage.showVspRepository(); - OnboardingUiUtils.importVSP(createVSP); - - Map artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile); - List vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); - for (String key : vfcKeys){ - resourceMetaData.setVersion("0.1"); - VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser()); - } - - ResourceGeneralPage.clickCertifyButton(vspName); - VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpFile, null, monitoringId, getUser(), createVSP); - DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); - HomePage.showVspRepository(); - OnboardingUiUtils.updateVSP(createVSP); - resourceMetaData.setVersion("1.1"); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile); - - Map artifactsFromCsarAfterUpdate = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile); - List vfcKeysAfterUpdate = artifactsFromCsarAfterUpdate.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); - for (String key : vfcKeysAfterUpdate){ - verifyVfcInstanceArtifacts(resourceMetaData, null, artifactsFromCsarAfterUpdate, key); - VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser()); - } - - } - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } - - private Map> verifyVfcArtifacts(String filepath, String csarFile, - ResourceReqDetails resourceMetaData, RestResponse getResponse) throws Exception { - - ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts"); - Map> expectedArtifactMap = null; - ExtentTestActions.log(Status.INFO, "Reading artifacts in CSAR file"); - Map artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filepath + csarFile); - List vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); - for (String key : vfcKeys){ - expectedArtifactMap = verifyVfcInstanceArtifacts(resourceMetaData, getResponse, artifactsFromCsar, key); - } - return expectedArtifactMap; - } - - private Map> verifyVfcInstanceArtifacts( - ResourceReqDetails resourceMetaData, RestResponse getResponse, Map artifactsFromCsar, String key) { - - Map> expectedArtifactMap; - Map> vfcDeploymentArtifacts = (Map>)artifactsFromCsar.get(key); - LinkedList deploymentList = vfcDeploymentArtifacts.get(DEPLOYMENT); - LinkedList informationalList = (LinkedList) vfcDeploymentArtifacts.get(INFORMATIONAL); - - expectedArtifactMap = new HashMap>(); - if(deploymentList == null){ - expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, new LinkedList()); - }else{ - expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, deploymentList); - } - if(informationalList == null){ - expectedArtifactMap.put(ARTIFACTS, new LinkedList()); - }else{ - expectedArtifactMap.put(ARTIFACTS, informationalList); - } - - VFCArtifactVerificator.verifyVfcArtifacts(resourceMetaData, getUser(), key, expectedArtifactMap, getResponse); - return expectedArtifactMap; - } + String vspid = createVSP.getVspId(); + VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, createVSP, getUser()); + VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true); + + String downloadDirectory = getWindowTest().getDownloadDirectory(); + String csarFile = vspid + ".csar"; + + DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); + HomePage.showVspRepository(); + OnboardingUiUtils.importVSP(createVSP); + resourceMetaData.setVersion("0.1"); + + verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile); + + } + + @Test + public void updateComplexVFCArtifacts_AddRemove_Onboarding_TC1484185() throws Exception { + + //check of version is 1 + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; + String snmpPollFile = "vprobes-vLB.zip"; + String updatedSnmpPollFile = "vprobes-vLBAgent.zip"; + + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); + VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); + String vspName = createVSP.getName(); + resourceMetaData.setName(vspName); + String vspid = createVSP.getVspId(); + String monitoringComponentId = VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpPollFile, null, createVSP, getUser()); + VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true); + + String downloadDirectory = getWindowTest().getDownloadDirectory(); + String csarFile = vspid + ".csar"; + + DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); + HomePage.showVspRepository(); + OnboardingUiUtils.importVSP(createVSP); + ResourceGeneralPage.clickCertifyButton(vspName); + + VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpPollFile, null, monitoringComponentId, getUser(), createVSP); + DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); + HomePage.showVspRepository(); + OnboardingUiUtils.updateVSP(createVSP); + resourceMetaData.setVersion("1.1"); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile); + + verifyVfcArtifacts(downloadDirectory, csarFile, resourceMetaData, null); + + } + + @Test + public void updateComplexVFCArtifacts_Modify_Onboarding_TC1484195() throws Exception { + + //check of version is 2 + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + String vnfFile = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; + String snmpFile = "vprobes-vLB.zip"; + String updatedSnmpFile = "vprobes-vLB-Modified.zip"; + + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); + VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); + String vspName = createVSP.getName(); + resourceMetaData.setName(vspName); + String vspid = createVSP.getVspId(); + String monitoringId = VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, createVSP, getUser()); + VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), createVSP, true); + + String downloadDirectory = getWindowTest().getDownloadDirectory(); + String csarFile = vspid + ".csar"; + + DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); + HomePage.showVspRepository(); + OnboardingUiUtils.importVSP(createVSP); + + Map artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile); + List vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); + for (String key : vfcKeys) { + resourceMetaData.setVersion("0.1"); + VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser()); + } + + ResourceGeneralPage.clickCertifyButton(vspName); + VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpFile, null, monitoringId, getUser(), createVSP); + DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); + HomePage.showVspRepository(); + OnboardingUiUtils.updateVSP(createVSP); + resourceMetaData.setVersion("1.1"); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, vnfFile); + + Map artifactsFromCsarAfterUpdate = ArtifactFromCsar.getVFCArtifacts(downloadDirectory + csarFile); + List vfcKeysAfterUpdate = artifactsFromCsarAfterUpdate.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); + for (String key : vfcKeysAfterUpdate) { + verifyVfcInstanceArtifacts(resourceMetaData, null, artifactsFromCsarAfterUpdate, key); + VFCArtifactVerificator.verifyVfcArtifactUpdated(key, resourceMetaData, getUser()); + } + + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } + + private Map> verifyVfcArtifacts(String filepath, String csarFile, + ResourceReqDetails resourceMetaData, RestResponse getResponse) throws Exception { + + ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts"); + Map> expectedArtifactMap = null; + ExtentTestActions.log(Status.INFO, "Reading artifacts in CSAR file"); + Map artifactsFromCsar = ArtifactFromCsar.getVFCArtifacts(filepath + csarFile); + List vfcKeys = artifactsFromCsar.keySet().stream().filter(p -> p.contains("vfc")).collect(Collectors.toList()); + for (String key : vfcKeys) { + expectedArtifactMap = verifyVfcInstanceArtifacts(resourceMetaData, getResponse, artifactsFromCsar, key); + } + return expectedArtifactMap; + } + + private Map> verifyVfcInstanceArtifacts( + ResourceReqDetails resourceMetaData, RestResponse getResponse, Map artifactsFromCsar, String key) { + + Map> expectedArtifactMap; + Map> vfcDeploymentArtifacts = (Map>) artifactsFromCsar.get(key); + LinkedList deploymentList = vfcDeploymentArtifacts.get(DEPLOYMENT); + LinkedList informationalList = (LinkedList) vfcDeploymentArtifacts.get(INFORMATIONAL); + + expectedArtifactMap = new HashMap>(); + if (deploymentList == null) { + expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, new LinkedList()); + } else { + expectedArtifactMap.put(DEPLOYMENT_ARTIFACTS, deploymentList); + } + if (informationalList == null) { + expectedArtifactMap.put(ARTIFACTS, new LinkedList()); + } else { + expectedArtifactMap.put(ARTIFACTS, informationalList); + } + + VFCArtifactVerificator.verifyVfcArtifacts(resourceMetaData, getUser(), key, expectedArtifactMap, getResponse); + return expectedArtifactMap; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java index e6e4b724b5..859d6285cf 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,18 +25,34 @@ import org.openecomp.sdc.be.dao.api.ActionStatus; 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.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ArtifactPageEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InformationalArtifactsPlaceholders; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ResourceMetadataEnum; +import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage; +import org.openecomp.sdc.ci.tests.pages.PropertiesPage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ToscaArtifactsPage; +import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; @@ -51,483 +67,478 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.awt.*; +import java.io.IOException; import java.util.ArrayList; import java.util.List; public class Vf extends SetupCDTest { - private String filePath; - @BeforeClass - public void beforeClass(){ - filePath = FileHandling.getFilePath(""); - } - - @BeforeMethod - public void beforeTest(){ - System.out.println("File repository is : " + filePath); - getExtendTest().log(Status.INFO, "File repository is : " + filePath); - } - - - @Test - public void vfcLinkedToComputeInVfFlow() throws Exception { - String fileName = "vFW_VFC2.yml"; - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - - try{ - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); - - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(String.format("%s %s", LeftPanelCanvasItems.COMPUTE.getValue() , "1.0")); - CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - CanvasElement cpElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - AssertJUnit.assertNotNull(cpElement); - ServiceVerificator.verifyNumOfComponentInstances(vfMetaData, "0.1", 2, getUser()); - - canvasManager.linkElements(computeElement.getElementNameOnCanvas() , cpElement.getElementNameOnCanvas()); - - vfMetaData.setVersion("0.1"); - VfVerificator.verifyLinkCreated(vfMetaData, getUser(), 1); - } - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); - } - - } - - @Test - public void addUpdateDeleteDeploymentArtifactToVfTest() throws Exception { - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - - List deploymentArtifactList = new ArrayList<>(); - deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); - deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML")); - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); - } - AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); - - String newDescription = "new description"; - DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel()); - DeploymentArtifactPage.artifactPopup().insertDescription(newDescription); - DeploymentArtifactPage.artifactPopup().clickDoneButton(); - String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel()); - AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); - - DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel()); - DeploymentArtifactPage.clickOK(); - AssertJUnit.assertTrue("artifact "+ deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1)); - - AssertJUnit.assertTrue("artifact "+ deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed()); - } - - - @Test - public void addUpdateDeleteInformationalArtifact() throws Exception { - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); - InformationalArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); - - AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1)); - - String newDescription = "new description"; - InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel()); - InformationalArtifactPage.artifactPopup().insertDescription(newDescription); - InformationalArtifactPage.artifactPopup().clickDoneButton(); - String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel()); - AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); - - InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel()); - InformationalArtifactPage.clickOK(); - AssertJUnit.assertTrue("artifact "+ informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0)); - } - - - @Test - public void addPropertiesToVfcInstanceInVfTest() throws Exception { - - if(true){ + private String filePath; + + @BeforeClass + public void beforeClass() { + filePath = FileHandling.getFilePath(""); + } + + @BeforeMethod + public void beforeTest() { + System.out.println("File repository is : " + filePath); + getExtendTest().log(Status.INFO, "File repository is : " + filePath); + } + + + @Test + public void vfcLinkedToComputeInVfFlow() throws Exception { + String fileName = "vFW_VFC2.yml"; + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + + try { + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); + + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(String.format("%s %s", LeftPanelCanvasItems.COMPUTE.getValue(), "1.0")); + CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + CanvasElement cpElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + AssertJUnit.assertNotNull(cpElement); + ServiceVerificator.verifyNumOfComponentInstances(vfMetaData, "0.1", 2, getUser()); + + canvasManager.linkElements(computeElement.getElementNameOnCanvas(), cpElement.getElementNameOnCanvas()); + + vfMetaData.setVersion("0.1"); + VfVerificator.verifyLinkCreated(vfMetaData, getUser(), 1); + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); + } + + } + + @Test + public void addUpdateDeleteDeploymentArtifactToVfTest() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + List deploymentArtifactList = new ArrayList<>(); + deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); + deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML")); + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); + } + AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); + + String newDescription = "new description"; + DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel()); + DeploymentArtifactPage.artifactPopup().insertDescription(newDescription); + DeploymentArtifactPage.artifactPopup().clickDoneButton(); + String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel()); + AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); + + DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel()); + DeploymentArtifactPage.clickOK(); + AssertJUnit.assertTrue("artifact " + deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1)); + + AssertJUnit.assertTrue("artifact " + deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed()); + } + + + @Test + public void addUpdateDeleteInformationalArtifact() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + + ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); + InformationalArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); + + AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1)); + + String newDescription = "new description"; + InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel()); + InformationalArtifactPage.artifactPopup().insertDescription(newDescription); + InformationalArtifactPage.artifactPopup().clickDoneButton(); + String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel()); + AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); + + InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel()); + InformationalArtifactPage.clickOK(); + AssertJUnit.assertTrue("artifact " + informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0)); + } + + + @Test + public void addPropertiesToVfcInstanceInVfTest() throws Exception { + + if (true) { // throw new SkipException("Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); - SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); - } - - String fileName = "vFW_VFC.yml"; - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - - try{ - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - - vfCanvasManager.clickOnCanvaElement(vfcElement); - CompositionPage.showPropertiesAndAttributesTab(); - List properties = CompositionPage.getProperties(); - String propertyValue = "abc123"; - for (int i = 0; i < 2; i++) { - WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label")); - findElement.click(); - PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue); - PropertiesPage.getPropertyPopup().clickSave(); - - - findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value")); - AssertJUnit.assertTrue(findElement.getText().equals(propertyValue)); - } - } - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); - } - } - - @Test - public void changeInstanceVersionTest() throws Exception{ - - ResourceReqDetails atomicResourceMetaData = null; - ResourceReqDetails vfMetaData = null; - CanvasManager vfCanvasManager; - CanvasElement vfcElement = null; - String fileName = "vFW_VFC3.yml"; - try{ - atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - - vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - - CompositionPage.clickCertifyButton(vfMetaData.getName()); - assert(false); - } - catch(Exception e){ - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); - AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError)); - - - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "1.0"); - - //verfication - VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0"); - } - - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); - } - - } - - - @Test - public void addAllInformationalArtifactPlaceholdersInVfTest() throws Exception{ - - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){ - ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, filePath,"asc_heat 0 2.yaml", informArtifact.getValue()); - } - - AssertJUnit.assertTrue(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)); - } - - @Test - public void verifyToscaArtifactsExist() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - final int numOfToscaArtifacts = 2; - ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); - AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts)); - - for(int i = 0; i < numOfToscaArtifacts; i++){ - String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); - AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); - } - ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName()); - VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser()); - } - - @Test - public void vfCertificationTest() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - String vfName = vfMetaData.getName(); - - ResourceGeneralPage.clickCheckinButton(vfName); - GeneralUIUtils.findComponentAndClick(vfName); - ResourceGeneralPage.clickCertifyButton(vfName); - - vfMetaData.setVersion("1.0"); - VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - - GeneralUIUtils.findComponentAndClick(vfName); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); - } - - @Test - public void deleteVfCheckedoutTest() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - GeneralPageElements.clickTrashButtonAndConfirm(); - - vfMetaData.setVersion("0.1"); - VfVerificator.verifyVfDeleted(vfMetaData, getUser()); - } - - @Test - public void revertVfMetadataTest() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceReqDetails vfRevertDetails = new ResourceReqDetails(); - vfRevertDetails.setName("ciUpdatedName"); - vfRevertDetails.setDescription("kuku"); - vfRevertDetails.setCategories(vfMetaData.getCategories()); - vfRevertDetails.setVendorName("updatedVendor"); - vfRevertDetails.setVendorRelease("updatedRelease"); - ResourceUIUtils.fillResourceGeneralInformationPage(vfRevertDetails, getUser(), false); - - GeneralPageElements.clickRevertButton(); - - VfVerificator.verifyVFMetadataInUI(vfMetaData); - - } - - @Test - public void addDeploymentArtifactInCompositionScreenTest() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3","OTHER"); - CompositionPage.showDeploymentArtifactTab(); - CompositionPage.clickAddArtifactButton(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); - - List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className("i-sdc-designer-sidebar-section-content-item-artifact")); - AssertJUnit.assertEquals(1, actualArtifactList.size()); - } - - // future removed from ui - - @Test - public void addDeploymentArtifactAndVerifyInCompositionScreen() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - - ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); - AssertJUnit.assertTrue(DeploymentArtifactPage.checkElementsCountInTable(1)); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - CompositionPage.showDeploymentArtifactTab(); - List deploymentArtifactsFromScreen = CompositionPage.getDeploymentArtifacts(); - AssertJUnit.assertTrue(1 == deploymentArtifactsFromScreen.size()); - - String actualArtifactFileName = deploymentArtifactsFromScreen.get(0).getText(); - AssertJUnit.assertTrue("asc_heat-0-2.yaml".equals(actualArtifactFileName)); - } - - @Test - public void checkoutVfTest() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - GeneralPageElements.clickCheckoutButton(); - - vfMetaData.setVersion("0.2"); - VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - - ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - ResourceGeneralPage.clickCheckoutButton(); - - vfMetaData.setVersion("1.1"); - vfMetaData.setUniqueId(null); - VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - } - - @Test - public void deleteInstanceFromVfCanvas() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - CanvasElement portElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.PORT); - - vfCanvasManager.clickOnCanvaElement(computeElement); - vfCanvasManager.deleteElementFromCanvas(computeElement); - - VfVerificator.verifyNumOfComponentInstances(vfMetaData, 1, getUser()); - } - - @Test - public void changeInstanceNameInVfTest() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - - String updatedInstanceName = "updatedName"; - vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName); - - String actualSelectedInstanceName = CompositionPage.getSelectedInstanceName(); - AssertJUnit.assertTrue(updatedInstanceName.equals(actualSelectedInstanceName)); - } - - - @Test - public void submitVfForTestingWithNonCertifiedAsset() throws Exception{ - String fileName = "vFW_VFC4.yml"; - - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); - - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - - try{ - CompositionPage.clickCertifyButton(vfMetaData.getName()); - assert(false); - } - catch(Exception e){ - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); - AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError)); - } - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); - } - } - - @Test - public void isDisabledAndReadOnlyInCheckin() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - ResourceMetadataEnum[] fieldsForCheck = {ResourceMetadataEnum.RESOURCE_NAME, - ResourceMetadataEnum.DESCRIPTION, ResourceMetadataEnum.VENDOR_NAME, ResourceMetadataEnum.VENDOR_RELEASE, - ResourceMetadataEnum.CONTACT_ID}; - - for (ResourceMetadataEnum field: fieldsForCheck){ - AssertJUnit.assertTrue(GeneralUIUtils.isElementReadOnly(field.getValue())); - } - - AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(ResourceMetadataEnum.CATEGORY.getValue())); - AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue())); - } - - @Test - public void exportToscaWithModulePropertiesVFTest() throws AWTException, Exception { - String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip"; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vendorSoftwareProductObject= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); - String vspName = vendorSoftwareProductObject.getName(); - ResourceGeneralPage.clickSubmitForTestingButton(vspName); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); - VfModuleVerificator.validateSpecificModulePropertiesFromRequest(resource); - } - - @Test - public void canvasTestJS() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - CanvasElement portElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.PORT); - - canvasManager.linkElements(computeElement.getElementNameOnCanvas(), portElement.getElementNameOnCanvas()); - - } - - @Test - public void addVesEventsDeploymentArtifactToVfAndCheckMagnifierTest() throws Exception { - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - - List deploymentArtifactList = new ArrayList<>(); - ArtifactInfo art1 = new ArtifactInfo(filePath, "fm_metadata_three_fault_defs.yml", "desc", "artifactfault", "VES_EVENTS"); - deploymentArtifactList.add(art1); - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); - } - AssertJUnit.assertTrue(DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); - - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on magnifier button %s", art1.getArtifactLabel())); - WebElement magnifierButtonElement = GeneralUIUtils.getWebElementByTestID(ArtifactPageEnum.BROWSE_ARTIFACT.getValue() + art1.getArtifactLabel()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Found magnifier button: %s", magnifierButtonElement.getText())); - magnifierButtonElement.click(); - List headers = GeneralUIUtils.getWebElementsListByClassName("datatable-header-cell"); - AssertJUnit.assertEquals(3, headers.size()); - headers.get(0).getText(); - List rows = GeneralUIUtils.getWebElementsListByContainsClassName("datatable-body-row"); - AssertJUnit.assertEquals(3, rows.size()); - } - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance on Composition screen"); + } + + String fileName = "vFW_VFC.yml"; + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + + try { + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + + vfCanvasManager.clickOnCanvaElement(vfcElement); + CompositionPage.showPropertiesAndAttributesTab(); + List properties = CompositionPage.getProperties(); + String propertyValue = "abc123"; + for (int i = 0; i < 2; i++) { + WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label")); + findElement.click(); + PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue); + PropertiesPage.getPropertyPopup().clickSave(); + + + findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value")); + AssertJUnit.assertTrue(findElement.getText().equals(propertyValue)); + } + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); + } + } + + @Test + public void changeInstanceVersionTest() throws Exception { + + ResourceReqDetails atomicResourceMetaData = null; + ResourceReqDetails vfMetaData = null; + CanvasManager vfCanvasManager; + CanvasElement vfcElement = null; + String fileName = "vFW_VFC3.yml"; + try { + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + + vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + + CompositionPage.clickCertifyButton(vfMetaData.getName()); + assert (false); + } catch (Exception e) { + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); + AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError)); + + + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "1.0"); + + //verfication + VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0"); + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); + } + + } + + + @Test + public void addAllInformationalArtifactPlaceholdersInVfTest() throws Exception { + + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + + for (InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()) { + ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, filePath, "asc_heat 0 2.yaml", informArtifact.getValue()); + } + + AssertJUnit.assertTrue(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)); + } + + @Test + public void verifyToscaArtifactsExist() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + final int numOfToscaArtifacts = 2; + ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); + AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts)); + + for (int i = 0; i < numOfToscaArtifacts; i++) { + String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); + AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); + } + ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName()); + VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser()); + } + + @Test + public void vfCertificationTest() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + String vfName = vfMetaData.getName(); + + ResourceGeneralPage.clickCheckinButton(vfName); + GeneralUIUtils.findComponentAndClick(vfName); + ResourceGeneralPage.clickCertifyButton(vfName); + + vfMetaData.setVersion("1.0"); + VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); + + GeneralUIUtils.findComponentAndClick(vfName); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); + } + + @Test + public void deleteVfCheckedoutTest() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + GeneralPageElements.clickTrashButtonAndConfirm(); + + vfMetaData.setVersion("0.1"); + VfVerificator.verifyVfDeleted(vfMetaData, getUser()); + } + + @Test + public void revertVfMetadataTest() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceReqDetails vfRevertDetails = new ResourceReqDetails(); + vfRevertDetails.setName("ciUpdatedName"); + vfRevertDetails.setDescription("kuku"); + vfRevertDetails.setCategories(vfMetaData.getCategories()); + vfRevertDetails.setVendorName("updatedVendor"); + vfRevertDetails.setVendorRelease("updatedRelease"); + ResourceUIUtils.fillResourceGeneralInformationPage(vfRevertDetails, getUser(), false); + + GeneralPageElements.clickRevertButton(); + + VfVerificator.verifyVFMetadataInUI(vfMetaData); + + } + + @Test + public void addDeploymentArtifactInCompositionScreenTest() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3", "OTHER"); + CompositionPage.showDeploymentArtifactTab(); + CompositionPage.clickAddArtifactButton(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); + + List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className("i-sdc-designer-sidebar-section-content-item-artifact")); + AssertJUnit.assertEquals(1, actualArtifactList.size()); + } + + // future removed from ui + + @Test + public void addDeploymentArtifactAndVerifyInCompositionScreen() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); + AssertJUnit.assertTrue(DeploymentArtifactPage.checkElementsCountInTable(1)); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + CompositionPage.showDeploymentArtifactTab(); + List deploymentArtifactsFromScreen = CompositionPage.getDeploymentArtifacts(); + AssertJUnit.assertTrue(1 == deploymentArtifactsFromScreen.size()); + + String actualArtifactFileName = deploymentArtifactsFromScreen.get(0).getText(); + AssertJUnit.assertTrue("asc_heat-0-2.yaml".equals(actualArtifactFileName)); + } + + @Test + public void checkoutVfTest() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + GeneralPageElements.clickCheckoutButton(); + + vfMetaData.setVersion("0.2"); + VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + + ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); + + vfMetaData.setVersion("1.1"); + vfMetaData.setUniqueId(null); + VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); + } + + @Test + public void deleteInstanceFromVfCanvas() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); + CanvasElement portElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.PORT); + + vfCanvasManager.clickOnCanvaElement(computeElement); + vfCanvasManager.deleteElementFromCanvas(computeElement); + + VfVerificator.verifyNumOfComponentInstances(vfMetaData, 1, getUser()); + } + + @Test + public void changeInstanceNameInVfTest() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); + + String updatedInstanceName = "updatedName"; + vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName); + + String actualSelectedInstanceName = CompositionPage.getSelectedInstanceName(); + AssertJUnit.assertTrue(updatedInstanceName.equals(actualSelectedInstanceName)); + } + + + @Test + public void submitVfForTestingWithNonCertifiedAsset() throws Exception { + String fileName = "vFW_VFC4.yml"; + + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); + + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + + try { + CompositionPage.clickCertifyButton(vfMetaData.getName()); + assert (false); + } catch (Exception e) { + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name()); + AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError)); + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); + } + } + + @Test + public void isDisabledAndReadOnlyInCheckin() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + ResourceMetadataEnum[] fieldsForCheck = {ResourceMetadataEnum.RESOURCE_NAME, + ResourceMetadataEnum.DESCRIPTION, ResourceMetadataEnum.VENDOR_NAME, ResourceMetadataEnum.VENDOR_RELEASE, + ResourceMetadataEnum.CONTACT_ID}; + + for (ResourceMetadataEnum field : fieldsForCheck) { + AssertJUnit.assertTrue(GeneralUIUtils.isElementReadOnly(field.getValue())); + } + + AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(ResourceMetadataEnum.CATEGORY.getValue())); + AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue())); + } + + @Test + public void exportToscaWithModulePropertiesVFTest() throws Exception { + String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip"; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); + String vspName = vendorSoftwareProductObject.getName(); + ResourceGeneralPage.clickSubmitForTestingButton(vspName); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); + VfModuleVerificator.validateSpecificModulePropertiesFromRequest(resource); + } + + @Test + public void canvasTestJS() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); + CanvasElement portElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.PORT); + + canvasManager.linkElements(computeElement.getElementNameOnCanvas(), portElement.getElementNameOnCanvas()); + + } + + @Test + public void addVesEventsDeploymentArtifactToVfAndCheckMagnifierTest() throws Exception { + final int expectedHeaderAndRowSize = 3; + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + List deploymentArtifactList = new ArrayList<>(); + ArtifactInfo art1 = new ArtifactInfo(filePath, "fm_metadata_three_fault_defs.yml", "desc", "artifactfault", "VES_EVENTS"); + deploymentArtifactList.add(art1); + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); + } + AssertJUnit.assertTrue(DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); + + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on magnifier button %s", art1.getArtifactLabel())); + WebElement magnifierButtonElement = GeneralUIUtils.getWebElementByTestID(ArtifactPageEnum.BROWSE_ARTIFACT.getValue() + art1.getArtifactLabel()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Found magnifier button: %s", magnifierButtonElement.getText())); + magnifierButtonElement.click(); + List headers = GeneralUIUtils.getWebElementsListByClassName("datatable-header-cell"); + AssertJUnit.assertEquals(expectedHeaderAndRowSize, headers.size()); + headers.get(0).getText(); + List rows = GeneralUIUtils.getWebElementsListByContainsClassName("datatable-body-row"); + AssertJUnit.assertEquals(expectedHeaderAndRowSize, rows.size()); + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfAPI.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfAPI.java index 414f77b2f1..fe6718eea2 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfAPI.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfAPI.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,18 +23,45 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InformationalArtifactsPlaceholders; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ResourceMetadataEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ToscaArtifactsScreenEnum; -import org.openecomp.sdc.ci.tests.datatypes.enums.*; +import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; +import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.AttFtpClient; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; +import org.openecomp.sdc.ci.tests.pages.HomePage; +import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage; +import org.openecomp.sdc.ci.tests.pages.InputsPage; +import org.openecomp.sdc.ci.tests.pages.PropertiesPage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ToscaArtifactsPage; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; +import org.openecomp.sdc.ci.tests.utilities.PropertiesUIUtils; +import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils; +import org.openecomp.sdc.ci.tests.utilities.RestCDUtils; import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; @@ -51,214 +78,216 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import static org.assertj.core.api.Assertions.assertThat; public class VfAPI extends SetupCDTest { - private String filePath; + private String filePath; - @BeforeClass - public void beforeClass(){ - filePath = FileHandling.getFilePath(""); - } - - @BeforeMethod - public void beforeTest(){ - System.out.println("File repository is : " + filePath); - getExtendTest().log(Status.INFO, "File repository is : " + filePath); - } - - private ResourceReqDetails createVFviaAPI() { - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating VF %s", vfMetaData.getName())); - AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value(); - return vfMetaData; - } - + @BeforeClass + public void beforeClass() { + filePath = FileHandling.getFilePath(""); + } - @Test - public void updateVF() throws Exception { - - // create Resource - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(resourceMetaData, getUser()); - - // update Resource - ResourceReqDetails updatedResource = new ResourceReqDetails(); - updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + resourceMetaData.getName()); - updatedResource.setDescription("kuku"); - updatedResource.setVendorName("updatedVendor"); - updatedResource.setVendorRelease("updatedRelease"); - updatedResource.setContactId("ab0001"); - updatedResource.setCategories(resourceMetaData.getCategories()); - updatedResource.setVersion("0.1"); - updatedResource.setResourceType(ResourceTypeEnum.VF.getValue()); - List newTags = resourceMetaData.getTags(); - newTags.remove(resourceMetaData.getName()); - newTags.add(updatedResource.getName()); - updatedResource.setTags(newTags); - ResourceUIUtils.updateResource(updatedResource, getUser()); - - VfVerificator.verifyVFMetadataInUI(updatedResource); - VfVerificator.verifyVFUpdated(updatedResource, getUser()); - } + @BeforeMethod + public void beforeTest() { + System.out.println("File repository is : " + filePath); + getExtendTest().log(Status.INFO, "File repository is : " + filePath); + } + private ResourceReqDetails createVFviaAPI() { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating VF %s", vfMetaData.getName())); + AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value(); + return vfMetaData; + } - - @Test - public void vfcLinkedToComputeInVfFlowApi() throws Exception { - String fileName = "vFW_VFC2.yml"; - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - - try{ - //Create VFC via API - Resource vfc = AtomicOperationUtils.importResource(filePath, fileName).left().value(); - atomicResourceMetaData.setName(vfc.getName()); - //Certify VFC via API - vfc = (Resource) AtomicOperationUtils.changeComponentState(vfc, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + @Test + public void updateVF() throws Exception { + + // create Resource + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(resourceMetaData, getUser()); + + // update Resource + ResourceReqDetails updatedResource = new ResourceReqDetails(); + updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + resourceMetaData.getName()); + updatedResource.setDescription("kuku"); + updatedResource.setVendorName("updatedVendor"); + updatedResource.setVendorRelease("updatedRelease"); + updatedResource.setContactId("ab0001"); + updatedResource.setCategories(resourceMetaData.getCategories()); + updatedResource.setVersion("0.1"); + updatedResource.setResourceType(ResourceTypeEnum.VF.getValue()); + List newTags = resourceMetaData.getTags(); + newTags.remove(resourceMetaData.getName()); + newTags.add(updatedResource.getName()); + updatedResource.setTags(newTags); + ResourceUIUtils.updateResource(updatedResource, getUser()); + + VfVerificator.verifyVFMetadataInUI(updatedResource); + VfVerificator.verifyVFUpdated(updatedResource, getUser()); + } - //Create VF via API - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value(); - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - //Composition - drag the created VFC and another element, link between them - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(String.format("%s %s", LeftPanelCanvasItems.COMPUTE.getValue() , "1.0")); - CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - CanvasElement cpElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - AssertJUnit.assertNotNull(cpElement); - ServiceVerificator.verifyNumOfComponentInstances(vfMetaData, "0.1", 2, getUser()); - canvasManager.linkElements(cpElement, computeElement); - - vfMetaData.setVersion("0.1"); - VfVerificator.verifyLinkCreated(vfMetaData, getUser(), 1); - } - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); - } + @Test + public void vfcLinkedToComputeInVfFlowApi() throws Exception { + String fileName = "vFW_VFC2.yml"; + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + + try { + //Create VFC via API + Resource vfc = AtomicOperationUtils.importResource(filePath, fileName).left().value(); + atomicResourceMetaData.setName(vfc.getName()); + + //Certify VFC via API + vfc = (Resource) AtomicOperationUtils.changeComponentState(vfc, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + //Create VF via API + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value(); + + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + //Composition - drag the created VFC and another element, link between them + DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(String.format("%s %s", LeftPanelCanvasItems.COMPUTE.getValue(), "1.0")); + CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + CanvasElement cpElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + AssertJUnit.assertNotNull(cpElement); + ServiceVerificator.verifyNumOfComponentInstances(vfMetaData, "0.1", 2, getUser()); + canvasManager.linkElements(cpElement, computeElement); + + vfMetaData.setVersion("0.1"); + VfVerificator.verifyLinkCreated(vfMetaData, getUser(), 1); + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); + } - } + } - - @Test - public void addUpdateDeleteDeploymentArtifactToVfTestApi() throws Exception { - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); - - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + @Test + public void addUpdateDeleteDeploymentArtifactToVfTestApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); - List deploymentArtifactList = new ArrayList(); - deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); - deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML")); - for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); - } - AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); - - String newDescription = "new description"; - DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel()); - DeploymentArtifactPage.artifactPopup().insertDescription(newDescription); - DeploymentArtifactPage.artifactPopup().clickDoneButton(); - String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel()); - AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); - - DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel()); - DeploymentArtifactPage.clickOK(); - AssertJUnit.assertTrue("artifact "+ deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1)); - - AssertJUnit.assertTrue("artifact "+ deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed()); - } - + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - @Test - public void addUpdateDeleteInformationalArtifactApi() throws Exception { - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); - - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + List deploymentArtifactList = new ArrayList(); + deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER")); + deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML")); + for (ArtifactInfo deploymentArtifact : deploymentArtifactList) { + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); + } + AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size())); + + String newDescription = "new description"; + DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel()); + DeploymentArtifactPage.artifactPopup().insertDescription(newDescription); + DeploymentArtifactPage.artifactPopup().clickDoneButton(); + String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel()); + AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); + + DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel()); + DeploymentArtifactPage.clickOK(); + AssertJUnit.assertTrue("artifact " + deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1)); + + AssertJUnit.assertTrue("artifact " + deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed()); + } - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - - ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); - InformationalArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); - - AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1)); - - String newDescription = "new description"; - InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel()); - InformationalArtifactPage.artifactPopup().insertDescription(newDescription); - InformationalArtifactPage.artifactPopup().clickDoneButton(); - String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel()); - AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); - - InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel()); - InformationalArtifactPage.clickOK(); - AssertJUnit.assertTrue("artifact "+ informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0)); - } + @Test + public void addUpdateDeleteInformationalArtifactApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); - @Test - public void addPropertiesToVfcInstanceInVfTestApi() throws Exception { - - String fileName = "vFW_VFC.yml"; - ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); - - try{ - //Create VFC via API - Resource vfc = AtomicOperationUtils.importResource(filePath, fileName).left().value(); - atomicResourceMetaData.setName(vfc.getName()); + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - //Certify VFC via API - vfc = (Resource) AtomicOperationUtils.changeComponentState(vfc, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); + ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); + InformationalArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(atomicResourceMetaData.getName()); - CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - - vfCanvasManager.clickOnCanvaElement(vfcElement); - CompositionPage.showPropertiesAndAttributesTab(); - List properties = CompositionPage.getProperties(); - String propertyValue = "abc123"; - for (int i = 0; i < 2; i++) { - WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label")); - findElement.click(); - PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue); - PropertiesPage.getPropertyPopup().clickSave(); - - - findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value")); - AssertJUnit.assertTrue(findElement.getText().equals(propertyValue)); - } - } - finally{ - ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); - } - } + AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1)); + + String newDescription = "new description"; + InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel()); + InformationalArtifactPage.artifactPopup().insertDescription(newDescription); + InformationalArtifactPage.artifactPopup().clickDoneButton(); + String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel()); + AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); + + InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel()); + InformationalArtifactPage.clickOK(); + AssertJUnit.assertTrue("artifact " + informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0)); + } + + + @Test + public void addPropertiesToVfcInstanceInVfTestApi() throws Exception { + + String fileName = "vFW_VFC.yml"; + ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + + try { + //Create VFC via API + Resource vfc = AtomicOperationUtils.importResource(filePath, fileName).left().value(); + atomicResourceMetaData.setName(vfc.getName()); + + //Certify VFC via API + vfc = (Resource) AtomicOperationUtils.changeComponentState(vfc, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); + + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.searchForElement(atomicResourceMetaData.getName()); + CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); + + vfCanvasManager.clickOnCanvaElement(vfcElement); + CompositionPage.showPropertiesAndAttributesTab(); + List properties = CompositionPage.getProperties(); + String propertyValue = "abc123"; + for (int i = 0; i < 2; i++) { + WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label")); + findElement.click(); + PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue); + PropertiesPage.getPropertyPopup().clickSave(); + + + findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value")); + AssertJUnit.assertTrue(findElement.getText().equals(propertyValue)); + } + } finally { + ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); + } + } /* @Test public void changeInstanceVersionTest() throws Exception{ @@ -311,118 +340,118 @@ public class VfAPI extends SetupCDTest { }*/ // future removed from ui - @Test(enabled = false) - public void addUpdateDeleteSimplePropertiesToVfTest() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); - List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER); - int propertiesCount = PropertiesPage.getElemenetsFromTable().size(); - for (PropertyTypeEnum prop : propertyList){ - PropertiesUIUtils.addNewProperty(prop); - } - AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable())); - VfVerificator.verifyPropertiesInUI(propertyList); - PropertiesPage.verifyTotalProperitesField(propertiesCount + propertyList.size()); + @Test(enabled = false) + public void addUpdateDeleteSimplePropertiesToVfTest() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); + List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER); + int propertiesCount = PropertiesPage.getElemenetsFromTable().size(); + for (PropertyTypeEnum prop : propertyList) { + PropertiesUIUtils.addNewProperty(prop); + } + AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable())); + VfVerificator.verifyPropertiesInUI(propertyList); + PropertiesPage.verifyTotalProperitesField(propertiesCount + propertyList.size()); + + + PropertyTypeEnum prop = propertyList.get(0); + prop.setDescription("updatedDescription"); + prop.setValue("value"); + PropertiesUIUtils.updateProperty(prop); + + PropertiesPage.clickDeletePropertyArtifact(prop.getName()); + AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size() - 1, () -> PropertiesPage.getElemenetsFromTable())); + } + // future removed from ui + @Test(enabled = false) + public void vfcInstancesInputScreenTest() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + + Map elementsIntancesMap = new HashMap(); + for (LeftPanelCanvasItems element : Arrays.asList(LeftPanelCanvasItems.DATABASE, LeftPanelCanvasItems.BLOCK_STORAGE)) { + CanvasElement elementOnCanvas = vfCanvasManager.createElementOnCanvas(element); + vfCanvasManager.clickOnCanvaElement(elementOnCanvas); + String selectedInstanceName = CompositionPage.getSelectedInstanceName(); + elementsIntancesMap.put(selectedInstanceName, element.getValue()); + } + + CompositionPage.moveToInputsScreen(); + int canvasElementsSize = vfCanvasManager.getCanvasElements().size(); + AssertJUnit.assertTrue("Instances count is not as expected: " + canvasElementsSize, InputsPage.checkElementsCountInTable(canvasElementsSize)); + + for (String element : elementsIntancesMap.keySet()) { + String resourceName = elementsIntancesMap.get(element); + ResourceReqDetails resource = new ResourceReqDetails(); + resource.setName(resourceName); + resource.setVersion("1.0"); + resource.setResourceType(ResourceTypeEnum.VFC.toString()); + RestResponse restResponse = RestCDUtils.getResource(resource, getUser()); + Map propertiesNameTypeJson = ResponseParser.getPropertiesNameType(restResponse); + + List propertyRowsFromTable = InputsPage.getInstancePropertiesList(element); + AssertJUnit.assertTrue("Some properties are missing in table. Instance name is : " + element, propertyRowsFromTable.size() == propertiesNameTypeJson.size()); + VfVerificator.verifyVfInputs(element, propertiesNameTypeJson, propertyRowsFromTable); + + GeneralUIUtils.clickOnElementByText(element); + } - PropertyTypeEnum prop = propertyList.get(0); - prop.setDescription("updatedDescription"); - prop.setValue("value"); - PropertiesUIUtils.updateProperty(prop); - - PropertiesPage.clickDeletePropertyArtifact(prop.getName()); - AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size() - 1, () -> PropertiesPage.getElemenetsFromTable())); - } - - // future removed from ui - @Test(enabled = false) - public void vfcInstancesInputScreenTest() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - - Map elementsIntancesMap = new HashMap(); - for (LeftPanelCanvasItems element : Arrays.asList(LeftPanelCanvasItems.DATABASE, LeftPanelCanvasItems.BLOCK_STORAGE)){ - CanvasElement elementOnCanvas = vfCanvasManager.createElementOnCanvas(element); - vfCanvasManager.clickOnCanvaElement(elementOnCanvas); - String selectedInstanceName = CompositionPage.getSelectedInstanceName(); - elementsIntancesMap.put(selectedInstanceName, element.getValue()); - } + } - CompositionPage.moveToInputsScreen(); - int canvasElementsSize = vfCanvasManager.getCanvasElements().size(); - AssertJUnit.assertTrue("Instances count is not as expected: " + canvasElementsSize, InputsPage.checkElementsCountInTable(canvasElementsSize)); - - for (String element : elementsIntancesMap.keySet()){ - String resourceName = elementsIntancesMap.get(element); - ResourceReqDetails resource = new ResourceReqDetails(); - resource.setName(resourceName); - resource.setVersion("1.0"); - resource.setResourceType(ResourceTypeEnum.VFC.toString()); - RestResponse restResponse = RestCDUtils.getResource(resource, getUser()); - Map propertiesNameTypeJson = ResponseParser.getPropertiesNameType(restResponse); - - List propertyRowsFromTable = InputsPage.getInstancePropertiesList(element); - AssertJUnit.assertTrue("Some properties are missing in table. Instance name is : " + element, propertyRowsFromTable.size() == propertiesNameTypeJson.size()); - VfVerificator.verifyVfInputs(element, propertiesNameTypeJson, propertyRowsFromTable); - - GeneralUIUtils.clickOnElementByText(element); - } - - } + @Test + public void addAllInformationalArtifactPlaceholdersInVfTestApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - @Test - public void addAllInformationalArtifactPlaceholdersInVfTestApi() throws Exception{ - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + int fileNameCounter = 0; + String fileName; + for (InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()) { + fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; + ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, + FileHandling.getFilePath("uniqueFileNames"), fileName, + informArtifact.getValue()); + fileNameCounter++; + } + assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue(); + } - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - int fileNameCounter = 0; - String fileName; - for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){ - fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; - ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, - FileHandling.getFilePath("uniqueFileNames"),fileName, - informArtifact.getValue()); - fileNameCounter++; - } - assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue(); - } - - @Test - public void verifyToscaArtifactsExistApi() throws Exception{ - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); + @Test + public void verifyToscaArtifactsExistApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - final int numOfToscaArtifacts = 2; - ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); - AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts)); - - for(int i = 0; i < numOfToscaArtifacts; i++){ - String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); - AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); - } + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - //TODO Andrey should click on certify button - ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName()); - vfMetaData.setVersion("1.0"); - VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser()); - } - - @Test(enabled=false) - public void testDownload() throws Exception{ + final int numOfToscaArtifacts = 2; + ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); + AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts)); + + for (int i = 0; i < numOfToscaArtifacts; i++) { + String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); + AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); + } + + //TODO Andrey should click on certify button + ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName()); + vfMetaData.setVersion("1.0"); + VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser()); + } + + @Test(enabled = false) + public void testDownload() throws Exception { // ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); // ResourceUIUtils.createResource(vfMetaData, getUser()); // @@ -431,129 +460,129 @@ public class VfAPI extends SetupCDTest { // assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts)); // GeneralUIUtils.clickOnElementByTestId("download-Tosca Model"); // System.out.println("download me"); - - AttFtpClient attFtpClient = AttFtpClient.getInstance(); - - File retrieveLastModifiedFileFromFTP = attFtpClient.retrieveLastModifiedFileFromFTP(); - attFtpClient.deleteFilesFromFTPserver(); - } - - @Test - public void vfCertificationTestApi() throws Exception{ - //Create VF via API - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - Resource vf = AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value(); - - //Certify VF via API - vf = (Resource) AtomicOperationUtils.changeComponentState(vf, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); - } - - @Test - public void deleteVfCheckedoutTestApi() throws Exception{ - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - GeneralPageElements.clickTrashButtonAndConfirm(); - - vfMetaData.setVersion("0.1"); - VfVerificator.verifyVfDeleted(vfMetaData, getUser()); - } - - @Test - public void revertVfMetadataTestApi() throws Exception{ - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); + AttFtpClient attFtpClient = AttFtpClient.getFtpClient(); - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - ResourceReqDetails vfRevertDetails = new ResourceReqDetails(); - vfRevertDetails.setName("ciUpdatedName"); - vfRevertDetails.setDescription("kuku"); - vfRevertDetails.setCategories(vfMetaData.getCategories()); - vfRevertDetails.setVendorName("updatedVendor"); - vfRevertDetails.setVendorRelease("updatedRelease"); - ResourceUIUtils.fillResourceGeneralInformationPage(vfRevertDetails, getUser(), false); - - GeneralPageElements.clickRevertButton(); - - VfVerificator.verifyVFMetadataInUI(vfMetaData); - - } - - @Test - public void addDeploymentArtifactInCompositionScreenTestApi() throws Exception{ - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); + File retrieveLastModifiedFileFromFTP = attFtpClient.retrieveLastModifiedFileFromFTP(); + attFtpClient.deleteFilesFromFTPserver(); + } - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3","OTHER"); - CompositionPage.showDeploymentArtifactTab(); - CompositionPage.clickAddArtifactButton(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); - - List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className("i-sdc-designer-sidebar-section-content-item-artifact")); - AssertJUnit.assertEquals(1, actualArtifactList.size()); - } - - // future removed from ui - @Test(enabled = false) - public void addPropertyInCompositionScreenTest() throws Exception{ - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.createVF(vfMetaData, getUser()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - CompositionPage.showPropertiesAndAttributesTab(); - List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER); - int propertiesCount = CompositionPage.getProperties().size(); - for (PropertyTypeEnum prop : propertyList){ - PropertiesUIUtils.addNewProperty(prop); - } - AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> CompositionPage.getProperties())); - } - - @Test - public void addDeploymentArtifactAndVerifyInCompositionScreenApi() throws Exception{ - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); + @Test + public void vfCertificationTestApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + Resource vf = AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value(); - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + //Certify VF via API + vf = (Resource) AtomicOperationUtils.changeComponentState(vf, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); - DeploymentArtifactPage.clickAddNewArtifact(); - ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); - AssertJUnit.assertTrue(DeploymentArtifactPage.checkElementsCountInTable(1)); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - CompositionPage.showDeploymentArtifactTab(); - List deploymentArtifactsFromScreen = CompositionPage.getDeploymentArtifacts(); - AssertJUnit.assertTrue(1 == deploymentArtifactsFromScreen.size()); - - String actualArtifactFileName = deploymentArtifactsFromScreen.get(0).getText(); - AssertJUnit.assertTrue("asc_heat-0-2.yaml".equals(actualArtifactFileName)); - } + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); + } + + @Test + public void deleteVfCheckedoutTestApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); + + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + GeneralPageElements.clickTrashButtonAndConfirm(); + + vfMetaData.setVersion("0.1"); + VfVerificator.verifyVfDeleted(vfMetaData, getUser()); + } + + @Test + public void revertVfMetadataTestApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); + + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + ResourceReqDetails vfRevertDetails = new ResourceReqDetails(); + vfRevertDetails.setName("ciUpdatedName"); + vfRevertDetails.setDescription("kuku"); + vfRevertDetails.setCategories(vfMetaData.getCategories()); + vfRevertDetails.setVendorName("updatedVendor"); + vfRevertDetails.setVendorRelease("updatedRelease"); + ResourceUIUtils.fillResourceGeneralInformationPage(vfRevertDetails, getUser(), false); + + GeneralPageElements.clickRevertButton(); + + VfVerificator.verifyVFMetadataInUI(vfMetaData); + + } + + @Test + public void addDeploymentArtifactInCompositionScreenTestApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); + + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3", "OTHER"); + CompositionPage.showDeploymentArtifactTab(); + CompositionPage.clickAddArtifactButton(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup()); + + List actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className("i-sdc-designer-sidebar-section-content-item-artifact")); + AssertJUnit.assertEquals(1, actualArtifactList.size()); + } + + // future removed from ui + @Test(enabled = false) + public void addPropertyInCompositionScreenTest() throws Exception { + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + CompositionPage.showPropertiesAndAttributesTab(); + List propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER); + int propertiesCount = CompositionPage.getProperties().size(); + for (PropertyTypeEnum prop : propertyList) { + PropertiesUIUtils.addNewProperty(prop); + } + AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> CompositionPage.getProperties())); + } + + @Test + public void addDeploymentArtifactAndVerifyInCompositionScreenApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); + + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"); + DeploymentArtifactPage.clickAddNewArtifact(); + ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact); + AssertJUnit.assertTrue(DeploymentArtifactPage.checkElementsCountInTable(1)); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + CompositionPage.showDeploymentArtifactTab(); + List deploymentArtifactsFromScreen = CompositionPage.getDeploymentArtifacts(); + AssertJUnit.assertTrue(1 == deploymentArtifactsFromScreen.size()); + + String actualArtifactFileName = deploymentArtifactsFromScreen.get(0).getText(); + AssertJUnit.assertTrue("asc_heat-0-2.yaml".equals(actualArtifactFileName)); + } /*@Test public void checkoutVfTest() throws Exception{ @@ -583,46 +612,46 @@ public class VfAPI extends SetupCDTest { VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); }*/ - - @Test - public void deleteInstanceFromVfCanvasApi() throws Exception{ - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.PORT); - - vfCanvasManager.clickOnCanvaElement(computeElement); - vfCanvasManager.deleteElementFromCanvas(computeElement); - - VfVerificator.verifyNumOfComponentInstances(vfMetaData, 1, getUser()); - } - - @Test - public void changeInstanceNameInVfTestApi() throws Exception{ - //Create VF via API - ResourceReqDetails vfMetaData = createVFviaAPI(); + @Test + public void deleteInstanceFromVfCanvasApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); - CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - - String updatedInstanceName = "updatedName"; - vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName); - - String actualSelectedInstanceName = CompositionPage.getSelectedInstanceName(); - AssertJUnit.assertTrue(updatedInstanceName.equals(actualSelectedInstanceName)); - } + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); + vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.PORT); + + vfCanvasManager.clickOnCanvaElement(computeElement); + vfCanvasManager.deleteElementFromCanvas(computeElement); + + VfVerificator.verifyNumOfComponentInstances(vfMetaData, 1, getUser()); + } + + @Test + public void changeInstanceNameInVfTestApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = createVFviaAPI(); + + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); + + String updatedInstanceName = "updatedName"; + vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName); + + String actualSelectedInstanceName = CompositionPage.getSelectedInstanceName(); + AssertJUnit.assertTrue(updatedInstanceName.equals(actualSelectedInstanceName)); + } /*@Test @@ -664,34 +693,34 @@ public class VfAPI extends SetupCDTest { ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); } }*/ - - @Test - public void isDisabledAndReadOnlyInCheckinApi() throws Exception{ - //Create VF via API - ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - Resource vf = AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value(); - - //Check in VF via API - vf = (Resource) AtomicOperationUtils.changeComponentState(vf, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); - - //Go to Catalog and find the created VF - CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - - ResourceMetadataEnum[] fieldsForCheck = {ResourceMetadataEnum.RESOURCE_NAME, - ResourceMetadataEnum.DESCRIPTION, ResourceMetadataEnum.VENDOR_NAME, ResourceMetadataEnum.VENDOR_RELEASE, - ResourceMetadataEnum.CONTACT_ID}; - for (ResourceMetadataEnum field: fieldsForCheck){ - AssertJUnit.assertTrue(GeneralUIUtils.isElementReadOnly(field.getValue())); - } - - AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(ResourceMetadataEnum.CATEGORY.getValue())); - AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue())); - } + @Test + public void isDisabledAndReadOnlyInCheckinApi() throws Exception { + //Create VF via API + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + Resource vf = AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value(); + + //Check in VF via API + vf = (Resource) AtomicOperationUtils.changeComponentState(vf, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + + //Go to Catalog and find the created VF + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + ResourceMetadataEnum[] fieldsForCheck = {ResourceMetadataEnum.RESOURCE_NAME, + ResourceMetadataEnum.DESCRIPTION, ResourceMetadataEnum.VENDOR_NAME, ResourceMetadataEnum.VENDOR_RELEASE, + ResourceMetadataEnum.CONTACT_ID}; + + for (ResourceMetadataEnum field : fieldsForCheck) { + AssertJUnit.assertTrue(GeneralUIUtils.isElementReadOnly(field.getValue())); + } + + AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(ResourceMetadataEnum.CATEGORY.getValue())); + AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue())); + } @Test - public void displayHomeAfterNavigationToOnboardingTest() throws Exception{ + public void displayHomeAfterNavigationToOnboardingTest() throws Exception { //Production bug scenario: "Home" - Click on any VF/ Service - Copy the URL - Go to “ONBOARD” - Paste the URL - Review the breadcrumbs // Expected: "Home" Actual: "Onboarding" @@ -714,39 +743,38 @@ public class VfAPI extends SetupCDTest { GeneralUIUtils.ultimateWait(); //Validate that main menu button is Home and not Onboarding - String id = DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue(); + String id = DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue(); WebElement button = GeneralUIUtils.getWebElementByTestID(id); AssertJUnit.assertTrue(button.getAttribute("text").trim().equals("HOME")); } - - @Test - public void exportToscaWithModulePropertiesVFTest() throws Exception { - String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip"; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); - String vspName = vsp.getName(); - ResourceGeneralPage.clickCertifyButton(vspName); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "1.0"); - VfModuleVerificator.validateSpecificModulePropertiesFromRequest(resource); - } - - @Test - public void exportToscaWithModulePropertiesTemplateCheckVFTest() throws Exception { - String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip"; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); - ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); - GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_MODEL.getValue()); - File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); - ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(latestFilefromDir); - VfModuleVerificator.validateSpecificModulePropertiesFromFile(toscaDefinition); - } - + @Test + public void exportToscaWithModulePropertiesVFTest() throws Exception { + String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip"; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); + String vspName = vsp.getName(); + ResourceGeneralPage.clickCertifyButton(vspName); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "1.0"); + VfModuleVerificator.validateSpecificModulePropertiesFromRequest(resource); + } - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + @Test + public void exportToscaWithModulePropertiesTemplateCheckVFTest() throws Exception { + String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip"; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); + ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); + GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_MODEL.getValue()); + File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); + ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(latestFilefromDir); + VfModuleVerificator.validateSpecificModulePropertiesFromFile(toscaDefinition); + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfArtifacts.java index 28ff2cc8ca..0e3780a259 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfArtifacts.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfArtifacts.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,7 +39,11 @@ import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.pages.CompositionPage; import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; -import org.openecomp.sdc.ci.tests.utilities.*; +import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils; +import org.openecomp.sdc.ci.tests.utilities.FileHandling; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openecomp.sdc.ci.tests.utilities.HomeUtils; +import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; @@ -48,7 +52,6 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import java.awt.*; import java.io.File; import java.io.FileNotFoundException; import java.util.HashMap; @@ -58,348 +61,347 @@ import java.util.Map.Entry; import static org.testng.AssertJUnit.assertTrue; -public class VfArtifacts extends SetupCDTest{ - - public static final String VSAEGW_FDNT_30_1607_E2E_ZIP = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; - public static final String VFW_FCGI_30_1607_E2E_ZIP = "2016-044_vfw_fcgi_30_1607_e2e.zip"; - public static final String FDNT_UPDATE_HEAT_PARAMS_ZIP = "FDNT_UpdateHeatParams.zip"; - public static final String FDNT_WITHOUT_ENV_FILES_ZIP = "FDNT_WithoutEnvFiles.zip"; - public static final String VLANDSLIDE_LDSA_30_1607_E2E_ZIP = "2016-014_vlandslide_ldsa_30_1607_e2e.zip"; - public static final String VJSA_VJSA_30_1610_E2E_ZIP = "2016-209_vjsa_vjsa_30_1610_e2e.zip"; - public static final String VLB_LMSP_30_1607_E2E_ZIP = "2016-045_vlb_lmsp_30_1607_e2e.zip"; - public static final String MOBT_MOBT_30_1607_E2E_ZIP = "2016-109_mobt_mobt_30_1607_e2e.zip"; - public static final String MOBT_MOBT_30_1607_E2E_DIFFERENT_PARAMS_ZIP = "2016-109_mobt_mobt_30_1607_e2e_DifferentParams.zip"; - public static final String VMSP_PXMC_30_1607_E2E_ZIP = "2016-042_vmsp_pxmc_30_1607_e2e.zip"; - public static final String VFW_FNAT_30_1607_E2E_ZIP = "2016-044_vfw_fnat_30_1607_e2e.zip"; - public static final String VLANDSLIDE_LDST_30_1607_E2E_ZIP = "2016-014_vlandslide_ldst_30_1607_e2e.zip"; - public static final String VIXIA_IXLA_30_1607_E2E_ZIP = "2016-017_vixia_ixla_30_1607_e2e.zip"; - private String filePath; - private String vnfsRepositoryPath; - private String createdEnvFilePath; - private static final String PARAMETERS = "parameters"; - - @BeforeMethod - public void beforeTest() throws FileNotFoundException{ - filePath = getWindowTest().getDownloadDirectory(); - vnfsRepositoryPath = FileHandling.getFilePath("VfArtifacts"); - Config config = Utils.getConfig(); - createdEnvFilePath = config.getWindowsDownloadDirectory(); - } - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } - - - @DataProvider(name = "heatEnvAndVersion", parallel = false) +public class VfArtifacts extends SetupCDTest { + + public static final String VSAEGW_FDNT_30_1607_E2E_ZIP = "2016-043_vsaegw_fdnt_30_1607_e2e.zip"; + public static final String VFW_FCGI_30_1607_E2E_ZIP = "2016-044_vfw_fcgi_30_1607_e2e.zip"; + public static final String FDNT_UPDATE_HEAT_PARAMS_ZIP = "FDNT_UpdateHeatParams.zip"; + public static final String FDNT_WITHOUT_ENV_FILES_ZIP = "FDNT_WithoutEnvFiles.zip"; + public static final String VLANDSLIDE_LDSA_30_1607_E2E_ZIP = "2016-014_vlandslide_ldsa_30_1607_e2e.zip"; + public static final String VJSA_VJSA_30_1610_E2E_ZIP = "2016-209_vjsa_vjsa_30_1610_e2e.zip"; + public static final String VLB_LMSP_30_1607_E2E_ZIP = "2016-045_vlb_lmsp_30_1607_e2e.zip"; + public static final String MOBT_MOBT_30_1607_E2E_ZIP = "2016-109_mobt_mobt_30_1607_e2e.zip"; + public static final String MOBT_MOBT_30_1607_E2E_DIFFERENT_PARAMS_ZIP = "2016-109_mobt_mobt_30_1607_e2e_DifferentParams.zip"; + public static final String VMSP_PXMC_30_1607_E2E_ZIP = "2016-042_vmsp_pxmc_30_1607_e2e.zip"; + public static final String VFW_FNAT_30_1607_E2E_ZIP = "2016-044_vfw_fnat_30_1607_e2e.zip"; + public static final String VLANDSLIDE_LDST_30_1607_E2E_ZIP = "2016-014_vlandslide_ldst_30_1607_e2e.zip"; + public static final String VIXIA_IXLA_30_1607_E2E_ZIP = "2016-017_vixia_ixla_30_1607_e2e.zip"; + private String filePath; + private String vnfsRepositoryPath; + private String createdEnvFilePath; + private static final String PARAMETERS = "parameters"; + + @BeforeMethod + public void beforeTest() throws FileNotFoundException { + filePath = getWindowTest().getDownloadDirectory(); + vnfsRepositoryPath = FileHandling.getFilePath("VfArtifacts"); + Config config = Utils.getConfig(); + createdEnvFilePath = config.getWindowsDownloadDirectory(); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } + + + @DataProvider(name = "heatEnvAndVersion", parallel = false) // parameters: VSP, updatedVsp, expectedHeatVersion, expectedHeatEnvVersion - public Object[][] provideData() { - - return new Object[][] { - { VSAEGW_FDNT_30_1607_E2E_ZIP, FDNT_UPDATE_HEAT_PARAMS_ZIP, "2", "2" }, // expected heat version 2 and heatEnv 2 - { VSAEGW_FDNT_30_1607_E2E_ZIP, FDNT_WITHOUT_ENV_FILES_ZIP, "1", "2" }, // expected heat version 1 and heatEnv 2 - {VLANDSLIDE_LDSA_30_1607_E2E_ZIP, VJSA_VJSA_30_1610_E2E_ZIP, "1", "1" }, // expected heat version 1 and heatEnv 1 - {VLB_LMSP_30_1607_E2E_ZIP, VLB_LMSP_30_1607_E2E_ZIP, "1", "2" }, // expected heat version 1 and heatEnv 2(DE270634) - {MOBT_MOBT_30_1607_E2E_ZIP, MOBT_MOBT_30_1607_E2E_DIFFERENT_PARAMS_ZIP, "2", "2" } // expected heat version 2 and heatEnv 2 - }; - } - -// update first env file and verify parameters value - @Test - public void uploadUpdatedHeatEnv() throws Exception{ - - String vnfFile = VFW_FNAT_30_1607_E2E_ZIP; - File updateEnvFile = null; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.getName(); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); - Map deploymentArtifacts = resource.getDeploymentArtifacts(); - List envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); + public Object[][] provideData() { + + return new Object[][]{ + {VSAEGW_FDNT_30_1607_E2E_ZIP, FDNT_UPDATE_HEAT_PARAMS_ZIP, "2", "2"}, // expected heat version 2 and heatEnv 2 + {VSAEGW_FDNT_30_1607_E2E_ZIP, FDNT_WITHOUT_ENV_FILES_ZIP, "1", "2"}, // expected heat version 1 and heatEnv 2 + {VLANDSLIDE_LDSA_30_1607_E2E_ZIP, VJSA_VJSA_30_1610_E2E_ZIP, "1", "1"}, // expected heat version 1 and heatEnv 1 + {VLB_LMSP_30_1607_E2E_ZIP, VLB_LMSP_30_1607_E2E_ZIP, "1", "2"}, // expected heat version 1 and heatEnv 2(DE270634) + {MOBT_MOBT_30_1607_E2E_ZIP, MOBT_MOBT_30_1607_E2E_DIFFERENT_PARAMS_ZIP, "2", "2"} // expected heat version 2 and heatEnv 2 + }; + } + + // update first env file and verify parameters value + @Test + public void uploadUpdatedHeatEnv() throws Exception { + + String vnfFile = VFW_FNAT_30_1607_E2E_ZIP; + File updateEnvFile = null; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = vsp.getName(); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); + Map deploymentArtifacts = resource.getDeploymentArtifacts(); + List envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); // create env file and update it - if(envFilesList.size()>0){ + if (envFilesList.size() > 0) { // select index of env file to be updated - HeatWithParametersDefinition selectedEnvFileToUpdate = envFilesList.get(0); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.EDIT_ARTIFACT.getValue()+selectedEnvFileToUpdate.getHeatEnvLabel()); - updateEnvFile = ArtifactUIUtils.uploadCreatedUpdateParametersEnvFile(selectedEnvFileToUpdate, createdEnvFilePath); - ArtifactUIUtils.verifyUpdatedEnvParameters(selectedEnvFileToUpdate, updateEnvFile); - } - else{ - SetupCDTest.getExtendTest().log(Status.INFO, "Resource does not contain HEAT files"); - } - } - -// update all env files and verify parameters value in Deployment Artifact View - @Test - public void uploadUpdatedAllHeatEnv() throws Exception{ - - String vnfFile = VFW_FNAT_30_1607_E2E_ZIP; - File updateEnvFile = null; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.getName(); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); - Map deploymentArtifacts = resource.getDeploymentArtifacts(); - List envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); - if(envFilesList.size()>0){ - for(HeatWithParametersDefinition selectedEnvFileToUpdate : envFilesList){ - // create env file and update it - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.EDIT_ARTIFACT.getValue()+selectedEnvFileToUpdate.getHeatEnvLabel()); - updateEnvFile = ArtifactUIUtils.uploadCreatedUpdateParametersEnvFile(selectedEnvFileToUpdate, createdEnvFilePath); - ArtifactUIUtils.verifyUpdatedEnvParameters(selectedEnvFileToUpdate, updateEnvFile); - } - }else{ - SetupCDTest.getExtendTest().log(Status.INFO, "Resource does not contain HEAT files"); - } - } - -// update all env files and verify parameters value in Composition - @Test - public void uploadUpdatedAllHeatEnvComposition() throws Exception{ - - String vnfFile = VLANDSLIDE_LDST_30_1607_E2E_ZIP; - File updateEnvFile = null; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.getName(); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); - Map deploymentArtifacts = resource.getDeploymentArtifacts(); - List envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.StepsEnum.COMPOSITION.getValue()); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB.getValue()); - if(envFilesList.size()>0){ - for(HeatWithParametersDefinition selectedEnvFileToUpdate : envFilesList){ - // create env file and update it - String dataTestId = DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ITEM.getValue()+selectedEnvFileToUpdate.getHeatArtifactDisplayName(); - GeneralUIUtils.hoverOnAreaByTestId(dataTestId); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.EDIT_ARTIFACT.getValue()+selectedEnvFileToUpdate.getHeatArtifactDisplayName()); - updateEnvFile = ArtifactUIUtils.uploadCreatedUpdateParametersEnvFile(selectedEnvFileToUpdate, createdEnvFilePath); - ArtifactUIUtils.verifyUpdatedEnvParameters(selectedEnvFileToUpdate, updateEnvFile, dataTestId); - } - }else{ - SetupCDTest.getExtendTest().log(Status.INFO, "Resource does not contain HEAT files"); - } - } - -// expected heat version 1 and heatEnv 0 - @Test - // Download ENV file from VF level Update VSP. - public void downloadEnvFromVFLevelUpdateVSP() throws Throwable { - String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; - String updatedVnfFile= VLANDSLIDE_LDSA_30_1607_E2E_ZIP; - String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject CreatedVsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = CreatedVsp.getName(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, CreatedVsp, updatedVnfFile, getUser()); - //get updated vsp env files - Map currentZipEnvfiles=ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, downloadDirPath); - GeneralUIUtils.findComponentAndClick(vspName); - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - List deploymentArtifcatsList = DeploymentArtifactPage.getDeploymentArtifactsNamesWorkSpace(); - - for (int i = 0; i < deploymentArtifcatsList.size(); i++) { - if (DeploymentArtifactPage.getArtifactType(deploymentArtifcatsList.get(i)).equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType())) { - DeploymentArtifactPage.clickDownloadEnvArtifact(deploymentArtifcatsList.get(i)); - GeneralUIUtils.ultimateWait(); - File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(downloadDirPath); - ArtifactUIUtils.compareYamlFilesByPattern(latestFilefromDir, currentZipEnvfiles.get(deploymentArtifcatsList.get(i)), PARAMETERS); - } - } - } - - @Test - // Download ENV file from VF level Work-Space. - public void downloadEnvFromVFLevelWorkSpace() throws AWTException, Exception { - String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; - String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - Map currentZipEnvfiles=ArtifactBusinessLogic.createEnvFilesListFromCsar(vsp.getName(),downloadDirPath); - GeneralUIUtils.findComponentAndClick(vsp.getName()); - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - List deploymentArtifcatsList = DeploymentArtifactPage.getDeploymentArtifactsNamesWorkSpace(); - - for (int i = 0; i < deploymentArtifcatsList.size(); i++) { - - if (DeploymentArtifactPage.getArtifactType(deploymentArtifcatsList.get(i)).equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType())) { - DeploymentArtifactPage.clickDownloadEnvArtifact(deploymentArtifcatsList.get(i)); - GeneralUIUtils.ultimateWait(); - File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(downloadDirPath); - ArtifactUIUtils.compareYamlFilesByPattern(latestFilefromDir,currentZipEnvfiles.get(deploymentArtifcatsList.get(i)), PARAMETERS); - } - } - } - - @Test - // Download ENV file from VF level Composition. - public void downloadEnvVFLevelComposition() throws AWTException, Exception { - - String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); - String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - Map currentZipEnvfiles=ArtifactBusinessLogic.createEnvFilesListFromCsar(vsp.getName(),downloadDirPath); - GeneralUIUtils.findComponentAndClick(vsp.getName()); - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CompositionPage.clickOnTabTestID(CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB); - List deploymentArtifcatsList = CompositionPage.getCompositionEnvArtifacts(); - - for (int i = 0; i < deploymentArtifcatsList.size(); i++) { - String fileName = GeneralUIUtils.getDataTestIdAttributeValue(deploymentArtifcatsList.get(i)).replace(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ENV.getValue(), ""); - if (GeneralUIUtils.isElementVisibleByTestId(GeneralUIUtils.getDataTestIdAttributeValue(deploymentArtifcatsList.get(i)))) { - CompositionPage.clickDownloadEnvArtifactComposition(fileName).click(); - GeneralUIUtils.ultimateWait(); - File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(downloadDirPath); - ArtifactUIUtils.compareYamlFilesByPattern(latestFilefromDir,currentZipEnvfiles.get(fileName), PARAMETERS); - } - } - } - - @Test - // Download ENV file from VF level Update parameters in UI. - public void downloadEnvVFLevelUpdateParameters() throws Exception { - - String vnfFile = VFW_FCGI_30_1607_E2E_ZIP; - String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vendorSoftwareProductObject= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vendorSoftwareProductObject.getName(), "0.1"); + HeatWithParametersDefinition selectedEnvFileToUpdate = envFilesList.get(0); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.EDIT_ARTIFACT.getValue() + selectedEnvFileToUpdate.getHeatEnvLabel()); + updateEnvFile = ArtifactUIUtils.uploadCreatedUpdateParametersEnvFile(selectedEnvFileToUpdate, createdEnvFilePath); + ArtifactUIUtils.verifyUpdatedEnvParameters(selectedEnvFileToUpdate, updateEnvFile); + } else { + SetupCDTest.getExtendTest().log(Status.INFO, "Resource does not contain HEAT files"); + } + } + + // update all env files and verify parameters value in Deployment Artifact View + @Test + public void uploadUpdatedAllHeatEnv() throws Exception { + + String vnfFile = VFW_FNAT_30_1607_E2E_ZIP; + File updateEnvFile = null; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = vsp.getName(); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); + Map deploymentArtifacts = resource.getDeploymentArtifacts(); + List envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); + if (envFilesList.size() > 0) { + for (HeatWithParametersDefinition selectedEnvFileToUpdate : envFilesList) { + // create env file and update it + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.EDIT_ARTIFACT.getValue() + selectedEnvFileToUpdate.getHeatEnvLabel()); + updateEnvFile = ArtifactUIUtils.uploadCreatedUpdateParametersEnvFile(selectedEnvFileToUpdate, createdEnvFilePath); + ArtifactUIUtils.verifyUpdatedEnvParameters(selectedEnvFileToUpdate, updateEnvFile); + } + } else { + SetupCDTest.getExtendTest().log(Status.INFO, "Resource does not contain HEAT files"); + } + } + + // update all env files and verify parameters value in Composition + @Test + public void uploadUpdatedAllHeatEnvComposition() throws Exception { + + String vnfFile = VLANDSLIDE_LDST_30_1607_E2E_ZIP; + File updateEnvFile = null; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = vsp.getName(); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); + Map deploymentArtifacts = resource.getDeploymentArtifacts(); + List envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.StepsEnum.COMPOSITION.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB.getValue()); + if (envFilesList.size() > 0) { + for (HeatWithParametersDefinition selectedEnvFileToUpdate : envFilesList) { + // create env file and update it + String dataTestId = DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ITEM.getValue() + selectedEnvFileToUpdate.getHeatArtifactDisplayName(); + GeneralUIUtils.hoverOnAreaByTestId(dataTestId); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.EDIT_ARTIFACT.getValue() + selectedEnvFileToUpdate.getHeatArtifactDisplayName()); + updateEnvFile = ArtifactUIUtils.uploadCreatedUpdateParametersEnvFile(selectedEnvFileToUpdate, createdEnvFilePath); + ArtifactUIUtils.verifyUpdatedEnvParameters(selectedEnvFileToUpdate, updateEnvFile, dataTestId); + } + } else { + SetupCDTest.getExtendTest().log(Status.INFO, "Resource does not contain HEAT files"); + } + } + + // expected heat version 1 and heatEnv 0 + @Test + // Download ENV file from VF level Update VSP. + public void downloadEnvFromVFLevelUpdateVSP() throws Throwable { + String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; + String updatedVnfFile = VLANDSLIDE_LDSA_30_1607_E2E_ZIP; + String downloadDirPath = SetupCDTest.getConfig().getWindowsDownloadDirectory(); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject CreatedVsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = CreatedVsp.getName(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, CreatedVsp, updatedVnfFile, getUser()); + //get updated vsp env files + Map currentZipEnvfiles = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, downloadDirPath); + GeneralUIUtils.findComponentAndClick(vspName); + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + List deploymentArtifcatsList = DeploymentArtifactPage.getDeploymentArtifactsNamesWorkSpace(); + + for (int i = 0; i < deploymentArtifcatsList.size(); i++) { + if (DeploymentArtifactPage.getArtifactType(deploymentArtifcatsList.get(i)).equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType())) { + DeploymentArtifactPage.clickDownloadEnvArtifact(deploymentArtifcatsList.get(i)); + GeneralUIUtils.ultimateWait(); + File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(downloadDirPath); + ArtifactUIUtils.compareYamlFilesByPattern(latestFilefromDir, currentZipEnvfiles.get(deploymentArtifcatsList.get(i)), PARAMETERS); + } + } + } + + @Test + // Download ENV file from VF level Work-Space. + public void downloadEnvFromVFLevelWorkSpace() throws Exception { + String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; + String downloadDirPath = SetupCDTest.getConfig().getWindowsDownloadDirectory(); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + Map currentZipEnvfiles = ArtifactBusinessLogic.createEnvFilesListFromCsar(vsp.getName(), downloadDirPath); + GeneralUIUtils.findComponentAndClick(vsp.getName()); + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + List deploymentArtifcatsList = DeploymentArtifactPage.getDeploymentArtifactsNamesWorkSpace(); + + for (int i = 0; i < deploymentArtifcatsList.size(); i++) { + + if (DeploymentArtifactPage.getArtifactType(deploymentArtifcatsList.get(i)).equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType())) { + DeploymentArtifactPage.clickDownloadEnvArtifact(deploymentArtifcatsList.get(i)); + GeneralUIUtils.ultimateWait(); + File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(downloadDirPath); + ArtifactUIUtils.compareYamlFilesByPattern(latestFilefromDir, currentZipEnvfiles.get(deploymentArtifcatsList.get(i)), PARAMETERS); + } + } + } + + @Test + // Download ENV file from VF level Composition. + public void downloadEnvVFLevelComposition() throws Exception { + + String downloadDirPath = SetupCDTest.getConfig().getWindowsDownloadDirectory(); + String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + Map currentZipEnvfiles = ArtifactBusinessLogic.createEnvFilesListFromCsar(vsp.getName(), downloadDirPath); + GeneralUIUtils.findComponentAndClick(vsp.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CompositionPage.clickOnTabTestID(CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB); + List deploymentArtifcatsList = CompositionPage.getCompositionEnvArtifacts(); + + for (int i = 0; i < deploymentArtifcatsList.size(); i++) { + String fileName = GeneralUIUtils.getDataTestIdAttributeValue(deploymentArtifcatsList.get(i)).replace(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ENV.getValue(), ""); + if (GeneralUIUtils.isElementVisibleByTestId(GeneralUIUtils.getDataTestIdAttributeValue(deploymentArtifcatsList.get(i)))) { + CompositionPage.clickDownloadEnvArtifactComposition(fileName).click(); + GeneralUIUtils.ultimateWait(); + File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(downloadDirPath); + ArtifactUIUtils.compareYamlFilesByPattern(latestFilefromDir, currentZipEnvfiles.get(fileName), PARAMETERS); + } + } + } + + @Test + // Download ENV file from VF level Update parameters in UI. + public void downloadEnvVFLevelUpdateParameters() throws Exception { + + String vnfFile = VFW_FCGI_30_1607_E2E_ZIP; + String downloadDirPath = SetupCDTest.getConfig().getWindowsDownloadDirectory(); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vendorSoftwareProductObject.getName(), "0.1"); Map deploymentArtifacts = resource.getDeploymentArtifacts(); List envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); - + for (int i = 0; i < envFilesList.size(); i++) { - String artifactName = envFilesList.get(i).getHeatArtifactDisplayName(); - if (envFilesList.get(i).getHeatArtifactType().equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType())) { - ExtentTestActions.log(Status.INFO, String.format("Opening the edit/view artifact parameters form of %s resource...", vnfFile)); - DeploymentArtifactPage.clickEditEnvArtifact(envFilesList.get(i).getHeatArtifactDisplayName()); - - ExtentTestActions.log(Status.INFO, String.format("Going To locating all artifact parameters from UI of %s artifact...", artifactName)); - Map dataToWriteInUI = ArtifactUIUtils.getDataToWriteInUI(envFilesList.get(i).getHeatParameterDefinition()); - Map data = dataToWriteInUI; - ExtentTestActions.log(Status.INFO, String.format("Success to locate all artifact parameters from UI of %s artifact...", artifactName)); - - List listToSearchEnvParametersInUI = envFilesList.get(i).getHeatParameterDefinition(); - fillHeatEnvParametersInUi(data, listToSearchEnvParametersInUI); - - DeploymentArtifactPage.clickSaveEnvParameters(); - GeneralUIUtils.waitForLoader(); - ExtentTestActions.log(Status.INFO, String.format("Going to get the %s updated resource ...", vendorSoftwareProductObject.getName())); - resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vendorSoftwareProductObject.getName(), "0.1"); - deploymentArtifacts = resource.getDeploymentArtifacts(); - Map> envFilesListupdated = new HashMap<>(); - ExtentTestActions.log(Status.INFO, String.format("Mapping the %s artifact parameters ...", artifactName)); - envFilesListupdated.put(artifactName,ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts)); - List heatEnvUpdatedParameters=envFilesListupdated.get(artifactName); - DeploymentArtifactPage. clickDownloadEnvArtifact(artifactName); - - Map mapExpectedProperties = new HashMap<>(); - for (HeatParameterDataDefinition param : heatEnvUpdatedParameters.get(i).getHeatParameterDefinition()) { - mapExpectedProperties.put(param.getName(), ArtifactUIUtils.getValue(param)); - } - ArtifactUIUtils.compareYamlParametersByPattern(mapExpectedProperties, FileHandling.getLastModifiedFileNameFromDir(downloadDirPath), PARAMETERS); - } + String artifactName = envFilesList.get(i).getHeatArtifactDisplayName(); + if (envFilesList.get(i).getHeatArtifactType().equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType())) { + ExtentTestActions.log(Status.INFO, String.format("Opening the edit/view artifact parameters form of %s resource...", vnfFile)); + DeploymentArtifactPage.clickEditEnvArtifact(envFilesList.get(i).getHeatArtifactDisplayName()); + + ExtentTestActions.log(Status.INFO, String.format("Going To locating all artifact parameters from UI of %s artifact...", artifactName)); + Map dataToWriteInUI = ArtifactUIUtils.getDataToWriteInUI(envFilesList.get(i).getHeatParameterDefinition()); + Map data = dataToWriteInUI; + ExtentTestActions.log(Status.INFO, String.format("Success to locate all artifact parameters from UI of %s artifact...", artifactName)); + + List listToSearchEnvParametersInUI = envFilesList.get(i).getHeatParameterDefinition(); + fillHeatEnvParametersInUi(data, listToSearchEnvParametersInUI); + + DeploymentArtifactPage.clickSaveEnvParameters(); + GeneralUIUtils.waitForLoader(); + ExtentTestActions.log(Status.INFO, String.format("Going to get the %s updated resource ...", vendorSoftwareProductObject.getName())); + resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vendorSoftwareProductObject.getName(), "0.1"); + deploymentArtifacts = resource.getDeploymentArtifacts(); + Map> envFilesListupdated = new HashMap<>(); + ExtentTestActions.log(Status.INFO, String.format("Mapping the %s artifact parameters ...", artifactName)); + envFilesListupdated.put(artifactName, ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts)); + List heatEnvUpdatedParameters = envFilesListupdated.get(artifactName); + DeploymentArtifactPage.clickDownloadEnvArtifact(artifactName); + + Map mapExpectedProperties = new HashMap<>(); + for (HeatParameterDataDefinition param : heatEnvUpdatedParameters.get(i).getHeatParameterDefinition()) { + mapExpectedProperties.put(param.getName(), ArtifactUIUtils.getValue(param)); + } + ArtifactUIUtils.compareYamlParametersByPattern(mapExpectedProperties, FileHandling.getLastModifiedFileNameFromDir(downloadDirPath), PARAMETERS); + } } - } - - - @Test - public void checkDefaultCreatedEnvArtifacts() throws Exception{ - String vnfFile = VIXIA_IXLA_30_1607_E2E_ZIP; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.getName(); - Map generatedEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); - HomeUtils.findComponentAndClick(vspName); - GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); - for(Entry envFileEntry : generatedEnvFileList.entrySet()){ - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue()+envFileEntry.getKey()); - ArtifactUIUtils.compareYamlFilesByPattern(envFileEntry.getValue(), FileHandling.getLastModifiedFileNameFromDir(), PARAMETERS); + } + + + @Test + public void checkDefaultCreatedEnvArtifacts() throws Exception { + String vnfFile = VIXIA_IXLA_30_1607_E2E_ZIP; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = vsp.getName(); + Map generatedEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); + HomeUtils.findComponentAndClick(vspName); + GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); + for (Entry envFileEntry : generatedEnvFileList.entrySet()) { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() + envFileEntry.getKey()); + ArtifactUIUtils.compareYamlFilesByPattern(envFileEntry.getValue(), FileHandling.getLastModifiedFileNameFromDir(), PARAMETERS); // if(true){ //// throw new SkipException("Test skipped, new artifact version design should be developed"); // SetupCDTest.getExtendTest().log(Status.INFO, "Test skipped, new artifact version design should be developed"); // } // ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), "1", ArtifactTypeEnum.HEAT_ENV); // ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), "1", ArtifactTypeEnum.HEAT); - } - } - -// ------------------------------------------------------------------------------- - @Test(dataProvider = "heatEnvAndVersion") - public void checkDefaultCreatedEnvArtifactsAfterVspUpdate(String vnfFile, String updatedVnfFile, String expectedHeatVersion, String expectedHeatEnvVersion) throws Throwable{ - String stringForLog = String.format("%s:%s:%s:%s", vnfFile, updatedVnfFile, expectedHeatVersion, expectedHeatEnvVersion); - setLog(stringForLog); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.getName(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); - Map generatedUpdatedEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); - HomeUtils.findComponentAndClick(vspName); - GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); - for(Entry envFileEntry : generatedUpdatedEnvFileList.entrySet()){ + } + } + + // ------------------------------------------------------------------------------- + @Test(dataProvider = "heatEnvAndVersion") + public void checkDefaultCreatedEnvArtifactsAfterVspUpdate(String vnfFile, String updatedVnfFile, String expectedHeatVersion, String expectedHeatEnvVersion) throws Throwable { + String stringForLog = String.format("%s:%s:%s:%s", vnfFile, updatedVnfFile, expectedHeatVersion, expectedHeatEnvVersion); + setLog(stringForLog); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = vsp.getName(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); + Map generatedUpdatedEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); + HomeUtils.findComponentAndClick(vspName); + GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); + for (Entry envFileEntry : generatedUpdatedEnvFileList.entrySet()) { // TODO test will pass on case all objects on deployment view are visible - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue()+envFileEntry.getKey()); - ArtifactUIUtils.compareYamlFilesByPattern(envFileEntry.getValue(), FileHandling.getLastModifiedFileNameFromDir(), PARAMETERS); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() + envFileEntry.getKey()); + ArtifactUIUtils.compareYamlFilesByPattern(envFileEntry.getValue(), FileHandling.getLastModifiedFileNameFromDir(), PARAMETERS); // ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), expectedHeatEnvVersion, ArtifactTypeEnum.HEAT_ENV); // ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), expectedHeatVersion, ArtifactTypeEnum.HEAT); - } - if(true){ + } + if (true) { // throw new SkipException("Test skipped, new artifact version design should be developed"); - ExtentTestActions.log(Status.INFO, "Test skipped, new artifact version design should be developed"); - } - } - -// expected heat version 1 and heatEnv 3 - @Test - public void checkDefaultCreatedEnvArtifactsVspUpdatedWithSameVspTwice() throws Throwable{ - String vnfFile = VFW_FCGI_30_1607_E2E_ZIP; - String updatedVnfFile = VFW_FCGI_30_1607_E2E_ZIP; - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.getName(); - - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); - // Artifact validation commented until new artifact version design should be developed - Map generatedUpdatedSecondTimeEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); - HomeUtils.findComponentAndClick(vspName); - GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); - for(Entry envFileEntry : generatedUpdatedSecondTimeEnvFileList.entrySet()){ - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue()+envFileEntry.getKey()); - ArtifactUIUtils.compareYamlFilesByPattern(envFileEntry.getValue(), FileHandling.getLastModifiedFileNameFromDir(), PARAMETERS); - if(true){ + ExtentTestActions.log(Status.INFO, "Test skipped, new artifact version design should be developed"); + } + } + + // expected heat version 1 and heatEnv 3 + @Test + public void checkDefaultCreatedEnvArtifactsVspUpdatedWithSameVspTwice() throws Throwable { + String vnfFile = VFW_FCGI_30_1607_E2E_ZIP; + String updatedVnfFile = VFW_FCGI_30_1607_E2E_ZIP; + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = vsp.getName(); + + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + OnboardingUiUtils.updateVnfAndValidate(vnfsRepositoryPath, vsp, updatedVnfFile, getUser()); + // Artifact validation commented until new artifact version design should be developed + Map generatedUpdatedSecondTimeEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); + HomeUtils.findComponentAndClick(vspName); + GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); + for (Entry envFileEntry : generatedUpdatedSecondTimeEnvFileList.entrySet()) { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() + envFileEntry.getKey()); + ArtifactUIUtils.compareYamlFilesByPattern(envFileEntry.getValue(), FileHandling.getLastModifiedFileNameFromDir(), PARAMETERS); + if (true) { // throw new SkipException("Test skipped, new artifact version design should be developed"); ExtentTestActions.log(Status.INFO, "Test skipped, new artifact version design should be developed"); - } + } // ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), "3", ArtifactTypeEnum.HEAT_ENV); // ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), "1", ArtifactTypeEnum.HEAT); - } - } - - - public void downloadFile(Entry envFileEntry) { - int fileCountBefore = FileHandling.getFileCountFromDefaulDownloadDirectory(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue()+envFileEntry.getKey()); - int fileCountAfter = FileHandling.getFileCountFromDefaulDownloadDirectory(); - assertTrue("Downloaded file is missing", (fileCountAfter - fileCountBefore) == 1 ); - } - - public static void fillHeatEnvParametersInUi(Map data,List listToSearchEnvParametersInUI) { - ExtentTestActions.log(Status.INFO, String.format("Going to search parameters in UI and insert new current value to each parameter in UI...")); - - for (HeatParameterDataDefinition paramDefinition : listToSearchEnvParametersInUI){ - DeploymentArtifactPage.searchBoxEnv(paramDefinition.getName()); - WebElement currenValueField=GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.EnvParameterView.ENV_CURRENT_VALUE.getValue()+paramDefinition.getName()); - currenValueField.clear(); - currenValueField.sendKeys(data.get(paramDefinition.getName()).toString()); - GeneralUIUtils.ultimateWait(); - DeploymentArtifactPage.clearSearchBoxEnv(); - } - } - + } + } + + + public void downloadFile(Entry envFileEntry) { + int fileCountBefore = FileHandling.getFileCountFromDefaulDownloadDirectory(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() + envFileEntry.getKey()); + int fileCountAfter = FileHandling.getFileCountFromDefaulDownloadDirectory(); + assertTrue("Downloaded file is missing", (fileCountAfter - fileCountBefore) == 1); + } + + public static void fillHeatEnvParametersInUi(Map data, List listToSearchEnvParametersInUI) { + ExtentTestActions.log(Status.INFO, String.format("Going to search parameters in UI and insert new current value to each parameter in UI...")); + + for (HeatParameterDataDefinition paramDefinition : listToSearchEnvParametersInUI) { + DeploymentArtifactPage.searchBoxEnv(paramDefinition.getName()); + WebElement currenValueField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.EnvParameterView.ENV_CURRENT_VALUE.getValue() + paramDefinition.getName()); + currenValueField.clear(); + currenValueField.sendKeys(data.get(paramDefinition.getName()).toString()); + GeneralUIUtils.ultimateWait(); + DeploymentArtifactPage.clearSearchBoxEnv(); + } + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java index 4f6e74522d..f0d9d720ef 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -48,605 +48,594 @@ import static org.assertj.core.api.Assertions.assertThat; public class VfDeploymentInformationalArtifacts extends SetupCDTest { - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // START US824719 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // US824719 - Import VSP - VF informational artifacts - // TC1434241 - Import VF Artifacts - Deployment Artifacts - One Artifact, One Type - @Test - public void importVfArtifactsDeploymentArtifactsOneArtifactOneType() throws Exception { - String fileName = "TC1434241.csar"; - String folder ="US825779"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); - } - - // US824719 - Import VSP - VF informational artifacts - // TC1434245 - Import VF Artifacts - Deployment Artifacts - Multiple Artifacts, Multiple Types - @Test - public void importVfArtifactsDeploymentArtifactsMultipleArtifactsMultipleTypes() throws Exception { - String fileName = "TC1434245.csar"; - String folder ="US825779"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1")); - - deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); - - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName,folder, deploymentArtifacts, null); - } - - // US824719 - Import VSP - VF informational artifacts - // TC1434247 - Import VF Artifacts - Informational Artifacts - One Artifact, One Type - @Test - public void importVfArtifactsInformationalArtifactsOneArtifactOneType() throws Exception { - String fileName = "TC1434247.csar"; - String folder ="US825779"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - - List informationalArtifacts = new ArrayList(); - informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); - } - - // US824719 - Import VSP - VF informational artifacts - // TC1434248 - Import VF Artifacts - Informational Artifacts - Multiple Artifacts, Multiple Types - @Test - public void importVfArtifactsInformationalArtifactsMultipleArtifactsMultipleTypes() throws Exception { - String fileName = "TC1434248.csar"; - String folder ="US825779"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - - List informationalArtifacts = new ArrayList(); - informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); - informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1")); - informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); - } - - // US824719 - Import VSP - VF informational artifacts - // TC1434249 - Import VF Artifacts - Deployment and Informational Artifacts - Multiple Artifacts, Multiple Types - @Test - public void importVfArtifactsDeploymentAndInformationalArtifactsMultipleArtifactsMultipleTypes() throws Exception { - String fileName = "TC1434249.csar"; - String folder ="US825779"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - - List informationalArtifacts = new ArrayList(); - informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); - informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1")); - informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); - } - - // TODO: there is defect in flow: "Updated button enabled for artifact in invalid type folder" - // TODO: re-check it after defect fix - // US824719 - Import VSP - VF informational artifacts - // TC1438310 - Import VF Artifacts - Deployment Artifacts - Artifact Type Invalid - @Test - public void importVFArtifactsDeploymentArtifactsArtifactTypeInvalid() throws Exception { - String fileName = "DeploymentArtifactWithInvalidType.csar"; - String folder ="US825779"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "ArtifactName.yaml", null, "ArtifactName", ArtifactTypeEnum.OTHER.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); - } - - // US824719 - Import VSP - VF informational artifacts - // TC1438311 - Import VF Artifacts - Informational Artifacts - Artifact Type Invalid - @Test - public void importVfArtifactsInformationalArtifactsArtifactTypeInvalid() throws Exception { - String fileName = "InformationArtifactWithInvalidType.csar"; - String folder ="US825779"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - - List informationalArtifacts = new ArrayList(); - informationalArtifacts.add(new ArtifactInfo(null, "ArtifactName.yaml", null, "ArtifactName", ArtifactTypeEnum.OTHER.getType(), "1")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); - } - - // US824719 - Import VSP - VF informational artifacts - // TC1438231 - Import VF Artifacts - Deployment Artifacts - Artifact Name To Long - @Test - public void importVfArtifactsDeploymentArtifactsArtifactNameToLong() throws Exception { - String folder = "US825779"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - String fileName = "DeploymentArtifactWithLongName.csar"; - - importVfFromCsar(resourceMetaData, folder, fileName, getUser()); - - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // START US824719 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // US824719 - Import VSP - VF informational artifacts + // TC1434241 - Import VF Artifacts - Deployment Artifacts - One Artifact, One Type + @Test + public void importVfArtifactsDeploymentArtifactsOneArtifactOneType() throws Exception { + String fileName = "TC1434241.csar"; + String folder = "US825779"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); + } + + // US824719 - Import VSP - VF informational artifacts + // TC1434245 - Import VF Artifacts - Deployment Artifacts - Multiple Artifacts, Multiple Types + @Test + public void importVfArtifactsDeploymentArtifactsMultipleArtifactsMultipleTypes() throws Exception { + String fileName = "TC1434245.csar"; + String folder = "US825779"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1")); + + deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); + + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); + } + + // US824719 - Import VSP - VF informational artifacts + // TC1434247 - Import VF Artifacts - Informational Artifacts - One Artifact, One Type + @Test + public void importVfArtifactsInformationalArtifactsOneArtifactOneType() throws Exception { + String fileName = "TC1434247.csar"; + String folder = "US825779"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + + List informationalArtifacts = new ArrayList(); + informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); + } + + // US824719 - Import VSP - VF informational artifacts + // TC1434248 - Import VF Artifacts - Informational Artifacts - Multiple Artifacts, Multiple Types + @Test + public void importVfArtifactsInformationalArtifactsMultipleArtifactsMultipleTypes() throws Exception { + String fileName = "TC1434248.csar"; + String folder = "US825779"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + + List informationalArtifacts = new ArrayList(); + informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); + informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1")); + informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); + } + + // US824719 - Import VSP - VF informational artifacts + // TC1434249 - Import VF Artifacts - Deployment and Informational Artifacts - Multiple Artifacts, Multiple Types + @Test + public void importVfArtifactsDeploymentAndInformationalArtifactsMultipleArtifactsMultipleTypes() throws Exception { + String fileName = "TC1434249.csar"; + String folder = "US825779"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + + List informationalArtifacts = new ArrayList(); + informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); + informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1")); + informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); + } + + // TODO: there is defect in flow: "Updated button enabled for artifact in invalid type folder" + // TODO: re-check it after defect fix + // US824719 - Import VSP - VF informational artifacts + // TC1438310 - Import VF Artifacts - Deployment Artifacts - Artifact Type Invalid + @Test + public void importVFArtifactsDeploymentArtifactsArtifactTypeInvalid() throws Exception { + String fileName = "DeploymentArtifactWithInvalidType.csar"; + String folder = "US825779"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "ArtifactName.yaml", null, "ArtifactName", ArtifactTypeEnum.OTHER.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); + } + + // US824719 - Import VSP - VF informational artifacts + // TC1438311 - Import VF Artifacts - Informational Artifacts - Artifact Type Invalid + @Test + public void importVfArtifactsInformationalArtifactsArtifactTypeInvalid() throws Exception { + String fileName = "InformationArtifactWithInvalidType.csar"; + String folder = "US825779"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + + List informationalArtifacts = new ArrayList(); + informationalArtifacts.add(new ArtifactInfo(null, "ArtifactName.yaml", null, "ArtifactName", ArtifactTypeEnum.OTHER.getType(), "1")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); + } + + // US824719 - Import VSP - VF informational artifacts + // TC1438231 - Import VF Artifacts - Deployment Artifacts - Artifact Name To Long + @Test + public void importVfArtifactsDeploymentArtifactsArtifactNameToLong() throws Exception { + String folder = "US825779"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + String fileName = "DeploymentArtifactWithLongName.csar"; + + importVfFromCsar(resourceMetaData, folder, fileName, getUser()); + + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); + assertThat(errorMessage).contains(checkUIResponseOnError); + } + + // US824719 - Import VSP - VF informational artifacts + // TC1438232 - Import VF Artifacts - Informational Artifacts - Artifact Name To Long + // TODO: make informational artifact name longer then 255 + // TODO: windows/linux not allowed it + @Test(enabled = false) + public void importVfArtifactsInformationalArtifactsArtifactNameToLong() throws Exception { + String folder = "US825779"; + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + + String fileName = "InformationArtifactWithLongName.csar"; + + importVfFromCsar(resourceMetaData, folder, fileName, getUser()); + + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); + assertThat(errorMessage).contains(checkUIResponseOnError); + } + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // END US824719 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // START US825779 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update + // TC1443954 - Update With Multiple Changes In Deployment And Informational Artifacts + @Test + public void updateWithMultipleChangesInDeploymentAndInformationalArtifacts() throws Exception { + String folder = "US825779"; + String fileName = "ImportTC1443954.csar"; + + ArtifactInfo deploymentHeat1 = new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"); + ArtifactInfo deploymentHeat2 = new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1"); + ArtifactInfo deploymentHeat3 = new ArtifactInfo(null, "heatartifactname3.yaml", null, "heatartifactname3", ArtifactTypeEnum.HEAT.getType(), "1"); + + ArtifactInfo deploymentHeatVol1 = new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1"); + ArtifactInfo deploymentHeatVol2 = new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1"); + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(deploymentHeat1); + deploymentArtifacts.add(deploymentHeat2); + deploymentArtifacts.add(deploymentHeat3); + deploymentArtifacts.add(deploymentHeatVol1); + deploymentArtifacts.add(deploymentHeatVol2); + + ArtifactInfo infoGuide1 = new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1"); + ArtifactInfo infoGuide2 = new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1"); + + ArtifactInfo infoOther1 = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"); + ArtifactInfo infoOther2 = new ArtifactInfo(null, "artifactname2.txt", null, "artifactname2", ArtifactTypeEnum.OTHER.getType(), "1"); + ArtifactInfo infoOther3 = new ArtifactInfo(null, "artifactname3.txt", null, "artifactname3", ArtifactTypeEnum.OTHER.getType(), "1"); + + List informationalArtifacts = new ArrayList(); + informationalArtifacts.add(infoGuide1); + informationalArtifacts.add(infoGuide2); + informationalArtifacts.add(infoOther1); + informationalArtifacts.add(infoOther2); + informationalArtifacts.add(infoOther3); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + + fileName = "UpdateTC1443954.csar"; + + List informationalArtifactsNotExist = new ArrayList(); + List deploymentArtifactsNotExist = new ArrayList(); + + // Changes in deployment artifacts + deploymentArtifactsNotExist.add(deploymentHeat1); + deploymentArtifactsNotExist.add(deploymentHeat2); + deploymentArtifacts.remove(deploymentHeat1); + deploymentArtifacts.remove(deploymentHeat2); + deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname4.yaml", null, "heatartifactname4", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname5.yaml", null, "heatartifactname5", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentHeatVol1.setArtifactVersion("2"); + deploymentHeatVol2.setArtifactVersion("2"); + + // Changes in informational artifacts + infoGuide1.setArtifactVersion("2"); + infoOther1.setArtifactVersion("2"); + informationalArtifactsNotExist.add(infoGuide2); + informationalArtifactsNotExist.add(infoOther2); + informationalArtifacts.remove(infoGuide2); + informationalArtifacts.remove(infoOther2); + informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact3.yml", null, "GuideInfoArtifact3", ArtifactTypeEnum.GUIDE.getType(), "1")); + informationalArtifacts.add(new ArtifactInfo(null, "artifactname4.txt", null, "artifactname4", ArtifactTypeEnum.OTHER.getType(), "1")); + + updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, informationalArtifacts, deploymentArtifactsNotExist, informationalArtifactsNotExist); + } + + + // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update + // TC1444206 - Update With Existed Deployment Artifact By Artifact With Different Type + @Test + public void updateWithExistedDeploymentArtifactByArtifactWithDifferentType() throws Exception { + String folder = "US825779"; + String fileName = "ImportTC1444206.csar"; + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + + fileName = "UpdateTC1444206.csar"; + String filePath = FileHandling.getFilePath(folder); + + ResourceUIUtils.updateVfWithCsar(filePath, fileName); + + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name()); + assertThat(errorMessage).contains(checkUIResponseOnError); + } + + // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update + // TC1444207 - Update With Existed Informational Artifact By Artifact With Different Type + @Test + public void updateWithExistedInformationalArtifactByArtifactWithDifferentType() throws Exception { + String folder = "US825779"; + String fileName = "ImportTC1444207.csar"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + + List informationalArtifacts = new ArrayList(); + informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + + fileName = "UpdateTC1444207.csar"; + String filePath = FileHandling.getFilePath(folder); + + ResourceUIUtils.updateVfWithCsar(filePath, fileName); + + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name()); + assertThat(errorMessage).contains(checkUIResponseOnError); + } + + + // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update + // TC1444208 - Update With Existed Informational Artifact By Deployment Artifact With Different Type + @Test + public void updateWithExistedInformationalArtifactByDeploymentArtifactWithDifferentType() throws Exception { + String folder = "US825779"; + String fileName = "ImportTC1444208.csar"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + + fileName = "UpdateTC1444208.csar"; + String filePath = FileHandling.getFilePath(folder); + + ResourceUIUtils.updateVfWithCsar(filePath, fileName); + + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name()); + assertThat(errorMessage).contains(checkUIResponseOnError); + } + + // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update + // TC1444520 - Update Deployment Artifact With Name To Long + @Test + public void updateDeploymentArtifactWithNameToLong() throws Exception { + String folder = "US825779"; + + String fileName = "ImportTC1444520.csar"; + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, null, null); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + + fileName = "UpdateTC1444520.csar"; + String filePath = FileHandling.getFilePath(folder); + + ResourceUIUtils.updateVfWithCsar(filePath, fileName); + + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); assertThat(errorMessage).contains(checkUIResponseOnError); - } - - // US824719 - Import VSP - VF informational artifacts - // TC1438232 - Import VF Artifacts - Informational Artifacts - Artifact Name To Long - // TODO: make informational artifact name longer then 255 - // TODO: windows/linux not allowed it - @Test(enabled=false) - public void importVfArtifactsInformationalArtifactsArtifactNameToLong() throws Exception { - String folder ="US825779"; - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - - String fileName = "InformationArtifactWithLongName.csar"; - - importVfFromCsar(resourceMetaData, folder, fileName, getUser()); - - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); - assertThat(errorMessage).contains(checkUIResponseOnError); - } - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // END US824719 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // START US825779 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1443954 - Update With Multiple Changes In Deployment And Informational Artifacts - @Test - public void updateWithMultipleChangesInDeploymentAndInformationalArtifacts() throws Exception { - String folder ="US825779"; - String fileName = "ImportTC1443954.csar"; - - ArtifactInfo deploymentHeat1 = new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"); - ArtifactInfo deploymentHeat2 = new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1"); - ArtifactInfo deploymentHeat3 = new ArtifactInfo(null, "heatartifactname3.yaml", null, "heatartifactname3", ArtifactTypeEnum.HEAT.getType(), "1"); - - ArtifactInfo deploymentHeatVol1 = new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1"); - ArtifactInfo deploymentHeatVol2 = new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1"); - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(deploymentHeat1); - deploymentArtifacts.add(deploymentHeat2); - deploymentArtifacts.add(deploymentHeat3); - deploymentArtifacts.add(deploymentHeatVol1); - deploymentArtifacts.add(deploymentHeatVol2); - - ArtifactInfo infoGuide1 = new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1"); - ArtifactInfo infoGuide2 = new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1"); - - ArtifactInfo infoOther1 = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"); - ArtifactInfo infoOther2 = new ArtifactInfo(null, "artifactname2.txt", null, "artifactname2", ArtifactTypeEnum.OTHER.getType(), "1"); - ArtifactInfo infoOther3 = new ArtifactInfo(null, "artifactname3.txt", null, "artifactname3", ArtifactTypeEnum.OTHER.getType(), "1"); - - List informationalArtifacts = new ArrayList(); - informationalArtifacts.add(infoGuide1); - informationalArtifacts.add(infoGuide2); - informationalArtifacts.add(infoOther1); - informationalArtifacts.add(infoOther2); - informationalArtifacts.add(infoOther3); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1443954.csar"; - - List informationalArtifactsNotExist = new ArrayList(); - List deploymentArtifactsNotExist = new ArrayList(); - - // Changes in deployment artifacts - deploymentArtifactsNotExist.add(deploymentHeat1); - deploymentArtifactsNotExist.add(deploymentHeat2); - deploymentArtifacts.remove(deploymentHeat1); - deploymentArtifacts.remove(deploymentHeat2); - deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname4.yaml", null, "heatartifactname4", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname5.yaml", null, "heatartifactname5", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentHeatVol1.setArtifactVersion("2"); - deploymentHeatVol2.setArtifactVersion("2"); - - // Changes in informational artifacts - infoGuide1.setArtifactVersion("2"); - infoOther1.setArtifactVersion("2"); - informationalArtifactsNotExist.add(infoGuide2); - informationalArtifactsNotExist.add(infoOther2); - informationalArtifacts.remove(infoGuide2); - informationalArtifacts.remove(infoOther2); - informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact3.yml", null, "GuideInfoArtifact3", ArtifactTypeEnum.GUIDE.getType(), "1")); - informationalArtifacts.add(new ArtifactInfo(null, "artifactname4.txt", null, "artifactname4", ArtifactTypeEnum.OTHER.getType(), "1")); - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, informationalArtifacts, deploymentArtifactsNotExist, informationalArtifactsNotExist); - } - - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1444206 - Update With Existed Deployment Artifact By Artifact With Different Type - @Test - public void updateWithExistedDeploymentArtifactByArtifactWithDifferentType() throws Exception { - String folder ="US825779"; - String fileName = "ImportTC1444206.csar"; - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1444206.csar"; - String filePath = FileHandling.getFilePath(folder); ; - - ResourceUIUtils.updateVfWithCsar(filePath, fileName); - - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name()); - assertThat(errorMessage).contains(checkUIResponseOnError); - } - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1444207 - Update With Existed Informational Artifact By Artifact With Different Type - @Test - public void updateWithExistedInformationalArtifactByArtifactWithDifferentType() throws Exception { - String folder ="US825779"; - String fileName = "ImportTC1444207.csar"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - - List informationalArtifacts = new ArrayList(); - informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1444207.csar"; - String filePath = FileHandling.getFilePath(folder); - - ResourceUIUtils.updateVfWithCsar(filePath, fileName); - - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name()); - assertThat(errorMessage).contains(checkUIResponseOnError); - } - - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1444208 - Update With Existed Informational Artifact By Deployment Artifact With Different Type - @Test - public void updateWithExistedInformationalArtifactByDeploymentArtifactWithDifferentType() throws Exception { - String folder ="US825779"; - String fileName = "ImportTC1444208.csar"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1444208.csar"; - String filePath = FileHandling.getFilePath(folder); ; - - ResourceUIUtils.updateVfWithCsar(filePath, fileName); - - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name()); - assertThat(errorMessage).contains(checkUIResponseOnError); - } - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1444520 - Update Deployment Artifact With Name To Long - @Test - public void updateDeploymentArtifactWithNameToLong() throws Exception { - String folder ="US825779"; - - String fileName = "ImportTC1444520.csar"; - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, null, null); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1444520.csar"; - String filePath = FileHandling.getFilePath(folder); ; - - ResourceUIUtils.updateVfWithCsar(filePath, fileName); - - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); - assertThat(errorMessage).contains(checkUIResponseOnError); - } - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1444521 - Update Informational Artifact With Name To Long - @Test - public void updateInformationalArtifactWithNameToLong() throws Exception { - - String folder = "US825779"; - String fileName = "ImportTC1444521.csar"; - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, null, null); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1444521.csar"; - String filePath = FileHandling.getFilePath(folder); ; - - ResourceUIUtils.updateVfWithCsar(filePath, fileName); - - String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); - assertThat(errorMessage).contains(checkUIResponseOnError); - } - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1444531 - Update Informational Artifact With Invalid Type - @Test - public void updateInformationalArtifactWithInvalidType() throws Exception { - String folder ="US825779"; - String fileName = "ImportTC1444531.csar"; - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, null, null); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1444531.csar"; - - List informationalArtifacts = new ArrayList(); - informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, null, informationalArtifacts, null, null); - } - - - @Test - public void importValidInformationalArtifactInInvalidFolerTest_TC1438313() throws Exception{ - String fileName = "ValidArtifactNameInInvalidFolder.csar"; - String folder = "US824719"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); - } - - @Test - public void updateValidInformationalArtifactInInvalidFolerTest_TC1444533() throws Exception{ - String fileName = "ImportTC1444533.csar"; - String folder = "US824719"; - String filePath = FileHandling.getFilePath(folder); - - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); - - String updatedCsarFileName = "UpdateTC1444533.csar"; - - List deploymentArtifacts = new ArrayList(); - deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); - deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4")); - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, updatedCsarFileName, deploymentArtifacts, null, null, null); - } - - - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // END US825779 - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - public void updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(String folder, String fileName, - List deploymentArtifacts, List informationalArtifacts, - List deploymentArtifactsNotExist, List informationalArtifactsNotExist) throws Exception { - String filePath = FileHandling.getFilePath(folder); - ResourceUIUtils.updateVfWithCsar(filePath, fileName); - - validateDeploymentArtifactPage(deploymentArtifacts, null); - validateInformationalArtifactPage(informationalArtifacts, null); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - validateDeploymentArtifactInComposition(deploymentArtifacts, null); - validateInformationalArtifactInComposition(informationalArtifacts, null); - - } - - - public void importVfFromCsar(ResourceReqDetails resourceMetaData, String folder, String fileName, User user) { - String filePath = FileHandling.getFilePath(folder); - GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue()); - // Insert file to the browse dialog - WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VF_FILE.getValue()); - browseWebElement.sendKeys(filePath + fileName); - - // Fill the general page fields. - GeneralUIUtils.waitForLoader(); - ResourceUIUtils.fillResourceGeneralInformationPage(resourceMetaData, getUser(), true); - GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); - } - - - - - public void importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(String fileName, String folder, List deploymentArtifacts, List informationalArtifacts) throws Exception { - String filePath = FileHandling.getFilePath(folder); - ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); - ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); - - validateDeploymentArtifactPage(deploymentArtifacts, null); - validateInformationalArtifactPage(informationalArtifacts, null); - - ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - validateDeploymentArtifactInComposition(deploymentArtifacts, null); - validateInformationalArtifactInComposition(informationalArtifacts, null); - } - - public void validateInformationalArtifactInComposition(List informationalArtifacts, List informationalArtifactsNotExist) throws Exception { - CompositionPage.showInformationArtifactTab(); - // Composition informational - if(informationalArtifacts != null && informationalArtifacts.size() > 0) { - validateEachArtifactOnCompositionRightMenuInformationPage(informationalArtifacts); - } - if(informationalArtifactsNotExist != null && informationalArtifactsNotExist.size() > 0) { - validateEachArtifactNotExistOnCompositionRightMenuInformationPage(informationalArtifactsNotExist); - } - } - - public void validateDeploymentArtifactInComposition(List deploymentArtifacts, List deploymentArtifactsNotExist) throws Exception { - CompositionPage.showDeploymentArtifactTab(); - // Composition deployment - if(deploymentArtifacts != null && deploymentArtifacts.size() > 0) { - validateEachArtifactOnCompositionRightMenuDeploymentPage(deploymentArtifacts); - } - if(deploymentArtifactsNotExist != null && deploymentArtifactsNotExist.size() > 0) { - validateEachArtifactNotExistOnCompositionRightMenuDeploymentPage(deploymentArtifactsNotExist); - } - } - - public void validateInformationalArtifactPage(List informationalArtifacts, List informationalArtifactsNotExist) { - ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - // Informational page - if(informationalArtifacts != null && informationalArtifacts.size() > 0) { - validateEachArtifactInformationPage(informationalArtifacts); - } - if(informationalArtifactsNotExist != null && informationalArtifactsNotExist.size() > 0) { - validateEachArtifactNotExistInformationPage(informationalArtifactsNotExist); - } - } - - public void validateDeploymentArtifactPage(List deploymentArtifacts, List deploymentArtifactsNotExist) { - ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - // Deployment page - if(deploymentArtifacts != null && deploymentArtifacts.size() > 0) { - validateEachArtifactOnDeploymentPage(deploymentArtifacts); - } - if(deploymentArtifactsNotExist != null && deploymentArtifactsNotExist.size() > 0) { - validateEachArtifactNotExistOnDeploymentPage(deploymentArtifactsNotExist); - } - } - - // TODO: add validation that if not editable / deleteable then button should not appear - public void validateEachArtifactOnDeploymentPage(List artifactInfoList) { - for(ArtifactInfo artifact: artifactInfoList) { - String type = artifact.getArtifactType(); - String label = artifact.getArtifactLabel(); - String version = artifact.getArtifactVersion(); - - if (type.equals(ArtifactTypeEnum.HEAT.getType()) || type.equals(ArtifactTypeEnum.HEAT_VOL.getType()) || type.equals(ArtifactTypeEnum.HEAT_NET.getType())){ - ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(label, null, version, type, true, false, false, true); - } - else{ - ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(label, null, version, type, true, true, true, false); - } - } - } - - public void validateEachArtifactNotExistOnDeploymentPage(List artifactInfoList) { - for(ArtifactInfo artifact: artifactInfoList) { - ArtifactUIUtils.validateNotExistArtifactOnDeploymentInformationPage(artifact.getArtifactLabel()); - } - } - - public void validateEachArtifactInformationPage(List artifactInfoList) { - for(ArtifactInfo artifact: artifactInfoList) { - ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(artifact.getArtifactLabel(), null, artifact.getArtifactVersion(), artifact.getArtifactType(), true, true, true, false); - } - } - - public void validateEachArtifactNotExistInformationPage(List artifactInfoList) { - for(ArtifactInfo artifact: artifactInfoList) { - ArtifactUIUtils.validateNotExistArtifactOnDeploymentInformationPage(artifact.getArtifactLabel()); - } - } - - public void validateEachArtifactOnCompositionRightMenuDeploymentPage(List artifactInfoList) { - for(ArtifactInfo artifact: artifactInfoList) { - - String type = artifact.getArtifactType(); - String label = artifact.getArtifactLabel(); - String filename = artifact.getFilename(); - - if (type.equals(ArtifactTypeEnum.HEAT.getType()) || type.equals(ArtifactTypeEnum.HEAT_VOL.getType()) || type.equals(ArtifactTypeEnum.HEAT_NET.getType())){ - ArtifactUIUtils.validateExistArtifactOnCompositionRightMenuDeploymentInformationPage(filename, label, false, true, true, false); - } - else{ - ArtifactUIUtils.validateExistArtifactOnCompositionRightMenuDeploymentInformationPage(filename, label, true, false, true, true); - } - } - } - - public void validateEachArtifactNotExistOnCompositionRightMenuDeploymentPage(List artifactInfoList) { - for(ArtifactInfo artifact: artifactInfoList) { - ArtifactUIUtils.validateNotExistArtifactOnCompositionRightMenuDeploymentInformationPage(artifact.getArtifactLabel()); - } - } - - // TODO: there is defect in this flow - // TODO: change isEditable to false when defect fix - public void validateEachArtifactOnCompositionRightMenuInformationPage(List artifactInfoList) { - for(ArtifactInfo artifact: artifactInfoList) { - ArtifactUIUtils.validateExistArtifactOnCompositionRightMenuDeploymentInformationPage(artifact.getFilename(), artifact.getArtifactLabel(), true, false, true, true); - } - } - - public void validateEachArtifactNotExistOnCompositionRightMenuInformationPage(List artifactInfoList) { - for(ArtifactInfo artifact: artifactInfoList) { - ArtifactUIUtils.validateNotExistArtifactOnCompositionRightMenuDeploymentInformationPage(artifact.getArtifactLabel()); - } - } - - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + } + + // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update + // TC1444521 - Update Informational Artifact With Name To Long + @Test + public void updateInformationalArtifactWithNameToLong() throws Exception { + + String folder = "US825779"; + String fileName = "ImportTC1444521.csar"; + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, null, null); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + + fileName = "UpdateTC1444521.csar"; + String filePath = FileHandling.getFilePath(folder); + + ResourceUIUtils.updateVfWithCsar(filePath, fileName); + + String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); + assertThat(errorMessage).contains(checkUIResponseOnError); + } + + // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update + // TC1444531 - Update Informational Artifact With Invalid Type + @Test + public void updateInformationalArtifactWithInvalidType() throws Exception { + String folder = "US825779"; + String fileName = "ImportTC1444531.csar"; + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, null, null); + + GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); + + fileName = "UpdateTC1444531.csar"; + + List informationalArtifacts = new ArrayList(); + informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); + + updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, null, informationalArtifacts, null, null); + } + + + @Test + public void importValidInformationalArtifactInInvalidFolerTest_TC1438313() throws Exception { + String fileName = "ValidArtifactNameInInvalidFolder.csar"; + String folder = "US824719"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + + importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); + } + + @Test + public void updateValidInformationalArtifactInInvalidFolerTest_TC1444533() throws Exception { + String fileName = "ImportTC1444533.csar"; + String folder = "US824719"; + String filePath = FileHandling.getFilePath(folder); + + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); + + String updatedCsarFileName = "UpdateTC1444533.csar"; + + List deploymentArtifacts = new ArrayList(); + deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2")); + deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4")); + + updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, updatedCsarFileName, deploymentArtifacts, null, null, null); + } + + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // END US825779 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + + public void updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(String folder, String fileName, + List deploymentArtifacts, List informationalArtifacts, + List deploymentArtifactsNotExist, List informationalArtifactsNotExist) throws Exception { + String filePath = FileHandling.getFilePath(folder); + ResourceUIUtils.updateVfWithCsar(filePath, fileName); + + validateDeploymentArtifactPage(deploymentArtifacts, null); + validateInformationalArtifactPage(informationalArtifacts, null); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + validateDeploymentArtifactInComposition(deploymentArtifacts, null); + validateInformationalArtifactInComposition(informationalArtifacts, null); + + } + + + public void importVfFromCsar(ResourceReqDetails resourceMetaData, String folder, String fileName, User user) { + String filePath = FileHandling.getFilePath(folder); + GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue()); + // Insert file to the browse dialog + WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VF_FILE.getValue()); + browseWebElement.sendKeys(filePath + fileName); + + // Fill the general page fields. + GeneralUIUtils.waitForLoader(); + ResourceUIUtils.fillResourceGeneralInformationPage(resourceMetaData, getUser(), true); + GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); + } + + + public void importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(String fileName, String folder, List deploymentArtifacts, List informationalArtifacts) throws Exception { + String filePath = FileHandling.getFilePath(folder); + ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser()); + + validateDeploymentArtifactPage(deploymentArtifacts, null); + validateInformationalArtifactPage(informationalArtifacts, null); + + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + + validateDeploymentArtifactInComposition(deploymentArtifacts, null); + validateInformationalArtifactInComposition(informationalArtifacts, null); + } + + public void validateInformationalArtifactInComposition(List informationalArtifacts, List informationalArtifactsNotExist) throws Exception { + CompositionPage.showInformationArtifactTab(); + // Composition informational + if (informationalArtifacts != null && informationalArtifacts.size() > 0) { + validateEachArtifactOnCompositionRightMenuInformationPage(informationalArtifacts); + } + if (informationalArtifactsNotExist != null && informationalArtifactsNotExist.size() > 0) { + validateEachArtifactNotExistOnCompositionRightMenuInformationPage(informationalArtifactsNotExist); + } + } + + public void validateDeploymentArtifactInComposition(List deploymentArtifacts, List deploymentArtifactsNotExist) throws Exception { + CompositionPage.showDeploymentArtifactTab(); + // Composition deployment + if (deploymentArtifacts != null && deploymentArtifacts.size() > 0) { + validateEachArtifactOnCompositionRightMenuDeploymentPage(deploymentArtifacts); + } + if (deploymentArtifactsNotExist != null && deploymentArtifactsNotExist.size() > 0) { + validateEachArtifactNotExistOnCompositionRightMenuDeploymentPage(deploymentArtifactsNotExist); + } + } + + public void validateInformationalArtifactPage(List informationalArtifacts, List informationalArtifactsNotExist) { + ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); + // Informational page + if (informationalArtifacts != null && informationalArtifacts.size() > 0) { + validateEachArtifactInformationPage(informationalArtifacts); + } + if (informationalArtifactsNotExist != null && informationalArtifactsNotExist.size() > 0) { + validateEachArtifactNotExistInformationPage(informationalArtifactsNotExist); + } + } + + public void validateDeploymentArtifactPage(List deploymentArtifacts, List deploymentArtifactsNotExist) { + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + // Deployment page + if (deploymentArtifacts != null && deploymentArtifacts.size() > 0) { + validateEachArtifactOnDeploymentPage(deploymentArtifacts); + } + if (deploymentArtifactsNotExist != null && deploymentArtifactsNotExist.size() > 0) { + validateEachArtifactNotExistOnDeploymentPage(deploymentArtifactsNotExist); + } + } + + // TODO: add validation that if not editable / deleteable then button should not appear + public void validateEachArtifactOnDeploymentPage(List artifactInfoList) { + for (ArtifactInfo artifact : artifactInfoList) { + String type = artifact.getArtifactType(); + String label = artifact.getArtifactLabel(); + String version = artifact.getArtifactVersion(); + + if (type.equals(ArtifactTypeEnum.HEAT.getType()) || type.equals(ArtifactTypeEnum.HEAT_VOL.getType()) || type.equals(ArtifactTypeEnum.HEAT_NET.getType())) { + ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(label, null, version, type, true, false, false, true); + } else { + ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(label, null, version, type, true, true, true, false); + } + } + } + + public void validateEachArtifactNotExistOnDeploymentPage(List artifactInfoList) { + for (ArtifactInfo artifact : artifactInfoList) { + ArtifactUIUtils.validateNotExistArtifactOnDeploymentInformationPage(artifact.getArtifactLabel()); + } + } + + public void validateEachArtifactInformationPage(List artifactInfoList) { + for (ArtifactInfo artifact : artifactInfoList) { + ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(artifact.getArtifactLabel(), null, artifact.getArtifactVersion(), artifact.getArtifactType(), true, true, true, false); + } + } + + public void validateEachArtifactNotExistInformationPage(List artifactInfoList) { + for (ArtifactInfo artifact : artifactInfoList) { + ArtifactUIUtils.validateNotExistArtifactOnDeploymentInformationPage(artifact.getArtifactLabel()); + } + } + + public void validateEachArtifactOnCompositionRightMenuDeploymentPage(List artifactInfoList) { + for (ArtifactInfo artifact : artifactInfoList) { + + String type = artifact.getArtifactType(); + String label = artifact.getArtifactLabel(); + String filename = artifact.getFilename(); + + if (type.equals(ArtifactTypeEnum.HEAT.getType()) || type.equals(ArtifactTypeEnum.HEAT_VOL.getType()) || type.equals(ArtifactTypeEnum.HEAT_NET.getType())) { + ArtifactUIUtils.validateExistArtifactOnCompositionRightMenuDeploymentInformationPage(filename, label, false, true, true, false); + } else { + ArtifactUIUtils.validateExistArtifactOnCompositionRightMenuDeploymentInformationPage(filename, label, true, false, true, true); + } + } + } + + public void validateEachArtifactNotExistOnCompositionRightMenuDeploymentPage(List artifactInfoList) { + for (ArtifactInfo artifact : artifactInfoList) { + ArtifactUIUtils.validateNotExistArtifactOnCompositionRightMenuDeploymentInformationPage(artifact.getArtifactLabel()); + } + } + + // TODO: there is defect in this flow + // TODO: change isEditable to false when defect fix + public void validateEachArtifactOnCompositionRightMenuInformationPage(List artifactInfoList) { + for (ArtifactInfo artifact : artifactInfoList) { + ArtifactUIUtils.validateExistArtifactOnCompositionRightMenuDeploymentInformationPage(artifact.getFilename(), artifact.getArtifactLabel(), true, false, true, true); + } + } + + public void validateEachArtifactNotExistOnCompositionRightMenuInformationPage(List artifactInfoList) { + for (ArtifactInfo artifact : artifactInfoList) { + ArtifactUIUtils.validateNotExistArtifactOnCompositionRightMenuDeploymentInformationPage(artifact.getArtifactLabel()); + } + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ArtifactsCorrelationManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ArtifactsCorrelationManager.java index 7b7fb8ed39..ce46d5b833 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ArtifactsCorrelationManager.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ArtifactsCorrelationManager.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,44 +29,44 @@ import java.util.Set; public class ArtifactsCorrelationManager { - private static HashMap> vNFArtifactsCorrelationMap = new HashMap>(); - private static HashMap>> serviceVNFCorrelationMap = new HashMap>>(); - - public static void addVNFartifactDetails(String vspName, - LinkedList deploymentArtifacts) { - - vNFArtifactsCorrelationMap.put(vspName, deploymentArtifacts); - - - } - - public static Entry> getVNFartifactDetails(String vnfName){ - - - Set>> entrySet = vNFArtifactsCorrelationMap.entrySet(); - for (Entry> entry : entrySet) { - String key = entry.getKey(); - if (key.equals(vnfName)) { - return entry; - } - - } - return null; - - } - - - public static void addVNFtoServiceArtifactCorrelation(String service, String vnfName){ - - serviceVNFCorrelationMap.put(service, getVNFartifactDetails(vnfName)); - - } - - public static Set>>> getServiceArtifactCorrelationMap(String service){ - - return serviceVNFCorrelationMap.entrySet(); - - } - + private static HashMap> vNFArtifactsCorrelationMap = new HashMap>(); + private static HashMap>> serviceVNFCorrelationMap = new HashMap>>(); + + public static void addVNFartifactDetails(String vspName, + LinkedList deploymentArtifacts) { + + vNFArtifactsCorrelationMap.put(vspName, deploymentArtifacts); + + + } + + public static Entry> getVNFartifactDetails(String vnfName) { + + + Set>> entrySet = vNFArtifactsCorrelationMap.entrySet(); + for (Entry> entry : entrySet) { + String key = entry.getKey(); + if (key.equals(vnfName)) { + return entry; + } + + } + return null; + + } + + + public static void addVNFtoServiceArtifactCorrelation(String service, String vnfName) { + + serviceVNFCorrelationMap.put(service, getVNFartifactDetails(vnfName)); + + } + + public static Set>>> getServiceArtifactCorrelationMap(String service) { + + return serviceVNFCorrelationMap.entrySet(); + + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java index f34ada6a70..37e8855800 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,84 +24,86 @@ import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.apache.commons.net.ftp.FTPReply; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; import java.util.stream.Collectors; public class AttFtpClient { - private static final AttFtpClient instance = new AttFtpClient(); + private static final AttFtpClient FTP_CLIENT = new AttFtpClient(); - public static AttFtpClient getInstance() { - return instance; - } + public static AttFtpClient getFtpClient() { + return FTP_CLIENT; + } - private FTPClient apacheFtpClient; + private FTPClient apacheFtpClient; - private AttFtpClient() { - apacheFtpClient = new FTPClient(); - }; + private AttFtpClient() { + apacheFtpClient = new FTPClient(); + } - public void init(String server, int port, String user, String pass) { + public void init(String server, int port, String user, String pass) { - try { - apacheFtpClient.connect(server, port); - showServerReply(apacheFtpClient); - - - int replyCode = apacheFtpClient.getReplyCode(); - if (!FTPReply.isPositiveCompletion(replyCode)) { - System.out.println("Connect failed"); - return; - } + try { + apacheFtpClient.connect(server, port); + showServerReply(apacheFtpClient); - boolean success = apacheFtpClient.login(user, pass); - showServerReply(apacheFtpClient); - if (!success) { - System.out.println("Could not login to the server"); - return; - } - -// else{ -// apacheFtpClient.enterLocalPassiveMode(); -// apacheFtpClient.setFileType(FTP.BINARY_FILE_TYPE); -// } - } catch (IOException ex) { - System.out.println("Oops! Something wrong happened"); - ex.printStackTrace(); - } + int replyCode = apacheFtpClient.getReplyCode(); + if (!FTPReply.isPositiveCompletion(replyCode)) { + System.out.println("Connect failed"); + return; + } - } + boolean success = apacheFtpClient.login(user, pass); + showServerReply(apacheFtpClient); - public File retrieveLastModifiedFileFromFTP() throws IOException { - FTPFile[] files1 = retrieveListOfFile(); + if (!success) { + System.out.println("Could not login to the server"); + return; + } + } catch (IOException ex) { + System.out.println("Oops! Something wrong happened"); + ex.printStackTrace(); + } + } + + public File retrieveLastModifiedFileFromFTP() throws IOException { + FTPFile[] files1 = retrieveListOfFile(); + + // sort list by TimeStamp + List sorted = Arrays.asList(files1).stream() + .sorted(Comparator.comparing(FTPFile::getTimestamp)).collect(Collectors.toList()); + printFileDetailsList(sorted); + + // retrieve file from FTP + FTPFile ftpFile = sorted.get(sorted.size() - 1); - // sort list by TimeStamp - List sorted = Arrays.asList(files1).stream() - .sorted((e1, e2) -> e1.getTimestamp().compareTo(e2.getTimestamp())).collect(Collectors.toList()); - printFileDetailsList(sorted); + return retrieveFileFromFTP(ftpFile); - // retrieve file from FTP - FTPFile ftpFile = sorted.get(sorted.size() - 1); + } - return retrieveFileFromFTP(ftpFile); + public FTPFile[] retrieveListOfFile() throws IOException { + // Lists files and directories + FTPFile[] files = apacheFtpClient.listFiles(""); - } + printNames(files); + return files; + } - public FTPFile[] retrieveListOfFile() throws IOException { - // Lists files and directories - FTPFile[] files = apacheFtpClient.listFiles(""); - - printNames(files); - return files; - } + public File retrieveFileFromFTP(FTPFile ftpFile) throws IOException { - public File retrieveFileFromFTP(FTPFile ftpFile) throws IOException { - File downloadFile1 = new File("tmp"); OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(downloadFile1)); boolean success = apacheFtpClient.retrieveFile(ftpFile.getName(), outputStream1); @@ -110,100 +112,100 @@ public class AttFtpClient { if (success) { System.out.println("File #1 has been downloaded successfully."); } - - - return downloadFile1; - - } - - public void deleteFilesFromFTPserver() throws IOException { - FTPFile[] files = retrieveListOfFile(); - deleteFiles(files); - } - - public void terminateClient() throws IOException { - - String status = apacheFtpClient.getStatus(); - - // logs out and disconnects from server - try { - if (apacheFtpClient.isConnected()) { - apacheFtpClient.logout(); - apacheFtpClient.disconnect(); - } - } catch (IOException ex) { - ex.printStackTrace(); - } - } - - private void printFileDetailsList(List list) { - DateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - for (FTPFile ftpFile : list) { - - String details = ftpFile.getName(); - if (ftpFile.isDirectory()) { - details = "[" + details + "]"; - } - details += "\t\t" + ftpFile.getSize(); - details += "\t\t" + dateFormater.format(ftpFile.getTimestamp().getTime()); - - System.out.println(details); - } - } - - private void printNames(FTPFile[] files) { - if (files != null && files.length > 0) { - for (FTPFile aFile : files) { - System.out.println(aFile); - } - } - } - - private void showServerReply(FTPClient ftpClient) { - String[] replies = ftpClient.getReplyStrings(); - if (replies != null && replies.length > 0) { - for (String aReply : replies) { - System.out.println("SERVER: " + aReply); - } - } - } - - public class LastModifiedComparator implements Comparator { - - public int compare(FTPFile f1, FTPFile f2) { - return f1.getTimestamp().compareTo(f2.getTimestamp()); - } - } - - public FTPFile getMaxLastModified(FTPFile[] ftpFiles) { - return Collections.max(Arrays.asList(ftpFiles), new LastModifiedComparator()); - } - - public static void displayFiles(File[] files) { - for (File file : files) { - System.out.printf("File: %-20s Last Modified:" + new Date(file.lastModified()) + "\n", file.getName()); - } - } - - public void deleteFiles(FTPFile[] files) { - - for (FTPFile file : files) { - - boolean deleted = false; - try { - deleted = apacheFtpClient.deleteFile(file.getName()); - } catch (IOException e) { - e.printStackTrace(); - } - - if (deleted) { - System.out.println("The file was deleted successfully."); - } else { - System.out.println("Could not delete the  file, it may not exist."); - } - } - - } + + + return downloadFile1; + + } + + public void deleteFilesFromFTPserver() throws IOException { + FTPFile[] files = retrieveListOfFile(); + deleteFiles(files); + } + + public void terminateClient() throws IOException { + + String status = apacheFtpClient.getStatus(); + + // logs out and disconnects from server + try { + if (apacheFtpClient.isConnected()) { + apacheFtpClient.logout(); + apacheFtpClient.disconnect(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + + private void printFileDetailsList(List list) { + DateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + for (FTPFile ftpFile : list) { + + String details = ftpFile.getName(); + if (ftpFile.isDirectory()) { + details = "[" + details + "]"; + } + details += "\t\t" + ftpFile.getSize(); + details += "\t\t" + dateFormater.format(ftpFile.getTimestamp().getTime()); + + System.out.println(details); + } + } + + private void printNames(FTPFile[] files) { + if (files != null && files.length > 0) { + for (FTPFile aFile : files) { + System.out.println(aFile); + } + } + } + + private void showServerReply(FTPClient ftpClient) { + String[] replies = ftpClient.getReplyStrings(); + if (replies != null && replies.length > 0) { + for (String aReply : replies) { + System.out.println("SERVER: " + aReply); + } + } + } + + public class LastModifiedComparator implements Comparator { + + public int compare(FTPFile f1, FTPFile f2) { + return f1.getTimestamp().compareTo(f2.getTimestamp()); + } + } + + public FTPFile getMaxLastModified(FTPFile[] ftpFiles) { + return Collections.max(Arrays.asList(ftpFiles), new LastModifiedComparator()); + } + + public static void displayFiles(File[] files) { + for (File file : files) { + System.out.printf("File: %-20s Last Modified:" + new Date(file.lastModified()) + "\n", file.getName()); + } + } + + public void deleteFiles(FTPFile[] files) { + + for (FTPFile file : files) { + + boolean deleted = false; + try { + deleted = apacheFtpClient.deleteFile(file.getName()); + } catch (IOException e) { + e.printStackTrace(); + } + + if (deleted) { + System.out.println("The file was deleted successfully."); + } else { + System.out.println("Could not delete the  file, it may not exist."); + } + } + + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java index 0ba51de87a..7ba689cd95 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,95 +34,99 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FilenameFilter; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; public class DriverFactory { - private static ThreadLocal driverThread; - private static List webDriverThreadPool = Collections.synchronizedList(new ArrayList()); - private static Config config; - - public DriverFactory() { - try { - config = Utils.getConfig(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - - @BeforeSuite(alwaysRun = true) - public static void instantiateDriverObject() { - - // Selenium 3.4.0 change, location of gecko driver, set system property + private static ThreadLocal driverThread; + private static List webDriverThreadPool = Collections.synchronizedList(new ArrayList()); + private static Config config; + + public DriverFactory() { + try { + config = Utils.getConfig(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + @BeforeSuite(alwaysRun = true) + public static void instantiateDriverObject() { + + // Selenium 3.4.0 change, location of gecko driver, set system property // System.setProperty("webdriver.gecko.driver","C:\\Gekko18\\geckodriver-v0.18.0-win64\\geckodriver.exe"); //change for 3.4.0, gecko driver location - // End of Selenium 3.4.0 change - - File basePath = new File(FileHandling.getBasePath()); - File[] listFiles = basePath.listFiles(new FilenameFilter() { - - @Override - public boolean accept(File basePath, String name) { - return name.startsWith(WebDriverThread.AUTOMATION_DOWNLOAD_DIR); - } - }); - Arrays.asList(listFiles).forEach(e -> FileHandling.deleteDirectory(e.getAbsolutePath())); - - - - driverThread = new ThreadLocal() { - @Override - protected WebDriverThread initialValue() { - WebDriverThread webDriverThread = new WebDriverThread(config); - webDriverThreadPool.add(webDriverThread); - return webDriverThread; - } - }; - } - - public static WebDriver getDriver() throws Exception { - return driverThread.get().getDriver(); - } - - public static FirefoxProfile getDriverFirefoxProfile() throws Exception { - return driverThread.get().getFirefoxProfile(); - } - - @AfterSuite(alwaysRun = true) - public static void quitDriverAfterSuite() throws Exception { - for (WebDriverThread webDriverThread : webDriverThreadPool) { - if (webDriverThread.getDriver() != null) - webDriverThread.quitDriver(); - } - - MobProxy.removeAllProxyServers(); - - deleteDownloadDirs(); - } - - private static void deleteDownloadDirs() throws IOException { -// System.gc(); - HashMap windowMap = WindowTestManager.getWholeMap(); - for (WindowTest win : windowMap.values()){ - String downloadDirectory = win.getDownloadDirectory(); - FileUtils.deleteDirectory(new File(downloadDirectory)); - } - } - - public static void quitDriver() throws Exception{ - driverThread.get().quitDriver(); - driverThread.remove(); - WindowTestManager.removeWindowTest(); - MobProxy.removePoxyServer(); - } - - public static Config getConfig() { - return config; - } - - public static void setConfig(Config config) { - DriverFactory.config = config; - } - + // End of Selenium 3.4.0 change + + File basePath = new File(FileHandling.getBasePath()); + File[] listFiles = basePath.listFiles(new FilenameFilter() { + + @Override + public boolean accept(File basePath, String name) { + return name.startsWith(WebDriverThread.AUTOMATION_DOWNLOAD_DIR); + } + }); + Arrays.asList(listFiles).forEach(e -> FileHandling.deleteDirectory(e.getAbsolutePath())); + + + driverThread = new ThreadLocal() { + @Override + protected WebDriverThread initialValue() { + WebDriverThread webDriverThread = new WebDriverThread(config); + webDriverThreadPool.add(webDriverThread); + return webDriverThread; + } + }; + } + + public static WebDriver getDriver() throws Exception { + return driverThread.get().getDriver(); + } + + public static FirefoxProfile getDriverFirefoxProfile() throws Exception { + return driverThread.get().getFirefoxProfile(); + } + + @AfterSuite(alwaysRun = true) + public static void quitDriverAfterSuite() throws Exception { + for (WebDriverThread webDriverThread : webDriverThreadPool) { + if (webDriverThread.getDriver() != null) { + webDriverThread.quitDriver(); + } + } + + MobProxy.removeAllProxyServers(); + + deleteDownloadDirs(); + } + + private static void deleteDownloadDirs() throws IOException { + //System.gc(); + HashMap windowMap = WindowTestManager.getWholeMap(); + for (WindowTest win : windowMap.values()) { + String downloadDirectory = win.getDownloadDirectory(); + FileUtils.deleteDirectory(new File(downloadDirectory)); + } + } + + public static void quitDriver() throws Exception { + driverThread.get().quitDriver(); + driverThread.remove(); + WindowTestManager.removeWindowTest(); + MobProxy.removePoxyServer(); + } + + public static Config getConfig() { + return config; + } + + public static void setConfig(Config config) { + DriverFactory.config = config; + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentManager.java index 31b878a94b..75d22610a6 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentManager.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentManager.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,137 +38,133 @@ import java.util.Calendar; import java.util.GregorianCalendar; public class ExtentManager { - - private static final String VERSIONS_INFO_FILE_NAME = "versions.info"; - private static ExtentReports extent; - private static ExtentHtmlReporter htmlReporter; - private static ExtentXReporter extentxReporter; - private static final String icon = "$(document).ready(function() {" +"\n"+ - "$('.brand-logo').html('').prepend(\"\").width(\"120px\").css(\"float\",\"left\").css(\"padding-left\",\"0\");$('.report-name').css(\"font-weight\",\"bold\");"+"\n"+ -// "$('.logo-content' ).remove();"+"\n"+ -// "$('#slide-out li:first-child').on('click', function(){ $('#charts-row').hide() }) ; $('#slide-out li:last-child').on('click', function(){ $('#charts-row').show() });"+"\n"+ -// "$('.charts div:nth-child(2)').remove();"+"\n"+ - "})"; - - public enum suiteNameXml { - - TESTNG_FAILED_XML_NAME("testng-failed.xml"); - - suiteNameXml(String value) { - this.value = value; - } - - private String value; - - public String getValue() { - return value; - } - - } - - public synchronized static ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { - String dbIp = DriverFactory.getConfig().getReportDBhost(); - int dbPort = DriverFactory.getConfig().getReportDBport(); - - if (extent == null) { - extentxReporter = new ExtentXReporter(dbIp, dbPort); - extent = new ExtentReports(); - initAndSetExtentHtmlReporter(filePath, htmlFile, isAppend); - if(extentxReporter.config().getReportObjectId() != null){ - setExtentXReporter(isAppend); - }else{ - extentxReporter.stop(); - } + + private static final String VERSIONS_INFO_FILE_NAME = "versions.info"; + private static ExtentReports extent; + private static ExtentHtmlReporter htmlReporter; + private static ExtentXReporter extentxReporter; + private static final String ICON = "$(document).ready(function() {" + "\n" + + "$('.brand-logo').html('').prepend(\"\").width(\"120px\").css(\"float\",\"left\").css(\"padding-left\",\"0\");$('.report-name').css(\"font-weight\",\"bold\");" + "\n" + + "})"; + + public enum suiteNameXml { + + TESTNG_FAILED_XML_NAME("testng-failed.xml"); + + suiteNameXml(String value) { + this.value = value; + } + + private String value; + + public String getValue() { + return value; + } + + } + + private static synchronized ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { + String dbIp = DriverFactory.getConfig().getReportDBhost(); + int dbPort = DriverFactory.getConfig().getReportDBport(); + + if (extent == null) { + extentxReporter = new ExtentXReporter(dbIp, dbPort); + extent = new ExtentReports(); + initAndSetExtentHtmlReporter(filePath, htmlFile, isAppend); + if (extentxReporter.config().getReportObjectId() != null) { + setExtentXReporter(isAppend); + } else { + extentxReporter.stop(); + } } return extent; } - - public synchronized static void setExtentXReporter(Boolean isAppend){ - extentxReporter.setAppendExisting(isAppend); - extent.attachReporter(extentxReporter); + + private static synchronized void setExtentXReporter(Boolean isAppend) { + extentxReporter.setAppendExisting(isAppend); + extent.attachReporter(extentxReporter); } - - public synchronized static void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception{ - htmlReporter = new ExtentHtmlReporter(filePath + htmlFile); - setConfiguration(htmlReporter); - htmlReporter.setAppendExisting(isAppend); - extent.attachReporter(htmlReporter); + + private static synchronized void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { + htmlReporter = new ExtentHtmlReporter(filePath + htmlFile); + setConfiguration(htmlReporter); + htmlReporter.setAppendExisting(isAppend); + extent.attachReporter(htmlReporter); } - public synchronized static ExtentReports getReporter() { + static synchronized ExtentReports getReporter() { return extent; } - public static void initReporter(String filepath, String htmlFile, ITestContext context) throws Exception { - - String onboardVersion = AutomationUtils.getOnboardVersion(); - String osVersion = AutomationUtils.getOSVersion(); - Config config = Utils.getConfig(); - String envData = config.getUrl(); - String suiteName = getSuiteName(context); - String reportStartDate = null; - if(suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())){ - if (config.getUseBrowserMobProxy()) { - setTrafficCaptue(config); - } - setReporter(filepath, htmlFile, true); - String suiteNameFromVersionInfoFile = FileHandling.getKeyByValueFromPropertyFormatFile(filepath + VERSIONS_INFO_FILE_NAME, "suiteName"); - reporterDataDefinition(onboardVersion, osVersion, envData, suiteNameFromVersionInfoFile); - }else{ - FileHandling.deleteDirectory(SetupCDTest.getReportFolder()); - FileHandling.createDirectory(filepath); - setReporter(filepath, htmlFile, false); - Calendar calendar = new GregorianCalendar(); - SimpleDateFormat formatter = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a"); - reportStartDate = formatter.format(calendar.getTime()); - reporterDataDefinition(onboardVersion, osVersion, envData, suiteName); - AutomationUtils.createVersionsInfoFile(filepath + VERSIONS_INFO_FILE_NAME, onboardVersion, osVersion, envData, suiteName, reportStartDate); - } - - } - - public static void reporterDataDefinition(String onboardVersion, String osVersion, String envData, String suiteNameFromVersionInfoFile) throws Exception { - extent.setSystemInfo("Onboard Version", onboardVersion); - extent.setSystemInfo("OS Version", osVersion); - extent.setSystemInfo("Host Name Address", RestCDUtils.getExecutionHostAddress()); - extent.setSystemInfo("ExecutedOn", envData); - extent.setSystemInfo("SuiteName", suiteNameFromVersionInfoFile); - } - - public static String getSuiteName(ITestContext context) { - String suitePath = context.getSuite().getXmlSuite().getFileName(); - if(suitePath != null){ - File file = new File(suitePath); - String suiteName = file.getName(); - return suiteName; - } - return null; - } - - public synchronized static ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception { - - htmlReporter.config().setTheme(Theme.STANDARD); - htmlReporter.config().setEncoding("UTF-8"); - htmlReporter.config().setProtocol(Protocol.HTTPS); - htmlReporter.config().setDocumentTitle("SDC Automation Report"); - htmlReporter.config().setChartVisibilityOnOpen(true); -// htmlReporter.config().setReportName(AutomationUtils.getATTVersion()); - htmlReporter.config().setReportName("SDC Automation Report"); - htmlReporter.config().setChartVisibilityOnOpen(false); - htmlReporter.config().setJS(icon); - htmlReporter.setStartTime(null); - return htmlReporter; + static void initReporter(String filepath, String htmlFile, ITestContext context) throws Exception { + + String onboardVersion = AutomationUtils.getOnboardVersion(); + String osVersion = AutomationUtils.getOSVersion(); + Config config = Utils.getConfig(); + String envData = config.getUrl(); + String suiteName = getSuiteName(context); + String reportStartDate = null; + if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { + if (config.getUseBrowserMobProxy()) { + setTrafficCaptue(config); + } + setReporter(filepath, htmlFile, true); + String suiteNameFromVersionInfoFile = FileHandling.getKeyByValueFromPropertyFormatFile(filepath + VERSIONS_INFO_FILE_NAME, "suiteName"); + reporterDataDefinition(onboardVersion, osVersion, envData, suiteNameFromVersionInfoFile); + } else { + FileHandling.deleteDirectory(SetupCDTest.getReportFolder()); + FileHandling.createDirectory(filepath); + setReporter(filepath, htmlFile, false); + Calendar calendar = new GregorianCalendar(); + SimpleDateFormat formatter = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a"); + reportStartDate = formatter.format(calendar.getTime()); + reporterDataDefinition(onboardVersion, osVersion, envData, suiteName); + AutomationUtils.createVersionsInfoFile(filepath + VERSIONS_INFO_FILE_NAME, onboardVersion, osVersion, envData, suiteName, reportStartDate); + } + + } + + private static void reporterDataDefinition(String onboardVersion, String osVersion, String envData, String suiteNameFromVersionInfoFile) throws Exception { + extent.setSystemInfo("Onboard Version", onboardVersion); + extent.setSystemInfo("OS Version", osVersion); + extent.setSystemInfo("Host Name Address", RestCDUtils.getExecutionHostAddress()); + extent.setSystemInfo("ExecutedOn", envData); + extent.setSystemInfo("SuiteName", suiteNameFromVersionInfoFile); + } + + static String getSuiteName(ITestContext context) { + String suitePath = context.getSuite().getXmlSuite().getFileName(); + if (suitePath != null) { + File file = new File(suitePath); + String suiteName = file.getName(); + return suiteName; + } + return null; + } + + private static synchronized ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception { + + htmlReporter.config().setTheme(Theme.STANDARD); + htmlReporter.config().setEncoding("UTF-8"); + htmlReporter.config().setProtocol(Protocol.HTTPS); + htmlReporter.config().setDocumentTitle("SDC Automation Report"); + htmlReporter.config().setChartVisibilityOnOpen(true); + htmlReporter.config().setReportName("SDC Automation Report"); + htmlReporter.config().setChartVisibilityOnOpen(false); + htmlReporter.config().setJS(ICON); + htmlReporter.setStartTime(null); + return htmlReporter; + } + + public static void closeReporter() { + extent.flush(); + } + + private static void setTrafficCaptue(Config config) { + boolean mobProxyStatus = config.getUseBrowserMobProxy(); + if (mobProxyStatus) { + config.setCaptureTraffic(true); + } } - - public static void closeReporter(){ - extent.flush(); - } - - public static void setTrafficCaptue(Config config) { - boolean mobProxyStatus = config.getUseBrowserMobProxy(); - if (mobProxyStatus){ - config.setCaptureTraffic(true);; - } - } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java index f90b7107e4..9ebcb9b0c2 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,83 +34,80 @@ import java.io.IOException; import java.util.UUID; public class ExtentTestActions { - - public static SomeInterface testManager = new ExtentTestManager(); - - public static void log(Status logStatus, Markup mark){ - ExtentTest test = testManager.getTest(); - test.log(logStatus, mark); - } - - public static void log(Status logStatus, String message){ - ExtentTest test = testManager.getTest(); - test.log(logStatus, message); - } - - public static void log(Status logStatus, String message, String duration){ - log(logStatus, message + addDurationTag(duration)); - } - - public static void log(Status logStatus, Throwable throwabel){ - ExtentTest test = testManager.getTest(); - test.log(logStatus, throwabel); - } - - public static void addTag(Status logStatus, String message){ - Markup m = null; - switch(logStatus){ - case PASS: - m = MarkupHelper.createLabel(message, ExtentColor.GREEN); - break; - case FAIL: - m = MarkupHelper.createLabel(message, ExtentColor.RED); - break; - case SKIP: - m = MarkupHelper.createLabel(message, ExtentColor.BLUE); - break; - case FATAL: - m = MarkupHelper.createLabel(message, ExtentColor.BROWN); - break; - default: - break; - } - - if (m != null){ - log(logStatus, m); - } - } - - public static String addScreenshot(Status logStatus, String screenshotName, String message) throws IOException{ - String imageFilePath = null; - String uuid = UUID.randomUUID().toString(); - String[] stringArray = uuid.split("-"); - screenshotName = screenshotName + "-" + stringArray[stringArray.length - 1]; - try { - File imageFile = GeneralUIUtils.takeScreenshot(screenshotName, SetupCDTest.getScreenshotFolder()); - imageFilePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFile.toURI()).getPath(); - } catch (IOException e) { - e.printStackTrace(); - } - - ExtentTest test = testManager.getTest(); - test.log(logStatus, message, MediaEntityBuilder.createScreenCaptureFromPath(imageFilePath).build()); - return imageFilePath; - } - - private static String addDurationTag(String duration){ - return "" + duration + ""; - } - - public static String addLinkTag(String fileName, String pathToFile){ - return String.format("HAR file", fileName, pathToFile); - } - - public static void addFileToReportAsLink(File harFile, String pathToFileFromReportDirectory, String message) { - log(Status.INFO, message, addLinkTag(harFile.getName(), pathToFileFromReportDirectory)); - } - - - + + private static SomeInterface testManager = new ExtentTestManager(); + + public static void log(Status logStatus, Markup mark) { + ExtentTest test = testManager.getTest(); + test.log(logStatus, mark); + } + + public static void log(Status logStatus, String message) { + ExtentTest test = testManager.getTest(); + test.log(logStatus, message); + } + + public static void log(Status logStatus, String message, String duration) { + log(logStatus, message + addDurationTag(duration)); + } + + public static void log(Status logStatus, Throwable throwabel) { + ExtentTest test = testManager.getTest(); + test.log(logStatus, throwabel); + } + + static void addTag(Status logStatus, String message) { + Markup m = null; + switch (logStatus) { + case PASS: + m = MarkupHelper.createLabel(message, ExtentColor.GREEN); + break; + case FAIL: + m = MarkupHelper.createLabel(message, ExtentColor.RED); + break; + case SKIP: + m = MarkupHelper.createLabel(message, ExtentColor.BLUE); + break; + case FATAL: + m = MarkupHelper.createLabel(message, ExtentColor.BROWN); + break; + default: + break; + } + + if (m != null) { + log(logStatus, m); + } + } + + public static String addScreenshot(Status logStatus, String screenshotName, String message) throws IOException { + String imageFilePath = null; + String uuid = UUID.randomUUID().toString(); + String[] stringArray = uuid.split("-"); + screenshotName = screenshotName + "-" + stringArray[stringArray.length - 1]; + try { + File imageFile = GeneralUIUtils.takeScreenshot(screenshotName, SetupCDTest.getScreenshotFolder()); + imageFilePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFile.toURI()).getPath(); + } catch (IOException e) { + e.printStackTrace(); + } + + ExtentTest test = testManager.getTest(); + test.log(logStatus, message, MediaEntityBuilder.createScreenCaptureFromPath(imageFilePath).build()); + return imageFilePath; + } + + private static String addDurationTag(String duration) { + return "" + duration + ""; + } + + private static String addLinkTag(String fileName, String pathToFile) { + return String.format("HAR file", fileName, pathToFile); + } + + static void addFileToReportAsLink(File harFile, String pathToFileFromReportDirectory, String message) { + log(Status.INFO, message, addLinkTag(harFile.getName(), pathToFileFromReportDirectory)); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java index 4d28e9a8b4..295abbe8ac 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,41 +26,40 @@ import org.openecomp.sdc.ci.tests.api.SomeInterface; import java.util.HashMap; -public class ExtentTestManager implements SomeInterface{ +public class ExtentTestManager implements SomeInterface { - private static HashMap extentTestMap = new HashMap(); - private static ExtentReports extent = ExtentManager.getReporter(); - - public ExtentTestManager(){ - - } - - @Override - public synchronized ExtentTest getTest() { - return extentTestMap.get(Thread.currentThread().getId()); - } + private static HashMap extentTestMap = new HashMap(); + private static ExtentReports extent = ExtentManager.getReporter(); - public static synchronized void endTest() { -// extent.endTest(extentTestMap.get(Thread.currentThread().getId())); - extent.flush(); - } + public ExtentTestManager() { - public static synchronized ExtentTest startTest(String testName) { - return startTest(testName, ""); - } + } - public static synchronized ExtentTest startTest(String testName, String desc) { - ExtentTest test = extent.createTest(testName, desc); - extentTestMap.put(Thread.currentThread().getId(), test); + @Override + public synchronized ExtentTest getTest() { + return extentTestMap.get(Thread.currentThread().getId()); + } - return test; - } - - public static synchronized void assignCategory(Class clazz){ - String[] parts = clazz.getName().split("\\."); - String lastOne1 = parts[parts.length-1]; - String lastOne2 = parts[parts.length-2]; - extentTestMap.get(Thread.currentThread().getId()).assignCategory(lastOne2 + "-" + lastOne1); - } + public static synchronized void endTest() { + extent.flush(); + } + + public static synchronized ExtentTest startTest(String testName) { + return startTest(testName, ""); + } + + public static synchronized ExtentTest startTest(String testName, String desc) { + ExtentTest test = extent.createTest(testName, desc); + extentTestMap.put(Thread.currentThread().getId(), test); + + return test; + } + + public static synchronized void assignCategory(Class clazz) { + String[] parts = clazz.getName().split("\\."); + String lastOne1 = parts[parts.length - 1]; + String lastOne2 = parts[parts.length - 2]; + extentTestMap.get(Thread.currentThread().getId()).assignCategory(lastOne2 + "-" + lastOne1); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java index d082f2d174..70a1dd6f81 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,105 +28,105 @@ import com.github.markusbernhardt.proxy.ProxySearch.Strategy; import com.github.markusbernhardt.proxy.util.PlatformUtil; import com.github.markusbernhardt.proxy.util.PlatformUtil.Platform; import net.lightbody.bmp.BrowserMobProxyServer; +import org.apache.http.HttpStatus; import org.slf4j.LoggerFactory; -import java.net.*; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.SocketAddress; +import java.net.URI; import java.util.HashMap; import java.util.List; public class MobProxy { - - private static HashMap mobProxyServerMap = new HashMap(); - public static InetSocketAddress localProxyAddress = getProxy(); - - public static InetSocketAddress getProxy(){ - setLogger(); - - ProxySearch proxySearch = new ProxySearch(); -// proxySearch.addStrategy(Strategy.JAVA); -// proxySearch.addStrategy(Strategy.BROWSER); -// proxySearch.addStrategy(Strategy.OS_DEFAULT); -// proxySearch.addStrategy(Strategy.ENV_VAR); - if (PlatformUtil.getCurrentPlattform() == Platform.WIN) { - proxySearch.addStrategy(Strategy.IE); - proxySearch.addStrategy(Strategy.FIREFOX); - proxySearch.addStrategy(Strategy.JAVA); - } else if (PlatformUtil.getCurrentPlattform() == Platform.LINUX) { - proxySearch.addStrategy(Strategy.GNOME); - proxySearch.addStrategy(Strategy.KDE); - proxySearch.addStrategy(Strategy.FIREFOX); - proxySearch.addStrategy(Strategy.ENV_VAR); - return null; - } else { - proxySearch.addStrategy(Strategy.OS_DEFAULT); - } - ProxySelector proxySelector = proxySearch.getProxySelector(); - ProxySelector.setDefault(proxySelector); - URI home = URI.create("http://www.google.com"); - System.out.println("ProxySelector: " + proxySelector); - System.out.println("URI: " + home); - List proxyList = proxySelector.select(home); - String host = null; - String port = null; - if (proxyList != null && !proxyList.isEmpty()) { - for (Proxy proxy : proxyList) { - System.out.println(proxy); - SocketAddress address = proxy.address(); - if (address instanceof InetSocketAddress) { - host = ((InetSocketAddress) address).getHostName(); - port = Integer.toString(((InetSocketAddress) address).getPort()); - System.setProperty("http.proxyHost", host); - System.setProperty("http.proxyPort", port); - } - } - } - InetSocketAddress address = new InetSocketAddress(host, Integer.parseInt(port)); - return address; - } - - // set logger for all classes connected to MobProxy - public static void setLogger() { - LoggerContext lc = (LoggerContext) LoggerFactory. getILoggerFactory(); -// lc.getLogger("ROOT").setLevel(Level.DEBUG); - for(Logger logger:lc.getLoggerList()){ - logger.setLevel(Level.INFO); - } - } - - public static synchronized void setProxyServer() { - BrowserMobProxyServer server = new BrowserMobProxyServer(); - server.setTrustAllServers(true); - if (localProxyAddress != null){ - server.setChainedProxy(localProxyAddress); - server.start(); - } else { - server.start(); - // filter firefox requests to mozilla when system proxy is absent - server.blacklistRequests(".*mozilla.*", 200); - } - addProxyServerToPull(Thread.currentThread().getId(), server); - } - - public static synchronized BrowserMobProxyServer getPoxyServer() { + private static HashMap mobProxyServerMap = new HashMap(); + private static InetSocketAddress localProxyAddress = getProxy(); + + public static InetSocketAddress getProxy() { + setLogger(); + + ProxySearch proxySearch = new ProxySearch(); + if (PlatformUtil.getCurrentPlattform() == Platform.WIN) { + proxySearch.addStrategy(Strategy.IE); + proxySearch.addStrategy(Strategy.FIREFOX); + proxySearch.addStrategy(Strategy.JAVA); + } else if (PlatformUtil.getCurrentPlattform() == Platform.LINUX) { + proxySearch.addStrategy(Strategy.GNOME); + proxySearch.addStrategy(Strategy.KDE); + proxySearch.addStrategy(Strategy.FIREFOX); + proxySearch.addStrategy(Strategy.ENV_VAR); + return null; + } else { + proxySearch.addStrategy(Strategy.OS_DEFAULT); + } + ProxySelector proxySelector = proxySearch.getProxySelector(); + + ProxySelector.setDefault(proxySelector); + URI home = URI.create("http://www.google.com"); + System.out.println("ProxySelector: " + proxySelector); + System.out.println("URI: " + home); + List proxyList = proxySelector.select(home); + String host = null; + String port = null; + if (proxyList != null && !proxyList.isEmpty()) { + for (Proxy proxy : proxyList) { + System.out.println(proxy); + SocketAddress address = proxy.address(); + if (address instanceof InetSocketAddress) { + host = ((InetSocketAddress) address).getHostName(); + port = Integer.toString(((InetSocketAddress) address).getPort()); + System.setProperty("http.proxyHost", host); + System.setProperty("http.proxyPort", port); + } + } + } + InetSocketAddress address = new InetSocketAddress(host, Integer.parseInt(port)); + return address; + } + + // set logger for all classes connected to MobProxy + public static void setLogger() { + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + for (Logger logger : lc.getLoggerList()) { + logger.setLevel(Level.INFO); + } + } + + public static synchronized void setProxyServer() { + BrowserMobProxyServer server = new BrowserMobProxyServer(); + server.setTrustAllServers(true); + if (localProxyAddress != null) { + server.setChainedProxy(localProxyAddress); + server.start(); + } else { + server.start(); + // filter firefox requests to mozilla when system proxy is absent + server.blacklistRequests(".*mozilla.*", HttpStatus.SC_OK); + } + addProxyServerToPull(Thread.currentThread().getId(), server); + } + + public static synchronized BrowserMobProxyServer getPoxyServer() { return mobProxyServerMap.get(Thread.currentThread().getId()); } - - public static void addProxyServerToPull(Long threadId, BrowserMobProxyServer server){ - mobProxyServerMap.put(threadId, server); - } - - public static synchronized void removePoxyServer() { - if (getPoxyServer() != null){ - getPoxyServer().stop(); - mobProxyServerMap.remove(Thread.currentThread().getId()); - } + + public static void addProxyServerToPull(Long threadId, BrowserMobProxyServer server) { + mobProxyServerMap.put(threadId, server); + } + + public static synchronized void removePoxyServer() { + if (getPoxyServer() != null) { + getPoxyServer().stop(); + mobProxyServerMap.remove(Thread.currentThread().getId()); + } + } + + public static void removeAllProxyServers() { + for (Long threadNumber : mobProxyServerMap.keySet()) { + mobProxyServerMap.get(threadNumber).stop(); + } } - - public static void removeAllProxyServers(){ - for(Long threadNumber :mobProxyServerMap.keySet()){ - mobProxyServerMap.get(threadNumber).stop(); - } - } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/OnboardCSVReport.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/OnboardCSVReport.java index 03c9b0281f..c748a6bccf 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/OnboardCSVReport.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/OnboardCSVReport.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,38 +26,38 @@ import java.io.PrintWriter; public class OnboardCSVReport { - private StringBuilder sb; - private PrintWriter pw; - - public OnboardCSVReport(String filepath, String filename) { - sb = new StringBuilder(); - try { - File csvFile = new File(filepath + filename); - pw = new PrintWriter(csvFile); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - - } - - public StringBuilder appendStringToFile(String content) { - return sb.append(content + ","); - } - - public void openNewRow() { - sb.append("\n"); - } - - public void writeRow(String... content) { - for (String str : content) { - appendStringToFile(str); - } - openNewRow(); - } - - public void closeFile() { - pw.write(sb.toString()); - pw.close(); - } + private StringBuilder sb; + private PrintWriter pw; + + public OnboardCSVReport(String filepath, String filename) { + sb = new StringBuilder(); + try { + File csvFile = new File(filepath + filename); + pw = new PrintWriter(csvFile); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + + } + + public StringBuilder appendStringToFile(String content) { + return sb.append(content + ","); + } + + public void openNewRow() { + sb.append("\n"); + } + + public void writeRow(String... content) { + for (String str : content) { + appendStringToFile(str); + } + openNewRow(); + } + + public void closeFile() { + pw.write(sb.toString()); + pw.close(); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ReportAfterTestManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ReportAfterTestManager.java index b86b694e0a..fcbbaefaac 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ReportAfterTestManager.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ReportAfterTestManager.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,102 +27,103 @@ import org.testng.ITestResult; import java.io.IOException; -public class ReportAfterTestManager extends ExtentTestActions { - - private static String testName; - private static Throwable throwable; - private static int status; - - private static void logSuccessAfterTest(){ - final Status logStatus = Status.PASS; - addTag(logStatus, "Success"); - try{ - String message = "Finished the test with the following screenshot : "; - addScreenshotToReport(logStatus, testName, message); - }catch(Exception e){ - log(logStatus, "SUCCESS - The following exepction occured : " + e.getMessage()); - } - } - - private static void logFailAfterTest(){ - addTag(Status.FAIL, "Failure"); - try{ - log(Status.ERROR, "ERROR - The following exepction occured : "); - log(Status.ERROR, throwable); - String message = "Failure is described in the following screenshot : "; - addScreenshotToReport(Status.FAIL, testName, message); - }catch(Exception e){ - log(Status.ERROR, "ERROR - The following exepction occured : " + e.getMessage()); - } - } - - private static void logSkipAfterTest(){ - final Status logStatus = Status.SKIP; - addTag(logStatus, "Skipped"); - try{ - log(logStatus, "SKIP - The following exepction occured : "); - log(logStatus, throwable); - String message = "Skip is described in the following screenshot : "; - addScreenshotToReport(logStatus, testName, message); - }catch(Exception e){ - log(logStatus, "SKIP - The following exepction occured : " + e.getMessage()); - } - } - private static void logFatalAfterTest(){ - final Status logStatus = Status.FATAL; - addTag(logStatus, "Fatal"); - try{ - log(logStatus, "FATAL - The following exepction occured : "); - log(logStatus, throwable); - String message = "Fatal is described in the following screenshot : "; - addScreenshotToReport(logStatus, testName, message); - }catch(Exception e){ - log(logStatus, "FATAL - The following exepction occured : " + e.getMessage()); - } - } - - private static String addScreenshotToReport(Status logStatus, String testName, String message) throws IOException{ - - String addedValueFromDataProvider = WindowTestManager.getWindowMap().getAddedValueFromDataProvider(); - if (addedValueFromDataProvider != null){ - addedValueFromDataProvider = addedValueFromDataProvider.replace(":", "-"); - testName = testName + "...." + addedValueFromDataProvider; - } - - return addScreenshot(logStatus, testName, message); - } - - public static void report(ITestResult result, ITestContext context){ - - testName = result.getName(); - throwable = result.getThrowable(); - status = result.getStatus(); - - String suiteName = ExtentManager.getSuiteName(context); - - switch(status){ - case ITestResult.SUCCESS: - logSuccessAfterTest(); - break; - - case ITestResult.FAILURE: - - if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { - logFatalAfterTest(); - }else{ - logFailAfterTest(); - } - break; - - case ITestResult.SKIP: - logSkipAfterTest(); - break; - - default: - break; - } - - } - +public class ReportAfterTestManager extends ExtentTestActions { + + private static String testName; + private static Throwable throwable; + private static int status; + + private static void logSuccessAfterTest() { + final Status logStatus = Status.PASS; + addTag(logStatus, "Success"); + try { + String message = "Finished the test with the following screenshot : "; + addScreenshotToReport(logStatus, testName, message); + } catch (Exception e) { + log(logStatus, "SUCCESS - The following exepction occured : " + e.getMessage()); + } + } + + private static void logFailAfterTest() { + addTag(Status.FAIL, "Failure"); + try { + log(Status.ERROR, "ERROR - The following exepction occured : "); + log(Status.ERROR, throwable); + String message = "Failure is described in the following screenshot : "; + addScreenshotToReport(Status.FAIL, testName, message); + } catch (Exception e) { + log(Status.ERROR, "ERROR - The following exepction occured : " + e.getMessage()); + } + } + + private static void logSkipAfterTest() { + final Status logStatus = Status.SKIP; + addTag(logStatus, "Skipped"); + try { + log(logStatus, "SKIP - The following exepction occured : "); + log(logStatus, throwable); + String message = "Skip is described in the following screenshot : "; + addScreenshotToReport(logStatus, testName, message); + } catch (Exception e) { + log(logStatus, "SKIP - The following exepction occured : " + e.getMessage()); + } + } + + private static void logFatalAfterTest() { + final Status logStatus = Status.FATAL; + addTag(logStatus, "Fatal"); + try { + log(logStatus, "FATAL - The following exepction occured : "); + log(logStatus, throwable); + String message = "Fatal is described in the following screenshot : "; + addScreenshotToReport(logStatus, testName, message); + } catch (Exception e) { + log(logStatus, "FATAL - The following exepction occured : " + e.getMessage()); + } + } + + private static String addScreenshotToReport(Status logStatus, String testName, String message) throws IOException { + + String addedValueFromDataProvider = WindowTestManager.getWindowMap().getAddedValueFromDataProvider(); + if (addedValueFromDataProvider != null) { + addedValueFromDataProvider = addedValueFromDataProvider.replace(":", "-"); + testName = testName + "...." + addedValueFromDataProvider; + } + + return addScreenshot(logStatus, testName, message); + } + + public static void report(ITestResult result, ITestContext context) { + + testName = result.getName(); + throwable = result.getThrowable(); + status = result.getStatus(); + + String suiteName = ExtentManager.getSuiteName(context); + + switch (status) { + case ITestResult.SUCCESS: + logSuccessAfterTest(); + break; + + case ITestResult.FAILURE: + + if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { + logFatalAfterTest(); + } else { + logFailAfterTest(); + } + break; + + case ITestResult.SKIP: + logSkipAfterTest(); + break; + + default: + break; + } + + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java index d208537702..b28f64e887 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,6 +37,4 @@ public class Retry implements IRetryAnalyzer { } - - } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java index 397233730a..ad2071ad12 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -50,7 +50,13 @@ import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.ITestContext; import org.testng.ITestResult; -import org.testng.annotations.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; import java.io.File; import java.io.FileWriter; @@ -60,524 +66,472 @@ import java.util.UUID; public abstract class SetupCDTest extends DriverFactory { - // private static final String RE_RUN = "ReRun - "; - private static final String RE_RUN = "ReRun - "; - private static final String WEB_SEAL_PASSWORD = "123123a"; - protected static final String HEAT_FILE_YAML_NAME_PREFIX = "Heat-File"; - protected static final String HEAT_FILE_YAML_NAME_SUFFIX = ".yaml"; - - public SetupCDTest() { - LoggerContext lc = (LoggerContext) LoggerFactory. getILoggerFactory(); - lc.getLogger("org.apache").setLevel(Level.INFO); - } - - /**************** CONSTANTS ****************/ - private static final String CREDENTIALS_FILE = "credentials.yaml"; - private static final String REPORT_FILE_NAME = "SDC_UI_Extent_Report.html"; - protected static final String REPORT_FOLDER = "." + File.separator + "ExtentReport" + File.separator; - protected static final String SCREENSHOT_FOLDER = REPORT_FOLDER + "screenshots" + File.separator; - protected static final String HAR_FILES_FOLDER_NAME = "har_files"; - protected static final String HAR_FILES_FOLDER = REPORT_FOLDER + HAR_FILES_FOLDER_NAME + File.separator; - - - private static final String SHORT_CSV_REPORT_FILE_NAME = "ShortReport.csv"; - private static final int NUM_OF_ATTEMPTS_TO_REFTRESH = 2; - - - /**************** PRIVATES ****************/ - private static String url; - private static boolean uiSimulator; - private static boolean localEnv = true; - private static OnboardCSVReport csvReport; - private final UserCredentialsFromFile credentialsIns = UserCredentialsFromFile.getInstance(); - - protected static ITestContext myContext; - - - /**************** METHODS ****************/ - public static ExtentTest getExtendTest() { - SomeInterface testManager = new ExtentTestManager(); - return testManager.getTest(); - } - public static WindowTest getWindowTest(){ - return WindowTestManager.getWindowMap(); - } - - public OnboardCSVReport getCsvReport() { - return csvReport; - } - - public static String getReportFolder() { - return REPORT_FOLDER; - } - - public static String getScreenshotFolder() { - return SCREENSHOT_FOLDER; - } - - public static String getHarFilesFolder() { - return HAR_FILES_FOLDER; - } - - - protected abstract UserRoleEnum getRole(); - - /**************** BEFORE ****************/ - - @BeforeSuite(alwaysRun = true) - public void setupBeforeSuite(ITestContext context) throws Exception { - RestCDUtils.deleteOnDemand(); - myContext=context; - setErrorConfigurationFile(); - setUrl(); - ExtentManager.initReporter(getReportFolder(), REPORT_FILE_NAME, context); - csvReport = new OnboardCSVReport(getReportFolder(), SHORT_CSV_REPORT_FILE_NAME); - } - - private static void setErrorConfigurationFile() { - if (!System.getProperty("os.name").contains("Windows")){ - String errorConfigurationFilename = getConfig().getErrorConfigurationFile(); - errorConfigurationFilename = errorConfigurationFilename.substring(errorConfigurationFilename.lastIndexOf("/") + 1, errorConfigurationFilename.length()); - getConfig().setErrorConfigurationFile(FileHandling.getBasePath() + File.separator + "conf" + File.separator + errorConfigurationFilename); - if (new File(getConfig().getErrorConfigurationFile()).exists()){ - System.out.println("Found error-configuration.yaml in : " + getConfig().getErrorConfigurationFile()); - } - } - } - - @BeforeMethod(alwaysRun = true ) - public void setBrowserBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception { - - boolean emptyDataProvider = method.getAnnotation(Test.class).dataProvider().isEmpty(); - String className = method.getDeclaringClass().getName(); - if (emptyDataProvider && !className.contains("ToscaValidationTest") ) { - System.out.println("ExtentReport instance started from BeforeMethod..."); - String suiteName = ExtentManager.getSuiteName(context); - if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { - ExtentTestManager.startTest(RE_RUN + method.getName()); - }else{ - ExtentTestManager.startTest(method.getName()); - } - - ExtentTestManager.assignCategory(this.getClass()); - setBrowserBeforeTest(getRole()); - } else { - System.out.println("ExtentReport instance started from Test..."); - } - - getConfig().setWindowsDownloadDirectory(getWindowTest().getDownloadDirectory()); - - if (getConfig().getCaptureTraffic()){ - try{ - MobProxy.getPoxyServer().newHar(method.getName() + ".har"); - } catch (Throwable e) { - e.printStackTrace(); - } - } - } - - /**************** AFTER ****************/ - @AfterMethod(alwaysRun = true) - public void quitAfterTest(ITestResult result, ITestContext context) throws Exception { - - try{ - ReportAfterTestManager.report(result, context); - GeneralUIUtils.closeErrorMessage(); - } - finally{ - try { - if (getConfig().getCaptureTraffic()){ - addTrafficFileToReport(result); - } - - if (result.getInstanceName().equals(OnboardingFlowsUI.class.getName()) && result.getStatus() == ITestResult.FAILURE){ - System.out.println("Onboarding test failed, closign browser...."); - getExtendTest().log(Status.INFO, "Onboarding test failed, closing browser...."); - quitDriver(); - } - else if (!getUser().getRole().toLowerCase().equals(UserRoleEnum.ADMIN.name().toLowerCase())){ - boolean navigateToHomePageSuccess = HomePage.navigateToHomePage(); - if (!navigateToHomePageSuccess){ - System.out.println("Navigating to homepage failed, reopening driver...."); - getExtendTest().log(Status.INFO, "Navigating to homepage failed, reopening driver...."); - quitDriver(); - } - } - - } catch (Exception e) { - e.printStackTrace(); - getExtendTest().log(Status.ERROR, "Exception:"+ e.toString()); - } - - - - ExtentTestManager.endTest(); - String suiteName = ExtentManager.getSuiteName(context); + // private static final String RE_RUN = "ReRun - "; + private static final String RE_RUN = "ReRun - "; + private static final String WEB_SEAL_PASSWORD = "123123a"; + protected static final String HEAT_FILE_YAML_NAME_PREFIX = "Heat-File"; + protected static final String HEAT_FILE_YAML_NAME_SUFFIX = ".yaml"; + private static final int BASIC_SLEEP_DURATION = 1000; + + public SetupCDTest() { + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + lc.getLogger("org.apache").setLevel(Level.INFO); + } + + /**************** CONSTANTS ****************/ + private static final String CREDENTIALS_FILE = "credentials.yaml"; + private static final String REPORT_FILE_NAME = "SDC_UI_Extent_Report.html"; + private static final String REPORT_FOLDER = "." + File.separator + "ExtentReport" + File.separator; + private static final String SCREENSHOT_FOLDER = REPORT_FOLDER + "screenshots" + File.separator; + private static final String HAR_FILES_FOLDER_NAME = "har_files"; + private static final String HAR_FILES_FOLDER = REPORT_FOLDER + HAR_FILES_FOLDER_NAME + File.separator; + + + private static final String SHORT_CSV_REPORT_FILE_NAME = "ShortReport.csv"; + private static final int NUM_OF_ATTEMPTS_TO_REFTRESH = 2; + + + /**************** PRIVATES ****************/ + private static String url; + private static boolean uiSimulator; + private static boolean localEnv = true; + private static OnboardCSVReport csvReport; + private final UserCredentialsFromFile credentialsIns = UserCredentialsFromFile.getInstance(); + + private static ITestContext myContext; + + + /**************** METHODS ****************/ + public static ExtentTest getExtendTest() { + SomeInterface testManager = new ExtentTestManager(); + return testManager.getTest(); + } + + public static WindowTest getWindowTest() { + return WindowTestManager.getWindowMap(); + } + + private OnboardCSVReport getCsvReport() { + return csvReport; + } + + public static String getReportFolder() { + return REPORT_FOLDER; + } + + public static String getScreenshotFolder() { + return SCREENSHOT_FOLDER; + } + + private static String getHarFilesFolder() { + return HAR_FILES_FOLDER; + } + + + protected abstract UserRoleEnum getRole(); + + /**************** BEFORE ****************/ + + @BeforeSuite(alwaysRun = true) + public void setupBeforeSuite(ITestContext context) throws Exception { + RestCDUtils.deleteOnDemand(); + myContext = context; + setErrorConfigurationFile(); + setUrl(); + ExtentManager.initReporter(getReportFolder(), REPORT_FILE_NAME, context); + csvReport = new OnboardCSVReport(getReportFolder(), SHORT_CSV_REPORT_FILE_NAME); + } + + private static void setErrorConfigurationFile() { + if (!System.getProperty("os.name").contains("Windows")) { + String errorConfigurationFilename = getConfig().getErrorConfigurationFile(); + errorConfigurationFilename = errorConfigurationFilename.substring(errorConfigurationFilename.lastIndexOf("/") + 1, errorConfigurationFilename.length()); + getConfig().setErrorConfigurationFile(FileHandling.getBasePath() + File.separator + "conf" + File.separator + errorConfigurationFilename); + if (new File(getConfig().getErrorConfigurationFile()).exists()) { + System.out.println("Found error-configuration.yaml in : " + getConfig().getErrorConfigurationFile()); + } + } + } + + @BeforeMethod(alwaysRun = true) + public void setBrowserBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception { + + boolean emptyDataProvider = method.getAnnotation(Test.class).dataProvider().isEmpty(); + String className = method.getDeclaringClass().getName(); + if (emptyDataProvider && !className.contains("ToscaValidationTest")) { + System.out.println("ExtentReport instance started from BeforeMethod..."); + String suiteName = ExtentManager.getSuiteName(context); + if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { + ExtentTestManager.startTest(RE_RUN + method.getName()); + } else { + ExtentTestManager.startTest(method.getName()); + } + + ExtentTestManager.assignCategory(this.getClass()); + setBrowserBeforeTest(getRole()); + } else { + System.out.println("ExtentReport instance started from Test..."); + } + + getConfig().setWindowsDownloadDirectory(getWindowTest().getDownloadDirectory()); + + if (getConfig().getCaptureTraffic()) { + try { + MobProxy.getPoxyServer().newHar(method.getName() + ".har"); + } catch (Throwable e) { + e.printStackTrace(); + } + } + } + + /**************** AFTER ****************/ + @AfterMethod(alwaysRun = true) + public void quitAfterTest(ITestResult result, ITestContext context) throws Exception { + + try { + ReportAfterTestManager.report(result, context); + GeneralUIUtils.closeErrorMessage(); + } finally { + try { + if (getConfig().getCaptureTraffic()) { + addTrafficFileToReport(result); + } + + if (result.getInstanceName().equals(OnboardingFlowsUI.class.getName()) && result.getStatus() == ITestResult.FAILURE) { + System.out.println("Onboarding test failed, closign browser...."); + getExtendTest().log(Status.INFO, "Onboarding test failed, closing browser...."); + quitDriver(); + } else if (!getUser().getRole().toLowerCase().equals(UserRoleEnum.ADMIN.name().toLowerCase())) { + boolean navigateToHomePageSuccess = HomePage.navigateToHomePage(); + if (!navigateToHomePageSuccess) { + System.out.println("Navigating to homepage failed, reopening driver...."); + getExtendTest().log(Status.INFO, "Navigating to homepage failed, reopening driver...."); + quitDriver(); + } + } + + } catch (Exception e) { + e.printStackTrace(); + getExtendTest().log(Status.ERROR, "Exception:" + e.toString()); + } + + + ExtentTestManager.endTest(); + String suiteName = ExtentManager.getSuiteName(context); // write result to csv file - if((!suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) && (result.getStatus() == ITestResult.SKIP)) { - addResultToCSV(result, context); - } - if(suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue()) && !(result.getStatus() == ITestResult.SUCCESS)) { - addResultToCSV(result, context); - } + if ((!suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) && (result.getStatus() == ITestResult.SKIP)) { + addResultToCSV(result, context); + } + if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue()) && !(result.getStatus() == ITestResult.SUCCESS)) { + addResultToCSV(result, context); + } // ExtentManager.closeReporter(); - FileHandling.cleanCurrentDownloadDir(); - } - - } - public void addResultToCSV(ITestResult result, ITestContext context) { -// String suiteName = ExtentManager.getSuiteName(context); - ExtentTest test = getExtendTest(); - com.aventstack.extentreports.model.Test model = test.getModel(); - String name = model.getName(); - String status = model.getStatus().toString(); -// if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue()) && !(result.getStatus() == ITestResult.SUCCESS)) { - getCsvReport().writeRow(result.getInstanceName(), name.replace(RE_RUN,""), status); -// } - } - - public void generateReport4Jenkins(ITestContext context) { - String suiteName = ExtentManager.getSuiteName(context); -// String outputDirectory = context.getOutputDirectory(); - JSONObject obj = new JSONObject(); - String success = Integer.toString(context.getPassedTests().size()); - String failed = Integer.toString(context.getFailedTests().size()); - String total = Integer.toString(context.getFailedTests().size()+context.getPassedTests().size()); - obj.put("projectName", "SDC-ONAP-UI-Automation-"+suiteName); - obj.put("projectVersion", AutomationUtils.getOSVersion()); - obj.put("platform", "Linux"); - obj.put("total", total); - obj.put("success", success); - obj.put("failed", failed); - - try (FileWriter file = new FileWriter(getReportFolder() + "jenkinsResults.json")) { - - file.write(obj.toJSONString()); - file.flush(); - - } catch (IOException e) { - e.printStackTrace(); - } - - System.out.print(obj); - - - } - - - @Parameters({ "eraseAfterTests" }) - @AfterSuite(alwaysRun = true) - public void afterSuite2(@Optional("true") String eraseAfterTestsReadValue) throws Exception { -// public void afterSuite() throws Exception { - - csvReport.closeFile(); - generateReport4Jenkins(myContext); - - if (Boolean.parseBoolean(eraseAfterTestsReadValue)){ - RestCDUtils.deleteOnDemand(); - } else { - System.out.println("Resources will not be deleted according to suite configuration ..."); - } - - if (getConfig().getUseBrowserMobProxy()){ - MobProxy.getPoxyServer().stop(); - } - } - - protected static String setUrl() { - url = getConfig().getUrl(); - uiSimulator = getConfig().isUiSimulator(); - if (url == null) { - String message = "no URL found"; - System.out.println(message); - Assert.fail(message); - } else if (!url.contains("localhost") && !url.contains("192.168.33.10") && !url.contains("127.0.0.1") && !url.contains("192.168.50.5") && !uiSimulator==true) { - localEnv = false; - } - return url; - } - - - - public static void navigateToUrl(String url) throws Exception { - try { - System.out.println("Deleting cookies..."); - deleteCookies(); - - System.out.println("Navigating to URL : " + url); - getDriver().navigate().to(url); - GeneralUIUtils.waitForLoader(); - - System.out.println("Zooming out..."); - GeneralUIUtils.windowZoomOutUltimate(); - - } - catch (Exception e) { - String msg = "Browser is unreachable"; - System.out.println(msg); - getExtendTest().log(Status.ERROR, msg); - Assert.fail(msg); - } - } - private static void deleteCookies() throws Exception { - getDriver().manage().deleteAllCookies(); - Thread.sleep(1000); - - int attempts = 0; - final int max_attempts = 3; - - while (!getDriver().manage().getCookies().isEmpty() && attempts < max_attempts){ - getExtendTest().log(Status.INFO, "Trying to delete cookies one more time - " + (attempts + 1) + "/" + max_attempts + "attempts"); - String deleteCookiesJS = "document.cookie.split(';').forEach(function(c) { document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/'); });"; - ((JavascriptExecutor) getDriver()).executeScript(deleteCookiesJS); - attempts++; - - if (attempts == max_attempts){ - String msg = "Did not delete cookies, can't login as user " + WindowTestManager.getWindowMap().getUser().getRole(); - System.out.println(msg); - getExtendTest().log(Status.ERROR, msg); - Assert.fail(msg); - } - } - } - - protected void loginToSystem(UserRoleEnum role) throws Exception { - UserCredentials credentials = new UserCredentials(role.getUserId(), role.getPassword(), role.getFirstName(), role.getLastName(), role.name()); - if (localEnv){ - loginToSimulator(role); - } - else{ - sendUserAndPasswordKeys(credentials); - WebElement submitButton = GeneralUIUtils.getWebElementBy(By.name("btnSubmit"), 30); - submitButton.click(); - WebElement buttonOK = GeneralUIUtils.getWebElementBy(By.name("successOK"), 30); - Assert.assertTrue(buttonOK.isDisplayed(), "OK button is not displayed."); - buttonOK.click(); - } - GeneralUIUtils.ultimateWait(); - getWindowTest().setUser(credentials); - } - - private void goToHomePage(UserRoleEnum role) throws Exception { - try { - getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() == 0 ? NUM_OF_ATTEMPTS_TO_REFTRESH : getWindowTest().getRefreshAttempts()); - if (!role.equals(UserRoleEnum.ADMIN)) { - - WebElement closeButton = GeneralUIUtils.getClickableButtonBy(By.className("sdc-welcome-close"), 10); - if (closeButton != null){ - closeButton.click(); - } - - if (!GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.MainMenuButtons.HOME_BUTTON.getValue())) - { - restartBrowser(role); - } - } - } - catch (Exception e) { - restartBrowser(role); - } - } - private void restartBrowser(UserRoleEnum role) throws Exception { - getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() - 1); - if (getWindowTest().getRefreshAttempts() <= 0) { - System.out.println("ERR : Something is wrong with browser!"); - Assert.fail("ERR : Something is wrong with browser!"); - } - System.out.println("Trying again..."); - getExtendTest().log(Status.INFO, "Trying again..."); - getExtendTest().log(Status.INFO, String.format("%s attempt(s) left", getWindowTest().getRefreshAttempts() )); - System.out.println(String.format("%s attempt(s) left", getWindowTest().getRefreshAttempts() )); - - reloginWithNewRole(role); - } - - public void loginToSimulator(UserRoleEnum role){ - WebDriver driver = GeneralUIUtils.getDriver(); - WebDriverWait wait = new WebDriverWait(driver, 30); - - wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@method='" + "post" + "']")))); - - WebElement userIdTextbox = GeneralUIUtils.getWebElementBy(By.name("userId")); - userIdTextbox.sendKeys(role.getUserId()); - WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password")); - passwordTextbox.sendKeys(WEB_SEAL_PASSWORD); - - wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[@value='" + "Login" + "']")))).click(); - } - - private void sendUserAndPasswordKeys(UserCredentials userId) { - System.out.println("Login as user : " + userId.getUserId()); - WebElement userNameTextbox = GeneralUIUtils.getWebElementBy(By.name("userid")); - userNameTextbox.sendKeys(userId.getUserId()); - WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password")); - passwordTextbox.sendKeys(userId.getPassword()); - } - - public void loginWithUser(UserRoleEnum role) { - try { - getExtendTest().log(Status.INFO, String.format("Login as user %s", role.name().toUpperCase())); - loginToSystem(role); - goToHomePage(role); - } catch (Exception e) { - throw new RuntimeException(e); - } - finally{ - getWindowTest().setPreviousRole(getWindowTest().getUser().getRole()); - } - } - - private void setUser(UserRoleEnum role) { - User user = new User(); - user.setUserId(role.getUserId()); - user.setFirstName(role.getFirstName()); - user.setRole(role.name()); - user.setLastName(role.getLastName()); - - getWindowTest().setUser(user); - } - - public User getUser() { - return getWindowTest().getUser(); - } - - private void setBrowserBeforeTest(UserRoleEnum role) { - System.out.println(String.format("Setup before test as %s.", role.toString().toUpperCase() )); - try { - System.out.println("Previous role is : " + getWindowTest().getPreviousRole() + " ; Current role is : " + role.name()); - if (!getWindowTest().getPreviousRole().toLowerCase().equals(role.name().toLowerCase())){ - System.out.println("Roles are different, navigate and login"); - navigateAndLogin(role); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void navigateAndLogin(UserRoleEnum role) throws Exception { - getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() != 0 ? getWindowTest().getRefreshAttempts() : 0); - setUser(role); - navigateToUrl(url); - loginWithUser(role); - GeneralUIUtils.ultimateWait(); - } - - public User getUser(UserRoleEnum role) { - User user = new User(); - user.setUserId(role.getUserId()); - user.setFirstName(role.getFirstName()); - user.setLastName(role.getLastName()); - user.setRole(role.name()); - return user; - } - - protected void reloginWithNewRole(UserRoleEnum role) throws Exception { - System.out.println(String.format("Setup before relogin as %s", role.toString().toUpperCase())); - navigateAndLogin(role); - } - - /*public static void setLocalUrl(UserRoleEnum role) { - switch (role) { - case ADMIN: { - url = "http://localhost:8181/sdc1/proxy-admin1#/dashboard"; - break; - } - case DESIGNER: { - url = "http://localhost:8181/sdc1/proxy-designer1#/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; - } - case PRODUCT_MANAGER1: { - url = "http://localhost:8181/sdc1/proxy-pm1#/dashboard"; - break; - } - case PRODUCT_MANAGER2: { - url = "http://localhost:8181/sdc1/proxy-pm2#/dashboard"; - break; - } - case PRODUCT_STRATEGIST1: { - url = "http://localhost:8181/sdc1/proxy-ps1#/dashboard"; - break; - } - case PRODUCT_STRATEGIST2: { - url = "http://localhost:8181/sdc1/proxy-ps2#/dashboard"; - break; - } - default: { - break; - } - } - }*/ - - public void addTrafficFileToReport(ITestResult result) { - try { - // Get the HAR data - Har har = MobProxy.getPoxyServer().getHar(); - String shortUUID = UUID.randomUUID().toString().split("-")[0]; - File harFile = new File(getHarFilesFolder() + result.getName() + shortUUID + ".har"); - new File(getHarFilesFolder()).mkdirs(); - - har.writeTo(harFile); - - String pathToFileFromReportDirectory = HAR_FILES_FOLDER_NAME + File.separator + harFile.getName(); - ExtentTestActions.addFileToReportAsLink(harFile, pathToFileFromReportDirectory, "File with captured traffic"); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - - /* - * * Start section of test in ExtentReport with DataProvider parameters, - * should be started from test method, see example in onboardVNFTest - */ - public void setLog(String fromDataProvider) { - - String suiteName = ExtentManager.getSuiteName(myContext); - if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { - ExtentTestManager.startTest(RE_RUN +Thread.currentThread().getStackTrace()[2].getMethodName() + "      " + fromDataProvider); - }else{ - ExtentTestManager.startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "      " + fromDataProvider); - } - - - - getWindowTest().setAddedValueFromDataProvider(fromDataProvider); - ExtentTestManager.assignCategory(this.getClass()); - setBrowserBeforeTest(getRole()); - } - - - - /**************** MAIN ****************/ - public static void main(String[] args) { - System.out.println("---------------------"); - System.out.println("running test from CLI"); - System.out.println("---------------------"); - - String attsdcFilePath = FileHandling.getBasePath() + File.separator + "conf" + File.separator + "attsdc.yaml"; - System.setProperty("config.resource", attsdcFilePath); - System.out.println("attsdc.yaml file path is : " + attsdcFilePath); - - String filepath = FileHandling.getBasePath() + File.separator + "Files" + File.separator; - System.setProperty("filePath", filepath); - System.out.println("filePath is : " + System.getProperty("filePath")); - - Object[] testSuitsList = FileHandling.filterFileNamesFromFolder(FileHandling.getBasePath() + File.separator + "testSuites", ".xml"); - if (testSuitsList != null) { - System.out.println(String.format("Found %s testSuite(s)", testSuitsList.length)); - args = Arrays.copyOf(testSuitsList, testSuitsList.length, String[].class); - StartTest.main(args); - } - } + FileHandling.cleanCurrentDownloadDir(); + } + + } + + private void addResultToCSV(ITestResult result, ITestContext context) { + ExtentTest test = getExtendTest(); + com.aventstack.extentreports.model.Test model = test.getModel(); + String name = model.getName(); + String status = model.getStatus().toString(); + getCsvReport().writeRow(result.getInstanceName(), name.replace(RE_RUN, ""), status); + } + + private void generateReport4Jenkins(ITestContext context) { + String suiteName = ExtentManager.getSuiteName(context); + JSONObject obj = new JSONObject(); + String success = Integer.toString(context.getPassedTests().size()); + String failed = Integer.toString(context.getFailedTests().size()); + String total = Integer.toString(context.getFailedTests().size() + context.getPassedTests().size()); + obj.put("projectName", "SDC-ONAP-UI-Automation-" + suiteName); + obj.put("projectVersion", AutomationUtils.getOSVersion()); + obj.put("platform", "Linux"); + obj.put("total", total); + obj.put("success", success); + obj.put("failed", failed); + + try (FileWriter file = new FileWriter(getReportFolder() + "jenkinsResults.json")) { + + file.write(obj.toJSONString()); + file.flush(); + + } catch (IOException e) { + e.printStackTrace(); + } + + System.out.print(obj); + + + } + + + @Parameters({"eraseAfterTests"}) + @AfterSuite(alwaysRun = true) + public void afterSuite2(@Optional("true") String eraseAfterTestsReadValue) throws Exception { + + csvReport.closeFile(); + generateReport4Jenkins(myContext); + + if (Boolean.parseBoolean(eraseAfterTestsReadValue)) { + RestCDUtils.deleteOnDemand(); + } else { + System.out.println("Resources will not be deleted according to suite configuration ..."); + } + + if (getConfig().getUseBrowserMobProxy()) { + MobProxy.getPoxyServer().stop(); + } + } + + private static String setUrl() { + url = getConfig().getUrl(); + uiSimulator = getConfig().isUiSimulator(); + if (url == null) { + String message = "no URL found"; + System.out.println(message); + Assert.fail(message); + } else if (!url.contains("localhost") && !url.contains("192.168.33.10") && !url.contains("127.0.0.1") && !url.contains("192.168.50.5") && !uiSimulator) { + localEnv = false; + } + return url; + } + + + private static void navigateToUrl(String url) throws Exception { + try { + System.out.println("Deleting cookies..."); + deleteCookies(); + + System.out.println("Navigating to URL : " + url); + getDriver().navigate().to(url); + GeneralUIUtils.waitForLoader(); + + System.out.println("Zooming out..."); + GeneralUIUtils.windowZoomOutUltimate(); + + } catch (Exception e) { + String msg = "Browser is unreachable"; + System.out.println(msg); + getExtendTest().log(Status.ERROR, msg); + Assert.fail(msg); + } + } + + private static void deleteCookies() throws Exception { + getDriver().manage().deleteAllCookies(); + Thread.sleep(BASIC_SLEEP_DURATION); + + int attempts = 0; + final int max_attempts = 3; + + while (!getDriver().manage().getCookies().isEmpty() && attempts < max_attempts) { + getExtendTest().log(Status.INFO, "Trying to delete cookies one more time - " + (attempts + 1) + "/" + max_attempts + "attempts"); + String deleteCookiesJS = "document.cookie.split(';').forEach(function(c) { document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/'); });"; + ((JavascriptExecutor) getDriver()).executeScript(deleteCookiesJS); + attempts++; + + if (attempts == max_attempts) { + String msg = "Did not delete cookies, can't login as user " + WindowTestManager.getWindowMap().getUser().getRole(); + System.out.println(msg); + getExtendTest().log(Status.ERROR, msg); + Assert.fail(msg); + } + } + } + + private void loginToSystem(UserRoleEnum role) throws Exception { + final int gettingWebElementTimeOut = 30; + UserCredentials credentials = new UserCredentials(role.getUserId(), role.getPassword(), role.getFirstName(), role.getLastName(), role.name()); + if (localEnv) { + loginToSimulator(role); + } else { + sendUserAndPasswordKeys(credentials); + WebElement submitButton = GeneralUIUtils.getWebElementBy(By.name("btnSubmit"), gettingWebElementTimeOut); + submitButton.click(); + WebElement buttonOK = GeneralUIUtils.getWebElementBy(By.name("successOK"), gettingWebElementTimeOut); + Assert.assertTrue(buttonOK.isDisplayed(), "OK button is not displayed."); + buttonOK.click(); + } + GeneralUIUtils.ultimateWait(); + getWindowTest().setUser(credentials); + } + + private void goToHomePage(UserRoleEnum role) throws Exception { + final int gettingButtonTimeOut = 10; + try { + getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() == 0 ? NUM_OF_ATTEMPTS_TO_REFTRESH : getWindowTest().getRefreshAttempts()); + if (!role.equals(UserRoleEnum.ADMIN)) { + + WebElement closeButton = GeneralUIUtils.getClickableButtonBy(By.className("sdc-welcome-close"), gettingButtonTimeOut); + if (closeButton != null) { + closeButton.click(); + } + + if (!GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.MainMenuButtons.HOME_BUTTON.getValue())) { + restartBrowser(role); + } + } + } catch (Exception e) { + restartBrowser(role); + } + } + + private void restartBrowser(UserRoleEnum role) throws Exception { + getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() - 1); + if (getWindowTest().getRefreshAttempts() <= 0) { + System.out.println("ERR : Something is wrong with browser!"); + Assert.fail("ERR : Something is wrong with browser!"); + } + System.out.println("Trying again..."); + getExtendTest().log(Status.INFO, "Trying again..."); + getExtendTest().log(Status.INFO, String.format("%s attempt(s) left", getWindowTest().getRefreshAttempts())); + System.out.println(String.format("%s attempt(s) left", getWindowTest().getRefreshAttempts())); + + reloginWithNewRole(role); + } + + private void loginToSimulator(UserRoleEnum role) { + final int gettingWebElementTimeOut = 30; + WebDriver driver = GeneralUIUtils.getDriver(); + WebDriverWait wait = new WebDriverWait(driver, gettingWebElementTimeOut); + + wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@method='" + "post" + "']")))); + + WebElement userIdTextbox = GeneralUIUtils.getWebElementBy(By.name("userId")); + userIdTextbox.sendKeys(role.getUserId()); + WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password")); + passwordTextbox.sendKeys(WEB_SEAL_PASSWORD); + + wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[@value='" + "Login" + "']")))).click(); + } + + private void sendUserAndPasswordKeys(UserCredentials userId) { + System.out.println("Login as user : " + userId.getUserId()); + WebElement userNameTextbox = GeneralUIUtils.getWebElementBy(By.name("userid")); + userNameTextbox.sendKeys(userId.getUserId()); + WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password")); + passwordTextbox.sendKeys(userId.getPassword()); + } + + private void loginWithUser(UserRoleEnum role) { + try { + getExtendTest().log(Status.INFO, String.format("Login as user %s", role.name().toUpperCase())); + loginToSystem(role); + goToHomePage(role); + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + getWindowTest().setPreviousRole(getWindowTest().getUser().getRole()); + } + } + + private void setUser(UserRoleEnum role) { + User user = new User(); + user.setUserId(role.getUserId()); + user.setFirstName(role.getFirstName()); + user.setRole(role.name()); + user.setLastName(role.getLastName()); + + getWindowTest().setUser(user); + } + + public User getUser() { + return getWindowTest().getUser(); + } + + private void setBrowserBeforeTest(UserRoleEnum role) { + System.out.println(String.format("Setup before test as %s.", role.toString().toUpperCase())); + try { + System.out.println("Previous role is : " + getWindowTest().getPreviousRole() + " ; Current role is : " + role.name()); + if (!getWindowTest().getPreviousRole().toLowerCase().equals(role.name().toLowerCase())) { + System.out.println("Roles are different, navigate and login"); + navigateAndLogin(role); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void navigateAndLogin(UserRoleEnum role) throws Exception { + getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() != 0 ? getWindowTest().getRefreshAttempts() : 0); + setUser(role); + navigateToUrl(url); + loginWithUser(role); + GeneralUIUtils.ultimateWait(); + } + + public User getUser(UserRoleEnum role) { + User user = new User(); + user.setUserId(role.getUserId()); + user.setFirstName(role.getFirstName()); + user.setLastName(role.getLastName()); + user.setRole(role.name()); + return user; + } + + protected void reloginWithNewRole(UserRoleEnum role) throws Exception { + System.out.println(String.format("Setup before relogin as %s", role.toString().toUpperCase())); + navigateAndLogin(role); + } + + private void addTrafficFileToReport(ITestResult result) { + try { + // Get the HAR data + Har har = MobProxy.getPoxyServer().getHar(); + String shortUUID = UUID.randomUUID().toString().split("-")[0]; + File harFile = new File(getHarFilesFolder() + result.getName() + shortUUID + ".har"); + new File(getHarFilesFolder()).mkdirs(); + + har.writeTo(harFile); + + String pathToFileFromReportDirectory = HAR_FILES_FOLDER_NAME + File.separator + harFile.getName(); + ExtentTestActions.addFileToReportAsLink(harFile, pathToFileFromReportDirectory, "File with captured traffic"); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + + /* + * * Start section of test in ExtentReport with DataProvider parameters, + * should be started from test method, see example in onboardVNFTest + */ + public void setLog(String fromDataProvider) { + + String suiteName = ExtentManager.getSuiteName(myContext); + if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) { + ExtentTestManager.startTest(RE_RUN + Thread.currentThread().getStackTrace()[2].getMethodName() + "      " + fromDataProvider); + } else { + ExtentTestManager.startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "      " + fromDataProvider); + } + + + getWindowTest().setAddedValueFromDataProvider(fromDataProvider); + ExtentTestManager.assignCategory(this.getClass()); + setBrowserBeforeTest(getRole()); + } + + + /**************** MAIN ****************/ + public static void main(String[] args) { + System.out.println("---------------------"); + System.out.println("running test from CLI"); + System.out.println("---------------------"); + + String attsdcFilePath = FileHandling.getBasePath() + File.separator + "conf" + File.separator + "attsdc.yaml"; + System.setProperty("config.resource", attsdcFilePath); + System.out.println("attsdc.yaml file path is : " + attsdcFilePath); + + String filepath = FileHandling.getBasePath() + File.separator + "Files" + File.separator; + System.setProperty("filePath", filepath); + System.out.println("filePath is : " + System.getProperty("filePath")); + + Object[] testSuitsList = FileHandling.filterFileNamesFromFolder(FileHandling.getBasePath() + File.separator + "testSuites", ".xml"); + if (testSuitsList != null) { + System.out.println(String.format("Found %s testSuite(s)", testSuitsList.length)); + args = Arrays.copyOf(testSuitsList, testSuitsList.length, String[].class); + StartTest.main(args); + } + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/TestFtp.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/TestFtp.java index 3b0439060a..bb48cbddb8 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/TestFtp.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/TestFtp.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,67 +30,63 @@ import java.nio.file.Paths; public class TestFtp { - public static void main(String[] args) throws IOException { - AttFtpClient instance = AttFtpClient.getInstance(); - - String server = "localhost"; - int port = 2121; - String user = "admin"; - String pass = "admin"; - AttFtpClient.getInstance().init(server, port, user, pass); - - try { - AttFtpClient.getInstance().retrieveListOfFile(); - - File retrieveLastModifiedFileFromFTP = instance.retrieveLastModifiedFileFromFTP(); - String content = new String(Files.readAllBytes(Paths.get(retrieveLastModifiedFileFromFTP.getPath())), StandardCharsets.UTF_8); -// instance.deleteFilesFromFTPserver(); - System.out.println(content); - readFile(retrieveLastModifiedFileFromFTP); - - } finally { - instance.terminateClient(); - } - - + public static void main(String[] args) throws IOException { + AttFtpClient instance = AttFtpClient.getFtpClient(); - - - - - } - public static void readFile(File retrieveLastModifiedFileFromFTP) { + String server = "localhost"; + final int port = 2121; + String user = "admin"; + String pass = "admin"; + AttFtpClient.getFtpClient().init(server, port, user, pass); - StringBuilder sb = new StringBuilder(); - BufferedReader br = null; - FileReader fileReader = null; - try { - fileReader = new FileReader(retrieveLastModifiedFileFromFTP.getPath()); - br = new BufferedReader(fileReader); - String line; - while ((line = br.readLine()) != null) { - if (sb.length() > 0) { - sb.append("\n"); - } - sb.append(line); - } - } catch (IOException e) { - System.out.println(e); - } finally { - try { - if (br != null) { - br.close(); - } - if(fileReader != null) { - fileReader.close(); - } - } catch (IOException ex) { - System.out.println(ex); - } - } - String contents = sb.toString(); - System.out.println(contents); - - } + try { + AttFtpClient.getFtpClient().retrieveListOfFile(); + + File retrieveLastModifiedFileFromFTP = instance.retrieveLastModifiedFileFromFTP(); + String content = new String(Files.readAllBytes(Paths.get(retrieveLastModifiedFileFromFTP.getPath())), StandardCharsets.UTF_8); +// instance.deleteFilesFromFTPserver(); + System.out.println(content); + readFile(retrieveLastModifiedFileFromFTP); + + } finally { + instance.terminateClient(); + } + + + } + + private static void readFile(File retrieveLastModifiedFileFromFTP) { + + StringBuilder sb = new StringBuilder(); + BufferedReader br = null; + FileReader fileReader = null; + try { + fileReader = new FileReader(retrieveLastModifiedFileFromFTP.getPath()); + br = new BufferedReader(fileReader); + String line; + while ((line = br.readLine()) != null) { + if (sb.length() > 0) { + sb.append("\n"); + } + sb.append(line); + } + } catch (IOException e) { + System.out.println(e); + } finally { + try { + if (br != null) { + br.close(); + } + if (fileReader != null) { + fileReader.close(); + } + } catch (IOException ex) { + System.out.println(ex); + } + } + String contents = sb.toString(); + System.out.println(contents); + + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java index da89c51633..bc9fd7eb67 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,132 +44,118 @@ import java.util.UUID; public class WebDriverThread { - public static final String AUTOMATION_DOWNLOAD_DIR = "automationDownloadDir"; - private WebDriver webdriver; - private FirefoxProfile firefoxProfile; - public static final String SELENIUM_NODE_URL = "http://%s:%s/wd/hub"; - - public WebDriverThread(Config config) { - initDriver(config); - webdriver.manage().window().maximize(); - } - - public WebDriver getDriver() throws Exception { - return webdriver; - } - - public void quitDriver() { - if (webdriver != null) { - webdriver.quit(); - webdriver = null; - } - } - - - public void initDriver(Config config){ - try { - boolean remoteTesting = config.isRemoteTesting(); - if (!remoteTesting) { - boolean mobProxyStatus = config.getUseBrowserMobProxy(); - if (mobProxyStatus){ - setWebDriverWithMobProxy(); - } else { - - // Selenium 3.4.0 change, add firefox options : set, add firefox 5.X location and enable -// FirefoxOptions options = new FirefoxOptions(); -// options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox5\\firefox.exe"); //Location where Firefox is installed -// options.addPreference("dom.file.createInChild", true); // Enable file upload with sendKeys - // End of Selenium 3.4.0 change - - System.out.println("Opening LOCAL browser"); - DesiredCapabilities cap = new DesiredCapabilities(); - - cap = DesiredCapabilities.firefox(); - cap.setBrowserName("firefox"); - cap.setCapability(FirefoxDriver.PROFILE, initFirefoxProfile()); - //unexpected model dialog fix. - cap.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT); -// cap.setCapability("moz:firefoxOptions", options); //Add options to Capabilities, Selenium 3.4.0 change - - firefoxProfile.setPreference("network.proxy.type", 2); -// firefoxProfile.setPreference("network.proxy.autoconfig_url", "http://emea-auto.proxy.att.com:8001/"); - firefoxProfile.setPreference("network.proxy.autoconfig_url", "http://autoproxy.sbc.com/autoproxy.cgi"); - firefoxProfile.setPreference("network.proxy.no_proxies_on", "localhost"); - - webdriver = new FirefoxDriver(cap); - } - } else { - System.out.println("Opening REMOTE browser"); - String remoteEnvIP = config.getRemoteTestingMachineIP(); - String remoteEnvPort = config.getRemoteTestingMachinePort(); - - DesiredCapabilities cap = new DesiredCapabilities(); - cap = DesiredCapabilities.firefox(); - cap.setPlatform(Platform.ANY); - cap.setBrowserName("firefox"); - - String remoteNodeUrl = String.format(SELENIUM_NODE_URL, remoteEnvIP, remoteEnvPort); - RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL(remoteNodeUrl), cap); - remoteWebDriver.setFileDetector(new LocalFileDetector()); - webdriver = remoteWebDriver; - } - - - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - private FirefoxProfile initFirefoxProfile() { - firefoxProfile = new FirefoxProfile(); - firefoxProfile.setPreference("browser.download.folderList",2); - firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false); - firefoxProfile.setPreference("browser.download.dir", getDownloadDirectory()); - firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream, application/xml, text/plain, text/xml, image/jpeg"); - return firefoxProfile; - } - - private String getDownloadDirectory() { - String downloadDirectory = FileHandling.getBasePath() + File.separator + AUTOMATION_DOWNLOAD_DIR + UUID.randomUUID().toString().split("-")[0] + File.separator; - File dir = new File(downloadDirectory); - if(!dir.exists()) { - dir.mkdirs(); - } - return dir.getAbsolutePath(); - } - - public FirefoxProfile getFirefoxProfile() { - return firefoxProfile; - } - - private void setWebDriverWithMobProxy(){ - WebDriver driver = null; - MobProxy.setProxyServer(); - BrowserMobProxyServer proxyServer = MobProxy.getPoxyServer(); - - firefoxProfile = new FirefoxProfile(); - firefoxProfile.setPreference("browser.download.folderList",2); - firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false); - firefoxProfile.setPreference("browser.download.dir", getDownloadDirectory()); - firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream, application/xml, text/plain, text/xml, image/jpeg"); - firefoxProfile.setAcceptUntrustedCertificates(true); - firefoxProfile.setAssumeUntrustedCertificateIssuer(true); -// firefoxProfile.setPreference("network.proxy.http", "localhost"); -// firefoxProfile.setPreference("network.proxy.http_port", proxyServer.getPort()); -// firefoxProfile.setPreference("network.proxy.ssl", "localhost"); -// firefoxProfile.setPreference("network.proxy.ssl_port", proxyServer.getPort()); -// firefoxProfile.setPreference("network.proxy.type", 1); -// firefoxProfile.setPreference("network.proxy.no_proxies_on", ""); + static final String AUTOMATION_DOWNLOAD_DIR = "automationDownloadDir"; + private WebDriver webdriver; + private FirefoxProfile firefoxProfile; + private static final String SELENIUM_NODE_URL = "http://%s:%s/wd/hub"; + + WebDriverThread(Config config) { + initDriver(config); + webdriver.manage().window().maximize(); + } + + public WebDriver getDriver() throws Exception { + return webdriver; + } + + void quitDriver() { + if (webdriver != null) { + webdriver.quit(); + webdriver = null; + } + } + + + private void initDriver(Config config) { + try { + boolean remoteTesting = config.isRemoteTesting(); + if (!remoteTesting) { + boolean mobProxyStatus = config.getUseBrowserMobProxy(); + if (mobProxyStatus) { + setWebDriverWithMobProxy(); + } else { + + System.out.println("Opening LOCAL browser"); + DesiredCapabilities cap = new DesiredCapabilities(); + + cap = DesiredCapabilities.firefox(); + cap.setBrowserName("firefox"); + cap.setCapability(FirefoxDriver.PROFILE, initFirefoxProfile()); + //unexpected model dialog fix. + cap.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT); + + firefoxProfile.setPreference("network.proxy.type", 2); + firefoxProfile.setPreference("network.proxy.autoconfig_url", "http://autoproxy.sbc.com/autoproxy.cgi"); + firefoxProfile.setPreference("network.proxy.no_proxies_on", "localhost"); + + webdriver = new FirefoxDriver(cap); + } + } else { + System.out.println("Opening REMOTE browser"); + String remoteEnvIP = config.getRemoteTestingMachineIP(); + String remoteEnvPort = config.getRemoteTestingMachinePort(); + + DesiredCapabilities cap = new DesiredCapabilities(); + cap = DesiredCapabilities.firefox(); + cap.setPlatform(Platform.ANY); + cap.setBrowserName("firefox"); + + String remoteNodeUrl = String.format(SELENIUM_NODE_URL, remoteEnvIP, remoteEnvPort); + RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL(remoteNodeUrl), cap); + remoteWebDriver.setFileDetector(new LocalFileDetector()); + webdriver = remoteWebDriver; + } + + + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + + private FirefoxProfile initFirefoxProfile() { + firefoxProfile = new FirefoxProfile(); + firefoxProfile.setPreference("browser.download.folderList", 2); + firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false); + firefoxProfile.setPreference("browser.download.dir", getDownloadDirectory()); + firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream, application/xml, text/plain, text/xml, image/jpeg"); + return firefoxProfile; + } + + private String getDownloadDirectory() { + String downloadDirectory = FileHandling.getBasePath() + File.separator + AUTOMATION_DOWNLOAD_DIR + UUID.randomUUID().toString().split("-")[0] + File.separator; + File dir = new File(downloadDirectory); + if (!dir.exists()) { + dir.mkdirs(); + } + return dir.getAbsolutePath(); + } + + FirefoxProfile getFirefoxProfile() { + return firefoxProfile; + } + + private void setWebDriverWithMobProxy() { + WebDriver driver = null; + MobProxy.setProxyServer(); + BrowserMobProxyServer proxyServer = MobProxy.getPoxyServer(); + + firefoxProfile = new FirefoxProfile(); + firefoxProfile.setPreference("browser.download.folderList", 2); + firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false); + firefoxProfile.setPreference("browser.download.dir", getDownloadDirectory()); + firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream, application/xml, text/plain, text/xml, image/jpeg"); + firefoxProfile.setAcceptUntrustedCertificates(true); + firefoxProfile.setAssumeUntrustedCertificateIssuer(true); DesiredCapabilities capabilities = new DesiredCapabilities(); - + capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile); capabilities.setCapability(CapabilityType.PROXY, ClientUtil.createSeleniumProxy(proxyServer)); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); webdriver = new FirefoxDriver(capabilities); - proxyServer.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT, CaptureType.REQUEST_COOKIES, CaptureType.REQUEST_BINARY_CONTENT, - CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_COOKIES, CaptureType.RESPONSE_HEADERS, CaptureType.RESPONSE_BINARY_CONTENT); - } + proxyServer.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT, CaptureType.REQUEST_COOKIES, CaptureType.REQUEST_BINARY_CONTENT, + CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_COOKIES, CaptureType.RESPONSE_HEADERS, CaptureType.RESPONSE_BINARY_CONTENT); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTest.java index 3e61861cf0..1de4b4c799 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTest.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,53 +25,62 @@ import org.openecomp.sdc.be.model.User; import java.io.File; public class WindowTest { - - public WindowTest(){ - refreshAttempts = 0; - previousRole = ""; - addedValueFromDataProvider = null; - try { - downloadDirectory = DriverFactory.getDriverFirefoxProfile().getStringPreference("browser.download.dir", null) + File.separator; - } catch (Exception e) { - e.printStackTrace(); - } - } - - private int refreshAttempts; - private String previousRole; - private User user; - private String addedValueFromDataProvider; - private String downloadDirectory; - - public int getRefreshAttempts() { - return refreshAttempts; - } - public void setRefreshAttempts(int refreshAttempts) { - this.refreshAttempts = refreshAttempts; - } - public String getPreviousRole() { - return previousRole; - } - public void setPreviousRole(String previousRole) { - this.previousRole = previousRole; - } - public User getUser() { - return user; - } - public void setUser(User user) { - this.user = user; - } - public synchronized String getAddedValueFromDataProvider() { - return addedValueFromDataProvider; - } - public synchronized void setAddedValueFromDataProvider(String addedValueFromDataProvider) { - this.addedValueFromDataProvider = addedValueFromDataProvider; - } - public String getDownloadDirectory() { - return downloadDirectory; - } - public void setDownloadDirectory(String downloadDirectory) { - this.downloadDirectory = downloadDirectory; - } + + public WindowTest() { + refreshAttempts = 0; + previousRole = ""; + addedValueFromDataProvider = null; + try { + downloadDirectory = DriverFactory.getDriverFirefoxProfile().getStringPreference("browser.download.dir", null) + File.separator; + } catch (Exception e) { + e.printStackTrace(); + } + } + + private int refreshAttempts; + private String previousRole; + private User user; + private String addedValueFromDataProvider; + private String downloadDirectory; + + public int getRefreshAttempts() { + return refreshAttempts; + } + + public void setRefreshAttempts(int refreshAttempts) { + this.refreshAttempts = refreshAttempts; + } + + public String getPreviousRole() { + return previousRole; + } + + public void setPreviousRole(String previousRole) { + this.previousRole = previousRole; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public synchronized String getAddedValueFromDataProvider() { + return addedValueFromDataProvider; + } + + public synchronized void setAddedValueFromDataProvider(String addedValueFromDataProvider) { + this.addedValueFromDataProvider = addedValueFromDataProvider; + } + + public String getDownloadDirectory() { + return downloadDirectory; + } + + public void setDownloadDirectory(String downloadDirectory) { + this.downloadDirectory = downloadDirectory; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java index b160b57132..ad67fab8e8 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,28 +23,28 @@ package org.openecomp.sdc.ci.tests.execute.setup; import java.util.HashMap; public class WindowTestManager { - - private static HashMap windowMap = new HashMap(); - - public static synchronized WindowTest getWindowMap() { - Long currentThreadId = Thread.currentThread().getId(); - boolean containsKey = windowMap.containsKey(currentThreadId); - if (!containsKey){ - setWindowMap(currentThreadId); - } - return windowMap.get(currentThreadId); - } - - private static synchronized void setWindowMap(Long currentThreadId) { - WindowTestManager.windowMap.put(currentThreadId, new WindowTest()); - } - - public static synchronized void removeWindowTest(){ - windowMap.remove(Thread.currentThread().getId()); - } - - public static synchronized HashMap getWholeMap(){ - return windowMap; - } - + + private static HashMap windowMap = new HashMap(); + + public static synchronized WindowTest getWindowMap() { + Long currentThreadId = Thread.currentThread().getId(); + boolean containsKey = windowMap.containsKey(currentThreadId); + if (!containsKey) { + setWindowMap(currentThreadId); + } + return windowMap.get(currentThreadId); + } + + private static synchronized void setWindowMap(Long currentThreadId) { + WindowTestManager.windowMap.put(currentThreadId, new WindowTest()); + } + + public static synchronized void removeWindowTest() { + windowMap.remove(Thread.currentThread().getId()); + } + + public static synchronized HashMap getWholeMap() { + return windowMap; + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/AdminGeneralPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/AdminGeneralPage.java index ca54133c09..bfb096f5c5 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/AdminGeneralPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/AdminGeneralPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,102 +30,97 @@ import org.openqa.selenium.WebElement; import java.util.List; public class AdminGeneralPage extends GeneralPageElements { + + private static UserManagementTab userManagementTab = new UserManagementTab(); + + public static UserManagementTab getUserManagementTab() { + return userManagementTab; + } + + public static void selectCategoryManagmetTab() throws Exception { + + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.AdminPageTabs.CATEGORY_MANAGEMENT.getValue()); + } + + public static void selectUserManagmetTab() throws Exception { + + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.AdminPageTabs.USER_MANAGEMENT.getValue()); + } + + public static List getServiceCategoriesList() throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.SERVICE_CATEGORY_HEADER.getValue()); + GeneralUIUtils.waitForLoader(); + return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.CategoryManagement.SERVICE_CATEGORY_LIST.getValue()); + } + + public static List getResourceCategoriesList() throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_HEADER.getValue()); + GeneralUIUtils.waitForLoader(); + return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_LIST.getValue()); + } + + public static void createNewServiceCategory(String name) throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.SERVICE_CATEGORY_HEADER.getValue()); + SetupCDTest.getExtendTest().log(Status.INFO, "Creating service..."); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.NEW_CATEGORY_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(); + defineNewResourceCategoryName(name); + GeneralPageElements.clickOKButton(); + GeneralUIUtils.waitForLoader(); + } + + public static void selectElementFromList(List list, String elementToSelect) throws Exception { + + for (WebElement webElement : list) { + if (webElement.getText().toLowerCase().equals(elementToSelect.toLowerCase())) { + webElement.click(); + } + } + + } + + + public static void addSubCategoryToResource(List resourceList, String parentResource, String subCategoryName) throws Exception { + + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_HEADER.getValue()); + selectElementFromList(resourceList, parentResource); + SetupCDTest.getExtendTest().log(Status.INFO, "Creating..."); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.NEW_SUB_CATEGORY_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(); + defineNewResourceCategoryName(subCategoryName); + GeneralPageElements.clickOKButton(); + GeneralUIUtils.waitForLoader(); + + + } + + public static void createNewResourceCategory(String name) throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_HEADER.getValue()); + SetupCDTest.getExtendTest().log(Status.INFO, "Creating..."); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.NEW_CATEGORY_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(); + defineNewResourceCategoryName(name); + GeneralPageElements.clickOKButton(); + GeneralUIUtils.waitForLoader(); + + } + + public void insertPropertyDefaultValue(String value) { + WebElement propertyValue = GeneralUIUtils + .getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue()); + propertyValue.clear(); + propertyValue.sendKeys(value); + } + + private static void defineNewResourceCategoryName(String name) { + WebElement categoryNameTextbox = getCategoryName(); + categoryNameTextbox.clear(); + categoryNameTextbox.sendKeys(name); + } + + private static WebElement getCategoryName() { + return GeneralUIUtils.getWebElementByClassName(DataTestIdEnum.CategoryManagement.NEW_CATEGORY_NAME.getValue()); + } - public AdminGeneralPage() { - super(); - } - - private static UserManagementTab userManagementTab = new UserManagementTab(); - - public static UserManagementTab getUserManagementTab() { - return userManagementTab; - } - - public static void selectCategoryManagmetTab() throws Exception { - - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.AdminPageTabs.CATEGORY_MANAGEMENT.getValue()); - } - - public static void selectUserManagmetTab() throws Exception { - - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.AdminPageTabs.USER_MANAGEMENT.getValue()); - } - - public static List getServiceCategoriesList() throws Exception { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.SERVICE_CATEGORY_HEADER.getValue()); - GeneralUIUtils.waitForLoader(); - return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.CategoryManagement.SERVICE_CATEGORY_LIST.getValue()); - } - - public static List getResourceCategoriesList() throws Exception { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_HEADER.getValue()); - GeneralUIUtils.waitForLoader(); - return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_LIST.getValue()); - } - - public static void createNewServiceCategory(String name) throws Exception { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.SERVICE_CATEGORY_HEADER.getValue()); - SetupCDTest.getExtendTest().log(Status.INFO, "Creating service..."); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.NEW_CATEGORY_BUTTON.getValue()); - GeneralUIUtils.waitForLoader(); - defineNewResourceCategoryName(name); - GeneralPageElements.clickOKButton(); - GeneralUIUtils.waitForLoader(); - } - - public static void selectElementFromList(List list, String elementToSelect) throws Exception { - - for (WebElement webElement : list) { - if (webElement.getText().toLowerCase().equals(elementToSelect.toLowerCase())){ - webElement.click(); - } - } - - } - - - - public static void addSubCategoryToResource(List resourceList, String parentResource, String subCategoryName) throws Exception{ - - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_HEADER.getValue()); - selectElementFromList(resourceList, parentResource); - SetupCDTest.getExtendTest().log(Status.INFO, "Creating..."); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.NEW_SUB_CATEGORY_BUTTON.getValue()); - GeneralUIUtils.waitForLoader(); - defineNewResourceCategoryName(subCategoryName); - GeneralPageElements.clickOKButton(); - GeneralUIUtils.waitForLoader(); - - - } - - public static void createNewResourceCategory(String name) throws Exception { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.RESOURCE_CATEGORY_HEADER.getValue()); - SetupCDTest.getExtendTest().log(Status.INFO, "Creating..."); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CategoryManagement.NEW_CATEGORY_BUTTON.getValue()); - GeneralUIUtils.waitForLoader(); - defineNewResourceCategoryName(name); - GeneralPageElements.clickOKButton(); - GeneralUIUtils.waitForLoader(); - - } - - public void insertPropertyDefaultValue(String value) { - WebElement propertyValue = GeneralUIUtils - .getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue()); - propertyValue.clear(); - propertyValue.sendKeys(value); - } - - private static void defineNewResourceCategoryName(String name) { - WebElement categoryNameTextbox = getCategoryName(); - categoryNameTextbox.clear(); - categoryNameTextbox.sendKeys(name); - } - - private static WebElement getCategoryName() { - return GeneralUIUtils.getWebElementByClassName(DataTestIdEnum.CategoryManagement.NEW_CATEGORY_NAME.getValue()); - } - } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ComponentLeftMenu.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ComponentLeftMenu.java index d795599f24..672b8e05b0 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ComponentLeftMenu.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ComponentLeftMenu.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/CompositionPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/CompositionPage.java index 6e0cfe563d..2311bd9bc6 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/CompositionPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/CompositionPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,208 +37,198 @@ import java.util.List; public class CompositionPage extends GeneralPageElements { - public CompositionPage() { - super(); - } - - public static UploadArtifactPopup artifactPopup() { - return new UploadArtifactPopup(true); - } - - public static void searchForElement(String elementName) { - SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + elementName + " in the left panel"); - WebElement searchField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.SEARCH_ASSET.getValue()); - searchField.clear(); - searchField.sendKeys(elementName); - GeneralUIUtils.ultimateWait(); - } - - public static void showDeploymentArtifactTab() throws Exception { - clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB); - } - - public static void showInformationsTab() throws Exception { - clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.INFORMATION_TAB); - } - - public static void showPropertiesAndAttributesTab() throws Exception { - clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.PROPERTIES_AND_ATTRIBUTES_TAB); - } - - public static List getProperties() { - return PropertiesPage.getElemenetsFromTable(); - } - - public static List getDeploymentArtifacts() { - return getAllAddedArtifacts(); - } - - public static List getAllAddedArtifacts() { - String dataTestsId = DataTestIdEnum.CompositionScreenEnum.ARTIFACTS_LIST.getValue(); - return GeneralUIUtils.getWebElementsListBy(By.xpath("//*[contains(@data-tests-id,'" + dataTestsId + "')]")); - } - - public static void moveToInputsScreen() throws Exception { - OpenPagesMenu(2); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.MENU_INPUTS.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void moveToPropertiesScreen() throws Exception { - OpenPagesMenu(2); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.MENU_PROPERTIES_ASSIGNMENT.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void moveToOnboardScreen() throws Exception { - OpenPagesMenu(0); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.MENU_ONBOARD.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void moveToHomeScreen() throws Exception { - OpenPagesMenu(0); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.MENU_HOME.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - private static void OpenPagesMenu(int counter) { - Actions actions = new Actions(GeneralUIUtils.getDriver()); - List triangleList = GeneralUIUtils.getWebElementsListByClassName(DataTestIdEnum.CompositionScreenEnum.MENU_TRIANGLE_DROPDOWN.getValue()); - WebElement pagesMenu = triangleList.get(counter); - actions.moveToElement(pagesMenu).perform(); - } - - public static void changeComponentVersion(CanvasManager canvasManager, CanvasElement element, String version) { - changeComponentVersion(canvasManager,element,version,false); - } - - public static void changeComponentVersion(CanvasManager canvasManager, CanvasElement element, String version, boolean isValidate) { - try{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Changing component version to %s", version)); - canvasManager.clickOnCanvaElement(element); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue()); -// GeneralUIUtils.ultimateWait(); - Select selectlist = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue())); - while (selectlist.getOptions().size() == 0) { - selectlist = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue())); - } - GeneralUIUtils.ultimateWait();; - selectlist.selectByValue(version); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.clickSomewhereOnPage(); - - // Validate Selection - if(isValidate) - { - GeneralUIUtils.ultimateWait(); - canvasManager.clickOnCanvaElement(element); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating component version changed to %s", version)); - String actualSelectedValue = GeneralUIUtils.getWebElementBy(By.xpath(String.format("//select[@data-tests-id='%s']//option[@selected='selected']",DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue()))).getText(); - AssertJUnit.assertTrue(actualSelectedValue.equals(version)); - } - } - catch(Exception e){ - throw e; - } - } - - public static void clickAddArtifactButton() throws Exception{ - clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.ADD_ARTIFACT); - GeneralUIUtils.getWebElementByClassName("sdc-add-artifact"); - } - - public static String getSelectedInstanceName(){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText(); - } - - public static void showInformationArtifactTab() throws Exception { - clickOnTab(DataTestIdEnum.CompositionScreenEnum.INFORMATION_ARTIFACTS); - } - - public static void showAPIArtifactTab() throws Exception { - clickOnTab(DataTestIdEnum.CompositionScreenEnum.API); - } - - public static void showInformationTab() throws Exception { - clickOnTab(DataTestIdEnum.CompositionScreenEnum.INFORMATION); - } - - public static void showCompositionTab() throws Exception { - clickOnTab(DataTestIdEnum.CompositionScreenEnum.COMPOSITION); - } - - public static void showInputsTab() throws Exception { - clickOnTab(DataTestIdEnum.CompositionScreenEnum.INPUTS); - } - - public static void showRequirementsAndCapabilitiesTab() throws Exception { - clickOnTab(DataTestIdEnum.CompositionScreenEnum.REQUIREMENTS_AND_CAPABILITIES); - } - - public static List getOpenTabTitle() throws Exception{ -// return GeneralUIUtils.getElementsByCSS("expand-collapse span"); - return GeneralUIUtils.getElementsByCSS("expand-collapse ng-transclude"); - } - - public static void clickOnTab(DataTestIdEnum.CompositionScreenEnum tabSelector) throws Exception{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", tabSelector.name())); - GeneralUIUtils.getElementsByCSS(tabSelector.getValue()).get(0).click(); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum tabSelector) throws Exception{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", tabSelector.name())); - GeneralUIUtils.getWebElementByTestID(tabSelector.getValue()).click(); - GeneralUIUtils.ultimateWait(); - } - - public static CanvasElement addElementToCanvasScreen(LeftPanelCanvasItems elementName, CanvasManager vfCanvasManager) throws Exception{ - CompositionPage.searchForElement(elementName.name()); - return vfCanvasManager.createElementOnCanvas(elementName); - } - - public static CanvasElement addElementToCanvasScreen(String elementName, CanvasManager vfCanvasManager) throws Exception{ - CompositionPage.searchForElement(elementName); - return vfCanvasManager.createElementOnCanvas(elementName); - } - - public static List getCompositionDeplymentArtifacts() { - return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue()); - } - public static WebElement getCustomizationUUID() throws Exception { - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CUSTOMIZATION_UUID.getValue()); - } - - - public static List getCompositionEnvArtifacts(){ - return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ENV.getValue()); - } - - public static WebElement clickDownloadEnvArtifactComposition(String fileName) { - GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ENV.getValue() + fileName); - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() +fileName); - } - - public static void setSingleProperty(String propertyDataTestID, String propertyValue) - { - WebElement findElement = GeneralUIUtils.getWebElementByTestID(propertyDataTestID); - findElement.click(); - PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue); - PropertiesPage.getPropertyPopup().clickSave(); - GeneralUIUtils.ultimateWait(); - findElement = GeneralUIUtils.getWebElementByTestID("value_" + propertyDataTestID); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating property %s is set", propertyValue)); - AssertJUnit.assertTrue(findElement.getText().equals(propertyValue)); - GeneralUIUtils.ultimateWait(); - } - - - - - - - - - + private CompositionPage() { + super(); + } + + public static UploadArtifactPopup artifactPopup() { + return new UploadArtifactPopup(true); + } + + public static void searchForElement(String elementName) { + SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + elementName + " in the left panel"); + WebElement searchField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.SEARCH_ASSET.getValue()); + searchField.clear(); + searchField.sendKeys(elementName); + GeneralUIUtils.ultimateWait(); + } + + public static void showDeploymentArtifactTab() throws Exception { + clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB); + } + + public static void showInformationsTab() throws Exception { + clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.INFORMATION_TAB); + } + + public static void showPropertiesAndAttributesTab() throws Exception { + clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.PROPERTIES_AND_ATTRIBUTES_TAB); + } + + public static List getProperties() { + return PropertiesPage.getElemenetsFromTable(); + } + + public static List getDeploymentArtifacts() { + return getAllAddedArtifacts(); + } + + public static List getAllAddedArtifacts() { + String dataTestsId = DataTestIdEnum.CompositionScreenEnum.ARTIFACTS_LIST.getValue(); + return GeneralUIUtils.getWebElementsListBy(By.xpath("//*[contains(@data-tests-id,'" + dataTestsId + "')]")); + } + + public static void moveToInputsScreen() throws Exception { + openPagesMenu(2); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.MENU_INPUTS.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void moveToPropertiesScreen() throws Exception { + openPagesMenu(2); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.MENU_PROPERTIES_ASSIGNMENT.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void moveToOnboardScreen() throws Exception { + openPagesMenu(0); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.MENU_ONBOARD.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void moveToHomeScreen() throws Exception { + openPagesMenu(0); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.MENU_HOME.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + private static void openPagesMenu(int counter) { + Actions actions = new Actions(GeneralUIUtils.getDriver()); + List triangleList = GeneralUIUtils.getWebElementsListByClassName(DataTestIdEnum.CompositionScreenEnum.MENU_TRIANGLE_DROPDOWN.getValue()); + WebElement pagesMenu = triangleList.get(counter); + actions.moveToElement(pagesMenu).perform(); + } + + public static void changeComponentVersion(CanvasManager canvasManager, CanvasElement element, String version) { + changeComponentVersion(canvasManager, element, version, false); + } + + public static void changeComponentVersion(CanvasManager canvasManager, CanvasElement element, String version, boolean isValidate) { + try { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Changing component version to %s", version)); + canvasManager.clickOnCanvaElement(element); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue()); + //GeneralUIUtils.ultimateWait(); + Select selectlist = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue())); + while (selectlist.getOptions().size() == 0) { + selectlist = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue())); + } + GeneralUIUtils.ultimateWait(); + selectlist.selectByValue(version); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.clickSomewhereOnPage(); + + // Validate Selection + if (isValidate) { + GeneralUIUtils.ultimateWait(); + canvasManager.clickOnCanvaElement(element); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating component version changed to %s", version)); + String actualSelectedValue = GeneralUIUtils.getWebElementBy(By.xpath(String.format("//select[@data-tests-id='%s']//option[@selected='selected']", DataTestIdEnum.CompositionScreenEnum.CHANGE_VERSION.getValue()))).getText(); + AssertJUnit.assertTrue(actualSelectedValue.equals(version)); + } + } catch (Exception e) { + throw e; + } + } + + public static void clickAddArtifactButton() throws Exception { + clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum.ADD_ARTIFACT); + GeneralUIUtils.getWebElementByClassName("sdc-add-artifact"); + } + + public static String getSelectedInstanceName() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText(); + } + + public static void showInformationArtifactTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.INFORMATION_ARTIFACTS); + } + + public static void showAPIArtifactTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.API); + } + + public static void showInformationTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.INFORMATION); + } + + public static void showCompositionTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.COMPOSITION); + } + + public static void showInputsTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.INPUTS); + } + + public static void showRequirementsAndCapabilitiesTab() throws Exception { + clickOnTab(DataTestIdEnum.CompositionScreenEnum.REQUIREMENTS_AND_CAPABILITIES); + } + + public static List getOpenTabTitle() throws Exception { + return GeneralUIUtils.getElementsByCSS("expand-collapse ng-transclude"); + } + + public static void clickOnTab(DataTestIdEnum.CompositionScreenEnum tabSelector) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", tabSelector.name())); + GeneralUIUtils.getElementsByCSS(tabSelector.getValue()).get(0).click(); + GeneralUIUtils.ultimateWait(); + } + + public static void clickOnTabTestID(DataTestIdEnum.CompositionScreenEnum tabSelector) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", tabSelector.name())); + GeneralUIUtils.getWebElementByTestID(tabSelector.getValue()).click(); + GeneralUIUtils.ultimateWait(); + } + + public static CanvasElement addElementToCanvasScreen(LeftPanelCanvasItems elementName, CanvasManager vfCanvasManager) throws Exception { + CompositionPage.searchForElement(elementName.name()); + return vfCanvasManager.createElementOnCanvas(elementName); + } + + public static CanvasElement addElementToCanvasScreen(String elementName, CanvasManager vfCanvasManager) throws Exception { + CompositionPage.searchForElement(elementName); + return vfCanvasManager.createElementOnCanvas(elementName); + } + + public static List getCompositionDeplymentArtifacts() { + return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue()); + } + + public static WebElement getCustomizationUUID() throws Exception { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionScreenEnum.CUSTOMIZATION_UUID.getValue()); + } + + + public static List getCompositionEnvArtifacts() { + return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ENV.getValue()); + } + + public static WebElement clickDownloadEnvArtifactComposition(String fileName) { + GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ENV.getValue() + fileName); + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() + fileName); + } + + public static void setSingleProperty(String propertyDataTestID, String propertyValue) { + WebElement findElement = GeneralUIUtils.getWebElementByTestID(propertyDataTestID); + findElement.click(); + PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue); + PropertiesPage.getPropertyPopup().clickSave(); + GeneralUIUtils.ultimateWait(); + findElement = GeneralUIUtils.getWebElementByTestID("value_" + propertyDataTestID); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating property %s is set", propertyValue)); + AssertJUnit.assertTrue(findElement.getText().equals(propertyValue)); + GeneralUIUtils.ultimateWait(); + } + + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentArtifactPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentArtifactPage.java index ff9464fd6a..669a79ac39 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentArtifactPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentArtifactPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,248 +40,243 @@ import java.util.stream.Collectors; public class DeploymentArtifactPage extends GeneralPageElements { - public DeploymentArtifactPage() { - super(); - } - - public static ResourceLeftMenu getLeftPanel() { - return new ResourceLeftMenu(); - } - - public static UploadArtifactPopup artifactPopup() { - return new UploadArtifactPopup(); - } - - protected static void addNewArtifact(ArtifactGroupTypeEnum artifactGroupType) { - switch (artifactGroupType) { - case DEPLOYMENT: - GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPageEnum.ADD_DEPLOYMENT_ARTIFACT.getValue()).click(); - break; - case INFORMATIONAL: - GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPageEnum.ADD_INFORMATIONAL_ARTIFACT.getValue()).click(); - break; - default: - break; - } - } - - public static void clickAddNewArtifact() { - addNewArtifact(ArtifactGroupTypeEnum.DEPLOYMENT); - } - - public static void clickAddAnotherArtifact() { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.ADD_ANOTHER_ARTIFACT.getValue()).click(); - } - - public static void clickEditArtifact(String artifactLabel) { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.EDIT_ARTIFACT.getValue() + artifactLabel).click(); - } - - public static void clickEditEnvArtifact(String artifactLabel) { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.EDIT_PARAMETERS_OF_ARTIFACT.getValue() + artifactLabel).click(); - } - - public static void hoverArtifact(String artifactLabel) { - GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_NAME.getValue() + artifactLabel); - } - - public static void clickDeleteArtifact(String artifactLabel) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Deleting %s Artefact ",artifactLabel)); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DELETE_ARTIFACT.getValue() + artifactLabel).click(); - } - - public static WebElement clickDownloadArtifact(String artifactLabel) { - WebElement downloadButton = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT.getValue() + artifactLabel); - - return downloadButton; - } - - public static void clickDownloadEnvArtifact(String envFileNameToDownload) { - ExtentTestActions.log(Status.INFO, String.format("Downloading the updated %s artifact for validate parameters with the response after the update...", envFileNameToDownload)); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() + envFileNameToDownload); - ExtentTestActions.log(Status.INFO, String.format("%s Envartifact was downloaded successfully!", envFileNameToDownload)); - } - - public static void clickSaveEnvParameters() { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.SAVE.getValue()).click(); - GeneralUIUtils.ultimateWait(); - } - - public static void clickCloseEnvParameters() { + protected DeploymentArtifactPage() { + super(); + } + + public static ResourceLeftMenu getLeftPanel() { + return new ResourceLeftMenu(); + } + + public static UploadArtifactPopup artifactPopup() { + return new UploadArtifactPopup(); + } + + protected static void addNewArtifact(ArtifactGroupTypeEnum artifactGroupType) { + switch (artifactGroupType) { + case DEPLOYMENT: + GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPageEnum.ADD_DEPLOYMENT_ARTIFACT.getValue()).click(); + break; + case INFORMATIONAL: + GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPageEnum.ADD_INFORMATIONAL_ARTIFACT.getValue()).click(); + break; + default: + break; + } + } + + public static void clickAddNewArtifact() { + addNewArtifact(ArtifactGroupTypeEnum.DEPLOYMENT); + } + + public static void clickAddAnotherArtifact() { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.ADD_ANOTHER_ARTIFACT.getValue()).click(); + } + + public static void clickEditArtifact(String artifactLabel) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.EDIT_ARTIFACT.getValue() + artifactLabel).click(); + } + + public static void clickEditEnvArtifact(String artifactLabel) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.EDIT_PARAMETERS_OF_ARTIFACT.getValue() + artifactLabel).click(); + } + + public static void hoverArtifact(String artifactLabel) { + GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_NAME.getValue() + artifactLabel); + } + + public static void clickDeleteArtifact(String artifactLabel) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Deleting %s Artefact ", artifactLabel)); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DELETE_ARTIFACT.getValue() + artifactLabel).click(); + } + + public static WebElement clickDownloadArtifact(String artifactLabel) { + WebElement downloadButton = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT.getValue() + artifactLabel); + + return downloadButton; + } + + public static void clickDownloadEnvArtifact(String envFileNameToDownload) { + ExtentTestActions.log(Status.INFO, String.format("Downloading the updated %s artifact for validate parameters with the response after the update...", envFileNameToDownload)); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DOWNLOAD_ARTIFACT_ENV.getValue() + envFileNameToDownload); + ExtentTestActions.log(Status.INFO, String.format("%s Envartifact was downloaded successfully!", envFileNameToDownload)); + } + + public static void clickSaveEnvParameters() { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.SAVE.getValue()).click(); + GeneralUIUtils.ultimateWait(); + } + + public static void clickCloseEnvParameters() { GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.CANCEL_BUTTON.getValue()).click(); GeneralUIUtils.ultimateWait(); } - - public static WebElement getAddOtherArtifactButton(){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.ADD_ANOTHER_ARTIFACT.getValue()); - } - - public static void clickOK(){ - SetupCDTest.getExtendTest().log(Status.INFO, "Artifact Page, Clicking OK"); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.OK.getValue()).click(); - GeneralUIUtils.getWebElementBy(By.className("flex-container")); - GeneralUIUtils.waitForAngular(); - } - - public static String getArtifactDescription(String artifactLabel) throws Exception { - clickOnArtifactDescription(artifactLabel); // open artifact - WebElement artifactDescriptionElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.GET_DEPLOYMENT_ARTIFACT_DESCRIPTION.getValue()); - String artifactDesc = artifactDescriptionElement.getAttribute("value"); - closeArtifactDescription(artifactLabel); // close artifact - return artifactDesc; - } - - public static void closeArtifactDescription(String artifactLabel) { - GeneralUIUtils.clickOnElementByTestId("popover-x-button"); - } - - public static WebElement clickOnArtifactDescription(String artifactLabel) throws Exception { - try{ - WebElement artifact = GeneralUIUtils.getWebElementByTestID("descriptionIcon_" + artifactLabel); - artifact.click(); - GeneralUIUtils.waitForLoader(); - return artifact; - } - catch(Exception e){ - throw new Exception("Artifact " + artifactLabel + "is not found"); - } - } - - public static boolean checkElementsCountInTable(int expectedElementsCount) { - return GeneralPageElements.checkElementsCountInTable(expectedElementsCount + 1); - } - - public static String[] verifyArtifactsExistInTable(String filepath, String vnfFile) throws Exception{ - String[] artifactNamesFromZipFile = FileHandling.getArtifactsFromZip(filepath, vnfFile); - return verifyArtifactsExistInTable(artifactNamesFromZipFile); - } - - public static String[] verifyArtifactsExistInTable(String[] artifactNamesFromZipFile) throws Exception{ - if (artifactNamesFromZipFile != null){ - checkArtifactsDisplayed(artifactNamesFromZipFile); - checkEnvArtifactsDisplayed(); - } - - return artifactNamesFromZipFile; - } - - public static void checkArtifactsDisplayed(String[] artifactsFromZipFile) throws Exception { - SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the artifacts in the table"); - List artifactList = Lists.newArrayList(artifactsFromZipFile).stream().filter(p -> !p.contains(".env")).map(p -> getVisualArtifactName(p)).collect(Collectors.toList()); - try{ -// List rows = GeneralUIUtils.getElementsByCSS("div div[data-tests-id^='artifact-item'] span.ng-binding:nth-of-type(2)"); - List rows = GeneralUIUtils.getElementsByCSS("div div[data-tests-id^='artifact-item'] span[data-tests-id^='artifactDisplayName']"); - for (WebElement r : rows){ - String artifactDisplayed = r.getAttribute("textContent").trim(); - if (artifactList.contains(artifactDisplayed)){ - artifactList.remove(artifactDisplayed); - } - else if (artifactDisplayed.toLowerCase().contains("license")){ - artifactList.add(artifactDisplayed); - } - } - checkLicenseArtifactsDisplayed(artifactList); - } - catch(Exception e){ - throw new Exception("Table problem"); - } - - - if (!artifactList.isEmpty()){ - throw new Exception(String.format("missing the following artifact(s) : %s", artifactList.toString())); - } - } - - public static void checkEnvArtifactsDisplayed() throws Exception { - List envRows; - List heatRows; - List heatNetRows; - List heatVolRows; - int envArtifactsSize = 0; - - SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the HEAT_ENV artifacts in the table"); - - try{ - envRows = GeneralUIUtils.getElementsByCSS("div div[data-tests-id='HEAT_ENV']"); - - heatRows = GeneralUIUtils.getElementsByCSS("div div[tooltip-content='HEAT']"); - heatNetRows = GeneralUIUtils.getElementsByCSS("div div[tooltip-content='HEAT_NET']"); - heatVolRows = GeneralUIUtils.getElementsByCSS("div div[tooltip-content='HEAT_VOL']"); - - envArtifactsSize = heatRows.size() + heatNetRows.size() + heatVolRows.size(); - } - catch(Exception e){ - throw new Exception("Table problem"); - } - - if (envArtifactsSize !=envRows.size()){ - throw new Exception(String.format("some env artifacts are missing... there is %s instead of %s", envRows.size(), envArtifactsSize)); - } - - } - - public static void checkLicenseArtifactsDisplayed(List rowsFromTable) throws Exception { - SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the license artifacts in the table"); - String vfLicense = getPreparedLicense(ArtifactTypeEnum.VF_LICENSE.getType()); - String[] split = vfLicense.split(" "); - vfLicense = vfLicense.replaceAll(split[0], split[0].toUpperCase()); - if (rowsFromTable.contains(vfLicense)){ - rowsFromTable.remove(vfLicense); - } - - String vendorLicense = getPreparedLicense(ArtifactTypeEnum.VENDOR_LICENSE.getType()); - if (rowsFromTable.contains(vendorLicense)){ - rowsFromTable.remove(vendorLicense); - } - - } - - public static String getPreparedLicense(String license) { - return WordUtils.capitalizeFully(license.replaceAll("_", " ")); - } - - - private static String getVisualArtifactName(String artifactName) { - if (artifactName.contains(".")){ - return artifactName.substring(0, artifactName.lastIndexOf(".")); - } - return artifactName; - } - - public static void updateDescription(String newDescription, ArtifactInfo artefact) throws Exception{ - UploadArtifactPopup artifactPopup = new UploadArtifactPopup(true); - DeploymentArtifactPage.clickEditArtifact(artefact.getArtifactLabel()); - artifactPopup.insertDescription(newDescription); - artifactPopup.clickDoneButton(); - } - - public static List getDeploymentArtifactsNamesWorkSpace() { - return GeneralUIUtils.getWebElementListText(GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.ArtifactPageEnum.ARTIFACT_NAME.getValue())); - } - - //Get Artifact Type by Artifact Name. - public static String getArtifactType(String artifactName){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.TYPE.getValue()+artifactName).getText(); - } - - public static List getHeatParametersInUI(String dataTestId){ - Listelements; - ListNames=new ArrayList<>(); - elements=GeneralUIUtils.getWebElementsListByContainTestID(dataTestId); - for (WebElement webElement : elements) { - String attributevalue=webElement.getAttribute("data-tests-id"); - Names.add(attributevalue.replace("heatParameterName_", "")); - } - return Names; - } - - public static void searchBoxEnv(String parameterName) { - GeneralUIUtils.getWebElementByContainsClassName("w-sdc-env-search-input").sendKeys(parameterName); - } - - public static void clearSearchBoxEnv() { - GeneralUIUtils.getWebElementByContainsClassName("w-sdc-env-search-input").clear(); - } + + public static WebElement getAddOtherArtifactButton() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.ADD_ANOTHER_ARTIFACT.getValue()); + } + + public static void clickOK() { + SetupCDTest.getExtendTest().log(Status.INFO, "Artifact Page, Clicking OK"); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.OK.getValue()).click(); + GeneralUIUtils.getWebElementBy(By.className("flex-container")); + GeneralUIUtils.waitForAngular(); + } + + public static String getArtifactDescription(String artifactLabel) throws Exception { + clickOnArtifactDescription(artifactLabel); // open artifact + WebElement artifactDescriptionElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.GET_DEPLOYMENT_ARTIFACT_DESCRIPTION.getValue()); + String artifactDesc = artifactDescriptionElement.getAttribute("value"); + closeArtifactDescription(artifactLabel); // close artifact + return artifactDesc; + } + + public static void closeArtifactDescription(String artifactLabel) { + GeneralUIUtils.clickOnElementByTestId("popover-x-button"); + } + + public static WebElement clickOnArtifactDescription(String artifactLabel) throws Exception { + try { + WebElement artifact = GeneralUIUtils.getWebElementByTestID("descriptionIcon_" + artifactLabel); + artifact.click(); + GeneralUIUtils.waitForLoader(); + return artifact; + } catch (Exception e) { + throw new Exception("Artifact " + artifactLabel + "is not found"); + } + } + + public static boolean checkElementsCountInTable(int expectedElementsCount) { + return GeneralPageElements.checkElementsCountInTable(expectedElementsCount + 1); + } + + public static String[] verifyArtifactsExistInTable(String filepath, String vnfFile) throws Exception { + String[] artifactNamesFromZipFile = FileHandling.getArtifactsFromZip(filepath, vnfFile); + return verifyArtifactsExistInTable(artifactNamesFromZipFile); + } + + public static String[] verifyArtifactsExistInTable(String[] artifactNamesFromZipFile) throws Exception { + if (artifactNamesFromZipFile != null) { + checkArtifactsDisplayed(artifactNamesFromZipFile); + checkEnvArtifactsDisplayed(); + } + + return artifactNamesFromZipFile; + } + + public static void checkArtifactsDisplayed(String[] artifactsFromZipFile) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the artifacts in the table"); + List artifactList = Lists.newArrayList(artifactsFromZipFile).stream().filter(p -> !p.contains(".env")).map(p -> getVisualArtifactName(p)).collect(Collectors.toList()); + try { + List rows = GeneralUIUtils.getElementsByCSS("div div[data-tests-id^='artifact-item'] span[data-tests-id^='artifactDisplayName']"); + for (WebElement r : rows) { + String artifactDisplayed = r.getAttribute("textContent").trim(); + if (artifactList.contains(artifactDisplayed)) { + artifactList.remove(artifactDisplayed); + } else if (artifactDisplayed.toLowerCase().contains("license")) { + artifactList.add(artifactDisplayed); + } + } + checkLicenseArtifactsDisplayed(artifactList); + } catch (Exception e) { + throw new Exception("Table problem"); + } + + + if (!artifactList.isEmpty()) { + throw new Exception(String.format("missing the following artifact(s) : %s", artifactList.toString())); + } + } + + public static void checkEnvArtifactsDisplayed() throws Exception { + List envRows; + List heatRows; + List heatNetRows; + List heatVolRows; + int envArtifactsSize = 0; + + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the HEAT_ENV artifacts in the table"); + + try { + envRows = GeneralUIUtils.getElementsByCSS("div div[data-tests-id='HEAT_ENV']"); + + heatRows = GeneralUIUtils.getElementsByCSS("div div[tooltip-content='HEAT']"); + heatNetRows = GeneralUIUtils.getElementsByCSS("div div[tooltip-content='HEAT_NET']"); + heatVolRows = GeneralUIUtils.getElementsByCSS("div div[tooltip-content='HEAT_VOL']"); + + envArtifactsSize = heatRows.size() + heatNetRows.size() + heatVolRows.size(); + } catch (Exception e) { + throw new Exception("Table problem"); + } + + if (envArtifactsSize != envRows.size()) { + throw new Exception(String.format("some env artifacts are missing... there is %s instead of %s", envRows.size(), envArtifactsSize)); + } + + } + + public static void checkLicenseArtifactsDisplayed(List rowsFromTable) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the license artifacts in the table"); + String vfLicense = getPreparedLicense(ArtifactTypeEnum.VF_LICENSE.getType()); + String[] split = vfLicense.split(" "); + vfLicense = vfLicense.replaceAll(split[0], split[0].toUpperCase()); + if (rowsFromTable.contains(vfLicense)) { + rowsFromTable.remove(vfLicense); + } + + String vendorLicense = getPreparedLicense(ArtifactTypeEnum.VENDOR_LICENSE.getType()); + if (rowsFromTable.contains(vendorLicense)) { + rowsFromTable.remove(vendorLicense); + } + + } + + public static String getPreparedLicense(String license) { + return WordUtils.capitalizeFully(license.replaceAll("_", " ")); + } + + + private static String getVisualArtifactName(String artifactName) { + if (artifactName.contains(".")) { + return artifactName.substring(0, artifactName.lastIndexOf(".")); + } + return artifactName; + } + + public static void updateDescription(String newDescription, ArtifactInfo artefact) throws Exception { + UploadArtifactPopup artifactPopup = new UploadArtifactPopup(true); + DeploymentArtifactPage.clickEditArtifact(artefact.getArtifactLabel()); + artifactPopup.insertDescription(newDescription); + artifactPopup.clickDoneButton(); + } + + public static List getDeploymentArtifactsNamesWorkSpace() { + return GeneralUIUtils.getWebElementListText(GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.ArtifactPageEnum.ARTIFACT_NAME.getValue())); + } + + //Get Artifact Type by Artifact Name. + public static String getArtifactType(String artifactName) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.TYPE.getValue() + artifactName).getText(); + } + + public static List getHeatParametersInUI(String dataTestId) { + List elements; + List Names = new ArrayList<>(); + elements = GeneralUIUtils.getWebElementsListByContainTestID(dataTestId); + for (WebElement webElement : elements) { + String attributevalue = webElement.getAttribute("data-tests-id"); + Names.add(attributevalue.replace("heatParameterName_", "")); + } + return Names; + } + + public static void searchBoxEnv(String parameterName) { + GeneralUIUtils.getWebElementByContainsClassName("w-sdc-env-search-input").sendKeys(parameterName); + } + + public static void clearSearchBoxEnv() { + GeneralUIUtils.getWebElementByContainsClassName("w-sdc-env-search-input").clear(); + } public static void editHeatParamValue(String paramName, String value) throws Exception { SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + paramName + " parameter on Heat Params modal screen"); @@ -298,7 +293,7 @@ public class DeploymentArtifactPage extends GeneralPageElements { public static void clickOnDeleteHeatParamValue(String paramName) throws Exception { SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + paramName + " parameter on Properties screen"); String value = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.EnvParameterView.ENV_CURRENT_VALUE.getValue() + paramName).getAttribute("value"); - if (value!=null) { + if (value != null) { GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPageEnum.DELETE_PARAMETER_OF_ARTIFACT.getValue() + paramName); GeneralUIUtils.ultimateWait(); SetupCDTest.getExtendTest().log(Status.INFO, "Value of " + paramName + " is deleted"); @@ -306,7 +301,7 @@ public class DeploymentArtifactPage extends GeneralPageElements { SetupCDTest.getExtendTest().log(Status.INFO, "Value of " + paramName + " is empty and cannot be deleted"); } - public static void clickOnHeatParam(String paramName)throws Exception { + public static void clickOnHeatParam(String paramName) throws Exception { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component in Properties", paramName)); GeneralUIUtils.clickOnElementByTestId(paramName); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentPage.java index 50fc80c0c3..dd3fdec6bc 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/DeploymentPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,202 +33,202 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class DeploymentPage { - - public DeploymentPage() { - super(); - } - - public static List getGroupMembersList(String instanceName) { - List propertyRows = null; - clickOnModuleName(instanceName); - propertyRows = getVisibleMembers(); - return propertyRows; - } - - public static void clickOnModuleName(String instanceName) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", instanceName)); - GeneralUIUtils.clickOnElementByText(instanceName); - GeneralUIUtils.ultimateWait(); - } - - public static List getVisibleMembers() { - List instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='hierarchy-module-member-list']")); - for (WebElement instance : instancesFromTable){ - Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); - if (!parentAttributes.toString().contains("hidden")){ - return instance.findElements(By.cssSelector("div[class^='expand-collapse-sub-title']")); - } - } - return null; - } - - public static void clickOnProperties() throws Exception{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Properties button")); - GeneralUIUtils.clickOnElementByCSS(DataTestIdEnum.DeploymentScreen.BUTTON_PROPERTIES.getValue()); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnArtifacts() throws Exception{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Artifacts button")); - GeneralUIUtils.clickOnElementByCSS(DataTestIdEnum.DeploymentScreen.BUTTON_ARTIFACTS.getValue()); - GeneralUIUtils.ultimateWait(); - } - - public static void clickOnSaveButton(){ - clickInDeployment(DataTestIdEnum.DeploymentScreen.SAVE); - GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("popover-inner")); - } - - public static void clickOnCancelButton(){ - clickInDeployment(DataTestIdEnum.DeploymentScreen.CANCEL); - GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("popover-inner")); - } - - public static void clickOnXIcon(){ - clickInDeployment(DataTestIdEnum.DeploymentScreen.X_BUTTON); - GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("popover-inner")); - } - - public static void clickOnEditIcon(){ - clickInDeployment(DataTestIdEnum.DeploymentScreen.PENCIL_ICON); - } - +public class DeploymentPage { + + public DeploymentPage() { + super(); + } + + public static List getGroupMembersList(String instanceName) { + List propertyRows = null; + clickOnModuleName(instanceName); + propertyRows = getVisibleMembers(); + return propertyRows; + } + + public static void clickOnModuleName(String instanceName) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", instanceName)); + GeneralUIUtils.clickOnElementByText(instanceName); + GeneralUIUtils.ultimateWait(); + } + + public static List getVisibleMembers() { + List instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='hierarchy-module-member-list']")); + for (WebElement instance : instancesFromTable) { + Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); + if (!parentAttributes.toString().contains("hidden")) { + return instance.findElements(By.cssSelector("div[class^='expand-collapse-sub-title']")); + } + } + return null; + } + + public static void clickOnProperties() throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Properties button")); + GeneralUIUtils.clickOnElementByCSS(DataTestIdEnum.DeploymentScreen.BUTTON_PROPERTIES.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public static void clickOnArtifacts() throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Artifacts button")); + GeneralUIUtils.clickOnElementByCSS(DataTestIdEnum.DeploymentScreen.BUTTON_ARTIFACTS.getValue()); + GeneralUIUtils.ultimateWait(); + } + + public static void clickOnSaveButton() { + clickInDeployment(DataTestIdEnum.DeploymentScreen.SAVE); + GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("popover-inner")); + } + + public static void clickOnCancelButton() { + clickInDeployment(DataTestIdEnum.DeploymentScreen.CANCEL); + GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("popover-inner")); + } + + public static void clickOnXIcon() { + clickInDeployment(DataTestIdEnum.DeploymentScreen.X_BUTTON); + GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("popover-inner")); + } + + public static void clickOnEditIcon() { + clickInDeployment(DataTestIdEnum.DeploymentScreen.PENCIL_ICON); + } + public static void clickOnProperty(WebElement property) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s propertie ...", property.getText())); - property.click(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue()); - } - - private static void clickInDeployment(DataTestIdEnum.DeploymentScreen element){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s ...", element.getValue())); - GeneralUIUtils.clickOnElementByTestId(element.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static List getPropertyNames() throws Exception{ - clickOnProperties(); - return GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.PROPERTY_NAMES.getValue()); - } - - public static List getArtifactNames() throws Exception{ - clickOnArtifacts(); - return GeneralUIUtils.getInputElements(DataTestIdEnum.DeploymentScreen.ARTIFACT_NAME.getValue()); - } - + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s propertie ...", property.getText())); + property.click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue()); + } + + private static void clickInDeployment(DataTestIdEnum.DeploymentScreen element) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s ...", element.getValue())); + GeneralUIUtils.clickOnElementByTestId(element.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static List getPropertyNames() throws Exception { + clickOnProperties(); + return GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.PROPERTY_NAMES.getValue()); + } + + public static List getArtifactNames() throws Exception { + clickOnArtifacts(); + return GeneralUIUtils.getInputElements(DataTestIdEnum.DeploymentScreen.ARTIFACT_NAME.getValue()); + } + public static String updateModuleName(String currentModuleName, String newModuleName) throws Exception { - GeneralUIUtils.ultimateWait(); - ResourceUIUtils.clickOnElementByText(currentModuleName, null); - GeneralUIUtils.ultimateWait(); - clickOnEditIcon(); - WebElement moduleNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.NAME_INPUT.getValue()); - String oldModuleName = moduleNameField.getAttribute("value"); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating %s module name ...", currentModuleName)); - moduleNameField.clear(); - GeneralUIUtils.ultimateWait(); - moduleNameField.sendKeys(newModuleName); - GeneralUIUtils.ultimateWait(); - clickOnSaveButton(); - String newReconstructedModuleName = reconstructModuleName(currentModuleName.split("\\.\\."), newModuleName); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Name of element instance changed from %s to %s", currentModuleName, newReconstructedModuleName)); - return oldModuleName; - } - - public static String reconstructModuleName(String[] splittedName, String middleName){ - int i = 0; - StringBuilder builder = new StringBuilder(); - for(String s : splittedName) { - if (i == 1){ - builder.append(middleName); - } else { - builder.append(s); - } - if (i < 2 ){ - builder.append(".."); - } - i++; - } - return builder.toString(); - } - + GeneralUIUtils.ultimateWait(); + ResourceUIUtils.clickOnElementByText(currentModuleName, null); + GeneralUIUtils.ultimateWait(); + clickOnEditIcon(); + WebElement moduleNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.NAME_INPUT.getValue()); + String oldModuleName = moduleNameField.getAttribute("value"); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating %s module name ...", currentModuleName)); + moduleNameField.clear(); + GeneralUIUtils.ultimateWait(); + moduleNameField.sendKeys(newModuleName); + GeneralUIUtils.ultimateWait(); + clickOnSaveButton(); + String newReconstructedModuleName = reconstructModuleName(currentModuleName.split("\\.\\."), newModuleName); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Name of element instance changed from %s to %s", currentModuleName, newReconstructedModuleName)); + return oldModuleName; + } + + public static String reconstructModuleName(String[] splittedName, String middleName) { + int i = 0; + StringBuilder builder = new StringBuilder(); + for (String s : splittedName) { + if (i == 1) { + builder.append(middleName); + } else { + builder.append(s); + } + if (i < 2) { + builder.append(".."); + } + i++; + } + return builder.toString(); + } + public static List getVisibleModulesService() { - List instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='hierarchy-modules-list']")); - for (WebElement instance : instancesFromTable){ - Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); - if (!parentAttributes.toString().contains("hidden")){ - return instance.findElements(By.cssSelector("span[class^='expand-collapse-title-text']")); - } - } - return null; - } - + List instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='hierarchy-modules-list']")); + for (WebElement instance : instancesFromTable) { + Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); + if (!parentAttributes.toString().contains("hidden")) { + return instance.findElements(By.cssSelector("span[class^='expand-collapse-title-text']")); + } + } + return null; + } + public static List getInstanceModulesList(String instanceName) { - List propertyRows = null; - ResourceUIUtils.clickOnElementByText(instanceName, null); - GeneralUIUtils.ultimateWait(); - propertyRows = getVisibleModulesService(); - return propertyRows; - } - - public static String getGroupVersion() throws Exception{ - return GeneralUIUtils.getElementsByCSS("div[data-tests-id='selected-module-version']").get(0).getText(); - } - - public static String getModuleID() throws Exception{ - return GeneralUIUtils.getElementsByCSS("div[data-tests-id='selected-module-group-uuid'] span[class^='small-font']").get(0).getText(); - } - - public static Map> collectMetaDataFromUI() throws Exception{ - ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen(); - Map> deploymentViewMetaData = new HashMap>(); - List moduleRowsFromTable = GeneralUIUtils.getElementsByCSS("span[class^='expand-collapse-title-text']"); - for(WebElement moduleRow :moduleRowsFromTable){ - HashMap tempGroupMap = new HashMap(); - String moduleRowText = moduleRow.getText(); - GeneralUIUtils.clickOnElementByText(moduleRowText); - tempGroupMap.put("moduleID", getModuleID()); - tempGroupMap.put("version", DeploymentPage.getGroupVersion().split(":")[1].trim()); - deploymentViewMetaData.put(moduleRowText.split("\\.\\.")[1], tempGroupMap); - GeneralUIUtils.clickOnElementByText(moduleRowText); - } - return deploymentViewMetaData; - } - - public static void updateAndCancel(String newModuleName, DataTestIdEnum.DeploymentScreen buttonToClick){ - WebElement moduleNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.NAME_INPUT.getValue()); - String oldModuleName = moduleNameField.getAttribute("value"); - moduleNameField.clear(); - GeneralUIUtils.ultimateWait(); - moduleNameField.sendKeys(newModuleName); - GeneralUIUtils.ultimateWait(); - if (buttonToClick.equals(DataTestIdEnum.DeploymentScreen.X_BUTTON)) - clickOnXIcon(); - else - clickOnCancelButton(); - } - - public static String getPropertyValueFromPropertiesList(String property) throws InterruptedException{ - List propertyDataElements = GeneralUIUtils.getElementsByCSS("div[class^='list-item property-data']"); - for(WebElement propertyDataElement: propertyDataElements){ - WebElement propertyNameElement = GeneralUIUtils.getElementfromElementByCSS(propertyDataElement, DeploymentScreen.PROPERTY_NAMES.getValue()); - if (propertyNameElement.getText().equals(property)){ - WebElement propertyValueElement = GeneralUIUtils.getElementfromElementByCSS(propertyDataElement, String.format("div[data-tests-id='%s']", DeploymentScreen.PROPERTY_SCHEMA_TYPE.getValue())); - return propertyValueElement.getText().trim().split(":")[1].trim(); - } - } - return null; - } - - public static List getPropertyErrorValidationMessdge() throws Exception{ - List propertyErrorElements = GeneralUIUtils.getElementsByCSS("div[class='input-error'] span[class='ng-scope']"); - return propertyErrorElements; - } - - public static boolean isPropertySaveButtonDisabled(){ - WebElement saveButtonElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.SAVE.getValue()); - return GeneralUIUtils.isElementDisabled(saveButtonElement); - } - - - + List propertyRows = null; + ResourceUIUtils.clickOnElementByText(instanceName, null); + GeneralUIUtils.ultimateWait(); + propertyRows = getVisibleModulesService(); + return propertyRows; + } + + public static String getGroupVersion() throws Exception { + return GeneralUIUtils.getElementsByCSS("div[data-tests-id='selected-module-version']").get(0).getText(); + } + + public static String getModuleID() throws Exception { + return GeneralUIUtils.getElementsByCSS("div[data-tests-id='selected-module-group-uuid'] span[class^='small-font']").get(0).getText(); + } + + public static Map> collectMetaDataFromUI() throws Exception { + ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen(); + Map> deploymentViewMetaData = new HashMap>(); + List moduleRowsFromTable = GeneralUIUtils.getElementsByCSS("span[class^='expand-collapse-title-text']"); + for (WebElement moduleRow : moduleRowsFromTable) { + HashMap tempGroupMap = new HashMap(); + String moduleRowText = moduleRow.getText(); + GeneralUIUtils.clickOnElementByText(moduleRowText); + tempGroupMap.put("moduleID", getModuleID()); + tempGroupMap.put("version", DeploymentPage.getGroupVersion().split(":")[1].trim()); + deploymentViewMetaData.put(moduleRowText.split("\\.\\.")[1], tempGroupMap); + GeneralUIUtils.clickOnElementByText(moduleRowText); + } + return deploymentViewMetaData; + } + + public static void updateAndCancel(String newModuleName, DataTestIdEnum.DeploymentScreen buttonToClick) { + WebElement moduleNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.NAME_INPUT.getValue()); + String oldModuleName = moduleNameField.getAttribute("value"); + moduleNameField.clear(); + GeneralUIUtils.ultimateWait(); + moduleNameField.sendKeys(newModuleName); + GeneralUIUtils.ultimateWait(); + if (buttonToClick.equals(DataTestIdEnum.DeploymentScreen.X_BUTTON)) { + clickOnXIcon(); + } else { + clickOnCancelButton(); + } + } + + public static String getPropertyValueFromPropertiesList(String property) throws InterruptedException { + List propertyDataElements = GeneralUIUtils.getElementsByCSS("div[class^='list-item property-data']"); + for (WebElement propertyDataElement : propertyDataElements) { + WebElement propertyNameElement = GeneralUIUtils.getElementfromElementByCSS(propertyDataElement, DeploymentScreen.PROPERTY_NAMES.getValue()); + if (propertyNameElement.getText().equals(property)) { + WebElement propertyValueElement = GeneralUIUtils.getElementfromElementByCSS(propertyDataElement, String.format("div[data-tests-id='%s']", DeploymentScreen.PROPERTY_SCHEMA_TYPE.getValue())); + return propertyValueElement.getText().trim().split(":")[1].trim(); + } + } + return null; + } + + public static List getPropertyErrorValidationMessdge() throws Exception { + List propertyErrorElements = GeneralUIUtils.getElementsByCSS("div[class='input-error'] span[class='ng-scope']"); + return propertyErrorElements; + } + + public static boolean isPropertySaveButtonDisabled() { + WebElement saveButtonElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.SAVE.getValue()); + return GeneralUIUtils.isElementDisabled(saveButtonElement); + } + + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GeneralPageElements.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GeneralPageElements.java index 97128945a0..d4051d772a 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GeneralPageElements.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GeneralPageElements.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,7 +36,10 @@ import java.util.function.Supplier; public class GeneralPageElements { - public GeneralPageElements() { + private static final int WAIT_FOR_ELEMENT_TIME_OUT = 60; + private static final int WAIT_FOR_ELEMENT_TIME_OUT_DIVIDER = 10; + + protected GeneralPageElements() { super(); } @@ -74,7 +77,7 @@ public class GeneralPageElements { clickCreateButton(); } - public static void clickCheckinButton(String componentName) throws Exception { + public static void clickCheckinButton(String componentName) { SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the CHECKIN button"); GeneralUIUtils.ultimateWait(); GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); @@ -85,13 +88,13 @@ public class GeneralPageElements { GeneralUIUtils.ultimateWait(); } - public static void clickSubmitForTestingButton(String componentName) throws Exception { + public static void clickSubmitForTestingButton(String componentName) { SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on the submitting for testing button"); GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.SUBMIT_FOR_TESTING_BUTTON.getValue()); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.SUMBIT_FOR_TESTING_MESSAGE.getValue()).sendKeys("Submit for testing " + componentName); GeneralUIUtils.ultimateWait(); clickOKButton(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue(), 60); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue(), WAIT_FOR_ELEMENT_TIME_OUT); GeneralUIUtils.ultimateWait(); } @@ -116,7 +119,7 @@ public class GeneralPageElements { clickRestoreButton(componentName); } - private static void clickRestoreButton(String componentName){ + private static void clickRestoreButton(String componentName) { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Going to restore component: %s", componentName)); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.RESTORE_BUTTON.getValue()); } @@ -131,7 +134,7 @@ public class GeneralPageElements { clickArchiveButton(componentName); } - private static void clickArchiveButton(String componentName){ + private static void clickArchiveButton(String componentName) { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Going to archive component: %s", componentName)); GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.GeneralElementsEnum.ARCHIVE_BUTTON.getValue()); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.ARCHIVE_BUTTON.getValue()); @@ -149,7 +152,7 @@ public class GeneralPageElements { clickUpgradeServicesCloseButton(); GeneralUIUtils.ultimateWait(); HomePage.navigateToHomePage(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue(), GeneralUIUtils.getTimeOut()/10); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue(), GeneralUIUtils.getTimeOut() / WAIT_FOR_ELEMENT_TIME_OUT_DIVIDER); } catch (Exception e) { throw new Exception("Certification of " + componentName + " failed"); } @@ -180,14 +183,14 @@ public class GeneralPageElements { } } - public static void clickUpgradeServicesCloseButton(){ + public static void clickUpgradeServicesCloseButton() { WebElement closeButton = null; try { - closeButton = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.UPGRADE_SERVICES_CANCEL.getValue(), GeneralUIUtils.getTimeOut()/10); + closeButton = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.UPGRADE_SERVICES_CANCEL.getValue(), GeneralUIUtils.getTimeOut() / WAIT_FOR_ELEMENT_TIME_OUT_DIVIDER); UpgradeServicesPopup.setUpgradePopupShown(true); SetupCDTest.getExtendTest().log(Status.INFO, "Closing Update Services popup with X button ..."); closeButton.click(); - }catch (WebDriverException e){ + } catch (WebDriverException e) { // regular flow UpgradeServicesPopup.setUpgradePopupShown(false); SetupCDTest.getExtendTest().log(Status.INFO, "Update Services popup is not shown, continuing ..."); @@ -201,8 +204,6 @@ public class GeneralPageElements { } - - public static void clickDeleteVersionButton() throws Exception { SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on DELETE VERSION button ..."); GeneralUIUtils.ultimateWait(); @@ -242,9 +243,9 @@ public class GeneralPageElements { SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on TRASH button ..."); GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.DELETE_VERSION_BUTTON.getValue()); clickOKButton(); - } + } - public static void clickBrowseButton() throws InterruptedException{ + public static void clickBrowseButton() throws InterruptedException { SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Browse button ..."); GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.ModalItems.BROWSE_BUTTON.getValue()); } @@ -257,13 +258,12 @@ public class GeneralPageElements { public static void clickDeleteFile() throws Exception { SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on delete file X-button ..."); - GeneralUIUtils.clickOnAreaJS(GeneralUIUtils.getWebElementBy - (By.cssSelector("div[class='i-sdc-form-file-upload-x-btn']"))); + GeneralUIUtils.clickOnAreaJS(GeneralUIUtils.getWebElementBy(By.cssSelector("div[class='i-sdc-form-file-upload-x-btn']"))); GeneralUIUtils.ultimateWait(); } - public static void clickOnHomeButton() { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - } + public static void clickOnHomeButton() { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GovernorOperationPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GovernorOperationPage.java index f37d8f7bc0..72f5bc72eb 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GovernorOperationPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/GovernorOperationPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,18 +27,18 @@ import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; public class GovernorOperationPage { - public GovernorOperationPage() { - super(); - } + private GovernorOperationPage() { + super(); + } - public static void approveSerivce(String serviceName) { - SetupCDTest.getExtendTest().log(Status.INFO, "Approving the distrbution of the service " + serviceName); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.APPROVE.getValue()).click(); - GeneralUIUtils.waitForLoader(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.APPROVE_MESSAGE.getValue()) - .sendKeys("service " + serviceName + " tested successfully"); - GeneralPageElements.clickOKButton(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()); - } + public static void approveSerivce(String serviceName) { + SetupCDTest.getExtendTest().log(Status.INFO, "Approving the distrbution of the service " + serviceName); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.APPROVE.getValue()).click(); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.APPROVE_MESSAGE.getValue()) + .sendKeys("service " + serviceName + " tested successfully"); + GeneralPageElements.clickOKButton(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HeatParamNameBuilder.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HeatParamNameBuilder.java index d8cc274868..a54dc434da 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HeatParamNameBuilder.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HeatParamNameBuilder.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,12 +26,13 @@ public class HeatParamNameBuilder { private static final String CURRENT_VAL = DataTestIdEnum.EnvParameterView.ENV_CURRENT_VALUE.getValue(); private static final String DEFAULT_VAL = DataTestIdEnum.EnvParameterView.ENV_DEFAULT_VALUE.getValue(); + private HeatParamNameBuilder() {} - public static String buildCurrentHeatParamValue(String paramName){ + public static String buildCurrentHeatParamValue(String paramName) { return new StringBuilder().append(CURRENT_VAL).append(paramName).toString(); } - public static String buildDefaultHeatParamValue(String paramName){ + public static String buildDefaultHeatParamValue(String paramName) { return new StringBuilder().append(DEFAULT_VAL).append(paramName).toString(); } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HomePage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HomePage.java index e8d1049aad..d6485fd5c2 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HomePage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/HomePage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,77 +34,76 @@ import java.util.List; public class HomePage extends GeneralPageElements { - public HomePage() { - super(); - } - - public static void showVspRepository(){ - GeneralUIUtils.waitForElementInVisibilityBy(By.className("ui-notification"), 30); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.MainMenuButtons.REPOSITORY_ICON.getValue()); - } - - public static boolean searchForVSP(String vspName){ - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ImportVfRepository.SEARCH.getValue()).sendKeys(vspName); - GeneralUIUtils.ultimateWait(); -// return checkElementsCountInTable(2); - return true; - } - - public static void importVSP(String vspName){ - HomePage.showVspRepository(); - boolean vspFound = HomePage.searchForVSP(vspName); - if (vspFound){ - List elemenetsFromTable = getElemenetsFromTable(); -// GeneralUIUtils.waitForLoader(); - WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 30); - WebElement findElement = wait.until(ExpectedConditions.visibilityOf(elemenetsFromTable.get(1))); - findElement.click(); - GeneralUIUtils.waitForLoader(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.IMPORT_VSP.getValue()); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); - GeneralUIUtils.waitForLoader(60*10); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); - } - } - - - public static boolean navigateToHomePage() { - try{ - System.out.println("Searching for reporsitory icon."); - WebElement repositoryIcon = GeneralUIUtils.getInputElement("repository-icon"); - if (repositoryIcon != null){ - return true; - } - else{ - GeneralUIUtils.ultimateWait(); - List homeButtons = GeneralUIUtils.getElemenetsFromTable(By.xpath("//a[contains(.,'HOME')]")); - if (homeButtons.size() != 0){ - for (WebElement home : homeButtons){ - if (home.isDisplayed()){ - home.click(); - System.out.println("Clicked on home button"); - break; - } - } - GeneralUIUtils.closeErrorMessage(); - WebElement homeButton = GeneralUIUtils.getInputElement(DataTestIdEnum.MainMenuButtons.HOME_BUTTON.getValue()); - return homeButton.isDisplayed(); - } - - } - } - catch(Exception innerException){ - System.out.println("Can't click on home button."); - return false; - } - return false; - } + private static final int WAIT_FOR_ELEMENT_TIME_OUT = 30; + private static final int WAIT_FOR_LOADER_TIME_OUT = 600; + + public HomePage() { + super(); + } + + public static void showVspRepository() { + GeneralUIUtils.waitForElementInVisibilityBy(By.className("ui-notification"), WAIT_FOR_ELEMENT_TIME_OUT); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.MainMenuButtons.REPOSITORY_ICON.getValue()); + } + + public static boolean searchForVSP(String vspName) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ImportVfRepository.SEARCH.getValue()).sendKeys(vspName); + GeneralUIUtils.ultimateWait(); + return true; + } + + public static void importVSP(String vspName) { + HomePage.showVspRepository(); + boolean vspFound = HomePage.searchForVSP(vspName); + if (vspFound) { + List elemenetsFromTable = getElemenetsFromTable(); + WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), WAIT_FOR_ELEMENT_TIME_OUT); + WebElement findElement = wait.until(ExpectedConditions.visibilityOf(elemenetsFromTable.get(1))); + findElement.click(); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.IMPORT_VSP.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(WAIT_FOR_LOADER_TIME_OUT); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); + } + } + + + public static boolean navigateToHomePage() { + try { + System.out.println("Searching for reporsitory icon."); + WebElement repositoryIcon = GeneralUIUtils.getInputElement("repository-icon"); + if (repositoryIcon != null) { + return true; + } else { + GeneralUIUtils.ultimateWait(); + List homeButtons = GeneralUIUtils.getElemenetsFromTable(By.xpath("//a[contains(.,'HOME')]")); + if (homeButtons.size() != 0) { + for (WebElement home : homeButtons) { + if (home.isDisplayed()) { + home.click(); + System.out.println("Clicked on home button"); + break; + } + } + GeneralUIUtils.closeErrorMessage(); + WebElement homeButton = GeneralUIUtils.getInputElement(DataTestIdEnum.MainMenuButtons.HOME_BUTTON.getValue()); + return homeButton.isDisplayed(); + } + + } + } catch (Exception innerException) { + System.out.println("Can't click on home button."); + return false; + } + return false; + } + + public static File downloadVspCsarToDefaultDirectory(String vspName) throws Exception { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + DownloadManager.downloadCsarByNameFromVSPRepository(vspName, ""); + File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); + return latestFilefromDir; + } - public static File downloadVspCsarToDefaultDirectory(String vspName) throws Exception { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); - DownloadManager.downloadCsarByNameFromVSPRepository(vspName, ""); - File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); - return latestFilefromDir; - } - } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/IconPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/IconPage.java index fd9befa148..82200e0e54 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/IconPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/IconPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,26 +26,26 @@ import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; public class IconPage extends GeneralPageElements { - public IconPage() { - super(); - } + private IconPage() { + super(); + } - public static void clickOnIcon(ResourceCategoryEnum iconName) { - GeneralUIUtils.getWebElementByTestID(iconStringBuilder(iconName) + DataTestIdEnum.ServiceMetadataEnum.ICON.getValue()) - .click(); - } + public static void clickOnIcon(ResourceCategoryEnum iconName) { + GeneralUIUtils.getWebElementByTestID(iconStringBuilder(iconName) + DataTestIdEnum.ServiceMetadataEnum.ICON.getValue()) + .click(); + } - private static String iconStringBuilder(ResourceCategoryEnum icon) { - String iconName = icon.getSubCategory(); - String[] splitedIconName = iconName.split(" "); - splitedIconName[0] = splitedIconName[0].toLowerCase(); + private static String iconStringBuilder(ResourceCategoryEnum icon) { + String iconName = icon.getSubCategory(); + String[] splitedIconName = iconName.split(" "); + splitedIconName[0] = splitedIconName[0].toLowerCase(); - StringBuilder sb = new StringBuilder(); - for (String word : splitedIconName) { - sb.append(word); - } + StringBuilder sb = new StringBuilder(); + for (String word : splitedIconName) { + sb.append(word); + } - return sb.toString(); - } + return sb.toString(); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InformationalArtifactPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InformationalArtifactPage.java index be551af8e2..8dcc8908aa 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InformationalArtifactPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InformationalArtifactPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,43 +31,42 @@ import java.util.List; public class InformationalArtifactPage extends DeploymentArtifactPage { - public InformationalArtifactPage() { - super(); - } + private InformationalArtifactPage() { + super(); + } - public static void clickAddNewArtifact() { - addNewArtifact(ArtifactGroupTypeEnum.INFORMATIONAL); - } + public static void clickAddNewArtifact() { + addNewArtifact(ArtifactGroupTypeEnum.INFORMATIONAL); + } - public static String getArtifactDescription(String artifactLabel) throws Exception { - InformationalArtifactPage.clickOnArtifact(artifactLabel); - String artifactDesc = GeneralUIUtils.getWebElementByTestID( - artifactLabel + DataTestIdEnum.ArtifactPageEnum.GET_INFORMATIONAL_ARTIFACT_DESCRIPTION.getValue()) - .getText(); - InformationalArtifactPage.clickOnArtifact(artifactLabel); // close artifact - return artifactDesc; - } + public static String getArtifactDescription(String artifactLabel) throws Exception { + InformationalArtifactPage.clickOnArtifact(artifactLabel); + String artifactDesc = GeneralUIUtils.getWebElementByTestID( + artifactLabel + DataTestIdEnum.ArtifactPageEnum.GET_INFORMATIONAL_ARTIFACT_DESCRIPTION.getValue()) + .getText(); + InformationalArtifactPage.clickOnArtifact(artifactLabel); // close artifact + return artifactDesc; + } - public static List getElemenetsFromTable() { - return GeneralUIUtils.getWebElementsListByTestID("InformationalArtifactRow"); - } - - public static WebElement clickOnArtifact(String artifactLabel) throws Exception { - try{ - WebElement artifact = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.ARTIFACT_NAME.getValue() + artifactLabel); - artifact.click(); - GeneralUIUtils.waitForLoader(); - return artifact; - } - catch(Exception e){ - throw new Exception("Artifact " + artifactLabel + "is not found"); - } - } - - - public static void clickDeleteArtifact(String artifactLabel) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Deleting %s Artefact ",artifactLabel)); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DELETE_ARTIFACT.getValue() + artifactLabel).click(); - } + public static List getElemenetsFromTable() { + return GeneralUIUtils.getWebElementsListByTestID("InformationalArtifactRow"); + } + + public static WebElement clickOnArtifact(String artifactLabel) throws Exception { + try { + WebElement artifact = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.ARTIFACT_NAME.getValue() + artifactLabel); + artifact.click(); + GeneralUIUtils.waitForLoader(); + return artifact; + } catch (Exception e) { + throw new Exception("Artifact " + artifactLabel + "is not found"); + } + } + + + public static void clickDeleteArtifact(String artifactLabel) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Deleting %s Artefact ", artifactLabel)); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.DELETE_ARTIFACT.getValue() + artifactLabel).click(); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InputsPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InputsPage.java index d015816192..ee8d77e309 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InputsPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/InputsPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,124 +34,118 @@ import java.util.stream.Collectors; public class InputsPage extends GeneralPageElements { - public InputsPage() { - super(); - - } - - public static List getInstancePropertiesList(String instanceName) { - List propertyRows = null; - GeneralUIUtils.clickOnElementByText(instanceName); - GeneralUIUtils.ultimateWait(); - propertyRows = getVisibleProperites(); - return propertyRows; - } - - public static List getVisibleProperites() { - List instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='vf-instance-list']")); - for (WebElement instance : instancesFromTable){ - Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); - if (!parentAttributes.toString().contains("hidden")){ - return instance.findElements(By.className("property-row")); - } - } - return null; - } - - public static void addInputToService(String VFInstanceName, String propertyName) throws Exception{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding property %s from VF instance %s to Service", propertyName, VFInstanceName)); - List instaceInputs = getInstanceInputsList(VFInstanceName); - for(WebElement instancInput: instaceInputs){ - String actualPropertyName = instancInput.findElement(By.className("title-text")).getText(); - if (actualPropertyName.equals(propertyName) && clickOnVFInputCheckbox(instancInput)){ - clickOnAddInputButton(); - } - } - } + private InputsPage() { + super(); + } + + public static List getInstancePropertiesList(String instanceName) { + List propertyRows = null; + GeneralUIUtils.clickOnElementByText(instanceName); + GeneralUIUtils.ultimateWait(); + propertyRows = getVisibleProperites(); + return propertyRows; + } + + static List getVisibleProperites() { + List instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='vf-instance-list']")); + for (WebElement instance : instancesFromTable) { + Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); + if (!parentAttributes.toString().contains("hidden")) { + return instance.findElements(By.className("property-row")); + } + } + return null; + } + + public static void addInputToService(String VFInstanceName, String propertyName) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding property %s from VF instance %s to Service", propertyName, VFInstanceName)); + List instaceInputs = getInstanceInputsList(VFInstanceName); + for (WebElement instancInput : instaceInputs) { + String actualPropertyName = instancInput.findElement(By.className("title-text")).getText(); + if (actualPropertyName.equals(propertyName) && clickOnVFInputCheckbox(instancInput)) { + clickOnAddInputButton(); + } + } + } public static List getInstanceInputsList(String instanceName) { - List inputRows = null; - GeneralUIUtils.clickOnElementByText(instanceName); - GeneralUIUtils.ultimateWait(); - inputRows = getVisibleInputs(inputRows); - return inputRows; + List inputRows = null; + GeneralUIUtils.clickOnElementByText(instanceName); + GeneralUIUtils.ultimateWait(); + inputRows = getVisibleInputs(inputRows); + return inputRows; + } + + public static List getVisibleInputs(List inputRows) { + List instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='vf-instance-list']")); + for (WebElement instance : instancesFromTable) { + Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); + if (!parentAttributes.toString().contains("hidden")) { + inputRows = instance.findElements(By.className("input-row")); + break; + } + } + return inputRows; + } + + public static void clickOnAddInputButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Add Input aka Greater than symbol button")); + GeneralUIUtils.clickOnElementByTestId(InputsScreenService.ADD_SELECTED_INPUTS_BTN.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static boolean clickOnVFInputCheckbox(WebElement instancInput) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on VF instance input checkbox")); + instancInput.findElement(By.className("tlv-checkbox-label")).click(); + GeneralUIUtils.ultimateWait(); + return instancInput.findElement(By.className("tlv-checkbox-i")).getAttribute("class").contains("ng-not-empty"); + } + + public static WebElement getServiceInput(String VFInstanceName, String propertyName) throws Exception { + String expectedInputName = String.format("%s_%s", VFInstanceName.replace(" ", "").toLowerCase(), propertyName); + List inputsFromTable = GeneralUIUtils.getElementsByCSS(InputsScreenService.SERVICE_INPUT_ROW.getValue()); + for (WebElement inputFromTable : inputsFromTable) { + String actualInputName = inputFromTable.findElement(By.className("title-text")).getText(); + if (actualInputName.equals(expectedInputName)) { + return inputFromTable; + } + } + throw new TestException(String.format("%s input don't exist", expectedInputName)); + } + + public static void deleteServiceInput(String VFInstanceName, String propertyName) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Deleting property %s in VF instance %s ", propertyName, VFInstanceName)); + WebElement serviceInput = getServiceInput(VFInstanceName, propertyName); + serviceInput.findElement(By.cssSelector(InputsScreenService.DELETE_INPUT_BTN.getValue())).click(); + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on OK button ")); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.OK.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static List getVFCInstancesNamesFromTable() throws Exception { + WebElement inputsTable = getInputsTable("VFC "); + return inputsTable.findElements(By.cssSelector("span[class^='title-text']")).stream(). + map(e -> e.getText()). + collect(Collectors.toList()); + } + + public static WebElement getInputsTable(String tableName) throws Exception { + List tableElements = GeneralUIUtils.getElementsByCSS("div.table"); + for (WebElement tableElement : tableElements) { + String tableTitle = GeneralUIUtils.getElementfromElementByCSS(tableElement, "div.table-header").getText(); + if (tableTitle.contains(tableName)) { + return tableElement; + } + } + throw new TestException(String.format("Can't find %s table", tableName)); } - - public static List getVisibleInputs(List inputRows) { - List instancesFromTable = GeneralUIUtils.getDriver().findElements(By.cssSelector("div[class^='vf-instance-list']")); - for (WebElement instance : instancesFromTable){ - Object parentAttributes = GeneralUIUtils.getAllElementAttributes(instance); - if (!parentAttributes.toString().contains("hidden")){ - inputRows = instance.findElements(By.className("input-row")); - break; - } - } - return inputRows; - } - - public static void clickOnAddInputButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Add Input aka Greater than symbol button")); - GeneralUIUtils.clickOnElementByTestId(InputsScreenService.ADD_SELECTED_INPUTS_BTN.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static boolean clickOnVFInputCheckbox(WebElement instancInput){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on VF instance input checkbox")); - instancInput.findElement(By.className("tlv-checkbox-label")).click(); - GeneralUIUtils.ultimateWait(); - return instancInput.findElement(By.className("tlv-checkbox-i")).getAttribute("class").contains("ng-not-empty"); - } - - public static WebElement getServiceInput(String VFInstanceName, String propertyName) throws Exception{ - String expectedInputName = String.format("%s_%s", VFInstanceName.replace(" ", "").toLowerCase(), propertyName); - List inputsFromTable = GeneralUIUtils.getElementsByCSS(InputsScreenService.SERVICE_INPUT_ROW.getValue()); - for(WebElement inputFromTable: inputsFromTable){ - String actualInputName = inputFromTable.findElement(By.className("title-text")).getText(); - if(actualInputName.equals(expectedInputName)){ - return inputFromTable; - } - } - throw new TestException(String.format("%s input don't exist", expectedInputName)); - } - - public static void deleteServiceInput(String VFInstanceName, String propertyName) throws Exception{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Deleting property %s in VF instance %s ", propertyName, VFInstanceName)); - WebElement serviceInput = getServiceInput(VFInstanceName, propertyName); - serviceInput.findElement(By.cssSelector(InputsScreenService.DELETE_INPUT_BTN.getValue())).click(); - GeneralUIUtils.ultimateWait(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on OK button ")); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.OK.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static List getVFCInstancesNamesFromTable() throws Exception{ - WebElement inputsTable = getInputsTable("VFC "); - return inputsTable.findElements(By.cssSelector("span[class^='title-text']")).stream(). - map(e -> e.getText()). - collect(Collectors.toList()); - } - - public static WebElement getInputsTable(String tableName) throws Exception{ - List tableElements = GeneralUIUtils.getElementsByCSS("div.table"); - for(WebElement tableElement: tableElements){ - String tableTitle = GeneralUIUtils.getElementfromElementByCSS(tableElement, "div.table-header").getText(); - if (tableTitle.contains(tableName)){ - return tableElement; - } - } - throw new TestException(String.format("Can't find %s table", tableName)); - } - - public static void clickOnProperty(String propertyName) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on property %s ", propertyName)); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_NAME.getValue() + propertyName); -// GeneralUIUtils.ultimateWait(); - } - - - - - - + + public static void clickOnProperty(String propertyName) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on property %s ", propertyName)); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_NAME.getValue() + propertyName); + //GeneralUIUtils.ultimateWait(); + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/OpsOperationPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/OpsOperationPage.java index 6069c9c30c..630ffe419e 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/OpsOperationPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/OpsOperationPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,122 +34,127 @@ import java.util.List; public class OpsOperationPage { - public OpsOperationPage() { - super(); - } - - public static void distributeService() { - SetupCDTest.getExtendTest().log(Status.INFO, "Distributing"); - clickOnButton(DataTestIdEnum.DistributionChangeButtons.DISTRIBUTE); - GeneralUIUtils.waitForLoader(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.MONITOR.getValue()); - } - - public static void displayMonitor() { - GeneralUIUtils.moveToStep(StepsEnum.MONITOR); - } - - public static void re_distributeService() { - SetupCDTest.getExtendTest().log(Status.INFO, "Redistributing..."); - clickOnButton(DataTestIdEnum.DistributionChangeButtons.RE_DISTRIBUTE); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.MONITOR.getValue()); - } - - private static void clickOnButton(DataTestIdEnum.DistributionChangeButtons button) { - GeneralUIUtils.getWebElementByTestID(button.getValue()).click(); - GeneralUIUtils.waitForLoader(); - } - - public static List getRowsFromMonitorTable() { - SetupCDTest.getExtendTest().log(Status.INFO, "Counting the rows from the distribution table"); - GeneralPageElements.checkElementsCountInTable(1, () -> GeneralUIUtils.getWebElementsListByTestID("ditributionTable")); - List distributionRecords = GeneralUIUtils.getWebElementsListByTestID("ditributionTable"); - List findElements = distributionRecords.get(0).findElements(By.className("w-sdc-distribute-parent-block")); - return findElements; - } - - public static void showDistributionStatus(int rowIndex) { - GeneralUIUtils.getWebElementByTestID("ShowRecordButton_" + String.valueOf(rowIndex)).click(); - GeneralUIUtils.waitForLoader(); - } - - public static String getTotalArtifactsSum(int rowIndex) { - return GeneralUIUtils.getWebElementByTestID("totalArtifacts_" + String.valueOf(rowIndex)).getText(); - } - - public static String getNotifiedArtifactsSum(int rowIndex) { - return GeneralUIUtils.getWebElementByTestID("notified_" + String.valueOf(rowIndex)).getText(); - } - - public static String getDownloadedArtifactsSum(int rowIndex) { - return GeneralUIUtils.getWebElementByTestID("downloaded_" + String.valueOf(rowIndex)).getText(); - } - - public static String getDeployedArtifactsSum(int rowIndex) { - return GeneralUIUtils.getWebElementByTestID("deployed_" + String.valueOf(rowIndex)).getText(); - } - - public static String getNotNotifiedArtifactsSum(int rowIndex) { - return GeneralUIUtils.getWebElementByTestID("NotNotified_" + String.valueOf(rowIndex)).getText(); - } - - public static String getErrorsSum(int rowIndex) { - return GeneralUIUtils.getWebElementByTestID("errors_" + String.valueOf(rowIndex)).getText(); - } - - public static void clickRefreshTableButton(int rowIndex) { - GeneralUIUtils.getWebElementByTestID("refreshButton").click(); - // wait until total artifacts field disappear - WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 90); - wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + "totalArtifacts_" + String.valueOf(rowIndex) + "']"))); - } - - public static void waitUntilArtifactsDistributed(int rowIndex) throws Exception { - waitUntilArtifactsDistributed("0", 0); - } - - public static void waitUntilArtifactsDistributed(String expectedArtifactsSum, int rowIndex) throws Exception { - SetupCDTest.getExtendTest().log(Status.INFO, "Waiting until all artifacts are distributed"); - boolean isKeepWaiting = true; - int maxWaitingPeriodMS = 5 * 60 * 1000; - int sumWaitingTime = 0; - int napPeriod = 10000; - while (isKeepWaiting) { - showDistributionStatus(rowIndex); - String actualTotalArtifactsSize = getTotalArtifactsSum(rowIndex); - String actualNotifiedArtifactsSize = getNotifiedArtifactsSum(rowIndex); - String actualDownloadedArtifactsSize = getDownloadedArtifactsSum(rowIndex); - String actualDeployedArtifactsSize = getDeployedArtifactsSum(rowIndex); - String actualNotNotifedArtifactsSize = getNotNotifiedArtifactsSum(rowIndex); - isKeepWaiting = !actualTotalArtifactsSize.equals(actualDownloadedArtifactsSize) - || !actualTotalArtifactsSize.equals(actualNotifiedArtifactsSize) - || !actualTotalArtifactsSize.equals(actualDeployedArtifactsSize) - || actualTotalArtifactsSize.equals("0") || actualDownloadedArtifactsSize.equals("0") - || actualNotifiedArtifactsSize.equals("0") || actualDeployedArtifactsSize.equals("0"); - - if (isKeepWaiting) { - - if (Integer.parseInt(actualNotNotifedArtifactsSize) > 1) { - SetupCDTest.getExtendTest().log(Status.INFO, "Some artifacts are not notified"); - isKeepWaiting = false; - throw new Exception("Some artifacts are not notified..."); - } - - GeneralUIUtils.sleep(napPeriod); - sumWaitingTime += napPeriod; - - if (sumWaitingTime > maxWaitingPeriodMS) { - SetupCDTest.getExtendTest().log(Status.INFO, "Not all artifacts are displayed"); - isKeepWaiting = false; - throw new Exception(String.format("Not all artifacts are displayed withing %s seconds", - String.valueOf(maxWaitingPeriodMS / 1000))); - } - - clickRefreshTableButton(rowIndex); - } - } - - SetupCDTest.getExtendTest().log(Status.INFO, "All artifacts were successfully distributed"); - } + private static final int WEB_DRIVER_TIME_OUT = 90; + private static final int MAX_WAITING_PERIOD_MS = 5 * 60 * 1000; + private static final int NAP_PERIOD = 10000; + private static final int MAX_WAITING_PERIOF_DIVIDER = 1000; + + private OpsOperationPage() { + super(); + } + + public static void distributeService() { + SetupCDTest.getExtendTest().log(Status.INFO, "Distributing"); + clickOnButton(DataTestIdEnum.DistributionChangeButtons.DISTRIBUTE); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.MONITOR.getValue()); + } + + public static void displayMonitor() { + GeneralUIUtils.moveToStep(StepsEnum.MONITOR); + } + + public static void reDistributeService() { + SetupCDTest.getExtendTest().log(Status.INFO, "Redistributing..."); + clickOnButton(DataTestIdEnum.DistributionChangeButtons.RE_DISTRIBUTE); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DistributionChangeButtons.MONITOR.getValue()); + } + + private static void clickOnButton(DataTestIdEnum.DistributionChangeButtons button) { + GeneralUIUtils.getWebElementByTestID(button.getValue()).click(); + GeneralUIUtils.waitForLoader(); + } + + public static List getRowsFromMonitorTable() { + SetupCDTest.getExtendTest().log(Status.INFO, "Counting the rows from the distribution table"); + GeneralPageElements.checkElementsCountInTable(1, () -> GeneralUIUtils.getWebElementsListByTestID("ditributionTable")); + List distributionRecords = GeneralUIUtils.getWebElementsListByTestID("ditributionTable"); + List findElements = distributionRecords.get(0).findElements(By.className("w-sdc-distribute-parent-block")); + return findElements; + } + + public static void showDistributionStatus(int rowIndex) { + GeneralUIUtils.getWebElementByTestID("ShowRecordButton_" + String.valueOf(rowIndex)).click(); + GeneralUIUtils.waitForLoader(); + } + + public static String getTotalArtifactsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("totalArtifacts_" + String.valueOf(rowIndex)).getText(); + } + + public static String getNotifiedArtifactsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("notified_" + String.valueOf(rowIndex)).getText(); + } + + public static String getDownloadedArtifactsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("downloaded_" + String.valueOf(rowIndex)).getText(); + } + + public static String getDeployedArtifactsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("deployed_" + String.valueOf(rowIndex)).getText(); + } + + public static String getNotNotifiedArtifactsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("NotNotified_" + String.valueOf(rowIndex)).getText(); + } + + public static String getErrorsSum(int rowIndex) { + return GeneralUIUtils.getWebElementByTestID("errors_" + String.valueOf(rowIndex)).getText(); + } + + public static void clickRefreshTableButton(int rowIndex) { + GeneralUIUtils.getWebElementByTestID("refreshButton").click(); + // wait until total artifacts field disappear + WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), WEB_DRIVER_TIME_OUT); + wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + "totalArtifacts_" + String.valueOf(rowIndex) + "']"))); + } + + public static void waitUntilArtifactsDistributed(int rowIndex) throws Exception { + waitUntilArtifactsDistributed("0", 0); + } + + public static void waitUntilArtifactsDistributed(String expectedArtifactsSum, int rowIndex) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Waiting until all artifacts are distributed"); + boolean isKeepWaiting = true; + int maxWaitingPeriodMS = MAX_WAITING_PERIOD_MS; + int sumWaitingTime = 0; + int napPeriod = NAP_PERIOD; + while (isKeepWaiting) { + showDistributionStatus(rowIndex); + String actualTotalArtifactsSize = getTotalArtifactsSum(rowIndex); + String actualNotifiedArtifactsSize = getNotifiedArtifactsSum(rowIndex); + String actualDownloadedArtifactsSize = getDownloadedArtifactsSum(rowIndex); + String actualDeployedArtifactsSize = getDeployedArtifactsSum(rowIndex); + String actualNotNotifedArtifactsSize = getNotNotifiedArtifactsSum(rowIndex); + isKeepWaiting = !actualTotalArtifactsSize.equals(actualDownloadedArtifactsSize) + || !actualTotalArtifactsSize.equals(actualNotifiedArtifactsSize) + || !actualTotalArtifactsSize.equals(actualDeployedArtifactsSize) + || actualTotalArtifactsSize.equals("0") || actualDownloadedArtifactsSize.equals("0") + || actualNotifiedArtifactsSize.equals("0") || actualDeployedArtifactsSize.equals("0"); + + if (isKeepWaiting) { + + if (Integer.parseInt(actualNotNotifedArtifactsSize) > 1) { + SetupCDTest.getExtendTest().log(Status.INFO, "Some artifacts are not notified"); + isKeepWaiting = false; + throw new Exception("Some artifacts are not notified..."); + } + + GeneralUIUtils.sleep(napPeriod); + sumWaitingTime += napPeriod; + + if (sumWaitingTime > maxWaitingPeriodMS) { + SetupCDTest.getExtendTest().log(Status.INFO, "Not all artifacts are displayed"); + isKeepWaiting = false; + throw new Exception(String.format("Not all artifacts are displayed withing %s seconds", + String.valueOf(maxWaitingPeriodMS / MAX_WAITING_PERIOF_DIVIDER))); + } + + clickRefreshTableButton(rowIndex); + } + } + + SetupCDTest.getExtendTest().log(Status.INFO, "All artifacts were successfully distributed"); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductGeneralPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductGeneralPage.java index 486d78a694..c1f12427cd 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductGeneralPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductGeneralPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,87 +32,86 @@ import java.util.ArrayList; /** * @author al714h - * */ public class ProductGeneralPage extends ResourceGeneralPage { - public ProductGeneralPage() { - super(); - } - - public static ProductLeftMenu getProductLeftMenu() { + private ProductGeneralPage() { + super(); + } + + public static ProductLeftMenu getProductLeftMenu() { return new ProductLeftMenu(); } - public static void defineName(String productName) { - WebElement productNameTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PRODUCT_NAME.getValue()); - productNameTextbox.clear(); - productNameTextbox.sendKeys(productName); - } - - public static void defineFullName(String productFullName) { - WebElement productFullNameTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.FULL_NAME.getValue()); - productFullNameTextbox.clear(); - productFullNameTextbox.sendKeys(productFullName); - } - - public static void defineProjectCode(String pmat) { - WebElement pmattTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PROJECT_CODE.getValue()); - pmattTextbox.clear(); - pmattTextbox.sendKeys(pmat); - } - - public static String getPmattText(){ - return getPmattField().getAttribute("value"); - } - - public static String[] getTags(){ - return ResourceGeneralPage.getElementsFromTagsTable().stream().map(WebElement::getText).toArray(String[]::new); - } - - private static WebElement getPmattField() { - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PROJECT_CODE.getValue()); - } - - public static void deleteOldTags(ProductReqDetails product){ - // Delete tag elements - int i = GeneralUIUtils.getWebElementsListByTestID("i-sdc-tag-delete").size(); - while (i > 0){ - GeneralUIUtils.getWebElementByTestID("i-sdc-tag-delete").click(); - i--; - } - - product.setTags(new ArrayList()); - } - - public static void clickAddWorkflow (){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding workflow...")); - GeneralUIUtils.clickOnElementByText("Add Workflow"); - } - - public static void fillAndAddNewWorkflow(String name, String description ) throws InterruptedException{ - GeneralUIUtils.ultimateWait(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling name field with %s", name)); - insertText(name, "label + input"); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling description filed with %s", name)); - insertText(description,"label + textarea"); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking save button ")); - clickSave(); - } - - public static void insertText(String artifactDescriptoin, String element) throws InterruptedException { - GeneralUIUtils.getElementsByCSS("div[class='modal-content']"); - WebElement artifactDescriptionTextbox = GeneralUIUtils.getWebElementBy(By.cssSelector(element)); - artifactDescriptionTextbox.clear(); - artifactDescriptionTextbox.sendKeys(artifactDescriptoin); - GeneralUIUtils.ultimateWait(); - } - - public static void clickSave() { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save button")); - GeneralUIUtils.clickOnElementByText("Save"); - GeneralUIUtils.ultimateWait(); - } + public static void defineName(String productName) { + WebElement productNameTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PRODUCT_NAME.getValue()); + productNameTextbox.clear(); + productNameTextbox.sendKeys(productName); + } + + public static void defineFullName(String productFullName) { + WebElement productFullNameTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.FULL_NAME.getValue()); + productFullNameTextbox.clear(); + productFullNameTextbox.sendKeys(productFullName); + } + + public static void defineProjectCode(String pmat) { + WebElement pmattTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PROJECT_CODE.getValue()); + pmattTextbox.clear(); + pmattTextbox.sendKeys(pmat); + } + + public static String getPmattText() { + return getPmattField().getAttribute("value"); + } + + public static String[] getTags() { + return ResourceGeneralPage.getElementsFromTagsTable().stream().map(WebElement::getText).toArray(String[]::new); + } + + private static WebElement getPmattField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.PROJECT_CODE.getValue()); + } + + public static void deleteOldTags(ProductReqDetails product) { + // Delete tag elements + int i = GeneralUIUtils.getWebElementsListByTestID("i-sdc-tag-delete").size(); + while (i > 0) { + GeneralUIUtils.getWebElementByTestID("i-sdc-tag-delete").click(); + i--; + } + + product.setTags(new ArrayList()); + } + + public static void clickAddWorkflow() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding workflow...")); + GeneralUIUtils.clickOnElementByText("Add Workflow"); + } + + public static void fillAndAddNewWorkflow(String name, String description) throws InterruptedException { + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling name field with %s", name)); + insertText(name, "label + input"); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling description filed with %s", name)); + insertText(description, "label + textarea"); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking save button ")); + clickSave(); + } + + public static void insertText(String artifactDescriptoin, String element) throws InterruptedException { + GeneralUIUtils.getElementsByCSS("div[class='modal-content']"); + WebElement artifactDescriptionTextbox = GeneralUIUtils.getWebElementBy(By.cssSelector(element)); + artifactDescriptionTextbox.clear(); + artifactDescriptionTextbox.sendKeys(artifactDescriptoin); + GeneralUIUtils.ultimateWait(); + } + + public static void clickSave() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save button")); + GeneralUIUtils.clickOnElementByText("Save"); + GeneralUIUtils.ultimateWait(); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductLeftMenu.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductLeftMenu.java index 2972e59618..9e761e8058 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductLeftMenu.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ProductLeftMenu.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,24 +25,23 @@ import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; /** * @author al714h - * */ public class ProductLeftMenu implements ComponentLeftMenu { - public void moveToGeneralScreen() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.GENERAL); - } - - public void moveToIconScreen() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.ICON); - } - - public void moveToCompositionScreen() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); - } - - public void moveToHierarchyScreen() { - GeneralUIUtils.moveToStep(StepsEnum.HIERARCHY); - } + public void moveToGeneralScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.GENERAL); + } + + public void moveToIconScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.ICON); + } + + public void moveToCompositionScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); + } + + public void moveToHierarchyScreen() { + GeneralUIUtils.moveToStep(StepsEnum.HIERARCHY); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesAssignmentPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesAssignmentPage.java index a91c4f7078..72622f4e76 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesAssignmentPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesAssignmentPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,71 +31,76 @@ import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; public class PropertiesAssignmentPage { - public static void clickOnInputTab(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Input Tab")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUTS_TAB.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnPropertiesTab(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Properties Tab")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTIES_TAB.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnCompositionRightTab(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Composition Right Tab")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.COMPOSITION_TAB.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnPropertyStructureRightTab(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Property Structure Right Tab")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTY_STRUCTURE_TAB.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnDeclareButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Declare Button")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DECLARE_BUTTON.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnSaveButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save Button")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_BUTTON.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnDiscardButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Discard Button")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DISCARD_BUTTON.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnDialogSaveButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save Button in Dialog Popup")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_SAVE.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnDialogDiscardButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Discard Button in Dialog Popup")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_DISCARD.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnDialogCancelButton(){ + + private PropertiesAssignmentPage() { + + } + + public static void clickOnInputTab() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Input Tab")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUTS_TAB.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnPropertiesTab() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Properties Tab")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTIES_TAB.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnCompositionRightTab() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Composition Right Tab")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.COMPOSITION_TAB.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnPropertyStructureRightTab() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Property Structure Right Tab")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.PROPERTY_STRUCTURE_TAB.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnDeclareButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Declare Button")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DECLARE_BUTTON.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnSaveButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save Button")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_BUTTON.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnDiscardButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Discard Button")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DISCARD_BUTTON.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnDialogSaveButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Save Button in Dialog Popup")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_SAVE.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnDialogDiscardButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Discard Button in Dialog Popup")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_DISCARD.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnDialogCancelButton() { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Cancel Button in Dialog Popup")); GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.SAVE_DIALOG_CANCEL.getValue()); // GeneralUIUtils.ultimateWait(); } - public static void clickOnEditButton(String propertyName) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Edit button ")); - GeneralUIUtils.clickOnElementByTestId(PropertyNameBuilder.buildPopupField(propertyName)); -// GeneralUIUtils.ultimateWait(); - } + public static void clickOnEditButton(String propertyName) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Edit button ")); + GeneralUIUtils.clickOnElementByTestId(PropertyNameBuilder.buildPopupField(propertyName)); + //GeneralUIUtils.ultimateWait(); + } public static void clickOnSetButton() { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Set button in a property popup ")); @@ -103,126 +108,119 @@ public class PropertiesAssignmentPage { // GeneralUIUtils.ultimateWait(); } - public static void clickOnExpandButton(String propertyName, int index){ + public static void clickOnExpandButton(String propertyName, int index) { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Expand Complex Property Button")); GeneralUIUtils.clickOnElementByTestId(PropertyNameBuilder.buildIExpandButton(propertyName, index)); // GeneralUIUtils.ultimateWait(); } - - public static void findSearchBoxAndClick(String resourceName) throws Exception { - SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " in Properties"); - WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue()); - try{ - searchTextbox.clear(); - searchTextbox.sendKeys(resourceName); - GeneralUIUtils.ultimateWait(); - } - catch(Exception e){ - SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar"); - e.printStackTrace(); - } - - try{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component in Properties", resourceName)); - GeneralUIUtils.clickOnElementByInputTestIdWithoutWait(resourceName); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); - } - catch(Exception e){ - SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName); - e.printStackTrace(); - } - } - - public static void clickOnProperty(String propertyName)throws Exception { - - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component in Properties", propertyName)); - GeneralUIUtils.clickOnElementByTestId(propertyName); -// GeneralUIUtils.ultimateWait(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); - } - - public static void clickOnAddValueToList(String propertyName)throws Exception { - try{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the Add To List button of %s component in Properties", propertyName)); - GeneralUIUtils.clickOnElementByTestId( PropertiesAssignmentScreen.ADD_TO_LIST_BUTTON.getValue() + propertyName); -// GeneralUIUtils.ultimateWait(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); - } - catch(Exception e){ - SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on Add To List button of component named " + propertyName); - e.printStackTrace(); - } - } - - public static void clickODeleteValueFromList(String propertyName, int index)throws Exception { - try{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the Delete From List button of %s component in Properties", propertyName)); - GeneralUIUtils.clickOnElementByTestId( PropertiesAssignmentScreen.DELETE_FROM_LIST_BUTTON.getValue() + propertyName + "." + String.valueOf(index)); -// GeneralUIUtils.ultimateWait(); + + public static void findSearchBoxAndClick(String resourceName) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " in Properties"); + WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue()); + try { + searchTextbox.clear(); + searchTextbox.sendKeys(resourceName); + GeneralUIUtils.ultimateWait(); + } catch (Exception e) { + SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar"); + e.printStackTrace(); + } + + try { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component in Properties", resourceName)); + GeneralUIUtils.clickOnElementByInputTestIdWithoutWait(resourceName); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); + } catch (Exception e) { + SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName); + e.printStackTrace(); + } + } + + public static void clickOnProperty(String propertyName) throws Exception { + + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component in Properties", propertyName)); + GeneralUIUtils.clickOnElementByTestId(propertyName); + //GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); + } + + public static void clickOnAddValueToList(String propertyName) throws Exception { + try { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the Add To List button of %s component in Properties", propertyName)); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.ADD_TO_LIST_BUTTON.getValue() + propertyName); //GeneralUIUtils.ultimateWait(); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); + } catch (Exception e) { + SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on Add To List button of component named " + propertyName); + e.printStackTrace(); } - catch(Exception e){ + } + + public static void clickODeleteValueFromList(String propertyName, int index) throws Exception { + try { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the Delete From List button of %s component in Properties", propertyName)); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.DELETE_FROM_LIST_BUTTON.getValue() + propertyName + "." + String.valueOf(index)); + //GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); + } catch (Exception e) { SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on Delete From List button of component named " + propertyName); e.printStackTrace(); } } - - public static void clickOnDeleteInputButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Delete Input Button")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_BUTTON.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnDeleteInputDialogConfirmationButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Delete Input Dialog Confirmation Button")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_DELETE.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnComponentInComposition(String resourceName) throws Exception{ - try{ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component on Properties screen", resourceName)); - GeneralUIUtils.clickOnElementByTestId(resourceName); -// GeneralUIUtils.ultimateWait(); -// GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); - } - catch(Exception e){ - SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName); - e.printStackTrace(); - } - } - - public static void findInput(String componentName, String resourceName) throws Exception { - SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + componentName + "_" + resourceName + " on Inputs screen"); - WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue()); - String searchPattern = componentName + "_" + resourceName; - - searchTextbox.clear(); - searchTextbox.sendKeys(searchPattern); - GeneralUIUtils.ultimateWait(); - } - - public static void findProperty(String resourceName) throws Exception { - SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen"); - WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue()); - - searchTextbox.clear(); - searchTextbox.sendKeys(resourceName); - GeneralUIUtils.ultimateWait(); - } - - public static void editPropertyValue(String resourceName, String value) throws Exception { - SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen"); - WebElement valueTextbox = GeneralUIUtils.getWebElementByTestID(resourceName); + + public static void clickOnDeleteInputButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Delete Input Button")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_BUTTON.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnDeleteInputDialogConfirmationButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Delete Input Dialog Confirmation Button")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_DELETE.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnComponentInComposition(String resourceName) throws Exception { + try { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component on Properties screen", resourceName)); + GeneralUIUtils.clickOnElementByTestId(resourceName); //GeneralUIUtils.ultimateWait(); + //GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue()); + } catch (Exception e) { + SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName); + e.printStackTrace(); + } + } + + public static void findInput(String componentName, String resourceName) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + componentName + "_" + resourceName + " on Inputs screen"); + WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue()); + String searchPattern = componentName + "_" + resourceName; + + searchTextbox.clear(); + searchTextbox.sendKeys(searchPattern); + GeneralUIUtils.ultimateWait(); + } + + public static void findProperty(String resourceName) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen"); + WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.SEARCH_BOX.getValue()); + + searchTextbox.clear(); + searchTextbox.sendKeys(resourceName); + GeneralUIUtils.ultimateWait(); + } + + public static void editPropertyValue(String resourceName, String value) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen"); + WebElement valueTextbox = GeneralUIUtils.getWebElementByTestID(resourceName); clickOnProperty(resourceName); - valueTextbox.clear(); - SetupCDTest.getExtendTest().log(Status.INFO, "Editing " + resourceName + " property on Properties screen"); - valueTextbox.sendKeys(value); - GeneralUIUtils.ultimateWait(); + valueTextbox.clear(); + SetupCDTest.getExtendTest().log(Status.INFO, "Editing " + resourceName + " property on Properties screen"); + valueTextbox.sendKeys(value); + GeneralUIUtils.ultimateWait(); - } + } public static void deletePropertyValue(String resourceName) throws Exception { SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property on Properties screen"); @@ -237,104 +235,98 @@ public class PropertiesAssignmentPage { } - public static Boolean isPropertyChecked(String resourceName){ + public static Boolean isPropertyChecked(String resourceName) { // TODO add better implementation for css string - GeneralUIUtils.ultimateWait(); - Boolean isDisabled = GeneralUIUtils.checkForDisabledAttributeInHiddenElement("checkbox[data-tests-id='" + resourceName + "'] input"); - SetupCDTest.getExtendTest().log(Status.INFO, "Is property checkbox disabled? " + isDisabled); - if (isDisabled) - return true; - return false; - - - } + GeneralUIUtils.ultimateWait(); + Boolean isDisabled = GeneralUIUtils.checkForDisabledAttributeInHiddenElement("checkbox[data-tests-id='" + resourceName + "'] input"); + SetupCDTest.getExtendTest().log(Status.INFO, "Is property checkbox disabled? " + isDisabled); + return isDisabled; + } - public static boolean isButtonDisabled(String dataTestId){ - return GeneralUIUtils.checkForDisabledAttribute(dataTestId); - } + public static boolean isButtonDisabled(String dataTestId) { + return GeneralUIUtils.checkForDisabledAttribute(dataTestId); + } - public static String selectBooleanPropertyValue(String propertyName, String propertyValue) { + public static String selectBooleanPropertyValue(String propertyName, String propertyValue) { SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + propertyName + " property on Properties screen"); - String actualPropertyValue = null; - try{ - actualPropertyValue = GeneralUIUtils.getSelectedElementFromDropDown(propertyName).getText(); - } - catch(NoSuchElementException e){ - SetupCDTest.getExtendTest().log(Status.INFO, "#selectBooleanPropertyValue - Failed to get selected boolean property value "); - SetupCDTest.getExtendTest().log(Status.INFO, e); - } - try{ - GeneralUIUtils.getSelectList(propertyValue, propertyName); - } - catch(NoSuchElementException e){} - return actualPropertyValue; - } - - - - //Filter Actions - public static void clickOnFilterButton() { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter button ")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_BUTTON.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnFilterAllCheckbox() { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter All Checkbox ")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_ALL.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnFilterCPCheckbox() { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter CP Checkbox ")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_CP.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnFilterVfcCheckbox() { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter VFC Checkbox ")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_VFC.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnFilterVlCheckbox() { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter VL Checkbox ")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_VL.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnFilterApplyButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Apply Button")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_APPLY_BUTTON.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnFilterCloseButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Close Button")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CLOSE_BUTTON.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void clickOnFilterClearAllButton(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Clear All Button")); - GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.CLEAR_FILTER_BUTTON.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void findFilterBoxAndClick(String resourceName) throws Exception { - SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property in Properties table"); - WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.FILTER_BOX.getValue()); - try{ - searchTextbox.clear(); - searchTextbox.sendKeys(resourceName); - GeneralUIUtils.ultimateWait(); - } - catch(Exception e){ - SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar"); - e.printStackTrace(); - } - - } - - + String actualPropertyValue = null; + try { + actualPropertyValue = GeneralUIUtils.getSelectedElementFromDropDown(propertyName).getText(); + } catch (NoSuchElementException e) { + SetupCDTest.getExtendTest().log(Status.INFO, "#selectBooleanPropertyValue - Failed to get selected boolean property value "); + SetupCDTest.getExtendTest().log(Status.INFO, e); + } + try { + GeneralUIUtils.getSelectList(propertyValue, propertyName); + } catch (NoSuchElementException e) { + e.printStackTrace(); + } + return actualPropertyValue; + } + + + //Filter Actions + public static void clickOnFilterButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter button ")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_BUTTON.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnFilterAllCheckbox() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter All Checkbox ")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_ALL.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnFilterCPCheckbox() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter CP Checkbox ")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_CP.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnFilterVfcCheckbox() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter VFC Checkbox ")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_VFC.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnFilterVlCheckbox() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter VL Checkbox ")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CHECKBOX_VL.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnFilterApplyButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Apply Button")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_APPLY_BUTTON.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnFilterCloseButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Close Button")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.FILTER_CLOSE_BUTTON.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void clickOnFilterClearAllButton() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on Filter Clear All Button")); + GeneralUIUtils.clickOnElementByTestId(PropertiesAssignmentScreen.CLEAR_FILTER_BUTTON.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void findFilterBoxAndClick(String resourceName) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " property in Properties table"); + WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesAssignmentScreen.FILTER_BOX.getValue()); + try { + searchTextbox.clear(); + searchTextbox.sendKeys(resourceName); + GeneralUIUtils.ultimateWait(); + } catch (Exception e) { + SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar"); + e.printStackTrace(); + } + + } + + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesPage.java index 23db611081..8ff4570da4 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertiesPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,50 +31,52 @@ import java.util.List; public class PropertiesPage extends GeneralPageElements { - public PropertiesPage() { - super(); - } - - public static List getElemenetsFromTable() { - return GeneralUIUtils.getInputElements(DataTestIdEnum.PropertiesPageEnum.PROPERTY_ROW.getValue()); - } - - public static void clickAddPropertyArtifact() { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.ADD_NEW_PROPERTY.getValue()).click(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue()); - } - - public static void clickEditPropertyArtifact(String propertyName) { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.EDIT_PROPERTY.getValue() + propertyName).click(); - } - - public static void clickDeletePropertyArtifact(String propertyName) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Delete property %s", propertyName)); - GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPageEnum.DELETE_PROPERTY.getValue() + propertyName); - GeneralPageElements.clickOKButton(); - GeneralUIUtils.waitForElementInVisibilityBy(By.className("w-sdc-modal-confirmation"), 10); - } - - public static void clickDeletePropertyFromPopup(String propertyName) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Delete property %s", propertyName)); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName); - GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.PropertiesPageEnum.DELETE_PROPERTY_POPUP.getValue()); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); - } - - public static void clickOnProperty(String propertyName) { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName).click(); - } - - public static PropertyPopup getPropertyPopup() { - return new PropertyPopup(); - } - - public static boolean verifyTotalProperitesField(int count){ - String totalPropertiesCount = GeneralUIUtils.getWebElementBy(By.id("properties-count")).getText(); - return ("Total Properties: " + count).equals(totalPropertiesCount); - } - + private static final int WAIT_FOR_ELEMENT_TIME_OUT = 10; + + private PropertiesPage() { + super(); + } + + public static List getElemenetsFromTable() { + return GeneralUIUtils.getInputElements(DataTestIdEnum.PropertiesPageEnum.PROPERTY_ROW.getValue()); + } + + public static void clickAddPropertyArtifact() { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.ADD_NEW_PROPERTY.getValue()).click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue()); + } + + public static void clickEditPropertyArtifact(String propertyName) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.EDIT_PROPERTY.getValue() + propertyName).click(); + } + + public static void clickDeletePropertyArtifact(String propertyName) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Delete property %s", propertyName)); + GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPageEnum.DELETE_PROPERTY.getValue() + propertyName); + GeneralPageElements.clickOKButton(); + GeneralUIUtils.waitForElementInVisibilityBy(By.className("w-sdc-modal-confirmation"), WAIT_FOR_ELEMENT_TIME_OUT); + } + + public static void clickDeletePropertyFromPopup(String propertyName) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Delete property %s", propertyName)); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName); + GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.PropertiesPageEnum.DELETE_PROPERTY_POPUP.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + } + + public static void clickOnProperty(String propertyName) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propertyName).click(); + } + + public static PropertyPopup getPropertyPopup() { + return new PropertyPopup(); + } + + public static boolean verifyTotalProperitesField(int count) { + String totalPropertiesCount = GeneralUIUtils.getWebElementBy(By.id("properties-count")).getText(); + return ("Total Properties: " + count).equals(totalPropertiesCount); + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyNameBuilder.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyNameBuilder.java index 3cbef2c894..aa0b463374 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyNameBuilder.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyNameBuilder.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,88 +30,90 @@ public class PropertyNameBuilder { private static final String PREFIX_INPUT_VAL = DataTestIdEnum.PropertiesAssignmentScreen.INPUT_VALUE_FIELD_PREFIX.getValue(); private static final String POPUP_VAL = DataTestIdEnum.PropertiesAssignmentScreen.POPUP_VALUE_FIELD_PREFIX.getValue(); + private PropertyNameBuilder() { + + } + //VF/Service simple property value field - public static String buildSimpleField(String propertyName){ + public static String buildSimpleField(String propertyName) { return new StringBuilder().append(PREFIX_VAL).append(propertyName).toString(); } - public static String buildPopupField(String propertyName){ + public static String buildPopupField(String propertyName) { return new StringBuilder().append(POPUP_VAL).append(propertyName).toString(); } - public static String buildIndexedField(String propertyName, int index){ + public static String buildIndexedField(String propertyName, int index) { return new StringBuilder().append(PREFIX_VAL).append(propertyName).append(".").append(index).toString(); } - public static String buildIndexedKeyField(String propertyName, int index){ + public static String buildIndexedKeyField(String propertyName, int index) { return new StringBuilder().append(PREFIX_KEY).append(propertyName).append(".").append(index).toString(); } - public static String buildIComplexField(String propertyName, String nestedProperty){ + public static String buildIComplexField(String propertyName, String nestedProperty) { return new StringBuilder().append(PREFIX_VAL).append(propertyName).append(".").append(nestedProperty).toString(); } - public static String buildIComplexListField(String propertyName, String nestedProperty, int index){ + public static String buildIComplexListField(String propertyName, String nestedProperty, int index) { return new StringBuilder().append(PREFIX_VAL).append(propertyName).append(".").append(index).append(".").append(nestedProperty).toString(); } - public static String buildIExpandButton(String propertyName, int index){ + public static String buildIExpandButton(String propertyName, int index) { return new StringBuilder().append(PREFIX_EXPAND).append(propertyName).append(".").append(index).toString(); } - - //VF input value field - public static String buildDeclaredInputField(String componentName, String propertyName){ + public static String buildDeclaredInputField(String componentName, String propertyName) { return new StringBuilder().append(PREFIX_INPUT_VAL).append(componentName).append("_").append(propertyName).toString(); } - public static String buildInputField(String propertyName){ + public static String buildInputField(String propertyName) { return new StringBuilder().append(PREFIX_INPUT_VAL).append(propertyName).toString(); } //Service Property value field - declared from VF - public static String buildServicePropertyValue(String componentName, String propertyName){ + public static String buildServicePropertyValue(String componentName, String propertyName) { return new StringBuilder().append(PREFIX_VAL).append(componentName).append("_").append(propertyName).toString(); } //Service Input Name - public static String buildServiceInputNameServiceLevel(ComponentInstance componentInstance, String propertyName){ + public static String buildServiceInputNameServiceLevel(ComponentInstance componentInstance, String propertyName) { return new StringBuilder().append(componentInstance.getNormalizedName()) .append("_").append(propertyName).toString(); } - public static String buildServiceInputNameVfLevel(ComponentInstance componentInstance, String componentName, String propertyName){ + public static String buildServiceInputNameVfLevel(ComponentInstance componentInstance, String componentName, String propertyName) { return new StringBuilder().append(componentInstance.getNormalizedName()) .append("_").append(componentName).append("_").append(propertyName).toString(); } //Service Input Value - public static String buildVfDeclaredPropValue(String componentName, String propertyName){ + public static String buildVfDeclaredPropValue(String componentName, String propertyName) { String inputName = componentName + "_" + propertyName; return new StringBuilder().append("{\"get_input\":\"").append(inputName).append("\"}").toString(); } - public static String buildServiceDeclaredPropertyValue(ComponentInstance componentInstance, String componentName, String propertyName){ - String inputName = buildServiceInputNameVfLevel(componentInstance, componentName, propertyName ); + public static String buildServiceDeclaredPropertyValue(ComponentInstance componentInstance, String componentName, String propertyName) { + String inputName = buildServiceInputNameVfLevel(componentInstance, componentName, propertyName); return new StringBuilder().append("{\"get_input\":\"").append(inputName).append("\"}").toString(); } - public static String buildServiceDeclaredPropValueServiceLevel(ComponentInstance componentInstance, String propertyName){ - String inputName = buildServiceInputNameServiceLevel(componentInstance, propertyName ); + public static String buildServiceDeclaredPropValueServiceLevel(ComponentInstance componentInstance, String propertyName) { + String inputName = buildServiceInputNameServiceLevel(componentInstance, propertyName); return new StringBuilder().append("{\"get_input\":\"").append(inputName).append("\"}").toString(); } //Service Input value field - public static String buildServiceDeclaredFieldServiceLevel(ComponentInstance componentInstance, String propertyName){ - String inputName = buildServiceInputNameServiceLevel(componentInstance, propertyName ); + public static String buildServiceDeclaredFieldServiceLevel(ComponentInstance componentInstance, String propertyName) { + String inputName = buildServiceInputNameServiceLevel(componentInstance, propertyName); return new StringBuilder().append(PREFIX_INPUT_VAL).append(inputName).toString(); } - public static String buildServiceDeclaredFieldVfLevel(ComponentInstance componentInstance, String componentName, String propertyName){ - String inputName = buildServiceInputNameVfLevel(componentInstance, componentName, propertyName ); + public static String buildServiceDeclaredFieldVfLevel(ComponentInstance componentInstance, String componentName, String propertyName) { + String inputName = buildServiceInputNameVfLevel(componentInstance, componentName, propertyName); return new StringBuilder().append(PREFIX_INPUT_VAL).append(inputName).toString(); } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyPopup.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyPopup.java index 77321ae145..df1dc9ec80 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyPopup.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/PropertyPopup.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,81 +30,79 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; public class PropertyPopup { - - - public PropertyPopup() { - } - - public boolean getPopupForm(){ - return GeneralUIUtils.waitForElementInVisibilityByTestId(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue(), 60); - } - - public void insertPropertyName(String name) { - WebElement propertyNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_NAME.getValue()); - propertyNameField.clear(); - propertyNameField.sendKeys(name); - } - - public void insertPropertyDefaultValue(String value) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Inserting to property default value: %s ", value)); - WebElement selectedType = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue())).getFirstSelectedOption(); - if(selectedType.getText().equals("boolean")) { - GeneralUIUtils.getSelectList(value, DataTestIdEnum.PropertiesPopupEnum.PROPERTY_BOOLEAN_VALUE.getValue()); - } else { - WebElement propertyValue = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue()); - propertyValue.clear(); - propertyValue.sendKeys(value); - } - - GeneralUIUtils.ultimateWait(); - } - - public void insertPropertyDescription(String description) { - WebElement propertyDescription = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_DESCRIPTION.getValue()); - propertyDescription.clear(); - propertyDescription.sendKeys(description); - } - - public void selectPropertyType(String propertyType) { - boolean isEntrySchemaDisplayed; - try{ - GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue()); - isEntrySchemaDisplayed = GeneralUIUtils.getDriver().findElement(By.xpath(DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue())).isDisplayed(); - if (isEntrySchemaDisplayed){ - PropertiesPage.getPropertyPopup().selectEntrySchema(propertyType); - } - } - catch(NoSuchElementException e){ - - } - } - - public void selectEntrySchema(String propertyType){ - GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue()); - } - - public void clickAdd() { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.ADD.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public void clickSave() { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.SAVE.getValue()); - getPopupForm(); - } - - public void clickCancel() { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.CANCEL.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public void clickDone() { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.DONE.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public void selectPropertyRadioButton(String propertyName) { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_RADIO_BUTTON_CONTAINER.getValue() + propertyName).findElement(By.className(DataTestIdEnum.PropertiesPopupEnum.RADIO_BUTTON_CLASS.getValue())).click(); - } + + + private static final int WAIT_FOR_ELEMENT_TIME_OUT = 60; + + private boolean getPopupForm() { + return GeneralUIUtils.waitForElementInVisibilityByTestId(DataTestIdEnum.PropertiesPageEnum.POPUP_FORM.getValue(), WAIT_FOR_ELEMENT_TIME_OUT); + } + + public void insertPropertyName(String name) { + WebElement propertyNameField = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_NAME.getValue()); + propertyNameField.clear(); + propertyNameField.sendKeys(name); + } + + public void insertPropertyDefaultValue(String value) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Inserting to property default value: %s ", value)); + WebElement selectedType = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue())).getFirstSelectedOption(); + if (selectedType.getText().equals("boolean")) { + GeneralUIUtils.getSelectList(value, DataTestIdEnum.PropertiesPopupEnum.PROPERTY_BOOLEAN_VALUE.getValue()); + } else { + WebElement propertyValue = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue()); + propertyValue.clear(); + propertyValue.sendKeys(value); + } + + GeneralUIUtils.ultimateWait(); + } + + public void insertPropertyDescription(String description) { + WebElement propertyDescription = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_DESCRIPTION.getValue()); + propertyDescription.clear(); + propertyDescription.sendKeys(description); + } + + public void selectPropertyType(String propertyType) { + boolean isEntrySchemaDisplayed; + try { + GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue()); + isEntrySchemaDisplayed = GeneralUIUtils.getDriver().findElement(By.xpath(DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue())).isDisplayed(); + if (isEntrySchemaDisplayed) { + PropertiesPage.getPropertyPopup().selectEntrySchema(propertyType); + } + } catch (NoSuchElementException e) { + + } + } + + public void selectEntrySchema(String propertyType) { + GeneralUIUtils.getSelectList(propertyType, DataTestIdEnum.PropertiesPopupEnum.ENTRY_SCHEMA.getValue()); + } + + public void clickAdd() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.ADD.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public void clickSave() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.SAVE.getValue()); + getPopupForm(); + } + + public void clickCancel() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.CANCEL.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public void clickDone() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesPopupEnum.DONE.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public void selectPropertyRadioButton(String propertyName) { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_RADIO_BUTTON_CONTAINER.getValue() + propertyName).findElement(By.className(DataTestIdEnum.PropertiesPopupEnum.RADIO_BUTTON_CLASS.getValue())).click(); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceGeneralPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceGeneralPage.java index 5f329f5376..a7d0fe6477 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceGeneralPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceGeneralPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,155 +32,157 @@ import java.util.List; public class ResourceGeneralPage extends GeneralPageElements { - public ResourceGeneralPage() { - super(); - } - - public static WebElement getNameField() { - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.RESOURCE_NAME.getValue()); - } - - public static WebElement getDescriptionField() { - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.DESCRIPTION.getValue()); - } - - public static String getCategoryDataTestsIdAttribute() { - return DataTestIdEnum.ResourceMetadataEnum.CATEGORY.getValue(); - } - - public static WebElement getVendorNameField() { - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_NAME.getValue()); - } - - public static WebElement getVendorReleaseField() { - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_RELEASE.getValue()); - } - - public static WebElement getTagsField() { - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS.getValue()); - } - - public static WebElement getContactIdField() { - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.CONTACT_ID.getValue()); - } - - /***************************************************************/ - - public static String getNameText() { - return getNameField().getAttribute("value"); - } - - public static void defineName(String resourceName) { - WebElement resourceNameTextbox = getNameField(); - resourceNameTextbox.clear(); - resourceNameTextbox.sendKeys(resourceName); - } - - public static void defineNameWithPaste() { - defineTextBoxWithPaste(getNameField()); - } - - public static String getDescriptionText() { - return getDescriptionField().getAttribute("value"); - } - - public static void defineDescription(String description) { - WebElement descriptionTextbox = getDescriptionField(); - descriptionTextbox.clear(); - descriptionTextbox.sendKeys(description); - } - - public static void defineDescriptionWithPaste() { - defineTextBoxWithPaste(getDescriptionField()); - } - - public static String getVendorNameText() { - return getVendorNameField().getAttribute("value"); - } - - public static void defineVendorName(String vendorName) { - WebElement vendorNameTextbox = getVendorNameField(); - vendorNameTextbox.clear(); - vendorNameTextbox.sendKeys(vendorName); - } - - public static void defineVendorNameWithPaste() { - defineTextBoxWithPaste(getVendorNameField()); - } - - public static String getVendorReleaseText() { - return getVendorReleaseField().getAttribute("value"); - } - - public static void defineVendorRelease(String vendorRelease) { - WebElement vendorReleaseTextbox = getVendorReleaseField(); - vendorReleaseTextbox.clear(); - vendorReleaseTextbox.sendKeys(vendorRelease); - } - - public static void defineVendorReleaseWithPaste() { - defineTextBoxWithPaste(getVendorReleaseField()); - } - - public static void defineTag(String resourceTags) { - WebElement tagTextbox = getTagsField(); - tagTextbox.clear(); - tagTextbox.sendKeys(resourceTags); - tagTextbox.sendKeys(Keys.ENTER); - } - - public static void defineTagsList(ComponentReqDetails component, String[] tags) { - List taglist = new ArrayList(); - WebElement resourceTagsTextbox = getTagsField(); - for (String tag : tags) { - resourceTagsTextbox.clear(); - resourceTagsTextbox.sendKeys(tag); - GeneralUIUtils.sleep(500); - resourceTagsTextbox.sendKeys(Keys.ENTER); - taglist.add(tag); - } - component.getTags().addAll(taglist); - } - - public static void defineTagsListWithPaste() { - List taglist = new ArrayList(); - WebElement resourceTagsTextbox = getTagsField(); - defineTextBoxWithPaste(resourceTagsTextbox); - resourceTagsTextbox.sendKeys(Keys.ENTER); - } - - public static void defineCategory(String category) { - GeneralUIUtils.getSelectList(category, getCategoryDataTestsIdAttribute()); - } - - public static String getContactIdText() { - return getContactIdField().getAttribute("value"); - } - - public static void defineContactId(String userId) { - WebElement contactIdTextbox = getContactIdField(); - contactIdTextbox.clear(); - contactIdTextbox.sendKeys(userId); - GeneralUIUtils.waitForLoader(); - } - - public static List getElementsFromTagsTable(){ - return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS_TABLE.getValue()); - } - - public static void defineTextBoxWithPaste(WebElement textBox) { - textBox.clear(); - textBox.sendKeys(Keys.CONTROL + "v"); - GeneralUIUtils.ultimateWait(); - } - - public static void moveToToscaArtifactsSectionAndDownloadTosca() { - getLeftMenu().moveToToscaArtifactsScreen(); - ToscaArtifactsPage.downloadCsar(); - } - - public static String getVersionUI(){ - String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText().replace("V", ""); - return actualVersion; - } + private static final int SLEEP_DURATION = 500; + + protected ResourceGeneralPage() { + super(); + } + + public static WebElement getNameField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.RESOURCE_NAME.getValue()); + } + + public static WebElement getDescriptionField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.DESCRIPTION.getValue()); + } + + public static String getCategoryDataTestsIdAttribute() { + return DataTestIdEnum.ResourceMetadataEnum.CATEGORY.getValue(); + } + + public static WebElement getVendorNameField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_NAME.getValue()); + } + + public static WebElement getVendorReleaseField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_RELEASE.getValue()); + } + + public static WebElement getTagsField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS.getValue()); + } + + public static WebElement getContactIdField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.CONTACT_ID.getValue()); + } + + /***************************************************************/ + + public static String getNameText() { + return getNameField().getAttribute("value"); + } + + public static void defineName(String resourceName) { + WebElement resourceNameTextbox = getNameField(); + resourceNameTextbox.clear(); + resourceNameTextbox.sendKeys(resourceName); + } + + public static void defineNameWithPaste() { + defineTextBoxWithPaste(getNameField()); + } + + public static String getDescriptionText() { + return getDescriptionField().getAttribute("value"); + } + + public static void defineDescription(String description) { + WebElement descriptionTextbox = getDescriptionField(); + descriptionTextbox.clear(); + descriptionTextbox.sendKeys(description); + } + + public static void defineDescriptionWithPaste() { + defineTextBoxWithPaste(getDescriptionField()); + } + + public static String getVendorNameText() { + return getVendorNameField().getAttribute("value"); + } + + public static void defineVendorName(String vendorName) { + WebElement vendorNameTextbox = getVendorNameField(); + vendorNameTextbox.clear(); + vendorNameTextbox.sendKeys(vendorName); + } + + public static void defineVendorNameWithPaste() { + defineTextBoxWithPaste(getVendorNameField()); + } + + public static String getVendorReleaseText() { + return getVendorReleaseField().getAttribute("value"); + } + + public static void defineVendorRelease(String vendorRelease) { + WebElement vendorReleaseTextbox = getVendorReleaseField(); + vendorReleaseTextbox.clear(); + vendorReleaseTextbox.sendKeys(vendorRelease); + } + + public static void defineVendorReleaseWithPaste() { + defineTextBoxWithPaste(getVendorReleaseField()); + } + + public static void defineTag(String resourceTags) { + WebElement tagTextbox = getTagsField(); + tagTextbox.clear(); + tagTextbox.sendKeys(resourceTags); + tagTextbox.sendKeys(Keys.ENTER); + } + + public static void defineTagsList(ComponentReqDetails component, String[] tags) { + List taglist = new ArrayList(); + WebElement resourceTagsTextbox = getTagsField(); + for (String tag : tags) { + resourceTagsTextbox.clear(); + resourceTagsTextbox.sendKeys(tag); + GeneralUIUtils.sleep(SLEEP_DURATION); + resourceTagsTextbox.sendKeys(Keys.ENTER); + taglist.add(tag); + } + component.getTags().addAll(taglist); + } + + public static void defineTagsListWithPaste() { + List taglist = new ArrayList(); + WebElement resourceTagsTextbox = getTagsField(); + defineTextBoxWithPaste(resourceTagsTextbox); + resourceTagsTextbox.sendKeys(Keys.ENTER); + } + + public static void defineCategory(String category) { + GeneralUIUtils.getSelectList(category, getCategoryDataTestsIdAttribute()); + } + + public static String getContactIdText() { + return getContactIdField().getAttribute("value"); + } + + public static void defineContactId(String userId) { + WebElement contactIdTextbox = getContactIdField(); + contactIdTextbox.clear(); + contactIdTextbox.sendKeys(userId); + GeneralUIUtils.waitForLoader(); + } + + public static List getElementsFromTagsTable() { + return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS_TABLE.getValue()); + } + + public static void defineTextBoxWithPaste(WebElement textBox) { + textBox.clear(); + textBox.sendKeys(Keys.CONTROL + "v"); + GeneralUIUtils.ultimateWait(); + } + + public static void moveToToscaArtifactsSectionAndDownloadTosca() { + getLeftMenu().moveToToscaArtifactsScreen(); + ToscaArtifactsPage.downloadCsar(); + } + + public static String getVersionUI() { + String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText().replace("V", ""); + return actualVersion; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceLeftMenu.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceLeftMenu.java index 2955d72e2e..6d92a03e42 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceLeftMenu.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ResourceLeftMenu.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,47 +25,47 @@ import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; public class ResourceLeftMenu implements ComponentLeftMenu { - public void moveToGeneralScreen() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.GENERAL); - } + public void moveToGeneralScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.GENERAL); + } - public void moveToIconScreen() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.ICON); - } + public void moveToIconScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.ICON); + } - public void moveToDeploymentArtifactScreen() { - GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); - } + public void moveToDeploymentArtifactScreen() { + GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); + } - public void moveToInformationalArtifactScreen() { - GeneralUIUtils.moveToStep(StepsEnum.INFORMATION_ARTIFACT); - } + public void moveToInformationalArtifactScreen() { + GeneralUIUtils.moveToStep(StepsEnum.INFORMATION_ARTIFACT); + } - public void moveToPropertiesScreen() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.PROPERTIES); - } + public void moveToPropertiesScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.PROPERTIES); + } - public void moveToCompositionScreen() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); - } + public void moveToCompositionScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); + } - public void moveToActivityLogScreen() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.ACTIVITY_LOG); - } + public void moveToActivityLogScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.ACTIVITY_LOG); + } - public void moveToDeploymentViewScreen() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_VIEW); - } + public void moveToDeploymentViewScreen() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_VIEW); + } - public void moveToToscaArtifactsScreen() { - GeneralUIUtils.moveToStep(StepsEnum.TOSCA_ARTIFACTS); - } - - public void moveToInputsScreen() { - GeneralUIUtils.moveToStep(StepsEnum.INPUTS); - } - - public void moveToPropertiesAssignmentScreen() { - GeneralUIUtils.moveToStep(StepsEnum.PROPERTIES_ASSIGNMENT); - } + public void moveToToscaArtifactsScreen() { + GeneralUIUtils.moveToStep(StepsEnum.TOSCA_ARTIFACTS); + } + + public void moveToInputsScreen() { + GeneralUIUtils.moveToStep(StepsEnum.INPUTS); + } + + public void moveToPropertiesAssignmentScreen() { + GeneralUIUtils.moveToStep(StepsEnum.PROPERTIES_ASSIGNMENT); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceGeneralPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceGeneralPage.java index a2847f0cf4..07f3f23215 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceGeneralPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceGeneralPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,108 +44,104 @@ import java.util.Map; public class ServiceGeneralPage extends ResourceGeneralPage { - public ServiceGeneralPage() { - super(); - } - - public static ServiceLeftMenu getServiceLeftMenu() { + public static ServiceLeftMenu getServiceLeftMenu() { return new ServiceLeftMenu(); } - public static void defineName(String serviceName) { - WebElement serviceNameTextbox = GeneralUIUtils - .getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.SERVICE_NAME.getValue()); - serviceNameTextbox.clear(); - serviceNameTextbox.sendKeys(serviceName); - } - - public static void defineProjectCode(String pmat) { - WebElement projectCodeTextbox = GeneralUIUtils - .getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.PROJECT_CODE.getValue()); - projectCodeTextbox.clear(); - projectCodeTextbox.sendKeys(pmat); - } - - public static String getProjectCodeText(){ - return getProjectCodeField().getAttribute("value"); - } - - public static String[] getTags(){ - return ResourceGeneralPage.getElementsFromTagsTable().stream().map(WebElement::getText).toArray(String[]::new); - } - - private static WebElement getProjectCodeField() { - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.PROJECT_CODE.getValue()); - } - - public static void deleteOldTags(ServiceReqDetails service){ - // Delete tag elements - int i = GeneralUIUtils.getWebElementsListByTestID("i-sdc-tag-delete").size(); - while (i > 0){ - GeneralUIUtils.getWebElementByTestID("i-sdc-tag-delete").click(); - i--; - } - - service.setTags(new ArrayList()); - } - - public static String getCategoryText() { - return GeneralUIUtils.getSelectedElementFromDropDown(getCategoryDataTestsIdAttribute()).getText(); - } - - public static String getInstantiationTypeChosenValue() { - return GeneralUIUtils.getSelectedElementFromDropDown(getInstantiationTypeIdAttribute()).getText(); - } - - private static String getInstantiationTypeIdAttribute() { - return ServiceMetadataEnum.INSTANTIATION_TYPE.getValue(); - } - - public static void clickAddWorkflow (){ - SetupCDTest.getExtendTest().log(Status.INFO, "Adding workflow..."); - GeneralUIUtils.clickOnElementByText("Add Workflow"); - } - - public static void fillAndAddNewWorkflow(String name, String description ) throws InterruptedException{ - GeneralUIUtils.ultimateWait(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling name field with %s", name)); - insertText(name, "label + input"); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling description filed with %s", name)); - insertText(description,"label + textarea"); - SetupCDTest.getExtendTest().log(Status.INFO, "Clicking save button "); - clickSave(); - } - - public static void insertText(String artifactDescriptoin, String element) throws InterruptedException { - GeneralUIUtils.getElementsByCSS("div[class='modal-content']"); - WebElement artifactDescriptionTextbox = GeneralUIUtils.getWebElementBy(By.cssSelector(element)); - artifactDescriptionTextbox.clear(); - artifactDescriptionTextbox.sendKeys(artifactDescriptoin); - GeneralUIUtils.ultimateWait(); - } - - public static void clickSave() { - SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Save button"); - GeneralUIUtils.clickOnElementByXpath("//*[@data-test-id='form-submit-button']"); - GeneralUIUtils.ultimateWait(); - } - - public static void defineInstantiationType(String instantiationType) { - GeneralUIUtils.getSelectList(instantiationType, DataTestIdEnum.ServiceMetadataEnum.INSTANTIATION_TYPE.getValue()); - } - - public Service prepareServiceObject(ServiceReqDetails serviceMetadata) throws Exception { - return AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, serviceMetadata.getName(), "0.1"); - } - - public static boolean parseToscaFileIntoServiceAndValidateProperties(ServiceReqDetails serviceMetadata) throws Exception { - ServiceGeneralPage serviceGeneralPageObject = new ServiceGeneralPage(); - Service service = serviceGeneralPageObject.prepareServiceObject(serviceMetadata); - Map expectedMetadataMap = Utils.generateServiceMetadataToExpectedObject(serviceMetadata, service); - File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); - ToscaDefinition toscaServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(latestFilefromDir); - Either> serviceToscaMetadataValidator = ToscaValidation.serviceToscaMetadataValidator(expectedMetadataMap, toscaServiceDefinition); - return serviceToscaMetadataValidator.isRight(); - } - + public static void defineName(String serviceName) { + WebElement serviceNameTextbox = GeneralUIUtils + .getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.SERVICE_NAME.getValue()); + serviceNameTextbox.clear(); + serviceNameTextbox.sendKeys(serviceName); + } + + public static void defineProjectCode(String pmat) { + WebElement projectCodeTextbox = GeneralUIUtils + .getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.PROJECT_CODE.getValue()); + projectCodeTextbox.clear(); + projectCodeTextbox.sendKeys(pmat); + } + + public static String getProjectCodeText() { + return getProjectCodeField().getAttribute("value"); + } + + public static String[] getTags() { + return ResourceGeneralPage.getElementsFromTagsTable().stream().map(WebElement::getText).toArray(String[]::new); + } + + private static WebElement getProjectCodeField() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.PROJECT_CODE.getValue()); + } + + public static void deleteOldTags(ServiceReqDetails service) { + // Delete tag elements + int i = GeneralUIUtils.getWebElementsListByTestID("i-sdc-tag-delete").size(); + while (i > 0) { + GeneralUIUtils.getWebElementByTestID("i-sdc-tag-delete").click(); + i--; + } + + service.setTags(new ArrayList()); + } + + public static String getCategoryText() { + return GeneralUIUtils.getSelectedElementFromDropDown(getCategoryDataTestsIdAttribute()).getText(); + } + + public static String getInstantiationTypeChosenValue() { + return GeneralUIUtils.getSelectedElementFromDropDown(getInstantiationTypeIdAttribute()).getText(); + } + + private static String getInstantiationTypeIdAttribute() { + return ServiceMetadataEnum.INSTANTIATION_TYPE.getValue(); + } + + public static void clickAddWorkflow() { + SetupCDTest.getExtendTest().log(Status.INFO, "Adding workflow..."); + GeneralUIUtils.clickOnElementByText("Add Workflow"); + } + + public static void fillAndAddNewWorkflow(String name, String description) throws InterruptedException { + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling name field with %s", name)); + insertText(name, "label + input"); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Filling description filed with %s", name)); + insertText(description, "label + textarea"); + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking save button "); + clickSave(); + } + + public static void insertText(String artifactDescriptoin, String element) throws InterruptedException { + GeneralUIUtils.getElementsByCSS("div[class='modal-content']"); + WebElement artifactDescriptionTextbox = GeneralUIUtils.getWebElementBy(By.cssSelector(element)); + artifactDescriptionTextbox.clear(); + artifactDescriptionTextbox.sendKeys(artifactDescriptoin); + GeneralUIUtils.ultimateWait(); + } + + public static void clickSave() { + SetupCDTest.getExtendTest().log(Status.INFO, "Clicking on Save button"); + GeneralUIUtils.clickOnElementByXpath("//*[@data-test-id='form-submit-button']"); + GeneralUIUtils.ultimateWait(); + } + + public static void defineInstantiationType(String instantiationType) { + GeneralUIUtils.getSelectList(instantiationType, DataTestIdEnum.ServiceMetadataEnum.INSTANTIATION_TYPE.getValue()); + } + + public Service prepareServiceObject(ServiceReqDetails serviceMetadata) throws Exception { + return AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, serviceMetadata.getName(), "0.1"); + } + + public static boolean parseToscaFileIntoServiceAndValidateProperties(ServiceReqDetails serviceMetadata) throws Exception { + ServiceGeneralPage serviceGeneralPageObject = new ServiceGeneralPage(); + Service service = serviceGeneralPageObject.prepareServiceObject(serviceMetadata); + Map expectedMetadataMap = Utils.generateServiceMetadataToExpectedObject(serviceMetadata, service); + File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); + ToscaDefinition toscaServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(latestFilefromDir); + Either> serviceToscaMetadataValidator = ToscaValidation.serviceToscaMetadataValidator(expectedMetadataMap, toscaServiceDefinition); + return serviceToscaMetadataValidator.isRight(); + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceLeftMenu.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceLeftMenu.java index 127ada2309..04324e15ca 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceLeftMenu.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ServiceLeftMenu.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,9 +24,9 @@ import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.StepsEnum; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; public class ServiceLeftMenu implements ComponentLeftMenu { - - public void moveToManagmentWorkflow() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.MANAGEMENT_WORKFLOW); - } + + public void moveToManagmentWorkflow() throws Exception { + GeneralUIUtils.moveToStep(StepsEnum.MANAGEMENT_WORKFLOW); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/TesterOperationPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/TesterOperationPage.java index d556ee1d09..32526812fd 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/TesterOperationPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/TesterOperationPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,73 +27,65 @@ import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; public class TesterOperationPage { - public TesterOperationPage() { - super(); - } + private TesterOperationPage() { + super(); + } - public static void certifyComponent(String componentName) throws Exception{ - clickStartTestingButton(); - clickAcceptCertificationButton(componentName); - } + public static void certifyComponent(String componentName) throws Exception { + clickStartTestingButton(); + clickAcceptCertificationButton(componentName); + } - public static void clickAcceptCertificationButton(String componentName) throws Exception { - ExtentTestActions.log(Status.INFO, "Accepting certifiction of " + componentName); - String actionDuration = GeneralUIUtils.getActionDuration(() -> - { - try { - clickAcceptCertificationButtonWithoutDuration(componentName); - } catch (Exception e) { - e.printStackTrace(); - } - }); - ExtentTestActions.log(Status.INFO, componentName + " is certifed", actionDuration); + public static void clickAcceptCertificationButton(String componentName) throws Exception { + ExtentTestActions.log(Status.INFO, "Accepting certifiction of " + componentName); + String actionDuration = GeneralUIUtils.getActionDuration(() -> + { + try { + clickAcceptCertificationButtonWithoutDuration(componentName); + } catch (Exception e) { + e.printStackTrace(); + } + }); + ExtentTestActions.log(Status.INFO, componentName + " is certifed", actionDuration); - } - - public static void clickStartTestingButton() throws Exception{ - ExtentTestActions.log(Status.INFO, "Starting to test"); - String actionDuration = GeneralUIUtils.getActionDuration(() -> { - try { - clickStartTestingButtonWithoutDuration(); - } catch (Exception e) { - e.printStackTrace(); - } - }); - ExtentTestActions.log(Status.INFO, "Ready for certification", actionDuration); - } - - -/* private static void certifyComponentWithoutDuration(String componentName) throws Exception { - clickStartTestingButtonWithoutDuration(); - clickAcceptCertificationButtonWithoutDuration(componentName); - }*/ - - - private static void clickAcceptCertificationButtonWithoutDuration(String componentName) throws Exception { - try{ - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.ACCEPT.getValue()); -// GeneralUIUtils.ultimateWait(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.ACCEPT_TESTING_MESSAGE.getValue()).sendKeys(componentName + " tested successfuly"); - GeneralPageElements.clickOKButton(); -// GeneralUIUtils.sleep(2000); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()); - } - catch (Exception e){ - throw new Exception("Accepting certification of " + componentName + " failed"); - } - } - - private static void clickStartTestingButtonWithoutDuration() throws Exception { - try{ - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.START_TESTING.getValue()); -// GeneralUIUtils.ultimateWait(); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.LifeCyleChangeButtons.ACCEPT.getValue()); -// GeneralUIUtils.ultimateWait(); -// GeneralUIUtils.sleep(1000); - } - catch (Exception e){ - throw new Exception("Start testing failed"); - } - } + } + + public static void clickStartTestingButton() throws Exception { + ExtentTestActions.log(Status.INFO, "Starting to test"); + String actionDuration = GeneralUIUtils.getActionDuration(() -> { + try { + clickStartTestingButtonWithoutDuration(); + } catch (Exception e) { + e.printStackTrace(); + } + }); + ExtentTestActions.log(Status.INFO, "Ready for certification", actionDuration); + } + + + private static void clickAcceptCertificationButtonWithoutDuration(String componentName) throws Exception { + try { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.ACCEPT.getValue()); + //GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.ACCEPT_TESTING_MESSAGE.getValue()).sendKeys(componentName + " tested successfuly"); + GeneralPageElements.clickOKButton(); + //GeneralUIUtils.sleep(2000); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()); + } catch (Exception e) { + throw new Exception("Accepting certification of " + componentName + " failed"); + } + } + + private static void clickStartTestingButtonWithoutDuration() throws Exception { + try { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.START_TESTING.getValue()); + //GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.LifeCyleChangeButtons.ACCEPT.getValue()); + //GeneralUIUtils.ultimateWait(); + //GeneralUIUtils.sleep(1000); + } catch (Exception e) { + throw new Exception("Start testing failed"); + } + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ToscaArtifactsPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ToscaArtifactsPage.java index f57801b534..d93c4633ab 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ToscaArtifactsPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/ToscaArtifactsPage.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,34 +26,34 @@ import org.openqa.selenium.WebElement; public class ToscaArtifactsPage extends DeploymentArtifactPage { - public ToscaArtifactsPage() { - - } - - public static String getArtifactName(int row){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_NAME.getValue() + row).getText(); - } - - public static String getArtifactType(int row){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_TYPE.getValue() + row).getText(); - } - - public static String getArtifactVersion(int row){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_VERSION.getValue() + row).getText(); - } - - public static WebElement getArtifactDetails(int row){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_DETAILS.getValue() + row); - } - - public static void downloadCsar() { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ToscaArtifactsScreenEnum.DOWNLOAD_CSAR.getValue()); -// GeneralUIUtils.ultimateWait(); - } - - public static void downloadTemplate() { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ToscaArtifactsScreenEnum.TOSCA_TEMPLATE.getValue()); -// GeneralUIUtils.ultimateWait(); - } + private ToscaArtifactsPage() { + + } + + public static String getArtifactName(int row) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_NAME.getValue() + row).getText(); + } + + public static String getArtifactType(int row) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_TYPE.getValue() + row).getText(); + } + + public static String getArtifactVersion(int row) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_VERSION.getValue() + row).getText(); + } + + public static WebElement getArtifactDetails(int row) { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ToscaArtifactsScreenEnum.ARTIFACT_DETAILS.getValue() + row); + } + + public static void downloadCsar() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ToscaArtifactsScreenEnum.DOWNLOAD_CSAR.getValue()); + //GeneralUIUtils.ultimateWait(); + } + + public static void downloadTemplate() { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ToscaArtifactsScreenEnum.TOSCA_TEMPLATE.getValue()); + //GeneralUIUtils.ultimateWait(); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UpgradeServicesPopup.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UpgradeServicesPopup.java index 240ddf9f11..81ae4b5145 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UpgradeServicesPopup.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UpgradeServicesPopup.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,13 +21,18 @@ package org.openecomp.sdc.ci.tests.pages; public class UpgradeServicesPopup { - static boolean isUpgradePopupShown; + + private UpgradeServicesPopup() { + + } + + private static boolean isUpgradePopupShown; public static boolean isUpgradePopupShown() { return isUpgradePopupShown; } - public static void setUpgradePopupShown(boolean upgradePopupShown) { + static void setUpgradePopupShown(boolean upgradePopupShown) { isUpgradePopupShown = upgradePopupShown; } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java index fb8ead33d7..d8007c013b 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,76 +32,65 @@ import java.io.File; public class UploadArtifactPopup { - boolean isCompositionPage; - - public UploadArtifactPopup(boolean isCompositionPage) { - super(); - this.isCompositionPage = isCompositionPage; - } - - public UploadArtifactPopup() { - super(); - } - - public WebElement getArtifactDescriptionWebElement(){ - return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_DESCRIPTION.getValue()); - } - - public void loadFile(String path, String filename) { - final WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPopup.BROWSE.getValue()); -// browseWebElement.sendKeys(path + filename); - browseWebElement.sendKeys(path + File.separator + filename); - GeneralUIUtils.ultimateWait(); - -// if (!browseWebElement.getAttribute("value").equals(filename)) -// { -// throw new TestException("File named " + filename + " does not presented"); -// } - } - - - - public void insertDescription(String artifactDescriptoin) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Changing artifact description to: %s", artifactDescriptoin)); - WebElement artifactDescriptionTextbox = getArtifactDescriptionWebElement(); - artifactDescriptionTextbox.clear(); - artifactDescriptionTextbox.sendKeys(artifactDescriptoin); - - GeneralUIUtils.ultimateWait();; - } - - public Select defineArtifactLabel(String requiredArtifactLabel) { - Select selectList = null; - WebElement artifactLabelWebElement = null; - -// if (isCompositionPage){ - artifactLabelWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue()); -// } -// else{ -// selectList = GeneralUIUtils.getSelectList("Create New Artifact", DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue()); -// artifactLabelWebElement = GeneralUIUtils.getDriver().findElement(By.name(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue())); -// } - - artifactLabelWebElement.clear(); - artifactLabelWebElement.sendKeys(requiredArtifactLabel); - return selectList; - } - - public Select selectArtifactType(String artifactType) { - return GeneralUIUtils.getSelectList(artifactType, DataTestIdEnum.ArtifactPopup.ARTIFACT_TYPE.getValue()); - } - - public void clickDoneButton() throws Exception { - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPopup.DONE_BUTTON.getValue()); - GeneralUIUtils.waitForLoader(); - GeneralUIUtils.waitForElementInVisibilityBy(By.className("sdc-add-artifact"), 10); - } - - public void clickCancelButton() throws Exception { - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.CANCEL_BUTTON.getValue()).click(); - GeneralUIUtils.waitForLoader(); - GeneralUIUtils.waitForElementInVisibilityByTestId("sdc-add-artifact"); - } + private static final int WAITING_FOR_ELEMENT_TIME_OUT = 10; + private boolean isCompositionPage; + + public UploadArtifactPopup(boolean isCompositionPage) { + super(); + this.isCompositionPage = isCompositionPage; + } + + public UploadArtifactPopup() { + super(); + } + + private WebElement getArtifactDescriptionWebElement() { + return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_DESCRIPTION.getValue()); + } + + public void loadFile(String path, String filename) { + final WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPopup.BROWSE.getValue()); + browseWebElement.sendKeys(path + File.separator + filename); + GeneralUIUtils.ultimateWait(); + } + + + public void insertDescription(String artifactDescriptoin) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Changing artifact description to: %s", artifactDescriptoin)); + WebElement artifactDescriptionTextbox = getArtifactDescriptionWebElement(); + artifactDescriptionTextbox.clear(); + artifactDescriptionTextbox.sendKeys(artifactDescriptoin); + + GeneralUIUtils.ultimateWait(); + } + + public Select defineArtifactLabel(String requiredArtifactLabel) { + Select selectList = null; + WebElement artifactLabelWebElement; + + artifactLabelWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.ARTIFACT_LABEL.getValue()); + + + artifactLabelWebElement.clear(); + artifactLabelWebElement.sendKeys(requiredArtifactLabel); + return selectList; + } + + public Select selectArtifactType(String artifactType) { + return GeneralUIUtils.getSelectList(artifactType, DataTestIdEnum.ArtifactPopup.ARTIFACT_TYPE.getValue()); + } + + public void clickDoneButton() throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPopup.DONE_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.waitForElementInVisibilityBy(By.className("sdc-add-artifact"), WAITING_FOR_ELEMENT_TIME_OUT); + } + + public void clickCancelButton() throws Exception { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.CANCEL_BUTTON.getValue()).click(); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.waitForElementInVisibilityByTestId("sdc-add-artifact"); + } // public void clickUpdateButton() throws Exception { // clickAddButton(); @@ -109,16 +98,16 @@ public class UploadArtifactPopup { // GeneralUIUtils.waitForLoader(); // GeneralUIUtils.waitForElementInVisibilityByTestId(By.className("sdc-add-artifact"), 50); // } - - public void insertURL(String artifactDescriptoin) throws Exception { - WebElement artifactDescriptionTextbox = getArtifactURLWebElement(); - artifactDescriptionTextbox.clear(); - artifactDescriptionTextbox. sendKeys(artifactDescriptoin); - } - - public WebElement getArtifactURLWebElement(){ - return GeneralUIUtils.getWebElementBy(By.cssSelector((DataTestIdEnum.ArtifactPopup.URL.getValue()))); - } - + + public void insertURL(String artifactDescriptoin) throws Exception { + WebElement artifactDescriptionTextbox = getArtifactURLWebElement(); + artifactDescriptionTextbox.clear(); + artifactDescriptionTextbox.sendKeys(artifactDescriptoin); + } + + public WebElement getArtifactURLWebElement() { + return GeneralUIUtils.getWebElementBy(By.cssSelector((DataTestIdEnum.ArtifactPopup.URL.getValue()))); + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationPage.java index 75e1030014..ae01e9c207 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationPage.java @@ -20,16 +20,18 @@ import com.aventstack.extentreports.Status; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.By; import org.openqa.selenium.WebElement; -import org.openqa.selenium.*; -import static org.testng.AssertJUnit.assertTrue; - import java.util.List; +import static org.testng.AssertJUnit.assertTrue; + public class VspValidationPage extends GeneralPageElements { - public VspValidationPage() { super(); } + private VspValidationPage() { + super(); + } public static void navigateToVspValidationPageUsingNavbar() throws Exception { clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR); @@ -57,19 +59,20 @@ public class VspValidationPage extends GeneralPageElements { public static void clickCertificationQueryAll() throws Exception { List checkboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-certifications-query-checkbox-tree']//label//span[@class='rct-checkbox']"); - if(checkboxes.size() > 0){ + if (checkboxes.size() > 0) { checkboxes.get(0).click(); - } - else + } else { assertTrue("Checkbox Not Found", checkboxes.size() > 0); + } } public static void clickComplianceChecksAll() throws Exception { List checkboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-compliance-checks-checkbox-tree']//label//span[@class='rct-checkbox']"); - if(checkboxes.size() > 0) + if (checkboxes.size() > 0) { checkboxes.get(checkboxes.size() - 1).click(); - else + } else { assertTrue("Checkbox Not Found", checkboxes.size() > 0); + } } public static boolean checkCertificationQueryExists() throws Exception { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationResultsPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationResultsPage.java index a33344ecec..9972121a9f 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationResultsPage.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationResultsPage.java @@ -21,13 +21,14 @@ import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openqa.selenium.WebElement; -import org.testng.AssertJUnit; import java.util.List; public class VspValidationResultsPage extends GeneralPageElements { - public VspValidationResultsPage() { super(); } + private VspValidationResultsPage() { + super(); + } public static void navigateToVspValidationResultsPageUsingNavbar() throws Exception { clickOnElementUsingTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_NAVBAR); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/AdditionalConditions.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/AdditionalConditions.java index 57a2bf83dc..bd6cd9fcf1 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/AdditionalConditions.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/AdditionalConditions.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,82 +26,80 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.ExpectedCondition; public class AdditionalConditions { - - public static ExpectedCondition jQueryAJAXCallsHaveCompleted() { - return new ExpectedCondition() { - @Override - public Boolean apply(WebDriver driver) { - return (Boolean) ((JavascriptExecutor)driver). - executeScript("return (window.jQuery!= null) && (jQuery.active === 0);"); - } - }; - } - - public static ExpectedCondition angularHasFinishedProcessing() { - return new ExpectedCondition() { - @Override - public Boolean apply(WebDriver driver) { -// String scriptJS = "return (window.angular !==undefined) &&" -// + " (angular.element(document).injector() !==undefined) &&" -// + " (angular.element(document).injector().get('$http').pendingRequests.length === 0)"; -// return Boolean.valueOf(( (JavascriptExecutor) driver).executeScript(scriptJS).toString()); - new NgWebDriver((JavascriptExecutor) driver).waitForAngularRequestsToFinish(); - return true; - } - }; - } - - public static ExpectedCondition pageLoadWait() { + + private AdditionalConditions() { + + } + + public static ExpectedCondition jQueryAJAXCallsHaveCompleted() { + return new ExpectedCondition() { + @Override + public Boolean apply(WebDriver driver) { + return (Boolean) ((JavascriptExecutor) driver). + executeScript("return (window.jQuery!= null) && (jQuery.active === 0);"); + } + }; + } + + public static ExpectedCondition angularHasFinishedProcessing() { return new ExpectedCondition() { - @Override - public Boolean apply(WebDriver driver) { - String scriptJS = - "try {\r\n" + - " if (document.readyState !== 'complete') {\r\n" + - " return false; // Page not loaded yet\r\n" + - " }\r\n" + - " if (window.jQuery) {\r\n" + - " if (window.jQuery.active) {\r\n" + - " return false;\r\n" + - " } else if (window.jQuery.ajax && window.jQuery.ajax.active) {\r\n" + - " return false;\r\n" + - " }\r\n" + - " }\r\n" + - " if (window.angular) {\r\n" + - " if (!window.qa) {\r\n" + - " // Used to track the render cycle finish after loading is complete\r\n" + - " window.qa = {\r\n" + - " doneRendering: false\r\n" + - " };\r\n" + - " }\r\n" + - " // Get the angular injector for this app (change element if necessary)\r\n" + - " var injector = window.angular.element('body').injector();\r\n" + - " // Store providers to use for these checks\r\n" + - " var $rootScope = injector.get('$rootScope');\r\n" + - " var $http = injector.get('$http');\r\n" + - " var $timeout = injector.get('$timeout');\r\n" + - " // Check if digest\r\n" + - " if ($rootScope.$$phase === '$apply' || $rootScope.$$phase === '$digest' || $http.pendingRequests.length !== 0) {\r\n" + - " window.qa.doneRendering = false;\r\n" + - " return false; // Angular digesting or loading data\r\n" + - " }\r\n" + - " if (!window.qa.doneRendering) {\r\n" + - " // Set timeout to mark angular rendering as finished\r\n" + - " $timeout(function() {\r\n" + - " window.qa.doneRendering = true;\r\n" + - " }, 0);\r\n" + - " return false;\r\n" + - " }\r\n" + - " }\r\n" + - " return true;\r\n" + - "} catch (ex) {\r\n" + - " return false;\r\n" + - "}"; - return Boolean.valueOf(( (JavascriptExecutor) driver).executeScript(scriptJS).toString()); - } + @Override + public Boolean apply(WebDriver driver) { + new NgWebDriver((JavascriptExecutor) driver).waitForAngularRequestsToFinish(); + return true; + } }; - } + } + + public static ExpectedCondition pageLoadWait() { + return new ExpectedCondition() { + @Override + public Boolean apply(WebDriver driver) { + String scriptJS = "try {\n" + + " if (document.readyState !== 'complete') {\r\n" + + " return false; // Page not loaded yet\r\n" + + " }\r\n" + + " if (window.jQuery) {\r\n" + + " if (window.jQuery.active) {\r\n" + + " return false;\r\n" + + " } else if (window.jQuery.ajax && window.jQuery.ajax.active) {\r\n" + + " return false;\r\n" + + " }\r\n" + + " }\r\n" + + " if (window.angular) {\r\n" + + " if (!window.qa) {\r\n" + + " // Used to track the render cycle finish after loading is complete\r\n" + + " window.qa = {\r\n" + + " doneRendering: false\r\n" + + " };\r\n" + + " }\r\n" + + " // Get the angular injector for this app (change element if necessary)\r\n" + + " var injector = window.angular.element('body').injector();\r\n" + + " // Store providers to use for these checks\r\n" + + " var $rootScope = injector.get('$rootScope');\r\n" + + " var $http = injector.get('$http');\r\n" + + " var $timeout = injector.get('$timeout');\r\n" + + " // Check if digest\r\n" + + " if ($rootScope.$$phase === '$apply' || $rootScope.$$phase === '$digest' || $http.pendingRequests.length !== 0) {\r\n" + + " window.qa.doneRendering = false;\r\n" + + " return false; // Angular digesting or loading data\r\n" + + " }\r\n" + + " if (!window.qa.doneRendering) {\r\n" + + " // Set timeout to mark angular rendering as finished\r\n" + + " $timeout(function() {\r\n" + + " window.qa.doneRendering = true;\r\n" + + " }, 0);\r\n" + + " return false;\r\n" + + " }\r\n" + + " }\r\n" + + " return true;\r\n" + + "} catch (ex) {\r\n" + + " return false;\r\n" + + "}"; + return Boolean.valueOf(((JavascriptExecutor) driver).executeScript(scriptJS).toString()); + } + }; + } + - - } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/AdminWorkspaceUIUtilies.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/AdminWorkspaceUIUtilies.java index 2ee7e69d60..100982faee 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/AdminWorkspaceUIUtilies.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/AdminWorkspaceUIUtilies.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,29 +24,30 @@ import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.pages.AdminGeneralPage; public class AdminWorkspaceUIUtilies { - - - public static void createNewUser(String userId, UserRoleEnum userRole){ - AdminGeneralPage.getUserManagementTab().setNewUserBox(userId); - AdminGeneralPage.getUserManagementTab().selectUserRole(userRole); - AdminGeneralPage.getUserManagementTab().clickCreateButton(); - } - - public static void updateUserRole(int rowIndx, UserRoleEnum userRole) { - AdminGeneralPage.getUserManagementTab().updateUser(rowIndx); - AdminGeneralPage.getUserManagementTab().updateUserRole(userRole, rowIndx); - AdminGeneralPage.getUserManagementTab().saveAfterUpdateUser(rowIndx); - } - - public static void deleteFirstRow(){ - AdminGeneralPage.getUserManagementTab().deleteUser(0); - } - - public static void searchForUser(String searchString){ - AdminGeneralPage.getUserManagementTab().searchUser(searchString); - } - + private AdminWorkspaceUIUtilies() { + + } + + public static void createNewUser(String userId, UserRoleEnum userRole) { + AdminGeneralPage.getUserManagementTab().setNewUserBox(userId); + AdminGeneralPage.getUserManagementTab().selectUserRole(userRole); + AdminGeneralPage.getUserManagementTab().clickCreateButton(); + } + + public static void updateUserRole(int rowIndx, UserRoleEnum userRole) { + AdminGeneralPage.getUserManagementTab().updateUser(rowIndx); + AdminGeneralPage.getUserManagementTab().updateUserRole(userRole, rowIndx); + AdminGeneralPage.getUserManagementTab().saveAfterUpdateUser(rowIndx); + } + + public static void deleteFirstRow() { + AdminGeneralPage.getUserManagementTab().deleteUser(0); + } + + public static void searchForUser(String searchString) { + AdminGeneralPage.getUserManagementTab().searchUser(searchString); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java index c3876dc1c9..61a648cbfe 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -248,7 +248,7 @@ public final class ArtifactUIUtils { public static File uploadCreatedUpdateParametersEnvFile(HeatWithParametersDefinition heatEnvDetails, String directoryPath) throws Exception { -// created env file to upload + //created env file to upload File pathToEnvParametersFile = prepareEnvParametersFile(heatEnvDetails, directoryPath); ArtifactInfo heatEnvArtifactInfo = new ArtifactInfo(directoryPath, heatEnvDetails.getHeatEnvLabel() + ".env", "heatEnvDesc", heatEnvDetails.getHeatEnvLabel(), heatEnvDetails.getHeatEnvArtifactType()); ArtifactUIUtils.fillAndAddNewEnvArtifactParameters(heatEnvArtifactInfo, CompositionPage.artifactPopup()); @@ -257,7 +257,7 @@ public final class ArtifactUIUtils { public static File prepareEnvParametersFile(HeatWithParametersDefinition heatEnvDetails, String directoryPath) throws IOException { File pathToEnvParametersFile = FileHandling.createEmptyFile(directoryPath + heatEnvDetails.getHeatEnvLabel() + ".env"); -// fill file + //fill file FileHandling.writeToFile(pathToEnvParametersFile, "parameters:", 0); for (HeatParameterDataDefinition paramDefinition : heatEnvDetails.getHeatParameterDefinition()) { Object data = getDataToWrite(paramDefinition); @@ -268,6 +268,7 @@ public final class ArtifactUIUtils { } public static Object getDataToWrite(HeatParameterDataDefinition paramDefinition) { + final int testNumberParameter = 666; Object data = ""; switch (paramDefinition.getType()) { case "string": @@ -275,7 +276,7 @@ public final class ArtifactUIUtils { data = getFormatedData(paramDefinition.getName(), text); break; case "number": - data = getFormatedData(paramDefinition.getName(), 666); + data = getFormatedData(paramDefinition.getName(), testNumberParameter); break; case "json": String jsonText = "{\"param1\":\"param1\", \"param2\":2}"; @@ -300,6 +301,7 @@ public final class ArtifactUIUtils { public static Map getDataToWriteInUI(List paramDefinitionFromGetResourceResponse) { + final int testNumberParameter = 666; Map newValuesToUpdateInUI = new HashMap<>(); for (HeatParameterDataDefinition param : paramDefinitionFromGetResourceResponse) { switch (param.getType()) { @@ -309,7 +311,7 @@ public final class ArtifactUIUtils { newValuesToUpdateInUI.put(param.getName(), text); break; case "number": - newValuesToUpdateInUI.put(param.getName(), 666); + newValuesToUpdateInUI.put(param.getName(), testNumberParameter); break; case "json": String jsonText = "{\"param1\":\"param1\", \"param2\":2}"; diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/CatalogUIUtilitis.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/CatalogUIUtilitis.java index 56f0b757b8..cdbb2f4bd2 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/CatalogUIUtilitis.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/CatalogUIUtilitis.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,93 +38,98 @@ import java.util.Arrays; import java.util.List; public class CatalogUIUtilitis { - - public static void clickTopMenuButton(TopMenuButtonsEnum button) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s button ...", button.name())); - switch (button) { - case CATALOG: - GeneralUIUtils.getWebElementByTestID(button.getButton()).click(); - break; - case HOME: - GeneralUIUtils.getWebElementByTestID(button.getButton()).click(); - break; - case ON_BOARDING: - GeneralUIUtils.getWebElementByTestID(button.getButton()).click(); - break; - default: - break; - } - GeneralUIUtils.ultimateWait(); - } - - public static String catalogFilterTypeChecBox(TypesEnum enumtype) throws Exception { - String Type = enumtype.toString().toLowerCase(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s ...", Type)); - GeneralUIUtils.getWebElementByTestID(enumtype.getValue()).click(); - return Type; - } - - public static List catalogFilterStatusChecBox(CheckBoxStatusEnum statusEnum){ - List status = null; - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s status", statusEnum.name())); - switch (statusEnum) { - case IN_DESIGN: - status = Arrays.asList("NOT_CERTIFIED_CHECKIN", "NOT_CERTIFIED_CHECKOUT"); - GeneralUIUtils.getWebElementByTestID(statusEnum.getValue()).click(); - break; - case READY_FOR_TESTING: - status = Arrays.asList("READY_FOR_CERTIFICATION"); - GeneralUIUtils.getWebElementByTestID(statusEnum.getValue()).click(); - break; - case IN_TESTING: - status = Arrays.asList("CERTIFICATION_IN_PROGRESS"); - GeneralUIUtils.getWebElementByTestID(statusEnum.getValue()).click(); - break; - case CERTIFIED: - case DISTRIBUTED: - status = Arrays.asList("CERTIFIED"); - GeneralUIUtils.getWebElementByTestID(statusEnum.getValue()).click(); - break; - } - return status; - } + private CatalogUIUtilitis() { - // Get all Categories uniqueID .//The parent categories. - public static List getCategories() throws IOException, JSONException { - List allCategoriesList = new ArrayList<>(); - RestResponse allcategoriesJson = CatalogRestUtils.getAllCategoriesTowardsCatalogBe(); - JSONArray categories = new JSONArray(allcategoriesJson.getResponse()); - for (int i = 0; i < categories.length(); i++) { - String categoryname = (String) categories.getJSONObject(i).get("name"); - allCategoriesList.add(categoryname); - } - return allCategoriesList; - } + } - public static WebElement clickOnUpperCategoryCheckbox() /*throws InterruptedException*/ { - WebElement categoryCheckbox = getCategoryCheckbox(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s category ...", categoryCheckbox.getText())); - categoryCheckbox.click(); - GeneralUIUtils.ultimateWait(); - return categoryCheckbox; - } + public static void clickTopMenuButton(TopMenuButtonsEnum button) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s button ...", button.name())); + switch (button) { + case CATALOG: + GeneralUIUtils.getWebElementByTestID(button.getButton()).click(); + break; + case HOME: + GeneralUIUtils.getWebElementByTestID(button.getButton()).click(); + break; + case ON_BOARDING: + GeneralUIUtils.getWebElementByTestID(button.getButton()).click(); + break; + default: + break; + } + GeneralUIUtils.ultimateWait(); + } - public static WebElement getCategoryCheckbox() { - List categoryCheckboxes = GeneralUIUtils.getElementsByCSS("span[data-tests-id*='category']"); // get all categories and subcategories - return categoryCheckboxes.get(0); - } + public static String catalogFilterTypeChecBox(TypesEnum enumtype) throws Exception { + String Type = enumtype.toString().toLowerCase(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s ...", Type)); + GeneralUIUtils.getWebElementByTestID(enumtype.getValue()).click(); + return Type; + } - public static void clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle leftPanelElement) throws InterruptedException { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", leftPanelElement.name())); - GeneralUIUtils.getElementsByCSS(leftPanelElement.getValue()).forEach(WebElement::click); - } + public static List catalogFilterStatusChecBox(CheckBoxStatusEnum statusEnum) { + List status = null; + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s status", statusEnum.name())); + switch (statusEnum) { + case IN_DESIGN: + status = Arrays.asList("NOT_CERTIFIED_CHECKIN", "NOT_CERTIFIED_CHECKOUT"); + GeneralUIUtils.getWebElementByTestID(statusEnum.getValue()).click(); + break; + case READY_FOR_TESTING: + status = Arrays.asList("READY_FOR_CERTIFICATION"); + GeneralUIUtils.getWebElementByTestID(statusEnum.getValue()).click(); + break; + case IN_TESTING: + status = Arrays.asList("CERTIFICATION_IN_PROGRESS"); + GeneralUIUtils.getWebElementByTestID(statusEnum.getValue()).click(); + break; + case CERTIFIED: + case DISTRIBUTED: + status = Arrays.asList("CERTIFIED"); + GeneralUIUtils.getWebElementByTestID(statusEnum.getValue()).click(); + break; + default: + break; + } + return status; + } - public static WebElement catalogSearchBox(String searchText) { - WebElement searchBox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()); - searchBox.clear(); - searchBox.sendKeys(searchText); - return searchBox; - } + // Get all Categories uniqueID .//The parent categories. + public static List getCategories() throws IOException, JSONException { + List allCategoriesList = new ArrayList<>(); + RestResponse allcategoriesJson = CatalogRestUtils.getAllCategoriesTowardsCatalogBe(); + JSONArray categories = new JSONArray(allcategoriesJson.getResponse()); + for (int i = 0; i < categories.length(); i++) { + String categoryname = (String) categories.getJSONObject(i).get("name"); + allCategoriesList.add(categoryname); + } + return allCategoriesList; + } + + public static WebElement clickOnUpperCategoryCheckbox() /*throws InterruptedException*/ { + WebElement categoryCheckbox = getCategoryCheckbox(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s category ...", categoryCheckbox.getText())); + categoryCheckbox.click(); + GeneralUIUtils.ultimateWait(); + return categoryCheckbox; + } + + public static WebElement getCategoryCheckbox() { + List categoryCheckboxes = GeneralUIUtils.getElementsByCSS("span[data-tests-id*='category']"); // get all categories and subcategories + return categoryCheckboxes.get(0); + } + + public static void clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle leftPanelElement) throws InterruptedException { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", leftPanelElement.name())); + GeneralUIUtils.getElementsByCSS(leftPanelElement.getValue()).forEach(WebElement::click); + } + + public static WebElement catalogSearchBox(String searchText) { + WebElement searchBox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()); + searchBox.clear(); + searchBox.sendKeys(searchText); + return searchBox; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/DownloadManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/DownloadManager.java index b1e8955f3d..1d8d514676 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/DownloadManager.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/DownloadManager.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,35 +30,39 @@ import org.openqa.selenium.WebElement; import java.util.List; public class DownloadManager { - - - /** - * this method download csar file from VSP repository to default browser download directory - * @param vspName - * @throws Exception - */ - public static void downloadCsarByNameFromVSPRepository(String vspName, Boolean isDelete) throws Exception{ - - if(isDelete){ - FileHandling.cleanCurrentDownloadDir(); - } - HomePage.showVspRepository(); - boolean vspFound = HomePage.searchForVSP(vspName); - if (vspFound){ - ExtentTestActions.log(Status.INFO, String.format("Going to downloading VSP %s", vspName)); - List elemenetsFromTable = HomePage.getElemenetsFromTable(); - elemenetsFromTable.get(1).click(); - GeneralUIUtils.waitForLoader(); + + private DownloadManager() { + + } + + /** + * this method download csar file from VSP repository to default browser download directory + * + * @param vspName + * @throws Exception + */ + public static void downloadCsarByNameFromVSPRepository(String vspName, Boolean isDelete) throws Exception { + + if (isDelete) { + FileHandling.cleanCurrentDownloadDir(); + } + HomePage.showVspRepository(); + boolean vspFound = HomePage.searchForVSP(vspName); + if (vspFound) { + ExtentTestActions.log(Status.INFO, String.format("Going to downloading VSP %s", vspName)); + List elemenetsFromTable = HomePage.getElemenetsFromTable(); + elemenetsFromTable.get(1).click(); + GeneralUIUtils.waitForLoader(); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.DOWNLOAD_CSAR.getValue()); - ExtentTestActions.log(Status.INFO, "Succeeded to downloaded CSAR file named " + vspName + " into folder " + SetupCDTest.getWindowTest().getDownloadDirectory()); + ExtentTestActions.log(Status.INFO, "Succeeded to downloaded CSAR file named " + vspName + " into folder " + SetupCDTest.getWindowTest().getDownloadDirectory()); GeneralUIUtils.getElementsByCSS("div[class^='w-sdc-modal-close']").forEach(e -> e.click()); GeneralUIUtils.ultimateWait(); - } - } + } + } + + public static void downloadCsarByNameFromVSPRepository(String vspName, String vspId) throws Exception { + downloadCsarByNameFromVSPRepository(vspName, true); + } - public static void downloadCsarByNameFromVSPRepository(String vspName, String vspId) throws Exception{ - downloadCsarByNameFromVSPRepository(vspName, true); - } - } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java index 35460f6cb2..1ac4a72059 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,9 +31,23 @@ import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; import org.openecomp.sdc.common.util.GeneralUtility; import org.yaml.snakeyaml.Yaml; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; import java.nio.file.Paths; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; @@ -396,14 +410,9 @@ public class FileHandling { } public static boolean isFileDownloaded(String downloadPath, String fileName) { - boolean flag = false; File dir = new File(downloadPath); File[] dir_contents = dir.listFiles(); - for (int i = 0; i < dir_contents.length; i++) { - if (dir_contents[i].getName().equals(fileName)) - return flag = true; - } - return flag; + return Arrays.stream(dir_contents).anyMatch(file -> file.getName().equals(fileName)); } public static String getMD5OfFile(File file) throws IOException { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java index eed25908dd..153b14e175 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,14 +26,21 @@ import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.execute.setup.DriverFactory; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.utils.Utils; -import org.openqa.selenium.*; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.Keys; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.OutputType; +import org.openqa.selenium.TakesScreenshot; +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.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.WebDriverWait; -import java.awt.*; +import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.io.File; @@ -52,10 +59,15 @@ public final class GeneralUIUtils { private static final String DATA_TESTS_ID = "//*[@data-tests-id='%1$s' or @data-test-id='%1$s']"; private static final String COLOR_YELLOW_BORDER_4PX_SOLID_YELLOW = "color: yellow; border: 4px solid yellow;"; - private static int timeOut = (int) (60 * 1.5); + private static final int TIME_OUT = (int) (60 * 1.5); + private static final int WEB_DRIVER_WAIT_TIME_OUT = 10; + private static final int SLEEP_DURATION = 1000; + private static final int MAX_WAITING_PERIOD = 10 * 1000; + private static final int NAP_PERIOD = 100; + private static final int DURATION_FORMATIN = 60; public static int getTimeOut() { - return timeOut; + return TIME_OUT; } /**************** DRIVER ****************/ @@ -100,16 +112,16 @@ public final class GeneralUIUtils { } public static WebElement getWebElementByTestID(String dataTestId) { - return getWebElementByTestID(dataTestId, timeOut); + return getWebElementByTestID(dataTestId, TIME_OUT); } public static WebElement getWebElementByTestID(String dataTestId, int timeout) { WebDriverWait wait = new WebDriverWait(getDriver(), timeout); - return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))); + return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID, dataTestId)))); } public static boolean isWebElementExistByTestId(String dataTestId) { - return getDriver().findElements(By.xpath(String.format(DATA_TESTS_ID,dataTestId))).size() != 0; + return getDriver().findElements(By.xpath(String.format(DATA_TESTS_ID, dataTestId))).size() != 0; } public static boolean isWebElementExistByClass(String className) { @@ -119,7 +131,7 @@ public final class GeneralUIUtils { public static WebElement getInputElement(String dataTestId) { try { ultimateWait(); - return getDriver().findElement(By.xpath(String.format(DATA_TESTS_ID,dataTestId))); + return getDriver().findElement(By.xpath(String.format(DATA_TESTS_ID, dataTestId))); } catch (Exception e) { return null; } @@ -127,12 +139,12 @@ public final class GeneralUIUtils { public static List getInputElements(String dataTestId) { ultimateWait(); - return getDriver().findElements(By.xpath(String.format(DATA_TESTS_ID,dataTestId))); + return getDriver().findElements(By.xpath(String.format(DATA_TESTS_ID, dataTestId))); } public static WebElement getWebElementBy(By by) { - return getWebElementBy(by, timeOut); + return getWebElementBy(by, TIME_OUT); } public static WebElement getWebElementBy(By by, int timeOut) { @@ -154,7 +166,7 @@ public final class GeneralUIUtils { } public static List getWebElementsListBy(By by) { - return getWebElementsListBy(by, timeOut); + return getWebElementsListBy(by, TIME_OUT); } public static List getWebElementsListBy(By by, int timeOut) { @@ -164,15 +176,15 @@ public final class GeneralUIUtils { public static List getWebElementsListByContainTestID(String dataTestId) { try { - WebDriverWait wait = new WebDriverWait(getDriver(), 10); - return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(String.format("//*[contains(@data-tests-id, '%1$s') or contains(@data-test-id, '%1$s')]",dataTestId)))); + WebDriverWait wait = new WebDriverWait(getDriver(), WEB_DRIVER_WAIT_TIME_OUT); + return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(String.format("//*[contains(@data-tests-id, '%1$s') or contains(@data-test-id, '%1$s')]", dataTestId)))); } catch (Exception e) { return new ArrayList(); } } public static List getWebElementsListByContainsClassName(String containedText) { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//*[contains(@class, '" + containedText + "')]"))); } @@ -181,31 +193,31 @@ public final class GeneralUIUtils { } public static WebElement getWebElementByClassName(String className) { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); return wait.until(ExpectedConditions.visibilityOfElementLocated(By.className(className))); } public static List getWebElementsListByTestID(String dataTestId) { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); - return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); + return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(String.format(DATA_TESTS_ID, dataTestId)))); } public static List getWebElementsListByClassName(String className) { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className(className))); } public static Boolean isElementInvisibleByTestId(String dataTestId) { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); return wait.until( - ExpectedConditions.invisibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))); + ExpectedConditions.invisibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID, dataTestId)))); } public static Boolean isElementVisibleByTestId(String dataTestId) { try { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); - return wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath(String.format(DATA_TESTS_ID,dataTestId))))).isDisplayed(); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); + return wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath(String.format(DATA_TESTS_ID, dataTestId))))).isDisplayed(); } catch (Exception e) { return false; } @@ -217,34 +229,34 @@ public final class GeneralUIUtils { } public static void clickOnElementByTestIdWithoutWait(String dataTestId) { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); - wait.until(ExpectedConditions.elementToBeClickable(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))).click(); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); + wait.until(ExpectedConditions.elementToBeClickable(By.xpath(String.format(DATA_TESTS_ID, dataTestId)))).click(); } public static void clickOnElementByInputTestIdWithoutWait(String dataTestId) { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); wait.until(ExpectedConditions.elementToBeClickable(By.xpath(String.format(DATA_TESTS_ID, dataTestId) + "//*"))).click(); } public static void clickOnElementByTestId(String dataTestId, int customTimeout) { WebDriverWait wait = new WebDriverWait(getDriver(), customTimeout); - wait.until(ExpectedConditions.elementToBeClickable(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))).click(); + wait.until(ExpectedConditions.elementToBeClickable(By.xpath(String.format(DATA_TESTS_ID, dataTestId)))).click(); } public static WebElement waitForElementVisibilityByTestId(String dataTestId) { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); - return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); + return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID, dataTestId)))); } public static Boolean waitForElementInVisibilityByTestId(String dataTestId) { - return waitForElementInVisibilityByTestId(dataTestId, timeOut); + return waitForElementInVisibilityByTestId(dataTestId, TIME_OUT); } public static Boolean waitForElementInVisibilityByTestId(String dataTestId, int timeOut) { WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); - boolean displayed = getDriver().findElements(By.xpath(String.format(DATA_TESTS_ID,dataTestId))).isEmpty(); + boolean displayed = getDriver().findElements(By.xpath(String.format(DATA_TESTS_ID, dataTestId))).isEmpty(); if (!displayed) { - Boolean until = wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))); + Boolean until = wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID, dataTestId)))); ultimateWait(); return until; } @@ -252,7 +264,7 @@ public final class GeneralUIUtils { } public static Boolean waitForElementInVisibilityByTestId(By by) { - return waitForElementInVisibilityBy(by, timeOut); + return waitForElementInVisibilityBy(by, TIME_OUT); } @@ -261,7 +273,7 @@ public final class GeneralUIUtils { boolean displayed = getDriver().findElements(by).isEmpty(); if (!displayed) { Boolean until = wait.until(ExpectedConditions.invisibilityOfElementLocated(by)); - sleep(1000); + sleep(SLEEP_DURATION); return until; } return false; @@ -292,11 +304,12 @@ public final class GeneralUIUtils { } public static void waitForLoader() { - waitForLoader(timeOut); + waitForLoader(TIME_OUT); } public static void waitForLoader(int timeOut) { - sleep(500); + final int sleepDuration = 500; + sleep(sleepDuration); waitForElementInVisibilityBy(By.className("tlv-loader"), timeOut); } @@ -372,12 +385,11 @@ public final class GeneralUIUtils { } public static WebElement getElementfromElementByCSS(WebElement parentElement, String cssString) { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); GeneralUIUtils.waitForLoader(); return parentElement.findElement(By.cssSelector(cssString)); } - public static WebElement HighlightMyElement(WebElement element) { + private static WebElement highlightMyElement(WebElement element) { JavascriptExecutor javascript = (JavascriptExecutor) getDriver(); javascript.executeScript("arguments[0].setAttribute('style', arguments[1]);", element, COLOR_YELLOW_BORDER_4PX_SOLID_YELLOW); return element; @@ -385,22 +397,23 @@ public final class GeneralUIUtils { public static WebElement getSelectedElementFromDropDown(String dataTestId) { GeneralUIUtils.ultimateWait(); - return new Select(getDriver().findElement(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))).getFirstSelectedOption(); + return new Select(getDriver().findElement(By.xpath(String.format(DATA_TESTS_ID, dataTestId)))).getFirstSelectedOption(); } public static boolean checkElementsCountInTable(int expectedElementsCount, Supplier> func) { - int maxWaitingPeriodMS = 10 * 1000; - int napPeriodMS = 100; + int maxWaitingPeriodMS = MAX_WAITING_PERIOD; + int napPeriodMS = NAP_PERIOD; int sumOfWaiting = 0; - List elements = null; + List elements; boolean isKeepWaiting = false; while (!isKeepWaiting) { elements = func.get(); isKeepWaiting = (expectedElementsCount == elements.size()); sleep(napPeriodMS); sumOfWaiting += napPeriodMS; - if (sumOfWaiting > maxWaitingPeriodMS) + if (sumOfWaiting > maxWaitingPeriodMS) { return false; + } } return true; } @@ -410,12 +423,11 @@ public final class GeneralUIUtils { func.run(); long estimateTime = System.nanoTime(); long duration = TimeUnit.NANOSECONDS.toSeconds(estimateTime - startTime); - String durationString = String.format("%02d:%02d", duration / 60, duration % 60); - return durationString; + return String.format("%02d:%02d", duration / DURATION_FORMATIN, duration % DURATION_FORMATIN); } public static WebElement clickOnAreaJS(String areaId) { - return clickOnAreaJS(areaId, timeOut); + return clickOnAreaJS(areaId, TIME_OUT); } @@ -424,7 +436,7 @@ public final class GeneralUIUtils { ultimateWait(); WebElement area = getWebElementByTestID(areaId); JavascriptExecutor javascript = (JavascriptExecutor) getDriver(); - //HighlightMyElement(area); + //highlightMyElement(area); Object executeScript = javascript.executeScript("arguments[0].click();", area, COLOR_YELLOW_BORDER_4PX_SOLID_YELLOW); waitForLoader(timeout); ultimateWait(); @@ -438,7 +450,7 @@ public final class GeneralUIUtils { public static WebElement clickOnAreaJS(WebElement areaId) throws InterruptedException { JavascriptExecutor javascript = (JavascriptExecutor) getDriver(); - //HighlightMyElement(area); + //highlightMyElement(area); javascript.executeScript("arguments[0].click();", areaId, COLOR_YELLOW_BORDER_4PX_SOLID_YELLOW); return areaId; } @@ -449,25 +461,26 @@ public final class GeneralUIUtils { } public static void clickOnElementByText(String textInElement) { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); - HighlightMyElement(wait.until( + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); + highlightMyElement(wait.until( ExpectedConditions.elementToBeClickable(findByText(textInElement)))).click(); } public static void clickOnElementByText(String textInElement, int customTimeout) { WebDriverWait wait = new WebDriverWait(getDriver(), customTimeout); - HighlightMyElement(wait.until( + highlightMyElement(wait.until( ExpectedConditions.elementToBeClickable(findByText(textInElement)))).click(); } public static void clickJSOnElementByText(String textInElement) throws Exception { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); clickOnAreaJS(wait.until( ExpectedConditions.elementToBeClickable(findByText(textInElement)))); } public static void waitForAngular() { - WebDriverWait wait = new WebDriverWait(getDriver(), 90, 100); + final int webDriverWaitingTime = 90; + WebDriverWait wait = new WebDriverWait(getDriver(), webDriverWaitingTime, NAP_PERIOD); wait.until(AdditionalConditions.pageLoadWait()); wait.until(AdditionalConditions.angularHasFinishedProcessing()); } @@ -478,7 +491,7 @@ public final class GeneralUIUtils { public static boolean isElementReadOnly(WebElement element) { try { - HighlightMyElement(element).clear(); + highlightMyElement(element).clear(); return false; } catch (Exception e) { return true; @@ -491,8 +504,8 @@ public final class GeneralUIUtils { } public static boolean isElementDisabled(WebElement element) { - return HighlightMyElement(element).getAttribute("class").contains("view-mode") || - element.getAttribute("class").contains("disabled") || element.getAttribute("disabled") != null; + return highlightMyElement(element).getAttribute("class").contains("view-mode") + || element.getAttribute("class").contains("disabled") || element.getAttribute("disabled") != null; } public static boolean isElementDisabled(String dataTestId) { @@ -509,7 +522,7 @@ public final class GeneralUIUtils { long estimateTime = System.nanoTime(); long duration = TimeUnit.NANOSECONDS.toSeconds(estimateTime - startTime); - if (duration > timeOut) { + if (duration > TIME_OUT) { SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Delays on page, %d seconds", duration)); } } @@ -568,7 +581,7 @@ public final class GeneralUIUtils { } public static void clickOnElementByCSS(String cssString) throws Exception { - WebDriverWait wait = new WebDriverWait(getDriver(), timeOut); + WebDriverWait wait = new WebDriverWait(getDriver(), TIME_OUT); wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(cssString))).click(); ultimateWait(); } @@ -579,17 +592,18 @@ public final class GeneralUIUtils { } public static void dragAndDropElementByY(WebElement area, int yOffset) { + final int dragAndDropTimeout = 10; Actions actions = new Actions(getDriver()); - actions.dragAndDropBy(area, 10, yOffset).perform(); + actions.dragAndDropBy(area, dragAndDropTimeout, yOffset).perform(); ultimateWait(); } public static void waitForBackLoader() { - waitForBackLoader(timeOut); + waitForBackLoader(TIME_OUT); } public static void waitForBackLoader(int timeOut) { - sleep(100); + sleep(NAP_PERIOD); waitForElementInVisibilityBy(By.className("tlv-loader-back"), timeOut); } @@ -600,12 +614,14 @@ public final class GeneralUIUtils { } public static boolean checkForDisabledAttributeInHiddenElement(String cssString) { + final int numberOfDisableElements = 3; boolean isDisabled = false; - for (int i = 0; i < 3; i++) { - Object elementAttributes = getAllElementAttributes(getWebElementByPresence(By.cssSelector(cssString), timeOut)); + for (int i = 0; i < numberOfDisableElements; i++) { + Object elementAttributes = getAllElementAttributes(getWebElementByPresence(By.cssSelector(cssString), TIME_OUT)); isDisabled = elementAttributes.toString().contains("disabled"); - if (isDisabled) + if (isDisabled) { break; + } ultimateWait(); } return isDisabled; @@ -643,8 +659,8 @@ public final class GeneralUIUtils { ultimateWait(); } - public static String getTextValueFromWebElementByXpath(String Xpath) { - WebElement webElement = getWebElementBy(By.xpath(Xpath)); + public static String getTextValueFromWebElementByXpath(String xpath) { + WebElement webElement = getWebElementBy(By.xpath(xpath)); return webElement.getAttribute("value"); } @@ -675,49 +691,49 @@ public final class GeneralUIUtils { } public static Object getElementPositionOnCanvas(String elementName) { - String scriptJS = "var cy = window.jQuery('.sdc-composition-graph-wrapper').cytoscape('get');\n" + - "var n = cy.nodes('[name=\"" + elementName + "\"]');\n" + - "var nPos = n.renderedPosition();\n" + - "return JSON.stringify({\n" + - "\tx: nPos.x,\n" + - "\ty: nPos.y\n" + - "})"; + String scriptJS = "var cy = window.jQuery('.sdc-composition-graph-wrapper').cytoscape('get');\n" + + "var n = cy.nodes('[name=\"" + elementName + "\"]');\n" + + "var nPos = n.renderedPosition();\n" + + "return JSON.stringify({\n" + + "\tx: nPos.x,\n" + + "\ty: nPos.y\n" + + "})"; return ((JavascriptExecutor) getDriver()).executeScript(scriptJS); } public static Object getElementGreenDotPositionOnCanvas(String elementName) { - String scriptJS = "var cy = window.jQuery('.sdc-composition-graph-wrapper').cytoscape('get');\n" + - "var cyZoom = cy.zoom();\n" + - "var n = cy.nodes('[name=\"" + elementName + "\"]');\n" + - "var nPos = n.renderedPosition();\n" + - "var nData = n.data();\n" + - "var nImgSize = nData.imgWidth;\n" + - "var shiftSize = (nImgSize-18)*cyZoom/2;\n" + - "return JSON.stringify({\n" + - "\tx: nPos.x + shiftSize,\n" + - "\ty: nPos.y - shiftSize\n" + - "});"; + String scriptJS = "var cy = window.jQuery('.sdc-composition-graph-wrapper').cytoscape('get');\n" + + "var cyZoom = cy.zoom();\n" + + "var n = cy.nodes('[name=\"" + elementName + "\"]');\n" + + "var nPos = n.renderedPosition();\n" + + "var nData = n.data();\n" + + "var nImgSize = nData.imgWidth;\n" + + "var shiftSize = (nImgSize-18)*cyZoom/2;\n" + + "return JSON.stringify({\n" + + "\tx: nPos.x + shiftSize,\n" + + "\ty: nPos.y - shiftSize\n" + + "});"; return ((JavascriptExecutor) getDriver()).executeScript(scriptJS); - } - - public static Long getAndValidateActionDuration (Runnable action, int regularTestRunTime){ - Long actualTestRunTime = null; - try { - actualTestRunTime = Utils.getActionDuration(() -> { - try { - action.run(); - } catch (Throwable throwable) { - throwable.printStackTrace(); - } - }); - } catch (Exception e) { - e.printStackTrace(); - } - double factor = 1.5; - - assertTrue("Expected test run time should be less than " + regularTestRunTime*factor + ", " + - "actual time is " + actualTestRunTime , regularTestRunTime*factor>actualTestRunTime); -// SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + actualTestRunTime + " seconds"); - return actualTestRunTime; + } + + public static Long getAndValidateActionDuration(Runnable action, int regularTestRunTime) { + Long actualTestRunTime = null; + try { + actualTestRunTime = Utils.getActionDuration(() -> { + try { + action.run(); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + final double factor = 1.5; + + assertTrue("Expected test run time should be less than " + regularTestRunTime * factor + ", " + + "actual time is " + actualTestRunTime, regularTestRunTime * factor > actualTestRunTime); + //SetupCDTest.getExtendTest().log(Status.INFO, "Actual catalog loading time is " + actualTestRunTime + " seconds"); + return actualTestRunTime; } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/HomeUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/HomeUtils.java index 512e63a4ee..61a5e7b542 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/HomeUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/HomeUtils.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUiUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUiUtils.java index 6a91ed7c77..bbcfffd22b 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUiUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUiUtils.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,12 @@ package org.openecomp.sdc.ci.tests.utilities; import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; +import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.execute.devCI.ArtifactFromCsar; import org.openecomp.sdc.ci.tests.execute.setup.ArtifactsCorrelationManager; import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; @@ -30,12 +35,12 @@ import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; import org.openecomp.sdc.ci.tests.pages.GeneralPageElements; import org.openecomp.sdc.ci.tests.pages.HomePage; import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.openqa.selenium.WebElement; import org.testng.Assert; -import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; import java.io.File; import java.util.LinkedList; @@ -46,6 +51,8 @@ import java.util.stream.Collectors; public class OnboardingUiUtils { + private static final int WAITING_FOR_LOADER_TIME_OUT = 60 * 10; + private static void importUpdateVSP(VendorSoftwareProductObject vsp, boolean isUpdate, boolean restore) throws Exception { String vspName = vsp.getName(); boolean vspFound = HomePage.searchForVSP(vspName); @@ -66,7 +73,7 @@ public class OnboardingUiUtils { doCheckOut(); //Metadata verification onboardedVnfMetadataVerification(vsp, isUpdate); - String duration = GeneralUIUtils.getActionDuration(() -> waitUntilVnfCreated()); + String duration = GeneralUIUtils.getActionDuration(OnboardingUiUtils::waitUntilVnfCreated); ExtentTestActions.log(Status.INFO, "Succeeded in importing/updating " + vspName, duration); } else { Assert.fail("Did not find VSP named " + vspName); @@ -81,11 +88,11 @@ public class OnboardingUiUtils { } } - public static boolean getVspValidationCongiguration() throws Exception{ + public static boolean getVspValidationCongiguration() throws Exception { return Boolean.parseBoolean(OnboardingUtils.getVspValidationConfiguration()); } - public static boolean putVspValidationCongiguration(boolean value) throws Exception{ + public static boolean putVspValidationCongiguration(boolean value) throws Exception { return Boolean.parseBoolean(OnboardingUtils.putVspValidationConfiguration(value)); } @@ -108,7 +115,7 @@ public class OnboardingUiUtils { ExtentTestActions.log(Status.INFO, "Clicking create/update VNF"); GeneralUIUtils.ultimateWait(); GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); - GeneralUIUtils.waitForLoader(60 * 10); + GeneralUIUtils.waitForLoader(WAITING_FOR_LOADER_TIME_OUT); GeneralUIUtils.ultimateWait(); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/PortMirroringUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/PortMirroringUtils.java index ccea6d0230..a3f8a5c2c1 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/PortMirroringUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/PortMirroringUtils.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,8 +23,24 @@ package org.openecomp.sdc.ci.tests.utilities; import com.aventstack.extentreports.Status; import fj.data.Either; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -import org.openecomp.sdc.be.model.*; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.InputDefinition; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; +import org.openecomp.sdc.ci.tests.datatypes.CanvasElement; +import org.openecomp.sdc.ci.tests.datatypes.CanvasManager; +import org.openecomp.sdc.ci.tests.datatypes.ConnectionWizardPopUpObject; +import org.openecomp.sdc.ci.tests.datatypes.PortMirrioringConfigurationObject; +import org.openecomp.sdc.ci.tests.datatypes.PortMirroringEnum; +import org.openecomp.sdc.ci.tests.datatypes.PropertyObject; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceContainer; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; @@ -32,8 +48,12 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.pages.CompositionPage; import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; -import org.openecomp.sdc.ci.tests.utils.general.*; +import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.general.FileHandling; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; +import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils; import java.util.List; @@ -42,8 +62,14 @@ import java.util.Map; public class PortMirroringUtils { + private static final int WAITING_FOR_LOADER_TIME_OUT = 2000; + + private PortMirroringUtils() { + + } + public static ServiceContainer createServiceFromHeatFile(String filePath, String vnfFile) throws Throwable { -// 1. Import VSP v1.0 +//1. Import VSP v1.0 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName())); @@ -51,13 +77,13 @@ public class PortMirroringUtils { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile)); VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers); // VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct); -// 2. Create VF, certify - v1.0 is created +//2. Create VF, certify - v1.0 is created resourceReqDetails = org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Certify the VF")); -// 3. Create Service add to it the certified VF and certify the Service v1.0 +//3. Create Service add to it the certified VF and certify the Service v1.0 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); @@ -70,28 +96,28 @@ public class PortMirroringUtils { return new ServiceContainer(service, resource, vendorSoftwareProductObject, amdocsLicenseMembers); } - public static Resource GeneratePNFAndUpdateInput(String resourceName, String vendorModelNumber, User user) throws Exception { - Resource resource = getResourceByType(ResourceTypeEnum.PNF, resourceName, vendorModelNumber); + public static Resource generatePNFAndUpdateInput(String resourceName, String vendorModelNumber, User user) throws Exception { + Resource resource = getresourcebytype(ResourceTypeEnum.PNF, resourceName, vendorModelNumber); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating pnf %s and certify it", resource.getName())); Component componentObject = AtomicOperationUtils.getComponentObject(resource, UserRoleEnum.DESIGNER); - UpdateResourceInputViaAPI(user, componentObject, "physicalProbe", "nf_role"); + updateResourceInputViaAPI(user, componentObject, "physicalProbe", "nf_role"); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); return resource; } - private static void UpdateResourceInputViaAPI(User user, Component componentObject, String defaultValue, String inputName) throws Exception { + private static void updateResourceInputViaAPI(User user, Component componentObject, String defaultValue, String inputName) throws Exception { List componentInputs = componentObject.getInputs(); PropertyObject propertyObject = new PropertyObject(defaultValue, inputName, componentInputs.get(1).getParentUniqueId(), componentInputs.get(1).getUniqueId()); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Update input %s to %s", "nf_role", "physicalProbe")); PropertyRestUtils.updateInput(componentObject, propertyObject, user); } - public static Resource getResourceByType(ResourceTypeEnum resourceTypeEnum, String resourceName, String vendorModelNumber) { + public static Resource getresourcebytype(ResourceTypeEnum resourceTypeEnum, String resourceName, String vendorModelNumber) { ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(resourceTypeEnum, resourceName, ResourceCategoryEnum.NETWORK_L2_3_INFRASTRUCTURE, resourceName, vendorModelNumber); return AtomicOperationUtils.createResourceByResourceDetails(resourceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); } - public static String createProxyInstanceServiceName(String serviceName, String instanceId) { + public static String createproxyinstanceservicename(String serviceName, String instanceId) { String serviceProxyInstanceName = String.format("%s_proxy %s", serviceName, instanceId); return serviceProxyInstanceName; } @@ -132,13 +158,13 @@ public class PortMirroringUtils { PortMirroringEnum.PM_REQ_TYPE.getValue(), PortMirroringEnum.PMC_COLLECTOR_CAP.getValue()); Map capPropValues1 = null; - if(isCapPropAssign){ - capPropValues1 = canvasManager.linkElementsWithCapPropAssignment(serviceElementVmmeSourceName, portMirroringConfigurationElement, connectionWizardPopUpObjectVMME); - GeneralUIUtils.waitForLoader(2000); - canvasManager.linkElementsWithCapPropAssignment(serviceElementVprobeCollector, portMirroringConfigurationElement, connectionWizardPopUpObjectVProbe);} - else { - canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationElement, connectionWizardPopUpObjectVMME); - canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVprobeCollector, portMirroringConfigurationElement, connectionWizardPopUpObjectVProbe); + if (isCapPropAssign) { + capPropValues1 = canvasManager.linkElementsWithCapPropAssignment(serviceElementVmmeSourceName, portMirroringConfigurationElement, connectionWizardPopUpObjectVMME); + GeneralUIUtils.waitForLoader(WAITING_FOR_LOADER_TIME_OUT); + canvasManager.linkElementsWithCapPropAssignment(serviceElementVprobeCollector, portMirroringConfigurationElement, connectionWizardPopUpObjectVProbe); + } else { + canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationElement, connectionWizardPopUpObjectVMME); + canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVprobeCollector, portMirroringConfigurationElement, connectionWizardPopUpObjectVProbe); } @@ -146,8 +172,9 @@ public class PortMirroringUtils { vprobeSourceName, canvasManager, serviceElementVmmeSourceName, serviceElementVprobeCollector, service, portMirroringConfigurationElement, serviceContainerVmme_Source.getService(), serviceContainerVprobe_Collector.getService()); - if(capPropValues1!=null) - portMirrioringConfigurationObject.setCapPropValues(capPropValues1); + if (capPropValues1 != null) { + portMirrioringConfigurationObject.setCapPropValues(capPropValues1); + } return portMirrioringConfigurationObject; } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ProductUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ProductUIUtils.java index bde3340c6e..63ff158d24 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ProductUIUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ProductUIUtils.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,62 +32,60 @@ import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import java.awt.*; import java.util.List; /** * @author al714h - * */ public class ProductUIUtils { - protected static WebDriver driver; + protected static WebDriver driver; + + private ProductUIUtils() { + super(); + } + + private static void fillProductGeneralPage(ProductReqDetails product, User user) throws Exception { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Fill in metadata values in general page.. ")); + ProductGeneralPage.defineName(product.getName()); + ProductGeneralPage.defineFullName(product.getFullName()); + ProductGeneralPage.defineDescription(product.getDescription()); + ProductGeneralPage.defineProjectCode(product.getProjectCode()); + defineTagsList2(product.getTags()); + ProductGeneralPage.defineContactId(product.getContactId()); + GeneralUIUtils.clickSomewhereOnPage(); + } + + public static void createProduct(ProductReqDetails product, User user) throws Exception { + clikAddProduct(); + fillProductGeneralPage(product, user); + GeneralPageElements.clickCreateButton(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Product %s created", product.getName())); + } - public ProductUIUtils(TestName name, String className) { - super(); - } + private static void defineTagsList2(List productTags) { + WebElement productTagsTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.TAGS.getValue()); + for (String tag : productTags) { + productTagsTextbox.clear(); + productTagsTextbox.sendKeys(tag); + GeneralUIUtils.waitForAngular(); + productTagsTextbox.sendKeys(Keys.ENTER); + } + } - public static void fillProductGeneralPage(ProductReqDetails product, User user) throws Exception { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Fill in metadata values in general page.. ")); - ProductGeneralPage.defineName(product.getName()); - ProductGeneralPage.defineFullName(product.getFullName()); - ProductGeneralPage.defineDescription(product.getDescription()); - ProductGeneralPage.defineProjectCode(product.getProjectCode()); - defineTagsList2(product.getTags()); - ProductGeneralPage.defineContactId(product.getContactId()); - GeneralUIUtils.clickSomewhereOnPage(); - } - - public static void createProduct(ProductReqDetails product, User user) throws Exception, AWTException { - clikAddProduct(); - fillProductGeneralPage(product, user); - GeneralPageElements.clickCreateButton(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Product %s created", product.getName())); - } - - public static void defineTagsList2(List productTags){ - WebElement productTagsTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ProductMetadataEnum.TAGS.getValue()); - for (String tag : productTags) { - productTagsTextbox.clear(); - productTagsTextbox.sendKeys(tag); - GeneralUIUtils.waitForAngular(); - productTagsTextbox.sendKeys(Keys.ENTER); - } - } - - public static void clikAddProduct(){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking Add Product button")); - try { - GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.ADD_AREA.getValue()); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_PRODUCT.getValue()).click(); - GeneralUIUtils.ultimateWait(); - } catch (Exception e){ - SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exception on catched on Add Product button, retrying ...")); - GeneralUIUtils.hoverOnAreaByClassName("w-sdc-dashboard-card-new"); - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_PRODUCT.getValue()).click(); - GeneralUIUtils.ultimateWait(); - } - } + private static void clikAddProduct() { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking Add Product button")); + try { + GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.ADD_AREA.getValue()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_PRODUCT.getValue()).click(); + GeneralUIUtils.ultimateWait(); + } catch (Exception e) { + SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exception on catched on Add Product button, retrying ...")); + GeneralUIUtils.hoverOnAreaByClassName("w-sdc-dashboard-card-new"); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_PRODUCT.getValue()).click(); + GeneralUIUtils.ultimateWait(); + } + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/PropertiesUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/PropertiesUIUtils.java index 7eb4e63ab3..609b18eaeb 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/PropertiesUIUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/PropertiesUIUtils.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,65 +31,67 @@ import java.util.Map; public class PropertiesUIUtils { - public static Map addProperties(String name, String itemType, String defaultValue, - String description, String schemaType) throws Exception { - Map propertyvalues = new HashMap(); - GeneralUIUtils.getSelectList(itemType, "propertyType"); - ResourceUIUtils.definePropertyName(name); - if (itemType == "boolean") { - ResourceUIUtils.defineBoolenDefaultValue(defaultValue); - GeneralUIUtils.setWebElementByTestId("description","description"); - Thread.sleep(2000); - GeneralUIUtils.getWebElementByTestID("Add").click(); - } else if (itemType == "list" || itemType == "map") { - GeneralUIUtils.getSelectList(schemaType, "schemaType"); - } - if (!(itemType == "boolean")) { - ResourceUIUtils.defineDefaultValueByType(defaultValue); - GeneralUIUtils.setWebElementByTestId("description", "des"); - GeneralUIUtils.getWebElementByTestID("Add").click(); - Thread.sleep(2000); - } - propertyvalues.put("type", itemType); - propertyvalues.put("defaultValue", defaultValue); - propertyvalues.put("description", description); - propertyvalues.put("name", name); + private static final int SLEEP_TIME = 2000; - return propertyvalues; - } + public static Map addProperties(String name, String itemType, String defaultValue, + String description, String schemaType) throws Exception { + Map propertyvalues = new HashMap(); + GeneralUIUtils.getSelectList(itemType, "propertyType"); + ResourceUIUtils.definePropertyName(name); + if (itemType == "boolean") { + ResourceUIUtils.defineBoolenDefaultValue(defaultValue); + GeneralUIUtils.setWebElementByTestId("description", "description"); + Thread.sleep(SLEEP_TIME); + GeneralUIUtils.getWebElementByTestID("Add").click(); + } else if (itemType == "list" || itemType == "map") { + GeneralUIUtils.getSelectList(schemaType, "schemaType"); + } + if (!(itemType == "boolean")) { + ResourceUIUtils.defineDefaultValueByType(defaultValue); + GeneralUIUtils.setWebElementByTestId("description", "des"); + GeneralUIUtils.getWebElementByTestID("Add").click(); + Thread.sleep(SLEEP_TIME); + } + propertyvalues.put("type", itemType); + propertyvalues.put("defaultValue", defaultValue); + propertyvalues.put("description", description); + propertyvalues.put("name", name); - public static void vlidateProperties(Map propertyValues) throws InterruptedException { - WebElement name = GeneralUIUtils.getWebElementByTestID(propertyValues.get("name")); - name.getText().equalsIgnoreCase(propertyValues.get("name")); - WebElement defaultValue = GeneralUIUtils.getWebElementByTestID(propertyValues.get("name")); - defaultValue.getText().equalsIgnoreCase(propertyValues.get("defaultValue")); - WebElement type = GeneralUIUtils.getWebElementByTestID(propertyValues.get("type")); - type.getText().equalsIgnoreCase(propertyValues.get("type")); - } + return propertyvalues; + } - public static void addNewProperty(PropertyTypeEnum property) { - GeneralUIUtils.ultimateWait(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding new %s property", property.name())); - PropertiesPage.clickAddPropertyArtifact(); - PropertiesPage.getPropertyPopup().insertPropertyName(property.getName()); - PropertiesPage.getPropertyPopup().selectPropertyType(property.getType()); - PropertiesPage.getPropertyPopup().insertPropertyDescription(property.getDescription()); - PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(property.getValue()); - PropertiesPage.getPropertyPopup().clickSave(); - } - - public static void updateProperty(PropertyTypeEnum property) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating property: %s", property.name())); - PropertiesPage.clickOnProperty(property.getName()); - PropertiesPage.getPropertyPopup().insertPropertyDescription(property.getUpdateDescription()); - PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(property.getUpdateValue()); - PropertiesPage.getPropertyPopup().clickSave(); - } - - public static void changePropertyDefaultValueInComposition(String propertyName, String defaultValue) { - GeneralUIUtils.clickOnElementByTestId(propertyName); - PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(defaultValue); - PropertiesPage.getPropertyPopup().clickSave(); - } + public static void vlidateProperties(Map propertyValues) throws InterruptedException { + WebElement name = GeneralUIUtils.getWebElementByTestID(propertyValues.get("name")); + name.getText().equalsIgnoreCase(propertyValues.get("name")); + WebElement defaultValue = GeneralUIUtils.getWebElementByTestID(propertyValues.get("name")); + defaultValue.getText().equalsIgnoreCase(propertyValues.get("defaultValue")); + WebElement type = GeneralUIUtils.getWebElementByTestID(propertyValues.get("type")); + type.getText().equalsIgnoreCase(propertyValues.get("type")); + } + + public static void addNewProperty(PropertyTypeEnum property) { + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding new %s property", property.name())); + PropertiesPage.clickAddPropertyArtifact(); + PropertiesPage.getPropertyPopup().insertPropertyName(property.getName()); + PropertiesPage.getPropertyPopup().selectPropertyType(property.getType()); + PropertiesPage.getPropertyPopup().insertPropertyDescription(property.getDescription()); + PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(property.getValue()); + PropertiesPage.getPropertyPopup().clickSave(); + } + + public static void updateProperty(PropertyTypeEnum property) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating property: %s", property.name())); + PropertiesPage.clickOnProperty(property.getName()); + PropertiesPage.getPropertyPopup().insertPropertyDescription(property.getUpdateDescription()); + PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(property.getUpdateValue()); + PropertiesPage.getPropertyPopup().clickSave(); + } + + public static void changePropertyDefaultValueInComposition(String propertyName, String defaultValue) { + GeneralUIUtils.clickOnElementByTestId(propertyName); + PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(defaultValue); + PropertiesPage.getPropertyPopup().clickSave(); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java index 916b58a834..1937785326 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ResourceUIUtils.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -48,348 +48,349 @@ import java.util.List; import java.util.Random; 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() { - } - - static WebDriver driver = GeneralUIUtils.getDriver(); - - // click and upload tosca file //**to be changed. - public static void importFileWithSendKey(String FilePath, String FileName, CreateAndImportButtonsEnum type) - throws Exception { - WebElement importButton = HomeUtils.createAndImportButtons(type, driver).findElement(By.tagName("input")); - importButton.sendKeys(FilePath + FileName); - } - - public static String defineUserId(String userId) { - // - WebElement resourceUserIdTextbox = ResourceGeneralPage.getContactIdField(); - resourceUserIdTextbox.clear(); - resourceUserIdTextbox.sendKeys(userId); - return userId; - } - - public static String definePropertyName(String name) { - - WebElement nameProperty = GeneralUIUtils.getDriver().findElement(By.name("propertyName")); - nameProperty.sendKeys(name); - return name; - } - - public static void selectRandomResourceIcon() throws Exception { - GeneralUIUtils.moveToStep(StepsEnum.ICON); - WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 4); - wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(@data-tests-id, 'iconBox')]"))); - List iconElement = GeneralUIUtils.getDriver() - .findElements(By.xpath("//*[contains(@data-tests-id, 'iconBox')]")); - iconElement.get(0).click(); - } - - public static void defineDefaultValueByType(String Value) { - - WebElement valueString = GeneralUIUtils.getDriver().findElement(By.name("value")); - valueString.clear(); - valueString.sendKeys(Value); - } - - public static void defineBoolenDefaultValue(String Value) { - - WebElement elementBoolean = GeneralUIUtils.getDriver().findElement(By.name("value")); - Select se = new Select(elementBoolean); - se.selectByValue(Value); - } - - public static void fillResourceGeneralInformationPage(ResourceReqDetails resource, User user, boolean isNewResource) { - try { - ResourceGeneralPage.defineName(resource.getName()); - ResourceGeneralPage.defineDescription(resource.getDescription()); - ResourceGeneralPage.defineCategory(resource.getCategories().get(0).getSubcategories().get(0).getName()); - ResourceGeneralPage.defineVendorName(resource.getVendorName()); - ResourceGeneralPage.defineVendorRelease(resource.getVendorRelease()); - if (isNewResource){ - ResourceGeneralPage.defineTagsList(resource, new String[] { "This-is-tag", "another-tag", "Test-automation-tag" }); - } - else{ - ResourceGeneralPage.defineTagsList(resource, new String[] { "one-more-tag" }); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static void fillMaxValueResourceGeneralInformationPage(ResourceReqDetails resource) { - String stringPattern = "ABCDabcd123456"; - GeneralUIUtils.addStringtoClipboard(buildStringFromPattern(stringPattern, 5000)); - ResourceGeneralPage.defineNameWithPaste(); - ResourceGeneralPage.defineDescriptionWithPaste(); - ResourceGeneralPage.defineVendorNameWithPaste(); - ResourceGeneralPage.defineVendorReleaseWithPaste(); - ResourceGeneralPage.defineTagsListWithPaste(); - GeneralUIUtils.waitForAngular(); - } - - public static String buildStringFromPattern(String stringPattern, int stringLength){ - char[] chars = stringPattern.toCharArray(); - StringBuilder sb = new StringBuilder(); - Random random = new Random(); - for (int i = 0; i < stringLength; i++) { - char c = chars[random.nextInt(chars.length)]; - sb.append(c); - } - return sb.toString(); - } - - /** - * @deprecated Use {@link #createVF(ResourceReqDetails,User)} instead - */ - public static void createResource(ResourceReqDetails resource, User user) throws Exception { - createVF(resource, user); - } - - public static void createVF(ResourceReqDetails resource, User user) throws Exception { - ExtentTestActions.log(Status.INFO, "Going to create a new VF."); - createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_VF); - } - - public static void createResource(ResourceReqDetails resource, User user, DataTestIdEnum.Dashboard button) { - WebElement addVFButton; + 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 static final int BASIC_TIMEOUT = 10 * 60; + + private ResourceUIUtils() { + } + + private static WebDriver driver = GeneralUIUtils.getDriver(); + + // click and upload tosca file //**to be changed. + public static void importFileWithSendKey(String filePath, String fileName, CreateAndImportButtonsEnum type) + throws Exception { + WebElement importButton = HomeUtils.createAndImportButtons(type, driver).findElement(By.tagName("input")); + importButton.sendKeys(filePath + fileName); + } + + public static String defineUserId(String userId) { + // + WebElement resourceUserIdTextbox = ResourceGeneralPage.getContactIdField(); + resourceUserIdTextbox.clear(); + resourceUserIdTextbox.sendKeys(userId); + return userId; + } + + static String definePropertyName(String name) { + + WebElement nameProperty = GeneralUIUtils.getDriver().findElement(By.name("propertyName")); + nameProperty.sendKeys(name); + return name; + } + + public static void selectRandomResourceIcon() throws Exception { + final int webDriverWaitingTimeout = 4; + GeneralUIUtils.moveToStep(StepsEnum.ICON); + WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), webDriverWaitingTimeout); + wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(@data-tests-id, 'iconBox')]"))); + List iconElement = GeneralUIUtils.getDriver() + .findElements(By.xpath("//*[contains(@data-tests-id, 'iconBox')]")); + iconElement.get(0).click(); + } + + static void defineDefaultValueByType(String value) { + + WebElement valueString = GeneralUIUtils.getDriver().findElement(By.name("value")); + valueString.clear(); + valueString.sendKeys(value); + } + + static void defineBoolenDefaultValue(String value) { + + WebElement elementBoolean = GeneralUIUtils.getDriver().findElement(By.name("value")); + Select se = new Select(elementBoolean); + se.selectByValue(value); + } + + public static void fillResourceGeneralInformationPage(ResourceReqDetails resource, User user, boolean isNewResource) { + try { + ResourceGeneralPage.defineName(resource.getName()); + ResourceGeneralPage.defineDescription(resource.getDescription()); + ResourceGeneralPage.defineCategory(resource.getCategories().get(0).getSubcategories().get(0).getName()); + ResourceGeneralPage.defineVendorName(resource.getVendorName()); + ResourceGeneralPage.defineVendorRelease(resource.getVendorRelease()); + if (isNewResource) { + ResourceGeneralPage.defineTagsList(resource, new String[]{"This-is-tag", "another-tag", "Test-automation-tag"}); + } else { + ResourceGeneralPage.defineTagsList(resource, new String[]{"one-more-tag"}); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public static void fillMaxValueResourceGeneralInformationPage(ResourceReqDetails resource) { + final int stringPatternLength = 5000; + String stringPattern = "ABCDabcd123456"; + GeneralUIUtils.addStringtoClipboard(buildStringFromPattern(stringPattern, stringPatternLength)); + ResourceGeneralPage.defineNameWithPaste(); + ResourceGeneralPage.defineDescriptionWithPaste(); + ResourceGeneralPage.defineVendorNameWithPaste(); + ResourceGeneralPage.defineVendorReleaseWithPaste(); + ResourceGeneralPage.defineTagsListWithPaste(); + GeneralUIUtils.waitForAngular(); + } + + public static String buildStringFromPattern(String stringPattern, int stringLength) { + char[] chars = stringPattern.toCharArray(); + StringBuilder sb = new StringBuilder(); + Random random = new Random(); + for (int i = 0; i < stringLength; i++) { + char c = chars[random.nextInt(chars.length)]; + sb.append(c); + } + return sb.toString(); + } + + /** + * @deprecated Use {@link #createVF(ResourceReqDetails, User)} instead + */ + public static void createResource(ResourceReqDetails resource, User user) throws Exception { + createVF(resource, user); + } + + public static void createVF(ResourceReqDetails resource, User user) throws Exception { + ExtentTestActions.log(Status.INFO, "Going to create a new VF."); + createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_VF); + } + + private static void createResource(ResourceReqDetails resource, User user, DataTestIdEnum.Dashboard button) { + WebElement addVFButton; + try { + GeneralUIUtils.ultimateWait(); + try { + GeneralUIUtils.hoverOnAreaByClassName("w-sdc-dashboard-card-new"); + addVFButton = GeneralUIUtils.getWebElementByTestID(button.getValue()); + } catch (Exception e) { + File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resource.getName()); + final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); + SetupCDTest.getExtendTest().log(Status.WARNING, "Add button is not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath)); + showButtonsADD(); + addVFButton = GeneralUIUtils.getWebElementByTestID(button.getValue()); + } + addVFButton.click(); + GeneralUIUtils.ultimateWait(); + } catch (Exception e) { + SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on ADD button, retrying ... ")); + GeneralUIUtils.hoverOnAreaByClassName("w-sdc-dashboard-card-new"); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.getWebElementByTestID(button.getValue()).click(); + GeneralUIUtils.ultimateWait(); + } + fillResourceGeneralInformationPage(resource, user, true); + resource.setVersion("0.1"); + GeneralPageElements.clickCreateButton(); + } + + public static void updateResource(ResourceReqDetails resource, User user) { + ResourceGeneralPage.defineContactId(resource.getContactId()); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating General screen fields ...")); + fillResourceGeneralInformationPage(resource, user, false); + ResourceGeneralPage.clickUpdateButton(); + } + + /** + * Click on HTML element. + * + * @param dataTestId + * @throws Exception + */ + public static void getWebElementByTestID(String dataTestId) throws Exception { + final int webDriverWaitingTimeout = 20; + WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), webDriverWaitingTimeout); + WebElement element = wait + .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))); + element.click(); + // wait.until(ExpectedConditions.elemetto) + // WebElement serviceButton = + // GeneralUIUtils.getDriver().findElement(By.xpath("//*[@data-tests-id='" + // + dataTestId + "']")); + // serviceButton. + // serviceButton.click(); + } + + /** + * Import VFC + * + * @param user + * @param filePath + * @param fileName + * @return + * @throws Exception + */ + + public static void importVfc(ResourceReqDetails resourceMetaData, String filePath, String fileName, User user) + throws Exception { + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating new VFC resource ", resourceMetaData.getName())); + GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue()); + GeneralUIUtils.ultimateWait(); + // Insert file to the browse dialog + WebElement buttonVFC = GeneralUIUtils.findByText("Import VFC"); + WebElement fileInputElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VFC_FILE.getValue()); + if (!buttonVFC.isDisplayed()) { + File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resourceMetaData.getName()); + final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); + SetupCDTest.getExtendTest().log(Status.WARNING, "VFC button not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath)); + } try { - GeneralUIUtils.ultimateWait(); - try{ - GeneralUIUtils.hoverOnAreaByClassName("w-sdc-dashboard-card-new"); - addVFButton = GeneralUIUtils.getWebElementByTestID(button.getValue()); - } - catch (Exception e){ - File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resource.getName()); - final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); - SetupCDTest.getExtendTest().log(Status.WARNING, "Add button is not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath)); - showButtonsADD(); - addVFButton = GeneralUIUtils.getWebElementByTestID(button.getValue()); - } - addVFButton.click(); - GeneralUIUtils.ultimateWait(); - } - catch (Exception e ) { - SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on ADD button, retrying ... ")); - GeneralUIUtils.hoverOnAreaByClassName("w-sdc-dashboard-card-new"); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.getWebElementByTestID(button.getValue()).click(); - GeneralUIUtils.ultimateWait(); + fileInputElement.sendKeys(filePath + fileName); + } catch (ElementNotVisibleException e) { + SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on file input, converting VFC file input to visible")); + showButtons(); + fileInputElement.sendKeys(filePath + fileName); + } + // Fill the general page fields. + GeneralUIUtils.ultimateWait(); + fillResourceGeneralInformationPage(resourceMetaData, user, true); + GeneralPageElements.clickCreateButton(); + } + + public static void importVfcNoCreate(ResourceReqDetails resourceMetaData, String filePath, String fileName, User user) + throws Exception { + GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue()); + // Insert file to the browse dialog + WebElement buttonVFC = GeneralUIUtils.findByText("Import VFC"); + WebElement fileInputElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VFC_FILE.getValue()); + if (!buttonVFC.isDisplayed()) { + File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resourceMetaData.getName()); + final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); + SetupCDTest.getExtendTest().log(Status.WARNING, "VFC button not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath)); + } + try { + fileInputElement.sendKeys(filePath + fileName); + } catch (ElementNotVisibleException e) { + SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on file input, converting VFC file input to visible")); + showButtons(); + fileInputElement.sendKeys(filePath + fileName); + } + // Fill the general page fields. + GeneralUIUtils.waitForLoader(); + fillResourceGeneralInformationPage(resourceMetaData, user, true); + } + + + public static void importVfFromCsar(ResourceReqDetails resourceMetaData, String filePath, String fileName, User user) + throws Exception { + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating new VF asset resource %s", resourceMetaData.getName())); + GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue()); + GeneralUIUtils.ultimateWait(); + // Insert file to the browse dialog + WebElement buttonDCAE = GeneralUIUtils.findByText("Import DCAE asset"); + WebElement fileInputElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VF_FILE.getValue()); + if (!buttonDCAE.isDisplayed()) { + File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resourceMetaData.getName()); + final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); + SetupCDTest.getExtendTest().log(Status.WARNING, "DCAE button not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath)); + } + try { + fileInputElement.sendKeys(filePath + fileName); + } catch (ElementNotVisibleException e) { + SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on file input, converting DCAE file input to visible")); + showButtons(); + fileInputElement.sendKeys(filePath + fileName); + } + // Fill the general page fields. + GeneralUIUtils.ultimateWait(); + fillResourceGeneralInformationPage(resourceMetaData, user, true); + GeneralPageElements.clickCreateButton(BASIC_TIMEOUT); + //GeneralUIUtils.ultimateWait(); "don't change import of csar can take longer then 3 minutes" + GeneralUIUtils.waitForLoader(BASIC_TIMEOUT); + } + + public static void importVfFromCsarNoCreate(ResourceReqDetails resourceMetaData, String filePath, String fileName, User user) + throws Exception { + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating new VF asset resource %s, Create button will not be clicked", resourceMetaData.getName())); + GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue()); + GeneralUIUtils.ultimateWait(); + // Insert file to the browse dialog + WebElement buttonDCAE = GeneralUIUtils.findByText("Import DCAE asset"); + WebElement fileInputElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VF_FILE.getValue()); + if (!buttonDCAE.isDisplayed()) { + File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resourceMetaData.getName()); + final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); + SetupCDTest.getExtendTest().log(Status.WARNING, "DCAE button not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath)); } - fillResourceGeneralInformationPage(resource, user, true); - resource.setVersion("0.1"); - GeneralPageElements.clickCreateButton(); - } - - public static void updateResource(ResourceReqDetails resource, User user){ - ResourceGeneralPage.defineContactId(resource.getContactId()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating General screen fields ...")); - fillResourceGeneralInformationPage(resource, user, false); - ResourceGeneralPage.clickUpdateButton(); - } - - /** - * Click on HTML element. - * - * @param dataTestId - * @throws Exception - */ - public static void getWebElementByTestID(String dataTestId) throws Exception { - WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 20); - WebElement element = wait - .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))); - element.click(); - // wait.until(ExpectedConditions.elemetto) - // WebElement serviceButton = - // GeneralUIUtils.getDriver().findElement(By.xpath("//*[@data-tests-id='" - // + dataTestId + "']")); - // serviceButton. - // serviceButton.click(); - } - - /** - * Import VFC - * - * @param user - * @param filePath - * @param fileName - * @return - * @throws Exception - */ - - public static void importVfc(ResourceReqDetails resourceMetaData, String filePath, String fileName, User user) - throws Exception { - GeneralUIUtils.ultimateWait(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating new VFC resource ", resourceMetaData.getName())); - GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue()); - GeneralUIUtils.ultimateWait(); - // Insert file to the browse dialog - WebElement buttonVFC = GeneralUIUtils.findByText("Import VFC"); - WebElement fileInputElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VFC_FILE.getValue()); - if (!buttonVFC.isDisplayed()){ - File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resourceMetaData.getName()); - final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); - SetupCDTest.getExtendTest().log(Status.WARNING, "VFC button not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath)); - } - try{ - fileInputElement.sendKeys(filePath + fileName); - } catch (ElementNotVisibleException e) { - SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on file input, converting VFC file input to visible")); - showButtons(); - fileInputElement.sendKeys(filePath + fileName); - } - // Fill the general page fields. - GeneralUIUtils.ultimateWait(); - fillResourceGeneralInformationPage(resourceMetaData, user, true); - GeneralPageElements.clickCreateButton(); - } - - public static void importVfcNoCreate(ResourceReqDetails resourceMetaData, String filePath, String fileName, User user) - throws Exception { - GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue()); - // Insert file to the browse dialog - WebElement buttonVFC = GeneralUIUtils.findByText("Import VFC"); - WebElement fileInputElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VFC_FILE.getValue()); - if (!buttonVFC.isDisplayed()){ - File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resourceMetaData.getName()); - final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); - SetupCDTest.getExtendTest().log(Status.WARNING, "VFC button not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath)); - } - try{ - fileInputElement.sendKeys(filePath + fileName); - } catch (ElementNotVisibleException e) { - SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on file input, converting VFC file input to visible")); - showButtons(); - fileInputElement.sendKeys(filePath + fileName); - } - // Fill the general page fields. - GeneralUIUtils.waitForLoader(); - fillResourceGeneralInformationPage(resourceMetaData, user, true); - } - - - public static void importVfFromCsar(ResourceReqDetails resourceMetaData, String filePath, String fileName, User user) - throws Exception { - GeneralUIUtils.ultimateWait(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating new VF asset resource %s", resourceMetaData.getName())); - GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue()); - GeneralUIUtils.ultimateWait(); - // Insert file to the browse dialog - WebElement buttonDCAE = GeneralUIUtils.findByText("Import DCAE asset"); - WebElement fileInputElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VF_FILE.getValue()); - if (!buttonDCAE.isDisplayed()){ - File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resourceMetaData.getName()); - final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); - SetupCDTest.getExtendTest().log(Status.WARNING, "DCAE button not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath)); - } - try{ - fileInputElement.sendKeys(filePath + fileName); - } catch (ElementNotVisibleException e) { - SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on file input, converting DCAE file input to visible")); - showButtons(); - fileInputElement.sendKeys(filePath + fileName); - } - // Fill the general page fields. - GeneralUIUtils.ultimateWait(); - fillResourceGeneralInformationPage(resourceMetaData, user, true); - GeneralPageElements.clickCreateButton(10*60); -// GeneralUIUtils.ultimateWait(); "don't change import of csar can take longer then 3 minutes" - GeneralUIUtils.waitForLoader(10*60); - } - - public static void importVfFromCsarNoCreate(ResourceReqDetails resourceMetaData, String filePath, String fileName, User user) - throws Exception { - GeneralUIUtils.ultimateWait(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating new VF asset resource %s, Create button will not be clicked", resourceMetaData.getName())); - GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue()); - GeneralUIUtils.ultimateWait(); - // Insert file to the browse dialog - WebElement buttonDCAE = GeneralUIUtils.findByText("Import DCAE asset"); - WebElement fileInputElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VF_FILE.getValue()); - if (!buttonDCAE.isDisplayed()){ - File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Warning_" + resourceMetaData.getName()); - final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); - SetupCDTest.getExtendTest().log(Status.WARNING, "DCAE button not visible after hover on import area of Home page, moving on ..." + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath)); - } - try{ - fileInputElement.sendKeys(filePath + fileName); - } catch (ElementNotVisibleException e) { - SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on file input, converting DCAE file input to visible")); - showButtons(); - fileInputElement.sendKeys(filePath + fileName); - } - // Fill the general page fields. - GeneralUIUtils.ultimateWait(); - fillResourceGeneralInformationPage(resourceMetaData, user, true); - GeneralUIUtils.waitForLoader(10*60); - } - - public static void updateVfWithCsar(String filePath, String fileName) { - ExtentTestActions.log(Status.INFO, "Updating VF with updated CSAR file named " + fileName); - WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.GeneralElementsEnum.UPLOAD_FILE_INPUT.getValue()); - browseWebElement.sendKeys(filePath + fileName); - GeneralUIUtils.ultimateWait(); - GeneralPageElements.clickUpdateButton(); - GeneralUIUtils.waitForLoader(); - ExtentTestActions.log(Status.INFO, "VF is updated."); - } - - public static void showButtons(){ - String parentElementClassAttribute = "sdc-dashboard-import-element-container"; - WebElement fileInputElementWithVisible = GeneralUIUtils.getDriver().findElement(By.className(parentElementClassAttribute)); - GeneralUIUtils.unhideElement(fileInputElementWithVisible, parentElementClassAttribute); - GeneralUIUtils.ultimateWait(); - SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Input buttons now visible...")); - } - - public static void showButtonsADD(){ - try { - GeneralUIUtils.ultimateWait(); - String parentElementClassAttribute = "sdc-dashboard-create-element-container"; - WebElement fileInputElementWithVisible = GeneralUIUtils.getDriver().findElement(By.className(parentElementClassAttribute)); - GeneralUIUtils.unhideElement(fileInputElementWithVisible, parentElementClassAttribute); - GeneralUIUtils.ultimateWait(); - } catch (Exception e ){ - GeneralUIUtils.ultimateWait(); - String parentElementClassAttribute = "sdc-dashboard-create-element-container"; - WebElement fileInputElementWithVisible = GeneralUIUtils.getDriver().findElement(By.className(parentElementClassAttribute)); - GeneralUIUtils.unhideElement(fileInputElementWithVisible, parentElementClassAttribute); - GeneralUIUtils.ultimateWait(); - } - SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Input buttons now visible...")); - } - - public static void clickOnElementByText(String textToClick, String customizationFoLog){ - String customizationFoLogLocal = customizationFoLog != null ? customizationFoLog : ""; - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s %s", textToClick, customizationFoLogLocal)); - GeneralUIUtils.clickOnElementByText(textToClick); - } - - public static void createPNF(ResourceReqDetails resource, User user) throws Exception { - ExtentTestActions.log(Status.INFO, "Going to create a new PNF"); - createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_PNF); - } - - public static void createCR(ResourceReqDetails resource, User user) throws Exception { - ExtentTestActions.log(Status.INFO, "Going to create a new CR"); - createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_CR); - } - - public static ImmutablePair getFirstRIPos(ResourceReqDetails createResourceInUI, User user) { - String responseAfterDrag = RestCDUtils.getResource(createResourceInUI, user).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(xPosPostDrag, yPosPostDrag); - - } + try { + fileInputElement.sendKeys(filePath + fileName); + } catch (ElementNotVisibleException e) { + SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exeption catched on file input, converting DCAE file input to visible")); + showButtons(); + fileInputElement.sendKeys(filePath + fileName); + } + // Fill the general page fields. + GeneralUIUtils.ultimateWait(); + fillResourceGeneralInformationPage(resourceMetaData, user, true); + GeneralUIUtils.waitForLoader(BASIC_TIMEOUT); + } + + public static void updateVfWithCsar(String filePath, String fileName) { + ExtentTestActions.log(Status.INFO, "Updating VF with updated CSAR file named " + fileName); + WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.GeneralElementsEnum.UPLOAD_FILE_INPUT.getValue()); + browseWebElement.sendKeys(filePath + fileName); + GeneralUIUtils.ultimateWait(); + GeneralPageElements.clickUpdateButton(); + GeneralUIUtils.waitForLoader(); + ExtentTestActions.log(Status.INFO, "VF is updated."); + } + + private static void showButtons() { + String parentElementClassAttribute = "sdc-dashboard-import-element-container"; + WebElement fileInputElementWithVisible = GeneralUIUtils.getDriver().findElement(By.className(parentElementClassAttribute)); + GeneralUIUtils.unhideElement(fileInputElementWithVisible, parentElementClassAttribute); + GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Input buttons now visible...")); + } + + private static void showButtonsADD() { + try { + GeneralUIUtils.ultimateWait(); + String parentElementClassAttribute = "sdc-dashboard-create-element-container"; + WebElement fileInputElementWithVisible = GeneralUIUtils.getDriver().findElement(By.className(parentElementClassAttribute)); + GeneralUIUtils.unhideElement(fileInputElementWithVisible, parentElementClassAttribute); + GeneralUIUtils.ultimateWait(); + } catch (Exception e) { + GeneralUIUtils.ultimateWait(); + String parentElementClassAttribute = "sdc-dashboard-create-element-container"; + WebElement fileInputElementWithVisible = GeneralUIUtils.getDriver().findElement(By.className(parentElementClassAttribute)); + GeneralUIUtils.unhideElement(fileInputElementWithVisible, parentElementClassAttribute); + GeneralUIUtils.ultimateWait(); + } + SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Input buttons now visible...")); + } + + public static void clickOnElementByText(String textToClick, String customizationFoLog) { + String customizationFoLogLocal = customizationFoLog != null ? customizationFoLog : ""; + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s %s", textToClick, customizationFoLogLocal)); + GeneralUIUtils.clickOnElementByText(textToClick); + } + + public static void createPNF(ResourceReqDetails resource, User user) throws Exception { + ExtentTestActions.log(Status.INFO, "Going to create a new PNF"); + createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_PNF); + } + + public static void createCR(ResourceReqDetails resource, User user) throws Exception { + ExtentTestActions.log(Status.INFO, "Going to create a new CR"); + createResource(resource, user, DataTestIdEnum.Dashboard.BUTTON_ADD_CR); + } + + public static ImmutablePair getFirstRIPos(ResourceReqDetails createResourceInUI, User user) { + String responseAfterDrag = RestCDUtils.getResource(createResourceInUI, user).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(xPosPostDrag, yPosPostDrag); + + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/RestCDUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/RestCDUtils.java index 7ce9fbe90f..d5441b5476 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/RestCDUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/RestCDUtils.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,6 +21,7 @@ package org.openecomp.sdc.ci.tests.utilities; import com.aventstack.extentreports.Status; +import org.apache.http.HttpStatus; import org.codehaus.jettison.json.JSONObject; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.model.Component; @@ -35,7 +36,12 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.execute.setup.DriverFactory; import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.*; +import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.CategoryRestUtils; +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; +import org.openecomp.sdc.ci.tests.utils.rest.UserRestUtils; import java.io.IOException; import java.net.InetAddress; @@ -47,6 +53,8 @@ import java.util.stream.Collectors; public class RestCDUtils { + private static final int SLEEP_DURATION = 1000; + private static void setResourceUniqueIdAndUUID(ComponentReqDetails element, RestResponse getResourceResponse) { element.setUniqueId(ResponseParser.getUniqueIdFromResponse(getResourceResponse)); element.setUUID(ResponseParser.getUuidFromResponse(getResourceResponse)); @@ -59,12 +67,12 @@ public class RestCDUtils { try { ExtentTestActions.log(Status.INFO, getResourceMsg); System.out.println(getResourceMsg); - GeneralUIUtils.sleep(1000); + GeneralUIUtils.sleep(SLEEP_DURATION); RestResponse getResourceResponse = null; String resourceUniqueId = resource.getUniqueId(); if (resourceUniqueId != null) { getResourceResponse = ResourceRestUtils.getResource(resourceUniqueId); - if (getResourceResponse.getErrorCode().intValue() == 200) { + if (getResourceResponse.getErrorCode().intValue() == HttpStatus.SC_OK) { ExtentTestActions.log(Status.INFO, succeedGetResourceMsg); System.out.println(succeedGetResourceMsg); } @@ -72,7 +80,7 @@ public class RestCDUtils { } JSONObject getResourceJSONObject = null; getResourceResponse = ResourceRestUtils.getResourceByNameAndVersion(user.getUserId(), resource.getName(), resource.getVersion()); - if (getResourceResponse.getErrorCode().intValue() == 200) { + if (getResourceResponse.getErrorCode().intValue() == HttpStatus.SC_OK) { setResourceUniqueIdAndUUID(resource, getResourceResponse); ExtentTestActions.log(Status.INFO, succeedGetResourceMsg); System.out.println(succeedGetResourceMsg); @@ -86,11 +94,12 @@ public class RestCDUtils { } public static RestResponse getService(ServiceReqDetails service, User user) { + final int threadSleepTime = 3500; try { - Thread.sleep(3500); + Thread.sleep(threadSleepTime); RestResponse getServiceResponse = ServiceRestUtils.getServiceByNameAndVersion(user, service.getName(), service.getVersion()); - if (getServiceResponse.getErrorCode().intValue() == 200) { + if (getServiceResponse.getErrorCode().intValue() == HttpStatus.SC_OK) { setResourceUniqueIdAndUUID(service, getServiceResponse); } return getServiceResponse; @@ -106,9 +115,9 @@ public class RestCDUtils { try { computerName = InetAddress.getLocalHost().getHostAddress().replaceAll("\\.", "·"); System.out.println(computerName); - if (computerName.indexOf(".") > -1) - computerName = computerName.substring(0, - computerName.indexOf(".")).toUpperCase(); + if (computerName.contains(".")) { + computerName = computerName.substring(0, computerName.indexOf(".")).toUpperCase(); + } } catch (UnknownHostException e) { System.out.println("Uknown hostAddress"); } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ServiceUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ServiceUIUtils.java index f19b43069e..367dd3b68d 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ServiceUIUtils.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ServiceUIUtils.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -45,7 +45,7 @@ public class ServiceUIUtils { super(); } - public static void defineTagsList2(List serviceTags) { + private static void defineTagsList2(List serviceTags) { WebElement serviceTagsTextbox = GeneralUIUtils.getWebElementByTestID("i-sdc-tag-input"); for (String tag : serviceTags) { serviceTagsTextbox.clear(); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CatalogVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CatalogVerificator.java index 8230e7e5bf..d2aa1497ec 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CatalogVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CatalogVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,128 +41,132 @@ import java.util.Map; import java.util.stream.Collectors; public class CatalogVerificator { - - public static int getResourceNumber(ResourceTypeEnum resourceType, Map> catalogAsMap) throws Exception { - List resourcesArrayList = catalogAsMap.get("resources"); - return resourcesArrayList.stream(). - filter(s -> ((Resource)s).getResourceType().equals(resourceType)). - collect(Collectors.toList()).size(); - } - - public static int getTypeNumber(TypesEnum enumtype) throws Exception{ - Map> catalogAsMap = RestCDUtils.getCatalogAsMap(); - switch (enumtype) { - case RESOURCE: - return catalogAsMap.get("resources").size(); - case SERVICE: - return catalogAsMap.get("services").size(); - case PRODUCT: - return catalogAsMap.get("products").size(); - default: - return getResourceNumber(ResourceTypeEnum.valueOf(enumtype.name()), catalogAsMap); - } - } - - public static void validateType(TypesEnum enumtype) throws Exception{ - int numberOfElementsFromBE = getTypeNumber(enumtype); - int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s elements, should be %s ...", enumtype.name(), numberOfElementsFromBE)); - Assert.assertEquals(numberOfElementsFromBE, numberOfElementsFromUI, String.format("Expected : %s, Actual: %s", numberOfElementsFromBE, numberOfElementsFromUI)); - } - - public static int getStatusNumber(List status) throws Exception { - Map> catalogAsMap = RestCDUtils.getCatalogAsMap(); - return catalogAsMap.entrySet().stream(). - map(s -> s.getValue()). - flatMap(List::stream). - filter(s->(s != null && status.contains(mapBeLifecycleToUIStatus(s)))). - collect(Collectors.toList()).size(); - } - - public static void validateStatus(List status, String checkboxName) throws Exception{ - int numberOfElementsFromBE = getStatusNumber(status); - int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s elements , should be %s ...", checkboxName, numberOfElementsFromBE)); - Assert.assertEquals(numberOfElementsFromBE, numberOfElementsFromUI, String.format("Expected : %s, Actual: %s", numberOfElementsFromBE, numberOfElementsFromUI)); - } - - public static int getCategoryNumber(String categoryName) throws Exception { - Map> catalogAsMap = RestCDUtils.getCatalogAsMap(); - List serviceAndResourceList = new ArrayList<>(); - serviceAndResourceList.addAll(catalogAsMap.get("resources")); - serviceAndResourceList.addAll(catalogAsMap.get("services")); - List list = new ArrayList<>(); - if(!serviceAndResourceList.isEmpty()) { - for (Component s : serviceAndResourceList) { - if (s.getCategories().get(0).getName().equals(categoryName)) { - list.add(s); - } - } - } - return list.size(); - } - - public static void validateCategory(String categoryName) throws Exception{ -// int numberOfElementsFromBE = getCategoryNumber(categoryName); - int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s category elements , should be %s ...", categoryName, "more or equal to 0 elements ")); - Assert.assertTrue(numberOfElementsFromUI >= 0, String.format("Expected : %s, Actual: %s", "more or equal to 0 elements ", numberOfElementsFromUI)); - } - - public static int getSubCategoryNumber(String categoryName , String subCategoryName) throws Exception { - Map> catalogAsMap = RestCDUtils.getCatalogAsMap(); - List resourcesArrayList = catalogAsMap.get("resources"); - List list = new ArrayList<>(); - if(!resourcesArrayList.isEmpty()) { - for (Component s : resourcesArrayList) { - if (s.getCategories().get(0).getName().equalsIgnoreCase(categoryName) && - s.getCategories().get(0).getSubcategories().get(0).getName().equalsIgnoreCase(subCategoryName)) { - list.add(s); - } - } - } - return list.size(); - } - - public static void validateSubCategory(String categoryName, String subCategoryName) throws Exception{ - //int numberOfElementsFromBE = getSubCategoryNumber(categoryName, subCategoryName); - - int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s/%s subcategory elements , should be %s ...", categoryName, subCategoryName, "more then 0 elements ")); - Assert.assertTrue(numberOfElementsFromUI > 0, String.format("Expected : %s, Actual: %s", "more then 0 elements ", numberOfElementsFromUI)); - } - - public static int getNumberOfElementsFromCatalogHeader(){ - String elementsAsString = GeneralUIUtils.getWebElementByClassName("w-sdc-dashboard-catalog-items-header").getText(); - String numberOfElementsAsString = elementsAsString.split(" ")[0]; - if (numberOfElementsAsString.equals("No")){ - return 0; - } else { - return Integer.parseInt(numberOfElementsAsString); - } - } - - private static LifeCycleStateEnum mapBeLifecycleToUIStatus(Component component){ - boolean isServiceAndDistributed = component.getComponentType().equals(ComponentTypeEnum.SERVICE) && - ((Service) component).getDistributionStatus().equals(DistributionStatusEnum.DISTRIBUTED); - switch (component.getLifecycleState()) { - case CERTIFIED: - if (isServiceAndDistributed){ - return LifeCycleStateEnum.DISTRIBUTED; - } else { - return LifeCycleStateEnum.CERTIFIED; - } - case READY_FOR_CERTIFICATION: - return LifeCycleStateEnum.READY_FOR_TESTING; - case CERTIFICATION_IN_PROGRESS: - return LifeCycleStateEnum.IN_TESTING; - case NOT_CERTIFIED_CHECKIN: - return LifeCycleStateEnum.CHECKIN; //to IN DESIGN - case NOT_CERTIFIED_CHECKOUT: - return LifeCycleStateEnum.CHECKOUT; //to IN DESIGN - default: - throw new TestNGException("Missing enum value in enum converter"); - } - } - + + private CatalogVerificator() { + + } + + public static int getResourceNumber(ResourceTypeEnum resourceType, Map> catalogAsMap) throws Exception { + List resourcesArrayList = catalogAsMap.get("resources"); + return resourcesArrayList.stream(). + filter(s -> ((Resource) s).getResourceType().equals(resourceType)). + collect(Collectors.toList()).size(); + } + + public static int getTypeNumber(TypesEnum enumtype) throws Exception { + Map> catalogAsMap = RestCDUtils.getCatalogAsMap(); + switch (enumtype) { + case RESOURCE: + return catalogAsMap.get("resources").size(); + case SERVICE: + return catalogAsMap.get("services").size(); + case PRODUCT: + return catalogAsMap.get("products").size(); + default: + return getResourceNumber(ResourceTypeEnum.valueOf(enumtype.name()), catalogAsMap); + } + } + + public static void validateType(TypesEnum enumtype) throws Exception { + int numberOfElementsFromBE = getTypeNumber(enumtype); + int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s elements, should be %s ...", enumtype.name(), numberOfElementsFromBE)); + Assert.assertEquals(numberOfElementsFromBE, numberOfElementsFromUI, String.format("Expected : %s, Actual: %s", numberOfElementsFromBE, numberOfElementsFromUI)); + } + + public static int getStatusNumber(List status) throws Exception { + Map> catalogAsMap = RestCDUtils.getCatalogAsMap(); + return catalogAsMap.entrySet().stream(). + map(s -> s.getValue()). + flatMap(List::stream). + filter(s -> (s != null && status.contains(mapBeLifecycleToUIStatus(s)))). + collect(Collectors.toList()).size(); + } + + public static void validateStatus(List status, String checkboxName) throws Exception { + int numberOfElementsFromBE = getStatusNumber(status); + int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s elements , should be %s ...", checkboxName, numberOfElementsFromBE)); + Assert.assertEquals(numberOfElementsFromBE, numberOfElementsFromUI, String.format("Expected : %s, Actual: %s", numberOfElementsFromBE, numberOfElementsFromUI)); + } + + public static int getCategoryNumber(String categoryName) throws Exception { + Map> catalogAsMap = RestCDUtils.getCatalogAsMap(); + List serviceAndResourceList = new ArrayList<>(); + serviceAndResourceList.addAll(catalogAsMap.get("resources")); + serviceAndResourceList.addAll(catalogAsMap.get("services")); + List list = new ArrayList<>(); + if (!serviceAndResourceList.isEmpty()) { + for (Component s : serviceAndResourceList) { + if (s.getCategories().get(0).getName().equals(categoryName)) { + list.add(s); + } + } + } + return list.size(); + } + + public static void validateCategory(String categoryName) throws Exception { + //int numberOfElementsFromBE = getCategoryNumber(categoryName); + int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s category elements , should be %s ...", categoryName, "more or equal to 0 elements ")); + Assert.assertTrue(numberOfElementsFromUI >= 0, String.format("Expected : %s, Actual: %s", "more or equal to 0 elements ", numberOfElementsFromUI)); + } + + public static int getSubCategoryNumber(String categoryName, String subCategoryName) throws Exception { + Map> catalogAsMap = RestCDUtils.getCatalogAsMap(); + List resourcesArrayList = catalogAsMap.get("resources"); + List list = new ArrayList<>(); + if (!resourcesArrayList.isEmpty()) { + for (Component s : resourcesArrayList) { + if (s.getCategories().get(0).getName().equalsIgnoreCase(categoryName) + && s.getCategories().get(0).getSubcategories().get(0).getName().equalsIgnoreCase(subCategoryName)) { + list.add(s); + } + } + } + return list.size(); + } + + public static void validateSubCategory(String categoryName, String subCategoryName) throws Exception { + //int numberOfElementsFromBE = getSubCategoryNumber(categoryName, subCategoryName); + + int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s/%s subcategory elements , should be %s ...", categoryName, subCategoryName, "more then 0 elements ")); + Assert.assertTrue(numberOfElementsFromUI > 0, String.format("Expected : %s, Actual: %s", "more then 0 elements ", numberOfElementsFromUI)); + } + + public static int getNumberOfElementsFromCatalogHeader() { + String elementsAsString = GeneralUIUtils.getWebElementByClassName("w-sdc-dashboard-catalog-items-header").getText(); + String numberOfElementsAsString = elementsAsString.split(" ")[0]; + if (numberOfElementsAsString.equals("No")) { + return 0; + } else { + return Integer.parseInt(numberOfElementsAsString); + } + } + + private static LifeCycleStateEnum mapBeLifecycleToUIStatus(Component component) { + boolean isServiceAndDistributed = component.getComponentType().equals(ComponentTypeEnum.SERVICE) + && ((Service) component).getDistributionStatus().equals(DistributionStatusEnum.DISTRIBUTED); + switch (component.getLifecycleState()) { + case CERTIFIED: + if (isServiceAndDistributed) { + return LifeCycleStateEnum.DISTRIBUTED; + } else { + return LifeCycleStateEnum.CERTIFIED; + } + case READY_FOR_CERTIFICATION: + return LifeCycleStateEnum.READY_FOR_TESTING; + case CERTIFICATION_IN_PROGRESS: + return LifeCycleStateEnum.IN_TESTING; + case NOT_CERTIFIED_CHECKIN: + return LifeCycleStateEnum.CHECKIN; //to IN DESIGN + case NOT_CERTIFIED_CHECKOUT: + return LifeCycleStateEnum.CHECKOUT; //to IN DESIGN + default: + throw new TestNGException("Missing enum value in enum converter"); + } + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CustomizationUUIDVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CustomizationUUIDVerificator.java index 861347b9fb..74cf0a5210 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CustomizationUUIDVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CustomizationUUIDVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,20 +28,21 @@ import static org.testng.AssertJUnit.assertTrue; public class CustomizationUUIDVerificator { - public static void validateCustomizationUUIDuniqueness(List customizationUUIDs) { - boolean hasNoDuplicates = CustomizationUUIDVerificator.containsUnique(customizationUUIDs); - assertTrue("There are duplicate customizationUUIDs in list",hasNoDuplicates==true); - } - - public static boolean containsUnique(List list){ - Set set = new HashSet<>(); - - for (T t: list){ - if (!set.add(t)) - return false; - } - - return true; - } + public static void validateCustomizationUUIDuniqueness(List customizationUUIDs) { + boolean hasNoDuplicates = CustomizationUUIDVerificator.containsUnique(customizationUUIDs); + assertTrue("There are duplicate customizationUUIDs in list", hasNoDuplicates); + } + + private static boolean containsUnique(List list) { + Set set = new HashSet<>(); + + for (T t : list) { + if (!set.add(t)) { + return false; + } + } + + return true; + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java index 0f39fc0ed4..1eff6284b3 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,7 +36,13 @@ import org.openqa.selenium.WebElement; import java.io.File; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -45,20 +51,20 @@ import static org.testng.Assert.assertTrue; public class DeploymentViewVerificator { - //GroupPropertyEnum.getGroupPropertyNames(); - private static List currentPropertiesForUI = Arrays.asList("isBase", - "vf_module_label", - "vf_module_description", - "min_vf_module_instances", - "max_vf_module_instances", - "initial_count", + //GroupPropertyEnum.getGroupPropertyNames(); + private static List currentPropertiesForUI = Arrays.asList("isBase", + "vf_module_label", + "vf_module_description", + "min_vf_module_instances", + "max_vf_module_instances", + "initial_count", "vf_module_type", //works as isBase property, value can be Base/Expantion "volume_group", "vfc_list", "availability_zone_count"); - //GroupPropertyEnum.getGroupPropertyNamesWithoutIsbase(); - private static List currentPropertiesWithoutIsBaseForFile = Arrays.asList("vf_module_label", + //GroupPropertyEnum.getGroupPropertyNamesWithoutIsbase(); + private static List currentPropertiesWithoutIsBaseForFile = Arrays.asList("vf_module_label", "vf_module_description", "min_vf_module_instances", "max_vf_module_instances", @@ -67,276 +73,274 @@ public class DeploymentViewVerificator { "volume_group", "vfc_list", "availability_zone_count"); - - public static List getCurrentProperties() { - return currentPropertiesForUI; - } - - public static List getCurrentPropertiesWithoutIsBase() { - return currentPropertiesWithoutIsBaseForFile; - } - - - public static final String partToReplace = "_group"; - - private static Map>> deploymentViewData = new HashMap>>(){ - { - HashMap> segw_heat_c3_base , segw_heat_c3_VMs1 ; - - segw_heat_c3_base = new HashMap>(); - segw_heat_c3_base.put("members", Arrays.asList("segw_internet_security_group", "segw_security_group", "int_layer2vlan_net")); - segw_heat_c3_base.put("artifacts", Arrays.asList("segw_heat_c3_base.yml", "segw_heat_c3_base.env")); - segw_heat_c3_base.put("properties", currentPropertiesForUI); - put("segw_heat_c3_base", segw_heat_c3_base); - segw_heat_c3_VMs1 = new HashMap>(); - segw_heat_c3_VMs1.put("members", Arrays.asList("segw_oam_protected_0_port", - "fw_oam_int_layer2vlan_1_port", - "segw_0", "segw_internet_1_port", - "segw_layer2vlan_2_port", - "fw_gn_0", "fw_gn_hsl_direct_3_port", - "fw_oam_oam_mgmt_0_port", - "fw_oam_hsl_direct_3_port", - "fw_gn_oam_mgmt_0_port", - "fw_oam_oam_direct_2_port", - "fw_gn_gn_direct_2_port", - "fw_oam_0", - "fw_gn_int_layer2vlan_1_port")); - segw_heat_c3_VMs1.put("artifacts", Arrays.asList("segw_heat_c3_VMs1.yml", "segw_heat_c3_VMs1.env")); - segw_heat_c3_VMs1.put("properties", currentPropertiesForUI); - put("segw_heat_c3_VMs1", segw_heat_c3_VMs1); - } - }; - - private static Map>> deploymentViewDataMixedArtifacts = new HashMap>>(){ - { - HashMap> module_1_ldsa, module_2_ldsa, base_ldsa; - - module_1_ldsa = new HashMap>(); - module_1_ldsa.put("members", Stream.of("ltm_oam_protected_0_port", "ltm_dmz_direct_0_port", "ltm_server_0").collect(Collectors.toList())); - module_1_ldsa.put("artifacts", Stream.of("module_1_ldsa.yaml", "module_1_ldsa.env", "base_ldsa.33.yaml", "module_1_ldsa.11.yaml").collect(Collectors.toList())); - module_1_ldsa.put("properties", currentPropertiesForUI); - put("module_1_ldsa", module_1_ldsa); - module_2_ldsa = new HashMap>(); - module_2_ldsa.put("members", Stream.of("ltm_server_0").collect(Collectors.toList())); - module_2_ldsa.put("artifacts", Stream.of("module_2_ldsa.yaml", "module_2_ldsa.env", "base_ldsa.3.yaml", "module_2_ldsa.22.yaml").collect(Collectors.toList())); - module_2_ldsa.put("properties", currentPropertiesForUI); - put("module_2_ldsa", module_2_ldsa); - base_ldsa = new HashMap>(); - base_ldsa.put("members", Stream.of("ldsa_sec_grp_1").collect(Collectors.toList())); - base_ldsa.put("artifacts", Stream.of("base_ldsa.yaml", "module_2_ldsa.2.yaml", "module_1_ldsa.1.yaml").collect(Collectors.toList())); - base_ldsa.put("properties", currentPropertiesForUI); - put("base_ldsa", base_ldsa); - } - }; - - - private Map>> deploymentViewDataFromFile; - - public DeploymentViewVerificator(String pathToCsar) throws Exception { - deploymentViewDataFromFile = buildDeploymentViewDataFromCSAR(pathToCsar); - } - - public DeploymentViewVerificator() throws Exception { - deploymentViewDataFromFile = deploymentViewDataMixedArtifacts; - } - - - public void verifyDeploymentPageSubElements(String moduleName) throws Exception{ - HashMap> moduleProperties = getDeploymentViewData().get(moduleName); - - // add env placeholder to deployment view data - if (!moduleProperties.get("artifacts").contains(moduleName + ".env")){ - moduleProperties.get("artifacts").add(moduleName + ".env"); - } - - List members, artifacts, properties; - members = DeploymentPage.getGroupMembersList(moduleName); - artifacts = DeploymentPage.getArtifactNames(); - properties = DeploymentPage.getPropertyNames(); - - File imageFilePath = GeneralUIUtils.takeScreenshot(moduleName + UUID.randomUUID(), SetupCDTest.getScreenshotFolder(), null); - final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating group %s, should be %s members, %s artifacts " + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath), - moduleName, moduleProperties.get("members").size(), moduleProperties.get("artifacts").size())); - - assertTrue(moduleProperties.get("artifacts").size() == artifacts.size(), "Artifacts amount not as expected, expected " + moduleProperties.get("artifacts").size()); - assertTrue(moduleProperties.get("artifacts").containsAll(artifacts.stream(). - map(e -> e.getAttribute("textContent")). - collect(Collectors.toList()))); - assertTrue(moduleProperties.get("members").size() == members.size(), "Members amount not as expected, expected " + moduleProperties.get("members").size()); - assertTrue(moduleProperties.get("members").containsAll(members.stream(). - map(e -> e.getAttribute("textContent")). - collect(Collectors.toList()))); - assertTrue(moduleProperties.get("properties").size() == properties.size(), "Properties amount not as expected, expected " + moduleProperties.get("properties").size()); - assertTrue(moduleProperties.get("properties").containsAll(properties.stream(). - map(e -> e.getAttribute("textContent")). - collect(Collectors.toList()))); - DeploymentPage.clickOnProperties(); - DeploymentPage.clickOnArtifacts(); - } - - public void verifyDeploymentPageModules(List modules){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating VF groups , should be %s groups ", getDeploymentViewData().size())); - assertFalse(modules.isEmpty(), "No modules found"); - assertTrue(modules.size() == getDeploymentViewData().size(), "Modules amount not as expected, expected " + getDeploymentViewData().size()); - for (WebElement module: modules){ - assertTrue(getDeploymentViewData().containsKey(module.getText().split("\\.\\.")[1])); - } - } - - public static void verifyComponentNameChanged(String oldName, String newName){ - try{ - GeneralUIUtils.clickOnElementByText(oldName, 10); - assertTrue(false, "Element name don't changed"); - } catch(Exception e){ - GeneralUIUtils.clickOnElementByText(newName); - } - } - - public Map>> getDeploymentViewData() { -// return deploymentViewData; - return getDeploymentViewDataFromFile(); - } - - public static Map>> buildDeploymentViewDataFromCSAR(String pathToCSAR) throws Exception{ - ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(pathToCSAR)); - Map>> deploymentViewDataFromFile = new HashMap>>(); - Map groups = toscaDefinition.getTopology_template().getGroups(); - List keyList = groups.keySet().stream().collect(Collectors.toList()); - HashMap> groupsToArtifacts = getDeploymentArtifactsMappedToGroupsFromCSAR(pathToCSAR); - for(String groupKey: keyList){ - HashMap> tempGroupMap = new HashMap>(); - tempGroupMap.put("artifacts", groupsToArtifacts.get(convertAmdocsCsarGroupNameToSdcCsarGroupName(groupKey))); - if (groups.get(groupKey).getMembers() == null){ - tempGroupMap.put("members", Arrays.asList()); - } else { - tempGroupMap.put("members", groups.get(groupKey).getMembers()); - } - tempGroupMap.put("properties", currentPropertiesForUI); - deploymentViewDataFromFile.put(convertAmdocsCsarGroupNameToSdcCsarGroupName(groupKey), tempGroupMap); - } - return deploymentViewDataFromFile; - } - - public static HashMap> getDeploymentArtifactsMappedToGroupsFromCSAR(String pathToFile) throws Exception { - Map combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(pathToFile); - LinkedList deploymentArtifacts = ((LinkedList) combinedMap.get("Deployment")); - - HashMap> tempGroupMap = new HashMap>(); - for(HeatMetaFirstLevelDefinition deploymentArtifact: deploymentArtifacts) { - String groupName = deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().indexOf(".")); - if(deploymentArtifact.getType().equals("HEAT") || deploymentArtifact.getType().equals("HEAT_NET") || deploymentArtifact.getType().equals("HEAT_VOL")) { - List list = new ArrayList<>(); - list.add(deploymentArtifact.getFileName().trim()); - tempGroupMap.put(groupName, list); - } else { - // update current key - List list = tempGroupMap.get(groupName); - list.add(deploymentArtifact.getFileName().trim()); - tempGroupMap.put(groupName, list); - } - } - return tempGroupMap; - } - + + public static List getCurrentProperties() { + return currentPropertiesForUI; + } + + static List getCurrentPropertiesWithoutIsBase() { + return currentPropertiesWithoutIsBaseForFile; + } + + + private static final String PART_TO_REPLACE = "_group"; + + private static Map>> deploymentViewData = new HashMap>>() { + { + HashMap> segw_heat_c3_base, segw_heat_c3_VMs1; + + segw_heat_c3_base = new HashMap>(); + segw_heat_c3_base.put("members", Arrays.asList("segw_internet_security_group", "segw_security_group", "int_layer2vlan_net")); + segw_heat_c3_base.put("artifacts", Arrays.asList("segw_heat_c3_base.yml", "segw_heat_c3_base.env")); + segw_heat_c3_base.put("properties", currentPropertiesForUI); + put("segw_heat_c3_base", segw_heat_c3_base); + segw_heat_c3_VMs1 = new HashMap>(); + segw_heat_c3_VMs1.put("members", Arrays.asList("segw_oam_protected_0_port", + "fw_oam_int_layer2vlan_1_port", + "segw_0", "segw_internet_1_port", + "segw_layer2vlan_2_port", + "fw_gn_0", "fw_gn_hsl_direct_3_port", + "fw_oam_oam_mgmt_0_port", + "fw_oam_hsl_direct_3_port", + "fw_gn_oam_mgmt_0_port", + "fw_oam_oam_direct_2_port", + "fw_gn_gn_direct_2_port", + "fw_oam_0", + "fw_gn_int_layer2vlan_1_port")); + segw_heat_c3_VMs1.put("artifacts", Arrays.asList("segw_heat_c3_VMs1.yml", "segw_heat_c3_VMs1.env")); + segw_heat_c3_VMs1.put("properties", currentPropertiesForUI); + put("segw_heat_c3_VMs1", segw_heat_c3_VMs1); + } + }; + + private static Map>> deploymentViewDataMixedArtifacts = new HashMap>>() { + { + HashMap> module_1_ldsa, module_2_ldsa, base_ldsa; + + module_1_ldsa = new HashMap>(); + module_1_ldsa.put("members", Stream.of("ltm_oam_protected_0_port", "ltm_dmz_direct_0_port", "ltm_server_0").collect(Collectors.toList())); + module_1_ldsa.put("artifacts", Stream.of("module_1_ldsa.yaml", "module_1_ldsa.env", "base_ldsa.33.yaml", "module_1_ldsa.11.yaml").collect(Collectors.toList())); + module_1_ldsa.put("properties", currentPropertiesForUI); + put("module_1_ldsa", module_1_ldsa); + module_2_ldsa = new HashMap>(); + module_2_ldsa.put("members", Stream.of("ltm_server_0").collect(Collectors.toList())); + module_2_ldsa.put("artifacts", Stream.of("module_2_ldsa.yaml", "module_2_ldsa.env", "base_ldsa.3.yaml", "module_2_ldsa.22.yaml").collect(Collectors.toList())); + module_2_ldsa.put("properties", currentPropertiesForUI); + put("module_2_ldsa", module_2_ldsa); + base_ldsa = new HashMap>(); + base_ldsa.put("members", Stream.of("ldsa_sec_grp_1").collect(Collectors.toList())); + base_ldsa.put("artifacts", Stream.of("base_ldsa.yaml", "module_2_ldsa.2.yaml", "module_1_ldsa.1.yaml").collect(Collectors.toList())); + base_ldsa.put("properties", currentPropertiesForUI); + put("base_ldsa", base_ldsa); + } + }; + + + private Map>> deploymentViewDataFromFile; + + public DeploymentViewVerificator(String pathToCsar) throws Exception { + deploymentViewDataFromFile = buildDeploymentViewDataFromCSAR(pathToCsar); + } + + public DeploymentViewVerificator() throws Exception { + deploymentViewDataFromFile = deploymentViewDataMixedArtifacts; + } + + + public void verifyDeploymentPageSubElements(String moduleName) throws Exception { + HashMap> moduleProperties = getDeploymentViewData().get(moduleName); + + // add env placeholder to deployment view data + if (!moduleProperties.get("artifacts").contains(moduleName + ".env")) { + moduleProperties.get("artifacts").add(moduleName + ".env"); + } + + List members, artifacts, properties; + members = DeploymentPage.getGroupMembersList(moduleName); + artifacts = DeploymentPage.getArtifactNames(); + properties = DeploymentPage.getPropertyNames(); + + File imageFilePath = GeneralUIUtils.takeScreenshot(moduleName + UUID.randomUUID(), SetupCDTest.getScreenshotFolder(), null); + final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating group %s, should be %s members, %s artifacts " + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath), + moduleName, moduleProperties.get("members").size(), moduleProperties.get("artifacts").size())); + + assertTrue(moduleProperties.get("artifacts").size() == artifacts.size(), "Artifacts amount not as expected, expected " + moduleProperties.get("artifacts").size()); + assertTrue(moduleProperties.get("artifacts").containsAll(artifacts.stream(). + map(e -> e.getAttribute("textContent")). + collect(Collectors.toList()))); + assertTrue(moduleProperties.get("members").size() == members.size(), "Members amount not as expected, expected " + moduleProperties.get("members").size()); + assertTrue(moduleProperties.get("members").containsAll(members.stream(). + map(e -> e.getAttribute("textContent")). + collect(Collectors.toList()))); + assertTrue(moduleProperties.get("properties").size() == properties.size(), "Properties amount not as expected, expected " + moduleProperties.get("properties").size()); + assertTrue(moduleProperties.get("properties").containsAll(properties.stream(). + map(e -> e.getAttribute("textContent")). + collect(Collectors.toList()))); + DeploymentPage.clickOnProperties(); + DeploymentPage.clickOnArtifacts(); + } + + public void verifyDeploymentPageModules(List modules) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating VF groups , should be %s groups ", getDeploymentViewData().size())); + assertFalse(modules.isEmpty(), "No modules found"); + assertTrue(modules.size() == getDeploymentViewData().size(), "Modules amount not as expected, expected " + getDeploymentViewData().size()); + for (WebElement module : modules) { + assertTrue(getDeploymentViewData().containsKey(module.getText().split("\\.\\.")[1])); + } + } + + public static void verifyComponentNameChanged(String oldName, String newName) { + final int clickingElementTimeout = 10; + try { + GeneralUIUtils.clickOnElementByText(oldName, clickingElementTimeout); + assertTrue(false, "Element name don't changed"); + } catch (Exception e) { + GeneralUIUtils.clickOnElementByText(newName); + } + } + + public Map>> getDeploymentViewData() { + return getDeploymentViewDataFromFile(); + } + + public static Map>> buildDeploymentViewDataFromCSAR(String pathToCSAR) throws Exception { + ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(pathToCSAR)); + Map>> deploymentViewDataFromFile = new HashMap>>(); + Map groups = toscaDefinition.getTopology_template().getGroups(); + List keyList = groups.keySet().stream().collect(Collectors.toList()); + HashMap> groupsToArtifacts = getDeploymentArtifactsMappedToGroupsFromCSAR(pathToCSAR); + for (String groupKey : keyList) { + HashMap> tempGroupMap = new HashMap>(); + tempGroupMap.put("artifacts", groupsToArtifacts.get(convertAmdocsCsarGroupNameToSdcCsarGroupName(groupKey))); + if (groups.get(groupKey).getMembers() == null) { + tempGroupMap.put("members", Arrays.asList()); + } else { + tempGroupMap.put("members", groups.get(groupKey).getMembers()); + } + tempGroupMap.put("properties", currentPropertiesForUI); + deploymentViewDataFromFile.put(convertAmdocsCsarGroupNameToSdcCsarGroupName(groupKey), tempGroupMap); + } + return deploymentViewDataFromFile; + } + + public static HashMap> getDeploymentArtifactsMappedToGroupsFromCSAR(String pathToFile) throws Exception { + Map combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(pathToFile); + LinkedList deploymentArtifacts = ((LinkedList) combinedMap.get("Deployment")); + + HashMap> tempGroupMap = new HashMap>(); + for (HeatMetaFirstLevelDefinition deploymentArtifact : deploymentArtifacts) { + String groupName = deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().indexOf(".")); + if (deploymentArtifact.getType().equals("HEAT") || deploymentArtifact.getType().equals("HEAT_NET") || deploymentArtifact.getType().equals("HEAT_VOL")) { + List list = new ArrayList<>(); + list.add(deploymentArtifact.getFileName().trim()); + tempGroupMap.put(groupName, list); + } else { + // update current key + List list = tempGroupMap.get(groupName); + list.add(deploymentArtifact.getFileName().trim()); + tempGroupMap.put(groupName, list); + } + } + return tempGroupMap; + } + public static void cleanFolders(String outputFolder) throws IOException { - System.gc(); - FileUtils.cleanDirectory(new File(outputFolder)); - FileUtils.deleteDirectory(new File(outputFolder)); - } - - public static String unzipCsarFile(String pathToCsar) { - File csarFile = new File(pathToCsar); - - - File dir = new File(csarFile.getParent() + File.separator + "output"+ UUID.randomUUID() + File.separator + UUID.randomUUID()); - if(!dir.exists()) { - dir.mkdirs(); - } - - String outputFolder = dir.getPath(); - ArtifactFromCsar.unZip(pathToCsar, outputFolder); - return outputFolder; - } - - public static void validateEditPopoverFields(String expectedVNFName, String expectedHeatName, String expectedModuleName){ - String VNFname = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.RESOURCE_NAME_ON_POPOVER.getValue()).getText(); - String heatName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.NAME_INPUT.getValue()).getAttribute("value"); - String moduleName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.MODULE_NAME_ON_POPOVER.getValue()).getText(); - assertTrue(expectedVNFName.equals(VNFname), String.format("VNF name Expected: %s, Actual: %s ", expectedVNFName, VNFname)); - assertTrue(expectedHeatName.equals(heatName), String.format("HEAT name Expected: %s, Actual: %s ", expectedHeatName, heatName )); - assertTrue(expectedModuleName.equals(moduleName), String.format("Module name Expected: %s, Actual: %s ", expectedModuleName, moduleName)); - } - - public static void validateEditPopoverButtons(String newName, String invalidModuleName, String validModueName ){ - DeploymentPage.updateAndCancel(newName, DataTestIdEnum.DeploymentScreen.X_BUTTON); - verifyComponentNameChanged(invalidModuleName, validModueName); - DeploymentPage.clickOnEditIcon(); - DeploymentPage.updateAndCancel(newName, DataTestIdEnum.DeploymentScreen.CANCEL); - verifyComponentNameChanged(invalidModuleName, validModueName); - } - - public static void validateEditPopover() throws Exception{ - String moduleRowText = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue()).get(0).getText(); - DeploymentPage.clickOnModuleName(moduleRowText); - DeploymentPage.clickOnEditIcon(); - String[] splitedModuleName = moduleRowText.split("\\.\\."); - - validateEditPopoverFields(splitedModuleName[0], splitedModuleName[1], splitedModuleName[2]); - - String newName = "kuku"; - String newModuleName = DeploymentPage.reconstructModuleName(splitedModuleName, newName); - validateEditPopoverButtons(newName, newModuleName, moduleRowText); - } - - private Map>> getDeploymentViewDataFromFile() { - return deploymentViewDataFromFile; - } - - public static void validateModuleNameUpadate() throws Exception{ - List moduleRowsFromTable = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue()); - int i = 0; - for(WebElement moduleRow :moduleRowsFromTable){ - String moduleRowText = moduleRow.getText(); - String updatedName = "updatedName" + i; - DeploymentPage.updateModuleName(moduleRowText, updatedName); - String updatedModuleName = DeploymentPage.reconstructModuleName(moduleRowText.split("\\.\\."), updatedName); - verifyComponentNameChanged(moduleRowText, updatedModuleName); - // Close module - GeneralUIUtils.clickOnElementByText(updatedModuleName); - i++; - } - } - - public static void regularDepoymentScreenVerificator(Map> metaDataFromUI, DeploymentViewVerificator verificator) throws Exception, InterruptedException { - ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen(); - List moduleRowsFromTable = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue()); - verificator.verifyDeploymentPageModules(moduleRowsFromTable); - for(WebElement moduleRow :moduleRowsFromTable){ - String moduleRowText = moduleRow.getText(); - String middleName = moduleRowText.split("\\.\\.")[1]; - verificator.verifyDeploymentPageSubElements(middleName); - if (metaDataFromUI != null){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating %s group version, should be %s ", moduleRowText, metaDataFromUI.get(moduleRowText.split("\\.\\.")[1]))); - String groupVersion = DeploymentPage.getGroupVersion().split(":")[1].trim(); - String increasedVersion = String.valueOf(Integer.parseInt(metaDataFromUI.get(middleName).get("version")) + 1); - assertTrue(groupVersion.equals(increasedVersion)); - if ( metaDataFromUI.get(middleName).get("moduleID") != "primary"){ - String moduleID = DeploymentPage.getModuleID(); - assertFalse(moduleID.equals(metaDataFromUI.get(middleName).get("moduleID"))); - } - } - // Close module - GeneralUIUtils.clickOnElementByText(moduleRowText); - } - } - - public static String convertAmdocsCsarGroupNameToSdcCsarGroupName(String originalString){ - return originalString.replace(partToReplace, ""); - } - - - + System.gc(); + FileUtils.cleanDirectory(new File(outputFolder)); + FileUtils.deleteDirectory(new File(outputFolder)); + } + + public static String unzipCsarFile(String pathToCsar) { + File csarFile = new File(pathToCsar); + + + File dir = new File(csarFile.getParent() + File.separator + "output" + UUID.randomUUID() + File.separator + UUID.randomUUID()); + if (!dir.exists()) { + dir.mkdirs(); + } + + String outputFolder = dir.getPath(); + ArtifactFromCsar.unZip(pathToCsar, outputFolder); + return outputFolder; + } + + public static void validateEditPopoverFields(String expectedVNFName, String expectedHeatName, String expectedModuleName) { + String VNFname = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.RESOURCE_NAME_ON_POPOVER.getValue()).getText(); + String heatName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.NAME_INPUT.getValue()).getAttribute("value"); + String moduleName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentScreen.MODULE_NAME_ON_POPOVER.getValue()).getText(); + assertTrue(expectedVNFName.equals(VNFname), String.format("VNF name Expected: %s, Actual: %s ", expectedVNFName, VNFname)); + assertTrue(expectedHeatName.equals(heatName), String.format("HEAT name Expected: %s, Actual: %s ", expectedHeatName, heatName)); + assertTrue(expectedModuleName.equals(moduleName), String.format("Module name Expected: %s, Actual: %s ", expectedModuleName, moduleName)); + } + + public static void validateEditPopoverButtons(String newName, String invalidModuleName, String validModueName) { + DeploymentPage.updateAndCancel(newName, DataTestIdEnum.DeploymentScreen.X_BUTTON); + verifyComponentNameChanged(invalidModuleName, validModueName); + DeploymentPage.clickOnEditIcon(); + DeploymentPage.updateAndCancel(newName, DataTestIdEnum.DeploymentScreen.CANCEL); + verifyComponentNameChanged(invalidModuleName, validModueName); + } + + public static void validateEditPopover() throws Exception { + String moduleRowText = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue()).get(0).getText(); + DeploymentPage.clickOnModuleName(moduleRowText); + DeploymentPage.clickOnEditIcon(); + String[] splitedModuleName = moduleRowText.split("\\.\\."); + + validateEditPopoverFields(splitedModuleName[0], splitedModuleName[1], splitedModuleName[2]); + + String newName = "kuku"; + String newModuleName = DeploymentPage.reconstructModuleName(splitedModuleName, newName); + validateEditPopoverButtons(newName, newModuleName, moduleRowText); + } + + private Map>> getDeploymentViewDataFromFile() { + return deploymentViewDataFromFile; + } + + public static void validateModuleNameUpadate() throws Exception { + List moduleRowsFromTable = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue()); + int i = 0; + for (WebElement moduleRow : moduleRowsFromTable) { + String moduleRowText = moduleRow.getText(); + String updatedName = "updatedName" + i; + DeploymentPage.updateModuleName(moduleRowText, updatedName); + String updatedModuleName = DeploymentPage.reconstructModuleName(moduleRowText.split("\\.\\."), updatedName); + verifyComponentNameChanged(moduleRowText, updatedModuleName); + // Close module + GeneralUIUtils.clickOnElementByText(updatedModuleName); + i++; + } + } + + public static void regularDepoymentScreenVerificator(Map> metaDataFromUI, DeploymentViewVerificator verificator) throws Exception, InterruptedException { + ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen(); + List moduleRowsFromTable = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue()); + verificator.verifyDeploymentPageModules(moduleRowsFromTable); + for (WebElement moduleRow : moduleRowsFromTable) { + String moduleRowText = moduleRow.getText(); + String middleName = moduleRowText.split("\\.\\.")[1]; + verificator.verifyDeploymentPageSubElements(middleName); + if (metaDataFromUI != null) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating %s group version, should be %s ", moduleRowText, metaDataFromUI.get(moduleRowText.split("\\.\\.")[1]))); + String groupVersion = DeploymentPage.getGroupVersion().split(":")[1].trim(); + String increasedVersion = String.valueOf(Integer.parseInt(metaDataFromUI.get(middleName).get("version")) + 1); + assertTrue(groupVersion.equals(increasedVersion)); + if (metaDataFromUI.get(middleName).get("moduleID") != "primary") { + String moduleID = DeploymentPage.getModuleID(); + assertFalse(moduleID.equals(metaDataFromUI.get(middleName).get("moduleID"))); + } + } + // Close module + GeneralUIUtils.clickOnElementByText(moduleRowText); + } + } + + public static String convertAmdocsCsarGroupNameToSdcCsarGroupName(String originalString) { + return originalString.replace(PART_TO_REPLACE, ""); + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ErrorMessageUIVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ErrorMessageUIVerificator.java index 85f8a3e94d..0c834415e1 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ErrorMessageUIVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ErrorMessageUIVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,34 +31,32 @@ import org.testng.Assert; public class ErrorMessageUIVerificator { - private static ErrorMessageProperties getErrorByType(ActionStatus errorType){ - try{ - ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(errorType.name()); - String messageId = errorInfo.getMessageId(); - String code = errorInfo.getCode().toString(); - - return new ErrorMessageProperties(messageId, code); - } - catch(Exception e){ - return null; - } - } + private static ErrorMessageProperties getErrorByType(ActionStatus errorType) { + try { + ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(errorType.name()); + String messageId = errorInfo.getMessageId(); + String code = errorInfo.getCode().toString(); - public static void validateErrorMessage(ActionStatus errorMessage) { - String errorMessageBox = null; - try{ -// errorMessageBox = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - errorMessageBox = GeneralUIUtils.getWebElementByClassName("error-message-component").getText(); - } - catch(Exception e){ - ExtentTestActions.log(Status.INFO, "Did not find an error message popup."); - Assert.fail("Did not find an error message popup."); - } - - ExtentTestActions.log(Status.INFO, "An error message raised, validating its content."); - ErrorMessageProperties expectedResponseError = getErrorByType(errorMessage); - Assert.assertTrue(errorMessageBox.contains(expectedResponseError.getCode()), "Error message code is not " + expectedResponseError.getCode()); - Assert.assertTrue(errorMessageBox.contains(expectedResponseError.getMessageId()), "Error message ID is not " + expectedResponseError.getMessageId()); - } + return new ErrorMessageProperties(messageId, code); + } catch (Exception e) { + return null; + } + } + + public static void validateErrorMessage(ActionStatus errorMessage) { + String errorMessageBox = null; + try { + //errorMessageBox = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); + errorMessageBox = GeneralUIUtils.getWebElementByClassName("error-message-component").getText(); + } catch (Exception e) { + ExtentTestActions.log(Status.INFO, "Did not find an error message popup."); + Assert.fail("Did not find an error message popup."); + } + + ExtentTestActions.log(Status.INFO, "An error message raised, validating its content."); + ErrorMessageProperties expectedResponseError = getErrorByType(errorMessage); + Assert.assertTrue(errorMessageBox.contains(expectedResponseError.getCode()), "Error message code is not " + expectedResponseError.getCode()); + Assert.assertTrue(errorMessageBox.contains(expectedResponseError.getMessageId()), "Error message ID is not " + expectedResponseError.getMessageId()); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PortMirroringVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PortMirroringVerificator.java index f8ef39a212..2c980b7df2 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PortMirroringVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PortMirroringVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,33 +35,32 @@ import static org.testng.Assert.assertTrue; public class PortMirroringVerificator { - public static void checkProxyServiceName(String serviceName, String instanceId) - { + private PortMirroringVerificator() { + } + + public static void checkProxyServiceName(String serviceName, String instanceId) { String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText(); - String serviceExpectedName = PortMirroringUtils.createProxyInstanceServiceName(serviceName,instanceId); + String serviceExpectedName = PortMirroringUtils.createproxyinstanceservicename(serviceName, instanceId); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the instance name is %s", serviceExpectedName)); assertTrue(serviceActualName.equalsIgnoreCase(serviceExpectedName)); } - public static void checkProxyServiceType() - { - String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.TYPE.getValue()).getText(); + public static void checkProxyServiceType() { + String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanelGeneralInfo.TYPE.getValue()).getText(); SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the instance type is Service Proxy"); assertTrue(serviceActualName.equalsIgnoreCase(PortMirroringEnum.SERVICE_PROXY_TYPE.getValue())); } - public static void validatingProxyServiceNameAndType(String serviceName, String instanceId) - { + public static void validatingProxyServiceNameAndType(String serviceName, String instanceId) { checkProxyServiceName(serviceName, instanceId); checkProxyServiceType(); } - public static void validateGeneralInfo() - { - String type = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.TYPE.getValue()).getText(); - String resourceType = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.RESOURCE_TYPE.getValue()).getText(); - String category = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.CATEGORY.getValue()).getText(); - String subCategory = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.SUB_CATEGORY.getValue()).getText(); + public static void validateGeneralInfo() { + String type = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanelGeneralInfo.TYPE.getValue()).getText(); + String resourceType = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanelGeneralInfo.RESOURCE_TYPE.getValue()).getText(); + String category = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanelGeneralInfo.CATEGORY.getValue()).getText(); + String subCategory = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanelGeneralInfo.SUB_CATEGORY.getValue()).getText(); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the type equals %s", PortMirroringEnum.TYPE.getValue())); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the resource type equals %s", PortMirroringEnum.RESOURCE_TYPE.getValue())); @@ -74,14 +73,12 @@ public class PortMirroringVerificator { assertTrue(subCategory.equalsIgnoreCase(PortMirroringEnum.SUB_CATEGORY.getValue())); } - public static void validateReqsAndCapsTabExist() - { + public static void validateReqsAndCapsTabExist() { SetupCDTest.getExtendTest().log(Status.INFO, "Verifying tab reqs and caps exist for PMC element"); GeneralUIUtils.getWebElementBy(By.xpath(DataTestIdEnum.CompositionRightPanel.REQS_AND_CAPS_TAB_XPATH.getValue())).click(); } - public static void validateElementName(String expectedName) - { + public static void validateElementName(String expectedName) { String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText(); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the instance name is %s", expectedName)); assertTrue(serviceActualName.equalsIgnoreCase(expectedName)); @@ -101,5 +98,4 @@ public class PortMirroringVerificator { } - } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertiesAssignmentVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertiesAssignmentVerificator.java index 3e29bb9aa7..789976c362 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertiesAssignmentVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertiesAssignmentVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,32 +29,35 @@ import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; public class PropertiesAssignmentVerificator { - - public static void validateFilteredPropertiesCount(int propertiesCount, String propertyLocation){ - int actualPropertiesCount = GeneralUIUtils.getWebElementsListByContainsClassName(propertyLocation).size(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating. Expected properties count: %s , Actual: %s", propertiesCount, actualPropertiesCount)); - String errMsg = String.format("Properties amount not as expected, expected: %s ,Actual: %s", propertiesCount, actualPropertiesCount); - assertTrue(actualPropertiesCount == propertiesCount, errMsg); - } - - public static void validatePropertyValue(String expectedPropertyName, String expectedPropertyValue){ - String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(expectedPropertyName).getAttribute("value"); - assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the value of property/input %s. Expected: %s, Actual: %s ", expectedPropertyName, expectedPropertyValue, actualPropertyValue)); - } - - public static void validatePropertyValueIsNull(String expectedPropertyName){ - String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(expectedPropertyName).getAttribute("value"); - assertNull(actualPropertyValue, String.format("Validating the value of property/input %s. Expected: empty, Actual: %s ", expectedPropertyName, actualPropertyValue)); - } - - public static void validateListPropertyValue(DataTestIdEnum.PropertiesAssignmentScreen prefix, String expectedPropertyName, String expectedPropertyValue, int index){ - String listElement = prefix.getValue() + expectedPropertyName + "." + String.valueOf(index); - String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(listElement).getAttribute("value"); - assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the %s list element value of property %s. Expected: %s, Actual: %s ", index, expectedPropertyName, expectedPropertyValue, actualPropertyValue)); - } - - public static void validateBooleanPropertyValue(String expectedPropertyName, String expectedPropertyValue){ - String actualPropertyValue = GeneralUIUtils.getSelectedElementFromDropDown(expectedPropertyName).getText(); - assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the value of property %s. Expected: %s, Actual: %s ", expectedPropertyName, expectedPropertyValue, actualPropertyValue)); - } + + private PropertiesAssignmentVerificator() { + } + + public static void validateFilteredPropertiesCount(int propertiesCount, String propertyLocation) { + int actualPropertiesCount = GeneralUIUtils.getWebElementsListByContainsClassName(propertyLocation).size(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating. Expected properties count: %s , Actual: %s", propertiesCount, actualPropertiesCount)); + String errMsg = String.format("Properties amount not as expected, expected: %s ,Actual: %s", propertiesCount, actualPropertiesCount); + assertTrue(actualPropertiesCount == propertiesCount, errMsg); + } + + public static void validatePropertyValue(String expectedPropertyName, String expectedPropertyValue) { + String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(expectedPropertyName).getAttribute("value"); + assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the value of property/input %s. Expected: %s, Actual: %s ", expectedPropertyName, expectedPropertyValue, actualPropertyValue)); + } + + public static void validatePropertyValueIsNull(String expectedPropertyName) { + String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(expectedPropertyName).getAttribute("value"); + assertNull(actualPropertyValue, String.format("Validating the value of property/input %s. Expected: empty, Actual: %s ", expectedPropertyName, actualPropertyValue)); + } + + public static void validateListPropertyValue(DataTestIdEnum.PropertiesAssignmentScreen prefix, String expectedPropertyName, String expectedPropertyValue, int index) { + String listElement = prefix.getValue() + expectedPropertyName + "." + String.valueOf(index); + String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(listElement).getAttribute("value"); + assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the %s list element value of property %s. Expected: %s, Actual: %s ", index, expectedPropertyName, expectedPropertyValue, actualPropertyValue)); + } + + public static void validateBooleanPropertyValue(String expectedPropertyName, String expectedPropertyValue) { + String actualPropertyValue = GeneralUIUtils.getSelectedElementFromDropDown(expectedPropertyName).getText(); + assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the value of property %s. Expected: %s, Actual: %s ", expectedPropertyName, expectedPropertyValue, actualPropertyValue)); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertyVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertyVerificator.java index 52f26db0e3..ceca7aebb5 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertyVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertyVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,11 +28,14 @@ import static org.testng.Assert.assertTrue; public class PropertyVerificator { - - public static void validateEditVFCPropertiesPopoverFields(PropertyTypeEnum propertyType){ - String propertyValue = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue()).getAttribute("value"); - String propertyDescription = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_DESCRIPTION.getValue()).getAttribute("value"); - assertTrue(propertyType.getUpdateValue().equals(propertyValue), String.format("Property Value of type %s. Expected: %s, Actual: %s ", propertyType.getType().toString(), propertyType.getUpdateValue(), propertyValue)); - assertTrue(propertyType.getUpdateDescription().equals(propertyDescription), String.format("Property Description of type %s. Expected: %s, Actual: %s ", propertyType.getType().toString(), propertyType.getUpdateDescription(), propertyDescription)); - } + + private PropertyVerificator() { + } + + public static void validateEditVFCPropertiesPopoverFields(PropertyTypeEnum propertyType) { + String propertyValue = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_VALUE.getValue()).getAttribute("value"); + String propertyDescription = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_DESCRIPTION.getValue()).getAttribute("value"); + assertTrue(propertyType.getUpdateValue().equals(propertyValue), String.format("Property Value of type %s. Expected: %s, Actual: %s ", propertyType.getType().toString(), propertyType.getUpdateValue(), propertyValue)); + assertTrue(propertyType.getUpdateDescription().equals(propertyDescription), String.format("Property Description of type %s. Expected: %s, Actual: %s ", propertyType.getType().toString(), propertyType.getUpdateDescription(), propertyDescription)); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java index b454ee1c13..4110985781 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,13 +24,25 @@ import com.aventstack.extentreports.Status; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; -import org.openecomp.sdc.be.model.*; -import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.be.model.GroupInstance; +import org.openecomp.sdc.be.model.GroupInstanceProperty; +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.ComponentReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.PropertiesPopupEnum; +import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum; +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.execute.setup.ExtentTestActions; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.*; +import org.openecomp.sdc.ci.tests.pages.CompositionPage; +import org.openecomp.sdc.ci.tests.pages.DeploymentPage; +import org.openecomp.sdc.ci.tests.pages.PropertyPopup; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.RestCDUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; @@ -38,7 +50,11 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Random; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -46,292 +62,298 @@ import static org.testng.Assert.assertTrue; public class ServiceVerificator { - private ServiceVerificator() { - } - - public static void verifyNumOfComponentInstances(ComponentReqDetails component, String version, int numOfVFC, - User user) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifing the number of components on the canvas; should be %s", numOfVFC)); - String responseAfterDrag = null; - component.setVersion(version); - if (component instanceof ServiceReqDetails) { - responseAfterDrag = RestCDUtils.getService((ServiceReqDetails) component, user).getResponse(); - } else if (component instanceof ResourceReqDetails) { - responseAfterDrag = RestCDUtils.getResource((ResourceReqDetails) component, user).getResponse(); - } - int size = 0; - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - if(jsonResource.get("componentInstances")!= null){ - size = ((JSONArray) jsonResource.get("componentInstances")).size(); - assertTrue(size == numOfVFC, "Expected number of componenet instances is " + numOfVFC + ", but actual is " + size); - ExtentTestActions.log(Status.INFO, "The number of components on the canvas was verified."); - }else{ - assertTrue(false, "Expected number of componenet instances is " + numOfVFC + ", but actual is " + size); - } - } - - public static void verifyServiceUpdatedInUI(ServiceReqDetails service) { - assertTrue(service.getName().equals(ResourceGeneralPage.getNameText())); - assertTrue(service.getDescription().equals(ResourceGeneralPage.getDescriptionText())); - assertTrue(service.getCategory().equals(ServiceGeneralPage.getCategoryText())); - assertTrue(service.getProjectCode().equals(ServiceGeneralPage.getProjectCodeText())); - for(String tag: ServiceGeneralPage.getTags()){ - assertTrue(service.getTags().contains(tag)); - } - assertTrue(service.getContactId().equals(ResourceGeneralPage.getContactIdText())); - } - - public static void verifyServiceDeletedInUI(ServiceReqDetails service) throws InterruptedException { - Thread.sleep(1000); - List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.DASHBOARD_CARD.getValue()); - if (!(cardElements.isEmpty())){ - for (WebElement cardElement: cardElements){ - WebElement componentName = GeneralUIUtils.getElementfromElementByCSS(cardElement, + private static final int SLEEP_TIME = 1000; + private static final int ARTIFACT_SECTION_OFFSET = 700; + + private ServiceVerificator() { + } + + public static void verifyNumOfComponentInstances(ComponentReqDetails component, String version, int numOfVFC, + User user) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifing the number of components on the canvas; should be %s", numOfVFC)); + String responseAfterDrag = null; + component.setVersion(version); + if (component instanceof ServiceReqDetails) { + responseAfterDrag = RestCDUtils.getService((ServiceReqDetails) component, user).getResponse(); + } else if (component instanceof ResourceReqDetails) { + responseAfterDrag = RestCDUtils.getResource((ResourceReqDetails) component, user).getResponse(); + } + int size = 0; + JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); + if (jsonResource.get("componentInstances") != null) { + size = ((JSONArray) jsonResource.get("componentInstances")).size(); + assertTrue(size == numOfVFC, "Expected number of componenet instances is " + numOfVFC + ", but actual is " + size); + ExtentTestActions.log(Status.INFO, "The number of components on the canvas was verified."); + } else { + assertTrue(false, "Expected number of componenet instances is " + numOfVFC + ", but actual is " + size); + } + } + + public static void verifyServiceUpdatedInUI(ServiceReqDetails service) { + assertTrue(service.getName().equals(ResourceGeneralPage.getNameText())); + assertTrue(service.getDescription().equals(ResourceGeneralPage.getDescriptionText())); + assertTrue(service.getCategory().equals(ServiceGeneralPage.getCategoryText())); + assertTrue(service.getProjectCode().equals(ServiceGeneralPage.getProjectCodeText())); + for (String tag : ServiceGeneralPage.getTags()) { + assertTrue(service.getTags().contains(tag)); + } + assertTrue(service.getContactId().equals(ResourceGeneralPage.getContactIdText())); + } + + public static void verifyServiceDeletedInUI(ServiceReqDetails service) throws InterruptedException { + Thread.sleep(SLEEP_TIME); + List cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.DASHBOARD_CARD.getValue()); + if (!(cardElements.isEmpty())) { + for (WebElement cardElement : cardElements) { + WebElement componentName = GeneralUIUtils.getElementfromElementByCSS(cardElement, DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); - WebElement componentType = GeneralUIUtils.getElementfromElementByCSS(cardElement, + WebElement componentType = GeneralUIUtils.getElementfromElementByCSS(cardElement, DataTestIdEnum.DashboardCardEnum.ASSET_TYPE_CSS.getValue()); - - String componentNameStr = componentName.getAttribute("textContent").trim(), - componentTypeStr = componentType.getAttribute("class"); - - if(componentTypeStr.equals("S")){ - assertTrue( !(componentNameStr.equals(service.getName())), "Deleted service was found !!!"); - } - } - } - } - - public static void verifyServiceLifecycle(ServiceReqDetails service, User user, LifecycleStateEnum expectedLifecycleState) { - String responseAfterDrag = RestCDUtils.getService(service, user).getResponse(); - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - String actualLifecycleState = jsonResource.get("lifecycleState").toString(); - assertTrue(expectedLifecycleState.name().equals(actualLifecycleState), "actual: " + actualLifecycleState + "-- expected: " + expectedLifecycleState); - } - - public static void verifyServiceLifecycleInUI(LifeCycleStateEnum lifecycleState){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that service state is %s", lifecycleState.getValue())); - GeneralUIUtils.ultimateWait(); - assertTrue(ResourceGeneralPage.getLifeCycleState().equals(lifecycleState.getValue())); - } - - public static void verifyLinkCreated(ServiceReqDetails createServiceInUI, User user, int expectedRelationsSize) { - String responseAfterDrag = RestCDUtils.getService(createServiceInUI, user).getResponse(); - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - assertTrue(((JSONArray) jsonResource.get("componentInstancesRelations")).size() == expectedRelationsSize); - - } - - public static void verifyManagmentWorkflow(String expectedName, String expectedDescription){ - String actualName = GeneralUIUtils.getWebElementBy(By.cssSelector("div[class='text name']")).getText(); - String actualDescription = GeneralUIUtils.getWebElementBy(By.cssSelector("div[class='text description']")).getText(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifing name ( should be %s ) and description ( should be %s ) ", expectedName, expectedDescription)); - assertTrue(actualName.equals(expectedName) && actualDescription.equals(expectedDescription)); - } - - public static void verifyVersionUI(String expected){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that version is %s", expected)); - String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown - (DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText().replace("V", ""); - assertTrue(actualVersion.equals(expected), String.format( "Expected version: %s, Actual version: %s", expected, actualVersion)); - } - - public static void verifyResourceInstanceVersionUI(String expected){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that instance version is %s", expected)); - List selectedVersion = GeneralUIUtils.findElementsByXpath - ("//option[contains(@class,\"select-instance-version\") and contains (@selected, \"selected\")]"); + + String componentNameStr = componentName.getAttribute("textContent").trim(), + componentTypeStr = componentType.getAttribute("class"); + + if (componentTypeStr.equals("S")) { + assertTrue(!(componentNameStr.equals(service.getName())), "Deleted service was found !!!"); + } + } + } + } + + public static void verifyServiceLifecycle(ServiceReqDetails service, User user, LifecycleStateEnum expectedLifecycleState) { + String responseAfterDrag = RestCDUtils.getService(service, user).getResponse(); + JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); + String actualLifecycleState = jsonResource.get("lifecycleState").toString(); + assertTrue(expectedLifecycleState.name().equals(actualLifecycleState), "actual: " + actualLifecycleState + "-- expected: " + expectedLifecycleState); + } + + public static void verifyServiceLifecycleInUI(LifeCycleStateEnum lifecycleState) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that service state is %s", lifecycleState.getValue())); + GeneralUIUtils.ultimateWait(); + assertTrue(ResourceGeneralPage.getLifeCycleState().equals(lifecycleState.getValue())); + } + + public static void verifyLinkCreated(ServiceReqDetails createServiceInUI, User user, int expectedRelationsSize) { + String responseAfterDrag = RestCDUtils.getService(createServiceInUI, user).getResponse(); + JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); + assertTrue(((JSONArray) jsonResource.get("componentInstancesRelations")).size() == expectedRelationsSize); + + } + + public static void verifyManagmentWorkflow(String expectedName, String expectedDescription) { + String actualName = GeneralUIUtils.getWebElementBy(By.cssSelector("div[class='text name']")).getText(); + String actualDescription = GeneralUIUtils.getWebElementBy(By.cssSelector("div[class='text description']")).getText(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifing name ( should be %s ) and description ( should be %s ) ", expectedName, expectedDescription)); + assertTrue(actualName.equals(expectedName) && actualDescription.equals(expectedDescription)); + } + + public static void verifyVersionUI(String expected) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that version is %s", expected)); + String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum. + GeneralElementsEnum.VERSION_HEADER.getValue()).getText().replace("V", ""); + assertTrue(actualVersion.equals(expected), String.format("Expected version: %s, Actual version: %s", expected, actualVersion)); + } + + public static void verifyResourceInstanceVersionUI(String expected) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that instance version is %s", expected)); + List selectedVersion = GeneralUIUtils. + findElementsByXpath("//option[contains(@class,\"select-instance-version\") and contains (@selected, \"selected\")]"); String actual = selectedVersion.get(0).getText(); - assertTrue(expected.equals(actual), String.format( "Expected version: %s, Actual version: %s", expected, actual)); + assertTrue(expected.equals(actual), String.format("Expected version: %s, Actual version: %s", expected, actual)); + } + + public static void verifyOpenTabTitle(DataTestIdEnum.CompositionScreenEnum currentTab) throws Exception { + List expectedTitles = new ArrayList(); + for (String expectedTitle : currentTab.getTitle()) { + expectedTitles.add(expectedTitle.toLowerCase()); + } + for (WebElement actualTitle : CompositionPage.getOpenTabTitle()) { + int indexOfTitle = expectedTitles.indexOf(actualTitle.getText().trim().toLowerCase()); + assertTrue(indexOfTitle >= 0, "Wrong title"); + expectedTitles.remove(indexOfTitle); + } + assertTrue(expectedTitles.size() == 0, "Missing titles in " + currentTab.getValue()); + } + + public static void verifyDeploymentPageSubElements(String moduleName, DeploymentViewVerificator verificatorObj) throws Exception { + + HashMap> moduleProperties = verificatorObj.getDeploymentViewData().get(moduleName); + + ServiceVerificator.moveMetadataPropertiesArtifactSection(-ARTIFACT_SECTION_OFFSET); + + List artifacts, properties; + artifacts = DeploymentPage.getArtifactNames(); + properties = DeploymentPage.getPropertyNames(); + assertTrue(moduleProperties.get("artifacts").size() == artifacts.size(), "Artifacts amount not as expected, expected " + moduleProperties.get("artifacts").size()); + assertTrue(moduleProperties.get("artifacts").containsAll(artifacts.stream(). + map(e -> e.getAttribute("textContent")). + collect(Collectors.toList()))); + assertTrue(moduleProperties.get("properties").size() == properties.size(), "Properties amount not as expected, expected " + moduleProperties.get("properties").size()); + assertTrue(moduleProperties.get("properties").containsAll(properties.stream(). + map(e -> e.getAttribute("textContent")). + collect(Collectors.toList()))); + + DeploymentPage.clickOnProperties(); + DeploymentPage.clickOnArtifacts(); + ServiceVerificator.moveMetadataPropertiesArtifactSection(ARTIFACT_SECTION_OFFSET); + } + + public static void verifyVFModuleCustomizationUUID(ServiceReqDetails service) throws Exception { + final int UUIDMinimalLength = 35; + Predicate componentInstancePredicate = e -> e.length() > UUIDMinimalLength; + List customizationUUIDList = getAllVFModuleCustomizationUUIDs(service); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating vfModuleCustomizationUUID uniqness ... ")); + assertTrue(customizationUUIDList.stream().allMatch(componentInstancePredicate), "vfModuleCustomizationUUID is less then 35 chars"); + CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDList); + } + + public static List getAllVFModuleCustomizationUUIDs(ServiceReqDetails service) throws Exception { + Service serviceObj = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, service.getName(), service.getVersion()); + List customizationUUIDList = serviceObj.getComponentInstances().get(0).getGroupInstances().stream(). + map(e -> e.getCustomizationUUID()). + collect(Collectors.toList()); + + return customizationUUIDList; } - - public static void verifyOpenTabTitle(DataTestIdEnum.CompositionScreenEnum currentTab) throws Exception{ - List expectedTitles = new ArrayList(); - for(String expectedTitle: currentTab.getTitle()){ - expectedTitles.add(expectedTitle.toLowerCase()); - } - for (WebElement actualTitle: CompositionPage.getOpenTabTitle()){ - int indexOfTitle = expectedTitles.indexOf(actualTitle.getText().trim().toLowerCase()); - assertTrue(indexOfTitle >= 0, "Wrong title"); - expectedTitles.remove(indexOfTitle); - } - assertTrue(expectedTitles.size() == 0, "Missing titles in " + currentTab.getValue()); - } - - public static void verifyDeploymentPageSubElements(String moduleName, DeploymentViewVerificator verificatorObj) throws Exception{ - HashMap> moduleProperties = verificatorObj.getDeploymentViewData().get(moduleName); - - ServiceVerificator.moveMetadataPropertiesArtifactSection(-700); - - List artifacts, properties; - artifacts = DeploymentPage.getArtifactNames(); - properties = DeploymentPage.getPropertyNames(); - assertTrue(moduleProperties.get("artifacts").size() == artifacts.size(), "Artifacts amount not as expected, expected " + moduleProperties.get("artifacts").size()); - assertTrue(moduleProperties.get("artifacts").containsAll(artifacts.stream(). - map(e -> e.getAttribute("textContent")). - collect(Collectors.toList()))); - assertTrue(moduleProperties.get("properties").size() == properties.size(), "Properties amount not as expected, expected " + moduleProperties.get("properties").size()); - assertTrue(moduleProperties.get("properties").containsAll(properties.stream(). - map(e -> e.getAttribute("textContent")). - collect(Collectors.toList()))); - - DeploymentPage.clickOnProperties(); - DeploymentPage.clickOnArtifacts(); - ServiceVerificator.moveMetadataPropertiesArtifactSection(700); - } - - public static void verifyVFModuleCustomizationUUID(ServiceReqDetails service) throws Exception { - Predicate componentInstancePredicate = e -> e.length() > 35; - List customizationUUIDList = getAllVFModuleCustomizationUUIDs(service); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating vfModuleCustomizationUUID uniqness ... ")); - assertTrue(customizationUUIDList.stream().allMatch(componentInstancePredicate), "vfModuleCustomizationUUID is less then 35 chars"); - CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDList); - } - - public static List getAllVFModuleCustomizationUUIDs(ServiceReqDetails service) throws Exception { - Service serviceObj = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, service.getName(), service.getVersion()); - List customizationUUIDList = serviceObj.getComponentInstances().get(0).getGroupInstances().stream(). - map(e -> e.getCustomizationUUID()). - collect(Collectors.toList()); - - return customizationUUIDList; - } - - public static String getVFModulePropertyValue(ServiceReqDetails service, String propertyName, String moduleName) throws Exception { - Service serviceObj = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, service.getName(), service.getVersion()); - List groupInstances = serviceObj.getComponentInstances().get(0).getGroupInstances(); - List groupInstancesProperties = groupInstances.stream(). - filter(e -> e.getName().equals(moduleName)). - findFirst(). - get(). - convertToGroupInstancesProperties(); - String propertyValue = groupInstancesProperties.stream(). - filter(e -> e.getName().equals(propertyName)). - findFirst(). - get(). - getValue(); - return propertyValue; - } - - public static boolean isEqualCustomizationUUIDsAfterChanges(List listBefore, List listAfter){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating if vfModuleCustomizationUUID changed after certification ... ")); - return (listBefore.size() == listAfter.size()) && (listBefore.containsAll(listAfter)); - } - - public static void verifyDisabledServiceProperties() throws Exception{ - List propertiesForCheck = Arrays.asList("isBase", "vf_module_type", "vf_module_label", "vf_module_description"); - List popupElementsForCheck = Arrays.asList(PropertiesPopupEnum.PROPERTY_NAME, - PropertiesPopupEnum.PROPERTY_DESCRIPTION, - PropertiesPopupEnum.PROPERTY_TYPE, - PropertiesPopupEnum.PROPERTY_VALUE); - ServiceVerificator.moveMetadataPropertiesArtifactSection(-700); - List properties = DeploymentPage.getPropertyNames(); - - for(WebElement property : properties){ - if (propertiesForCheck.contains(property.getAttribute("textContent"))){ - DeploymentPage.clickOnProperty(property); - Select propertTypeElement = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue())); - boolean isTypeBoolean = propertTypeElement.getFirstSelectedOption().getText().contains("boolean"); - for (PropertiesPopupEnum popupElement: popupElementsForCheck){ - if (isTypeBoolean && popupElement == PropertiesPopupEnum.PROPERTY_VALUE){ - assertTrue(GeneralUIUtils.checkForDisabledAttribute(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_BOOLEAN_VALUE.getValue()), String.format("Element %s not disabled ", property.getText())); - } else { - assertTrue(GeneralUIUtils.checkForDisabledAttribute(popupElement.getValue()), String.format("Element %s not disabled ", property.getText())); - } - } - new PropertyPopup().clickCancel(); - } - } - - DeploymentPage.clickOnProperties(); - ServiceVerificator.moveMetadataPropertiesArtifactSection(700); - } - - public static void verifyEnabledServiceProperties() throws Exception{ - List propertiesForCheck = Arrays.asList("initial_count", "max_vf_module_instances", "min_vf_module_instances"); - - ServiceVerificator.moveMetadataPropertiesArtifactSection(-700); - List properties = DeploymentPage.getPropertyNames(); - - ServiceVerificator.positiveFlow(propertiesForCheck, properties); - ServiceVerificator.negativeFlow(propertiesForCheck, properties); - - DeploymentPage.clickOnProperties(); - ServiceVerificator.moveMetadataPropertiesArtifactSection(700); - } - - public static void positiveFlow(List propertiesForCheck, List properties) - throws InterruptedException { - int baseNumber = new Random().nextInt(100) + 2; - for(WebElement property : properties){ - String propertyName = property.getAttribute("textContent"); - if (propertiesForCheck.contains(propertyName)){ - DeploymentPage.clickOnProperty(property); - int actualNumber = 0; - if (propertyName.equals("initial_count")){ - actualNumber = baseNumber; - } else if (propertyName.equals("max_vf_module_instances")) { - actualNumber = baseNumber + 1; - } else if (propertyName.equals("min_vf_module_instances")){ - actualNumber = baseNumber - 1; - } - - new PropertyPopup().insertPropertyDefaultValue(String.valueOf(actualNumber)); - new PropertyPopup().clickSave(); - assertTrue(DeploymentPage.getPropertyValueFromPropertiesList(propertyName).equals(String.valueOf(actualNumber))); - } - } - } - - public static void negativeFlow(List propertiesForCheck, List properties) - throws Exception { - int currentMaxValue = Integer.valueOf(DeploymentPage.getPropertyValueFromPropertiesList("max_vf_module_instances")); - int currentMinValue = Integer.valueOf(DeploymentPage.getPropertyValueFromPropertiesList("min_vf_module_instances")); - int currentInitialValue = Integer.valueOf(DeploymentPage.getPropertyValueFromPropertiesList("initial_count")); - PropertyPopup propertyPopupObj = new PropertyPopup(); - - for(WebElement property : properties){ - String propertyName = property.getAttribute("textContent"); - if (propertiesForCheck.contains(propertyName)){ - DeploymentPage.clickOnProperty(property); - if (propertyName.equals("initial_count")){ - - propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentMaxValue + 1)); - ServiceVerificator.verifyErrorPresentAndSaveDisabled(); - propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentMinValue - 1)); - ServiceVerificator.verifyErrorPresentAndSaveDisabled(); - propertyPopupObj.insertPropertyDefaultValue(String.valueOf(0)); - ServiceVerificator.verifyErrorPresentAndSaveDisabled(); - - } else if (propertyName.equals("max_vf_module_instances")) { - - propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentInitialValue - 1)); - ServiceVerificator.verifyErrorPresentAndSaveDisabled(); - propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentMinValue - 1)); - ServiceVerificator.verifyErrorPresentAndSaveDisabled(); - propertyPopupObj.insertPropertyDefaultValue(String.valueOf(0)); - verifyErrorPresentAndSaveDisabled(); - - } else if (propertyName.equals("min_vf_module_instances")){ - - propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentInitialValue + 1)); - ServiceVerificator.verifyErrorPresentAndSaveDisabled(); - propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentMaxValue + 1)); - ServiceVerificator.verifyErrorPresentAndSaveDisabled(); - } - - new PropertyPopup().clickCancel(); - } - } - } - - public static void verifyErrorPresentAndSaveDisabled() throws Exception{ - assertTrue(DeploymentPage.isPropertySaveButtonDisabled(), "Property Save button enabled, should be disabled"); - assertTrue(DeploymentPage.getPropertyErrorValidationMessdge().size() == 1, "Error msg missing for input"); - } - - public static void moveMetadataPropertiesArtifactSection(int offset) throws InterruptedException { - WebElement dragLineElement = GeneralUIUtils.getElementByCSS("div.rg-top"); - GeneralUIUtils.dragAndDropElementByY(dragLineElement, offset); - } - - + + public static String getVFModulePropertyValue(ServiceReqDetails service, String propertyName, String moduleName) throws Exception { + Service serviceObj = AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, service.getName(), service.getVersion()); + List groupInstances = serviceObj.getComponentInstances().get(0).getGroupInstances(); + List groupInstancesProperties = groupInstances.stream(). + filter(e -> e.getName().equals(moduleName)). + findFirst(). + get(). + convertToGroupInstancesProperties(); + String propertyValue = groupInstancesProperties.stream(). + filter(e -> e.getName().equals(propertyName)). + findFirst(). + get(). + getValue(); + return propertyValue; + } + + public static boolean isEqualCustomizationUUIDsAfterChanges(List listBefore, List listAfter) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating if vfModuleCustomizationUUID changed after certification ... ")); + return (listBefore.size() == listAfter.size()) && (listBefore.containsAll(listAfter)); + } + + public static void verifyDisabledServiceProperties() throws Exception { + List propertiesForCheck = Arrays.asList("isBase", "vf_module_type", "vf_module_label", "vf_module_description"); + List popupElementsForCheck = Arrays.asList(PropertiesPopupEnum.PROPERTY_NAME, + PropertiesPopupEnum.PROPERTY_DESCRIPTION, + PropertiesPopupEnum.PROPERTY_TYPE, + PropertiesPopupEnum.PROPERTY_VALUE); + ServiceVerificator.moveMetadataPropertiesArtifactSection(-ARTIFACT_SECTION_OFFSET); + List properties = DeploymentPage.getPropertyNames(); + + for (WebElement property : properties) { + if (propertiesForCheck.contains(property.getAttribute("textContent"))) { + DeploymentPage.clickOnProperty(property); + Select propertTypeElement = new Select(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_TYPE.getValue())); + boolean isTypeBoolean = propertTypeElement.getFirstSelectedOption().getText().contains("boolean"); + for (PropertiesPopupEnum popupElement : popupElementsForCheck) { + if (isTypeBoolean && popupElement == PropertiesPopupEnum.PROPERTY_VALUE) { + assertTrue(GeneralUIUtils.checkForDisabledAttribute(DataTestIdEnum.PropertiesPopupEnum.PROPERTY_BOOLEAN_VALUE.getValue()), String.format("Element %s not disabled ", property.getText())); + } else { + assertTrue(GeneralUIUtils.checkForDisabledAttribute(popupElement.getValue()), String.format("Element %s not disabled ", property.getText())); + } + } + new PropertyPopup().clickCancel(); + } + } + + DeploymentPage.clickOnProperties(); + ServiceVerificator.moveMetadataPropertiesArtifactSection(ARTIFACT_SECTION_OFFSET); + } + + public static void verifyEnabledServiceProperties() throws Exception { + List propertiesForCheck = Arrays.asList("initial_count", "max_vf_module_instances", "min_vf_module_instances"); + + ServiceVerificator.moveMetadataPropertiesArtifactSection(-ARTIFACT_SECTION_OFFSET); + List properties = DeploymentPage.getPropertyNames(); + + ServiceVerificator.positiveFlow(propertiesForCheck, properties); + ServiceVerificator.negativeFlow(propertiesForCheck, properties); + + DeploymentPage.clickOnProperties(); + ServiceVerificator.moveMetadataPropertiesArtifactSection(ARTIFACT_SECTION_OFFSET); + } + + public static void positiveFlow(List propertiesForCheck, List properties) + throws InterruptedException { + final int randomInteger = 100; + int baseNumber = new Random().nextInt(randomInteger) + 2; + for (WebElement property : properties) { + String propertyName = property.getAttribute("textContent"); + if (propertiesForCheck.contains(propertyName)) { + DeploymentPage.clickOnProperty(property); + int actualNumber = 0; + if (propertyName.equals("initial_count")) { + actualNumber = baseNumber; + } else if (propertyName.equals("max_vf_module_instances")) { + actualNumber = baseNumber + 1; + } else if (propertyName.equals("min_vf_module_instances")) { + actualNumber = baseNumber - 1; + } + + new PropertyPopup().insertPropertyDefaultValue(String.valueOf(actualNumber)); + new PropertyPopup().clickSave(); + assertTrue(DeploymentPage.getPropertyValueFromPropertiesList(propertyName).equals(String.valueOf(actualNumber))); + } + } + } + + public static void negativeFlow(List propertiesForCheck, List properties) + throws Exception { + int currentMaxValue = Integer.valueOf(DeploymentPage.getPropertyValueFromPropertiesList("max_vf_module_instances")); + int currentMinValue = Integer.valueOf(DeploymentPage.getPropertyValueFromPropertiesList("min_vf_module_instances")); + int currentInitialValue = Integer.valueOf(DeploymentPage.getPropertyValueFromPropertiesList("initial_count")); + PropertyPopup propertyPopupObj = new PropertyPopup(); + + for (WebElement property : properties) { + String propertyName = property.getAttribute("textContent"); + if (propertiesForCheck.contains(propertyName)) { + DeploymentPage.clickOnProperty(property); + if (propertyName.equals("initial_count")) { + + propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentMaxValue + 1)); + ServiceVerificator.verifyErrorPresentAndSaveDisabled(); + propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentMinValue - 1)); + ServiceVerificator.verifyErrorPresentAndSaveDisabled(); + propertyPopupObj.insertPropertyDefaultValue(String.valueOf(0)); + ServiceVerificator.verifyErrorPresentAndSaveDisabled(); + + } else if (propertyName.equals("max_vf_module_instances")) { + + propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentInitialValue - 1)); + ServiceVerificator.verifyErrorPresentAndSaveDisabled(); + propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentMinValue - 1)); + ServiceVerificator.verifyErrorPresentAndSaveDisabled(); + propertyPopupObj.insertPropertyDefaultValue(String.valueOf(0)); + verifyErrorPresentAndSaveDisabled(); + + } else if (propertyName.equals("min_vf_module_instances")) { + + propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentInitialValue + 1)); + ServiceVerificator.verifyErrorPresentAndSaveDisabled(); + propertyPopupObj.insertPropertyDefaultValue(String.valueOf(currentMaxValue + 1)); + ServiceVerificator.verifyErrorPresentAndSaveDisabled(); + } + + new PropertyPopup().clickCancel(); + } + } + } + + public static void verifyErrorPresentAndSaveDisabled() throws Exception { + assertTrue(DeploymentPage.isPropertySaveButtonDisabled(), "Property Save button enabled, should be disabled"); + assertTrue(DeploymentPage.getPropertyErrorValidationMessdge().size() == 1, "Error msg missing for input"); + } + + public static void moveMetadataPropertiesArtifactSection(int offset) throws InterruptedException { + WebElement dragLineElement = GeneralUIUtils.getElementByCSS("div.rg-top"); + GeneralUIUtils.dragAndDropElementByY(dragLineElement, offset); + } + + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ToscaValidation.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ToscaValidation.java index 4151360ba6..f6262d5131 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ToscaValidation.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ToscaValidation.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,12 @@ import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.sdc.toscaparser.api.parameters.Input; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.tosca.datatypes.*; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaGroupPropertyDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaGroupsTopologyTemplateDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaInputsTopologyTemplateDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaServiceGroupsMetadataDefinition; +import org.openecomp.sdc.ci.tests.tosca.datatypes.VfModuleDefinition; import java.lang.reflect.Field; import java.util.HashMap; @@ -39,174 +44,177 @@ import java.util.Map; public class ToscaValidation { - - /** - * @param expectedToscaDefinition - expected toscaDefinition object - * @param actualToscaDefinition - actual toscaDefinition object - * @return true if all validation success else return error map - */ - public static Either> resourceToscaMetadataValidator(ToscaDefinition expectedToscaDefinition, ToscaDefinition actualToscaDefinition){ - - SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate resource TOSCA metadata..."); - Map expectedMetadata = expectedToscaDefinition.getMetadata(); - Map actualMetadata = actualToscaDefinition.getMetadata(); - Either> resourceToscaMetadataValidator = compareStringMapData(expectedMetadata, actualMetadata); - if(resourceToscaMetadataValidator.isLeft()){ - SetupCDTest.getExtendTest().log(Status.INFO, "Resource TOSCA metadata verification success"); - }else{ - SetupCDTest.getExtendTest().log(Status.ERROR, "Resource TOSCA metadata verification failed" + resourceToscaMetadataValidator.right().value()); - } - return resourceToscaMetadataValidator; - } - - public static Boolean resourceToscaNodeTemplateMetadataValidator(Map> expectedMetadata, ToscaDefinition actualToscaDefinition){ - boolean isTestFailed = true; - for(String nodeTemplateName : expectedMetadata.keySet()){ - Either> serviceToscaMetadataValidator = componentToscaNodeTemplateMetadataValidator(expectedMetadata.get(nodeTemplateName), actualToscaDefinition, nodeTemplateName, ComponentTypeEnum.RESOURCE, nodeTemplateName); - if(!serviceToscaMetadataValidator.left().value()){ - isTestFailed = false; - } - } - return isTestFailed; - } - - public static Either> vfModuleJsonFileValidator(Map expectedVfModulesDefinitionObject, Map actualVfModulesDefinitionObject){ - SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate vf module json file..."); - Either> vfModuleFileValidator = compareObjectMapData(expectedVfModulesDefinitionObject, actualVfModulesDefinitionObject); - if(vfModuleFileValidator.isLeft()){ - SetupCDTest.getExtendTest().log(Status.INFO, "Vf module json file verification success"); - }else{ - SetupCDTest.getExtendTest().log(Status.ERROR, "Vf module json file verification failed" + vfModuleFileValidator.right().value().toString()); - } - return vfModuleFileValidator; - } - - public static Either> serviceToscaMetadataValidator(Map expectedMetadata, ToscaDefinition actualToscaDefinition){ - - SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA metadata..."); - Map actualMetadata = actualToscaDefinition.getMetadata(); - Either> serviceToscaMetadataValidator = compareStringMapData(expectedMetadata, actualMetadata); - if(serviceToscaMetadataValidator.isLeft()){ - SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA metadata verification success"); - }else{ - SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA metadata verification failed" + serviceToscaMetadataValidator.right().value().toString()); - } - return serviceToscaMetadataValidator; - } - - public static Either> serviceToscaGroupMetadataValidator(Map expectedServiceGroup, ToscaDefinition actualToscaDefinition){ - - SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA group metadata..."); - Map actualServiceGroups = actualToscaDefinition.getTopology_template().getGroups(); - Either> serviceToscaGroupMetadataValidator = compareServiceGroupMetadata(expectedServiceGroup, actualServiceGroups); - if(serviceToscaGroupMetadataValidator.isLeft()){ - SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA group metadata verification success"); - }else{ - SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA group metadata verification failed" + serviceToscaGroupMetadataValidator.right().value().toString()); - } - return serviceToscaGroupMetadataValidator; - } - - public static Either> compareServiceGroupMetadata(Map expectedServiceGroup, Map actualServiceGroups) { + + private ToscaValidation() { + } + + /** + * @param expectedToscaDefinition - expected toscaDefinition object + * @param actualToscaDefinition - actual toscaDefinition object + * @return true if all validation success else return error map + */ + public static Either> resourceToscaMetadataValidator(ToscaDefinition expectedToscaDefinition, ToscaDefinition actualToscaDefinition) { + + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate resource TOSCA metadata..."); + Map expectedMetadata = expectedToscaDefinition.getMetadata(); + Map actualMetadata = actualToscaDefinition.getMetadata(); + Either> resourceToscaMetadataValidator = compareStringMapData(expectedMetadata, actualMetadata); + if (resourceToscaMetadataValidator.isLeft()) { + SetupCDTest.getExtendTest().log(Status.INFO, "Resource TOSCA metadata verification success"); + } else { + SetupCDTest.getExtendTest().log(Status.ERROR, "Resource TOSCA metadata verification failed" + resourceToscaMetadataValidator.right().value()); + } + return resourceToscaMetadataValidator; + } + + public static Boolean resourceToscaNodeTemplateMetadataValidator(Map> expectedMetadata, ToscaDefinition actualToscaDefinition) { + boolean isTestFailed = true; + for (String nodeTemplateName : expectedMetadata.keySet()) { + Either> serviceToscaMetadataValidator = componentToscaNodeTemplateMetadataValidator(expectedMetadata.get(nodeTemplateName), actualToscaDefinition, nodeTemplateName, ComponentTypeEnum.RESOURCE, nodeTemplateName); + if (!serviceToscaMetadataValidator.left().value()) { + isTestFailed = false; + } + } + return isTestFailed; + } + + public static Either> vfModuleJsonFileValidator(Map expectedVfModulesDefinitionObject, Map actualVfModulesDefinitionObject) { + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate vf module json file..."); + Either> vfModuleFileValidator = compareObjectMapData(expectedVfModulesDefinitionObject, actualVfModulesDefinitionObject); + if (vfModuleFileValidator.isLeft()) { + SetupCDTest.getExtendTest().log(Status.INFO, "Vf module json file verification success"); + } else { + SetupCDTest.getExtendTest().log(Status.ERROR, "Vf module json file verification failed" + vfModuleFileValidator.right().value().toString()); + } + return vfModuleFileValidator; + } + + public static Either> serviceToscaMetadataValidator(Map expectedMetadata, ToscaDefinition actualToscaDefinition) { + + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA metadata..."); + Map actualMetadata = actualToscaDefinition.getMetadata(); + Either> serviceToscaMetadataValidator = compareStringMapData(expectedMetadata, actualMetadata); + if (serviceToscaMetadataValidator.isLeft()) { + SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA metadata verification success"); + } else { + SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA metadata verification failed" + serviceToscaMetadataValidator.right().value().toString()); + } + return serviceToscaMetadataValidator; + } + + public static Either> serviceToscaGroupMetadataValidator(Map expectedServiceGroup, ToscaDefinition actualToscaDefinition) { + + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA group metadata..."); + Map actualServiceGroups = actualToscaDefinition.getTopology_template().getGroups(); + Either> serviceToscaGroupMetadataValidator = compareServiceGroupMetadata(expectedServiceGroup, actualServiceGroups); + if (serviceToscaGroupMetadataValidator.isLeft()) { + SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA group metadata verification success"); + } else { + SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA group metadata verification failed" + serviceToscaGroupMetadataValidator.right().value().toString()); + } + return serviceToscaGroupMetadataValidator; + } + + private static Either> compareServiceGroupMetadata(Map expectedServiceGroup, Map actualServiceGroups) { Map errorMap = new HashMap<>(); - for (String groupName : expectedServiceGroup.keySet()){ - if (actualServiceGroups.get(groupName) == null ){ + for (String groupName : expectedServiceGroup.keySet()) { + if (actualServiceGroups.get(groupName) == null) { errorMap.put("group/module [" + groupName + "]", " does not exist in TOSCA main yaml"); - }else{ + } else { compareServiceGroupData(expectedServiceGroup.get(groupName), actualServiceGroups.get(groupName), groupName, errorMap); } } - if(!errorMap.isEmpty()){ + if (!errorMap.isEmpty()) { return Either.right(errorMap); } return Either.left(true); } - public static Either> compareServiceGroupData(ToscaServiceGroupsMetadataDefinition expectedServiceGroupMetadata, ToscaServiceGroupsMetadataDefinition actualServiceGroupMetadata, String groupName, Map errorMap) { + private static Either> compareServiceGroupData(ToscaServiceGroupsMetadataDefinition expectedServiceGroupMetadata, ToscaServiceGroupsMetadataDefinition actualServiceGroupMetadata, String groupName, Map errorMap) { Field[] declaredFields = expectedServiceGroupMetadata.getClass().getSuperclass().getFields(); - for (Field field : declaredFields){ - if(!field.getName().equals("serialVersionUID")) { - try { - String expectedValue = (String) field.get(expectedServiceGroupMetadata); - String actualValue = (String) field.get(actualServiceGroupMetadata); - comparingServiceGroupMetadata(groupName, errorMap, field, expectedValue, actualValue); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - } - - if(!errorMap.isEmpty()){ + for (Field field : declaredFields) { + if (!field.getName().equals("serialVersionUID")) { + try { + String expectedValue = (String) field.get(expectedServiceGroupMetadata); + String actualValue = (String) field.get(actualServiceGroupMetadata); + comparingServiceGroupMetadata(groupName, errorMap, field, expectedValue, actualValue); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } + + if (!errorMap.isEmpty()) { return Either.right(errorMap); } return Either.left(true); } -// ###########################UsingParser############################ -public static Either> serviceToscaGroupMetadataValidatorUsingParser(Map expectedServiceGroup, List actualServiceGroups){ + // ###########################UsingParser############################ + public static Either> serviceToscaGroupMetadataValidatorUsingParser(Map expectedServiceGroup, List actualServiceGroups) { - SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA group metadata..."); - Either> serviceToscaGroupMetadataValidator = compareServiceGroupMetadataUsingParser(expectedServiceGroup, actualServiceGroups); - if(serviceToscaGroupMetadataValidator.isLeft()){ - SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA group metadata verification vs. tosca parser success"); - }else{ - SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA group metadata verification vs. tosca parser failed" + serviceToscaGroupMetadataValidator.right().value().toString()); - } - return serviceToscaGroupMetadataValidator; -} + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA group metadata..."); + Either> serviceToscaGroupMetadataValidator = compareServiceGroupMetadataUsingParser(expectedServiceGroup, actualServiceGroups); + if (serviceToscaGroupMetadataValidator.isLeft()) { + SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA group metadata verification vs. tosca parser success"); + } else { + SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA group metadata verification vs. tosca parser failed" + serviceToscaGroupMetadataValidator.right().value().toString()); + } + return serviceToscaGroupMetadataValidator; + } + + private static Either> compareServiceGroupMetadataUsingParser(Map expectedServiceGroup, List actualServiceGroups) { + + Map errorMap = new HashMap<>(); + for (String groupName : expectedServiceGroup.keySet()) { + Group actualGroup = getServiceToscaParserGroupFromObject(groupName, actualServiceGroups); + if (actualGroup == null) { + errorMap.put("group/module [" + groupName + "]", " does not exist in TOSCA main yaml"); + } else { + compareServiceGroupDataUsingParser(expectedServiceGroup.get(groupName), actualGroup.getMetadata(), groupName, errorMap); + } + } + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } + + private static Group getServiceToscaParserGroupFromObject(String groupName, List actualServiceGroups) { + for (Group group : actualServiceGroups) { + if (group.getName().equals(groupName)) { + return group; + } + } + return null; + } + + private static Either> compareServiceGroupDataUsingParser(ToscaServiceGroupsMetadataDefinition expectedServiceGroupMetadata, Metadata actualServiceGroupMetadata, String groupName, Map errorMap) { + + Field[] declaredFields = expectedServiceGroupMetadata.getClass().getSuperclass().getFields(); + for (Field field : declaredFields) { + if (!field.getName().equals("serialVersionUID")) { + try { + String expectedValue = (String) field.get(expectedServiceGroupMetadata); + String actualValue = actualServiceGroupMetadata.getValue(field.getName()); + comparingServiceGroupMetadata(groupName, errorMap, field, expectedValue, actualValue); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } + + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } - public static Either> compareServiceGroupMetadataUsingParser(Map expectedServiceGroup, List actualServiceGroups) { - - Map errorMap = new HashMap<>(); - for (String groupName : expectedServiceGroup.keySet()){ - Group actualGroup = getServiceToscaParserGroupFromObject(groupName, actualServiceGroups); - if (actualGroup == null ){ - errorMap.put("group/module [" + groupName + "]", " does not exist in TOSCA main yaml"); - }else{ - compareServiceGroupDataUsingParser(expectedServiceGroup.get(groupName), actualGroup.getMetadata(), groupName, errorMap); - } - } - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } - - private static Group getServiceToscaParserGroupFromObject(String groupName, List actualServiceGroups) { - for(Group group : actualServiceGroups){ - if(group.getName().equals(groupName)){ - return group; - } - } - return null; - } - - public static Either> compareServiceGroupDataUsingParser(ToscaServiceGroupsMetadataDefinition expectedServiceGroupMetadata, Metadata actualServiceGroupMetadata, String groupName, Map errorMap) { - - Field[] declaredFields = expectedServiceGroupMetadata.getClass().getSuperclass().getFields(); - for (Field field : declaredFields){ - if(!field.getName().equals("serialVersionUID")) { - try { - String expectedValue = (String) field.get(expectedServiceGroupMetadata); - String actualValue = actualServiceGroupMetadata.getValue(field.getName()); - comparingServiceGroupMetadata(groupName, errorMap, field, expectedValue, actualValue); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - } - - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } - - private static void comparingServiceGroupMetadata(String groupName, Map errorMap, Field field, String expectedValue, String actualValue) { - if (expectedValue != null && !expectedValue.trim().equals("")) { + private static void comparingServiceGroupMetadata(String groupName, Map errorMap, Field field, String expectedValue, String actualValue) { + if (expectedValue != null && !expectedValue.trim().equals("")) { if (actualValue != null) { Boolean result = compareStringValue(expectedValue, actualValue); if (!result) { @@ -217,397 +225,381 @@ public static Either> serviceToscaGroupMetadataVali System.out.println("Data field [" + field.getName() + "] in group service metadata [" + groupName + "] does not exist in actual object"); } } - } + } -// ############################################################################################ +//############################################################################################ + // ###########################Property UsingParser############################ + public static Either> serviceToscaGroupPropertyValidatorUsingParser(Map expectedServiceGroup, List actualServiceGroups) { - // ###########################Property UsingParser############################ - public static Either> serviceToscaGroupPropertyValidatorUsingParser(Map expectedServiceGroup, List actualServiceGroups){ + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA group property..."); + Either> serviceToscaGroupMetadataValidator = compareServiceGroupPropertyUsingParser(expectedServiceGroup, actualServiceGroups); + if (serviceToscaGroupMetadataValidator.isLeft()) { + SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA group property verification vs. tosca parser success"); + } else { + SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA group property verification vs. tosca parser failed" + serviceToscaGroupMetadataValidator.right().value().toString()); + } + return serviceToscaGroupMetadataValidator; + } - SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA group property..."); - Either> serviceToscaGroupMetadataValidator = compareServiceGroupPropertyUsingParser(expectedServiceGroup, actualServiceGroups); - if(serviceToscaGroupMetadataValidator.isLeft()){ - SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA group property verification vs. tosca parser success"); - }else{ - SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA group property verification vs. tosca parser failed" + serviceToscaGroupMetadataValidator.right().value().toString()); - } - return serviceToscaGroupMetadataValidator; - } + private static Either> compareServiceGroupPropertyUsingParser(Map expectedServiceGroup, List actualServiceGroups) { - public static Either> compareServiceGroupPropertyUsingParser(Map expectedServiceGroup, List actualServiceGroups) { + Map errorMap = new HashMap<>(); + for (String groupName : expectedServiceGroup.keySet()) { + Group actualGroup = getServiceToscaParserGroupFromObject(groupName, actualServiceGroups); + if (actualGroup == null) { + errorMap.put("group/module [" + groupName + "]", " does not exist in TOSCA main yaml"); + } else { + compareServiceGroupPropertyUsingParser(expectedServiceGroup.get(groupName).getProperties(), actualGroup.getProperties(), groupName, errorMap); + } + } + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } - Map errorMap = new HashMap<>(); - for (String groupName : expectedServiceGroup.keySet()){ - Group actualGroup = getServiceToscaParserGroupFromObject(groupName, actualServiceGroups); - if (actualGroup == null ){ - errorMap.put("group/module [" + groupName + "]", " does not exist in TOSCA main yaml"); - }else{ - compareServiceGroupPropertyUsingParser(expectedServiceGroup.get(groupName).getProperties(), actualGroup.getProperties(), groupName, errorMap); - } - } - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } + private static Either> compareServiceGroupPropertyUsingParser(ToscaGroupPropertyDefinition expectedServiceGroupProperty, LinkedHashMap actualServiceGroupProperty, String groupName, Map errorMap) { + + Field[] declaredFields = expectedServiceGroupProperty.getClass().getDeclaredFields(); + for (Field field : declaredFields) { + if (!field.getName().equals("serialVersionUID")) { + try { + String expectedValue = null; + String actualValue = null; + if (field.get(expectedServiceGroupProperty) != null) { + expectedValue = field.get(expectedServiceGroupProperty).toString(); + } + if (actualServiceGroupProperty.get(field.getName()) != null && actualServiceGroupProperty.get(field.getName()).getValue() != null) { + actualValue = actualServiceGroupProperty.get(field.getName()).getValue().toString(); + } + comparingServiceGroupProperty(groupName, errorMap, field, expectedValue, actualValue); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } - public static Either> compareServiceGroupPropertyUsingParser(ToscaGroupPropertyDefinition expectedServiceGroupProperty, LinkedHashMap actualServiceGroupProperty, String groupName, Map errorMap) { + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } - Field[] declaredFields = expectedServiceGroupProperty.getClass().getDeclaredFields(); - for (Field field : declaredFields){ - if(!field.getName().equals("serialVersionUID")) { - try { - String expectedValue = null; - String actualValue = null; - if (field.get(expectedServiceGroupProperty) != null) { - expectedValue = field.get(expectedServiceGroupProperty).toString(); - } - if (actualServiceGroupProperty.get(field.getName()) != null && actualServiceGroupProperty.get(field.getName()).getValue() != null) { - actualValue = actualServiceGroupProperty.get(field.getName()).getValue().toString(); - } - comparingServiceGroupProperty(groupName, errorMap, field, expectedValue, actualValue); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - } +//############################################################################################ - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } -// ############################################################################################ + //?------- + public static Either> serviceToscaGroupPropertyValidator(Map expectedServiceGroup, ToscaDefinition actualToscaDefinition) { + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA group property..."); + Map actualServiceGroups = actualToscaDefinition.getTopology_template().getGroups(); + Either> serviceToscaGroupPropertyValidator = compareServiceGroupProperty(expectedServiceGroup, actualServiceGroups); + if (serviceToscaGroupPropertyValidator.isLeft()) { + SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA group property verification success"); + } else { + SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA group property verification failed" + serviceToscaGroupPropertyValidator.right().value().toString()); + } + return serviceToscaGroupPropertyValidator; + } + private static Either> compareServiceGroupProperty(Map expectedServiceGroup, Map actualServiceGroups) { + Map errorMap = new HashMap<>(); + for (String groupName : expectedServiceGroup.keySet()) { + if (actualServiceGroups.get(groupName) == null) { + errorMap.put("group/module [" + groupName + "]", " does not exist in TOSCA main yaml"); + } else { + compareServiceGroupProperty(expectedServiceGroup.get(groupName).getProperties(), actualServiceGroups.get(groupName).getProperties(), groupName, errorMap); + } + } + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } + private static Either> compareServiceGroupProperty(ToscaGroupPropertyDefinition expectedServiceGroupProperty, ToscaGroupPropertyDefinition actualServiceGroupProperty, String groupName, Map errorMap) { + + Field[] declaredFields = expectedServiceGroupProperty.getClass().getDeclaredFields(); + for (Field field : declaredFields) { + if (!field.getName().equals("serialVersionUID")) { + try { + String expectedValue = null; + String actualValue = null; + if (field.get(expectedServiceGroupProperty) != null) { + expectedValue = field.get(expectedServiceGroupProperty).toString(); + } + if (field.get(actualServiceGroupProperty) != null) { + actualValue = field.get(actualServiceGroupProperty).toString(); + } + comparingServiceGroupProperty(groupName, errorMap, field, expectedValue, actualValue); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } + private static void comparingServiceGroupProperty(String groupName, Map errorMap, Field field, String expectedValue, String actualValue) { + if (expectedValue != null && !expectedValue.trim().equals("")) { + if (actualValue != null) { + Boolean result = compareStringValue(expectedValue, actualValue); + if (!result) { + errorMap.put("Data field [" + field.getName() + "] in group service property [" + groupName + "]", "expected: " + expectedValue + ", actual: " + actualValue); + } + } else { + errorMap.put("Data field [" + field.getName() + "] in group service property [" + groupName + "]", " does not exist in actual object"); + System.out.println("Data field [" + field.getName() + "] in group service property [" + groupName + "] does not exist in actual object"); + } + } + } + // ---------------------------------- + public static Either> componentToscaNodeTemplateMetadataValidator(Map expectedMetadata, ToscaDefinition actualToscaDefinition, String nodeTemplateName, ComponentTypeEnum componentType, String componentName) { + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate " + componentName + " " + componentType.getValue() + " node template TOSCA metadata..."); + Map actualMetadata = actualToscaDefinition.getTopology_template().getNode_templates().get(nodeTemplateName).getMetadata(); + Either> componentToscaMetadataValidator = compareStringMapData(expectedMetadata, actualMetadata); + if (componentToscaMetadataValidator.isLeft()) { + SetupCDTest.getExtendTest().log(Status.INFO, " " + componentName + " " + componentType.getValue() + "TOSCA node template metadata verification success"); + } else { + SetupCDTest.getExtendTest().log(Status.ERROR, " " + componentName + " " + componentType.getValue() + "TOSCA node template metadata verification failed" + componentToscaMetadataValidator.right().value().toString()); + } + return componentToscaMetadataValidator; + } + public static Either> serviceToscaMetadataValidatorAgainstParser(Map expectedMetadata, Metadata actualMetadata) { + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA metadata..."); + Either> serviceToscaMetadataValidator = compareMetadataUsingToscaParser(expectedMetadata, actualMetadata); + if (serviceToscaMetadataValidator.isLeft()) { + SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA metadata verification vs. tosca parser success"); + } else { + SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA metadata verification vs. tosca parser failed" + serviceToscaMetadataValidator.right().value().toString()); + } + return serviceToscaMetadataValidator; + } + private static Either> compareStringMapData(Map expectedMetadata, Map actualMetadata) { + Either.left(false); + Map errorMap = new HashMap<>(); + for (String key : expectedMetadata.keySet()) { + boolean isError = compareStringValue(expectedMetadata.get(key), actualMetadata.get(key)); + if (!isError) { + errorMap.put("Data key[" + key + "]", "expected: " + expectedMetadata.get(key) + ", actual: " + actualMetadata.get(key)); + } + } + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } + private static Either> compareObjectMapData(Map expectedObject, Map actualObject) { + Map errorMap = new HashMap<>(); + for (String key : expectedObject.keySet()) { + boolean isError = compareObjectValue(expectedObject.get(key), actualObject.get(key)); + if (!isError) { + errorMap.put("Data key[" + key + "]", "expected: " + expectedObject.get(key) + ", actual: " + actualObject.get(key)); + } + } + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } -//?------- - public static Either> serviceToscaGroupPropertyValidator(Map expectedServiceGroup, ToscaDefinition actualToscaDefinition){ + private static boolean compareObjectValue(VfModuleDefinition expected, VfModuleDefinition actual) { + return expected.equals(actual); + } - SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA group property..."); - Map actualServiceGroups = actualToscaDefinition.getTopology_template().getGroups(); - Either> serviceToscaGroupPropertyValidator = compareServiceGroupProperty(expectedServiceGroup, actualServiceGroups); - if(serviceToscaGroupPropertyValidator.isLeft()){ - SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA group property verification success"); - }else{ - SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA group property verification failed" + serviceToscaGroupPropertyValidator.right().value().toString()); - } - return serviceToscaGroupPropertyValidator; - } + private static Either> compareMetadataUsingToscaParser(Map expectedMetadata, Metadata actualMetadata) { + Map errorMap = new HashMap<>(); + for (String key : expectedMetadata.keySet()) { + boolean isError = compareStringValue(expectedMetadata.get(key), actualMetadata.getValue(key)); + if (!isError) { + errorMap.put("Data key[" + key + "]", "expected: " + expectedMetadata.get(key) + ", actual: " + actualMetadata.getValue(key)); + } + } + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } - public static Either> compareServiceGroupProperty(Map expectedServiceGroup, Map actualServiceGroups) { + private static boolean compareStringValue(String expected, String actual) { + return expected.equals(actual); + } - Map errorMap = new HashMap<>(); - for (String groupName : expectedServiceGroup.keySet()){ - if (actualServiceGroups.get(groupName) == null ){ - errorMap.put("group/module [" + groupName + "]", " does not exist in TOSCA main yaml"); - }else{ - compareServiceGroupProperty(expectedServiceGroup.get(groupName).getProperties(), actualServiceGroups.get(groupName).getProperties(), groupName, errorMap); - } - } - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } - - public static Either> compareServiceGroupProperty(ToscaGroupPropertyDefinition expectedServiceGroupProperty, ToscaGroupPropertyDefinition actualServiceGroupProperty, String groupName, Map errorMap) { - - Field[] declaredFields = expectedServiceGroupProperty.getClass().getDeclaredFields(); - for (Field field : declaredFields){ - if(!field.getName().equals("serialVersionUID")) { - try { - String expectedValue = null; - String actualValue = null; - if(field.get(expectedServiceGroupProperty) != null) { - expectedValue = field.get(expectedServiceGroupProperty).toString(); - } - if(field.get(actualServiceGroupProperty) != null) { - actualValue = field.get(actualServiceGroupProperty).toString(); - } - comparingServiceGroupProperty(groupName, errorMap, field, expectedValue, actualValue); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - } + public static Either> toscaInputsValidator(Map expectedInputs, Map actualInputs) { - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate TOSCA inputs..."); + Either> toscaInputsValidator = compareInputs(expectedInputs, actualInputs); + if (toscaInputsValidator.isLeft()) { + SetupCDTest.getExtendTest().log(Status.INFO, "TOSCA inputs verification success"); + } else { + SetupCDTest.getExtendTest().log(Status.ERROR, "TOSCA inputs verification failed" + toscaInputsValidator.right().value().toString()); + } - private static void comparingServiceGroupProperty(String groupName, Map errorMap, Field field, String expectedValue, String actualValue) { - if (expectedValue != null && !expectedValue.trim().equals("")) { - if (actualValue != null) { - Boolean result = compareStringValue(expectedValue, actualValue); - if (!result) { - errorMap.put("Data field [" + field.getName() + "] in group service property [" + groupName + "]", "expected: " + expectedValue + ", actual: " + actualValue); - } + if (toscaInputsValidator.right() != null && !toscaInputsValidator.right().equals("")) { + return toscaInputsValidator; + } + return Either.left(true); + } + + private static Either> compareInputs(Map expectedInputs, Map actualInputs) { + + Map errorMap = new HashMap<>(); + + for (String inputName : expectedInputs.keySet()) { + if (actualInputs.get(inputName) == null) { + errorMap.put("input [" + inputName + "]", " does not exist in TOSCA main yaml"); } else { - errorMap.put("Data field [" + field.getName() + "] in group service property [" + groupName + "]", " does not exist in actual object"); - System.out.println("Data field [" + field.getName() + "] in group service property [" + groupName + "] does not exist in actual object"); + compareInputData(expectedInputs.get(inputName), actualInputs.get(inputName), errorMap); } } - } - - - // ---------------------------------- - public static Either> componentToscaNodeTemplateMetadataValidator(Map expectedMetadata, ToscaDefinition actualToscaDefinition, String nodeTemplateName, ComponentTypeEnum componentType, String componentName){ - - SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate "+ componentName + " " + componentType.getValue() + " node template TOSCA metadata..."); - Map actualMetadata = actualToscaDefinition.getTopology_template().getNode_templates().get(nodeTemplateName).getMetadata(); - Either> componentToscaMetadataValidator = compareStringMapData(expectedMetadata, actualMetadata); - if(componentToscaMetadataValidator.isLeft()){ - SetupCDTest.getExtendTest().log(Status.INFO, " " + componentName + " " + componentType.getValue() + "TOSCA node template metadata verification success"); - }else{ - SetupCDTest.getExtendTest().log(Status.ERROR, " " +componentName + " " + componentType.getValue() + "TOSCA node template metadata verification failed" + componentToscaMetadataValidator.right().value().toString()); - } - return componentToscaMetadataValidator; - } - - public static Either> serviceToscaMetadataValidatorAgainstParser(Map expectedMetadata, Metadata actualMetadata){ - - SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA metadata..."); - - Either> serviceToscaMetadataValidator = compareMetadataUsingToscaParser(expectedMetadata, actualMetadata); - if(serviceToscaMetadataValidator.isLeft()){ - SetupCDTest.getExtendTest().log(Status.INFO, "Service TOSCA metadata verification vs. tosca parser success"); - }else{ - SetupCDTest.getExtendTest().log(Status.ERROR, "Service TOSCA metadata verification vs. tosca parser failed" + serviceToscaMetadataValidator.right().value().toString()); - } - return serviceToscaMetadataValidator; - } - - - public static Either> compareStringMapData(Map expectedMetadata, Map actualMetadata) { - Either.left(false); - Map errorMap = new HashMap<>(); - for(String key : expectedMetadata.keySet()){ - boolean isError = compareStringValue(expectedMetadata.get(key), actualMetadata.get(key)); - if(!isError){ - errorMap.put("Data key["+key+"]", "expected: " + expectedMetadata.get(key) + ", actual: " + actualMetadata.get(key)); - } - } - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } - - - public static Either> compareObjectMapData(Map expectedObject, Map actualObject) { - Map errorMap = new HashMap<>(); - for(String key : expectedObject.keySet()){ - boolean isError = compareObjectValue(expectedObject.get(key), actualObject.get(key)); - if(!isError){ - errorMap.put("Data key["+key+"]", "expected: " + expectedObject.get(key) + ", actual: " + actualObject.get(key)); - } - } - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } - - private static boolean compareObjectValue(VfModuleDefinition expected, VfModuleDefinition actual) { - return expected.equals(actual); - } - - public static Either> compareMetadataUsingToscaParser(Map expectedMetadata, Metadata actualMetadata) { - Map errorMap = new HashMap<>(); - for(String key : expectedMetadata.keySet()){ - boolean isError = compareStringValue(expectedMetadata.get(key), actualMetadata.getValue(key)); - if(!isError){ - errorMap.put("Data key["+key+"]", "expected: " + expectedMetadata.get(key) + ", actual: " + actualMetadata.getValue(key)); - } - } - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } - - private static boolean compareStringValue(String expected, String actual) { - return expected.equals(actual); - } - - public static Either> toscaInputsValidator(Map expectedInputs, Map actualInputs){ - - SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate TOSCA inputs..."); - Either> toscaInputsValidator = compareInputs(expectedInputs, actualInputs); - if(toscaInputsValidator.isLeft()){ - SetupCDTest.getExtendTest().log(Status.INFO, "TOSCA inputs verification success"); - }else{ - SetupCDTest.getExtendTest().log(Status.ERROR, "TOSCA inputs verification failed" + toscaInputsValidator.right().value().toString()); - } - - if(toscaInputsValidator.right() != null && ! toscaInputsValidator.right().equals("")){ - return toscaInputsValidator; - } - return Either.left(true); - } - - public static Either> compareInputs(Map expectedInputs, Map actualInputs) { - - Map errorMap = new HashMap<>(); - - for (String inputName : expectedInputs.keySet()){ - if (actualInputs.get(inputName) == null ){ - errorMap.put("input [" + inputName + "]", " does not exist in TOSCA main yaml"); - }else{ - compareInputData(expectedInputs.get(inputName), actualInputs.get(inputName), errorMap); - } - } - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } - - public static Either> compareInputData(ToscaInputsTopologyTemplateDefinition expectedInputDefinition, ToscaInputsTopologyTemplateDefinition actualInputDefinition, Map errorMap) { - - Field[] declaredFields = expectedInputDefinition.getClass().getDeclaredFields(); - for (Field field : declaredFields){ - try { - Object expectedValue = field.get(expectedInputDefinition); - Object actualValue = field.get(actualInputDefinition); + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } + + private static Either> compareInputData(ToscaInputsTopologyTemplateDefinition expectedInputDefinition, ToscaInputsTopologyTemplateDefinition actualInputDefinition, Map errorMap) { + + Field[] declaredFields = expectedInputDefinition.getClass().getDeclaredFields(); + for (Field field : declaredFields) { + try { + Object expectedValue = field.get(expectedInputDefinition); + Object actualValue = field.get(actualInputDefinition); // verification exclude fields as (immutable, hidden, constraints, entry_schema) according Renana - if(expectedValue != null && !expectedValue.toString().trim().equals("") && field.getName() != "name" && field.getName() != "immutable" && field.getName() != "hidden" && field.getName() != "constraints" && field.getName() != "entry_schema" && field.getName() != "required") { - if (actualValue != null) { - compareInputValue(expectedInputDefinition, errorMap, field, expectedValue, actualValue); - } else { - errorMap.put("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "]", " does not exist in actual object"); - System.out.println("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "] does not exist in actual object"); - } - } - }catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - - if(!errorMap.isEmpty()){ - return Either.right(errorMap); - } - return Either.left(true); - } - - public static void compareInputValue(ToscaInputsTopologyTemplateDefinition expectedInputDefinition, Map errorMap, Field field, Object expectedValue, Object actualValue) { - if(field.getName().equals("value") || field.getName().equals("Default")){ - switch (expectedInputDefinition.getType()) { - case "string": - if(! expectedValue.toString().replace("\n"," ").replaceAll("( +)", " ").equals(actualValue.toString().replace("\n"," ").replaceAll("( +)", " "))){ - errorMap.put("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]", "expected: " + expectedValue + ", actual: " + actualValue); - System.out.println("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]: expected: " + expectedValue + ", actual: " + actualValue); - } - break; - case "float": - float newExpectedValue = convertObjectToFloat(expectedValue); - float newActualValue = convertObjectToFloat(actualValue); - if(newExpectedValue != newActualValue){ - errorMap.put("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]", "expected: " + newExpectedValue + ", actual: " + newActualValue); - System.out.println("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]: expected: " + newExpectedValue + ", actual: " + newActualValue); - } - break; - case "boolean": - if(! expectedValue.toString().equalsIgnoreCase(actualValue.toString())){ - errorMap.put("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]", "expected: " + expectedValue + ", actual: " + actualValue); - System.out.println("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]: expected: " + expectedValue + ", actual: " + actualValue); - } - break; - case "list": - expectedInputDefinition.getEntry_schema().get("type"); - break; - case "map": - - break; - default: - break; - } - - - }else{ - if(! expectedValue.equals(actualValue)){ - errorMap.put("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]", "expected: " + expectedValue + ", actual: " + actualValue); - System.out.println("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]: expected: " + expectedValue + ", actual: " + actualValue); - } - } - - } - - - public static float convertObjectToFloat(Object object){ - - float floatValue = 0; - - if(object instanceof Integer){ - floatValue = ((Integer)object).floatValue(); - } - if(object instanceof Double){ - floatValue = ((Double)object).floatValue(); - } - if(object instanceof Float){ - floatValue = ((Float) object).floatValue(); - } - if(object instanceof String){ - floatValue = Float.parseFloat(object.toString()); - } - - if(object instanceof Long){ - floatValue = ((Long) object).floatValue(); - } - return floatValue; - } - - public static Either> toscaInputsValidatorAgainstParser(Map expectedInputsMap, ISdcCsarHelper fdntCsarHelper) { - SetupCDTest.getExtendTest().log(Status.INFO, "Going to convert tosca parser inputs output to ToscaInputsTopologyTemplateDefinition object..."); - if(!fdntCsarHelper.getServiceInputs().isEmpty()){ - if(expectedInputsMap != null && ! expectedInputsMap.isEmpty()){ - return Either.left(true); - }else{ - Map errorMap = new HashMap<>(); - errorMap.put("Inputs", " do not exist on actual service"); - SetupCDTest.getExtendTest().log(Status.INFO, "Inputs do not exist on actual service csar"); - return Either.right(errorMap); - } - } - Map actualInputsMap = convertInputsParserOutputToMap(fdntCsarHelper); - return toscaInputsValidator(expectedInputsMap, actualInputsMap); - } - - /** - * @param fdntCsarHelper convert list of inputs return from tosca parser to map of ToscaInputsTopologyTemplateDefinition - * @return field.get(actualServiceGroupProperty) - */ - public static Map convertInputsParserOutputToMap(ISdcCsarHelper fdntCsarHelper) { - Map actualInputsMap = new HashMap<>(); - List serviceInputs = fdntCsarHelper.getServiceInputs(); - for (Input input : serviceInputs){ - ToscaInputsTopologyTemplateDefinition actualInputDefinition = new ToscaInputsTopologyTemplateDefinition(); - actualInputDefinition.setDefault(input.getDefault()); - actualInputDefinition.setType(input.getType()); - actualInputDefinition.setDescription(input.getDescription()); - actualInputsMap.put(input.getName(), actualInputDefinition); - } - return actualInputsMap; - } - + if (expectedValue != null && !expectedValue.toString().trim().equals("") && field.getName() != "name" && field.getName() != "immutable" && field.getName() != "hidden" && field.getName() != "constraints" && field.getName() != "entry_schema" && field.getName() != "required") { + if (actualValue != null) { + compareInputValue(expectedInputDefinition, errorMap, field, expectedValue, actualValue); + } else { + errorMap.put("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "]", " does not exist in actual object"); + System.out.println("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "] does not exist in actual object"); + } + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + + if (!errorMap.isEmpty()) { + return Either.right(errorMap); + } + return Either.left(true); + } + + private static void compareInputValue(ToscaInputsTopologyTemplateDefinition expectedInputDefinition, Map errorMap, Field field, Object expectedValue, Object actualValue) { + if (field.getName().equals("value") || field.getName().equals("Default")) { + switch (expectedInputDefinition.getType()) { + case "string": + if (!expectedValue.toString().replace("\n", " ").replaceAll("( +)", " ").equals(actualValue.toString().replace("\n", " ").replaceAll("( +)", " "))) { + errorMap.put("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "]", "expected: " + expectedValue + ", actual: " + actualValue); + System.out.println("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "]: expected: " + expectedValue + ", actual: " + actualValue); + } + break; + case "float": + float newExpectedValue = convertObjectToFloat(expectedValue); + float newActualValue = convertObjectToFloat(actualValue); + if (newExpectedValue != newActualValue) { + errorMap.put("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "]", "expected: " + newExpectedValue + ", actual: " + newActualValue); + System.out.println("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "]: expected: " + newExpectedValue + ", actual: " + newActualValue); + } + break; + case "boolean": + if (!expectedValue.toString().equalsIgnoreCase(actualValue.toString())) { + errorMap.put("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "]", "expected: " + expectedValue + ", actual: " + actualValue); + System.out.println("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "]: expected: " + expectedValue + ", actual: " + actualValue); + } + break; + case "list": + expectedInputDefinition.getEntry_schema().get("type"); + break; + case "map": + + break; + default: + break; + } + + + } else { + if (!expectedValue.equals(actualValue)) { + errorMap.put("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "]", "expected: " + expectedValue + ", actual: " + actualValue); + System.out.println("Data field [" + field.getName() + "] in input [" + expectedInputDefinition.getName() + "]: expected: " + expectedValue + ", actual: " + actualValue); + } + } + + } + + + private static float convertObjectToFloat(Object object) { + + float floatValue = 0; + + if (object instanceof Integer) { + floatValue = ((Integer) object).floatValue(); + } + if (object instanceof Double) { + floatValue = ((Double) object).floatValue(); + } + if (object instanceof Float) { + floatValue = ((Float) object).floatValue(); + } + if (object instanceof String) { + floatValue = Float.parseFloat(object.toString()); + } + + if (object instanceof Long) { + floatValue = ((Long) object).floatValue(); + } + return floatValue; + } + + public static Either> toscaInputsValidatorAgainstParser(Map expectedInputsMap, ISdcCsarHelper fdntCsarHelper) { + SetupCDTest.getExtendTest().log(Status.INFO, "Going to convert tosca parser inputs output to ToscaInputsTopologyTemplateDefinition object..."); + if (!fdntCsarHelper.getServiceInputs().isEmpty()) { + if (expectedInputsMap != null && !expectedInputsMap.isEmpty()) { + return Either.left(true); + } else { + Map errorMap = new HashMap<>(); + errorMap.put("Inputs", " do not exist on actual service"); + SetupCDTest.getExtendTest().log(Status.INFO, "Inputs do not exist on actual service csar"); + return Either.right(errorMap); + } + } + Map actualInputsMap = convertInputsParserOutputToMap(fdntCsarHelper); + return toscaInputsValidator(expectedInputsMap, actualInputsMap); + } + + /** + * @param fdntCsarHelper convert list of inputs return from tosca parser to map of ToscaInputsTopologyTemplateDefinition + * @return field.get(actualServiceGroupProperty) + */ + private static Map convertInputsParserOutputToMap(ISdcCsarHelper fdntCsarHelper) { + Map actualInputsMap = new HashMap<>(); + List serviceInputs = fdntCsarHelper.getServiceInputs(); + for (Input input : serviceInputs) { + ToscaInputsTopologyTemplateDefinition actualInputDefinition = new ToscaInputsTopologyTemplateDefinition(); + actualInputDefinition.setDefault(input.getDefault()); + actualInputDefinition.setType(input.getType()); + actualInputDefinition.setDescription(input.getDescription()); + actualInputsMap.put(input.getName(), actualInputDefinition); + } + return actualInputsMap; + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/UserManagementVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/UserManagementVerificator.java index 0eab56ac18..533899eed1 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/UserManagementVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/UserManagementVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,112 +38,111 @@ import java.util.List; public class UserManagementVerificator { + private UserManagementVerificator() { + } + + public static void validateUserCreated(String userId, UserRoleEnum role) { + + ExtentTestActions.log(Status.INFO, "Validating that a new user is created and displayed in the first row in the table."); + + final int firstRow = 0; + + WebElement actualFirstName = AdminGeneralPage.getUserManagementTab().getFirstName(firstRow); + WebElement actualLastName = AdminGeneralPage.getUserManagementTab().getLastName(firstRow); + WebElement actualUserId = AdminGeneralPage.getUserManagementTab().getUserId(firstRow); + WebElement actualEmail = AdminGeneralPage.getUserManagementTab().getEmail(firstRow); + WebElement actualRole = AdminGeneralPage.getUserManagementTab().getRole(firstRow); + WebElement actualLastActive = AdminGeneralPage.getUserManagementTab().getLastActive(firstRow); + + + String actualFirstNameText = actualFirstName.getText(); + String actualLastNameText = actualLastName.getText(); + String actualUserIdText = actualUserId.getText(); + String actualEmailText = actualEmail.getText(); + String actualRoleText = actualRole.getText(); + String actualLastActiveText = actualLastActive.getText(); + + Assert.assertTrue(actualFirstNameText.equals("---"), "Actual first name is not '---'."); + Assert.assertTrue(actualLastNameText.equals("---"), "Actual last name is not '---'."); + Assert.assertTrue(actualUserIdText.equals(userId), "Actual user id is not " + userId); + Assert.assertTrue(actualEmailText.equals("---"), "Actual email is not '---'."); + Assert.assertTrue(actualRoleText.equals(WordUtils.capitalize(role.name().toLowerCase())), "Actual role is not " + role.name()); + Assert.assertTrue(actualLastActiveText.equals("Waiting"), "Actual role is not 'Waiting'."); + } + + + public static void validateUserRoleUpdated(int rowIndx, UserRoleEnum updatedRole) { + ExtentTestActions.log(Status.INFO, "Validating role is updated to " + updatedRole.name() + " in UI."); + WebElement actualRole = AdminGeneralPage.getUserManagementTab().getRole(rowIndx); + String actualRoleText = actualRole.getText(); + Assert.assertTrue(actualRoleText.equals(WordUtils.capitalize(updatedRole.name().toLowerCase())), "Actual role is not " + updatedRole.name()); + } + + public static void validateUserRoleUpdatedViaRest(User reqUser, User user, UserRoleEnum expectedUserRole) { + try { + ExtentTestActions.log(Status.INFO, "Validating role is updated to " + expectedUserRole.name() + " in BE."); + String actualUserRole = RestCDUtils.getUserRole(reqUser, user); + Assert.assertTrue(expectedUserRole.name().toLowerCase().equals(actualUserRole.toLowerCase()), "User role is not updated."); + } catch (Exception e) { + Assert.fail("The actual user role is null"); + } + } + + public static void validateUserNotFoundViaRest(User reqUser, User user) { + try { + ExtentTestActions.log(Status.INFO, "Validating user " + reqUser.getUserId() + " is not found in BE."); + RestResponse getUserResp = RestCDUtils.getUser(reqUser, user); + ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.USER_INACTIVE.name(), Arrays.asList(reqUser.getUserId()), getUserResp.getResponse()); + } catch (Exception e) { + Assert.fail("The response message does not describe the user is not found."); + } + } + + public static void validateUserIdNotFound(String userId) { + ExtentTestActions.log(Status.INFO, "Validating that user " + userId + " is not found."); + AdminGeneralPage.getUserManagementTab().searchUser(userId); + List rows = AdminGeneralPage.getUserManagementTab().getAllRowsDisplayed(); + Assert.assertEquals(rows.size(), 0, String.format("There are %s rows instead of none.", rows.size())); + } + + public static void validateOnlySingleRowDisplayed() { + ExtentTestActions.log(Status.INFO, "Validating that only a single row is displayed in table."); + List rows = AdminGeneralPage.getUserManagementTab().getAllRowsDisplayed(); + Assert.assertEquals(rows.size(), 1, String.format("There are %s rows instead of %s.", rows.size(), 1)); + } + + public static void validateRowDisplayedCorrectly(User user, int rowindex) { + String role = user.getRole(); + String userId = user.getUserId(); + String firstName = user.getFirstName(); + String lastName = user.getLastName(); + String email = user.getEmail(); + + ExtentTestActions.log(Status.INFO, "Validating that the row is properly displayed."); + + WebElement actualFirstName = AdminGeneralPage.getUserManagementTab().getFirstName(rowindex); + WebElement actualLastName = AdminGeneralPage.getUserManagementTab().getLastName(rowindex); + WebElement actualUserId = AdminGeneralPage.getUserManagementTab().getUserId(rowindex); + WebElement actualEmail = AdminGeneralPage.getUserManagementTab().getEmail(rowindex); + WebElement actualRole = AdminGeneralPage.getUserManagementTab().getRole(rowindex); + + + String actualFirstNameText = actualFirstName.getText(); + String actualLastNameText = actualLastName.getText(); + String actualUserIdText = actualUserId.getText(); + String actualEmailText = actualEmail.getText(); + String actualRoleText = actualRole.getText(); + + Assert.assertTrue(actualFirstNameText.equals(firstName), "Actual first name is not " + firstName); + Assert.assertTrue(actualLastNameText.equals(lastName), "Actual last name is not " + lastName); + Assert.assertTrue(actualUserIdText.equals(userId), "Actual user id is not " + userId); + Assert.assertTrue(actualEmailText.contains(email), "Actual email does not contain " + email); + Assert.assertTrue(actualRoleText.equals(WordUtils.capitalize(role.toLowerCase())), "Actual role is not " + role); + } + + public static void validateFirstRowDisplayedCorrectly(User user) { + validateRowDisplayedCorrectly(user, 0); + } + - - public static void validateUserCreated(String userId, UserRoleEnum role){ - - ExtentTestActions.log(Status.INFO, "Validating that a new user is created and displayed in the first row in the table."); - - final int firstRow = 0; - - WebElement actualFirstName = AdminGeneralPage.getUserManagementTab().getFirstName(firstRow); - WebElement actualLastName = AdminGeneralPage.getUserManagementTab().getLastName(firstRow); - WebElement actualUserId = AdminGeneralPage.getUserManagementTab().getUserId(firstRow); - WebElement actualEmail = AdminGeneralPage.getUserManagementTab().getEmail(firstRow); - WebElement actualRole = AdminGeneralPage.getUserManagementTab().getRole(firstRow); - WebElement actualLastActive = AdminGeneralPage.getUserManagementTab().getLastActive(firstRow); - - - String actualFirstNameText = actualFirstName.getText(); - String actualLastNameText = actualLastName.getText(); - String actualUserIdText = actualUserId.getText(); - String actualEmailText = actualEmail.getText(); - String actualRoleText = actualRole.getText(); - String actualLastActiveText = actualLastActive.getText(); - - Assert.assertTrue(actualFirstNameText.equals("---"), "Actual first name is not '---'."); - Assert.assertTrue(actualLastNameText.equals("---"), "Actual last name is not '---'."); - Assert.assertTrue(actualUserIdText.equals(userId), "Actual user id is not " + userId); - Assert.assertTrue(actualEmailText.equals("---"), "Actual email is not '---'."); - Assert.assertTrue(actualRoleText.equals(WordUtils.capitalize(role.name().toLowerCase())), "Actual role is not " + role.name()); - Assert.assertTrue(actualLastActiveText.equals("Waiting"), "Actual role is not 'Waiting'."); - } - - - public static void validateUserRoleUpdated(int rowIndx, UserRoleEnum updatedRole){ - ExtentTestActions.log(Status.INFO, "Validating role is updated to " + updatedRole.name() + " in UI."); - WebElement actualRole = AdminGeneralPage.getUserManagementTab().getRole(rowIndx); - String actualRoleText = actualRole.getText(); - Assert.assertTrue(actualRoleText.equals(WordUtils.capitalize(updatedRole.name().toLowerCase())), "Actual role is not " + updatedRole.name()); - } - - public static void validateUserRoleUpdatedViaRest(User reqUser, User user, UserRoleEnum expectedUserRole){ - try{ - ExtentTestActions.log(Status.INFO, "Validating role is updated to " + expectedUserRole.name() + " in BE."); - String actualUserRole = RestCDUtils.getUserRole(reqUser, user); - Assert.assertTrue(expectedUserRole.name().toLowerCase().equals(actualUserRole.toLowerCase()), "User role is not updated."); - } - catch(Exception e){ - Assert.fail("The actual user role is null"); - } - } - - public static void validateUserNotFoundViaRest(User reqUser, User user){ - try{ - ExtentTestActions.log(Status.INFO, "Validating user " + reqUser.getUserId() + " is not found in BE."); - RestResponse getUserResp = RestCDUtils.getUser(reqUser, user); - ErrorValidationUtils.checkBodyResponseOnError(ActionStatus.USER_INACTIVE.name(), Arrays.asList(reqUser.getUserId()), getUserResp.getResponse()); - } - catch(Exception e){ - Assert.fail("The response message does not describe the user is not found."); - } - } - - public static void validateUserIdNotFound(String userId){ - ExtentTestActions.log(Status.INFO, "Validating that user " + userId + " is not found."); - AdminGeneralPage.getUserManagementTab().searchUser(userId); - List rows = AdminGeneralPage.getUserManagementTab().getAllRowsDisplayed(); - Assert.assertEquals(rows.size(), 0, String.format("There are %s rows instead of none.", rows.size())); - } - - public static void validateOnlySingleRowDisplayed(){ - ExtentTestActions.log(Status.INFO, "Validating that only a single row is displayed in table."); - List rows = AdminGeneralPage.getUserManagementTab().getAllRowsDisplayed(); - Assert.assertEquals(rows.size(), 1, String.format("There are %s rows instead of %s.", rows.size(), 1)); - } - - public static void validateRowDisplayedCorrectly(User user, int rowindex){ - String role = user.getRole(); - String userId = user.getUserId(); - String firstName = user.getFirstName(); - String lastName = user.getLastName(); - String email = user.getEmail(); - - ExtentTestActions.log(Status.INFO, "Validating that the row is properly displayed."); - - WebElement actualFirstName = AdminGeneralPage.getUserManagementTab().getFirstName(rowindex); - WebElement actualLastName = AdminGeneralPage.getUserManagementTab().getLastName(rowindex); - WebElement actualUserId = AdminGeneralPage.getUserManagementTab().getUserId(rowindex); - WebElement actualEmail = AdminGeneralPage.getUserManagementTab().getEmail(rowindex); - WebElement actualRole = AdminGeneralPage.getUserManagementTab().getRole(rowindex); - - - String actualFirstNameText = actualFirstName.getText(); - String actualLastNameText = actualLastName.getText(); - String actualUserIdText = actualUserId.getText(); - String actualEmailText = actualEmail.getText(); - String actualRoleText = actualRole.getText(); - - Assert.assertTrue(actualFirstNameText.equals(firstName), "Actual first name is not " + firstName); - Assert.assertTrue(actualLastNameText.equals(lastName), "Actual last name is not " + lastName); - Assert.assertTrue(actualUserIdText.equals(userId), "Actual user id is not " + userId); - Assert.assertTrue(actualEmailText.contains(email), "Actual email does not contain " + email); - Assert.assertTrue(actualRoleText.equals(WordUtils.capitalize(role.toLowerCase())), "Actual role is not " + role); - } - - public static void validateFirstRowDisplayedCorrectly(User user){ - validateRowDisplayedCorrectly(user, 0); - } - - } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCArtifactVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCArtifactVerificator.java index 7284dc68f6..c87e5b792a 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCArtifactVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCArtifactVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,6 +21,7 @@ package org.openecomp.sdc.ci.tests.verificator; import com.aventstack.extentreports.Status; +import org.apache.http.HttpStatus; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; @@ -42,304 +43,304 @@ import java.util.stream.Collectors; import static org.testng.Assert.assertTrue; public class VFCArtifactVerificator { - - private static final String ARTIFACTS = "artifacts"; - private static final String DEPLOYMENT_ARTIFACTS = "deploymentArtifacts"; - private static List vfcArtifactList = new ArrayList(); - private static JSONObject jsonResource; - - public static void verifyVFCArtifactsNotInVFArtifactList(ResourceReqDetails resource , User user, RestResponse optionalGetResponse, Map> expectedArtifactMap){ - ExtentTestActions.log(Status.INFO, "Verifying that VFC artifacts are not as part of VF artifacts."); - LinkedList expectedDeploymentArtifacts = expectedArtifactMap.get(DEPLOYMENT_ARTIFACTS); - LinkedList expectedInformationalArtifacts = expectedArtifactMap.get(ARTIFACTS); - - Map vfDepArtifacts = getVFDeploymentArtifacts(resource, user, optionalGetResponse); - for (Object artifact : vfDepArtifacts.values()){ - JSONObject acArtifact = ((JSONObject) JSONValue.parse(artifact.toString())); - String acArtifactName = acArtifact.get("artifactName").toString(); - - for(HeatMetaFirstLevelDefinition exDepArtifact : expectedDeploymentArtifacts){ - assertTrue(!exDepArtifact.getType().equals(acArtifactName)); - } - } - - Map vfInfoArtifacts = getVFInforamtionalArtifacts(resource, user, optionalGetResponse); - for (Object artifact : vfInfoArtifacts.values()){ - JSONObject acArtifact = ((JSONObject) JSONValue.parse(artifact.toString())); - if (acArtifact.containsKey("artifactName")){ - String acArtifactName = acArtifact.get("artifactName").toString(); - - for(HeatMetaFirstLevelDefinition exInfoArtifact : expectedInformationalArtifacts){ - assertTrue(!exInfoArtifact.getType().equals(acArtifactName)); - } - } - - - } - - - - } - - public static void verifyVfcArtifactUpdated(String instanceName, ResourceReqDetails resource, User user){ - ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts are updated."); - List vfcArtifactsBeforeUpdate = getVfcArtifactList(); - - setVfcArtifactList(new ArrayList()); - setActualVfcArtifactList(instanceName, resource, user); - - for (VFCArtifact artifact : vfcArtifactsBeforeUpdate){ - String artifactnameBeforeUpdate = artifact.getArtifactname(); - for (VFCArtifact newArtifact : vfcArtifactList){ - String artifactnameAfterUpdate = newArtifact.getArtifactname(); - if (artifactnameBeforeUpdate.equals(artifactnameAfterUpdate)){ - String artifactUUIDAfterUpdate = newArtifact.getArtifactUUID(); - assertTrue(!artifactUUIDAfterUpdate.equals(artifact.getArtifactUUID())); - - int artifactVersionAfterUpdate = Integer.parseInt(newArtifact.getArtifactVersion()); - int artifactVersionBeforeUpdate = Integer.parseInt(artifact.getArtifactVersion()); - assertTrue(artifactVersionAfterUpdate == artifactVersionBeforeUpdate + 1); - - - vfcArtifactList.remove(newArtifact); - - ExtentTestActions.log(Status.INFO, "VFC artifacts are updated and verified."); - - break; - } - } - } - - - assertTrue(vfcArtifactList.size() == 0); - - } - - public static void verifyVFCArtifactNotChanged(String instanceName, ResourceReqDetails resource, User user){ - ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts are not chaned after update."); - List vfcArtifactsBeforeUpdate = getVfcArtifactList(); - - setVfcArtifactList(new ArrayList()); - setActualVfcArtifactList(instanceName, resource, user); - - for (VFCArtifact artifact : vfcArtifactsBeforeUpdate){ - String artifactnameBeforeUpdate = artifact.getArtifactname(); - for (VFCArtifact newArtifact : vfcArtifactList){ - String artifactnameAfterUpdate = newArtifact.getArtifactname(); - if (artifactnameBeforeUpdate.equals(artifactnameAfterUpdate)){ - String artifactUUIDAfterUpdate = newArtifact.getArtifactUUID(); - assertTrue(artifactUUIDAfterUpdate.equals(artifact.getArtifactUUID())); - - int artifactVersionAfterUpdate = Integer.parseInt(newArtifact.getArtifactVersion()); - int artifactVersionBeforeUpdate = Integer.parseInt(artifact.getArtifactVersion()); - assertTrue(artifactVersionAfterUpdate == artifactVersionBeforeUpdate); - - vfcArtifactList.remove(newArtifact); - break; - } - } - } - - - assertTrue(vfcArtifactList.size() == 0); - - } - - public static void verifyNoVfcArtifacts(ResourceReqDetails resource , User user, RestResponse optionalGetResponse){ - ExtentTestActions.log(Status.INFO, "Verifying that there are no VFC artifacts at all."); - JSONArray jArr = getVFInstances(resource, user, optionalGetResponse); - for (Object instanceObj : jArr){ - JSONObject instance = (JSONObject) JSONValue.parse(instanceObj.toString()); - List actualDeploymentArtifacts = getActualVfcInstanceArtifactsFromJson(DEPLOYMENT_ARTIFACTS, instance); - - assertTrue(actualDeploymentArtifacts == null || actualDeploymentArtifacts.size() == 0); - } - } - - public static void verifyVfcArtifacts(ResourceReqDetails resource , User user, String instanceName, Map> expectedArtifactMap, - RestResponse optionalGetResponse){ - ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts for instance named " + instanceName); - - String exCompName = instanceName.split(".vfc.")[1].toLowerCase(); - String exName = instanceName.split(".heat.")[1].toLowerCase(); - - JSONArray jArr = getVFInstances(resource, user, optionalGetResponse); - int jArrSize = jArr.size(); - - for (Object instanceObj : jArr){ - JSONObject instance = (JSONObject) JSONValue.parse(instanceObj.toString()); - String componentName = instance.get("componentName").toString().toLowerCase(); - String name = instance.get("name").toString().toLowerCase(); - - if (componentName.contains(exCompName) || name.toLowerCase().equals(exName)){ - - List actualDeploymentArtifacts = getActualVfcInstanceArtifactsFromJson(DEPLOYMENT_ARTIFACTS, instance); - LinkedList expectedDeploymentArtifacts = expectedArtifactMap.get(DEPLOYMENT_ARTIFACTS); - checkVFCArtifactsExist(expectedDeploymentArtifacts, actualDeploymentArtifacts); - - - List actualInformationalArtifacts = getActualVfcInstanceArtifactsFromJson(ARTIFACTS, instance); - LinkedList expectedInformationalArtifacts = expectedArtifactMap.get(ARTIFACTS); - checkVFCArtifactsExist(expectedInformationalArtifacts, actualInformationalArtifacts); - - jArr.remove(instanceObj); - - ExtentTestActions.log(Status.INFO, "VFC artifacts for instance named " + instanceName + "are verified."); - - break; - } - } - - assertTrue(jArr.size() == jArrSize - 1, "Instance " + instanceName + " was not found and tested"); - - } - - - - private static JSONArray getVFInstances(ResourceReqDetails resource, User user, RestResponse response) { - - jsonResource = getVFAsJsonObject(resource, user, response); - JSONArray jArr = (JSONArray) jsonResource.get("componentInstances"); - return jArr; - } - - private static Map getVFDeploymentArtifacts(ResourceReqDetails resource, User user, RestResponse response) { - - jsonResource = getVFAsJsonObject(resource, user, response); - Map jArr = (Map) jsonResource.get(DEPLOYMENT_ARTIFACTS); - return jArr; - } - - private static Map getVFInforamtionalArtifacts(ResourceReqDetails resource, User user, RestResponse response) { - - jsonResource = getVFAsJsonObject(resource, user, response); - Map jArr = (Map) jsonResource.get(ARTIFACTS); - return jArr; - } - - private static JSONObject getVFAsJsonObject(ResourceReqDetails resource, User user, RestResponse response) { - if (response == null){ - resource.setUniqueId(null); - response = RestCDUtils.getResource(resource, user); - assertTrue(response.getErrorCode().intValue() == 200); - getVFAsJsonObject(resource, user, response); - } - - String responseAfterDrag = response.getResponse(); - jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - return jsonResource; - } - - - - private static List getActualVfcInstanceArtifactsFromJson(String artifactKind, JSONObject instanceFromJson){ - Object actualtObject = instanceFromJson.get(artifactKind); - if (actualtObject != null){ - JSONObject actualJsonObject = (JSONObject) JSONValue.parse(actualtObject.toString()); - List actualArtifacts = (List) actualJsonObject.keySet().stream().map(e -> actualJsonObject.get(e).toString()).collect(Collectors.toList()); - return actualArtifacts; - } - return null; - } - - private static void checkVFCArtifactsExist(LinkedList expectedArtifacts, List actualArtifacts) { - if (expectedArtifacts == null){ - return; - } - - if (expectedArtifacts.size() != actualArtifacts.size()){ - ExtentTestActions.log(Status.FAIL, "Expected and actual VFC artifacts lists size are not the same. Expected size: " + expectedArtifacts.size() + " , actual size: " + actualArtifacts.size()); - Assert.fail("Expected and actual VFC artifacts lists size are not the same. Expected size: " + expectedArtifacts.size() + " , actual size: " + actualArtifacts.size()); - } - - List types = new ArrayList(); - List fileNames = new ArrayList(); - for (HeatMetaFirstLevelDefinition exArtifact : expectedArtifacts){ - - fileNames.add(exArtifact.getFileName()); - types.add(exArtifact.getType()); - - } - - for (int i = 0 ; i < actualArtifacts.size() ; i++){ - String actualArtifactsString = actualArtifacts.get(i); - JSONObject acArtifact = ((JSONObject) JSONValue.parse(actualArtifactsString)); - - String acArtifactFileName = acArtifact.get("artifactName").toString(); - String acArtifactType = acArtifact.get("artifactType").toString(); - - assertTrue(types.contains(acArtifactType), "List does not contain " + acArtifactType); - assertTrue(fileNames.contains(acArtifactFileName), "List does not contain " + acArtifactFileName); - - types.remove(acArtifactType); - fileNames.remove(acArtifactFileName); - - } - - assertTrue(types.size() == 0); - assertTrue(fileNames.size() == 0); - - } - - public static List getVfcArtifactList(){ - return vfcArtifactList; - } - - - public static void setVfcArtifactList(List vfcArtifactList) { - VFCArtifactVerificator.vfcArtifactList = vfcArtifactList; - } - - public static void setActualVfcArtifactList(String instanceName, ResourceReqDetails resource , User user) { - String exCompName = instanceName.split(".vfc.")[1].toLowerCase(); - String exName = instanceName.split(".heat.")[1].toLowerCase(); - - JSONArray jArr = getVFInstances(resource, user, null); - - for (Object instanceObj : jArr){ - JSONObject instance = (JSONObject) JSONValue.parse(instanceObj.toString()); - String componentName = instance.get("componentName").toString().toLowerCase(); - String name = instance.get("name").toString().toLowerCase(); - - if (componentName.contains(exCompName) || name.toLowerCase().equals(exName)){ - List actualDeploymentArtifacts = getActualVfcInstanceArtifactsFromJson(DEPLOYMENT_ARTIFACTS, instance); - List actualInformationalArtifacts = getActualVfcInstanceArtifactsFromJson(ARTIFACTS, instance); - - if (actualDeploymentArtifacts != null){ - for (int i = 0 ; i < actualDeploymentArtifacts.size() ; i++){ - String actualArtifactsString = actualDeploymentArtifacts.get(i); - JSONObject acArtifact = ((JSONObject) JSONValue.parse(actualArtifactsString)); - - if (acArtifact.containsKey("artifactName")){ - String acArtifactType = acArtifact.get("artifactName").toString(); - String acArtifactFileName = acArtifact.get("artifactType").toString(); - String acArtifactUUID = acArtifact.get("artifactUUID").toString(); - String acArtifactVersion = acArtifact.get("artifactVersion").toString(); - - vfcArtifactList.add(new VFCArtifact(acArtifactType, acArtifactFileName, acArtifactUUID, acArtifactVersion)); - } - } - } - if (actualInformationalArtifacts != null){ - for (int i = 0 ; i < actualInformationalArtifacts.size() ; i++){ - String actualArtifactsString = actualInformationalArtifacts.get(i); - JSONObject acArtifact = ((JSONObject) JSONValue.parse(actualArtifactsString)); - - if (acArtifact.containsKey("artifactName")){ - String acArtifactType = acArtifact.get("artifactName").toString(); - String acArtifactFileName = acArtifact.get("artifactType").toString(); - String acArtifactUUID = acArtifact.get("artifactUUID").toString(); - String acArtifactVersion = acArtifact.get("artifactVersion").toString(); - vfcArtifactList.add(new VFCArtifact(acArtifactType, acArtifactFileName, acArtifactUUID, acArtifactVersion)); - } - - - } - } - } - } - } - + + private VFCArtifactVerificator() { + } + + private static final String ARTIFACTS = "artifacts"; + private static final String DEPLOYMENT_ARTIFACTS = "deploymentArtifacts"; + private static List vfcArtifactList = new ArrayList(); + private static JSONObject jsonResource; + + public static void verifyVFCArtifactsNotInVFArtifactList(ResourceReqDetails resource, User user, RestResponse optionalGetResponse, Map> expectedArtifactMap) { + ExtentTestActions.log(Status.INFO, "Verifying that VFC artifacts are not as part of VF artifacts."); + LinkedList expectedDeploymentArtifacts = expectedArtifactMap.get(DEPLOYMENT_ARTIFACTS); + LinkedList expectedInformationalArtifacts = expectedArtifactMap.get(ARTIFACTS); + + Map vfDepArtifacts = getVFDeploymentArtifacts(resource, user, optionalGetResponse); + for (Object artifact : vfDepArtifacts.values()) { + JSONObject acArtifact = ((JSONObject) JSONValue.parse(artifact.toString())); + String acArtifactName = acArtifact.get("artifactName").toString(); + + for (HeatMetaFirstLevelDefinition exDepArtifact : expectedDeploymentArtifacts) { + assertTrue(!exDepArtifact.getType().equals(acArtifactName)); + } + } + + Map vfInfoArtifacts = getVFInforamtionalArtifacts(resource, user, optionalGetResponse); + for (Object artifact : vfInfoArtifacts.values()) { + JSONObject acArtifact = ((JSONObject) JSONValue.parse(artifact.toString())); + if (acArtifact.containsKey("artifactName")) { + String acArtifactName = acArtifact.get("artifactName").toString(); + + for (HeatMetaFirstLevelDefinition exInfoArtifact : expectedInformationalArtifacts) { + assertTrue(!exInfoArtifact.getType().equals(acArtifactName)); + } + } + + + } + + + } + + public static void verifyVfcArtifactUpdated(String instanceName, ResourceReqDetails resource, User user) { + ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts are updated."); + List vfcArtifactsBeforeUpdate = getVfcArtifactList(); + + setVfcArtifactList(new ArrayList()); + setActualVfcArtifactList(instanceName, resource, user); + + for (VFCArtifact artifact : vfcArtifactsBeforeUpdate) { + String artifactnameBeforeUpdate = artifact.getArtifactname(); + for (VFCArtifact newArtifact : vfcArtifactList) { + String artifactnameAfterUpdate = newArtifact.getArtifactname(); + if (artifactnameBeforeUpdate.equals(artifactnameAfterUpdate)) { + String artifactUUIDAfterUpdate = newArtifact.getArtifactUUID(); + assertTrue(!artifactUUIDAfterUpdate.equals(artifact.getArtifactUUID())); + + int artifactVersionAfterUpdate = Integer.parseInt(newArtifact.getArtifactVersion()); + int artifactVersionBeforeUpdate = Integer.parseInt(artifact.getArtifactVersion()); + assertTrue(artifactVersionAfterUpdate == artifactVersionBeforeUpdate + 1); + + + vfcArtifactList.remove(newArtifact); + + ExtentTestActions.log(Status.INFO, "VFC artifacts are updated and verified."); + + break; + } + } + } + + + assertTrue(vfcArtifactList.size() == 0); + + } + + public static void verifyVFCArtifactNotChanged(String instanceName, ResourceReqDetails resource, User user) { + ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts are not chaned after update."); + List vfcArtifactsBeforeUpdate = getVfcArtifactList(); + + setVfcArtifactList(new ArrayList()); + setActualVfcArtifactList(instanceName, resource, user); + + for (VFCArtifact artifact : vfcArtifactsBeforeUpdate) { + String artifactnameBeforeUpdate = artifact.getArtifactname(); + for (VFCArtifact newArtifact : vfcArtifactList) { + String artifactnameAfterUpdate = newArtifact.getArtifactname(); + if (artifactnameBeforeUpdate.equals(artifactnameAfterUpdate)) { + String artifactUUIDAfterUpdate = newArtifact.getArtifactUUID(); + assertTrue(artifactUUIDAfterUpdate.equals(artifact.getArtifactUUID())); + + int artifactVersionAfterUpdate = Integer.parseInt(newArtifact.getArtifactVersion()); + int artifactVersionBeforeUpdate = Integer.parseInt(artifact.getArtifactVersion()); + assertTrue(artifactVersionAfterUpdate == artifactVersionBeforeUpdate); + + vfcArtifactList.remove(newArtifact); + break; + } + } + } + + + assertTrue(vfcArtifactList.size() == 0); + + } + + public static void verifyNoVfcArtifacts(ResourceReqDetails resource, User user, RestResponse optionalGetResponse) { + ExtentTestActions.log(Status.INFO, "Verifying that there are no VFC artifacts at all."); + JSONArray jArr = getVFInstances(resource, user, optionalGetResponse); + for (Object instanceObj : jArr) { + JSONObject instance = (JSONObject) JSONValue.parse(instanceObj.toString()); + List actualDeploymentArtifacts = getActualVfcInstanceArtifactsFromJson(DEPLOYMENT_ARTIFACTS, instance); + + assertTrue(actualDeploymentArtifacts == null || actualDeploymentArtifacts.size() == 0); + } + } + + public static void verifyVfcArtifacts(ResourceReqDetails resource, User user, String instanceName, Map> expectedArtifactMap, + RestResponse optionalGetResponse) { + ExtentTestActions.log(Status.INFO, "Verifying VFC artifacts for instance named " + instanceName); + + String exCompName = instanceName.split(".vfc.")[1].toLowerCase(); + String exName = instanceName.split(".heat.")[1].toLowerCase(); + + JSONArray jArr = getVFInstances(resource, user, optionalGetResponse); + int jArrSize = jArr.size(); + + for (Object instanceObj : jArr) { + JSONObject instance = (JSONObject) JSONValue.parse(instanceObj.toString()); + String componentName = instance.get("componentName").toString().toLowerCase(); + String name = instance.get("name").toString().toLowerCase(); + + if (componentName.contains(exCompName) || name.toLowerCase().equals(exName)) { + + List actualDeploymentArtifacts = getActualVfcInstanceArtifactsFromJson(DEPLOYMENT_ARTIFACTS, instance); + LinkedList expectedDeploymentArtifacts = expectedArtifactMap.get(DEPLOYMENT_ARTIFACTS); + checkVFCArtifactsExist(expectedDeploymentArtifacts, actualDeploymentArtifacts); + + + List actualInformationalArtifacts = getActualVfcInstanceArtifactsFromJson(ARTIFACTS, instance); + LinkedList expectedInformationalArtifacts = expectedArtifactMap.get(ARTIFACTS); + checkVFCArtifactsExist(expectedInformationalArtifacts, actualInformationalArtifacts); + + jArr.remove(instanceObj); + + ExtentTestActions.log(Status.INFO, "VFC artifacts for instance named " + instanceName + "are verified."); + + break; + } + } + + assertTrue(jArr.size() == jArrSize - 1, "Instance " + instanceName + " was not found and tested"); + + } + + + private static JSONArray getVFInstances(ResourceReqDetails resource, User user, RestResponse response) { + + jsonResource = getVFAsJsonObject(resource, user, response); + JSONArray jArr = (JSONArray) jsonResource.get("componentInstances"); + return jArr; + } + + private static Map getVFDeploymentArtifacts(ResourceReqDetails resource, User user, RestResponse response) { + + jsonResource = getVFAsJsonObject(resource, user, response); + Map jArr = (Map) jsonResource.get(DEPLOYMENT_ARTIFACTS); + return jArr; + } + + private static Map getVFInforamtionalArtifacts(ResourceReqDetails resource, User user, RestResponse response) { + + jsonResource = getVFAsJsonObject(resource, user, response); + Map jArr = (Map) jsonResource.get(ARTIFACTS); + return jArr; + } + + private static JSONObject getVFAsJsonObject(ResourceReqDetails resource, User user, RestResponse response) { + if (response == null) { + resource.setUniqueId(null); + response = RestCDUtils.getResource(resource, user); + assertTrue(response.getErrorCode().intValue() == HttpStatus.SC_OK); + getVFAsJsonObject(resource, user, response); + } + + String responseAfterDrag = response.getResponse(); + jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); + return jsonResource; + } + + + private static List getActualVfcInstanceArtifactsFromJson(String artifactKind, JSONObject instanceFromJson) { + Object actualtObject = instanceFromJson.get(artifactKind); + if (actualtObject != null) { + JSONObject actualJsonObject = (JSONObject) JSONValue.parse(actualtObject.toString()); + List actualArtifacts = (List) actualJsonObject.keySet().stream().map(e -> actualJsonObject.get(e).toString()).collect(Collectors.toList()); + return actualArtifacts; + } + return null; + } + + private static void checkVFCArtifactsExist(LinkedList expectedArtifacts, List actualArtifacts) { + if (expectedArtifacts == null) { + return; + } + + if (expectedArtifacts.size() != actualArtifacts.size()) { + ExtentTestActions.log(Status.FAIL, "Expected and actual VFC artifacts lists size are not the same. Expected size: " + expectedArtifacts.size() + " , actual size: " + actualArtifacts.size()); + Assert.fail("Expected and actual VFC artifacts lists size are not the same. Expected size: " + expectedArtifacts.size() + " , actual size: " + actualArtifacts.size()); + } + + List types = new ArrayList(); + List fileNames = new ArrayList(); + for (HeatMetaFirstLevelDefinition exArtifact : expectedArtifacts) { + + fileNames.add(exArtifact.getFileName()); + types.add(exArtifact.getType()); + + } + + for (int i = 0; i < actualArtifacts.size(); i++) { + String actualArtifactsString = actualArtifacts.get(i); + JSONObject acArtifact = ((JSONObject) JSONValue.parse(actualArtifactsString)); + + String acArtifactFileName = acArtifact.get("artifactName").toString(); + String acArtifactType = acArtifact.get("artifactType").toString(); + + assertTrue(types.contains(acArtifactType), "List does not contain " + acArtifactType); + assertTrue(fileNames.contains(acArtifactFileName), "List does not contain " + acArtifactFileName); + + types.remove(acArtifactType); + fileNames.remove(acArtifactFileName); + + } + + assertTrue(types.size() == 0); + assertTrue(fileNames.size() == 0); + + } + + public static List getVfcArtifactList() { + return vfcArtifactList; + } + + + public static void setVfcArtifactList(List vfcArtifactList) { + VFCArtifactVerificator.vfcArtifactList = vfcArtifactList; + } + + public static void setActualVfcArtifactList(String instanceName, ResourceReqDetails resource, User user) { + String exCompName = instanceName.split(".vfc.")[1].toLowerCase(); + String exName = instanceName.split(".heat.")[1].toLowerCase(); + + JSONArray jArr = getVFInstances(resource, user, null); + + for (Object instanceObj : jArr) { + JSONObject instance = (JSONObject) JSONValue.parse(instanceObj.toString()); + String componentName = instance.get("componentName").toString().toLowerCase(); + String name = instance.get("name").toString().toLowerCase(); + + if (componentName.contains(exCompName) || name.toLowerCase().equals(exName)) { + List actualDeploymentArtifacts = getActualVfcInstanceArtifactsFromJson(DEPLOYMENT_ARTIFACTS, instance); + List actualInformationalArtifacts = getActualVfcInstanceArtifactsFromJson(ARTIFACTS, instance); + + if (actualDeploymentArtifacts != null) { + for (int i = 0; i < actualDeploymentArtifacts.size(); i++) { + String actualArtifactsString = actualDeploymentArtifacts.get(i); + JSONObject acArtifact = ((JSONObject) JSONValue.parse(actualArtifactsString)); + + if (acArtifact.containsKey("artifactName")) { + String acArtifactType = acArtifact.get("artifactName").toString(); + String acArtifactFileName = acArtifact.get("artifactType").toString(); + String acArtifactUUID = acArtifact.get("artifactUUID").toString(); + String acArtifactVersion = acArtifact.get("artifactVersion").toString(); + + vfcArtifactList.add(new VFCArtifact(acArtifactType, acArtifactFileName, acArtifactUUID, acArtifactVersion)); + } + } + } + if (actualInformationalArtifacts != null) { + for (int i = 0; i < actualInformationalArtifacts.size(); i++) { + String actualArtifactsString = actualInformationalArtifacts.get(i); + JSONObject acArtifact = ((JSONObject) JSONValue.parse(actualArtifactsString)); + + if (acArtifact.containsKey("artifactName")) { + String acArtifactType = acArtifact.get("artifactName").toString(); + String acArtifactFileName = acArtifact.get("artifactType").toString(); + String acArtifactUUID = acArtifact.get("artifactUUID").toString(); + String acArtifactVersion = acArtifact.get("artifactVersion").toString(); + vfcArtifactList.add(new VFCArtifact(acArtifactType, acArtifactFileName, acArtifactUUID, acArtifactVersion)); + } + + + } + } + } + } + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCverificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCverificator.java index 604cb8a6b2..3c3cb8c5f4 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCverificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCverificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,10 +28,13 @@ import static org.testng.AssertJUnit.assertFalse; public class VFCverificator { - public static void verifyVFCUpdatedInUI(ResourceReqDetails vf) { - assertFalse(vf.getName().equals(ResourceGeneralPage.getNameText())); - assertFalse(vf.getDescription().equals(ResourceGeneralPage.getDescriptionText())); - assertFalse(vf.getVendorName().equals(ResourceGeneralPage.getVendorNameText())); - assertFalse(vf.getVendorRelease().equals(ResourceGeneralPage.getVendorReleaseText())); - } + private VFCverificator() { + } + + public static void verifyVFCUpdatedInUI(ResourceReqDetails vf) { + assertFalse(vf.getName().equals(ResourceGeneralPage.getNameText())); + assertFalse(vf.getDescription().equals(ResourceGeneralPage.getDescriptionText())); + assertFalse(vf.getVendorName().equals(ResourceGeneralPage.getVendorNameText())); + assertFalse(vf.getVendorRelease().equals(ResourceGeneralPage.getVendorReleaseText())); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfModuleVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfModuleVerificator.java index efbb385225..8133c36790 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfModuleVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfModuleVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,112 +38,118 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import static org.testng.AssertJUnit.*; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertTrue; public class VfModuleVerificator { - - private final static List PROPERTY_TYPES = DeploymentViewVerificator.getCurrentPropertiesWithoutIsBase();//{"vf_module_label", "min_vf_module_instances", "max_vf_module_instances", "initial_count"}; - private static final String VF_MODULE_TYPE = "org.openecomp.groups.VfModule"; - - /** - * compare number of groups from HEAT.meta file vs TOSCA yaml groups generated by ASDC - * @param listTypeHeatMetaDefinition - java object created from HEAT.meta file - * @param toscaDefinition - java object created from TOSCA yaml - */ - public static void compareNumberOfVfModules(List listTypeHeatMetaDefinition, ToscaDefinition toscaDefinition) { - - int heatMetaGroupCount = 0; - int toscaDefinitionGroupCount = 0; - for (TypeHeatMetaDefinition typeHeatMetaDefinition : listTypeHeatMetaDefinition) { - if(!typeHeatMetaDefinition.getTypeName().equals("artifacts")) { - heatMetaGroupCount = typeHeatMetaDefinition.getGroupHeatMetaDefinition().size(); - } - } - toscaDefinitionGroupCount = toscaDefinition.getTopology_template().getGroups().size(); - assertEquals("Expected num of groups in HEAT.meta file is " + heatMetaGroupCount + ", but was in TOSCA yaml file " + toscaDefinitionGroupCount, heatMetaGroupCount, toscaDefinitionGroupCount); - } - - /** - * check group structure and "metadata" parameters vs data on the service object - * @param toscaDefinition - */ - public static void verifyGroupMetadata(ToscaDefinition toscaDefinition, Service service) { - - Map groups = toscaDefinition.getTopology_template().getGroups(); - for (Map.Entry groupTopologyTemplateDefinition : groups.entrySet()) { - String key = groupTopologyTemplateDefinition.getKey(); - GroupInstance groupInstanceObject = getGroupInstanceByKey(key, service); - ToscaServiceGroupsMetadataDefinition metadata = groupTopologyTemplateDefinition.getValue(); - assertNotNull("groupInstanceObject is null", groupInstanceObject); - assertTrue("expected vfModuleModelName " + groupInstanceObject.getGroupName() + ", actual " + metadata.getVfModuleModelName(), groupInstanceObject.getGroupName().equals(metadata.getVfModuleModelName())); - assertTrue("expected vfModuleModelInvariantUUID " + groupInstanceObject.getInvariantUUID() + ", actual " + metadata.getVfModuleModelInvariantUUID(), groupInstanceObject.getInvariantUUID().equals(metadata.getVfModuleModelInvariantUUID())); - assertTrue("expected vfModuleModelCustomizationUUID " + groupInstanceObject.getCustomizationUUID() + ", actual " + metadata.getVfModuleModelCustomizationUUID(), groupInstanceObject.getCustomizationUUID().equals(metadata.getVfModuleModelCustomizationUUID())); - assertTrue("expected vfModuleModelUUID " + groupInstanceObject.getGroupUUID() + ", actual " + metadata.getVfModuleModelUUID(), groupInstanceObject.getGroupUUID().equals(metadata.getVfModuleModelUUID())); - assertTrue("expected vfModuleModelVersion " + groupInstanceObject.getVersion() + ", actual " + metadata.getVfModuleModelVersion(), groupInstanceObject.getVersion().equals(metadata.getVfModuleModelVersion())); - } - } - - - /** - * @param key - * @param service - * @return - */ - public static GroupInstance getGroupInstanceByKey(String key, Service service) { - for(ComponentInstance componentInstance : service.getComponentInstances()){ - for(GroupInstance groupInstance : componentInstance.getGroupInstances()){ - if( key.equals(groupInstance.getName())){ - return groupInstance; - } - } - } - return null; - } - - public static void validateSpecificModulePropertiesFromRequest(Resource resource) { - List> allProperties = resource.getGroups().stream(). - filter(e -> e.getType().equals(VF_MODULE_TYPE)). - map(e -> e.getProperties()). - collect(Collectors.toList()); - for(String propertyType : PROPERTY_TYPES){ - int numberOfTypes = getPropertyType(allProperties, propertyType).size(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating VF property %s exist, Expected: %s, Actual: %s ", propertyType, allProperties.size(), numberOfTypes)); - assertTrue(numberOfTypes == allProperties.size()); - } - } - - public static List getPropertyType(List> allProperties, String propertyType) { - return allProperties.stream(). - flatMap(List::stream). - filter(e -> e.getName().equals(propertyType)). - collect(Collectors.toList()); - } - - public static void validateSpecificModulePropertiesFromFile(ToscaDefinition toscaDefinition){ - List vfModules = toscaDefinition. - getTopology_template().getGroups().values().stream(). - filter(e -> e.getType().equals(VF_MODULE_TYPE)). - collect(Collectors.toList()); - for(String propertyType : PROPERTY_TYPES){ - int numberOfTypes = (int) vfModules.stream(). - // Get all declared fields from class ToscaGroupPropertyDefinition, collect them to List and check that current property exist and declared class - filter(e -> Arrays.asList(e.getProperties().getClass().getDeclaredFields()).stream(). - map(p -> p.getName()). - collect(Collectors.toList()). - contains(propertyType) - ). - collect(Collectors.toList()). - size(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating VF property %s exist, Expected: %s, Actual: %s ", propertyType, vfModules.size(), numberOfTypes)); - assertTrue(numberOfTypes == vfModules.size()); - } - } - - public static String getTemplateFilenname(String pathToCsar) { - File csarFile = new File(pathToCsar); - String templateFileName = csarFile.getName().replaceAll("-csar.csar", "-template.yml"); - return templateFileName; - } - + private VfModuleVerificator() { + } + + private static final List PROPERTY_TYPES = DeploymentViewVerificator.getCurrentPropertiesWithoutIsBase(); //{"vf_module_label", "min_vf_module_instances", "max_vf_module_instances", "initial_count"}; + private static final String VF_MODULE_TYPE = "org.openecomp.groups.VfModule"; + + /** + * compare number of groups from HEAT.meta file vs TOSCA yaml groups generated by ASDC + * + * @param listTypeHeatMetaDefinition - java object created from HEAT.meta file + * @param toscaDefinition - java object created from TOSCA yaml + */ + public static void compareNumberOfVfModules(List listTypeHeatMetaDefinition, ToscaDefinition toscaDefinition) { + + int heatMetaGroupCount = 0; + int toscaDefinitionGroupCount = 0; + for (TypeHeatMetaDefinition typeHeatMetaDefinition : listTypeHeatMetaDefinition) { + if (!typeHeatMetaDefinition.getTypeName().equals("artifacts")) { + heatMetaGroupCount = typeHeatMetaDefinition.getGroupHeatMetaDefinition().size(); + } + } + toscaDefinitionGroupCount = toscaDefinition.getTopology_template().getGroups().size(); + assertEquals("Expected num of groups in HEAT.meta file is " + heatMetaGroupCount + ", but was in TOSCA yaml file " + toscaDefinitionGroupCount, heatMetaGroupCount, toscaDefinitionGroupCount); + } + + /** + * check group structure and "metadata" parameters vs data on the service object + * + * @param toscaDefinition + */ + public static void verifyGroupMetadata(ToscaDefinition toscaDefinition, Service service) { + + Map groups = toscaDefinition.getTopology_template().getGroups(); + for (Map.Entry groupTopologyTemplateDefinition : groups.entrySet()) { + String key = groupTopologyTemplateDefinition.getKey(); + GroupInstance groupInstanceObject = getGroupInstanceByKey(key, service); + ToscaServiceGroupsMetadataDefinition metadata = groupTopologyTemplateDefinition.getValue(); + assertNotNull("groupInstanceObject is null", groupInstanceObject); + assertTrue("expected vfModuleModelName " + groupInstanceObject.getGroupName() + ", actual " + metadata.getVfModuleModelName(), groupInstanceObject.getGroupName().equals(metadata.getVfModuleModelName())); + assertTrue("expected vfModuleModelInvariantUUID " + groupInstanceObject.getInvariantUUID() + ", actual " + metadata.getVfModuleModelInvariantUUID(), groupInstanceObject.getInvariantUUID().equals(metadata.getVfModuleModelInvariantUUID())); + assertTrue("expected vfModuleModelCustomizationUUID " + groupInstanceObject.getCustomizationUUID() + ", actual " + metadata.getVfModuleModelCustomizationUUID(), groupInstanceObject.getCustomizationUUID().equals(metadata.getVfModuleModelCustomizationUUID())); + assertTrue("expected vfModuleModelUUID " + groupInstanceObject.getGroupUUID() + ", actual " + metadata.getVfModuleModelUUID(), groupInstanceObject.getGroupUUID().equals(metadata.getVfModuleModelUUID())); + assertTrue("expected vfModuleModelVersion " + groupInstanceObject.getVersion() + ", actual " + metadata.getVfModuleModelVersion(), groupInstanceObject.getVersion().equals(metadata.getVfModuleModelVersion())); + } + } + + + /** + * @param key + * @param service + * @return + */ + public static GroupInstance getGroupInstanceByKey(String key, Service service) { + for (ComponentInstance componentInstance : service.getComponentInstances()) { + for (GroupInstance groupInstance : componentInstance.getGroupInstances()) { + if (key.equals(groupInstance.getName())) { + return groupInstance; + } + } + } + return null; + } + + public static void validateSpecificModulePropertiesFromRequest(Resource resource) { + List> allProperties = resource.getGroups().stream(). + filter(e -> e.getType().equals(VF_MODULE_TYPE)). + map(e -> e.getProperties()). + collect(Collectors.toList()); + for (String propertyType : PROPERTY_TYPES) { + int numberOfTypes = getPropertyType(allProperties, propertyType).size(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating VF property %s exist, Expected: %s, Actual: %s ", propertyType, allProperties.size(), numberOfTypes)); + assertTrue(numberOfTypes == allProperties.size()); + } + } + + public static List getPropertyType(List> allProperties, String propertyType) { + return allProperties.stream(). + flatMap(List::stream). + filter(e -> e.getName().equals(propertyType)). + collect(Collectors.toList()); + } + + public static void validateSpecificModulePropertiesFromFile(ToscaDefinition toscaDefinition) { + List vfModules = toscaDefinition. + getTopology_template().getGroups().values().stream(). + filter(e -> e.getType().equals(VF_MODULE_TYPE)). + collect(Collectors.toList()); + for (String propertyType : PROPERTY_TYPES) { + int numberOfTypes = (int) vfModules.stream(). + // Get all declared fields from class ToscaGroupPropertyDefinition, collect them to List and check that current property exist and declared class + filter(e -> Arrays.asList(e.getProperties().getClass().getDeclaredFields()).stream(). + map(p -> p.getName()). + collect(Collectors.toList()). + contains(propertyType) + ). + collect(Collectors.toList()). + size(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating VF property %s exist, Expected: %s, Actual: %s ", propertyType, vfModules.size(), numberOfTypes)); + assertTrue(numberOfTypes == vfModules.size()); + } + } + + public static String getTemplateFilenname(String pathToCsar) { + File csarFile = new File(pathToCsar); + String templateFileName = csarFile.getName().replaceAll("-csar.csar", "-template.yml"); + return templateFileName; + } + } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfVerificator.java index b13b9f1a70..db8d1b27e3 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfVerificator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,9 +20,10 @@ package org.openecomp.sdc.ci.tests.verificator; -//import com.att.automation.common.report_portal_integration.annotations.Step; //ReportPortal + import com.aventstack.extentreports.Status; 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; @@ -53,230 +54,231 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import static org.testng.Assert.*; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; public final class VfVerificator { - - public static void verifyNumOfComponentInstances(ResourceReqDetails createResourceInUI, int numOfVFC, User user) { - ServiceVerificator.verifyNumOfComponentInstances(createResourceInUI, createResourceInUI.getVersion(), numOfVFC, user); - } - - public static void verifyRILocationChanged(ResourceReqDetails createResourceInUI, - ImmutablePair prevRIPos, User user) { - - ImmutablePair currRIPos = ResourceUIUtils.getFirstRIPos(createResourceInUI, user); - assertTrue(!prevRIPos.left.equals(currRIPos.left) || !prevRIPos.right.equals(currRIPos.right)); - } - - public static void verifyLinkCreated(ResourceReqDetails createResourceInUI, User user, int expectedRelationsSize) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that a link was created on canvas")); - String responseAfterDrag = RestCDUtils.getResource(createResourceInUI, user).getResponse(); - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - assertTrue(((JSONArray) jsonResource.get("componentInstancesRelations")).size() == expectedRelationsSize); - ExtentTestActions.log(Status.INFO, "The link was verified."); - - } - -// @Step(description="Verifying fields on General screen through UI ...") //ReportPortal - public static void verifyVFMetadataInUI(ResourceReqDetails vf) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying fields on General screen through UI ...")); - assertTrue(vf.getName().equals(ResourceGeneralPage.getNameText())); - assertTrue(vf.getDescription().equals(ResourceGeneralPage.getDescriptionText())); - assertTrue(vf.getCategories().get(0).getSubcategories().get(0).getName().equals(GeneralUIUtils.getSelectedElementFromDropDown(ResourceGeneralPage.getCategoryDataTestsIdAttribute()).getText())); - assertTrue(vf.getVendorName().equals(ResourceGeneralPage.getVendorNameText())); - assertTrue(vf.getVendorRelease().equals(ResourceGeneralPage.getVendorReleaseText())); - assertTrue(vf.getContactId().equals(ResourceGeneralPage.getContactIdText())); - List tagsList = ResourceGeneralPage.getElementsFromTagsTable(); - assertTrue(vf.getTags().size() == tagsList.size()); - for (int i = 0 ; i < vf.getTags().size(); i ++ ){ - assertTrue(vf.getTags().contains(tagsList.get(i).getText())); - } - assertTrue(vf.getContactId().equals(ResourceGeneralPage.getContactIdText())); - } - -// @Step(description="Verifying fields on General screen through Backend ...") //ReportPortal - public static void verifyVFUpdated(ResourceReqDetails vf, User user) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying fields on General screen through Backend ...")); - String response = RestCDUtils.getResource(vf, user).getResponse(); - Resource resource = ResponseParser.convertResourceResponseToJavaObject(response); - assertTrue(vf.getName().equals(resource.getName())); - assertTrue(vf.getDescription().equals(resource.getDescription())); - assertTrue(vf.getVendorName().equals(resource.getVendorName())); - assertTrue(vf.getVendorRelease().equals(resource.getVendorRelease())); - assertTrue(vf.getContactId().equals(resource.getContactId())); - - assertTrue(vf.getCategories().size() == (resource.getCategories().size())); - for (int i = 0 ; i < vf.getCategories().size() ; i ++) - { - CategoryDefinition expectedCategoryDefinition = vf.getCategories().get(i); - CategoryDefinition actualCategoryDefinition = resource.getCategories().get(i); - assertTrue(expectedCategoryDefinition.getName().equals(actualCategoryDefinition.getName())); - assertTrue(expectedCategoryDefinition.getSubcategories().get(i).getName().equals(actualCategoryDefinition.getSubcategories().get(i).getName())); - } - - assertTrue(vf.getTags().size() == (resource.getTags().size())); - for (int i = 0 ; i < vf.getTags().size() ; i ++){ - List expectedTags = vf.getTags(); - List actualTags = resource.getTags(); - - assertTrue(actualTags.contains(expectedTags.get(i))); - - } - } - - public static void verifyVFLifecycle(ResourceReqDetails vf, User user, LifecycleStateEnum expectedLifecycleState) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that object %s state is %s", vf.getName(),expectedLifecycleState)); - String responseAfterDrag = RestCDUtils.getResource(vf, user).getResponse(); - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - String actualLifecycleState = jsonResource.get("lifecycleState").toString(); - assertTrue(expectedLifecycleState.name().equals(actualLifecycleState), "actual: " + actualLifecycleState + "-- expected: " + expectedLifecycleState); - } - - public static void verifyVfLifecycleInUI(LifeCycleStateEnum lifecycleState){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that object state is %s", lifecycleState.getValue())); - GeneralUIUtils.ultimateWait(); - assertTrue(ResourceGeneralPage.getLifeCycleState().equals(lifecycleState.getValue())); - } - - public static void verifyVersionUI(String expected){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that version is %s", expected)); - String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown - (DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText().replace("V", ""); - assertTrue(actualVersion.equals(expected), String.format( "Expected version: %s, Actual version: %s", expected, actualVersion)); - } - - public static void verifyInstanceVersion(ResourceReqDetails vf, User user, String instanceName, String instanceVersion){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that instance %s version is %s", instanceName,instanceVersion)); - String responseAfterDrag = RestCDUtils.getResource(vf, user).getResponse(); - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - JSONArray jsonArrayResource = (JSONArray) jsonResource.get("componentInstances"); - for (int i = 0; i < jsonArrayResource.size(); i++){ - Object object = jsonArrayResource.get(i); - try{ - JSONObject jRes = (JSONObject) JSONValue.parse(object.toString()); - String componentName = jRes.get("componentName").toString(); - if (componentName.equals(instanceName)){ - String componentVersion = jRes.get("componentVersion").toString(); - assertTrue(componentVersion.equals(instanceVersion)); - } - } - catch(Exception e){ - System.out.println("Can't test object in componentInstances array"); - Assert.fail("Can't test object in componentInstances array"); - } - } - } - - public static void verifyVfDeleted(ResourceReqDetails vf, User user){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating resource %s was deleted", vf.getName())); - RestResponse response = RestCDUtils.getResource(vf, user); - assertTrue(response.getErrorCode().intValue() == 404); - } - - public static void verifyPropertiesInUI(List propertyList){ - - for (PropertyTypeEnum prop : propertyList){ - String propName = prop.getName(); - - String actualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propName).getText(); - String actualType = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.PROPERTY_TYPE.getValue() + propName).getText(); - String actualDesciprtion = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.PROPERTY_DESCRIPTION.getValue() + propName).getText(); - - assertTrue(propName.equals(actualName), String.format("Property name is not correct. expected:%s ; actual %s", propName, actualName)); - assertTrue(prop.getType().equals(actualType), String.format("Property type is not correct. expected:%s ; actual %s", prop.getType(), actualType)); - assertTrue(prop.getDescription().equals(actualDesciprtion), String.format("Property description is not correct. expected:%s ; actual %s", prop.getDescription(), actualDesciprtion)); - - if (prop.getSchemaDefinition() != null){ - String actualSchema = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.ENTRY_SCHEMA.getValue() + propName).getText(); - assertTrue(prop.getSchemaDefinition().equals(actualSchema), String.format("Property schema is not correct. expected:%s ; actual %s", prop.getSchemaDefinition(), actualSchema)); - } - } - } - - public static void verifyToscaArtifactsInfo(ResourceReqDetails vf, User user){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating Tosca Aritfact Info of resource %s", vf.getName())); - String responseAfterDrag = RestCDUtils.getResource(vf, user).getResponse(); - JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); - JSONObject toscaArtifacts = (JSONObject) jsonResource.get("toscaArtifacts"); - - assertEquals(2, toscaArtifacts.size()); - for (Object artifactObj : toscaArtifacts.keySet()){ - JSONObject artifact = (JSONObject) JSONValue.parse(toscaArtifacts.get(artifactObj).toString()); - assertFalse(artifact.get("artifactUUID").toString().isEmpty(), "artifactUUID field is empty"); - assertFalse(artifact.get("artifactChecksum").toString().isEmpty(), "artifactChecksum filed is empty"); - assertFalse(artifact.get("payloadUpdateDate").toString().isEmpty(), "payloadUpdateDate field is empty"); - assertFalse(artifact.get("artifactVersion").toString().equals("0"), "artifactVersion field is 0"); - } - } - - public static void verifyVfInputs(String instanceName, Map instancePropertiesMapFromJson,List propertyRowsFromTable) { - - for (int i = 0 ; i < propertyRowsFromTable.size() ; i++){ - WebElement row = propertyRowsFromTable.get(i); - String propertyNameFromTable = row.findElement(By.xpath(".//*[@data-tests-id='" + "propertyName']")).getText(); - String propertyTypeFromTable = row.findElement(By.xpath(".//*[@data-tests-id='" + "propertyType']")).getText(); - String instanceNameFromTable = row.findElement(By.xpath(".//*[@data-tests-id='" + "instanceName']")).getText(); - String propertySchemaFromTable = row.findElement(By.xpath(".//*[@data-tests-id='" + "propertySchema']")).getText(); - - assertTrue(instancePropertiesMapFromJson.containsKey(propertyNameFromTable), "No property named : " + propertyNameFromTable + "for instance " + instanceName); - String expectedType = instancePropertiesMapFromJson.get(propertyNameFromTable); - assertTrue(expectedType.equals(propertyTypeFromTable.toLowerCase()), propertyNameFromTable + "type is incorrect"); - assertTrue(instanceName.equals(instanceNameFromTable), "Instance name of property named " + propertyNameFromTable + "is incorrect"); - } - } - - public static void verifyOnboardedVnfMetadata(String vspName, VendorSoftwareProductObject vspMetadata) { - SetupCDTest.getExtendTest().log(Status.INFO, "Verifying metadata"); - - assertTrue(vspName.equals(ResourceGeneralPage.getNameText()), "VSP name is not valid."); - List tagsList = ResourceGeneralPage.getElementsFromTagsTable(); - assertTrue(tagsList.size() == 1, "VSP tags size is not equal to 1."); - assertTrue(vspName.equals(tagsList.get(0).getText()), "VSP tag is not its name."); - - verifyMetadataIndifferentToFlow(vspMetadata); - } - - public static void verifyOnboardedVnfMetadataAfterUpdateVNF(String vspName, VendorSoftwareProductObject vspMetadata) { - SetupCDTest.getExtendTest().log(Status.INFO, "Verifying metadata after update VNF"); - - // VF name should be updated only only if VF not certified - if(Double.parseDouble(ResourceGeneralPage.getVersionUI()) < 1.0) { - assertTrue(vspName.equals(ResourceGeneralPage.getNameText()), "VSP name is not valid."); - List tagsList = ResourceGeneralPage.getElementsFromTagsTable(); - assertTrue(tagsList.size() == 1, "VSP tags size is not equal to 1."); - assertTrue(vspName.equals(tagsList.get(0).getText()), "VSP tag is not its name."); - } - - verifyMetadataIndifferentToFlow(vspMetadata); - } - - public static void verifyMetadataIndifferentToFlow(VendorSoftwareProductObject vspMetadata) { - assertTrue(vspMetadata.getDescription().equals(ResourceGeneralPage.getDescriptionText()), "VSP description is not valid."); - - String [] splitedSubCategorey = vspMetadata.getSubCategory().split("\\."); - String expectedSubCategory = splitedSubCategorey[splitedSubCategorey.length-1]; - String actualSubCategory = GeneralUIUtils.getSelectedElementFromDropDown(ResourceGeneralPage.getCategoryDataTestsIdAttribute()).getText().trim().toLowerCase(); - - assertTrue(expectedSubCategory.equals(actualSubCategory), "VSP category is not valid."); - assertTrue(vspMetadata.getVendorName().equals(ResourceGeneralPage.getVendorNameText()), "VSP vendor name is not valid."); - assertTrue("1.0".equals(ResourceGeneralPage.getVendorReleaseText()), "VSP version is not valid."); - assertTrue(vspMetadata.getAttContact().equals(ResourceGeneralPage.getContactIdText()), "VSP attContact is not valid."); - } - - public static void verifyIsElementDisabled(String elementLocator, String elementName){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Checking if %s is disabled", elementName)); - assertTrue(GeneralUIUtils.isElementReadOnly(elementLocator)); - } - - public static void verifyFilesChecksum(File actual, File expected){ - try { - String actualMd5OfFile = FileHandling.getMD5OfFile(actual); - String expectedMd5OfFile = FileHandling.getMD5OfFile(expected); - Assert.assertEquals(expectedMd5OfFile, actualMd5OfFile, "File does not exist"); - } catch (IOException e) { - e.printStackTrace(); - } - - } - + + private VfVerificator() { + } + + public static void verifyNumOfComponentInstances(ResourceReqDetails createResourceInUI, int numOfVFC, User user) { + ServiceVerificator.verifyNumOfComponentInstances(createResourceInUI, createResourceInUI.getVersion(), numOfVFC, user); + } + + public static void verifyRILocationChanged(ResourceReqDetails createResourceInUI, + ImmutablePair prevRIPos, User user) { + + ImmutablePair currRIPos = ResourceUIUtils.getFirstRIPos(createResourceInUI, user); + assertTrue(!prevRIPos.left.equals(currRIPos.left) || !prevRIPos.right.equals(currRIPos.right)); + } + + public static void verifyLinkCreated(ResourceReqDetails createResourceInUI, User user, int expectedRelationsSize) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that a link was created on canvas")); + String responseAfterDrag = RestCDUtils.getResource(createResourceInUI, user).getResponse(); + JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); + assertTrue(((JSONArray) jsonResource.get("componentInstancesRelations")).size() == expectedRelationsSize); + ExtentTestActions.log(Status.INFO, "The link was verified."); + + } + + public static void verifyVFMetadataInUI(ResourceReqDetails vf) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying fields on General screen through UI ...")); + assertTrue(vf.getName().equals(ResourceGeneralPage.getNameText())); + assertTrue(vf.getDescription().equals(ResourceGeneralPage.getDescriptionText())); + assertTrue(vf.getCategories().get(0).getSubcategories().get(0).getName().equals(GeneralUIUtils.getSelectedElementFromDropDown(ResourceGeneralPage.getCategoryDataTestsIdAttribute()).getText())); + assertTrue(vf.getVendorName().equals(ResourceGeneralPage.getVendorNameText())); + assertTrue(vf.getVendorRelease().equals(ResourceGeneralPage.getVendorReleaseText())); + assertTrue(vf.getContactId().equals(ResourceGeneralPage.getContactIdText())); + List tagsList = ResourceGeneralPage.getElementsFromTagsTable(); + assertTrue(vf.getTags().size() == tagsList.size()); + for (int i = 0; i < vf.getTags().size(); i++) { + assertTrue(vf.getTags().contains(tagsList.get(i).getText())); + } + assertTrue(vf.getContactId().equals(ResourceGeneralPage.getContactIdText())); + } + + public static void verifyVFUpdated(ResourceReqDetails vf, User user) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying fields on General screen through Backend ...")); + String response = RestCDUtils.getResource(vf, user).getResponse(); + Resource resource = ResponseParser.convertResourceResponseToJavaObject(response); + assertTrue(vf.getName().equals(resource.getName())); + assertTrue(vf.getDescription().equals(resource.getDescription())); + assertTrue(vf.getVendorName().equals(resource.getVendorName())); + assertTrue(vf.getVendorRelease().equals(resource.getVendorRelease())); + assertTrue(vf.getContactId().equals(resource.getContactId())); + + assertTrue(vf.getCategories().size() == (resource.getCategories().size())); + for (int i = 0; i < vf.getCategories().size(); i++) { + CategoryDefinition expectedCategoryDefinition = vf.getCategories().get(i); + CategoryDefinition actualCategoryDefinition = resource.getCategories().get(i); + assertTrue(expectedCategoryDefinition.getName().equals(actualCategoryDefinition.getName())); + assertTrue(expectedCategoryDefinition.getSubcategories().get(i).getName().equals(actualCategoryDefinition.getSubcategories().get(i).getName())); + } + + assertTrue(vf.getTags().size() == (resource.getTags().size())); + for (int i = 0; i < vf.getTags().size(); i++) { + List expectedTags = vf.getTags(); + List actualTags = resource.getTags(); + + assertTrue(actualTags.contains(expectedTags.get(i))); + + } + } + + public static void verifyVFLifecycle(ResourceReqDetails vf, User user, LifecycleStateEnum expectedLifecycleState) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that object %s state is %s", vf.getName(), expectedLifecycleState)); + String responseAfterDrag = RestCDUtils.getResource(vf, user).getResponse(); + JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); + String actualLifecycleState = jsonResource.get("lifecycleState").toString(); + assertTrue(expectedLifecycleState.name().equals(actualLifecycleState), "actual: " + actualLifecycleState + "-- expected: " + expectedLifecycleState); + } + + public static void verifyVfLifecycleInUI(LifeCycleStateEnum lifecycleState) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that object state is %s", lifecycleState.getValue())); + GeneralUIUtils.ultimateWait(); + assertTrue(ResourceGeneralPage.getLifeCycleState().equals(lifecycleState.getValue())); + } + + public static void verifyVersionUI(String expected) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that version is %s", expected)); + String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum. + GeneralElementsEnum.VERSION_HEADER.getValue()).getText().replace("V", ""); + assertTrue(actualVersion.equals(expected), String.format("Expected version: %s, Actual version: %s", expected, actualVersion)); + } + + public static void verifyInstanceVersion(ResourceReqDetails vf, User user, String instanceName, String instanceVersion) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that instance %s version is %s", instanceName, instanceVersion)); + String responseAfterDrag = RestCDUtils.getResource(vf, user).getResponse(); + JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); + JSONArray jsonArrayResource = (JSONArray) jsonResource.get("componentInstances"); + for (int i = 0; i < jsonArrayResource.size(); i++) { + Object object = jsonArrayResource.get(i); + try { + JSONObject jRes = (JSONObject) JSONValue.parse(object.toString()); + String componentName = jRes.get("componentName").toString(); + if (componentName.equals(instanceName)) { + String componentVersion = jRes.get("componentVersion").toString(); + assertTrue(componentVersion.equals(instanceVersion)); + } + } catch (Exception e) { + System.out.println("Can't test object in componentInstances array"); + Assert.fail("Can't test object in componentInstances array"); + } + } + } + + public static void verifyVfDeleted(ResourceReqDetails vf, User user) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating resource %s was deleted", vf.getName())); + RestResponse response = RestCDUtils.getResource(vf, user); + assertTrue(response.getErrorCode().intValue() == HttpStatus.SC_NOT_FOUND); + } + + public static void verifyPropertiesInUI(List propertyList) { + + for (PropertyTypeEnum prop : propertyList) { + String propName = prop.getName(); + + String actualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.PROPERTY_NAME.getValue() + propName).getText(); + String actualType = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.PROPERTY_TYPE.getValue() + propName).getText(); + String actualDesciprtion = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.PROPERTY_DESCRIPTION.getValue() + propName).getText(); + + assertTrue(propName.equals(actualName), String.format("Property name is not correct. expected:%s ; actual %s", propName, actualName)); + assertTrue(prop.getType().equals(actualType), String.format("Property type is not correct. expected:%s ; actual %s", prop.getType(), actualType)); + assertTrue(prop.getDescription().equals(actualDesciprtion), String.format("Property description is not correct. expected:%s ; actual %s", prop.getDescription(), actualDesciprtion)); + + if (prop.getSchemaDefinition() != null) { + String actualSchema = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.PropertiesPageEnum.ENTRY_SCHEMA.getValue() + propName).getText(); + assertTrue(prop.getSchemaDefinition().equals(actualSchema), String.format("Property schema is not correct. expected:%s ; actual %s", prop.getSchemaDefinition(), actualSchema)); + } + } + } + + public static void verifyToscaArtifactsInfo(ResourceReqDetails vf, User user) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating Tosca Aritfact Info of resource %s", vf.getName())); + String responseAfterDrag = RestCDUtils.getResource(vf, user).getResponse(); + JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); + JSONObject toscaArtifacts = (JSONObject) jsonResource.get("toscaArtifacts"); + + assertEquals(2, toscaArtifacts.size()); + for (Object artifactObj : toscaArtifacts.keySet()) { + JSONObject artifact = (JSONObject) JSONValue.parse(toscaArtifacts.get(artifactObj).toString()); + assertFalse(artifact.get("artifactUUID").toString().isEmpty(), "artifactUUID field is empty"); + assertFalse(artifact.get("artifactChecksum").toString().isEmpty(), "artifactChecksum filed is empty"); + assertFalse(artifact.get("payloadUpdateDate").toString().isEmpty(), "payloadUpdateDate field is empty"); + assertFalse(artifact.get("artifactVersion").toString().equals("0"), "artifactVersion field is 0"); + } + } + + public static void verifyVfInputs(String instanceName, Map instancePropertiesMapFromJson, List propertyRowsFromTable) { + + for (int i = 0; i < propertyRowsFromTable.size(); i++) { + WebElement row = propertyRowsFromTable.get(i); + String propertyNameFromTable = row.findElement(By.xpath(".//*[@data-tests-id='" + "propertyName']")).getText(); + String propertyTypeFromTable = row.findElement(By.xpath(".//*[@data-tests-id='" + "propertyType']")).getText(); + String instanceNameFromTable = row.findElement(By.xpath(".//*[@data-tests-id='" + "instanceName']")).getText(); + String propertySchemaFromTable = row.findElement(By.xpath(".//*[@data-tests-id='" + "propertySchema']")).getText(); + + assertTrue(instancePropertiesMapFromJson.containsKey(propertyNameFromTable), "No property named : " + propertyNameFromTable + "for instance " + instanceName); + String expectedType = instancePropertiesMapFromJson.get(propertyNameFromTable); + assertTrue(expectedType.equals(propertyTypeFromTable.toLowerCase()), propertyNameFromTable + "type is incorrect"); + assertTrue(instanceName.equals(instanceNameFromTable), "Instance name of property named " + propertyNameFromTable + "is incorrect"); + } + } + + public static void verifyOnboardedVnfMetadata(String vspName, VendorSoftwareProductObject vspMetadata) { + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying metadata"); + + assertTrue(vspName.equals(ResourceGeneralPage.getNameText()), "VSP name is not valid."); + List tagsList = ResourceGeneralPage.getElementsFromTagsTable(); + assertTrue(tagsList.size() == 1, "VSP tags size is not equal to 1."); + assertTrue(vspName.equals(tagsList.get(0).getText()), "VSP tag is not its name."); + + verifyMetadataIndifferentToFlow(vspMetadata); + } + + public static void verifyOnboardedVnfMetadataAfterUpdateVNF(String vspName, VendorSoftwareProductObject vspMetadata) { + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying metadata after update VNF"); + + // VF name should be updated only only if VF not certified + if (Double.parseDouble(ResourceGeneralPage.getVersionUI()) < 1.0) { + assertTrue(vspName.equals(ResourceGeneralPage.getNameText()), "VSP name is not valid."); + List tagsList = ResourceGeneralPage.getElementsFromTagsTable(); + assertTrue(tagsList.size() == 1, "VSP tags size is not equal to 1."); + assertTrue(vspName.equals(tagsList.get(0).getText()), "VSP tag is not its name."); + } + + verifyMetadataIndifferentToFlow(vspMetadata); + } + + public static void verifyMetadataIndifferentToFlow(VendorSoftwareProductObject vspMetadata) { + assertTrue(vspMetadata.getDescription().equals(ResourceGeneralPage.getDescriptionText()), "VSP description is not valid."); + + String[] splitedSubCategorey = vspMetadata.getSubCategory().split("\\."); + String expectedSubCategory = splitedSubCategorey[splitedSubCategorey.length - 1]; + String actualSubCategory = GeneralUIUtils.getSelectedElementFromDropDown(ResourceGeneralPage.getCategoryDataTestsIdAttribute()).getText().trim().toLowerCase(); + + assertTrue(expectedSubCategory.equals(actualSubCategory), "VSP category is not valid."); + assertTrue(vspMetadata.getVendorName().equals(ResourceGeneralPage.getVendorNameText()), "VSP vendor name is not valid."); + assertTrue("1.0".equals(ResourceGeneralPage.getVendorReleaseText()), "VSP version is not valid."); + assertTrue(vspMetadata.getAttContact().equals(ResourceGeneralPage.getContactIdText()), "VSP attContact is not valid."); + } + + public static void verifyIsElementDisabled(String elementLocator, String elementName) { + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Checking if %s is disabled", elementName)); + assertTrue(GeneralUIUtils.isElementReadOnly(elementLocator)); + } + + public static void verifyFilesChecksum(File actual, File expected) { + try { + String actualMd5OfFile = FileHandling.getMD5OfFile(actual); + String expectedMd5OfFile = FileHandling.getMD5OfFile(expected); + Assert.assertEquals(expectedMd5OfFile, actualMd5OfFile, "File does not exist"); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } -- cgit 1.2.3-korg