diff options
Diffstat (limited to 'ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/CreatePath.java')
-rw-r--r-- | ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/CreatePath.java | 980 |
1 files changed, 136 insertions, 844 deletions
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 66bb693778..d8d28e4afa 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 @@ -20,64 +20,35 @@ package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.awt.AWTException; -import java.io.Console; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.Random; -import com.mongodb.util.JSON; -import org.apache.commons.lang.RandomStringUtils; -import org.json.JSONObject; -import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders; +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.enums.CircleSize; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; -import org.openecomp.sdc.ci.tests.execute.sanity.Service; -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.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.*; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils; import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.stringtemplate.v4.ST; -import org.testng.Assert; -import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; import org.testng.annotations.Test; -import com.aventstack.extentreports.Status; -import com.clearspring.analytics.util.Pair; +import java.util.ArrayList; +import java.util.List; + public class CreatePath extends SetupCDTest { - protected static String filepath = FileHandling.getVnfRepositoryPath(); - protected String makeDistributionValue; + protected static String filePath = FileHandling.getFilePath("ComplexService"); + private static String fullCompositionFile = "fullComposition.zip"; + private static String fullCompositionFile2 = "fullCompositionNew.zip"; + private static String HSSFile = "HSS.zip"; + private static String VMMEFile = "VMME.zip"; + private static String makeDistributionValue; @Parameters({"makeDistribution"}) @BeforeMethod @@ -88,697 +59,155 @@ public class CreatePath extends SetupCDTest { //------------------------------------------Tests----------------------------------------------------- - // Jira issue 5610 + // Test#1 Jira issue 5610 @Test - public void AssertPathButtons() throws Exception, Throwable { - filepath = "C:\\Users\\ShiraShe\\Desktop"; - String vnfFile = "fullComposition.zip"; - String vspName = getToPathFlow(filepath, vnfFile); + public void AssertPathButtons() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + getToPathFlow(resourceReqDetails, filePath, fullCompositionFile); reloginWithNewRole(UserRoleEnum.DESIGNER); - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - openCreatePath(); - AssertCreatePath(); - AssertExtendPath(); - //SetupCDTest.getExtendTest().log(Status.INFO, String.format("disables buttons are OK")); + PathUtilities.createService(getUser()); + PathUtilities.openCreatePath(); + PathValidations.AssertCreatePath(); + PathValidations.AssertExtendPath(); } - // Jira issue 5441 + // Test#2 Jira issue 5441 @Test - public void CreatePathTestSanity() throws Exception, Throwable { - filepath = "C:\\Users\\ShiraShe\\Desktop"; - // List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileList(); - //String vnfFile = fileNamesFromFolder.get(0).toString(); - String vnfFile = "fullComposition.zip"; - String vspName = getToPathFlow(filepath, vnfFile); - createPath(vspName); + public void CreatePathTestSanity() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + Pair<String, ServiceReqDetails> pair = getToPathFlow(resourceReqDetails, filePath, fullCompositionFile); + String vspName = pair.left; + String serviceName = pair.right.getName(); + String pathName = "Test1"; + PathUtilities.createPath(pathName, vspName); + PathValidations.validateServicePath(serviceName, pathName); } - // Jira issue 5611 + // Test#3 Jira issue 5611 @Test - public void CreatePathCheckIO() throws Exception, Throwable { - filepath = "C:\\Users\\ShiraShe\\Desktop"; - // List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileList(); - //String vnfFile = fileNamesFromFolder.get(0).toString(); - String vnfFile = "fullComposition.zip"; - - // getToPathFlow - String vspName = onboardAndCertify(filepath, vnfFile); + public void CreatePathCheckIO() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile); reloginWithNewRole(UserRoleEnum.DESIGNER); - - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - // create path - String pathName = createPath(vspName); + String serviceName = PathUtilities.createService(getUser()).getName(); + String pathName = PathUtilities.createPath("Test3", vspName); // @@ check in @@ - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.CHECK_IN.getValue()); - GeneralUIUtils.getWebElementByTestID("checkindialog").sendKeys("check in automated confirmation message"); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); - GeneralUIUtils.ultimateWait(); - - // go to service composition - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue()).sendKeys(serviceMetadata.getName()); - getDriver().findElements(By.xpath("//*[@data-tests-id='dashboard-Elements']//*[@data-tests-id='" + serviceMetadata.getName() + "']")).get(0).click(); - GeneralUIUtils.ultimateWait(); + ResourceGeneralPage.clickCheckinButton(serviceName); + GeneralUIUtils.findComponentAndClick(serviceName); ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - AssertCreatedPathExistInCompositionPage(pathName); + PathValidations.AssertCreatedPathExistInCompositionPage(pathName); // @@ check out @@ - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.CHECKOUT.getValue()); - GeneralUIUtils.ultimateWait(); - - AssertCreatedPathExistInCompositionPage(pathName); - + ResourceGeneralPage.clickCheckoutButton(); + PathValidations.AssertCreatedPathExistInCompositionPage(pathName); } - // Jira issue 5441 + // Test#4 Jira issue 5441 @Test - public void CreateMultiplePaths() throws Exception, Throwable { - filepath = "C:\\Users\\ShiraShe\\Desktop"; - // List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileList(); - //String vnfFile = fileNamesFromFolder.get(0).toString(); - String vnfFile = "fullComposition.zip"; - String vspName = getToPathFlow(filepath, vnfFile); - createPath(vspName); - createPath(vspName); - createPathNumOfRows(7); - createPathNumOfRows(6); - createPathNumOfRows(4); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("multiple paths have been created")); - } - - // Jira issue 5506 - @Test - public void CreatePathWithComplex() throws Exception, Throwable { - List<String> vnfFiles = new ArrayList<>(); - vnfFiles.add("fullComposition.zip"); - vnfFiles.add("fullCompositionNew.zip"); - filepath = "C:\\Users\\ShiraShe\\Desktop"; - CreatePathComplexServiceFlow(filepath, vnfFiles); - //String vnfFile = "fullComposition.zip"; - // String vnfFile2 = "fullCompositionNew.zip"; - // runCreatePathComplexServiceFlow(filepath, vnfFile, vnfFile2); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("path with complex service has been created")); + public void CreateMultiplePaths() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + Pair<String, ServiceReqDetails> pair = getToPathFlow(resourceReqDetails, filePath, HSSFile); + String vspName = pair.left; + PathUtilities.createPath("Test4_path1", vspName); + PathUtilities.createPath("Test4_path2", vspName); + PathValidations.createPathNumOfRows(7); + PathValidations.createPathNumOfRows(6); + SetupCDTest.getExtendTest().log(Status.INFO, "multiple paths have been created"); } - // Jira issue 5506 + // Test#5 Jira issue 5506 @Test - public void RealScenarioComplex() throws Exception, Throwable { - filepath = "C:\\Users\\ShiraShe\\Desktop\\Srini"; + public void CreatePathWithComplex() throws Exception { List<String> vnfFiles = new ArrayList<>(); - vnfFiles.add("HSS.zip"); - vnfFiles.add("VMME.zip"); - CreatePathComplexServiceFlow(filepath, vnfFiles); - ExtentTestActions.addScreenshot(Status.INFO, "Complex service_" + vnfFiles.get(0) ,"Complex service created " + vnfFiles.get(1) + " is as follows : "); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("path with complex service has been created")); + vnfFiles.add(HSSFile); + vnfFiles.add(VMMEFile); + Pair<String, String> complex = CreatePathComplexServiceFlow(filePath, vnfFiles); + String serviceName = complex.left; + String pathName = complex.right; + PathValidations.validateServicePath(serviceName,pathName); + SetupCDTest.getExtendTest().log(Status.INFO, "path with complex service has been created"); } - // Jira issue 5506 + // Test#6 Jira issue 5506 @Test - public void CreateExtendedPathWithComplex() throws Exception, Throwable { - filepath = "C:\\Users\\ShiraShe\\Desktop"; + public void CreateExtendedPathWithComplex() throws Exception { List<String> vnfFiles = new ArrayList<>(); - vnfFiles.add("fullComposition.zip"); - vnfFiles.add("fullCompositionNew.zip"); - //String vnfFile = "fullComposition.zip"; - //String vnfFile2 = "fullCompositionNew.zip"; - String[] services = ToComplexService(filepath, vnfFiles); - createComplexExtendedPath(services[0], services[1]); - ExtentTestActions.addScreenshot(Status.INFO, "Complex service_" + services[0] ,"Complex service created " + services[1] + " is as follows : "); - + vnfFiles.add(fullCompositionFile); + vnfFiles.add(fullCompositionFile2); + String[] services = getToComplexService(filePath, vnfFiles); + PathValidations.validateComplexExtendedPath(services); + SetupCDTest.getExtendTest().log(Status.INFO, "path with complex service has been created"); } - // Jira issue 5441 + // Test#7 Jira issue 5441 @Test - public void CreatePathExtendedTest() throws Exception, Throwable { - filepath = "C:\\Users\\ShiraShe\\Desktop"; - // List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileList(); - //String vnfFile = fileNamesFromFolder.get(0).toString(); - String vnfFile = "fullComposition.zip"; - runCreateExtendedPathFlow(filepath, vnfFile); + public void CreatePathExtendedTest() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + runCreateExtendedPathFlow(resourceReqDetails, filePath, fullCompositionFile); } - //create service - public ServiceReqDetails createService() throws Exception, AWTException { - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - return serviceMetadata; - } + //////////////////////////////////////////////////////////////////////////////////////// + // flow methods // + //////////////////////////////////////////////////////////////////////////////////////// // workflow leading to path - public String onboardAndCertify(String filepath, String vnfFile) throws Exception, IOException { - - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); - Pair<String, VendorSoftwareProductObject> onboardAndValidate = OnboardingUiUtils.onboardAndValidate(resourceReqDetails,filepath, vnfFile, getUser()); - String vspName = onboardAndValidate.left; + public String onboardAndCertify(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception { + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser()); + String vspName = vendorSoftwareProductObject.getName(); DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen(); - ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile ,"The topology template for " + vnfFile + " is as follows : "); + ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile, "The topology template for " + vnfFile + " is as follows : "); DeploymentArtifactPage.clickSubmitForTestingButton(vspName); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("relogin as TESTER")); + SetupCDTest.getExtendTest().log(Status.INFO, "relogin as TESTER"); reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vspName); TesterOperationPage.certifyComponent(vspName); return vspName; } - public List<String> onboardAndCertifyMultipleVFs(String filepath, List<String> vnfFiles) throws Exception, IOException { - + public List<String> onboardAndCertifyMultipleVFs(String filePath, List<String> vnfFiles) throws Exception { List<String> VFNames = new ArrayList<>(); - for(int i = 0; i<vnfFiles.size(); i++) - { + for (int i = 0; i < vnfFiles.size(); i++) { ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); - Pair<String, VendorSoftwareProductObject> onboardAndValidate = OnboardingUiUtils.onboardAndValidate(resourceReqDetails,filepath, vnfFiles.get(i), getUser()); - VFNames.add(i, onboardAndValidate.left); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFiles.get(i), getUser()); + VFNames.add(i, vendorSoftwareProductObject.getName()); DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen(); - ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFiles.get(i) ,"The topology template for " + vnfFiles.get(i) + " is as follows : "); + ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFiles.get(i), "The topology template for " + vnfFiles.get(i) + " is as follows : "); DeploymentArtifactPage.clickSubmitForTestingButton(VFNames.get(i)); } - SetupCDTest.getExtendTest().log(Status.INFO, String.format("relogin as TESTER")); + SetupCDTest.getExtendTest().log(Status.INFO, "relogin as TESTER"); reloginWithNewRole(UserRoleEnum.TESTER); - for (int j = 0; j< VFNames.size(); j++) - { - GeneralUIUtils.findComponentAndClick(VFNames.get(j)); - TesterOperationPage.certifyComponent(VFNames.get(j)); + for (String VFName : VFNames) { + GeneralUIUtils.findComponentAndClick(VFName); + TesterOperationPage.certifyComponent(VFName); } - return VFNames; } - // path components - - public void AssertCreatePath() throws Exception, IOException { - String check = getDriver().findElements(By.xpath("//*[@data-tests-id='Create']")).get(0).getAttribute("disabled"); - if (check.intern() != "true") - { - throw new Exception("Button create path should be disabled. open bug to UI team"); - } - } - - public void AssertCreatedPathExistInCompositionPage(String pathName) throws Exception, IOException { - // check path in the list filter - checkPathFilter(pathName, true); - - openPathList(); - - // assert path is in the list - String PathListName1 = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']")).get(0).getText(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_CLOSE.getValue()); - } - - public void AssertExtendPath() throws Exception, IOException { - String check = getDriver().findElements(By.xpath("//*[@data-tests-id='extendPathlnk']")).get(0).getAttribute("class"); - if (check.intern() != "disabled") - { - throw new Exception("Button extend path should be disabled. open bug to UI team"); - } - } - - public void createPathNumOfRows(int numOfPathRows)throws Exception, AWTException{ - openCreatePath(); - insertValues("extended" + RandomStringUtils.randomAlphanumeric(8),"pathProtocol1", "pathPortNumbers1"); - selectFirstLineParam(); - extendPath(numOfPathRows); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); - } - - public void linkVFs(String vspName, int linksNum)throws Exception, AWTException { - - CompositionPage.searchForElement(vspName); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - List <CanvasElement> VFs = new ArrayList<CanvasElement>(); - - VFs.add(canvasManager.createElementOnCanvas(vspName)); - - for (int i = 1; i<linksNum; i++) - { - VFs.add(canvasManager.createElementOnCanvas(vspName)); - GeneralUIUtils.ultimateWait(); - canvasManager.linkElements(VFs.get(i), CircleSize.VF, VFs.get(i-1), CircleSize.VF); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("link VFs")); - GeneralUIUtils.ultimateWait(); - } - } - - public void linkServices(String Service1, String Service2, int linksNum)throws Exception, AWTException { - - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - List <CanvasElement> VFs = new ArrayList<CanvasElement>(); - - // get first service - CompositionPage.searchForElement(Service1); - VFs.add(canvasManager.createElementOnCanvas(Service1)); - - String service = Service2; - for (int i = 1; i<linksNum; i++) - { - CompositionPage.searchForElement(service); - VFs.add(canvasManager.createElementOnCanvas(service)); - GeneralUIUtils.ultimateWait(); - canvasManager.linkElements(VFs.get(i), CircleSize.SERVICE, VFs.get(i-1), CircleSize.SERVICE); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("link services")); - GeneralUIUtils.ultimateWait(); - - // change service to link - if (service.equals(Service2)) { - service = Service1; - } - else { - service = Service2; - } - } - } - - public void openCreatePath() throws Exception, AWTException{ - - getDriver().findElements(By.xpath("//*[@data-tests-id='pathsMenuBtn']/parent::*")).get(0).click(); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_PATH_MENU_BUTTON.getValue()); - } - - public void openPathList() throws Exception, AWTException { - getDriver().findElements(By.xpath("//*[@data-tests-id='pathsMenuBtn']/parent::*")).get(0).click(); - GeneralUIUtils.ultimateWait(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_BUTTON.getValue()); - } - - public void sendValue(String DataTestId, String value) throws Exception, AWTException { - - GeneralUIUtils.getWebElementByTestID(DataTestId).sendKeys(value); - GeneralUIUtils.ultimateWait(); - } - - public void insertValues(String pathName, String pathProtocol, String pathPortNumbers) throws Exception, AWTException { - - sendValue(DataTestIdEnum.ComplexServiceAmdocs.PATH_NAME.getValue(),pathName); - sendValue(DataTestIdEnum.ComplexServiceAmdocs.PATH_PROTOCOL.getValue(),pathProtocol); - sendValue(DataTestIdEnum.ComplexServiceAmdocs.PATH_PORT_NUMBER.getValue(),pathPortNumbers); - } - - public void selectFirstLineParam() throws Exception, AWTException{ - getDriver().findElements(By.xpath("//*[@data-tests-id='linkSrc']//option")).get(0).click(); - GeneralUIUtils.ultimateWait(); - getDriver().findElements(By.xpath("//*[@data-tests-id='linkSrcCP']//option")).get(0).click(); - GeneralUIUtils.ultimateWait(); - getDriver().findElements(By.xpath("//*[@data-tests-id='linkTarget']//option")).get(0).click(); - GeneralUIUtils.ultimateWait(); - getDriver().findElements(By.xpath("//*[@data-tests-id='linkTargetCP']//option")).get(0).click(); - GeneralUIUtils.ultimateWait(); - } - - public void checkPathFilter(String pathName, boolean isFound) throws Exception, AWTException{ - GeneralUIUtils.ultimateWait(); - List<WebElement> pathFilterList = getDriver().findElements(By.xpath("//*[@data-tests-id='service-path-selector']//option")); - if (isFound) { - for (int i = 0; i < pathFilterList.size(); i++) { - String element_text = pathFilterList.get(i).getText(); - if (element_text.equals(pathName)) - { - break; - } - if (i == pathFilterList.size() -1 ) - { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("path list filter check failed")); - throw new Exception("path filter list is missing a path"); - } - } - } - else { - for (int i = 0; i < pathFilterList.size(); i++) { - String element_text = pathFilterList.get(i).getText(); - if (element_text.equals(pathName)) - { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("path list filter check failed")); - throw new Exception("path filter list is has a path that should be deleted"); - } - } - } - SetupCDTest.getExtendTest().log(Status.INFO, String.format("path list filter check passed")); - } - - public void extendPath(int numOfLines) throws Exception, AWTException { - - int i; - for (i = 0; i < numOfLines; i++) { - String check; - String index = Integer.toString(i + 2); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.EXTEND_BUTTON.getValue()); - List<WebElement> linkSrcs = getDriver().findElements(By.xpath("//*[@data-tests-id='linkSrc']//select")); - List<WebElement> linkSrcCPs = getDriver().findElements(By.xpath("//*[@data-tests-id='linkSrcCP']//select")); - List<WebElement> linkTargets = getDriver().findElements(By.xpath("//*[@data-tests-id='linkTarget']//select")); - List<WebElement> linkTargetCPs = getDriver().findElements(By.xpath("//*[@data-tests-id='linkTargetCP']//select")); - - for (int j = 0; j < i + 2; j++) { - check = linkSrcs.get(j).getAttribute("class"); - if (!check.intern().contains("disabled")) { - throw new Exception("Source should be disabled. open bug to UI team"); - } - check = linkSrcCPs.get(j).getAttribute("class"); - if (!check.intern().contains("disabled")) { - throw new Exception("Source connection point of last lines should be disabled. open bug to UI team"); - } - } - for (int j = 0; j < i + 1; j++) { - - check = linkTargets.get(j).getAttribute("class"); - if (!check.intern().contains("disabled")) { - throw new Exception("Target of last lines should be disabled. open bug to UI team"); - } - check = linkTargetCPs.get(j).getAttribute("class"); - if (!check.intern().contains("disabled")) { - throw new Exception("Target connection point of last lines should be disabled. open bug to UI team"); - } - } - - List <WebElement> choices = getDriver().findElements(By.xpath("//*[" + index + "]/*[@data-tests-id='linkTarget']//option")); - choices.get((new Random()).nextInt(choices.size())).click(); - choices = getDriver().findElements(By.xpath("//*[" + index + "]/*[@data-tests-id='linkTargetCP']//option")); - choices.get((new Random()).nextInt(choices.size())).click(); - } - } - - public String editPath(String pathName) throws Exception, AWTException{ - getDriver().findElements(By.xpath("//*[text()='"+pathName+"']/parent::*//span")).get(0).click(); - pathName = "name2"; - GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ComplexServiceAmdocs.PATH_NAME.getValue()).clear(); - sendValue(DataTestIdEnum.ComplexServiceAmdocs.PATH_NAME.getValue(), pathName); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.SAVE.getValue()); - return pathName; - } - - public int deleteLines(int numOfLinesToDelete,int numOfLines)throws Exception, AWTException{ - - for (int i=0; i<numOfLinesToDelete; i++){ - getDriver().findElements(By.xpath("//*[@data-tests-id='removeLnk']//span")).get(0).click(); - numOfLines--; - } - if (getDriver().findElements(By.xpath("//*[@data-tests-id='linkTargetCP']//option")).size()>(numOfLines+1)) - { - throw new Exception("Path element was not deleted"); - } - GeneralUIUtils.ultimateWait(); - return numOfLines; - } - - public String getToPathFlow(String filepath, String vnfFile) throws Exception, AWTException { - - String vspName = onboardAndCertify(filepath, vnfFile); - reloginWithNewRole(UserRoleEnum.DESIGNER); - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - return vspName; - } - - // path scenarios - - public String createPath(String vspName) throws Exception, AWTException { - - linkVFs(vspName, 3); - openCreatePath(); - String pathName = "name1"; - insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); - //select path elements - selectFirstLineParam(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("path has been created")); - return pathName; - } - - // flows - - public void createExtendedPath(String vspName) throws Exception, AWTException { - //drag and drop VFs and link them - linkVFs(vspName, 5); - - //open create path box - openCreatePath(); - String pathName = "name1"; - insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); - selectFirstLineParam(); - //extend path - int numOfLines = 3; - extendPath(numOfLines); - //delete line - int numOfLinesToDelete = 1; - numOfLines = deleteLines(numOfLinesToDelete, numOfLines); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); - ExtentTestActions.log(Status.INFO, "path has been created"); - - // check that path exist in the path filter list - checkPathFilter(pathName, true); - - // check that path exist in the path list - getDriver().findElements(By.xpath("//*[@data-tests-id='pathsMenuBtn']/parent::*")).get(0).click(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_BUTTON.getValue()); - String PathListName1 = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']")).get(0).getText(); - - // edit path - pathName = editPath(pathName); - - // go back to path's list - getDriver().findElements(By.xpath("//*[@data-tests-id='pathsMenuBtn']/parent::*")).get(0).click(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_BUTTON.getValue()); - - // get name - String PathListName2 = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']")).get(0).getText(); - - // assert names changed - if (PathListName1.equals(PathListName2)) - { - throw new Exception("path name expected to change after edit but did not"); - } - - // delete path - int paths_before_deletion = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']/parent::*//span")).size(); - getDriver().findElements(By.xpath("//*[text()='"+pathName+"']/parent::*//span")).get(1).click(); - GeneralUIUtils.ultimateWait(); - int paths_after_deletion = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']/parent::*//span")).size(); - if (paths_after_deletion == paths_before_deletion) - { - throw new Exception("path expected to be deleted but did not"); - } - - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_CLOSE.getValue()); - //ArtifactsCorrelationManager.addVNFtoServiceArtifactCorrelation(serviceMetadata.getName(), vspName); - //ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser()); - //ExtentTestActions.addScreenshot(Status.INFO, "ServiceComposition_" + vnfFile, "The service topology is as follows: "); - //ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Path has been created")); - - // check that path got deleted in the path filter list - checkPathFilter(pathName, false); - } - - public void createComplexExtendedPath(String Service1, String Service2) throws Exception, AWTException { - //drag and drop Services and link them - linkServices(Service1, Service2, 5); - - //-----------------------------------------create path------------------------------------------------- - - //open create path box - openCreatePath(); - - String pathName = "name1"; - String pathProtocol = "pathProtocol1"; - String pathPortNumbers = "pathPortNumbers1"; - - insertValues(pathName, pathProtocol, pathPortNumbers); - - //select path parameters - selectFirstLineParam(); - //extend path - int numOfLines = 3; - extendPath(numOfLines); - - //delete line - int numOfLinesToDelete = 1; - numOfLines = deleteLines(numOfLinesToDelete, numOfLines); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); - ExtentTestActions.log(Status.INFO, "path has been created"); - - //---------------------------------------check path's list----------------------------- - - // go to path's list - openPathList(); - - // get name - String PathListName1 = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']")).get(0).getText(); - - // edit path - pathName = editPath(pathName); - - // go back to path's list - getDriver().findElements(By.xpath("//*[@data-tests-id='pathsMenuBtn']/parent::*")).get(0).click(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_BUTTON.getValue()); - - // get name - String PathListName2 = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']")).get(0).getText(); - - // assert names changed - if (PathListName1.equals(PathListName2)) - { - throw new Exception("path name expected to change after edit but did not"); - } - - // delete path - int paths_before_deletion = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']/parent::*//span")).size(); - getDriver().findElements(By.xpath("//*[text()='"+pathName+"']/parent::*//span")).get(1).click(); - Thread.sleep(1000); - int paths_after_deletion = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']/parent::*//span")).size(); - if (paths_after_deletion == paths_before_deletion) - { - throw new Exception("path expected to be deleted but did not"); - } - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_CLOSE.getValue()); - //ArtifactsCorrelationManager.addVNFtoServiceArtifactCorrelation(serviceMetadata.getName(), vspName); - - //assertNotNull(vfElement); - //ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser()); - //ExtentTestActions.addScreenshot(Status.INFO, "ServiceComposition_" + vnfFile, "The service topology is as follows: "); - - //ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Path has been created")); - } - - public String[] getToComplexService(String filepath, String vnfFile, String vnfFile2) throws Exception, AWTException{ - // create & certify 2 VF - String vspName1 = onboardAndCertify(filepath, vnfFile); - reloginWithNewRole(UserRoleEnum.DESIGNER); - String vspName2 = onboardAndCertify(filepath, vnfFile2); - - // create service 1 - reloginWithNewRole(UserRoleEnum.DESIGNER); - ServiceReqDetails serviceMetadata1 = createService(); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // create path - createPath(vspName1); - getDriver().findElements(By.xpath("//*[@data-tests-id='submit_for_testing']")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='changeLifeCycleMessage']")).get(0).sendKeys("new Service to test"); - getDriver().findElements(By.xpath("//*[@data-tests-id='OK']")).get(0).click(); - - // create service 2 - ServiceReqDetails serviceMetadata2 = createService(); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // create path - createPath(vspName2); - getDriver().findElements(By.xpath("//*[@data-tests-id='submit_for_testing']")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='changeLifeCycleMessage']")).get(0).sendKeys("new Service to test"); - getDriver().findElements(By.xpath("//*[@data-tests-id='OK']")).get(0).click(); - - //tester - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName()); - TesterOperationPage.certifyComponent(serviceMetadata1.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata2.getName()); - TesterOperationPage.certifyComponent(serviceMetadata2.getName()); - - //governor - reloginWithNewRole(UserRoleEnum.GOVERNOR); - GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName()); - GovernorOperationPage.approveSerivce(serviceMetadata1.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata2.getName()); - GovernorOperationPage.approveSerivce(serviceMetadata2.getName()); - - //create service for complex service + public Pair<String, ServiceReqDetails> getToPathFlow(ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception { + String vspName = onboardAndCertify(resourceReqDetails, filepath, vnfFile); reloginWithNewRole(UserRoleEnum.DESIGNER); - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - return new String[]{serviceMetadata1.getName(), serviceMetadata2.getName()}; + ServiceReqDetails serviceMetadata = PathUtilities.createService(getUser()); + return new Pair<>(vspName, serviceMetadata); } - public String[] ToComplexService(String filepath, List<String> vnfFiles) throws Exception, AWTException{ + public String[] getToComplexService(String filepath, List<String> vnfFiles) throws Exception { // create & certify 2 VF List<String> VFNames = onboardAndCertifyMultipleVFs(filepath, vnfFiles); - - // create service 1 - reloginWithNewRole(UserRoleEnum.DESIGNER); - ServiceReqDetails serviceMetadata1 = createService(); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // create path - createPath(VFNames.get(0)); - getDriver().findElements(By.xpath("//*[@data-tests-id='submit_for_testing']")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='changeLifeCycleMessage']")).get(0).sendKeys("new Service to test"); - getDriver().findElements(By.xpath("//*[@data-tests-id='OK']")).get(0).click(); - GeneralUIUtils.ultimateWait();; - - // create service 2 - ServiceReqDetails serviceMetadata2 = createService(); - GeneralUIUtils.ultimateWait();; - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // create path - createPath(VFNames.get(1)); - getDriver().findElements(By.xpath("//*[@data-tests-id='submit_for_testing']")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='changeLifeCycleMessage']")).get(0).sendKeys("new Service to test"); - getDriver().findElements(By.xpath("//*[@data-tests-id='OK']")).get(0).click(); - - //tester - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName()); - TesterOperationPage.certifyComponent(serviceMetadata1.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata2.getName()); - TesterOperationPage.certifyComponent(serviceMetadata2.getName()); - - //governor - reloginWithNewRole(UserRoleEnum.GOVERNOR); - GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName()); - GovernorOperationPage.approveSerivce(serviceMetadata1.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata2.getName()); - GovernorOperationPage.approveSerivce(serviceMetadata2.getName()); - - //create service for complex service reloginWithNewRole(UserRoleEnum.DESIGNER); - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + ServiceReqDetails serviceMetadata1 = PathUtilities.createService(getUser()); - return new String[]{serviceMetadata1.getName(), serviceMetadata2.getName()}; - } - - public void runCreatePathComplexServiceFlow(String filepath, String vnfFile, String vnfFile2) throws Exception, AWTException { - // create & certify 2 VF - String vspName1 = onboardAndCertify(filepath, vnfFile); - reloginWithNewRole(UserRoleEnum.DESIGNER); - String vspName2 = onboardAndCertify(filepath, vnfFile2); + // create path 1 + PathUtilities.createPath("newPath", VFNames.get(0)); + PathUtilities.submitForTesting(); + GeneralUIUtils.ultimateWait(); + ServiceReqDetails serviceMetadata2 = PathUtilities.createService(getUser()); - // create service 1 - reloginWithNewRole(UserRoleEnum.DESIGNER); - ServiceReqDetails serviceMetadata1 = createService(); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // create path - createPath(vspName1); - getDriver().findElements(By.xpath("//*[@data-tests-id='submit_for_testing']")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='changeLifeCycleMessage']")).get(0).sendKeys("new Service to test"); - getDriver().findElements(By.xpath("//*[@data-tests-id='OK']")).get(0).click(); - - // create service 2 - ServiceReqDetails serviceMetadata2 = createService(); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // create path - createPath(vspName2); - getDriver().findElements(By.xpath("//*[@data-tests-id='submit_for_testing']")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='changeLifeCycleMessage']")).get(0).sendKeys("new Service to test"); - getDriver().findElements(By.xpath("//*[@data-tests-id='OK']")).get(0).click(); + // create path 2 + PathUtilities.createPath("newPath2", VFNames.get(1)); + PathUtilities.submitForTesting(); //tester reloginWithNewRole(UserRoleEnum.TESTER); @@ -796,197 +225,60 @@ public class CreatePath extends SetupCDTest { //create service for complex service reloginWithNewRole(UserRoleEnum.DESIGNER); - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // link services - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(serviceMetadata1.getName()); - CanvasElement service1 = canvasManager.createElementOnCanvas(serviceMetadata1.getName()); - CompositionPage.searchForElement(serviceMetadata2.getName()); - CanvasElement service2 = canvasManager.createElementOnCanvas(serviceMetadata2.getName()); - canvasManager.linkElements(service1,CircleSize.SERVICE, service2, CircleSize.SERVICE); - - // create path - openCreatePath(); - insertValues("name1", "pathProtocol1", "pathPortNumbers1"); - selectFirstLineParam(); - GeneralUIUtils.getWebElementByTestID("Create").click(); + ServiceReqDetails serviceMetadata3 = PathUtilities.createService(getUser()); + return new String[]{serviceMetadata1.getName(), serviceMetadata2.getName(), serviceMetadata3.getName()}; } - public void CreatePathComplexServiceFlow(String filepath, List<String> vnfFiles) throws Exception, AWTException { - // create & certify 2 VF - List<String> vfNames = onboardAndCertifyMultipleVFs(filepath, vnfFiles); - - // create service 1 - reloginWithNewRole(UserRoleEnum.DESIGNER); - ServiceReqDetails serviceMetadata1 = createService(); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // create path - createPath(vfNames.get(0)); - getDriver().findElements(By.xpath("//*[@data-tests-id='submit_for_testing']")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='changeLifeCycleMessage']")).get(0).sendKeys("new Service to test"); - getDriver().findElements(By.xpath("//*[@data-tests-id='OK']")).get(0).click(); - - // create service 2 - ServiceReqDetails serviceMetadata2 = createService(); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // create path - createPath(vfNames.get(0)); - getDriver().findElements(By.xpath("//*[@data-tests-id='submit_for_testing']")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='changeLifeCycleMessage']")).get(0).sendKeys("new Service to test"); - getDriver().findElements(By.xpath("//*[@data-tests-id='OK']")).get(0).click(); - - //tester - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName()); - TesterOperationPage.certifyComponent(serviceMetadata1.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata2.getName()); - TesterOperationPage.certifyComponent(serviceMetadata2.getName()); - - //governor - reloginWithNewRole(UserRoleEnum.GOVERNOR); - GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName()); - GovernorOperationPage.approveSerivce(serviceMetadata1.getName()); - GeneralUIUtils.findComponentAndClick(serviceMetadata2.getName()); - GovernorOperationPage.approveSerivce(serviceMetadata2.getName()); - - //create service for complex service - reloginWithNewRole(UserRoleEnum.DESIGNER); - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - // go to composition - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - // link services + public Pair<String, String> CreatePathComplexServiceFlow(String filepath, List<String> vnfFiles) throws Exception { + String[] servicesName = getToComplexService(filepath, vnfFiles); CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(serviceMetadata1.getName()); - CanvasElement service1 = canvasManager.createElementOnCanvas(serviceMetadata1.getName()); - CompositionPage.searchForElement(serviceMetadata2.getName()); - CanvasElement service2 = canvasManager.createElementOnCanvas(serviceMetadata2.getName()); - canvasManager.linkElements(service1,CircleSize.SERVICE, service2, CircleSize.SERVICE); + CompositionPage.searchForElement(servicesName[0]); + CanvasElement service1 = canvasManager.createElementOnCanvas(servicesName[0]); + CompositionPage.searchForElement(servicesName[1]); + CanvasElement service2 = canvasManager.createElementOnCanvas(servicesName[1]); + canvasManager.linkElements(service1, CircleSize.SERVICE, service2, CircleSize.SERVICE); // create path - openCreatePath(); - insertValues("name1", "pathProtocol1", "pathPortNumbers1"); - selectFirstLineParam(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + String pathName = "name1"; + PathUtilities.openCreatePath(); + PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); + PathUtilities.selectFirstLineParam(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()).click(); + return new Pair<>(servicesName[2], pathName); } - public void runCreateExtendedPathFlow(String filepath, String vnfFile) throws Exception, AWTException { - - String vspName = getToPathFlow(filepath, vnfFile); + public void runCreateExtendedPathFlow(ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception { + Pair<String, ServiceReqDetails> pair = getToPathFlow(resourceReqDetails, filepath, vnfFile); + String vspName = pair.left; + PathUtilities.linkVFs(vspName, 4); - //drag and drop VFs and link them - linkVFs(vspName, 5); - - //-----------------------------------------create path------------------------------------------------- - - //open create path box - openCreatePath(); + //create path + PathUtilities.openCreatePath(); String pathName = "name1"; - insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); - - //select path parameters - selectFirstLineParam(); - //extend path + PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); + PathUtilities.selectFirstLineParam(); int numOfLines = 3; - extendPath(numOfLines); + PathValidations.extendPath(numOfLines); //delete line - int numOfLinesToDelete = 1; - numOfLines = deleteLines(numOfLinesToDelete, numOfLines); + PathUtilities.deleteLines(1, numOfLines); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); ExtentTestActions.log(Status.INFO, "path has been created"); // check path is on the list - openPathList(); - String PathListName1 = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']")).get(0).getText(); - - // edit path - pathName = editPath(pathName); - - // go back to path's list - getDriver().findElements(By.xpath("//*[@data-tests-id='pathsMenuBtn']/parent::*")).get(0).click(); + PathUtilities.openPathList(); + String PathListName1 = GeneralUIUtils.findByText(pathName).getText(); + String newPathName = "name2"; + PathUtilities.editPathName(pathName, newPathName); + GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.PATH_MENU_BUTTON.getValue() + "']/parent::*").get(0).click(); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_BUTTON.getValue()); + String PathListName2 = GeneralUIUtils.findByText(newPathName).getText(); + PathValidations.AssertNameChangeFromPathList(PathListName1, PathListName2); - // get name - String PathListName2 = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']")).get(0).getText(); - - // assert names changes - if (PathListName1.equals(PathListName2)) - { - throw new Exception("path name expected to change after edit but did not"); - } - - // delete path - int paths_before_deletion = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']/parent::*//span")).size(); - getDriver().findElements(By.xpath("//*[text()='"+pathName+"']/parent::*//span")).get(1).click(); - GeneralUIUtils.ultimateWait(); - int paths_after_deletion = getDriver().findElements(By.xpath("//*[text()='"+pathName+"']/parent::*//span")).size(); - if (paths_after_deletion == paths_before_deletion) - { - throw new Exception("path expected to be deleted but did not"); - } + // delete path and validate + PathValidations.ValidateAndDeletePathFromPathList(newPathName); GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_CLOSE.getValue()); - //ArtifactsCorrelationManager.addVNFtoServiceArtifactCorrelation(serviceMetadata.getName(), vspName); - //ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser()); - //ExtentTestActions.addScreenshot(Status.INFO, "ServiceComposition_" + vnfFile, "The service topology is as follows: "); - //ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Path has been created")); - } - - public void runCreatePathFlow(String filepath, String vnfFile) throws Exception, AWTException { - String vspName = onboardAndCertify(filepath, vnfFile); - - reloginWithNewRole(UserRoleEnum.DESIGNER); - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - - CompositionPage.searchForElement(vspName); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CanvasElement vfElement1 = canvasManager.createElementOnCanvas(vspName); - CanvasElement vfElement2 = canvasManager.createElementOnCanvas(vspName); - CanvasElement vfElement3 = canvasManager.createElementOnCanvas(vspName); - CanvasElement vfElement4 = canvasManager.createElementOnCanvas(vspName); - CanvasElement vfElement5 = canvasManager.createElementOnCanvas(vspName); - canvasManager.linkElements(vfElement1, CircleSize.VF, vfElement2, CircleSize.VF); - canvasManager.linkElements(vfElement3,CircleSize.VF, vfElement2, CircleSize.VF); - canvasManager.linkElements(vfElement3, CircleSize.VF, vfElement4, CircleSize.VF); - canvasManager.linkElements(vfElement5, CircleSize.VF, vfElement4, CircleSize.VF); - canvasManager.linkElements(vfElement5, CircleSize.VF, vfElement1, CircleSize.VF); - - //create path - - getDriver().findElements(By.xpath("//*[@data-tests-id='pathsMenuBtn']/parent::*")).get(0).click(); -// GeneralUIUtils.getWebElementByTestID("pathsMenuBtn").click(); - GeneralUIUtils.getWebElementByTestID("createPathMenuItem").click(); - //insert values - GeneralUIUtils.getWebElementByTestID("pathName").sendKeys("name"); - GeneralUIUtils.getWebElementByTestID("pathProtocol").sendKeys("pathProtocol"); - GeneralUIUtils.getWebElementByTestID("pathPortNumbers").sendKeys("pathPortNumbers"); - //select path parameters - - getDriver().findElements(By.xpath("//*[@data-tests-id='linkSrc']//option")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='linkSrcCP']//option")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='linkTarget']//option")).get(0).click(); - getDriver().findElements(By.xpath("//*[@data-tests-id='linkTargetCP']//option")).get(0).click(); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); - - //ArtifactsCorrelationManager.addVNFtoServiceArtifactCorrelation(serviceMetadata.getName(), vspName); - - //assertNotNull(vfElement); - //ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser()); - //ExtentTestActions.addScreenshot(Status.INFO, "ServiceComposition_" + vnfFile, "The service topology is as follows: "); - - //ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + SetupCDTest.getExtendTest().log(Status.INFO, "Path has been created"); } @Override |