diff options
Diffstat (limited to 'ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute')
43 files changed, 6606 insertions, 2891 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 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 new file mode 100644 index 0000000000..147748d00e --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/ElementsChanges.java @@ -0,0 +1,723 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; + +import com.aventstack.extentreports.Status; +import com.clearspring.analytics.util.Pair; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.datatypes.*; +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.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.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotSame; + + +public class +ElementsChanges extends SetupCDTest { + + protected static String filePath = FileHandling.getFilePath("ComplexService"); + private static String fullCompositionFile = "fullComposition.zip"; + private static String test = "test.zip"; + private static String fullCompositionFile2 = "test.zip"; + private static String HSSFile = "HSS.zip"; + private static String VMMEFile = "VMME.zip"; + private static String WithPort = "withPort.zip"; + private static String withoutPort = "withoutPort.zip"; + private static String makeDistributionValue; + + @Parameters({"makeDistribution"}) + @BeforeMethod + public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) { + makeDistributionValue = makeDistributionReadValue; + } + + //------------------------------------------Tests----------------------------------------------------- + + // Test#1 Jira issue 6324 + @Test + public void DeleteComponent() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile); + reloginWithNewRole(UserRoleEnum.DESIGNER); + ServiceReqDetails serviceMetadata = PathUtilities.createService(getUser()); + List<CanvasElement> VFs = PathUtilities.linkVFs(vspName, 3); + String pathName = PathUtilities.createPathWithoutLink("DeleteComponent", vspName); + PathUtilities.deleteComponents(VFs); + PathValidations.validatePathListIsEmpty(); + certifyServiceAsTester(serviceMetadata); + + } + + // Test#2 Jira issue 6325 + @Test + public void DeleteServiceComponent() throws Exception { + ServiceReqDetails serviceMetadata = getToComplexService(filePath, fullCompositionFile); + reloginWithNewRole(UserRoleEnum.DESIGNER); + ServiceReqDetails complexService = PathUtilities.createService(getUser()); + List<CanvasElement> services = createComplexPath(serviceMetadata.getName()); + PathUtilities.deleteComponents(services); + PathValidations.validatePathListIsEmpty(); + certifyServiceAsTester(complexService); + } + + // Test#3 Jira issue 6364 + @Test + public void ManualUpdateVF() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile); + reloginWithNewRole(UserRoleEnum.DESIGNER); + ServiceReqDetails serviceMetadata = PathUtilities.createService(getUser()); + PathUtilities.createPath("ManualUpdateVF", vspName); + 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("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(); + //VendorSoftwareProductRestUtils.uploadHeatPackage(filePath,fullCompositionFile,v,getUser()); +//upload new heat +commit submit + //go to home + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.MainMenuButtons.ONBOARD_BUTTON.getValue()); + + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + // CanvasManager.getCanvasManager().clickOnCanvaElement(vf); + //update version + //validate path still exist + certifyServiceAsTester(serviceMetadata); + } + + @Test + public void UpdateComponent() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vspName = onboardAndCertify(resourceReqDetails, filePath, VMMEFile); + + } + + @Test + public void UpdateComponentWithouForwarder() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vsp_v2_description = "change description for version 2"; + VendorSoftwareProductObject vendorSoftwareProductObject = getToPathServiceVersions(resourceReqDetails, filePath, WithPort, vsp_v2_description, withoutPort, getUser()); + + // create service + ServiceReqDetails service = PathUtilities.createService(getUser()); + + // create path + String vspName = vendorSoftwareProductObject.getName(); + String pathName = "path1"; + List<CanvasElement> VFs = PathUtilities.linkVFs(vspName, 2); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + for (CanvasElement element: VFs) { + CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); + } + PathUtilities.openCreatePath(); + PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); + PathUtilities.selectFirstLineParam(); + PathValidations.extendPath(3); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + + ///////////////// + // test case // + ///////////////// + + // validate version change has no effect + for (CanvasElement element: VFs) { + RestResponse ServiceForwardingPathsResponse = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + // change to version with different capabiliteis + 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(); + // validate paths changed + RestResponse ServiceForwardingPathsResponse2 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + assertNotSame( + "response message failed expectation, expectation is to change", + ServiceForwardingPathsResponse.getResponse(), + ServiceForwardingPathsResponse2.getResponse()); + // validate there are no error messages + PathValidations.ValidateThereIsNoErrorMessage(); + + 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 + RestResponse ServiceForwardingPathsResponse3 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + assertEquals( + "response message failed expectation, expectation is not to change", + ServiceForwardingPathsResponse2.getResponse(), + ServiceForwardingPathsResponse3.getResponse()); + // validate there are no error messages + PathValidations.ValidateThereIsNoErrorMessage(); + } + + /////////////////////// + // post requisites // + /////////////////////// + + // finish flow + certifyServiceAsTester(service); + } + + //TODO run and debug +// Test#3 Jira issue - 6230 + @Test + public void ValidatePathServiceVersions() throws Exception { + + ////////////////////// + // pre requisites // + ////////////////////// + + // start flow + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vsp_v2_description = "change description for version 2"; + VendorSoftwareProductObject vendorSoftwareProductObject = getToPathServiceVersions(resourceReqDetails, filePath, HSSFile, vsp_v2_description, fullCompositionFile, getUser()); + + // create service + ServiceReqDetails service = PathUtilities.createService(getUser()); + + // create path + String vspName = vendorSoftwareProductObject.getName(); + String pathName = "path1"; + List<CanvasElement> VFs = PathUtilities.linkVFs(vspName, 2); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + for (CanvasElement element: VFs) { + CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); + } + PathUtilities.openCreatePath(); + PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); + PathUtilities.selectFirstLineParam(); + PathValidations.extendPath(3); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + + ///////////////// + // test case // + ///////////////// + + // validate version change has no effect + for (CanvasElement element: VFs) { + RestResponse ServiceForwardingPathsResponse = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + + CompositionPage.changeComponentVersion(canvasManager, element, "2.0",false); + // validate paths hasn't changed + RestResponse ServiceForwardingPathsResponse2 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + assertEquals( + "response message failed expectation, expectation is not to change", + ServiceForwardingPathsResponse.getResponse(), + ServiceForwardingPathsResponse2.getResponse()); + // validate there are no error messages + PathValidations.ValidateThereIsNoErrorMessage(); + + CompositionPage.changeComponentVersion(canvasManager, element, "1.0",false); + // validate paths hasn't changed + RestResponse ServiceForwardingPathsResponse3 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + assertEquals( + "response message failed expectation, expectation is not to change", + ServiceForwardingPathsResponse.getResponse(), + ServiceForwardingPathsResponse3.getResponse()); + // validate there are no error messages + PathValidations.ValidateThereIsNoErrorMessage(); + } + + /////////////////////// + // post requisites // + /////////////////////// + + // finish flow + certifyServiceAsTester(service); + } + + //TODO run and debug +// Test#3 Jira issue - 6189 + @Test + public void ValidatePathServiceVersionsDifferentCapabilities() throws Exception { + + ////////////////////// + // pre requisites // + ////////////////////// + + // start flow + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vsp_v2_description = "change description for version 2"; + VendorSoftwareProductObject vendorSoftwareProductObject = getToPathServiceVersions(resourceReqDetails, filePath, HSSFile, vsp_v2_description, fullCompositionFile, getUser()); + + // create service + ServiceReqDetails service = PathUtilities.createService(getUser()); + + // create path + String vspName = vendorSoftwareProductObject.getName(); + String pathName = "path1"; + List<CanvasElement> VFs = PathUtilities.linkVFs(vspName, 2); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + for (CanvasElement element: VFs) { + CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); + } + PathUtilities.openCreatePath(); + PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); + PathUtilities.selectFirstLineParam(); + PathValidations.extendPath(3); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + + ///////////////// + // test case // + ///////////////// + + // validate version change has no effect + for (CanvasElement element: VFs) { + RestResponse ServiceForwardingPathsResponse = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + // change to version with different capabiliteis + 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(); + // validate paths changed + RestResponse ServiceForwardingPathsResponse2 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + assertNotSame( + "response message failed expectation, expectation is to change", + ServiceForwardingPathsResponse.getResponse(), + ServiceForwardingPathsResponse2.getResponse()); + // validate there are no error messages + PathValidations.ValidateThereIsNoErrorMessage(); + + 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 + RestResponse ServiceForwardingPathsResponse3 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + assertEquals( + "response message failed expectation, expectation is not to change", + ServiceForwardingPathsResponse2.getResponse(), + ServiceForwardingPathsResponse3.getResponse()); + // validate there are no error messages + PathValidations.ValidateThereIsNoErrorMessage(); + } + + /////////////////////// + // post requisites // + /////////////////////// + + // finish flow + certifyServiceAsTester(service); + } + + //TODO run and debug +// Test#3 Jira issue - 6231 + @Test + public void ValidatePathServiceVersionsnegative() throws Exception { + + ////////////////////// + // pre requisites // + ////////////////////// + + // start flow + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vsp_v2_description = "change description for version 2"; + VendorSoftwareProductObject vendorSoftwareProductObject = getToPathServiceVersions(resourceReqDetails, filePath, HSSFile, vsp_v2_description, fullCompositionFile, getUser()); + + // create service + ServiceReqDetails service = PathUtilities.createService(getUser()); + + // create path + String vspName = vendorSoftwareProductObject.getName(); + String pathName = "path1"; + List<CanvasElement> VFs = PathUtilities.linkVFs(vspName, 2); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + for (CanvasElement element: VFs) { + CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); + } + PathUtilities.openCreatePath(); + PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); + PathUtilities.selectFirstLineParam(); + PathValidations.extendPath(3); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + + ///////////////// + // test case // + ///////////////// + + // validate version change has no effect + for (CanvasElement element: VFs) { + RestResponse ServiceForwardingPathsResponse = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + // change to version with different capabiliteis + 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(); + // validate paths changed + RestResponse ServiceForwardingPathsResponse2 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + assertEquals( + "response message failed expectation, expectation is not to change", + ServiceForwardingPathsResponse.getResponse(), + ServiceForwardingPathsResponse2.getResponse()); + // validate there are no error messages + PathValidations.ValidateThereIsNoErrorMessage(); + + 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(); + // validate paths hasn't changed + RestResponse ServiceForwardingPathsResponse3 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + assertNotSame( + "response message failed expectation, expectation is to change", + ServiceForwardingPathsResponse2.getResponse(), + ServiceForwardingPathsResponse3.getResponse()); + // validate there are no error messages + PathValidations.ValidateThereIsNoErrorMessage(); + } + + /////////////////////// + // post requisites // + /////////////////////// + + // finish flow + certifyServiceAsTester(service); + } + + //TODO finish +// Test#3 Jira issue - 6189 + @Test + public void ValidatePathServiceVersionsDifferentCapabilitiesInComplexService() throws Exception { + + ////////////////////// + // pre requisites // + ////////////////////// + + // start flow + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vsp_v2_description = "change description for version 2"; + VendorSoftwareProductObject vendorSoftwareProductObject = getToPathServiceVersions(resourceReqDetails, filePath, HSSFile, vsp_v2_description, fullCompositionFile, getUser()); + + // create service + ServiceReqDetails service = PathUtilities.createService(getUser()); + + // create path + String vspName = vendorSoftwareProductObject.getName(); + String pathName = "path1"; + List<CanvasElement> VFs = PathUtilities.linkVFs(vspName, 2); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + for (CanvasElement element: VFs) { + CompositionPage.changeComponentVersion(canvasManager, element, "1.0", false); + } + PathUtilities.openCreatePath(); + PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); + PathUtilities.selectFirstLineParam(); + PathValidations.extendPath(3); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + + // certify Service + certifyServiceAsTester(service); + + reloginWithNewRole(UserRoleEnum.DESIGNER); + + // create new version + GeneralUIUtils.findComponentAndClick(service.getName()); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + canvasManager = CanvasManager.getCanvasManager(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.CHECKOUT.getValue()); + + ///////////////// + // test case // + ///////////////// + + // validate version change has no effect + for (CanvasElement element: VFs) { + RestResponse ServiceForwardingPathsResponse = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + // change to version with different capabilities + 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(); + // validate paths changed + RestResponse ServiceForwardingPathsResponse2 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + assertNotSame( + "response message failed expectation, expectation is to change", + ServiceForwardingPathsResponse.getResponse(), + ServiceForwardingPathsResponse2.getResponse()); + // validate there are no error messages + PathValidations.ValidateThereIsNoErrorMessage(); + + 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 + RestResponse ServiceForwardingPathsResponse3 = PathUtilities.getServiceForwardingPathsAPI(service.getName()); + assertEquals( + "response message failed expectation, expectation is not to change", + ServiceForwardingPathsResponse2.getResponse(), + ServiceForwardingPathsResponse3.getResponse()); + // validate there are no error messages + PathValidations.ValidateThereIsNoErrorMessage(); + } + + /////////////////////// + // post requisites // + /////////////////////// + + // finish flow + certifyServiceAsTester(service); + } + + @Test + public void ComplexServiceSanity() throws Exception { + // create & certify 2 VFs + List<String> vnfFiles = new ArrayList<>(); + vnfFiles.add(HSSFile); + vnfFiles.add(fullCompositionFile); + List<String> VFNames = onboardAndCertifyMultipleVFs(filePath, vnfFiles); + reloginWithNewRole(UserRoleEnum.DESIGNER); + + // create service 1 + ServiceReqDetails serviceMetadata1 = PathUtilities.createService(getUser()); + + // create path 1 + String path1 = "newPath"; + PathUtilities.createPath(path1, VFNames.get(0)); + PathUtilities.submitForTesting(); + GeneralUIUtils.ultimateWait(); + + // create service 2 + ServiceReqDetails serviceMetadata2 = PathUtilities.createService(getUser()); + + // create path 2 + String path2 = "newPath2"; + PathUtilities.createPath(path2, VFNames.get(1)); + PathUtilities.submitForTesting(); + + // 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); + ServiceReqDetails serviceMetadata3 = PathUtilities.createService(getUser()); + + // validate complex's path + String[] services = {serviceMetadata1.getName(), serviceMetadata2.getName(), serviceMetadata3.getName()}; + PathValidations.validateComplexExtendedPath(services); + + // validate certification + certifyServiceAsTester(serviceMetadata3); + } + + //////////////////////////////////////////////////////////////////////////////////////// + // flow methods // + //////////////////////////////////////////////////////////////////////////////////////// + + // workflow leading to path + 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 : "); + + DeploymentArtifactPage.clickSubmitForTestingButton(vspName); + 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 { + List<String> VFNames = new ArrayList<>(); + for (int i = 0; i < vnfFiles.size(); i++) { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + 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 : "); + DeploymentArtifactPage.clickSubmitForTestingButton(VFNames.get(i)); + } + SetupCDTest.getExtendTest().log(Status.INFO, "relogin as TESTER"); + reloginWithNewRole(UserRoleEnum.TESTER); + for (String VFName : VFNames) { + GeneralUIUtils.findComponentAndClick(VFName); + TesterOperationPage.certifyComponent(VFName); + } + return VFNames; + } + + public static List<CanvasElement> createComplexPath(String service) throws Exception { + List<CanvasElement> services = PathUtilities.linkServices(service, service, 3); + PathUtilities.createPathWithoutLink("name1", service); + PathUtilities.createPathWithoutLink("name2", service); + return services; + } + + public ServiceReqDetails getToComplexService(String filepath, String vnfFile) throws Exception { + // create & certify VF + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vspName = onboardAndCertify(resourceReqDetails, filepath, vnfFile); + reloginWithNewRole(UserRoleEnum.DESIGNER); + ServiceReqDetails serviceMetadata1 = PathUtilities.createService(getUser()); + + // create path + PathUtilities.createPath("newPath", vspName); + PathUtilities.submitForTesting(); + GeneralUIUtils.ultimateWait(); + + //tester + reloginWithNewRole(UserRoleEnum.TESTER);GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName()); + TesterOperationPage.certifyComponent(serviceMetadata1.getName()); + + //governor + reloginWithNewRole(UserRoleEnum.GOVERNOR); + GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName()); + GovernorOperationPage.approveSerivce(serviceMetadata1.getName()); + return serviceMetadata1; + } + + public VendorSoftwareProductObject getToPathServiceVersions(ResourceReqDetails resourceReqDetails, String filepath, String vnfFileV1, String descriptionV2, String vnfFileV3, User user) throws Exception { + + //////////////////////////////////// + // VF v1 // + //////////////////////////////////// + + VendorSoftwareProductObject vendorSoftwareProduct = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFileV1, getUser()); + String vspName = vendorSoftwareProduct.getName(); + + DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen(); + ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFileV1, "The topology template for " + vnfFileV1 + " is as follows : "); + DeploymentArtifactPage.clickSubmitForTestingButton(vspName); + SetupCDTest.getExtendTest().log(Status.INFO, "relogin as TESTER"); + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(vspName); + TesterOperationPage.certifyComponent(vspName); + reloginWithNewRole(UserRoleEnum.DESIGNER); + + //////////////////////////////////// + // VF v2 // + //////////////////////////////////// + + // vsp create new version + Pair<RestResponse, OnboardItemObject> newItemVersion = PathUtilities.createNewItemVersion( + vendorSoftwareProduct.getVspId(), + vendorSoftwareProduct.getComponentId(), + "version with different description", user); + assertEquals("did not succeed to create new item version", 200, 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()); + + // commit & submit vsp + VendorSoftwareProductRestUtils.prepareVspForUse(user, vendorSoftwareProduct, false); + + // update VF + HomePage.showVspRepository(); + PathUtilities.updateVF(vspName, vendorSoftwareProduct); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.UPDATE_VF.getValue()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.SUBMIT_FOR_TESTING_BUTTON.getValue()).click(); + GeneralUIUtils.ultimateWait(); + + // certify VF + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(vspName); + TesterOperationPage.certifyComponent(vspName); + reloginWithNewRole(UserRoleEnum.DESIGNER); + + //////////////////////////////////// + // VF v3 // + //////////////////////////////////// + + // create new version + newItemVersion = PathUtilities.createNewItemVersion( + vendorSoftwareProduct.getVspId(), + vendorSoftwareProduct.getVersion(), + "version with different heat", user); + assertEquals("did not succeed to create new item version", 200, 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()); + + RestResponse validateUpload = VendorSoftwareProductRestUtils.validateUpload(vendorSoftwareProduct, user); + assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), 200, validateUpload.getErrorCode().intValue()); + + // commit & submit vsp + VendorSoftwareProductRestUtils.prepareVspForUse(user, vendorSoftwareProduct, false); + + // update VF + HomePage.showVspRepository(); + PathUtilities.updateVF(vspName, vendorSoftwareProduct); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.UPDATE_VSP.getValue()); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.SUBMIT_FOR_TESTING_BUTTON.getValue()).click(); + GeneralUIUtils.ultimateWait(); + + // certify VF + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(vspName); + TesterOperationPage.certifyComponent(vspName); + reloginWithNewRole(UserRoleEnum.DESIGNER); + + return vendorSoftwareProduct; + } + + public void certifyServiceAsTester (ServiceReqDetails serviceMetaData) throws Exception{ + PathUtilities.submitForTesting(); + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceMetaData.getName()); + TesterOperationPage.certifyComponent(serviceMetaData.getName()); + } + + @Override + 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 new file mode 100644 index 0000000000..de1e624274 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/OnboardItemObject.java @@ -0,0 +1,61 @@ +package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; + + +public class OnboardItemObject extends OnboardItemObjectReqDetails { + + private String itemId; + private String name; + private String baseId; + private String status; + + public OnboardItemObject(){super();} + + public OnboardItemObject(String itemId, String name, String baseId, String status) { + this.itemId = itemId; + this.name = name; + this.baseId = baseId; + this.status = status; + } + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public String getName() { + return name; + } + + public void setName(String itemId) { + this.name = name; + } + + public String getBaseId() { + return baseId; + } + + public void setBaseId(String baseId) { + this.baseId = baseId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public String toString() { + 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 new file mode 100644 index 0000000000..8ce36c3b97 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/OnboardItemObjectReqDetails.java @@ -0,0 +1,40 @@ +package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; + + +public class OnboardItemObjectReqDetails { + + private String creationMethod; + private String description; + + public OnboardItemObjectReqDetails() { + } + + public OnboardItemObjectReqDetails(String creationMethod, String description) { + this.creationMethod = creationMethod; + this.description = description; + } + + public String getCreationMethod() { + return creationMethod; + } + + public void setCreationMethod(String creationMethod) { + this.creationMethod = creationMethod; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + 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 new file mode 100644 index 0000000000..374cb9a3b3 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathName.java @@ -0,0 +1,136 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; + +import com.aventstack.extentreports.Status; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; +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.DeploymentArtifactPage; +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; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +public class PathName extends SetupCDTest { + + 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 + public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) { + makeDistributionValue = makeDistributionReadValue; + } + + //------------------------------------------Tests----------------------------------------------------- + + // Test#8 Jira issue 6168 + @Test + public void ValidateSameNameTest() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile); + reloginWithNewRole(UserRoleEnum.DESIGNER); + PathUtilities.createService(getUser()); + String firstPathName = PathUtilities.createPath("Oren",vspName); + PathUtilities.createPathWithoutLink(firstPathName,vspName); + try { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); + } catch (Exception e) { + throw new Exception("when creating another path with duplicate name, expected error did not appear"); + } + } + + // Test#9 Jira issue 6183 + @Test + public void ValidateEditName() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + 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); + } + + // Test#10 Jira issue 6411 + @Test + public void SpacesName() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile); + reloginWithNewRole(UserRoleEnum.DESIGNER); + PathUtilities.createService(getUser()); + PathUtilities.createPath(" ", vspName); + try { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); + } catch (Exception e) { + throw new Exception("service path name cannot be empty or spaces "); + } + } + + // Test#11 Jira issue 6186 + @Test + public void ValidateNameWithSpaces() throws Exception { + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); + String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile); + reloginWithNewRole(UserRoleEnum.DESIGNER); + PathUtilities.createService(getUser()); + PathValidations.validateNameWithSpaces("New", vspName); + } + + //////////////////////////////////////////////////////////////////////////////////////// + // flow methods // + //////////////////////////////////////////////////////////////////////////////////////// + + // workflow leading to path + 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 : "); + + DeploymentArtifactPage.clickSubmitForTestingButton(vspName); + SetupCDTest.getExtendTest().log(Status.INFO, "relogin as TESTER"); + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(vspName); + TesterOperationPage.certifyComponent(vspName); + return vspName; + } + + @Override + 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/PathUrls.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUrls.java new file mode 100644 index 0000000000..583540796c --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUrls.java @@ -0,0 +1,37 @@ +package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; + +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +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; + + // 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"; +} 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 new file mode 100644 index 0000000000..bfccbc44f8 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/AmdocsComplexService/PathUtilities.java @@ -0,0 +1,423 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; + +import com.aventstack.extentreports.Status; +import com.clearspring.analytics.util.Pair; +import com.google.gson.Gson; +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.enums.UserRoleEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum; +import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.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.HomePage; +import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; +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.Utils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; +import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; +import org.openecomp.sdc.ci.tests.verificator.VfVerificator; +import org.openqa.selenium.WebElement; +import org.testng.Assert; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.testng.AssertJUnit.assertEquals; + + +public class PathUtilities { + + public static void openPathList() throws Exception { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_MENU_BUTTON.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_BUTTON.getValue()); + } + + public static ServiceReqDetails createService(User user) throws Exception { + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, user); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + GeneralUIUtils.ultimateWait(); + return serviceMetadata; + } + + public static List <CanvasElement> linkVFs(String vspName, int linksNum)throws Exception { + CompositionPage.searchForElement(vspName); + GeneralUIUtils.ultimateWait(); + CanvasManager canvasManager = CanvasManager.getCanvasManager(); + GeneralUIUtils.ultimateWait(); + 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(); +// for(int a=0; a<3; a++) +// try { +// canvasManager.linkElements(VFs.get(i), CircleSize.VF, VFs.get(i - 1), CircleSize.VF); +// break; +// } catch (Exception ignore) {} + SetupCDTest.getExtendTest().log(Status.INFO, "link VFs"); + GeneralUIUtils.ultimateWait(); + } + return VFs; + } + + public static List <CanvasElement> linkServices(String Service1, String Service2, int linksNum)throws Exception { + 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(); +// for(int a=0; a<3; a++) +// try { +// canvasManager.linkElements(VFs.get(i), CircleSize.SERVICE, VFs.get(i-1), CircleSize.SERVICE); +// break; +// } catch (Exception ignore) {} + SetupCDTest.getExtendTest().log(Status.INFO, "link services"); + GeneralUIUtils.ultimateWait(); + + // change service to link + if (service.equals(Service2)) service = Service1; + else service = Service2; + } + return VFs; + } + + public static void openCreatePath() throws Exception{ + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_MENU_BUTTON.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_PATH_MENU_BUTTON.getValue()); + } + + public static void sendValue(String DataTestId, String value) throws Exception { + GeneralUIUtils.getWebElementByTestID(DataTestId).sendKeys(value); + GeneralUIUtils.ultimateWait(); + } + + public static void insertValues(String pathName, String pathProtocol, String pathPortNumbers) throws Exception { + sendValue(DataTestIdEnum.ComplexServiceAmdocs.PATH_NAME.getValue(),pathName); + sendValue(DataTestIdEnum.ComplexServiceAmdocs.PATH_PROTOCOL.getValue(),pathProtocol); + sendValue(DataTestIdEnum.ComplexServiceAmdocs.PATH_PORT_NUMBER.getValue(),pathPortNumbers); + GeneralUIUtils.ultimateWait(); + } + + public static void selectFirstLineParam() throws Exception{ + GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.LINK_SOURCE.getValue()+ "']//option").get(0).click(); + GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+ DataTestIdEnum.ComplexServiceAmdocs.LINK_SOURCE_CP.getValue()+"']//option").get(0).click(); + GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET.getValue()+"']//option").get(0).click(); + GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET_CP.getValue()+"']//option").get(0).click(); + } + + public static void editPathName(String pathName, String newName) throws Exception{ + GeneralUIUtils.findElementsByXpath("//*[text()='"+pathName+"']/parent::*//span").get(0).click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ComplexServiceAmdocs.PATH_NAME.getValue()).clear(); + sendValue(DataTestIdEnum.ComplexServiceAmdocs.PATH_NAME.getValue(), newName); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.SAVE.getValue()); + } + + public static void editPathProtocol(String pathName, String newProtocol) throws Exception{ + GeneralUIUtils.findElementsByXpath("//*[text()='"+pathName+"']/parent::*//span").get(0).click(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ComplexServiceAmdocs.PATH_PROTOCOL.getValue()).clear(); + sendValue(DataTestIdEnum.ComplexServiceAmdocs.PATH_PROTOCOL.getValue(), newProtocol); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.SAVE.getValue()); + } + + public static int deleteLines(int numOfLinesToDelete, int numOfLines)throws Exception{ + for (int i=0; i<numOfLinesToDelete; i++){ + GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.REMOVE_LINK.getValue()+"']//span").get(0).click(); + numOfLines--; + } + 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); + openCreatePath(); + insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); + selectFirstLineParam(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + SetupCDTest.getExtendTest().log(Status.INFO, "path" +pathName+" has been created"); + return pathName; + } + + public static void deleteComponents(List<CanvasElement> elements)throws Exception { + for(CanvasElement element: elements) + { + CanvasManager.getCanvasManager().clickOnCanvaElement(element); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.DELETE_COMPONENT.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); + } + } + + public static void updateVF(String vspName, VendorSoftwareProductObject vendorSoftwareProduct) throws Exception { + boolean vspFound = HomePage.searchForVSP(vspName); + if (vspFound){ + List<WebElement> elementsFromTable = HomePage.getElemenetsFromTable(); + elementsFromTable.get(1).click(); + GeneralUIUtils.waitForLoader(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.UPDATE_VSP.getValue()); + + OnboardingUiUtils.doCheckOut(); + + //Metadata verification + VfVerificator.verifyOnboardedVnfMetadata(vspName, vendorSoftwareProduct); + + 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); + } + + public static void waitUntilVnfCreated() { + GeneralUIUtils.clickOnElementByTestIdWithoutWait(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()); + GeneralUIUtils.waitForLoader(60*10); + GeneralUIUtils.waitForAngular(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue()); + } + + 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(){ + 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()); + } + + public static String createPathWithoutLink(String pathName, String vspName) throws Exception { + openCreatePath(); + insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); + selectFirstLineParam(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + SetupCDTest.getExtendTest().log(Status.INFO, "path" +pathName+" has been created"); + return pathName; + } + + // rest apis + 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]; + throw new Exception("service uuid not found in the url"); + } + + private static Map<String, String> prepareHeadersMap(String userId) { + Map<String, String> headersMap = new HashMap<String, String>(); + headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json"); + headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json"); + headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId); + return headersMap; + } + + public static Pair<RestResponse, ServiceReqDetails> getServiceIDByNameAndVersion(String serviceName, String version) throws Exception { + User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + + RestResponse restResponse = ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails, serviceName, version); + ServiceReqDetails service = new ServiceReqDetails(); + service.setName(serviceName); + service.setUniqueId(ResponseParser.getUniqueIdFromResponse(restResponse)); + service.setVersion(version); + + return new Pair<>(restResponse, service); + } + + 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()); + return restResponse; + } + + public static RestResponse getServiceAPI(User sdncUserDetails, ServiceReqDetails serviceDetails) throws Exception { + String serviceBaseVersion = "0.1"; + // choose user + // User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + + // create serviceDetails + // ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); + + // get service + RestResponse restResponse = ServiceRestUtils.getServiceByNameAndVersion(sdncUserDetails, serviceDetails.getName(), + serviceBaseVersion); + assertEquals("Check API response code for GetServiceAPI call", 200, restResponse.getErrorCode().intValue()); + + Service service = ResponseParser.convertServiceResponseToJavaObject(restResponse.getResponse()); + String uniqueId = service.getUniqueId(); + serviceDetails.setUniqueId(uniqueId); + // ServiceValidationUtils.validateServiceResponseMetaData(serviceDetails, service, sdncUserDetails, (LifecycleStateEnum) null); + return restResponse; + } + + public static RestResponse getServiceForwardingPathsAPI(String serviceName) throws Exception { + User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + + // get service + Pair<RestResponse, ServiceReqDetails> servicePaths = getServiceIDByNameAndVersion(serviceName, "0.1"); + + // set url + Config config = Utils.getConfig(); + String url = String.format( + PathUrls.SERVICE_FORWARDING_PATHS, + config.getCatalogBeHost(), + config.getCatalogBePort(), + servicePaths.right.getUniqueId() + ); + String userId = sdncUserDetails.getUserId(); + + Map<String, String> headersMap = prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse restResponse = http.httpSendGet(url, headersMap); + assertEquals("Check API response code for GetServiceForwardingPathsAPI call", 200, restResponse.getErrorCode().intValue()); + return restResponse; + } + + public static RestResponse getServicePathLinkMapAPI(String serviceName) throws Exception { + User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + + // get service + Pair<RestResponse, ServiceReqDetails> servicePaths = getServiceIDByNameAndVersion(serviceName, "0.1"); + + // set url + Config config = Utils.getConfig(); + String url = String.format( + PathUrls.SERVICE_PATH_LINK_MAP, + config.getCatalogBeHost(), + config.getCatalogBePort(), + servicePaths.right.getUniqueId() + ); + + String userId = sdncUserDetails.getUserId(); + + Map<String, String> headersMap = prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse restResponse = http.httpSendGet(url, headersMap); + assertEquals("Check API response code for GetServiceForwardingPathsAPI call", 200, restResponse.getErrorCode().intValue()); + return restResponse; + } + + public static Pair<RestResponse, ServiceReqDetails> getServicePathsAPI(String serviceName) throws Exception { + User sdncUserDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + // get service + Pair<RestResponse, ServiceReqDetails> servicePaths = getServiceIDByNameAndVersion(serviceName, "0.1"); + + // set url + Config config = Utils.getConfig(); + String url = String.format( + PathUrls.GET_SERVICE_PATHS, + config.getCatalogFeHost(), + config.getCatalogFePort(), + servicePaths.right.getUniqueId()); + + String userId = sdncUserDetails.getUserId(); + + Map<String, String> headersMap = prepareHeadersMap(userId); + + HttpRequest http = new HttpRequest(); + RestResponse restResponse = http.httpSendGet(url, headersMap); + assertEquals("Check API response code for GetServiceForwardingPathsAPI call", 200, restResponse.getErrorCode().intValue()); + return new Pair<>(restResponse, servicePaths.right); + } + + public static Pair<RestResponse, OnboardItemObject> createNewItemVersion(String itemId, String itemVersion, String description, User user) throws Exception { + Config config = Utils.getConfig(); + String url = String.format( + PathUrls.CREATE_NEW_ITEM_VERSION, + config.getCatalogBeHost(), + config.getCatalogBePort(), + itemId, itemVersion); + String userId = user.getUserId(); + OnboardItemObject onboardItemObject = new OnboardItemObject(); + + onboardItemObject.setCreationMethod("major"); + onboardItemObject.setDescription(description); + + Map<String, String> headersMap = prepareHeadersMap(userId); + HttpRequest http = new HttpRequest(); + Gson gson = new Gson(); + String body = gson.toJson(onboardItemObject); + + RestResponse response = http.httpSendPost(url, body, headersMap); + + onboardItemObject.setItemId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "id")); + onboardItemObject.setName(ResponseParser.getValueFromJsonResponse(response.getResponse(), "name")); + onboardItemObject.setBaseId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "baseId")); + onboardItemObject.setStatus(ResponseParser.getValueFromJsonResponse(response.getResponse(), "status")); + + return new Pair<>(response, onboardItemObject); + } + + public static RestResponse updateVendorSoftwareProduct(VendorSoftwareProductObject vendorSoftwareProductObject, User user) throws Exception { + Config config = Utils.getConfig(); + String url = String.format( + PathUrls.UPDATE_VENDOR_SOFTWARE_PRODUCT, + config.getCatalogBeHost(), + config.getCatalogBePort(), + vendorSoftwareProductObject.getVspId(), + vendorSoftwareProductObject.getComponentId()); + String userId = user.getUserId(); + VendorSoftwareProductObject updateVendorSoftwareProductObject = new VendorSoftwareProductObject(); + + updateVendorSoftwareProductObject.setName(vendorSoftwareProductObject.getName()); + updateVendorSoftwareProductObject.setDescription(vendorSoftwareProductObject.getDescription()); + updateVendorSoftwareProductObject.setCategory(vendorSoftwareProductObject.getCategory()); + updateVendorSoftwareProductObject.setSubCategory(vendorSoftwareProductObject.getSubCategory()); + updateVendorSoftwareProductObject.setVendorName(vendorSoftwareProductObject.getVendorName()); + updateVendorSoftwareProductObject.setVendorId(vendorSoftwareProductObject.getVendorId()); + updateVendorSoftwareProductObject.setIcon(vendorSoftwareProductObject.getIcon()); + updateVendorSoftwareProductObject.setLicensingData(vendorSoftwareProductObject.getLicensingData()); + updateVendorSoftwareProductObject.setLicensingVersion(vendorSoftwareProductObject.getLicensingVersion()); + + Map<String, String> headersMap = prepareHeadersMap(userId); + HttpRequest http = new HttpRequest(); + Gson gson = new Gson(); + String body = gson.toJson(updateVendorSoftwareProductObject); + + return http.httpSendPut(url, body, headersMap); + } + +} 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 42c45699f3..0e24bc43e0 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 @@ -1,23 +1,353 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.ci.tests.execute.AmdocsComplexService; -/** - * validation tests for future validations - */ +import com.aventstack.extentreports.Status; +import com.clearspring.analytics.util.Pair; +import org.apache.commons.lang.RandomStringUtils; +import org.json.JSONObject; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +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; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage; +import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +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.openqa.selenium.WebElement; + +import java.io.File; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.stream.Collectors; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotSame; -import java.util.ArrayList; public class PathValidations { - String name; - String destinationPortNumber; - String protocol; + public static String[] validateServiceExtendedPath(String vspName) throws Exception { + PathUtilities.linkVFs(vspName, 5); + PathUtilities.openCreatePath(); + String pathName = "name1"; + PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1"); + PathUtilities.selectFirstLineParam(); + PathValidations.extendPath(3); + //delete line + PathUtilities.deleteLines(1, 3); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + ExtentTestActions.log(Status.INFO, "path has been created"); + PathValidations.checkPathFilter(pathName, true); + GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.PATH_MENU_BUTTON.getValue() + "']/parent::*").get(0).click(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_BUTTON.getValue()); + String PathListName1 = GeneralUIUtils.findByText(pathName).getText(); + // edit path + 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(); + + // assert names changed + assertNotSame("path name expected to change after edit but did not", PathListName1, PathListName2); + + // delete path + int paths_before_deletion = GeneralUIUtils.findElementsByXpath("//*[text()='" + newPathName + "']/parent::*//span").size(); + GeneralUIUtils.findElementsByXpath(newPathName).get(1).click(); + GeneralUIUtils.ultimateWait(); + int paths_after_deletion = GeneralUIUtils.findElementsByXpath("//*[text()='" + newPathName + "']/parent::*//span").size(); + assertNotSame("path expected to be deleted but did not", paths_after_deletion, paths_before_deletion); + + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_CLOSE.getValue()); + 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}; + } + + public static String[] validateComplexExtendedPath(String[] services) throws Exception { + PathUtilities.linkServices(services[0], services[1], 5); + PathUtilities.openCreatePath(); + String pathName = "name1"; + PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers"); + PathUtilities.selectFirstLineParam(); + int numOfLines = 3; + PathValidations.extendPath(numOfLines); + //delete line + PathUtilities.deleteLines(1, numOfLines); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + ExtentTestActions.log(Status.INFO, "path has been created"); + 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.ultimateWait(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_BUTTON.getValue()); + String PathListName2 = GeneralUIUtils.findByText(newPathName).getText(); + + // assert names changed + assertNotSame("path name expected to change after edit but did not", PathListName1, PathListName2); + + // delete path + int paths_before_deletion = GeneralUIUtils.findElementsByXpath("//*[text()='" + newPathName + "']/parent::*//span").size(); + GeneralUIUtils.findElementsByXpath("//*[text()='" + newPathName + "']/parent::*//span").get(1).click(); + GeneralUIUtils.ultimateWait(); + + int paths_after_deletion = GeneralUIUtils.findElementsByXpath("//*[text()='" + newPathName + "']/parent::*//span").size(); + assertNotSame("path expected to be deleted but did not", paths_after_deletion, paths_before_deletion); + + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_CLOSE.getValue()); + PathValidations.validateServicePath(services[2], pathName); + PathValidations.validateServicePath(services[2], newPathName); + SetupCDTest.getExtendTest().log(Status.INFO, "Paths have been validated"); + return new String[] {pathName, newPathName}; + } + + public static void createPathNumOfRows(int numOfPathRows)throws Exception{ + PathUtilities.openCreatePath(); + PathUtilities.insertValues("extended" + RandomStringUtils.randomAlphanumeric(8),"pathProtocol1", "pathPortNumbers1"); + PathUtilities.selectFirstLineParam(); + extendPath(numOfPathRows); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()); + SetupCDTest.getExtendTest().log(Status.INFO, "Path with " + numOfPathRows + " rows has been created"); + } + + public static void extendPath(int numOfLines) throws Exception { + for (int i=0; i < numOfLines; i++) { + String check; + String index = Integer.toString(i + 2); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.EXTEND_BUTTON.getValue()); + + List<WebElement> linkSrcs = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_SOURCE.getValue()+"']//select"); + List<WebElement> linkSrcCPs = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_SOURCE_CP.getValue()+"']//select"); + List<WebElement> linkTargets = GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='"+DataTestIdEnum.ComplexServiceAmdocs.LINK_TARGET.getValue()+"']//select"); + List<WebElement> 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"); + validateElementDisabledAttribute(check, "Source connection point"); + } + for (int j = 0; j < i + 1; j++) { + check = linkTargets.get(j).getAttribute("class"); + validateElementDisabledAttribute(check, "Target"); + check = linkTargetCPs.get(j).getAttribute("class"); + validateElementDisabledAttribute(check, "Target connection point"); + } + List <WebElement> 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.get((new Random()).nextInt(choices.size())).click(); + } + } + + public static void validateElementDisabledAttribute(String check, String param) throws Exception{ + assertEquals(param + " of last lines should be disabled", check.contains("disabled"), true); + } + + public static void validateExtendedPathDisabledButtons(List<WebElement> linkSrcs, int i, String errMsg) throws Exception { + String check = linkSrcs.get(i).getAttribute("class"); + assertEquals(errMsg, check.contains("disabled"), true); + } + + public static void validatePathListIsEmpty() throws Exception { + PathUtilities.openPathList(); + try { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_DELETE.getValue()); + } + 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 ValidateAndDeletePathFromPathList(String pathName) throws Exception { + // count paths + List<WebElement> path_list_name = GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_NAME.getValue()); + // delete paths + List<WebElement> path_delete = GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_DELETE.getValue()); + int paths_before_deletion = 0; + for (int i = 0; i < path_list_name.size(); i++) { + if (path_list_name.get(i).getText().equals(pathName)) { + paths_before_deletion++; + path_delete.get(i).click(); + } + } + int paths_after_deletion = 0; + List<WebElement> path_list_name2; + try { + path_list_name2 = GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_NAME.getValue()); + for (WebElement path_list_element : path_list_name2) { + if (path_list_element.getText().equals(pathName)) { + paths_after_deletion++; + } + } + } 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<WebElement> 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); + } + SetupCDTest.getExtendTest().log(Status.INFO, "path list filter check passed"); + } + + public static void AssertCreatePath() throws Exception { + String check = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()).getAttribute("disabled"); + assertEquals("create button path should be disabled", check, "true"); + } + + public static void AssertCreatedPathExistInCompositionPage(String pathName) throws Exception { + checkPathFilter(pathName, true); + PathUtilities.openPathList(); + + // assert path is in the list + GeneralUIUtils.findByText(pathName).getText(); + GeneralUIUtils.ultimateWait(); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_CLOSE.getValue()); +// GeneralUIUtils.ultimateWait(); + SetupCDTest.getExtendTest().log(Status.INFO, "Path is in the path list"); +// GeneralUIUtils.ultimateWait(); + } + + public static void AssertExtendPath() throws Exception { + String check = GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.ComplexServiceAmdocs.EXTEND_BUTTON.getValue()).get(0).getAttribute("class"); + assertEquals("Extend button should be disabled", check, "disabled"); + } + + public static Pair<RestResponse, ServiceReqDetails> validateServicePath(String serviceName, String name) throws Exception { + Pair<RestResponse, ServiceReqDetails> servicePaths = PathUtilities.getServicePathsAPI(serviceName); + String response = servicePaths.left.getResponse(); + + JSONObject jsonResponse = new JSONObject(response); + JSONObject forwardingPaths = jsonResponse.getJSONObject("forwardingPaths"); + Boolean validation_complete = Boolean.FALSE; + 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"); + Boolean empty = pathElements.getBoolean("empty"); + assertEquals("assert pathElements are not empty", empty, Boolean.FALSE); + validation_complete = Boolean.TRUE; + break; + } + } + assertEquals("validation success", validation_complete, Boolean.TRUE); + return servicePaths; + } + + public static void ValidateThereIsNoErrorMessage() throws Exception { + try { + GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.OK.getValue() + "']"); + throw new Exception("element should not be found"); + } catch (Exception e) { + if (e.getMessage().equals("element should not be found")) { + throw e; + } + } + } + + public static void validateEditToExistingName(String firstPathName, String secondPathName)throws Exception { + PathUtilities.openPathList(); + PathUtilities.editPathName(secondPathName, firstPathName); + try { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); + } catch (Exception e) { + throw new Exception("when creating another path with duplicate name, expected error did not appear"); + } + PathUtilities.openPathList(); + PathUtilities.editPathName(secondPathName, firstPathName + " "); + try { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); + } catch (Exception e) { + 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); + try { + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue()); + } catch (Exception e) { + 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.editPathProtocol(secondPathName, "pathProtocol2"); + } + + public static void validateNameWithSpaces(String pathName, String vspName) throws Exception{ + PathUtilities.createPath(pathName + " ", vspName); + PathUtilities.openPathList(); + PathUtilities.editPathName(pathName, "newName"); + PathUtilities.createPathWithoutLink(" " + pathName, vspName); + PathUtilities.openPathList(); + PathUtilities.editPathName(pathName, "newName2"); + } - ArrayList<String> elements; + public static void importAndVerifyVSP(VendorSoftwareProductObject createVendorSoftwareProduct, String filepath, String vnfFile) throws Exception { + DownloadManager.downloadCsarByNameFromVSPRepository(createVendorSoftwareProduct.getName(), createVendorSoftwareProduct.getVspId()); + File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); - public void Ph(String parameter1 ) - { - elements = new ArrayList<String>(); - elements.add(parameter1); - elements.get(1); + OnboardingUiUtils.importVSP(createVendorSoftwareProduct); + + ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); + + // Verify deployment artifacts + Map<String, Object> combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(latestFilefromDir.getAbsolutePath()); + + LinkedList<HeatMetaFirstLevelDefinition> deploymentArtifacts = ((LinkedList<HeatMetaFirstLevelDefinition>) combinedMap.get("Deployment")); + ArtifactsCorrelationManager.addVNFartifactDetails(vnfFile, deploymentArtifacts); + + List<String> heatEnvFilesFromCSAR = deploymentArtifacts.stream().filter(e -> e.getType().equals("HEAT_ENV")). + map(e -> e.getFileName()). + collect(Collectors.toList()); + + OnboardingUiUtils.validateDeploymentArtifactsVersion(deploymentArtifacts, heatEnvFilesFromCSAR); + + DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, vnfFile); } + } 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 c612b66461..9ef7c83370 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 @@ -20,26 +20,20 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import java.io.IOException; -import java.util.List; - +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.Resource; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -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.ExtentTestActions; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.pages.AdminGeneralPage; -import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; import org.openecomp.sdc.ci.tests.utilities.AdminWorkspaceUIUtilies; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; 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; import org.openecomp.sdc.ci.tests.utils.rest.UserRestUtils; @@ -48,11 +42,11 @@ import org.openecomp.sdc.ci.tests.verificator.UserManagementVerificator; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.Assert; -import org.testng.SkipException; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import com.aventstack.extentreports.Status; +import java.io.IOException; +import java.util.List; public class AdminUserManagment extends SetupCDTest { @@ -105,12 +99,15 @@ public class AdminUserManagment extends SetupCDTest { ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.USER_ALREADY_EXIST); } + + // design changed and now one letter user should exist //TC922253 - @Test + @Test(enabled=false) public void createInvalidMacIdTest(){ if(true){ - throw new SkipException("Open bug 324032"); +// throw new SkipException("Open bug 324032"); + ExtentTestActions.log(Status.INFO, "Open bug 324032"); } String macId = generateValidMacId(); @@ -221,8 +218,9 @@ public class AdminUserManagment extends SetupCDTest { ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS); } - - @Test + + //obsolete test since no more start certification request + /*@Test public void modifyUserRoleWithTaskInHand_InTesting() throws Exception{ User newTesterUser = new User(); newTesterUser.setUserId(generateValidUserId()); @@ -234,6 +232,7 @@ public class AdminUserManagment extends SetupCDTest { 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."); @@ -246,7 +245,7 @@ public class AdminUserManagment extends SetupCDTest { AdminWorkspaceUIUtilies.updateUserRole(0, updatedUserRole); ErrorMessageUIVerificator.validateErrorMessage(ActionStatus.CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS); - } + }*/ private static String generateValidUserId() { 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 new file mode 100644 index 0000000000..371c41637e --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Annotation.java @@ -0,0 +1,60 @@ +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.DataTestIdEnum.ToscaArtifactsScreenEnum; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum; +import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum; +import org.openecomp.sdc.ci.tests.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.tosca.datatypes.ToscaDefinition; +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.ToscaParserUtils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.io.File; + +import static org.assertj.core.api.Assertions.assertThat; + +public class Annotation extends SetupCDTest { + private String filePath; + + @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."); + } + + + 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 new file mode 100644 index 0000000000..8840557e5f --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ArchiveRestoreTest.java @@ -0,0 +1,197 @@ +package org.openecomp.sdc.ci.tests.execute.sanity; + +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.Service; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.datatypes.*; +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.testng.annotations.Test; + +import static org.testng.AssertJUnit.assertTrue; + +public class ArchiveRestoreTest extends SetupCDTest { + + private User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + + + @Test + public void updateVSP_WhenVF_Archived() throws Throwable { + + String vnfFile1 = "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip"; + String vnfFile2 = "2-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0_Added2TestParameters.zip"; + +// 1. Import VSP v1.0 + String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath(); + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails); + 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, this.sdncDesignerDetails, amdocsLicenseMembers, null); +// 2. Create VF from VSP, 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")); +// 3. Create Service add to it the certified VF and certify the Service v1.0 + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service")); +// 4. archive VF(1.0) + GeneralPageElements.clickArchivedButtonFromCatalog(resource.getName()); +// 5. service certification should send error message - unable to certify, service contains archived resource via UI + HomeUtils.findComponentAndClick(service.getName()); + GeneralPageElements.clickSubmitForTestingButtonErrorCase(service.getName()); +// 6. Update VSP to v2.0 - onboard level + getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2); + VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails, filePath, vnfFile2); + getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: ", vnfFile2)); + VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails); +// 7. Update the VF from VSP when it archived and restore - via UI + getExtendTest().log(Status.INFO, String.format("Going to update VF %s with VSP v2.0", resourceReqDetails.getName())); + CompositionPage.moveToHomeScreen(); + HomePage.showVspRepository(); + OnboardingUiUtils.updateVSP(vendorSoftwareProductObject, true); +// 8. Certify and update restored VF from with VSP v2.0 + GeneralPageElements.clickCertifyButton(resource.getName()); +// 9. Update the Service with the VFi version 2.0 and certify + HomeUtils.findComponentAndClick(service.getName()); + 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 + @Test + public void certifyVF_WhenVSP_Archived() throws Exception { + + String vnfFile1 = "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip"; + +// 1. Import VSP v1.0 + String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath(); + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails); + 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, this.sdncDesignerDetails, amdocsLicenseMembers, null); +// 2. Create VF from VSP, 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")); +// 3. Archive VSP (onboarding page-Amdocs side) + getExtendTest().log(Status.INFO, String.format("Going to archive component OB side: %s", resource.getName())); + VendorSoftwareProductRestUtils.archiveVendorSoftwareProduct(vendorSoftwareProductObject, sdncDesignerDetails); + getExtendTest().log(Status.INFO, String.format("Succeed to archive component %s, OB side", resource.getName())); +// 4. chekout resource and check that VF is archived + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + HomeUtils.findComponentAndClick(resource.getName()); + GeneralPageElements.clickCheckoutButton(); + resource = AtomicOperationUtils.getResourceObject(resource.getUniqueId()); + getExtendTest().log(Status.INFO, String.format("Going to validate is VSP archived: %s", resource.getName())); + assertTrue("Validate isVspArchived flag, expected: true, but was: " + resource.isVspArchived(), resource.isVspArchived().equals(true)); + String expectedText = "VSP is archived"; + getExtendTest().log(Status.INFO, String.format("Going to validate text box message, expected: %s", expectedText)); + String actualElementText = GeneralPageElements.getWebElementTextByTestId(DataTestIdEnum.ResourceMetadataEnum.SELECT_VSP.getValue()); + assertTrue("Validate text box message, expected: [" + expectedText + "], but was: " + actualElementText, actualElementText.equals(expectedText)); +// 5. certify new resource - should fail, via API + getExtendTest().log(Status.INFO, String.format("Going to certify archived on OB side resource %s , expected failure certification", resource.getName())); + GeneralPageElements.clickCertifyButtonNoUpgradePopupDismissErrorCase(resource.getName()); +// 6. restore + getExtendTest().log(Status.INFO, String.format("Going to restore component OB side: %s", resource.getName())); + VendorSoftwareProductRestUtils.restoreVendorSoftwareProduct(vendorSoftwareProductObject, sdncDesignerDetails); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Succeed to restore component %s, OB side", resource.getName())); +// 7. certify - should pass + getExtendTest().log(Status.INFO, String.format("Going to certify resource %s ", resource.getName())); + GeneralPageElements.clickCertifyButtonNoUpgradePopupDismiss(resource.getName()); + resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "2.0"); + assertTrue("Validate isVspArchived flag, expected: false, but was: " + resource.isVspArchived(), resource.isVspArchived().equals(false)); + } + + @Test + public void distributeServiceIncludedArchivedResource() throws Exception { + + String vnfFile1 = "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip"; +// 1. Import VSP v1.0 + String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath(); + AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails); + 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, this.sdncDesignerDetails, amdocsLicenseMembers, null); +// 2. Create VF from VSP, certify - v1.0 is created + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName())); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + getExtendTest().log(Status.INFO, String.format("Certify the VF")); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); +// 3. Create Service add to it the certified VF and certify the Service v1.0 + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); + Either<ComponentInstance, RestResponse> 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(); + + reloginWithNewRole(UserRoleEnum.GOVERNOR); + GeneralUIUtils.findComponentAndClick(service.getName()); + GovernorOperationPage.approveSerivce(service.getName()); +// 4. archive VF(1.0) + reloginWithNewRole(UserRoleEnum.DESIGNER); + GeneralPageElements.clickArchivedButtonFromCatalog(resource.getName()); +// 5. Distribute service - should pass + reloginWithNewRole(UserRoleEnum.OPS); + GeneralUIUtils.findComponentAndClick(service.getName()); + OpsOperationPage.distributeService(); + + } + + + @Test + public void certificationOfArchivedCR() throws Exception { + + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.CR, getUser()); + ResourceUIUtils.createCR(resourceReqDetails, sdncDesignerDetails); + GeneralPageElements.clickCertifyButtonNoUpgradePopupDismiss(resourceReqDetails.getName()); + GeneralUIUtils.ultimateWait(); + Resource resource = (Resource) AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceReqDetails.getName(), "1.0"); +// 1. Create Service add to it the certified CR and certify the Service v1.0 + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName())); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + getExtendTest().log(Status.INFO, String.format("Adding CR instance to Service")); +// 2. archive CR(1.0) + GeneralPageElements.clickArchivedButtonFromCatalog(resource.getName()); +// 3. service certification should send error message - unable to certify, service contains archived resource via UI + HomeUtils.findComponentAndClick(service.getName()); + GeneralPageElements.clickSubmitForTestingButtonErrorCase(service.getName()); +// 4. restore CR + GeneralPageElements.restoreComponentFromArchivedCatalog(resource.getName()); +// 5. Certify and update restored CR(v2.0) + GeneralPageElements.clickCheckoutButton(); + GeneralPageElements.clickCertifyButton(resource.getName()); +// 6. Update the Service with the CRi version 2.0 and certify service + HomeUtils.findComponentAndClick(service.getName()); + GeneralPageElements.clickSubmitForTestingButton(service.getName()); + } + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } +} 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 cd73dfba4f..c1c9406cb6 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 @@ -120,10 +120,9 @@ public class CatalogLeftPanelTest extends SetupCDTest{ 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); @@ -143,7 +142,7 @@ public class CatalogLeftPanelTest extends SetupCDTest{ 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()); } @@ -152,13 +151,13 @@ public class CatalogLeftPanelTest extends SetupCDTest{ CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE); - WebElement categorieCheckbox = CatalogUIUtilitis.clickOnUpperCategoryCheckbox(); + WebElement categoryCheckbox = CatalogUIUtilitis.clickOnUpperCategoryCheckbox(); - CatalogVerificator.validateCategory(categorieCheckbox.getAttribute("textContent").trim()); + CatalogVerificator.validateCategory(categoryCheckbox.getAttribute("textContent").trim()); } @Test - public void filterByGenericDtabaseSubCategory() throws Exception{ + public void filterByGenericDatabaseSubCategory() throws Exception{ CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE); @@ -179,7 +178,7 @@ public class CatalogLeftPanelTest extends SetupCDTest{ CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); List<WebElement> cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); - assertTrue(String.format("Wrong element name, Exepected : %s , Actual: %s", serviceMetadata.getName(), firstElementName), serviceMetadata.getName().equals(firstElementName)); + assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", serviceMetadata.getName(), firstElementName), serviceMetadata.getName().equals(firstElementName)); } @Test(priority = 17) @@ -192,7 +191,7 @@ public class CatalogLeftPanelTest extends SetupCDTest{ CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); List<WebElement> cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue()); String firstElementName = cardElements.get(0).getAttribute("textContent").trim(); - assertTrue(String.format("Wrong element name, Exepected : %s , Actual: %s", vfMetaData.getName(), firstElementName), vfMetaData.getName().equals(firstElementName)); + assertTrue(String.format("Wrong element name, Expected : %s , Actual: %s", vfMetaData.getName(), firstElementName), vfMetaData.getName().equals(firstElementName)); } @Test(priority = 5) @@ -200,14 +199,33 @@ public class CatalogLeftPanelTest extends SetupCDTest{ // create resource ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); ResourceUIUtils.createVF(vfMetaData, getUser()); - ResourceGeneralPage.clickCheckinButton(vfMetaData.getName()); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); - GeneralUIUtils.findComponentAndClickInCatalog(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); + CatalogUIUtilitis.catalogSearchBox(resourceMetadata.getName()); + GeneralUIUtils.findComponentAndClick(resourceMetadata.getName()); + + GeneralUIUtils.clickOnBrowserBackButton(); + + int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader(); + assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 1, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 1 ); + + List<WebElement> 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; 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 new file mode 100644 index 0000000000..dda6dd438f --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTestWithTime.java @@ -0,0 +1,282 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.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.DataTestIdEnum.CatalogPageLeftPanelSubCategoryCheckbox; +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.utils.Utils; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.verificator.CatalogVerificator; +import org.openqa.selenium.WebElement; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +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][]; + + 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; + 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 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"); + //Filter by type + actualTestRunTime = Utils.getAndValidateActionDuration(() -> { + try { + CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf(catalogType)); + } 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(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<LifeCycleStateEnum> 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); + //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 + //Validate number of elements after filtering + CatalogVerificator.validateStatus(lifecycleStates, statusCheckbox.name()); + } + + @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"); + //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()); + } + + @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); + 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)); + //Filter by sub category + actualTestRunTime = Utils.getAndValidateActionDuration(() -> { + try { + GeneralUIUtils.clickOnAreaJS(checkboxElement); + } catch (Exception e) { + e.printStackTrace(); + } + }, 400); + 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<WebElement> 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<WebElement> 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()); + } + + @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(); + + int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader(); + assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 1, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 1 ); + + List<WebElement> 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; + } + +} 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 5d1dfea5c1..6bbe9c8fdc 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 @@ -20,9 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import java.util.List; -import java.util.stream.Collectors; - import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.category.CategoryDefinition; @@ -41,6 +38,9 @@ import org.openqa.selenium.WebElement; import org.testng.Assert; import org.testng.annotations.Test; +import java.util.List; +import java.util.stream.Collectors; + public class Categories extends SetupCDTest { @@ -50,7 +50,7 @@ public class Categories extends SetupCDTest { AdminGeneralPage.selectCategoryManagmetTab(); String newResourceCategory = ElementFactory.getDefaultCategory().getName(); AdminGeneralPage.createNewResourceCategory(newResourceCategory); - GeneralUIUtils.clickSomewhereOnPage(); +// GeneralUIUtils.clickSomewhereOnPage(); List<WebElement> resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); List<String> collect = resourceCategoriesList.stream().map(f -> f.getText()).collect(Collectors.toList()); collect.contains(newResourceCategory); @@ -64,7 +64,7 @@ public class Categories extends SetupCDTest { AdminGeneralPage.selectCategoryManagmetTab(); String newserviceCategory = ElementFactory.getDefaultCategory().getName(); AdminGeneralPage.createNewServiceCategory(newserviceCategory); - GeneralUIUtils.clickSomewhereOnPage(); +// GeneralUIUtils.clickSomewhereOnPage(); List<WebElement> serviceCategoriesList = AdminGeneralPage.getServiceCategoriesList(); List<String> collect = serviceCategoriesList.stream().map(f -> f.getText()).collect(Collectors.toList()); collect.contains(newserviceCategory); @@ -85,9 +85,7 @@ public class Categories extends SetupCDTest { List<WebElement> resourceCategoriesList = AdminGeneralPage.getResourceCategoriesList(); AdminGeneralPage.addSubCategoryToResource(resourceCategoriesList, newResourceCategory , newSubCategory); GeneralUIUtils.waitForLoader(); - GeneralUIUtils.clickSomewhereOnPage(); - - +// GeneralUIUtils.clickSomewhereOnPage(); } @@ -113,7 +111,7 @@ public class Categories extends SetupCDTest { String newserviceCategory = ElementFactory.getDefaultCategory().getName(); AdminGeneralPage.createNewServiceCategory(newserviceCategory); AdminGeneralPage.createNewServiceCategory(newserviceCategory); - AdminGeneralPage.selectUserManagmetTab(); +// AdminGeneralPage.selectUserManagmetTab(); String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS.name()); 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 7dd3279644..cecda509a1 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 @@ -20,33 +20,16 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import java.util.ArrayList; -import java.util.List; - +import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; -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.*; 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.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.pages.TesterOperationPage; -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.pages.*; +import org.openecomp.sdc.ci.tests.utilities.*; 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; @@ -56,7 +39,8 @@ import org.testng.AssertJUnit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.aventstack.extentreports.Status; +import java.util.ArrayList; +import java.util.List; public class CustomizationUUID extends SetupCDTest { @@ -77,13 +61,13 @@ public class CustomizationUUID extends SetupCDTest { public void uniqueCustomizationUUIDforeachVFi() throws Exception { - ResourceReqDetails vfMetaData = createNewResourceWithArtifactSubmitForTesting(); + ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); - reloginWithNewRole(UserRoleEnum.TESTER); + /* reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); TesterOperationPage.certifyComponent(vfMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ List customizationUUIDs = new ArrayList<String>(); ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); @@ -126,13 +110,13 @@ public class CustomizationUUID extends SetupCDTest { public void uniqueCustomizationUUIDafterArtifactCRUDofVFi() throws Exception { - ResourceReqDetails vfMetaData = createNewResourceWithArtifactSubmitForTesting(); + ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); TesterOperationPage.certifyComponent(vfMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ List customizationUUIDs = new ArrayList<>(); ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); @@ -175,7 +159,7 @@ public class CustomizationUUID extends SetupCDTest { 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); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + GeneralPageElements.clickOKButton(); ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName()); @@ -192,13 +176,13 @@ public class CustomizationUUID extends SetupCDTest { public void uniqueCustomizationUUIDchangeVFiVersion() throws Exception { - ResourceReqDetails vfMetaData = createNewResourceWithArtifactSubmitForTesting(); + ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); TesterOperationPage.certifyComponent(vfMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ List customizationUUIDs = new ArrayList<>(); ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); @@ -217,11 +201,12 @@ public class CustomizationUUID extends SetupCDTest { HomePage.navigateToHomePage(); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); ResourceGeneralPage.clickCheckoutButton(); - ResourceGeneralPage.clickSubmitForTestingButton(vfMetaData.getName()); - reloginWithNewRole(UserRoleEnum.TESTER); + //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); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ //update VFI version @@ -244,13 +229,13 @@ public class CustomizationUUID extends SetupCDTest { public void uniqueCustomizationUUIDaddRelation() throws Exception { - ResourceReqDetails vfMetaData = createNewResourceWithArtifactSubmitForTesting(); + ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState(); - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); TesterOperationPage.certifyComponent(vfMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ List customizationUUIDs = new ArrayList<>(); ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); @@ -269,20 +254,21 @@ public class CustomizationUUID extends SetupCDTest { HomePage.navigateToHomePage(); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); ResourceGeneralPage.clickCheckoutButton(); - ResourceGeneralPage.clickSubmitForTestingButton(vfMetaData.getName()); - reloginWithNewRole(UserRoleEnum.TESTER); + //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); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ //update VFI version canvasManager = findServiceAndNavigateToCanvas(serviceMetadata); ServiceGeneralPage.clickCheckoutButton(); canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(NormativeTypesEnum.PORT.getFolderName()); - CanvasElement portElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.PORT); - canvasManager.linkElements(portElement, VFiElement1); +// CompositionPage.searchForElement(NormativeTypesEnum.PORT.getFolderName()); + CanvasElement contrailPortElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.CONTRAIL_PORT); + canvasManager.linkElements(contrailPortElement, VFiElement1); canvasManager.clickOnCanvaElement(VFiElement1); @@ -305,13 +291,13 @@ public class CustomizationUUID extends SetupCDTest { return canvasManager; } - public ResourceReqDetails createNewResourceWithArtifactSubmitForTesting() throws Exception { + public ResourceReqDetails createNewResourceWithArtifactCertifyState() throws Exception { ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); ResourceUIUtils.createVF(vfMetaData, getUser()); ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>(); + List<ArtifactInfo> 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) { @@ -336,9 +322,9 @@ public class CustomizationUUID extends SetupCDTest { CompositionPage.searchForElement(NormativeTypesEnum.COMPUTE.name()); CanvasManager canvasManagerVF = CanvasManager.getCanvasManager(); CanvasElement VFiElement1 = canvasManagerVF.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE); - - - ResourceGeneralPage.clickSubmitForTestingButton(vfMetaData.getName()); + + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); return vfMetaData; } 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 38a71f4a20..52dd381216 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 @@ -20,12 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import static org.testng.Assert.assertTrue; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; @@ -45,7 +40,11 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import com.aventstack.extentreports.Status; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.testng.Assert.assertTrue; public class DeploymentViewTests extends SetupCDTest { 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 ad8347fbbe..b1740b455a 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 @@ -20,48 +20,20 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +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.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.*; 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.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.enums.*; 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.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.TesterOperationPage; -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.pages.*; +import org.openecomp.sdc.ci.tests.utilities.*; 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; @@ -71,11 +43,12 @@ import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.Assert; -import org.testng.SkipException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.aventstack.extentreports.Status; +import java.util.*; + +import static org.testng.AssertJUnit.assertTrue; public class ImportDCAE extends SetupCDTest { @@ -117,13 +90,14 @@ public class ImportDCAE extends SetupCDTest { try{ ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName()); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); TesterOperationPage.certifyComponent(atomicResourceMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ ResourceReqDetails resourceMetaData = createDCAEAsset(); DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); @@ -150,7 +124,7 @@ public class ImportDCAE extends SetupCDTest { createDCAEAsset(); ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>(); + List<ArtifactInfo> 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) { @@ -200,7 +174,8 @@ public class ImportDCAE extends SetupCDTest { 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"); +// 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"; @@ -246,30 +221,32 @@ public class ImportDCAE extends SetupCDTest { try{ atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName()); + //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()); - - CompositionPage.clickSubmitForTestingButton(vfMetaData.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(); - - reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); - TesterOperationPage.certifyComponent(atomicResourceMetaData.getName()); + ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.clickCheckoutButton(); ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfMetaData.setVersion("0.2"); vfCanvasManager = CanvasManager.getCanvasManager(); CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "1.0"); @@ -282,7 +259,7 @@ public class ImportDCAE extends SetupCDTest { } } - + // future removed from ui @Test(enabled = false) public void addUpdateDeleteSimplePropertiesToDCAEAssetTest() throws Exception{ @@ -353,12 +330,16 @@ public class ImportDCAE extends SetupCDTest { public void addAllInformationalArtifactPlaceholdersInDCAEAssetTest() throws Exception{ createDCAEAsset(); ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - + int fileNameCounter = 0; + String fileName; for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){ - ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, filePath,"asc_heat 0 2.yaml", informArtifact.getValue()); + fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; + ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, + FileHandling.getFilePath("uniqueFileNames"),fileName, informArtifact.getValue()); + fileNameCounter++; } - assertTrue(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)); + assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue(); } @Test @@ -373,8 +354,9 @@ public class ImportDCAE extends SetupCDTest { String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); } - - ToscaArtifactsPage.clickSubmitForTestingButton(vfMetaData.getName()); + //TODO Andrey should click on certify button + ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName()); + vfMetaData.setVersion("1.0"); VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser()); } @@ -386,16 +368,17 @@ public class ImportDCAE extends SetupCDTest { ResourceGeneralPage.clickCheckinButton(vfName); GeneralUIUtils.findComponentAndClick(vfName); - ResourceGeneralPage.clickSubmitForTestingButton(vfName); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(vfName); - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfName); - TesterOperationPage.certifyComponent(vfName); + TesterOperationPage.certifyComponent(vfName);*/ vfMetaData.setVersion("1.0"); VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - reloginWithNewRole(UserRoleEnum.DESIGNER); + /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ GeneralUIUtils.findComponentAndClick(vfName); VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); } @@ -490,14 +473,14 @@ public class ImportDCAE extends SetupCDTest { 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()); - ResourceGeneralPage.clickSubmitForTestingButton(vfMetaData.getName()); - - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); TesterOperationPage.certifyComponent(vfMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); ResourceGeneralPage.clickCheckoutButton(); @@ -542,7 +525,8 @@ public class ImportDCAE extends SetupCDTest { ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName()); + //TODO Andrey changed to click on checkIn button + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); ResourceReqDetails vfMetaData = createDCAEAsset(); DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); @@ -550,7 +534,8 @@ public class ImportDCAE extends SetupCDTest { CompositionPage.addElementToCanvasScreen(atomicResourceMetaData.getName(), canvasManager); try{ - CompositionPage.clickSubmitForTestingButton(vfMetaData.getName()); + //TODO Andrey should click on certify button + CompositionPage.clickCertifyButton(vfMetaData.getName()); assert(false); } catch(Exception e){ @@ -658,7 +643,7 @@ public class ImportDCAE extends SetupCDTest { } public ResourceReqDetails createDCAEAsset() throws Exception{ - String fileName2 = SERVICE_INPUT_TEST_VF2_CSAR; + 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"); 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 9ed8ba5029..8a5667457d 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 @@ -20,12 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +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; @@ -39,34 +34,29 @@ 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.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.TesterOperationPage; -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.pages.*; +import org.openecomp.sdc.ci.tests.utilities.*; 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; -import org.openecomp.sdc.ci.tests.verificator.VFCverificator; import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.testng.Assert; -import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.testng.AssertJUnit.assertTrue; + +@Test(singleThreaded=true) public class ImportVFCAsset extends SetupCDTest { private ResourceReqDetails atomicResourceMetaData; - private String filePath; + @BeforeClass public void beforeClass(){ filePath = FileHandling.getFilePath(""); @@ -177,7 +167,7 @@ public class ImportVFCAsset extends SetupCDTest { } @Test - public void addUpdateDeletePlaceholdersInformationalArtefactVFCTest() throws Exception{ + public void addUpdateDeletePlaceholdersInformationalArtifactVFCTest() throws Exception{ String fileName = "importVFC_VFC7.yml"; atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); @@ -193,7 +183,8 @@ public class ImportVFCAsset extends SetupCDTest { InformationalArtifactPage.clickAddNewArtifact(); ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact); } - assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(informationalArtifactList.size())); + assertThat(InformationalArtifactPage.checkElementsCountInTable(informationalArtifactList.size())). + as("Check that artifact table contains artifacts uploaded").isTrue(); // update artifact description String newDescription = "new description"; @@ -201,7 +192,7 @@ public class ImportVFCAsset extends SetupCDTest { InformationalArtifactPage.artifactPopup().insertDescription(newDescription); InformationalArtifactPage.artifactPopup().clickDoneButton(); String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifactList.get(0).getArtifactLabel()); - assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription)); + assertThat(actualArtifactDescription).as("Check artifact description update").isEqualTo(newDescription); // delete artifacts for (ArtifactInfo informationalArtifact : informationalArtifactList) { @@ -209,13 +200,18 @@ public class ImportVFCAsset extends SetupCDTest { InformationalArtifactPage.clickOK(); } - assertTrue("not all artifacts is deleted", InformationalArtifactPage.checkElementsCountInTable(0)); - + assertThat(InformationalArtifactPage.checkElementsCountInTable(0)). + as("Check that all artifacts were deleted").isTrue(); + // fill placeholders + int fileNameCounter = 0; for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){ - ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, filePath,"asc_heat 0 2.yaml", informArtifact.getValue()); + fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; + ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, FileHandling.getFilePath("uniqueFileNames"), + fileName, informArtifact.getValue()); + fileNameCounter++; } - InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length); + assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue(); } @Test @@ -302,16 +298,17 @@ public class ImportVFCAsset extends SetupCDTest { ResourceGeneralPage.clickCheckinButton(vfName); GeneralUIUtils.findComponentAndClick(vfName); - ResourceGeneralPage.clickSubmitForTestingButton(vfName); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(vfName); - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfName); - TesterOperationPage.certifyComponent(vfName); + TesterOperationPage.certifyComponent(vfName);*/ atomicResourceMetaData.setVersion("1.0"); VfVerificator.verifyVFLifecycle(atomicResourceMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - reloginWithNewRole(UserRoleEnum.DESIGNER); + /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ GeneralUIUtils.findComponentAndClick(vfName); VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); } 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 bf2bda906c..579bfb8b10 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 @@ -22,7 +22,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; -import com.clearspring.analytics.util.Pair; import fj.data.Either; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; @@ -42,7 +41,6 @@ import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import java.awt.*; import java.sql.Timestamp; import java.util.List; @@ -96,9 +94,8 @@ public class OnboardViaApis{ boolean skipReport = true; AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1); ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, sdncDesignerDetails1, amdocsLicenseMembers); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, sdncDesignerDetails1, amdocsLicenseMembers); // VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct); - VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); @@ -121,11 +118,10 @@ public class OnboardViaApis{ System.out.println(distributeAndValidateService); } - public Service runOnboardViaApisOnly(ServiceReqDetails serviceReqDetails, ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception, AWTException { + public Service runOnboardViaApisOnly(ServiceReqDetails serviceReqDetails, ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception { - Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filepath, vnfFile, sdncDesignerDetails1); - VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; - vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left); + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filepath, vnfFile, sdncDesignerDetails1); + vendorSoftwareProductObject.setName(vendorSoftwareProductObject.getName()); resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); 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 837f834ffa..f2bb7b1e54 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 @@ -1,22 +1,25 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; -import com.clearspring.analytics.util.Pair; import fj.data.Either; import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders; -import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; +import org.openecomp.sdc.ci.tests.datatypes.*; 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; 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.GeneralPageElements; +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.rest.ResourceRestUtils; +import org.openecomp.sdc.ci.tests.verificator.CatalogVerificator; +import org.testng.Assert; import org.testng.annotations.Test; import java.io.File; @@ -200,6 +203,59 @@ public class OnboardingFlowsThroughAPI extends SetupCDTest{ 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 + { + // External Defect: 430425 +// Import VSP v1.0 + List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure(); + List<String> 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); + +// 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()); + AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + +// 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 = VendorSoftwareProductRestUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject, amdocsLicenseMembers, sdncDesignerDetails1); + VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1); + + //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 ); + + //Update VF with the new VSP version + GeneralUIUtils.findComponentAndClick(origVspName); + GeneralPageElements.clickCheckoutButton(); + GeneralPageElements.clickBrowseButton(); + OnboardingUiUtils.updateVSP(vendorSoftwareProductObject); + + + //Validate that VF name in v1.1 is not changed to new VSP name (it is required to keep the name if at least one certification was done) + Assert.assertTrue(origVspName.equals(ResourceGeneralPage.getNameText())); + + //Validate that VF name in v1.0 is the old VF name + GeneralPageElements.selectVersion("V1.0"); + Assert.assertTrue(origVspName.equals(ResourceGeneralPage.getNameText())); + } @Test() public void UpdateVSPRevertToEarlierVersion() throws Throwable @@ -337,9 +393,8 @@ public class OnboardingFlowsThroughAPI extends SetupCDTest{ 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)); - Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers); // VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct); - VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; // 2. Create VF, certify - v1.0 is created resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); @@ -372,9 +427,8 @@ public class OnboardingFlowsThroughAPI extends SetupCDTest{ 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)); - Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1, amdocsLicenseMembers); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1, amdocsLicenseMembers); // VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile1, createVendorSoftwareProduct); - VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; // 2. Create VF, certify - v1.0 is created resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); 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 b2314af267..1a14410266 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 @@ -21,7 +21,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; -import com.clearspring.analytics.util.Pair; import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders; import org.openecomp.sdc.ci.tests.datatypes.*; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; @@ -57,304 +56,281 @@ import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertTrue; public class OnboardingFlowsUI extends SetupCDTest { - - protected static String filePath = FileHandling.getVnfRepositoryPath(); - protected String makeDistributionValue; - - @Parameters({ "makeDistribution" }) - @BeforeMethod - public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) { - makeDistributionValue = makeDistributionReadValue; - } - - @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); - runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); - } - - @Test - public void performanceTest() throws Throwable { - System.out.println("Start test"); - Long actualTestRunTime = Utils.getActionDuration(() -> { - try { - onboardVNFTestSanityOneFile(); - } catch (Throwable throwable) { - throwable.printStackTrace(); - } - }); - Long regularTestRunTime = 400L; - double factor = 1.5; - assertTrue("Expected test run time should be less from " + regularTestRunTime*factor + ", actual time is " + actualTestRunTime , regularTestRunTime*factor>actualTestRunTime); - } - - @Test - public void onboardVNFTestSanity() throws Throwable { - List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileList(); - String vnfFile = fileNamesFromFolder.get(0).toString(); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); - } - - - 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() - + " and service category: " + serviceMetadata.getCategory()); - String vspName = onboardAndCertify(resourceReqDetails, filePath, vnfFile); - - reloginWithNewRole(UserRoleEnum.DESIGNER); - // create service + + protected static String filePath = FileHandling.getVnfRepositoryPath(); + protected String makeDistributionValue; + + @Parameters({"makeDistribution"}) + @BeforeMethod + public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) { + makeDistributionValue = makeDistributionReadValue; + } + + @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); + runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); + } + + @Test + public void performanceTest() throws Throwable { + System.out.println("Start test"); + Long actualTestRunTime = Utils.getActionDuration(() -> { + try { + onboardVNFTestSanityOneFile(); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + }); + Long regularTestRunTime = 400L; + double factor = 1.5; + assertTrue("Expected test run time should be less from " + regularTestRunTime * factor + ", actual time is " + actualTestRunTime, regularTestRunTime * factor > actualTestRunTime); + } + + @Test + public void onboardVNFTestSanity() throws Throwable { + List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileList(); + String vnfFile = fileNamesFromFolder.get(0).toString(); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); + } + + + 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() + + " and service category: " + serviceMetadata.getCategory()); + String vspName = onboardAndCertify(resourceReqDetails, filePath, vnfFile); + + //TODO Andrey check return window after certification + /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ + // create service // ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); + ServiceUIUtils.createService(serviceMetadata, getUser()); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CompositionPage.searchForElement(vspName); - CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager(); - CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vspName); - 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.getLeftMenu().moveToCompositionScreen(); + CompositionPage.searchForElement(vspName); + CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vspName); + ArtifactsCorrelationManager.addVNFtoServiceArtifactCorrelation(serviceMetadata.getName(), vspName); - ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + assertNotNull(vfElement); + ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser()); + ExtentTestActions.addScreenshot(Status.INFO, "ServiceComposition_" + vnfFile, "The service topology is as follows: "); - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - TesterOperationPage.certifyComponent(serviceMetadata.getName()); + ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - reloginWithNewRole(UserRoleEnum.GOVERNOR); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - GovernorOperationPage.approveSerivce(serviceMetadata.getName()); + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + TesterOperationPage.certifyComponent(serviceMetadata.getName()); - if (makeDistributionValue.equals("true")){ - - - reloginWithNewRole(UserRoleEnum.OPS); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - OpsOperationPage.distributeService(); - OpsOperationPage.displayMonitor(); + reloginWithNewRole(UserRoleEnum.GOVERNOR); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + GovernorOperationPage.approveSerivce(serviceMetadata.getName()); - List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable(); - AssertJUnit.assertEquals(1, rowsFromMonitorTable.size()); + if (makeDistributionValue.equals("true")) { - OpsOperationPage.waitUntilArtifactsDistributed(0); - -// validateInputArtsVSouput(serviceMetadata.getName()); - } - - getExtendTest().log(Status.INFO, String.format("The onboarding %s test is passed ! ", vnfFile)); - } + reloginWithNewRole(UserRoleEnum.OPS); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + OpsOperationPage.distributeService(); + OpsOperationPage.displayMonitor(); - public String onboardAndCertify(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception { - Pair<String, VendorSoftwareProductObject> onboardAndValidate = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser()); - String vspName = onboardAndValidate.left; - - DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen(); - ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile ,"The topology template for " + vnfFile + " is as follows : "); - - DeploymentArtifactPage.clickSubmitForTestingButton(vspName); - - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vspName); - TesterOperationPage.certifyComponent(vspName); - return vspName; - } - - - @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List") - public void onboardVNFTest(String filePath, String vnfFile) throws Throwable { - setLog(vnfFile); - System.out.println("printttttttttttttt - >" + makeDistributionValue); - ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource(); - ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService(); - runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); - } - - @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List") - public void onboardVNFShotFlow(String filePath, String vnfFile) throws Throwable { - setLog(vnfFile); - System.out.println("printttttttttttttt - >" + makeDistributionValue); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - onboardAndCertify(resourceReqDetails, filePath, vnfFile); - } - - @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") - public void onboardRandomVNFsTest(String filePath, String vnfFile) throws Throwable { - setLog(vnfFile); - System.out.println("printttttttttttttt - >" + makeDistributionValue); - System.out.println("Vnf File name is: " + vnfFile); - ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource(); - ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService(); - runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); - } - - - @Test - public void onboardUpdateVNFTest() throws Throwable { -// Object[] fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filePath); - List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filePath); -// String vnfFile = fileNamesFromFolder[0].toString(); - String vnfFile = fileNamesFromFolder.get(0); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser()); - String vspName = vsp.left; - ResourceGeneralPage.clickSubmitForTestingButton(vspName); - - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vspName); - TesterOperationPage.certifyComponent(vspName); - - reloginWithNewRole(UserRoleEnum.DESIGNER); - // 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()); - - HomePage.navigateToHomePage(); - - ///update flow -// String updatedVnfFile = fileNamesFromFolder[1].toString(); - String updatedVnfFile = fileNamesFromFolder.get(1); + List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable(); + AssertJUnit.assertEquals(1, rowsFromMonitorTable.size()); - getExtendTest().log(Status.INFO, String.format("Going to update the VNF with %s......", updatedVnfFile)); - // update VendorSoftwareProduct - OnboardingUiUtils.updateVnfAndValidate(filePath, vsp, updatedVnfFile, getUser()); - - ResourceGeneralPage.clickSubmitForTestingButton(vspName); + OpsOperationPage.waitUntilArtifactsDistributed(0); - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vspName); - TesterOperationPage.certifyComponent(vspName); +// validateInputArtsVSouput(serviceMetadata.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); - - // replace exiting VFI in service with new updated - - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - serviceCanvasManager = CanvasManager.getCanvasManager(); - CompositionPage.changeComponentVersion(serviceCanvasManager, vfElement, "2.0"); - ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser()); + } - ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + getExtendTest().log(Status.INFO, String.format("The onboarding %s test is passed ! ", vnfFile)); + } + + public String onboardAndCertify(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception { + VendorSoftwareProductObject onboardAndValidate = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser()); + String vspName = onboardAndValidate.getName(); - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - TesterOperationPage.certifyComponent(serviceMetadata.getName()); + DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen(); + ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile, "The topology template for " + vnfFile + " is as follows : "); - reloginWithNewRole(UserRoleEnum.GOVERNOR); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - GovernorOperationPage.approveSerivce(serviceMetadata.getName()); - + DeploymentArtifactPage.clickCertifyButton(vspName); + return vspName; + } - - reloginWithNewRole(UserRoleEnum.OPS); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - OpsOperationPage.distributeService(); - OpsOperationPage.displayMonitor(); - - List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable(); - AssertJUnit.assertEquals(1, rowsFromMonitorTable.size()); - - OpsOperationPage.waitUntilArtifactsDistributed(0); - - - getExtendTest().log(Status.INFO, String.format("Onboarding %s test is passed ! ", vnfFile)); - - - } - @Test - public void threeVMMSCsInServiceTest() throws Exception{ + @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List") + public void onboardVNFTest(String filePath, String vnfFile) throws Throwable { + setLog(vnfFile); + System.out.println("printttttttttttttt - >" + makeDistributionValue); + ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource(); + ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService(); + runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); + } - String pathFile = FileHandling.getFilePath("VmmscArtifacts"); - List<String> vmmscList = Arrays.asList(new File(pathFile).list()).stream().filter(e -> e.contains("vmmsc") && e.endsWith(".zip")).collect(Collectors.toList()); - assertTrue("Did not find vMMSCs", vmmscList.size() > 0); - - Map<String, String> vspNames = new HashMap<>(); - for (String vnfFile : vmmscList){ - 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); - Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, pathFile, getUser(), amdocsLicenseMembers); - - 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(); - DeploymentArtifactPage.verifyArtifactsExistInTable(pathFile, vnfFile); - - String vspName = createVendorSoftwareProduct.left; - DeploymentArtifactPage.clickSubmitForTestingButton(vspName); - - vspNames.put(vnfFile, vspName); - } + @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List") + public void onboardVNFShotFlow(String filePath, String vnfFile) throws Throwable { + setLog(vnfFile); + System.out.println("printttttttttttttt - >" + makeDistributionValue); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + onboardAndCertify(resourceReqDetails, filePath, vnfFile); + } + + @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") + public void onboardRandomVNFsTest(String filePath, String vnfFile) throws Throwable { + setLog(vnfFile); + System.out.println("printttttttttttttt - >" + makeDistributionValue); + System.out.println("Vnf File name is: " + vnfFile); + ResourceReqDetails resourceReqDetails = ElementFactory.getRandomCategoryResource(); + ServiceReqDetails serviceReqDetails = ElementFactory.getRandomCategoryService(); + runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile); + } + + + @Test + public void onboardUpdateVNFTest() throws Throwable { + List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filePath); + String vnfFile = fileNamesFromFolder.get(0); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser()); + String vspName = vsp.getName(); + ResourceGeneralPage.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()); + + HomePage.navigateToHomePage(); + + ///update flow + String updatedVnfFile = fileNamesFromFolder.get(1); + + getExtendTest().log(Status.INFO, String.format("Going to update the VNF with %s......", updatedVnfFile)); + // update VendorSoftwareProduct + OnboardingUiUtils.updateVnfAndValidate(filePath, vsp, updatedVnfFile, getUser()); + ResourceGeneralPage.clickCertifyButton(vspName); + + // replace exiting VFI in service with new updated + + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + serviceCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(serviceCanvasManager, vfElement, "2.0"); + ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", 1, getUser()); + + ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + TesterOperationPage.certifyComponent(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.GOVERNOR); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + GovernorOperationPage.approveSerivce(serviceMetadata.getName()); + + + reloginWithNewRole(UserRoleEnum.OPS); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + OpsOperationPage.distributeService(); + OpsOperationPage.displayMonitor(); + + List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable(); + AssertJUnit.assertEquals(1, rowsFromMonitorTable.size()); + + OpsOperationPage.waitUntilArtifactsDistributed(0); + getExtendTest().log(Status.INFO, String.format("Onboarding %s test is passed ! ", vnfFile)); + } + + + @Test + public void threeVMMSCsInServiceTest() throws Exception { + + String pathFile = FileHandling.getFilePath("VmmscArtifacts"); + List<String> vmmscList = Arrays.asList(new File(pathFile).list()).stream().filter(e -> e.contains("vmmsc") && e.endsWith(".zip")).collect(Collectors.toList()); + assertTrue("Did not find vMMSCs", vmmscList.size() > 0); + + Map<String, String> vspNames = new HashMap<>(); + for (String vnfFile : vmmscList) { + 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, pathFile, getUser(), amdocsLicenseMembers); + + 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(); + DeploymentArtifactPage.verifyArtifactsExistInTable(pathFile, vnfFile); + + String vspName = createVendorSoftwareProduct.getName(); + DeploymentArtifactPage.clickCertifyButton(vspName); + vspNames.put(vnfFile, vspName); + } - reloginWithNewRole(UserRoleEnum.TESTER); + /* reloginWithNewRole(UserRoleEnum.TESTER); for (String vsp : vspNames.values()){ GeneralUIUtils.findComponentAndClick(vsp); TesterOperationPage.certifyComponent(vsp); } - reloginWithNewRole(UserRoleEnum.DESIGNER); - // create service - ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); - ServiceUIUtils.createService(serviceMetadata, getUser()); - ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager(); - - for (String vsp : vspNames.values()){ - CompositionPage.searchForElement(vsp); - CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vsp); - assertNotNull(vfElement); - } - ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", vspNames.values().size(), getUser()); - File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Info_" + getExtendTest().getModel().getName()); - final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); - SetupCDTest.getExtendTest().log(Status.INFO, "Three kinds of vMMSC are in canvas now." + getExtendTest().addScreenCaptureFromPath(absolutePath)); - - ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); - - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - TesterOperationPage.certifyComponent(serviceMetadata.getName()); - - reloginWithNewRole(UserRoleEnum.GOVERNOR); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - GovernorOperationPage.approveSerivce(serviceMetadata.getName()); - - reloginWithNewRole(UserRoleEnum.OPS); - GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); - OpsOperationPage.distributeService(); - OpsOperationPage.displayMonitor(); - - List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable(); - AssertJUnit.assertEquals(1, rowsFromMonitorTable.size()); - - OpsOperationPage.waitUntilArtifactsDistributed(0); - - } - - - @Override - protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; - } + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ + // create service + ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); + ServiceUIUtils.createService(serviceMetadata, getUser()); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager serviceCanvasManager = CanvasManager.getCanvasManager(); + + for (String vsp : vspNames.values()) { + CompositionPage.searchForElement(vsp); + CanvasElement vfElement = serviceCanvasManager.createElementOnCanvas(vsp); + assertNotNull(vfElement); + } + ServiceVerificator.verifyNumOfComponentInstances(serviceMetadata, "0.1", vspNames.values().size(), getUser()); + File imageFilePath = GeneralUIUtils.takeScreenshot(null, SetupCDTest.getScreenshotFolder(), "Info_" + getExtendTest().getModel().getName()); + final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath(); + SetupCDTest.getExtendTest().log(Status.INFO, "Three kinds of vMMSC are in canvas now." + getExtendTest().addScreenCaptureFromPath(absolutePath)); + + ServiceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.TESTER); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + TesterOperationPage.certifyComponent(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.GOVERNOR); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + GovernorOperationPage.approveSerivce(serviceMetadata.getName()); + + reloginWithNewRole(UserRoleEnum.OPS); + GeneralUIUtils.findComponentAndClick(serviceMetadata.getName()); + OpsOperationPage.distributeService(); + OpsOperationPage.displayMonitor(); + + List<WebElement> rowsFromMonitorTable = OpsOperationPage.getRowsFromMonitorTable(); + AssertJUnit.assertEquals(1, rowsFromMonitorTable.size()); + + OpsOperationPage.waitUntilArtifactsDistributed(0); + + } + + + @Override + protected UserRoleEnum getRole() { + return UserRoleEnum.DESIGNER; + } } 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 fa55a1e66d..835206e62f 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 @@ -5,7 +5,11 @@ 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.enums.*; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems; +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.*; @@ -16,7 +20,6 @@ import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.AssertJUnit; -import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -92,7 +95,8 @@ public class PNF extends SetupCDTest { 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"); +// 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"; @@ -140,7 +144,8 @@ public class PNF extends SetupCDTest { try{ atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName()); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser()); ResourceUIUtils.createPNF(pnfMetaData, getUser()); @@ -148,22 +153,21 @@ public class PNF extends SetupCDTest { vfCanvasManager = CanvasManager.getCanvasManager(); CompositionPage.searchForElement(atomicResourceMetaData.getName()); cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - - - CompositionPage.clickSubmitForTestingButton(pnfMetaData.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); + + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); TesterOperationPage.certifyComponent(atomicResourceMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); vfCanvasManager = CanvasManager.getCanvasManager(); @@ -191,8 +195,9 @@ public class PNF extends SetupCDTest { String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); } - - ToscaArtifactsPage.clickSubmitForTestingButton(pnfMetaData.getName()); + //TODO Andrey should click on certify button + ToscaArtifactsPage.clickCertifyButton(pnfMetaData.getName()); + pnfMetaData.setVersion("1.0"); VfVerificator.verifyToscaArtifactsInfo(pnfMetaData, getUser()); } @@ -204,16 +209,17 @@ public class PNF extends SetupCDTest { ResourceGeneralPage.clickCheckinButton(vfName); GeneralUIUtils.findComponentAndClick(vfName); - ResourceGeneralPage.clickSubmitForTestingButton(vfName); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(vfName); - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(vfName); - TesterOperationPage.certifyComponent(vfName); + TesterOperationPage.certifyComponent(vfName);*/ pnfMetaData.setVersion("1.0"); VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - reloginWithNewRole(UserRoleEnum.DESIGNER); + /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ GeneralUIUtils.findComponentAndClick(vfName); VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); } @@ -256,14 +262,14 @@ public class PNF extends SetupCDTest { 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()); - ResourceGeneralPage.clickSubmitForTestingButton(pnfMetaData.getName()); - - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); TesterOperationPage.certifyComponent(pnfMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ GeneralUIUtils.findComponentAndClick(pnfMetaData.getName()); ResourceGeneralPage.clickCheckoutButton(); @@ -294,15 +300,16 @@ public class PNF extends SetupCDTest { ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); String pnfName = pnfMetaData.getName(); - ResourceGeneralPage.clickSubmitForTestingButton(pnfName); - reloginWithNewRole(UserRoleEnum.TESTER); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(pnfName); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(pnfName); - TesterOperationPage.certifyComponent(pnfName); + TesterOperationPage.certifyComponent(pnfName);*/ pnfMetaData.setVersion("1.0"); VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - reloginWithNewRole(UserRoleEnum.DESIGNER); + /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/ CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf("PNF")); SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating resource %s found", pnfName)); @@ -319,26 +326,26 @@ public class PNF extends SetupCDTest { vfCanvasManager.createElementOnCanvas("ContrailPort"); String pnfName = pnfMetaData.getName(); - ResourceGeneralPage.clickSubmitForTestingButton(pnfName); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(pnfName); - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(pnfName); - TesterOperationPage.certifyComponent(pnfName); + TesterOperationPage.certifyComponent(pnfName);*/ pnfMetaData.setVersion("1.0"); VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - reloginWithNewRole(UserRoleEnum.DESIGNER); + /*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); - CompositionPage.searchForElement("Network"); - CanvasElement networkElement = canvasManager.createElementOnCanvas("Network"); + CanvasElement networkElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.CONTRAIL_VIRTUAL_NETWORK); - canvasManager.linkElements(pnfElement, CircleSize.VF, networkElement, CircleSize.NORMATIVE); + canvasManager.linkElements(pnfElement, networkElement); String serviceName = serviceMetadata.getName(); ServiceGeneralPage.clickSubmitForTestingButton(serviceName); reloginWithNewRole(UserRoleEnum.TESTER); @@ -358,7 +365,7 @@ public class PNF extends SetupCDTest { public void checkInfomationArtifactUploadLimitation() throws Exception { ResourceReqDetails pnfMetaData = createPNFWithGenerateName(); ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen(); - List<WebElement> webElements = GeneralUIUtils.getWebElementsListBy(By.xpath("//button[@class='add-button ng-scope']")); + List<WebElement> 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"); 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 ef957c6e32..cdf2416139 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 @@ -1,12 +1,10 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; -import org.apache.commons.lang3.tuple.ImmutablePair; 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.enums.CircleSize; 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; @@ -23,7 +21,6 @@ import org.openecomp.sdc.ci.tests.utils.general.FileHandling; import org.openecomp.sdc.ci.tests.verificator.PortMirroringVerificator; import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator; import org.testng.AssertJUnit; -import org.testng.SkipException; import org.testng.annotations.Test; import java.io.File; @@ -34,7 +31,7 @@ public class PortMirroring extends SetupCDTest { @Test public void createPortMirroringConfigurationServiceProxy() throws Throwable { - PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(); + PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false); ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails(); CanvasManager canvasManager = portMirrioringConfigurationObject.getCanvasManager(); CanvasElement serviceElementVmmeSourceName = portMirrioringConfigurationObject.getServiceElementVmmeSourceName(); @@ -55,7 +52,7 @@ public class PortMirroring extends SetupCDTest { @Test public void distributePortMirroringConfigurationServiceProxy() throws Throwable { - PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(); + PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false); ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails(); Service service = portMirrioringConfigurationObject.getService(); @@ -124,9 +121,7 @@ public class PortMirroring extends SetupCDTest { PortMirroringEnum.PMCP_SOURCE_CAP.getValue()); canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSource, - CircleSize.SERVICE, portMirroringConfigurationByPolicyElement, - CircleSize.NORMATIVE, connectionWizardPopUpObjectVMME); serviceReqDetails.setVersion("0.1"); @@ -139,7 +134,8 @@ public class PortMirroring extends SetupCDTest { 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"); +// 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"); } canvasManager.clickOnCanvaElement(portMirroringConfigurationByPolicyElement); @@ -180,28 +176,22 @@ public class PortMirroring extends SetupCDTest { CompositionPage.searchForElement(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue()); CanvasElement portMirroringConfigurationByPolicyElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue()); - ImmutablePair<Integer, Integer> linkLocation = canvasManager.calcMidOfLink(serviceElementVmmeSource.getLocation(), portMirroringConfigurationByPolicyElement.getLocation()); - ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME = new ConnectionWizardPopUpObject("", "", PortMirroringEnum.PM_REQ_TYPE.getValue(), PortMirroringEnum.PMCP_SOURCE_CAP.getValue()); canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSource, - CircleSize.SERVICE, portMirroringConfigurationByPolicyElement, - CircleSize.NORMATIVE, connectionWizardPopUpObjectVMME); - CanvasElement linkBetweenPMCP_VMME = new CanvasElement("Link", linkLocation); - serviceReqDetails.setVersion("0.1"); getExtendTest().log(Status.INFO, "Validating link between elements was created"); ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 1); - canvasManager.openLinkPopupReqsCapsConnection(linkBetweenPMCP_VMME); + canvasManager.openLinkPopupReqsCapsConnection(serviceElementVmmeSource, portMirroringConfigurationByPolicyElement); canvasManager.closeLinkPopupReqsCapsConnection(); - canvasManager.deleteLinkPopupReqsCapsConnection(linkBetweenPMCP_VMME); + canvasManager.deleteLinkPopupReqsCapsConnection(serviceElementVmmeSource, portMirroringConfigurationByPolicyElement); getExtendTest().log(Status.INFO, "Validating link deleted"); ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 0); @@ -267,9 +257,10 @@ 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"); +// 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()); PortMirroringVerificator.validateElementName(PortMirroringEnum.PMCP_NEWNAME.getValue()); } @@ -294,15 +285,16 @@ 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"); +// GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionRightPanel.DELETE_ITEM.getValue()); +// GeneralUIUtils.clickOnElementByTestId("OK"); + canvasManager.deleteElementFromCanvas(portMirroringConfigurationByPolicyElement); PortMirroringVerificator.validateElementName(service.getName()); } @Test public void createPortMirroringConfigurationMulipleInstances() throws Throwable { - PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(); + PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false); ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails(); CanvasElement serviceElementVmmeSourceName = portMirrioringConfigurationObject.getServiceElementVmmeSourceName(); @@ -321,16 +313,19 @@ 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.PMC1_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, CircleSize.SERVICE, portMirroringConfigurationElement, - CircleSize.NORMATIVE, connectionWizardPopUpObjectVMME); + canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName,portMirroringConfigurationElement, + connectionWizardPopUpObjectVMME); getExtendTest().log(Status.INFO, "Connect VMME to PMC again"); - canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, CircleSize.SERVICE, portMirroringConfigurationElement, - CircleSize.NORMATIVE, connectionWizardPopUpObjectVMME); + canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationElement, + connectionWizardPopUpObjectVMME); getExtendTest().log(Status.INFO, "Validating 4 links between elements exist"); ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 4); @@ -345,12 +340,12 @@ public class PortMirroring extends SetupCDTest { PortMirroringEnum.PMCP_SOURCE_CAP.getValue()); getExtendTest().log(Status.INFO, "Connect VMME to PMCP again"); - canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, CircleSize.SERVICE, portMirroringConfigurationByPolicyElement, - CircleSize.NORMATIVE, connectionWizardPopUpObjectVMME_PMCP); + canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationByPolicyElement, + connectionWizardPopUpObjectVMME_PMCP); getExtendTest().log(Status.INFO, "Connect VMME to PMCP again"); - canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, CircleSize.SERVICE, portMirroringConfigurationByPolicyElement, - CircleSize.NORMATIVE, connectionWizardPopUpObjectVMME_PMCP); + canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationByPolicyElement, + connectionWizardPopUpObjectVMME_PMCP); serviceReqDetails.setVersion("0.1"); getExtendTest().log(Status.INFO, "Validating 6 links between elements exist"); @@ -360,7 +355,7 @@ public class PortMirroring extends SetupCDTest { @Test public void downloadArtifactFromPMCService() throws Throwable { //Scenario of bug 362271 - PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(); + PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false); ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails(); GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); @@ -387,7 +382,7 @@ public class PortMirroring extends SetupCDTest { @Test public void checkoutMirroringConfigurationServiceProxyAndDeletePMC() throws Throwable { - PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(); + PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false); ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails(); Service service = portMirrioringConfigurationObject.getService(); CanvasElement portMirroringConfigurationElement = portMirrioringConfigurationObject.getPortMirroringConfigurationElement(); @@ -409,10 +404,12 @@ public class PortMirroring extends SetupCDTest { ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); CanvasManager canvasManager = CanvasManager.getCanvasManager(); GeneralUIUtils.ultimateWait(); - canvasManager.clickOnCanvasPosition(portMirroringConfigurationElement.getLocation().getLeft(), portMirroringConfigurationElement.getLocation().getRight()); +// 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"); +// GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionRightPanel.DELETE_ITEM.getValue()); +// GeneralUIUtils.clickOnElementByTestId("OK"); + canvasManager.deleteElementFromCanvas(portMirroringConfigurationElement); PortMirroringVerificator.validateElementName(service.getName()); getExtendTest().log(Status.INFO, "Validating 0 links after delete the port mirroring element"); @@ -431,7 +428,7 @@ public class PortMirroring extends SetupCDTest { @Test public void updatePortMirroringServiceInstance() throws Throwable { - PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(); + PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false); Service service = portMirrioringConfigurationObject.getService(); CanvasElement vmmeCanvasElement = portMirrioringConfigurationObject.getServiceElementVmmeSourceName(); @@ -490,26 +487,20 @@ public class PortMirroring extends SetupCDTest { CompositionPage.searchForElement(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue()); CanvasElement portMirroringConfigurationByPolicyElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue()); - ImmutablePair<Integer, Integer> linkLocation = canvasManager.calcMidOfLink(serviceElementVmmeSource.getLocation(), portMirroringConfigurationByPolicyElement.getLocation()); - ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME = new ConnectionWizardPopUpObject("", "", PortMirroringEnum.PM_REQ_TYPE.getValue(), PortMirroringEnum.PMCP_SOURCE_CAP.getValue()); canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSource, - CircleSize.SERVICE, portMirroringConfigurationByPolicyElement, - CircleSize.NORMATIVE, connectionWizardPopUpObjectVMME); - CanvasElement linkBetweenPMCP_VMME = new CanvasElement("Link", linkLocation); - serviceReqDetails.setVersion("0.1"); getExtendTest().log(Status.INFO, "Validating link between elements was created"); ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 1); - canvasManager.openLinkPopupReqsCapsConnection(linkBetweenPMCP_VMME); + 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()); @@ -518,13 +509,13 @@ public class PortMirroring extends SetupCDTest { 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"); - } +// 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. - canvasManager.openLinkPopupReqsCapsConnection(linkBetweenPMCP_VMME); + canvasManager.openLinkPopupReqsCapsConnection(serviceElementVmmeSource, portMirroringConfigurationByPolicyElement); PortMirroringVerificator.validateLinkProperties(); } @@ -533,7 +524,7 @@ public class PortMirroring extends SetupCDTest { public void restorePortMirroringServiceLink() throws Throwable { //Scenario is taken from bug 361475 - Second Scenario - PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(); + PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false); ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails(); Service service = portMirrioringConfigurationObject.getService(); CanvasElement vmmeCanvasElement = portMirrioringConfigurationObject.getServiceElementVmmeSourceName(); @@ -566,7 +557,7 @@ public class PortMirroring extends SetupCDTest { @Test public void restoreServiceVersionOnContainerService() throws Throwable { //Scenario is taken from bug 361475 - First Scenario - PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(); + PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false); ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails(); Service service = portMirrioringConfigurationObject.getService(); CanvasElement vmmeCanvasElement = portMirrioringConfigurationObject.getServiceElementVmmeSourceName(); @@ -587,7 +578,8 @@ public class PortMirroring extends SetupCDTest { ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); CanvasManager canvasManager = CanvasManager.getCanvasManager(); - canvasManager.linkElements(vmmeCanvasElement, CircleSize.SERVICE, vprobeCanvasElement, CircleSize.SERVICE); +// 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); 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 ae7d4770ba..06da130b94 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 @@ -20,8 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import static org.testng.Assert.assertTrue; - +import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; @@ -29,8 +28,7 @@ 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.PropertiesAssignmentPage; -import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +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.ResourceUIUtils; @@ -41,13 +39,12 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.aventstack.extentreports.Status; - public class PropertiesAssignment extends SetupCDTest { private static String filePath; private static String csarFile = "PCRF_OS_FIXED.csar"; + private static String csarFile1 = "437285.csar"; @BeforeClass public void beforeClass(){ @@ -61,16 +58,16 @@ public class PropertiesAssignment extends SetupCDTest { } - + //VF - Simple Properties Tests @Test public void declareAndDeleteInputVfTest() throws Exception { -// ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); -// ResourceUIUtils.createResource(vfMetaData, getUser()); String csarTestFile = csarFile; - String componentName = "abstract_pcm"; - String propertyName = "min_instances"; - +// String componentName = "abstract_pcm"; + 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()); @@ -80,6 +77,7 @@ public class PropertiesAssignment extends SetupCDTest { PropertiesAssignmentPage.clickOnComponentInComposition(componentName); PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); PropertiesAssignmentPage.clickOnDeclareButton(); + GeneralUIUtils.ultimateWait(); AssertJUnit.assertTrue(PropertiesAssignmentPage.isPropertyChecked(propertyName)); PropertiesAssignmentPage.clickOnInputTab(); @@ -92,12 +90,465 @@ public class PropertiesAssignment extends SetupCDTest { } + + + @Test + public void editAndSaveSimplePropertyValueTest() throws Exception { + + String csarTestFile = csarFile; + String componentName = "abstract_psm"; + String propertyNameString = PropertyNameBuilder.buildSimpleField("nfc_function"); + String propertyNameInt = PropertyNameBuilder.buildSimpleField("index_value"); + String propertyValueString = "abc"; + String propertyValueInt = "123"; + + //Create VF + 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()); + + //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(); + + //Verify that properties values are saved + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyValueInt); + } + + @Test + public void editAndSaveBooleanPropertyValueTest() throws Exception { + + String csarTestFile = csarFile; + String componentName = "oam_volume_0"; + String propertyNameTrue = "value-prop-read_only"; + String propertyValueTrue = "TRUE"; + String propertyNameFalse = "value-prop-delete_on_termination"; + String propertyValueFalse = "FALSE"; + + //Create VF + 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()); + + //Navigate to Properties Assignment screen, edit simple properties values and save from a dialog + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.selectBooleanPropertyValue(propertyNameTrue, propertyValueTrue); + PropertiesAssignmentPage.selectBooleanPropertyValue(propertyNameFalse, propertyValueFalse); + PropertiesAssignmentPage.clickOnSaveButton(); + + //Verify that properties values are saved + ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen(); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentVerificator.validateBooleanPropertyValue(propertyNameTrue,propertyValueTrue); + PropertiesAssignmentVerificator.validateBooleanPropertyValue(propertyNameFalse,propertyValueFalse); + } + + @Test + public void editAndSavePopupPropertyValueTest() throws Exception { +// Internal bug 391466 +// Popup Property: value editing is done in a popup text field, opened by clicking Edit button +// Example: subnetpoolid property + + String csarTestFile = csarFile1; + String componentName = "abstract_cif"; + String propertyName = "port_cif_imsli_port_subnetpoolid"; + String propertyValue = "updated by designer"; + + //Create VF + 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()); + + //Navigate to Properties Assignment screen, edit popup property value and save + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnEditButton(propertyName); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), propertyValue); + PropertiesAssignmentPage.clickOnSetButton(); + 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); + + } + + + @Test + public void editAndDiscardSimplePropertyValueTest() throws Exception { + + String csarTestFile = csarFile; + String componentName = "abstract_psm"; + String propertyNameString = "value-prop-nfc_function"; + String propertyNameInt = "value-prop-index_value"; + String propertyValueString = "abc"; + String propertyValueInt = "123"; + String propertyOrigValueString = ""; + String propertyOrigValueInt = "0"; + + //Create VF + 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()); + + //Navigate to Properties Assignment screen, edit simple properties values and discard changes + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.editPropertyValue(propertyNameString, propertyValueString); + PropertiesAssignmentPage.editPropertyValue(propertyNameInt, propertyValueInt); + PropertiesAssignmentPage.clickOnDiscardButton(); + + //Verify that properties values are not saved + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyOrigValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyOrigValueInt); + } + + @Test + public void editAndSaveSimplePropertyFromDialogTest() throws Exception { + + String csarTestFile = csarFile; + String componentName = "abstract_psm"; + String propertyNameString = "value-prop-nfc_function"; + String propertyNameInt = "value-prop-index_value"; + String propertyValueString = "abc"; + String propertyValueInt = "123"; + + //Create VF + 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()); + + //Navigate to Properties Assignment screen, edit simple properties values and save from a dialog + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.editPropertyValue(propertyNameString, propertyValueString); + PropertiesAssignmentPage.editPropertyValue(propertyNameInt, propertyValueInt); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.clickOnDialogCancelButton(); + + //Verify that properties values are not removed + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyValueInt); + + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.clickOnDialogSaveButton(); + + //Verify that properties values are saved + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyValueInt); + } + + + @Test + public void editAndDiscardSimplePropertyFromDialogTest() throws Exception { + + String csarTestFile = csarFile; + String componentName = "abstract_psm"; + String propertyNameString = "value-prop-nfc_function"; + String propertyNameInt = "value-prop-index_value"; + String propertyValueString = "abc"; + String propertyValueInt = "123"; + String propertyOrigValueString = ""; + String propertyOrigValueInt = "0"; + + //Create VF + 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()); + + //Navigate to Properties Assignment screen, edit simple properties values and save from a dialog + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.editPropertyValue(propertyNameString, propertyValueString); + PropertiesAssignmentPage.editPropertyValue(propertyNameInt, propertyValueInt); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.clickOnDialogCancelButton(); + + ///Verify that properties values are not removed + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyValueInt); + + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.clickOnDialogDiscardButton(); + + //Verify that properties values are saved + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyOrigValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameInt,propertyOrigValueInt); + } + + + @Test + public void editAndSaveInputValueTest() throws Exception { + + String csarTestFile = csarFile; + String componentName = "abstract_psm"; + String propertyNameString = "value-input-nf_type"; + String propertyNameFloat = "value-input-pcm_volume_size_0"; + String propertyNameBoolean = "value-input-multi_stage_design"; + String propertyValueString = "POLICY"; + String propertyValueFloat = "80.1"; + String propertyValueBoolean = "TRUE"; + + //Create VF + 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()); + + //Navigate to Properties Assignment screen - Inputs + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnInputTab(); + + //Verify that Save button is disabled when inserting invalid value into Input field + PropertiesAssignmentPage.editPropertyValue(propertyNameFloat, propertyValueString); + AssertJUnit.assertTrue(PropertiesAssignmentPage.isButtonDisabled(DataTestIdEnum.PropertiesAssignmentScreen.SAVE_BUTTON.getValue())); + + //Insert valid values for different Input types and save + PropertiesAssignmentPage.editPropertyValue(propertyNameFloat, propertyValueFloat); + PropertiesAssignmentPage.editPropertyValue(propertyNameString, propertyValueString); + PropertiesAssignmentPage.selectBooleanPropertyValue(propertyNameBoolean, propertyValueBoolean); + PropertiesAssignmentPage.clickOnSaveButton(); + + //Verify that input values are saved after changing VF version + ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName()); + GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); + GeneralPageElements.clickCheckoutButton(); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameString,propertyValueString); + PropertiesAssignmentVerificator.validatePropertyValue(propertyNameFloat,propertyValueFloat); + PropertiesAssignmentVerificator.validateBooleanPropertyValue(propertyNameBoolean,propertyValueBoolean); + } + + //VF - List and Map Properties Tests + + @Test + public void editAndSaveListPropertyValueTest() throws Exception { + + String csarTestFile = csarFile; + String componentName = "abstract_pps"; + String propertyName = "compute_pps_user_data_format"; + String propertyListValueZero = "RAW"; + String propertyListValueOne = "property-value-one"; + String propertyListValueTwo = "property-value-two"; + + + //Create VF + 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()); + + //Navigate to Properties Assignment screen, edit "list of strings" properties values and save + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnAddValueToList(propertyName); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedField(propertyName,1), propertyListValueOne); + PropertiesAssignmentPage.clickOnAddValueToList(propertyName); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIndexedField(propertyName,2), propertyListValueTwo); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.clickODeleteValueFromList(propertyName,1); + PropertiesAssignmentPage.clickOnSaveButton(); + + //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.buildIndexedField(propertyName,0),propertyListValueZero); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIndexedField(propertyName,1),propertyListValueTwo); + + + //Declare property as input, delete input + PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); + PropertiesAssignmentPage.clickOnDeclareButton(); + 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 + public void editAndSaveListOfComplexPropertyValueTest() throws Exception { + + //External Defect 437285 - PLEASE DON'T DELETE THE TEST!!!! + + String csarTestFile = csarFile1; + String componentName = "abstract_cdi"; + String propertyName = "port_cdi_imscore_port_ip_requirements"; + String nestedPropertyName = "ip_count"; + String propertyListValue = "12345"; + + //Create VF + 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()); + + //Navigate to Properties Assignment screen, edit "list of strings" properties values and save + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnAddValueToList(propertyName); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildIComplexListField(propertyName,nestedPropertyName,1),propertyListValue); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.clickOnExpandButton(propertyName,1); + PropertiesAssignmentPage.deletePropertyValue(PropertyNameBuilder.buildIComplexListField(propertyName,nestedPropertyName,1)); + PropertiesAssignmentPage.clickOnSaveButton(); + + //Verify that properties values are saved + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnExpandButton(propertyName,1); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildIComplexListField(propertyName,nestedPropertyName,1),""); + + + } + + + @Test + public void editAndSaveMapPropertyValueTest() throws Exception { + + String csarTestFile = csarFile; + String componentName = "oam_volume_0"; + String propertyName = "metadata"; + String propertyMapKeyOne = "KEY1"; + String propertyMapValueOne = "property-value-one"; + String propertyMapKeyTwo = "KEY2"; + String propertyMapValueTwo = "property-value-two"; + + //Create VF + 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()); + + //Navigate to Properties Assignment screen, edit "map of strings" properties values and save + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnAddValueToList(propertyName); + 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.clickOnSaveButton(); + PropertiesAssignmentPage.clickOnAddValueToList(propertyName); + 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 + 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); + +// //Declare property as input, delete input + PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); + PropertiesAssignmentPage.clickOnDeclareButton(); + 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)); + } + + + //VF - Complex Properties Tests + @Test + public void editAndSaveComplexPropertyValueTest() throws Exception { + + String csarTestFile = csarFile; + String componentName = "abstract_psm"; + String propertyName = "service_template_filter"; + String propertyNameString = "substitute_service_template"; + String propertyNameInt = "index_value"; + String propertyNameBoolean = "scaling_enabled"; + String propertyValueString = "Modified_psmServiceTemplate.yaml"; + String propertyValueInt = "2147483647"; + String propertyValueBoolean = "FALSE"; + + //Create VF + 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()); + + //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.clickOnSaveButton(); + + //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.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)); + } - @Test + //VF - Filter Tests + @Test public void filterAllVfTest() throws Exception { -// ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); -// ResourceUIUtils.createResource(vfMetaData, getUser()); String csarTestFile = csarFile; String propertyName = "name"; 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 new file mode 100644 index 0000000000..7362ebb7f7 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignmentUpdateFlow.java @@ -0,0 +1,655 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.execute.sanity; + +import com.aventstack.extentreports.Status; +import fj.data.Either; +import org.apache.commons.lang3.StringUtils; +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.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.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.verificator.PropertiesAssignmentVerificator; +import org.openecomp.sdc.ci.tests.verificator.VfVerificator; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +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 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); + + + @BeforeClass + public void beforeClass(){ + filePath = FileHandling.getFilePath(""); + } + + @BeforeMethod + 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[][] { + {"editInputValueTopChange.csar", ""}, + {"editInputValueNoTopChange.csar", "Updated-SRE-Mgt"}}; + } + + /** + * 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 validationValue - expected property value after update + * @throws Exception + */ + @Test(dataProvider = "assetFilesInputs") + public void updateInputDefaultValueTest(String updFileName, String validationValue) throws Exception { + setLog(updFileName); + + String origTestFile = origFile; + String componentName = "abstract_virc_fe_be_0"; + String inputName = "management_net_name"; + String inputUpdValue = "Updated-SRE-Mgt"; + + //Import 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, origTestFile, getUser()); + + //Edit Input value + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildInputField(inputName), inputUpdValue); + PropertiesAssignmentPage.clickOnSaveButton(); + + //Certify VF via API + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + + HomePage.navigateToHomePage(); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); + + //Update VF + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + GeneralPageElements.clickCheckoutButton(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file")); + ResourceUIUtils.updateVfWithCsar(filePath, updFileName); + + //Validate Input value - 1) empty in case of topology change; 2) user value is kept if no topology change + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName),validationValue); + + } + + + @DataProvider(name = "assetFilesProperties", parallel = false) + public Object[][] createDataProp() { + 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"} , + {"editedPropValueToEmptyTopChange.csar", "value-prop-vm_type_tag", ""}, + {"newPropValueToEmptyTopChange.csar", "value-prop-high_availablity", ""}, + {"editedPropValueToNewTopChange.csar", "value-prop-vm_type_tag", "updated_by_file"}}; + + } + + /** + * No topoplogy change in updated file - designer changes in properties values are kept after update + * OrigFile Designer UpdFile Result After Update + * --------------------------------------------------------------- + * prop1=value1 prop1=value2 prop1=null prop1=value2 + * prop1=null prop1=value1 prop1=null prop1=value1 + * prop1=value1 prop1=value2 prop1=value3 prop1=value3 + * + * + * Topoplogy change in updated file - designer changes in properties values are not kept after update + * OrigFile Designer UpdFile Result After Update + * --------------------------------------------------------------- + * prop1=value1 prop1=value2 prop1=null prop1=null + * prop1=null prop1=value1 prop1=null prop1=null + * prop1=value1 prop1=value2 prop1=value3 prop1=value3 + * + * @param updFileName - csar for update + * @param propertyName + * @param validationValue - expected property value after update + * @throws Exception + */ + @Test (dataProvider = "assetFilesProperties") + public void updatePropertyDefaultValueTest(String updFileName, String propertyName, String validationValue) throws Exception { + setLog(updFileName); + String origTestFile = origFile; + String componentName = "abstract_virc_fe_be_0"; + String propertyUpdValue = "updated_by_designer"; + + //Import 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, origTestFile, getUser()); + + //Edit Input value + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.editPropertyValue(propertyName, propertyUpdValue); + PropertiesAssignmentPage.clickOnSaveButton(); + + //Certify VF via API + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + + HomePage.navigateToHomePage(); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); + + //Update VF + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + GeneralPageElements.clickCheckoutButton(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file")); + ResourceUIUtils.updateVfWithCsar(filePath, updFileName); + + //Validate Input value + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentVerificator.validatePropertyValue(propertyName,validationValue); + } + + + @Test + public void updatePropertyChangeVfiVersionTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "virc_fe_be_volume_0"; + String propertyName = "disk_bus"; + String propertyValue = "added_by_designer"; + String propertyValueUpd = "updated_by_designer"; + String inputName = componentName + "_" + propertyName; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //Edit Property Value and declare as input + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(resourceReqDetails.getName()); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), propertyValue); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName), propertyValue); + + //Check in VF and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF input in Service properties, declare it as service input + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), propertyValue); + PropertiesAssignmentPage.findSearchBoxAndClick(inputName); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.clickOnInputTab(); + 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(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(resourceReqDetails.getName()); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildDeclaredInputField(componentName, propertyName), + propertyValueUpd); +// PropertiesAssignmentPage.deletePropertyValue(PropertyNameBuilder.buildDeclaredInputField(componentName, propertyName)); + PropertiesAssignmentPage.clickOnSaveButton(); + ResourceGeneralPage.clickCheckinButton(resourceReqDetails.getName()); + + //Change resource version on service + resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "0.2"); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + //Validate that service contains property with "get_input" value and input with the updated value + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.isPropertyChecked(inputName); + PropertiesAssignmentVerificator.validatePropertyValue + (PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), + PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName )); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue + (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValueUpd); + } + + @Test + public void updateServicePropertyChangeVfiVersionTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "virc_fe_be_volume_0"; + String propertyName = "multi_stage_design"; + String propertyValueBoolean = "TRUE"; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //Check in VF and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF input in Service properties, declare it as service input + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); + String defaultPropertyValueBoolean = PropertiesAssignmentPage.selectBooleanPropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), propertyValueBoolean); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validateBooleanPropertyValue + (PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), + propertyValueBoolean); + +// //Checkout VF and check in - v0.2 + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + +// //Change resource version on service + resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "0.2"); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + +// //Validate that service contains property with "get_input" value and input with the updated value + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), + PropertyNameBuilder.buildServiceDeclaredPropValueServiceLevel(componentInstance, propertyName)); + PropertiesAssignmentPage.isPropertyChecked(propertyName); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validateBooleanPropertyValue + (PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), + StringUtils.isEmpty(defaultPropertyValueBoolean) ? propertyValueBoolean : defaultPropertyValueBoolean); + } + + @Test + public void deletePropertyChangeVfiVersionTest() throws Throwable{ + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "abstract_virc_fe_be_1"; + String propertyNameProp1 = "max_instances"; //empty property + String propertyNameProp2 = "nfc_naming_code"; //non-empty property + String propertyNameProp3 = "min_instances"; //non-empty property + String propertyNameProp4 = "nf_type"; + String propertyValueProp2 = "virc_fe_be"; + String propertyValueProp3 = "0"; + String propertyValueUpd1 = "111"; + String propertyValueUpd2 = "updated_by_designer"; + String propertyValueUpd4 = "added_by_designer_on_service"; + String inputName1 = componentName + "_" + propertyNameProp1; + String inputName2 = componentName + "_" + propertyNameProp2; + String inputName3 = componentName + "_" + propertyNameProp3; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //VF - Declare properties as inputs + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(resourceReqDetails.getName()); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyNameProp1); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyNameProp2); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyNameProp3); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName1), ""); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName2), propertyValueProp2); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName3), propertyValueProp3); + + //Check in VF, create Service and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF inputs in Service properties, add or edit properties values + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findSearchBoxAndClick(inputName1); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(inputName1), propertyValueUpd1); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(inputName2); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(inputName2), propertyValueUpd2); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(inputName3); + PropertiesAssignmentPage.deletePropertyValue(PropertyNameBuilder.buildSimpleField(inputName3)); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyNameProp4); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(propertyNameProp4), propertyValueUpd4); + PropertiesAssignmentPage.clickOnSaveButton(); + + //Checkout and check in VF, change VFi version on Service to 0.2 + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + //Service - Validate properties values + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName1), propertyValueUpd1); +// PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName2), propertyValueProp2); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName3), propertyValueProp3); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propertyNameProp4), propertyValueUpd4); + + //Service - Declare properties as inputs + PropertiesAssignmentPage.findSearchBoxAndClick(inputName1); + PropertiesAssignmentPage.clickOnDeclareButton(); +// PropertiesAssignmentPage.findSearchBoxAndClick(inputName2); +// PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(inputName3); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyNameProp4); + PropertiesAssignmentPage.clickOnDeclareButton(); + // TODO: 5/9/2018 Add validation for input values + + //VF - delete some declared inputs + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(resourceReqDetails.getName()); + GeneralPageElements.clickCheckoutButton(); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.findInput(componentName, propertyNameProp1); + PropertiesAssignmentPage.clickOnDeleteInputButton(); + PropertiesAssignmentPage.clickOnDeleteInputDialogConfirmationButton(); +//// PropertiesAssignmentPage.findInput(componentName, propertyNameProp2); +// PropertiesAssignmentPage.clickOnDeleteInputButton(); +// PropertiesAssignmentPage.clickOnDeleteInputDialogConfirmationButton(); + + //VF - check in VF, change VFi version on Service to 0.3 + ResourceGeneralPage.clickCheckinButton(resourceReqDetails.getName()); + resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "0.3"); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + //Service - Validate that deleted inputs are not found in Service properties, others are found + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findProperty(inputName1); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildSimpleField(inputName1))); +// PropertiesAssignmentPage.findProperty(inputName2); +// assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildSimpleField(inputName2))); + PropertiesAssignmentPage.findProperty(inputName3); + assertTrue(GeneralUIUtils.isElementVisibleByTestId(PropertyNameBuilder.buildSimpleField(inputName3))); + PropertiesAssignmentPage.findProperty(propertyNameProp4); + assertTrue(GeneralUIUtils.isElementVisibleByTestId(PropertyNameBuilder.buildSimpleField(propertyNameProp4))); + + //Service - Validate that Service inputs that were declared from deleted properties are not found + // - Validate that other inputs remain - Currently input of min_instances disappears - BUG 411833!!! + } + + @Test + public void updateVFCPropertyChangeVFCiVersionTest() throws Throwable { + ResourceReqDetails atomicResourceMetaData; + String prop1 = "network_role"; + String propValue1 = "added_value_1"; + String prop2 = "is_default"; + String propValue2 = "TRUE"; + + //Import VFC, certify VFC + String fileName = "importVFC_VFC23.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + String vfcName = atomicResourceMetaData.getName(); + ResourceGeneralPage.clickCheckinButton(vfcName); + + //Create VF + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + //Add VFCi to VF canvas + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(vfcName); + + //VF Properties Assignment - edit properties values and declare as input + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findSearchBoxAndClick(prop1); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(prop1), propValue1); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(prop2); + String propDefaultValue2 = PropertiesAssignmentPage.selectBooleanPropertyValue(PropertyNameBuilder.buildSimpleField(prop2), propValue2); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.clickOnDeclareButton(); + + //Check out and check in VFC - v0.2 + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(vfcName); + ResourceGeneralPage.clickCheckoutButton(); + ResourceGeneralPage.clickCheckinButton(vfcName); + + //Change VFCi version in VF + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "0.2"); + VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "0.2"); + + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vfMetaData.getName(), "0.1"); + List<ComponentInstance> components = resource.getComponentInstances(); + String normalizedName = components.get(0).getNormalizedName(); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.clickOnInputTab(); + //Verify that input value of the declared property that is EMPTY by default hasn't changed +// PropertiesAssignmentVerificator.validateBooleanPropertyValue(PropertyNameBuilder.buildDeclaredInputField(normalizedName, prop2), propValue2); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildDeclaredInputField(normalizedName, prop1), propValue1); + //Verify that input value of the declared property that is NOT EMPTY by default has been changed + PropertiesAssignmentVerificator.validateBooleanPropertyValue(PropertyNameBuilder.buildDeclaredInputField(normalizedName, prop2), + StringUtils.isEmpty(propDefaultValue2) ? propValue2 : propDefaultValue2); + + //Check out VFC - v0.3, delete a property, check in VFC + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(vfcName); + ResourceGeneralPage.clickCheckoutButton(); + ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); + PropertiesPage.clickDeletePropertyFromPopup(prop1); + PropertiesPage.clickDeletePropertyFromPopup(prop2); + ResourceGeneralPage.clickCheckinButton(vfcName); + + //Change VFCi version in VF + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "0.3"); + VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "0.3"); + + //Verify that properties and inputs were removed + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findProperty(prop1); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildSimpleField(prop1))); + PropertiesAssignmentPage.findProperty(prop2); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildSimpleField(prop2))); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.findProperty(normalizedName + "_" + prop1); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildDeclaredInputField(normalizedName, prop1))); + PropertiesAssignmentPage.findProperty(normalizedName + "_" + prop2); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildDeclaredInputField(normalizedName, prop2))); + } + + @Test + public void updateHeatParamChangeVfiVersionTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String artifactName = "base_fe_be"; + String heatParamName = "availability_zone_0"; + String heatParamUpdValue = "Updated_ZoneA"; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //Check in VF and add VFi to Service + 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(); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(service.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement vfElement = vfCanvasManager.createElementOnCanvas(resource.getName()); + + //Select VFi on canvas, open Deployment Artifacts tab + vfCanvasManager.clickOnCanvaElement(vfElement); + CompositionPage.showDeploymentArtifactTab(); + DeploymentArtifactPage.hoverArtifact(artifactName); + DeploymentArtifactPage.clickEditEnvArtifact(artifactName); + DeploymentArtifactPage.editHeatParamValue(HeatParamNameBuilder.buildCurrentHeatParamValue(heatParamName), heatParamUpdValue); + DeploymentArtifactPage.clickSaveEnvParameters(); + + //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(); + + //Change VFi version on Service canvas - v0.2 + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, vfElement, "0.2"); +// VfVerificator.verifyInstanceVersion(service, getUser(), resource.getName(), "0.2"); + + //Validate that edited heatparam value is kept + CompositionPage.showDeploymentArtifactTab(); + DeploymentArtifactPage.hoverArtifact(artifactName); + DeploymentArtifactPage.clickEditEnvArtifact(artifactName); + PropertiesAssignmentVerificator.validatePropertyValue(HeatParamNameBuilder.buildCurrentHeatParamValue(heatParamName), heatParamUpdValue); + DeploymentArtifactPage.clickCloseEnvParameters(); + + //Check out VF, delete heatparam value, check in VF - v0.3 + 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(); + + //Change VFi version on Service canvas - v0.3 + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, vfElement, "0.3"); + + //Validate that edited heatparam value is kept, default value is empty + CompositionPage.showDeploymentArtifactTab(); + DeploymentArtifactPage.hoverArtifact(artifactName); + DeploymentArtifactPage.clickEditEnvArtifact(artifactName); + PropertiesAssignmentVerificator.validatePropertyValue(HeatParamNameBuilder.buildCurrentHeatParamValue(heatParamName), heatParamUpdValue); + PropertiesAssignmentVerificator.validatePropertyValueIsNull(HeatParamNameBuilder.buildDefaultHeatParamValue(heatParamName)); + DeploymentArtifactPage.clickCloseEnvParameters(); + } + + + + @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 new file mode 100644 index 0000000000..a748281c4b --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/PropertiesAssignmentUpdateFlow_New.java @@ -0,0 +1,905 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.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.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.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.verificator.PropertiesAssignmentVerificator; +import org.openecomp.sdc.ci.tests.verificator.VfVerificator; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.List; + + + + +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); + + + @BeforeClass + public void beforeClass(){ + filePath = FileHandling.getFilePath(""); + } + + @BeforeMethod + public void beforeTest(){ + System.out.println("File repository is : " + filePath); +// SetupCDTest.getExtendTest().log(Status.INFO, "File repository is : " + filePath); + } + + //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[][] { + {"editInputValueTopChange.csar", ""}, + {"editInputValueNoTopChange.csar", "Updated-SRE-Mgt"}}; + } + + /** + * 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 validationValue - expected property value after update + * @throws Exception + */ + @Test(dataProvider = "assetFilesInputs") + public void updateInputDefaultValueTest(String updFileName, String validationValue) throws Exception { + setLog(updFileName); + + String origTestFile = origFile; + String componentName = "abstract_virc_fe_be_0"; + String inputName = "management_net_name"; + String inputUpdValue = "Updated-SRE-Mgt"; + + //Import 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, origTestFile, getUser()); + + //Edit Input value + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildInputField(inputName), inputUpdValue); + PropertiesAssignmentPage.clickOnSaveButton(); + + //Certify VF via API + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + + HomePage.navigateToHomePage(); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); + + //Update VF + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + GeneralPageElements.clickCheckoutButton(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file")); + ResourceUIUtils.updateVfWithCsar(filePath, updFileName); + + //Validate Input value - 1) empty in case of topology change; 2) user value is kept if no topology change + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName),validationValue); + + } + + + @DataProvider(name = "assetFilesProperties", parallel = false) + public Object[][] createDataProp() { + 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}, + {"virc_fe_be.csar", "value-prop-vm_type_tag", "", "virc_fe_be", true}, + {"editedPropValueToEmptyTopChange.csar", "value-prop-vm_type_tag", "updated_by_designer", "", false}, //topology change - simple + {"newPropValueToEmptyTopChange.csar", "value-prop-high_availablity", "updated_by_designer", "", false}, + {"editedPropValueToNewTopChange.csar", "value-prop-vm_type_tag", "updated_by_designer", "updated_by_file", false}, + {"virc_fe_be.csar", "value-prop-port_virc_fe_be_data_1_port_mac_requirements.mac_range_plan", "updated_by_designer", "updated_by_designer", false}, //no topology change - complex + {"virc_fe_be.csar", "value-prop-service_template_filter.count", "12345", "1", false}, + {"virc_fe_be.csar", "value-prop-service_template_filter.substitute_service_template", "", "Nested_virc_fe_beServiceTemplate.yaml", true}}; + } + + /** + * No topology change in updated file - designer changes in properties values are kept after update + * OrigFile Designer UpdFile Result After Update + * --------------------------------------------------------------- + * prop1=value1 prop1=value2 prop1=null prop1=value2 + * prop1=null prop1=value1 prop1=null prop1=value1 + * prop1=value1 prop1=value2 prop1=value3 prop1=value3 + * prop1=value1 prop1=null prop1=value1 prop1=value1 + * + * + * Topoplogy change in updated file - designer changes in properties values are not kept after update + * OrigFile Designer UpdFile Result After Update + * --------------------------------------------------------------- + * prop1=value1 prop1=value2 prop1=null prop1=null + * prop1=null prop1=value1 prop1=null prop1=null + * prop1=value1 prop1=value2 prop1=value3 prop1=value3 + * + * + * No topology change in updated files - complex property value changes + * OrigFile Designer UpdFile Result After Update + * --------------------------------------------------------------- + * prop1=null prop1=value1 prop1=null prop1=value1 + * prop1=value1 prop1=value2 prop1=value1 prop1=value1 + * prop1=value1 prop1=null prop1=value1 prop1=value1 + * + * @param updFileName - csar for update + * @param propertyName + * @param validationValue - expected property value after update + * @throws Exception + */ + @Test (dataProvider = "assetFilesProperties") + public void updatePropertyDefaultValueTest(String updFileName, String propertyName, String updValue, String validationValue, boolean userDeletesValue) throws Exception { + setLog(updFileName); + String origTestFile = origFile; + String componentName = "abstract_virc_fe_be_0"; +// String propertyUpdValue = "updated_by_designer"; + + //Import 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, origTestFile, getUser()); + + //Edit or delete Input value + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + if(userDeletesValue) { + PropertiesAssignmentPage.deletePropertyValue(propertyName); + } + else { + PropertiesAssignmentPage.editPropertyValue(propertyName, updValue); + } + PropertiesAssignmentPage.clickOnSaveButton(); + + //Certify VF via API + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1"); + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + + //Update VF + HomePage.navigateToHomePage(); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToGeneralScreen(); + GeneralPageElements.clickCheckoutButton(); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file")); + ResourceUIUtils.updateVfWithCsar(filePath, updFileName); + + //Validate Input value + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + 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 + {"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{ + setLog(propertyName); + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "abstract_virc_fe_be_1"; + String inputName = componentName + "_" + propertyName; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //VF - Declare property as input + declarePropertyAsInput(propertyName, componentName, resourceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName), origValue); + + //Check in VF, create Service and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF inputs in Service properties, add or edit properties values + findServiceProperty(inputName, serviceReqDetails); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(inputName), updValue); + PropertiesAssignmentPage.clickOnSaveButton(); + + //Checkout and check in VF, change VFi version on Service to 0.2 + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + //Service - Validate properties values + viewServiceProperties(serviceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), expectedValue); + } + + + @Test + public void changeVfiVersionServicePropertyDeleteValueTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "abstract_virc_fe_be_1"; + String propertyName = "min_instances"; + String propertyValue = "0"; + String inputName = componentName + "_" + propertyName; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //VF - Declare properties as inputs + declarePropertyAsInput(propertyName, componentName, resourceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName), propertyValue); + + //Check in VF, create Service and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF inputs in Service properties, delete property value + findServiceProperty(inputName, serviceReqDetails); + PropertiesAssignmentPage.deletePropertyValue(PropertyNameBuilder.buildSimpleField(inputName)); + PropertiesAssignmentPage.clickOnSaveButton(); + + //Checkout and check in VF, change VFi version on Service to 0.2 + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + //Service - Validate properties values + viewServiceProperties(serviceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), propertyValue); + } + + @Test + public void changeVfiVersionServiceGenericPropertyValueTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "abstract_virc_fe_be_1"; + String propertyName = "nf_type"; + String propertyUpdValue = "added by designer on service"; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //Check in VF, create Service and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF inputs in Service properties, add or edit property value + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), propertyUpdValue); + PropertiesAssignmentPage.clickOnSaveButton(); + + //Checkout and check in VF, change VFi version on Service to 0.2 + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + //Service - Validate property value + viewServiceProperties(serviceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), propertyUpdValue); + } + + + + //ChangeVersion tests - validating service input values after changing VFi version on service + @Test + public void changeVfiServiceInputEditValueTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "virc_fe_be_volume_0"; + String propertyName = "disk_bus"; + String propertyValue = "added_by_designer"; + String propertyValueUpd = "updated_by_designer"; + String inputName = componentName + "_" + propertyName; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //Edit Property Value and declare as input + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + viewVfComponentProperties(componentName, resourceReqDetails); + editAndDeclareSimpleProperty(propertyName, propertyValue); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName), propertyValue); + + //Check in VF and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF input in Service properties, declare it as service input + viewServiceProperties(serviceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), propertyValue); + findAndDeclareServiceProperty(inputName); + 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(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + viewVfInputs(resourceReqDetails); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildDeclaredInputField(componentName, propertyName), + propertyValueUpd); + PropertiesAssignmentPage.clickOnSaveButton(); + ResourceGeneralPage.clickCheckinButton(resourceReqDetails.getName()); + + //Change resource version on service + resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "0.2"); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + //Validate that service contains property with "get_input" value and input with the updated value + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.isPropertyChecked(inputName); + PropertiesAssignmentVerificator.validatePropertyValue + (PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), + PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName )); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue + (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValueUpd); + } + + @Test + public void changeVfiServiceInputEditBooleanTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "virc_fe_be_volume_0"; + String propertyName = "multi_stage_design"; + String origValue = "FALSE"; + String updValue = "TRUE"; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //Check in VF and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF input in Service properties, declare it as service input + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); + PropertiesAssignmentPage.selectBooleanPropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), updValue); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validateBooleanPropertyValue + (PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), + updValue); + +// //Checkout VF and check in - v0.2 + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft(); + AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft(); + +// //Change resource version on service + resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "0.2"); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + +// //Validate that service contains property with "get_input" value and input with the updated value + viewServiceProperties(serviceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), + PropertyNameBuilder.buildServiceDeclaredPropValueServiceLevel(componentInstance, propertyName)); + PropertiesAssignmentPage.isPropertyChecked(propertyName); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validateBooleanPropertyValue + (PropertyNameBuilder.buildServiceDeclaredFieldServiceLevel(componentInstance, propertyName), + origValue); + } + + @Test + public void changeVfiServiceInputDeleteValueTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "abstract_virc_fe_be_0"; + String propertyName = "vm_type_tag"; + String propertyValue = "updated_by_designer"; + String inputName = componentName + "_" + propertyName; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //Edit Property Value and declare as input + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + viewVfComponentProperties(componentName, resourceReqDetails); + editAndDeclareSimpleProperty(propertyName, propertyValue); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName), propertyValue); + + //Check in VF and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF input in Service properties, declare it as service input + viewServiceProperties(serviceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), propertyValue); + findAndDeclareServiceProperty(inputName); + 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(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + viewVfInputs(resourceReqDetails); + PropertiesAssignmentPage.deletePropertyValue(PropertyNameBuilder.buildDeclaredInputField(componentName, propertyName)); + PropertiesAssignmentPage.clickOnSaveButton(); + ResourceGeneralPage.clickCheckinButton(resourceReqDetails.getName()); + + //Change resource version on service + resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "0.2"); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + //Validate that service contains property with "get_input" value and input with the updated value + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.isPropertyChecked(inputName); + PropertiesAssignmentVerificator.validatePropertyValue + (PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), + PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName )); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue + (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValue); + } + + @Test + public void changeVfiServiceInputAddValueTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "virc_fe_be_volume_0"; + String propertyName = "disk_bus"; + String propertyValue = "updated_by_designer"; + String inputName = componentName + "_" + propertyName; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //Edit Property Value and declare as input + declarePropertyAsInput(propertyName, componentName, resourceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName), ""); + + //Check in VF and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF input in Service properties, declare it as service input + viewServiceProperties(serviceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), ""); + findAndDeclareServiceProperty(inputName); + 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(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + viewVfInputs(resourceReqDetails); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildDeclaredInputField(componentName, propertyName), propertyValue); + PropertiesAssignmentPage.clickOnSaveButton(); + ResourceGeneralPage.clickCheckinButton(resourceReqDetails.getName()); + + //Change resource version on service + resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "0.2"); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + //Validate that service contains property with "get_input" value and input with the updated value + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.isPropertyChecked(inputName); + PropertiesAssignmentVerificator.validatePropertyValue + (PropertyNameBuilder.buildServicePropertyValue(componentName, propertyName), + PropertyNameBuilder.buildServiceDeclaredPropertyValue(componentInstance, componentName, propertyName )); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue + (PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName), propertyValue); + } + + @Test + public void changeVfiServiceInputDeleteInputTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String componentName = "virc_fe_be_volume_0"; + String propertyName = "disk_bus"; + String propertyValue = "added_by_designer"; + String inputName = componentName + "_" + propertyName; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //Edit Property Value and declare as input + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + viewVfComponentProperties(componentName, resourceReqDetails); + editAndDeclareSimpleProperty(propertyName, propertyValue); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildInputField(inputName), propertyValue); + + //Check in VF and add VFi to Service + 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(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value(); + + //Find the VF input in Service properties, declare it as service input + viewServiceProperties(serviceReqDetails); + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildSimpleField(inputName), propertyValue); + findAndDeclareServiceProperty(inputName); + 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(); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + viewVfInputs(resourceReqDetails); + PropertiesAssignmentPage.clickOnDeleteInputButton(); + PropertiesAssignmentPage.clickOnDeleteInputDialogConfirmationButton(); + ResourceGeneralPage.clickCheckinButton(resourceReqDetails.getName()); + + //Change resource version on service + resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "0.2"); + AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true); + + //Validate that service property and input are deleted + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findProperty(inputName); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildSimpleField(inputName))); + PropertiesAssignmentPage.clickOnInputTab(); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildServiceDeclaredFieldVfLevel(componentInstance, componentName, propertyName))); + } + + + + //ChangeVersion test - validating VF input values after changing VFCi version on VF + @Test + public void updateVFCPropertyChangeVFCiVersionTest() throws Throwable { + ResourceReqDetails atomicResourceMetaData; + String prop1 = "network_role"; + String propValue1 = "added_value_1"; + String prop2 = "is_default"; + String propValue2 = "TRUE"; + String propDefaultValue2 = "FALSE"; + + //Import VFC, certify VFC + String fileName = "importVFC_VFC23.yml"; + atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, + ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); + ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); + String vfcName = atomicResourceMetaData.getName(); + ResourceGeneralPage.clickCheckinButton(vfcName); + + //Create VF + ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); + ResourceUIUtils.createVF(vfMetaData, getUser()); + + //Add VFCi to VF canvas + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(vfcName); + + //VF Properties Assignment - edit properties values and declare as input + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findSearchBoxAndClick(prop1); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(prop1), propValue1); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(prop2); + PropertiesAssignmentPage.selectBooleanPropertyValue(PropertyNameBuilder.buildSimpleField(prop2), propValue2); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.clickOnDeclareButton(); + + //Check out and check in VFC - v0.2 + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(vfcName); + ResourceGeneralPage.clickCheckoutButton(); + ResourceGeneralPage.clickCheckinButton(vfcName); + + //Change VFCi version in VF + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "0.2"); + VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "0.2"); + + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vfMetaData.getName(), "0.1"); + List<ComponentInstance> components = resource.getComponentInstances(); + String normalizedName = components.get(0).getNormalizedName(); + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.clickOnInputTab(); + //Verify that input value of the declared property that is EMPTY by default hasn't changed + PropertiesAssignmentVerificator.validatePropertyValue(PropertyNameBuilder.buildDeclaredInputField(normalizedName, prop1), propValue1); + //Verify that input value of the declared property that is NOT EMPTY by default has been changed + PropertiesAssignmentVerificator.validateBooleanPropertyValue(PropertyNameBuilder.buildDeclaredInputField(normalizedName, prop2), propDefaultValue2); + + //Check out VFC - v0.3, delete a property, check in VFC + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(vfcName); + ResourceGeneralPage.clickCheckoutButton(); + ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen(); + PropertiesPage.clickDeletePropertyFromPopup(prop1); + PropertiesPage.clickDeletePropertyFromPopup(prop2); + ResourceGeneralPage.clickCheckinButton(vfcName); + + //Change VFCi version in VF + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "0.3"); + VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "0.3"); + + //Verify that properties and inputs were removed + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findProperty(prop1); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildSimpleField(prop1))); + PropertiesAssignmentPage.findProperty(prop2); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildSimpleField(prop2))); + PropertiesAssignmentPage.clickOnInputTab(); + PropertiesAssignmentPage.findProperty(normalizedName + "_" + prop1); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildDeclaredInputField(normalizedName, prop1))); + PropertiesAssignmentPage.findProperty(normalizedName + "_" + prop2); + assertTrue(GeneralUIUtils.isElementInvisibleByTestId(PropertyNameBuilder.buildDeclaredInputField(normalizedName, prop2))); + } + + //ChangeVersion test - validating HEAT param values after changing VFi version on Service + @Test + public void updateHeatParamChangeVfiVersionTest() throws Throwable { + String vnfFile = "vIRC_FE_BE.zip"; + String artifactName = "base_fe_be"; + String heatParamName = "availability_zone_0"; + String heatParamUpdValue = "Updated_ZoneA"; + + //Import VSP, create VF - v0.1 + 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); + VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + + //Check in VF and add VFi to Service + 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(); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(service.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager vfCanvasManager = CanvasManager.getCanvasManager(); + CanvasElement vfElement = vfCanvasManager.createElementOnCanvas(resource.getName()); + + //Select VFi on canvas, open Deployment Artifacts tab + vfCanvasManager.clickOnCanvaElement(vfElement); + CompositionPage.showDeploymentArtifactTab(); + DeploymentArtifactPage.hoverArtifact(artifactName); + DeploymentArtifactPage.clickEditEnvArtifact(artifactName); + DeploymentArtifactPage.editHeatParamValue(HeatParamNameBuilder.buildCurrentHeatParamValue(heatParamName), heatParamUpdValue); + DeploymentArtifactPage.clickSaveEnvParameters(); + + //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(); + + //Change VFi version on Service canvas - v0.2 + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, vfElement, "0.2"); +// VfVerificator.verifyInstanceVersion(service, getUser(), resource.getName(), "0.2"); + + //Validate that edited heatparam value is kept + CompositionPage.showDeploymentArtifactTab(); + DeploymentArtifactPage.hoverArtifact(artifactName); + DeploymentArtifactPage.clickEditEnvArtifact(artifactName); + PropertiesAssignmentVerificator.validatePropertyValue(HeatParamNameBuilder.buildCurrentHeatParamValue(heatParamName), heatParamUpdValue); + DeploymentArtifactPage.clickCloseEnvParameters(); + + //Check out VF, delete heatparam value, check in VF - v0.3 + 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(); + + //Change VFi version on Service canvas - v0.3 + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service.getName()); + ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); + vfCanvasManager = CanvasManager.getCanvasManager(); + CompositionPage.changeComponentVersion(vfCanvasManager, vfElement, "0.3"); + + //Validate that edited heatparam value is kept, default value is empty + CompositionPage.showDeploymentArtifactTab(); + DeploymentArtifactPage.hoverArtifact(artifactName); + DeploymentArtifactPage.clickEditEnvArtifact(artifactName); + PropertiesAssignmentVerificator.validatePropertyValue(HeatParamNameBuilder.buildCurrentHeatParamValue(heatParamName), heatParamUpdValue); + PropertiesAssignmentVerificator.validatePropertyValueIsNull(HeatParamNameBuilder.buildDefaultHeatParamValue(heatParamName)); + DeploymentArtifactPage.clickCloseEnvParameters(); + } + + + private void declarePropertyAsInput(String propertyName, String componentName, ResourceReqDetails resourceReqDetails) throws Exception { + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + viewVfComponentProperties(componentName, resourceReqDetails); + findAndDeclareServiceProperty(propertyName); + } + + private void viewServiceProperties(ServiceReqDetails serviceReqDetails) throws Exception { + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName()); + CompositionPage.moveToPropertiesScreen(); + } + + private void findServiceProperty(String inputName, ServiceReqDetails serviceReqDetails) throws Exception { + viewServiceProperties(serviceReqDetails); + PropertiesAssignmentPage.findSearchBoxAndClick(inputName); + } + + private void viewVfComponentProperties(String componentName, ResourceReqDetails resourceReqDetails) throws Exception { + GeneralUIUtils.findComponentAndClick(resourceReqDetails.getName()); + ResourceGeneralPage.getLeftMenu().moveToPropertiesAssignmentScreen(); + PropertiesAssignmentPage.clickOnComponentInComposition(componentName); + } + + private void findAndDeclareServiceProperty(String inputName) throws Exception { + PropertiesAssignmentPage.findSearchBoxAndClick(inputName); + PropertiesAssignmentPage.clickOnDeclareButton(); + PropertiesAssignmentPage.clickOnInputTab(); + } + + private void editAndDeclareSimpleProperty(String propertyName, String propertyValue) throws Exception { + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(propertyName), propertyValue); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(propertyName); + PropertiesAssignmentPage.clickOnDeclareButton(); + } + + private void viewVfInputs(ResourceReqDetails resourceReqDetails) throws Exception { + GeneralUIUtils.findComponentAndClick(resourceReqDetails.getName()); + 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 71466f3211..a44ffe092a 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 @@ -45,7 +45,6 @@ import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.AssertJUnit; -import org.testng.SkipException; import org.testng.TestException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -55,6 +54,7 @@ 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; public class Service extends SetupCDTest { @@ -66,7 +66,12 @@ public class Service extends SetupCDTest { 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(""); @@ -170,7 +175,8 @@ public class Service extends SetupCDTest { ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ResourceUIUtils.createVF(atomicResourceMetaData, getUser()); - ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName()); + //TODO Andrey changed to click on ceckIn button + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); ServiceUIUtils.createService(serviceMetadata, getUser()); @@ -233,32 +239,39 @@ public class Service extends SetupCDTest { @Test public void addInformationArtifactInCompositionScreenTest() throws Exception{ - String fileName = HEAT_FILE_YAML_NAME; String descriptionText = DESCRIPTION; + List<String> artifactFileNames = new ArrayList<>(); ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); ServiceUIUtils.createService(serviceMetadata, getUser()); ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); - ArtifactInfo artifactInfo = new ArtifactInfo(filePath, fileName, descriptionText, ARTIFACT_LABEL,"OTHER"); + ArtifactInfo artifactInfo = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, descriptionText, ARTIFACT_LABEL,"OTHER"); CompositionPage.showInformationArtifactTab(); List<WebElement> beforeArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); CompositionPage.clickAddArtifactButton(); ArtifactUIUtils.fillAndAddNewArtifactParameters(artifactInfo, CompositionPage.artifactPopup()); List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)); - assertTrue(String.format("Wrong number of artifacts, Expected: %s Actual: %s", beforeArtifactList.size() + 1, actualArtifactList.size()), - (beforeArtifactList.size() + 1) == actualArtifactList.size()); + assertThat(actualArtifactList).as("Check number of artifacts").hasSize(beforeArtifactList.size() + 1); + int fileNameCounter = 0; + String fileName; for(DataTestIdEnum.InformationalArtifactsService artifact: DataTestIdEnum.InformationalArtifactsService.values()){ - ArtifactUIUtils.fillPlaceHolderInformationalArtifact(artifact, filePath, fileName, descriptionText); + fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; + ArtifactUIUtils.fillPlaceHolderInformationalArtifact(artifact, + FileHandling.getFilePath("uniqueFileNames"), fileName, descriptionText); + artifactFileNames.add(fileName); + fileNameCounter++; } - int numberOfFiles = CompositionPage.getAllAddedArtifacts().size(); - assertTrue(String.format("Wrong number of artifacts, Expected: %s Actual: %s", (beforeArtifactList.size() + 1), numberOfFiles), (beforeArtifactList.size() + 1) == numberOfFiles); - - for(WebElement actualArtifactFileName : CompositionPage.getAllAddedArtifacts()){ - assertTrue(fileName.equals(actualArtifactFileName.getText())); + 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 @@ -468,7 +481,7 @@ public class Service extends SetupCDTest { 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); - GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue()); + GeneralPageElements.clickOKButton(); assertTrue("Artifact does not deleted", !GeneralUIUtils.waitForElementInVisibilityByTestId(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME))); } } @@ -491,7 +504,8 @@ public class Service extends SetupCDTest { public CanvasElement createServiceWithRiArtifact(ResourceReqDetails atomicResourceMetaData, ServiceReqDetails serviceMetadata, ArtifactInfo artifact) throws Exception, AWTException { ResourceUIUtils.createVF(atomicResourceMetaData, getUser()); - ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName()); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); ServiceUIUtils.createService(serviceMetadata, getUser()); @@ -560,8 +574,8 @@ public class Service extends SetupCDTest { catch(TestException e){ } } - - @Test + + @Test() public void deploymentViewServiceTest() throws Exception{ User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); @@ -570,15 +584,18 @@ public class Service extends SetupCDTest { 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<GroupDefinition> 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<PropertyDataDefinition> propertyList = new ArrayList<>(); - propertyList.add(property); - AtomicOperationUtils.updateGroupPropertyOnResource(propertyList, resource, group.getUniqueId(), user, true); +// property.setValue("100"); +// List<PropertyDataDefinition> 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; } } @@ -602,7 +619,8 @@ public class Service extends SetupCDTest { ServiceVerificator.verifyDeploymentPageSubElements(instanceModuleText.split("\\.\\.")[2], new DeploymentViewVerificator(filePath + fileName2)); ServiceVerificator.verifyDisabledServiceProperties(); if(true){ - throw new SkipException("Sent email to Edith Ronen, waiting for answer"); +// 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")) @@ -633,13 +651,14 @@ public class Service extends SetupCDTest { 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.clickSubmitForTestingButton(resourceMetaData.getName()); + //TODO Andrey should click on certify button + ResourceGeneralPage.clickCertifyButton(resourceMetaData.getName()); - reloginWithNewRole(UserRoleEnum.TESTER); + /*reloginWithNewRole(UserRoleEnum.TESTER); GeneralUIUtils.findComponentAndClick(resourceMetaData.getName()); TesterOperationPage.certifyComponent(resourceMetaData.getName()); - reloginWithNewRole(UserRoleEnum.DESIGNER); + reloginWithNewRole(UserRoleEnum.DESIGNER);*/ ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService(); ServiceUIUtils.createService(serviceMetadata, getUser()); @@ -672,15 +691,44 @@ public class Service extends SetupCDTest { 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(); + } - public synchronized String addResourceToServiceInCanvas(ResourceReqDetails resourceMetaData) throws Exception { - DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen(); - CanvasManager canvasManager = CanvasManager.getCanvasManager(); - CompositionPage.searchForElement(resourceMetaData.getName()); - CanvasElement computeElement = canvasManager.createElementOnCanvas(resourceMetaData.getName()); - canvasManager.clickOnCanvaElement(computeElement); - String selectedInstanceName = CompositionPage.getSelectedInstanceName(); - return selectedInstanceName; + 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{ 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 324966c105..4fa97871f7 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 @@ -1,8 +1,12 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; -import com.clearspring.analytics.util.Pair; import fj.data.Either; +import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; +import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; +import org.onap.sdc.toscaparser.api.Group; +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.*; @@ -23,666 +27,764 @@ 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; import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils; import org.openecomp.sdc.ci.tests.utils.rest.PropertyRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; import org.openecomp.sdc.ci.tests.verificator.ToscaValidation; -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.onap.sdc.toscaparser.api.Group; -import org.onap.sdc.toscaparser.api.NodeTemplate; -import org.onap.sdc.toscaparser.api.elements.Metadata; -import org.testng.Assert; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.io.File; import java.util.*; +import static org.testng.Assert.assertFalse; -public class ToscaValidationTest extends SetupCDTest{ - private static final String GENERIC_VF = "Generic_VF"; - private static final String GENERIC_PNF = "Generic_PNF"; - - protected SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance(); - User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); +public class ToscaValidationTest extends SetupCDTest { - @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List") - public void toscaFileValidator(String filePath, String vnfFile) throws Exception, Throwable{ + private static final String GENERIC_VF = "Generic_VF"; + private static final String GENERIC_PNF = "Generic_PNF"; + private static final String GENERIC_CR = "Generic_CR"; + + protected SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance(); + User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + + @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List") + public void toscaFileValidator(String filePath, String vnfFile) throws Exception { //--------------------------GENERAL-------------------------------- /*// for debugging only - setLog("Test"); + setLog("Test"); File amdocsCsarFileName = (new File("C:\\Users\\al714h\\Downloads\\d218be69637647b0b693647d84a8c03f.csar")); toscaMainAmdocsDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(amdocsCsarFileName); toscaMainVfDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File("C:\\Users\\al714h\\Downloads\\resource-Civfonboarded2016073VmxBv301072E2eE60f5c15-csar.csar")); */ -// vnfFile = "BE-HEAT.zip"; - setLog(vnfFile); - List<Boolean> status = new ArrayList<>(); - ISdcCsarHelper fdntCsarHelper; - File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); + // vnfFile = "vRouter for DHV Test_Version_4.zip"; + setLog(vnfFile); + List<Boolean> status = new ArrayList<>(); + ISdcCsarHelper fdntCsarHelper; + File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); //--------------------------AMDOCS-------------------------------- - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, user);//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - resourceReqDetails = createCustomizedVsp(resourceReqDetails, filePath, vnfFile); - ToscaDefinition toscaMainAmdocsDefinition = downloadAndGetToscaMainYamlObjectUI(resourceReqDetails, filesFolder); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, user);//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + resourceReqDetails = createCustomizedVsp(resourceReqDetails, filePath, vnfFile); + ToscaDefinition toscaMainAmdocsDefinition = downloadAndGetToscaMainYamlObjectUI(resourceReqDetails, filesFolder); //------adding generic inputs to expected object - toscaMainAmdocsDefinition = addGenericPropertiesToToscaDefinitionObject(toscaMainAmdocsDefinition, GENERIC_VF); + toscaMainAmdocsDefinition = addGenericPropertiesToToscaDefinitionObject(toscaMainAmdocsDefinition, GENERIC_VF); // copy object - ToscaDefinition toscaExpectedMainServiceDefinition = new ToscaDefinition(toscaMainAmdocsDefinition); + ToscaDefinition toscaExpectedMainServiceDefinition = new ToscaDefinition(toscaMainAmdocsDefinition); // create list of modules from HEAT.meta file - File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir(); - List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition = CsarParserUtils.getListTypeHeatMetaDefinition(latestFilefromDir); + File latestFileFromDir = FileHandling.getLastModifiedFileNameFromDir(); + List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition = CsarParserUtils.getListTypeHeatMetaDefinition(latestFileFromDir); //TODO VfModuleVerificator.verifyGroupMetadata(); //TODO--------------------------AMDOCS DOWNLOAD VIA APIS-------------------------------- //--------------------------VF-------------------------------- // create VF base on VNF imported from previous step - have, resourceReqDetails object include part of resource metadata - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - ToscaDefinition toscaMainVfDefinition = downloadAndGetToscaMainYamlObjectApi(resource, filesFolder); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + ToscaDefinition toscaMainVfDefinition = downloadAndGetToscaMainYamlObjectApi(resource, filesFolder); //--------------------------SERVICE-------------------------------- - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); //--------------------------getProperties set values and declare-------------------- - Component componentObject = AtomicOperationUtils.getComponentObject(service, UserRoleEnum.DESIGNER); - Map<String, List<ComponentInstanceInput>> componentInstancesInputs = componentObject.getComponentInstancesInputs(); - setValuesToPropertiesList(componentInstancesInputs, toscaExpectedMainServiceDefinition); - PropertyRestUtils.declareProporties(componentObject, componentInstancesInputs, user); - - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - File ServiceCsarFileName = new File(File.separator + "ServiceCsar_" + ElementFactory.generateUUIDforSufix() + ".csar"); - OnboardingUtillViaApis.downloadToscaCsarToDirectory(service, new File(filesFolder.getPath() + ServiceCsarFileName)); - ToscaDefinition toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + ServiceCsarFileName)); + Component componentObject = AtomicOperationUtils.getComponentObject(service, UserRoleEnum.DESIGNER); + Map<String, List<ComponentInstanceInput>> componentInstancesInputs = componentObject.getComponentInstancesInputs(); + setValuesToPropertiesList(componentInstancesInputs, toscaExpectedMainServiceDefinition); + PropertyRestUtils.declareProporties(componentObject, componentInstancesInputs, user); + + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + Map<String, VfModuleDefinition> expectedVfModulesDefinitionObject = createExpectedVfModuleDefinitionObject(resource, service, listTypeHeatMetaDefinition); + + File serviceCsarFileName = new File(File.separator + "ServiceCsar_" + ElementFactory.generateUUIDforSufix() + ".csar"); + OnboardingUtillViaApis.downloadToscaCsarToDirectory(service, new File(filesFolder.getPath() + serviceCsarFileName)); + ToscaDefinition toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + serviceCsarFileName)); //--------------------------initialization of Tosca Parser-------------------------------- - fdntCsarHelper = initSdcCsarHelper(ServiceCsarFileName, filesFolder); + fdntCsarHelper = initSdcCsarHelper(serviceCsarFileName, filesFolder); ////---------------------------TESTS-------------------------------------------------- - status = validateVfMetadata(toscaMainAmdocsDefinition, toscaMainVfDefinition, resourceReqDetails, resource, vnfFile, status); - status = validateResourceNodeTemplateMetadata(toscaMainVfDefinition, resource, vnfFile, status); - status = validateServiceMetadata(toscaMainServiceDefinition, serviceReqDetails, service, vnfFile, status); - status = validateServiceNodeTemplateMetadata(toscaMainServiceDefinition, componentInstanceDefinition, resourceReqDetails, resource, vnfFile, status); - status = validateServiceMetadataUsingParser(fdntCsarHelper, serviceReqDetails, service, vnfFile, status); - status = validateServiceNodeTemplateMetadataUsingParser(fdntCsarHelper, resourceReqDetails, resource, componentInstanceDefinition, vnfFile, status); - status = validateResourceInputs(toscaMainAmdocsDefinition, toscaMainVfDefinition, vnfFile, status); - status = validateServiceInputs(toscaExpectedMainServiceDefinition, toscaMainServiceDefinition, vnfFile, status); - status = validateServiceInputsUsingParser(fdntCsarHelper, toscaExpectedMainServiceDefinition, vnfFile, status); + validateVfModuleJsonFile(expectedVfModulesDefinitionObject, service, componentInstanceDefinition.getUniqueId(), vnfFile, status); + validateVfMetadata(toscaMainAmdocsDefinition, toscaMainVfDefinition, resourceReqDetails, resource, vnfFile, status); + validateResourceNodeTemplateMetadata(toscaMainVfDefinition, resource, vnfFile, status); + validateServiceMetadata(toscaMainServiceDefinition, serviceReqDetails, service, vnfFile, status); + validateServiceNodeTemplateMetadata(toscaMainServiceDefinition, componentInstanceDefinition, resourceReqDetails, resource, vnfFile, status); + validateServiceMetadataUsingParser(fdntCsarHelper, serviceReqDetails, service, vnfFile, status); + validateServiceNodeTemplateMetadataUsingParser(fdntCsarHelper, resourceReqDetails, resource, componentInstanceDefinition, vnfFile, status); + validateResourceInputs(toscaMainAmdocsDefinition, toscaMainVfDefinition, vnfFile, status); + validateServiceInputs(toscaExpectedMainServiceDefinition, toscaMainServiceDefinition, vnfFile, status); + validateServiceInputsUsingParser(fdntCsarHelper, toscaExpectedMainServiceDefinition, vnfFile, status); + + Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject = createExpectedToscaServiceGroupsDefinitionObject(resource, service, listTypeHeatMetaDefinition); + validateServiceModuleMetadata(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition, vnfFile, status); + validateServiceModuleProperty(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition, vnfFile, status); + validateServiceModuleMetadataUsingParser(fdntCsarHelper, expectedToscaServiceGroupsDefinitionObject, vnfFile, status); + validateServiceModulePropertyUsingParser(fdntCsarHelper, expectedToscaServiceGroupsDefinitionObject, vnfFile, status); + + if (status.contains(false)) { + SetupCDTest.getExtendTest().log(Status.FAIL, "Summary: tosca validation test failed with zip file " + vnfFile); + assertFalse(true); + } + } - Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject = createExpectedToscaServiceGroupsDefinitionObject(resource, service, listTypeHeatMetaDefinition); - status = validateServiceModuleMetadata(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition, vnfFile, status); - status = validateServiceModuleProperty(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition, vnfFile, status); - status = validateServiceModuleMetadataUsingParser(fdntCsarHelper, expectedToscaServiceGroupsDefinitionObject, vnfFile, status); - status = validateServiceModulePropertyUsingParser(fdntCsarHelper, expectedToscaServiceGroupsDefinitionObject, vnfFile, status); - if(status.contains(false)){ - SetupCDTest.getExtendTest().log(Status.FAIL, "Summary: tosca validation test failed with zip file " + vnfFile); - Assert.assertFalse(true); - } - } + @DataProvider(name = "toscaValidationTest", parallel = true) + public static Object[][] dataProviderForSpecificResourceType() { + return new Object[][]{ + {"networkModel", ResourceTypeEnum.PNF, GENERIC_PNF}, + {"collectorResourceModel", ResourceTypeEnum.CR, GENERIC_CR}, + }; + } - @Test() - public void NetworkModel() throws Exception{ + @Test(dataProvider = "toscaValidationTest") + public void validateSpecificResourceType(String type, ResourceTypeEnum resourceType, String genericPropName) throws Exception { //--------------------------GENERAL-------------------------------- - String vnfFile = "networkModel"; - setLog(vnfFile); - List<Boolean> status = new ArrayList<>(); - ISdcCsarHelper fdntCsarHelper; - ToscaDefinition toscaMainAmdocsDefinition = new ToscaDefinition(); - File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); + String vnfFile = type; + setLog(vnfFile); + List<Boolean> status = new ArrayList<>(); + ISdcCsarHelper fdntCsarHelper; + ToscaDefinition expectedToscaMainDefinition = new ToscaDefinition(); + File filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); // filesFolder = new File(SetupCDTest.getWindowTest().getDownloadDirectory()); - ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, user); - toscaMainAmdocsDefinition = addGenericPropertiesToToscaDefinitionObject(toscaMainAmdocsDefinition, GENERIC_PNF); - ToscaDefinition toscaExpectedMainServiceDefinition = new ToscaDefinition(toscaMainAmdocsDefinition); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(resourceType, user); + expectedToscaMainDefinition = addGenericPropertiesToToscaDefinitionObject(expectedToscaMainDefinition, genericPropName); + ToscaDefinition toscaExpectedMainServiceDefinition = new ToscaDefinition(expectedToscaMainDefinition); //--------------------------VF-------------------------------- - Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceReqDetails,UserRoleEnum.DESIGNER,true).left().value(); - resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + Resource resource = AtomicOperationUtils.createResourceByResourceDetails(resourceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - ToscaDefinition toscaMainVfDefinition = downloadAndGetToscaMainYamlObjectApi(resource, filesFolder); + ToscaDefinition toscaMainVfDefinition = downloadAndGetToscaMainYamlObjectApi(resource, filesFolder); //--------------------------SERVICE-------------------------------- - ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); - Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); - ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); //--------------------------getProperties set values and declare-------------------- - Component componentObject = AtomicOperationUtils.getComponentObject(service, UserRoleEnum.DESIGNER); - Map<String, List<ComponentInstanceInput>> componentInstancesInputs = componentObject.getComponentInstancesInputs(); - setValuesToPropertiesList(componentInstancesInputs, toscaExpectedMainServiceDefinition); - PropertyRestUtils.declareProporties(componentObject, componentInstancesInputs, user); + Component componentObject = AtomicOperationUtils.getComponentObject(service, UserRoleEnum.DESIGNER); + Map<String, List<ComponentInstanceInput>> componentInstancesInputs = componentObject.getComponentInstancesInputs(); + setValuesToPropertiesList(componentInstancesInputs, toscaExpectedMainServiceDefinition); + PropertyRestUtils.declareProporties(componentObject, componentInstancesInputs, user); - service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - File ServiceCsarFileName = new File(File.separator + "ServiceCsar_" + ElementFactory.generateUUIDforSufix() + ".csar"); - OnboardingUtillViaApis.downloadToscaCsarToDirectory(service, new File(filesFolder.getPath() + ServiceCsarFileName)); - ToscaDefinition toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + ServiceCsarFileName)); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + File ServiceCsarFileName = new File(File.separator + "ServiceCsar_" + ElementFactory.generateUUIDforSufix() + ".csar"); + OnboardingUtillViaApis.downloadToscaCsarToDirectory(service, new File(filesFolder.getPath() + ServiceCsarFileName)); + ToscaDefinition toscaMainServiceDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + ServiceCsarFileName)); //--------------------------initialization of Tosca Parser-------------------------------- - fdntCsarHelper = initSdcCsarHelper(ServiceCsarFileName, filesFolder); + fdntCsarHelper = initSdcCsarHelper(ServiceCsarFileName, filesFolder); //---------------------------TESTS-------------------------------------------------- - status = validateVfMetadata(toscaMainAmdocsDefinition, toscaMainVfDefinition, resourceReqDetails, resource, vnfFile, status); - status = validateResourceNodeTemplateMetadata(toscaMainVfDefinition, resource, vnfFile, status); - status = validateServiceMetadata(toscaMainServiceDefinition, serviceReqDetails, service, vnfFile, status); - status = validateServiceNodeTemplateMetadata(toscaMainServiceDefinition, componentInstanceDefinition, resourceReqDetails, resource, vnfFile, status); - status = validateServiceMetadataUsingParser(fdntCsarHelper, serviceReqDetails, service, vnfFile, status); - status = validateServiceNodeTemplateMetadataUsingParser(fdntCsarHelper, resourceReqDetails, resource, componentInstanceDefinition, vnfFile, status); - status = validateResourceInputs(toscaMainAmdocsDefinition, toscaMainVfDefinition, vnfFile, status); - status = validateServiceInputs(toscaExpectedMainServiceDefinition, toscaMainServiceDefinition, vnfFile, status); - status = validateServiceInputsUsingParser(fdntCsarHelper, toscaExpectedMainServiceDefinition, vnfFile, status); + validateVfMetadata(expectedToscaMainDefinition, toscaMainVfDefinition, resourceReqDetails, resource, vnfFile, status); + validateResourceNodeTemplateMetadata(toscaMainVfDefinition, resource, vnfFile, status); + validateServiceMetadata(toscaMainServiceDefinition, serviceReqDetails, service, vnfFile, status); + validateServiceNodeTemplateMetadata(toscaMainServiceDefinition, componentInstanceDefinition, resourceReqDetails, resource, vnfFile, status); + validateServiceMetadataUsingParser(fdntCsarHelper, serviceReqDetails, service, vnfFile, status); + validateServiceNodeTemplateMetadataUsingParser(fdntCsarHelper, resourceReqDetails, resource, componentInstanceDefinition, vnfFile, status); + validateResourceInputs(expectedToscaMainDefinition, toscaMainVfDefinition, vnfFile, status); + validateServiceInputs(toscaExpectedMainServiceDefinition, toscaMainServiceDefinition, vnfFile, status); + validateServiceInputsUsingParser(fdntCsarHelper, toscaExpectedMainServiceDefinition, vnfFile, status); + + if (status.contains(false)) { + SetupCDTest.getExtendTest().log(Status.FAIL, "Summary: tosca validation test failed with zip file " + vnfFile); + assertFalse(true); + } + } - if(status.contains(false)){ - SetupCDTest.getExtendTest().log(Status.FAIL, "Summary: tosca validation test failed with zip file " + vnfFile); - Assert.assertFalse(true); - } - } - - /**The method set values to toscaDefinition object service level only, to resource level should put instead of setDefault --> setValue - * inputs.get(componentInstanceInput.getName()).setValue(randomString); - * @param componentInstancesInputs - * @param toscaDefinition - */ - private void setValuesToPropertiesList(Map<String, List<ComponentInstanceInput>> componentInstancesInputs, ToscaDefinition toscaDefinition) { - for(Map.Entry<String, List<ComponentInstanceInput>> entry : componentInstancesInputs.entrySet()) { - List<ComponentInstanceInput> value = entry.getValue(); - String[] names = entry.getKey().split("\\."); - String expectedServiceInputPrefix = null; - Map<String, ToscaInputsTopologyTemplateDefinition> inputs = toscaDefinition.getTopology_template().getInputs(); - if(names.length>0) { - expectedServiceInputPrefix = names[names.length - 1] + "_"; - } - for (ComponentInstanceInput componentInstanceInput :value) { - - - String type = componentInstanceInput.getType(); - List<String> myList = new ArrayList<String>(); - myList.add("cbf8049e-69e8-48c3-a06f-255634391403"); - if (type.equals("string")) { - String randomString = getRandomString(); - componentInstanceInput.setValue(randomString); - inputs.get(componentInstanceInput.getName()).setDefault(randomString); - - } - else if (type.equals("integer") ) { - int randomInteger = getRandomInteger(); - componentInstanceInput.setValue(Integer.toString(randomInteger)); - inputs.get(componentInstanceInput.getName()).setDefault(randomInteger); - } - else if (type.equals("float") ){ - componentInstanceInput.setValue("5.5"); - inputs.get(componentInstanceInput.getName()).setDefault("5.5"); - - } - else if (type.equals("boolean") ){ - componentInstanceInput.setValue("true"); - inputs.get(componentInstanceInput.getName()).setDefault("true"); - } - else if (type.equals("list") ){ - String myListofStrings = myList.toString(); - componentInstanceInput.setValue(myListofStrings); - inputs.get(componentInstanceInput.getName()).setDefault(myListofStrings); - } - else if (type.equals("json") ){ - String myJson = "{\"firstParam\":\"my First Param Value\",\"secondParam\":\"my Second Param Value\",\"numberParam\":666}"; - componentInstanceInput.setValue(myJson); - inputs.get(componentInstanceInput.getName()).setDefault(myJson); - } - else if (type.equals("comma_delimited_list") ){ - String commaDelimitedList = "[\"one\", \"two\"]"; - componentInstanceInput.setValue(commaDelimitedList); - inputs.get(componentInstanceInput.getName()).setDefault(commaDelimitedList); - } - - String expectedServiceInputName = expectedServiceInputPrefix + componentInstanceInput.getName(); - ToscaInputsTopologyTemplateDefinition oldInput = inputs.get(componentInstanceInput.getName()); - inputs.put(expectedServiceInputName, oldInput); - inputs.remove(componentInstanceInput.getName()); - - } - - } - } - - protected String getRandomString() { - String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; - StringBuilder salt = new StringBuilder(); - Random rnd = new Random(); - while (salt.length() < 18) { // length of the random string. - int index = (int) (rnd.nextFloat() * SALTCHARS.length()); - salt.append(SALTCHARS.charAt(index)); - } - String strValue = salt.toString(); - return strValue; + /** + * The method set values to toscaDefinition object service level only, to resource level should put instead of setDefault --> setValue + * inputs.get(componentInstanceInput.getName()).setValue(randomString); + * + * @param componentInstancesInputs list of componentInstancesInputs + * @param toscaDefinition + */ + private void setValuesToPropertiesList(Map<String, List<ComponentInstanceInput>> componentInstancesInputs, ToscaDefinition toscaDefinition) { + for (Map.Entry<String, List<ComponentInstanceInput>> entry : componentInstancesInputs.entrySet()) { + List<ComponentInstanceInput> value = entry.getValue(); + String[] names = entry.getKey().split("\\."); + String expectedServiceInputPrefix = null; + Map<String, ToscaInputsTopologyTemplateDefinition> inputs = toscaDefinition.getTopology_template().getInputs(); + if (names.length > 0) { + expectedServiceInputPrefix = names[names.length - 1] + "_"; + } + for (ComponentInstanceInput componentInstanceInput : value) { + + + String type = componentInstanceInput.getType(); + List<String> myList = new ArrayList<>(); + myList.add("cbf8049e-69e8-48c3-a06f-255634391403"); + switch (type) { + case "string": + String randomString = getRandomString(); + componentInstanceInput.setValue(randomString); + inputs.get(componentInstanceInput.getName()).setDefault(randomString); + + break; + case "integer": + int randomInteger = getRandomInteger(); + componentInstanceInput.setValue(Integer.toString(randomInteger)); + inputs.get(componentInstanceInput.getName()).setDefault(randomInteger); + break; + case "float": + componentInstanceInput.setValue("5.5"); + inputs.get(componentInstanceInput.getName()).setDefault("5.5"); + + break; + case "boolean": + componentInstanceInput.setValue("true"); + inputs.get(componentInstanceInput.getName()).setDefault("true"); + break; + case "list": + String myListofStrings = myList.toString(); + componentInstanceInput.setValue(myListofStrings); + inputs.get(componentInstanceInput.getName()).setDefault(myListofStrings); + break; + case "json": + String myJson = "{\"firstParam\":\"my First Param Value\",\"secondParam\":\"my Second Param Value\",\"numberParam\":666}"; + componentInstanceInput.setValue(myJson); + inputs.get(componentInstanceInput.getName()).setDefault(myJson); + break; + case "comma_delimited_list": + String commaDelimitedList = "[\"one\", \"two\"]"; + componentInstanceInput.setValue(commaDelimitedList); + inputs.get(componentInstanceInput.getName()).setDefault(commaDelimitedList); + break; + default: + break; + } + + String expectedServiceInputName = expectedServiceInputPrefix + componentInstanceInput.getName(); + ToscaInputsTopologyTemplateDefinition oldInput = inputs.get(componentInstanceInput.getName()); + inputs.put(expectedServiceInputName, oldInput); + inputs.remove(componentInstanceInput.getName()); + + } + + } + } - } + protected String getRandomString() { + String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + StringBuilder salt = new StringBuilder(); + Random rnd = new Random(); + while (salt.length() < 18) { // length of the random string. + int index = (int) (rnd.nextFloat() * SALTCHARS.length()); + salt.append(SALTCHARS.charAt(index)); + } + String strValue = salt.toString(); + return strValue; - protected int getRandomInteger() { - Random r = new Random(); - int Low = 10; - int High = 100; - int integerValue = r.nextInt(High - Low) + Low; - return integerValue; - } + } + + protected int getRandomInteger() { + Random r = new Random(); + int low = 10; + int high = 100; + int integerValue = r.nextInt(high - low) + low; + return integerValue; + } - //--------------------------Metadata verification-------------------------------- + //--------------------------Metadata verification-------------------------------- //--------------------------Resource-------------------------------- - - public List<Boolean> validateVfMetadata(ToscaDefinition toscaMainAmdocsDefinition, ToscaDefinition toscaMainVfDefinition, ResourceReqDetails resourceReqDetails,Resource resource, String vnfFile, List<Boolean> status) throws Exception{ - reportStartTestPrint("validateVfMetadata", vnfFile); - //add resource metadata to expected object - toscaMainAmdocsDefinition = addAndGenerateResourceMetadataToExpectedObject(toscaMainAmdocsDefinition, resourceReqDetails, resource); - Either<Boolean,Map<String,Object>> resourceToscaMetadataValidator = ToscaValidation.resourceToscaMetadataValidator(toscaMainAmdocsDefinition, toscaMainVfDefinition); - if(resourceToscaMetadataValidator.isRight()) - status.add(false); - return status; - } - - public List<Boolean> validateResourceNodeTemplateMetadata(ToscaDefinition toscaMainVfDefinition, Resource resource, String vnfFile, List<Boolean> status) throws Exception{ - reportStartTestPrint("validateResourceNodeTemplateMetadata", vnfFile); - Map<String, Map<String, String>> generateReosurceNodeTemplateMetadataToExpectedObject = generateResourceNodeTemplateMetadataToExpectedObject(resource); - Boolean resourceToscaMetadataValidator = ToscaValidation.resourceToscaNodeTemplateMetadataValidator(generateReosurceNodeTemplateMetadataToExpectedObject, toscaMainVfDefinition); - if(! resourceToscaMetadataValidator) - status.add(false); - return status; - } - -//--------------------------Service-------------------------------- - public List<Boolean> validateServiceMetadata(ToscaDefinition toscaMainServiceDefinition, ServiceReqDetails serviceReqDetails, Service service, String vnfFile, List<Boolean> status) throws Exception{ - reportStartTestPrint("validateServiceMetadata", vnfFile); - Map<String, String> generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service); - Either<Boolean,Map<String, Object>> serviceToscaMetadataValidator = ToscaValidation.serviceToscaMetadataValidator(generateServiceMetadataToExpectedObject, toscaMainServiceDefinition); - if(serviceToscaMetadataValidator.isRight()) - status.add(false); - return status; - } - - - public List<Boolean> validateServiceNodeTemplateMetadata(ToscaDefinition toscaMainServiceDefinition, ComponentInstance componentInstanceDefinition, ResourceReqDetails resourceReqDetails, Resource resource, String vnfFile, List<Boolean> status) throws Exception{ - reportStartTestPrint("validateServiceNodeTemplateMetadata", vnfFile); - Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject = generateServiceNodeTemplateMetadataToExpectedObject(resourceReqDetails, resource, componentInstanceDefinition); - Either<Boolean,Map<String, Object>> serviceToscaMetadataValidator = ToscaValidation.componentToscaNodeTemplateMetadataValidator(generateServiceNodeTemplateMetadataToExpectedObject, toscaMainServiceDefinition, componentInstanceDefinition.getName(), ComponentTypeEnum.SERVICE, componentInstanceDefinition.getName()); - if(serviceToscaMetadataValidator.isRight()) - status.add(false); - return status; - } - -//--------------------------Service verification against Pavel Parser-------------------------------- - public List<Boolean> validateServiceMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, ServiceReqDetails serviceReqDetails, Service service, String vnfFile, List<Boolean> status) throws Exception{ - if(fdntCsarHelper == null){ - reportSkipTestPrint("validateServiceMetadataUsingParser", status); - }else{ - reportStartTestPrint("validateServiceMetadataUsingParser", vnfFile); - Map<String, String> generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service); - Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata(); - Either<Boolean,Map<String, Object>> serviceToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceMetadataToExpectedObject, serviceMetadata); - if(serviceToscaMetadataValidatorAgainstParser.isRight()) - status.add(false); - } - return status; - } - - public List<Boolean> validateServiceNodeTemplateMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, ResourceReqDetails resourceReqDetails,Resource resource, ComponentInstance componentInstanceDefinition, String vnfFile, List<Boolean> status) throws Exception{ - if(fdntCsarHelper == null){ - reportSkipTestPrint("validateServiceNodeTemplateMetadataUsingParser", status); - }else{ - reportStartTestPrint("validateServiceNodeTemplateMetadataUsingParser", vnfFile); - Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject = generateServiceNodeTemplateMetadataToExpectedObject(resourceReqDetails, resource, componentInstanceDefinition); - List<NodeTemplate> serviceNodeTemplates = fdntCsarHelper.getServiceNodeTemplates(); - Metadata serviceNodeTemplateMetadata = serviceNodeTemplates.get(0).getMetaData(); - Either<Boolean,Map<String, Object>> serviceNodeTemplateToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceNodeTemplateMetadataToExpectedObject, serviceNodeTemplateMetadata); - if(serviceNodeTemplateToscaMetadataValidatorAgainstParser.isRight()) - status.add(false); - } - return status; - } - - //--------------------------Input verification-------------------------------- - - //--------------------------Resource-------------------------------- - public List<Boolean> validateResourceInputs(ToscaDefinition toscaMainAmdocsDefinition, ToscaDefinition toscaMainVfDefinition, String vnfFile, List<Boolean> status) throws Exception{ - reportStartTestPrint("validateResourceInputs", vnfFile); - Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaMainAmdocsDefinition.getTopology_template().getInputs(); - Map<String, ToscaInputsTopologyTemplateDefinition> actualInputsMap = toscaMainVfDefinition.getTopology_template().getInputs(); - Either<Boolean,Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidator(expectedInputsMap, actualInputsMap); - if(toscaInputsValidator.isRight()) - status.add(false); - return status; - } - - //--------------------------Service-------------------------------- - - public List<Boolean> validateServiceInputs(ToscaDefinition toscaExpectedMainServiceDefinition, ToscaDefinition toscaMainServiceDefinition, String vnfFile, List<Boolean> status) throws Exception{ - reportStartTestPrint("validateServiceInputs", vnfFile); - Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaExpectedMainServiceDefinition.getTopology_template().getInputs(); - Map<String, ToscaInputsTopologyTemplateDefinition> actualInputsMap = toscaMainServiceDefinition.getTopology_template().getInputs(); - Either<Boolean,Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidator(expectedInputsMap, actualInputsMap); - if(toscaInputsValidator.isRight()) - status.add(false); - return status; - } - - public List<Boolean> validateServiceModuleMetadata(Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, ToscaDefinition toscaMainServiceDefinition, String vnfFile, List<Boolean> status) { - reportStartTestPrint("validateServiceModuleMetadata", vnfFile); - - Either<Boolean,Map<String, Object>> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupMetadataValidator(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition); - if(toscaServiceModuleMetadataValidator.isRight()) - status.add(false); - return status; - } - - public List<Boolean> validateServiceModuleProperty(Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, ToscaDefinition toscaMainServiceDefinition, String vnfFile, List<Boolean> status) { - reportStartTestPrint("validateServiceModuleProperty", vnfFile); - - Either<Boolean,Map<String, Object>> toscaServiceModulePropertyValidator = ToscaValidation.serviceToscaGroupPropertyValidator(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition); - if(toscaServiceModulePropertyValidator.isRight()) - status.add(false); - return status; - } - - //--------------------------Service verification against Pavel Parser-------------------------------- - public List<Boolean> validateServiceInputsUsingParser(ISdcCsarHelper fdntCsarHelper, ToscaDefinition toscaExpectedMainServiceDefinition, String vnfFile, List<Boolean> status) throws Exception{ - if(fdntCsarHelper == null){ - reportSkipTestPrint("validateServiceInputsUsingParser", status); - }else{ - reportStartTestPrint("validateServiceInputsUsingParser", vnfFile); - Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaExpectedMainServiceDefinition.getTopology_template().getInputs(); - Either<Boolean,Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidatorAgainstParser(expectedInputsMap, fdntCsarHelper); - if(toscaInputsValidator.isRight()) - status.add(false); - } - return status; - } - - public List<Boolean> validateServiceModuleMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, String vnfFile, List<Boolean> status) { - reportStartTestPrint("validateServiceModuleMetadataUsingParser", vnfFile); - String customizationUUID = fdntCsarHelper.getServiceNodeTemplates().get(0).getMetaData().getValue("customizationUUID"); - List<Group> actualGroups = fdntCsarHelper.getVfModulesByVf(customizationUUID); - Either<Boolean,Map<String, Object>> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupMetadataValidatorUsingParser(expectedToscaServiceGroupsDefinitionObject, actualGroups); - if(toscaServiceModuleMetadataValidator.isRight()) - status.add(false); - return status; - } - - public List<Boolean> validateServiceModulePropertyUsingParser(ISdcCsarHelper fdntCsarHelper, Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, String vnfFile, List<Boolean> status) { - reportStartTestPrint("validateServiceModuleMetadataUsingParser", vnfFile); - String customizationUUID = fdntCsarHelper.getServiceNodeTemplates().get(0).getMetaData().getValue("customizationUUID"); - List<Group> actualGroups = fdntCsarHelper.getVfModulesByVf(customizationUUID); - Either<Boolean,Map<String, Object>> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupPropertyValidatorUsingParser(expectedToscaServiceGroupsDefinitionObject, actualGroups); - if(toscaServiceModuleMetadataValidator.isRight()) - status.add(false); - return status; - } - - private Map<String, ToscaGroupsTopologyTemplateDefinition> createExpectedToscaServiceGroupsDefinitionObject(Resource resource, Service service, List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition) { - Map<String, ToscaGroupsTopologyTemplateDefinition> toscaGroupsTopologyTemplateDefinitionMap = new HashMap<>(); - - for (TypeHeatMetaDefinition moduleType : listTypeHeatMetaDefinition) { - if (!moduleType.getTypeName().equals("artifacts")) { - for(GroupHeatMetaDefinition module : moduleType.getGroupHeatMetaDefinition()){ - ToscaGroupsTopologyTemplateDefinition toscaGroupsTopologyTemplateDefinition = new ToscaGroupsTopologyTemplateDefinition(); - String resourceModuleName = buildResourceModuleName(resource, module.getGroupName()); - ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition = setGroupMetadataFromResourceObject(resourceModuleName, resource); - if(!toscaServiceGroupsMetadataDefinition.equals("")){ - String serviceModuleName = buildServiceModuleName(service.getComponentInstances().get(0).getNormalizedName(), toscaServiceGroupsMetadataDefinition.getVfModuleModelName()); - toscaServiceGroupsMetadataDefinition = setGroupMetadataFromServiceObject(toscaServiceGroupsMetadataDefinition, serviceModuleName, service); - toscaGroupsTopologyTemplateDefinition.setMetadata(toscaServiceGroupsMetadataDefinition); - ToscaGroupPropertyDefinition toscaGroupPropertyDefinition = setGroupProperty(module); - toscaGroupsTopologyTemplateDefinition.setProperties(toscaGroupPropertyDefinition); - toscaGroupsTopologyTemplateDefinitionMap.put(serviceModuleName,toscaGroupsTopologyTemplateDefinition); - - }else{ - getExtendTest().log(Status.FAIL, "module name [" + module.getGroupName() + "] didn't represent in resource"); - } - } - } - } - return toscaGroupsTopologyTemplateDefinitionMap; - - } - - private ToscaGroupPropertyDefinition setGroupProperty(GroupHeatMetaDefinition module) { - ToscaGroupPropertyDefinition toscaGroupPropertyDefinition = new ToscaGroupPropertyDefinition(); - toscaGroupPropertyDefinition.setVf_module_label(module.getGroupName()); - Boolean isBase = module.getPropertyHeatMetaDefinition().getValue(); - if(isBase){ - toscaGroupPropertyDefinition.setInitial_count("1"); - toscaGroupPropertyDefinition.setMin_vf_module_instances("1"); - toscaGroupPropertyDefinition.setMax_vf_module_instances("1"); - toscaGroupPropertyDefinition.setVf_module_type("Base"); - }else{ - toscaGroupPropertyDefinition.setInitial_count("0"); - toscaGroupPropertyDefinition.setMin_vf_module_instances("0"); - toscaGroupPropertyDefinition.setMax_vf_module_instances(null); - toscaGroupPropertyDefinition.setVf_module_type("Expansion"); - } - toscaGroupPropertyDefinition.setAvailability_zone_count(null); - toscaGroupPropertyDefinition.setVfc_list(null); - toscaGroupPropertyDefinition.setVf_module_description(null); - toscaGroupPropertyDefinition.setVolume_group(isVolumeGroup(module)); - - return toscaGroupPropertyDefinition; - } - - private String isVolumeGroup(GroupHeatMetaDefinition module) { - String isVolumeGroup = "false"; - for( HeatMetaFirstLevelDefinition artifactList : module.getArtifactList()){ - if(artifactList.getType().equals(ArtifactTypeEnum.HEAT_VOL.getType())){ - isVolumeGroup = "true"; - return isVolumeGroup; - } - } - return isVolumeGroup; - } - - private Map<String,ToscaServiceGroupsMetadataDefinition> createExpectedToscaServiceGroupsPropertyDefinitionObject(Resource resource, Service service, List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition) { - - Map<String,ToscaServiceGroupsMetadataDefinition> toscaServiceGroupsMetadataDefinitionMap = new HashMap<>(); - for (TypeHeatMetaDefinition moduleType : listTypeHeatMetaDefinition) { - Map<String, String> groupProperty = new HashMap<>(); - - ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition = new ToscaServiceGroupsMetadataDefinition(); - for(GroupHeatMetaDefinition module : moduleType.getGroupHeatMetaDefinition()){ - String resourceModuleName = buildResourceModuleName(resource, module.getGroupName()); - toscaServiceGroupsMetadataDefinition = setGroupMetadataFromResourceObject(resourceModuleName, resource); - if(!toscaServiceGroupsMetadataDefinition.equals("")){ - String serviceModuleName = buildServiceModuleName(service.getComponentInstances().get(0).getNormalizedName(), toscaServiceGroupsMetadataDefinition.getVfModuleModelName()); - toscaServiceGroupsMetadataDefinition = setGroupMetadataFromServiceObject(toscaServiceGroupsMetadataDefinition, serviceModuleName, service); - toscaServiceGroupsMetadataDefinitionMap.put(serviceModuleName, toscaServiceGroupsMetadataDefinition); - }else{ - getExtendTest().log(Status.FAIL, "module name [" + module.getGroupName() + "] didn't represent in resource"); - } - } - } - return toscaServiceGroupsMetadataDefinitionMap; - } + public List<Boolean> validateVfMetadata(ToscaDefinition toscaMainAmdocsDefinition, ToscaDefinition toscaMainVfDefinition, ResourceReqDetails resourceReqDetails, Resource resource, String vnfFile, List<Boolean> status) throws Exception { + reportStartTestPrint("validateVfMetadata", vnfFile); + //add resource metadata to expected object + toscaMainAmdocsDefinition = addAndGenerateResourceMetadataToExpectedObject(toscaMainAmdocsDefinition, resourceReqDetails, resource); + Either<Boolean, Map<String, Object>> resourceToscaMetadataValidator = ToscaValidation.resourceToscaMetadataValidator(toscaMainAmdocsDefinition, toscaMainVfDefinition); + if (resourceToscaMetadataValidator.isRight()) + status.add(false); + return status; + } - private ToscaServiceGroupsMetadataDefinition setGroupMetadataFromServiceObject(ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition, String serviceModuleName, Service service) { - for (GroupInstance groupInstance : service.getComponentInstances().get(0).getGroupInstances()) { - if (groupInstance.getName().equals(serviceModuleName)) { - toscaServiceGroupsMetadataDefinition.setVfModuleModelCustomizationUUID(groupInstance.getCustomizationUUID()); - return toscaServiceGroupsMetadataDefinition; - } - } - return toscaServiceGroupsMetadataDefinition; - } - - private ToscaServiceGroupsMetadataDefinition setGroupMetadataFromResourceObject(String resourceModuleName, Resource resource) { - ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition = new ToscaServiceGroupsMetadataDefinition(); - for (GroupDefinition group : resource.getGroups()) { - if (group.getName().contains(resourceModuleName)) { - toscaServiceGroupsMetadataDefinition.setVfModuleModelName(group.getName()); - toscaServiceGroupsMetadataDefinition.setVfModuleModelInvariantUUID(group.getInvariantUUID()); - toscaServiceGroupsMetadataDefinition.setVfModuleModelUUID(group.getGroupUUID()); - toscaServiceGroupsMetadataDefinition.setVfModuleModelVersion(group.getVersion()); - return toscaServiceGroupsMetadataDefinition; - } - } - return toscaServiceGroupsMetadataDefinition; - } + public List<Boolean> validateResourceNodeTemplateMetadata(ToscaDefinition toscaMainVfDefinition, Resource resource, String vnfFile, List<Boolean> status) throws Exception { + reportStartTestPrint("validateResourceNodeTemplateMetadata", vnfFile); + Map<String, Map<String, String>> generateReosurceNodeTemplateMetadataToExpectedObject = generateResourceNodeTemplateMetadataToExpectedObject(resource); + Boolean resourceToscaMetadataValidator = ToscaValidation.resourceToscaNodeTemplateMetadataValidator(generateReosurceNodeTemplateMetadataToExpectedObject, toscaMainVfDefinition); + if (!resourceToscaMetadataValidator) + status.add(false); + return status; + } + + //--------------------------Service-------------------------------- + public List<Boolean> validateServiceMetadata(ToscaDefinition toscaMainServiceDefinition, ServiceReqDetails serviceReqDetails, Service service, String vnfFile, List<Boolean> status) throws Exception { + reportStartTestPrint("validateServiceMetadata", vnfFile); + Map<String, String> generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service); + Either<Boolean, Map<String, Object>> serviceToscaMetadataValidator = ToscaValidation.serviceToscaMetadataValidator(generateServiceMetadataToExpectedObject, toscaMainServiceDefinition); + if (serviceToscaMetadataValidator.isRight()) + status.add(false); + return status; + } + + + public List<Boolean> validateServiceNodeTemplateMetadata(ToscaDefinition toscaMainServiceDefinition, ComponentInstance componentInstanceDefinition, ResourceReqDetails resourceReqDetails, Resource resource, String vnfFile, List<Boolean> status) throws Exception { + reportStartTestPrint("validateServiceNodeTemplateMetadata", vnfFile); + Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject = generateServiceNodeTemplateMetadataToExpectedObject(resourceReqDetails, resource, componentInstanceDefinition); + Either<Boolean, Map<String, Object>> serviceToscaMetadataValidator = ToscaValidation.componentToscaNodeTemplateMetadataValidator(generateServiceNodeTemplateMetadataToExpectedObject, toscaMainServiceDefinition, componentInstanceDefinition.getName(), ComponentTypeEnum.SERVICE, componentInstanceDefinition.getName()); + if (serviceToscaMetadataValidator.isRight()) + status.add(false); + return status; + } + + private List<Boolean> validateVfModuleJsonFile(Map<String, VfModuleDefinition> expectedVfModulesDefinitionObject, Service service, String resInstUniqueId, String vnfFile, List<Boolean> status) throws Exception { + reportStartTestPrint("validateVfModuleJsonFile", vnfFile); + String artifactUniqueId = null; + for (ComponentInstance inst : service.getComponentInstances()) { + if (inst.getUniqueId().equals(resInstUniqueId)) { + artifactUniqueId = inst.getDeploymentArtifacts().get("vfModulesMetadata").getUniqueId(); + break; + } + } + if (artifactUniqueId == null) { + SetupCDTest.getExtendTest().log(Status.ERROR, "validateVfModuleJsonFile verification failed, artifact vfModulesMetadata not found"); + status.add(false); + return status; + } + RestResponse restResponse = ArtifactRestUtils.downloadResourceInstanceArtifact(service.getUniqueId(), resInstUniqueId, user, artifactUniqueId); + String artifactPayload = ArtifactRestUtils.getDecodedArtifactPayloadFromResponse(restResponse); + Map<String, VfModuleDefinition> actualVfModulesDefinitionObject = ResponseParser.convertVfModuleJsonResponseToJavaObject(artifactPayload); + Either<Boolean, Map<String, Object>> vfModuleJsonFileValidator = ToscaValidation.vfModuleJsonFileValidator(expectedVfModulesDefinitionObject, actualVfModulesDefinitionObject); + if (vfModuleJsonFileValidator.isRight()) + status.add(false); + return status; + } + + //--------------------------Service verification against Pavel Parser-------------------------------- + public List<Boolean> validateServiceMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, ServiceReqDetails serviceReqDetails, Service service, String vnfFile, List<Boolean> status) throws Exception { + if (fdntCsarHelper == null) { + reportSkipTestPrint("validateServiceMetadataUsingParser", status); + } else { + reportStartTestPrint("validateServiceMetadataUsingParser", vnfFile); + Map<String, String> generateServiceMetadataToExpectedObject = generateServiceMetadataToExpectedObject(serviceReqDetails, service); + Metadata serviceMetadata = fdntCsarHelper.getServiceMetadata(); + Either<Boolean, Map<String, Object>> serviceToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceMetadataToExpectedObject, serviceMetadata); + if (serviceToscaMetadataValidatorAgainstParser.isRight()) + status.add(false); + } + return status; + } + + public List<Boolean> validateServiceNodeTemplateMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, ResourceReqDetails resourceReqDetails, Resource resource, ComponentInstance componentInstanceDefinition, String vnfFile, List<Boolean> status) throws Exception { + if (fdntCsarHelper == null) { + reportSkipTestPrint("validateServiceNodeTemplateMetadataUsingParser", status); + } else { + reportStartTestPrint("validateServiceNodeTemplateMetadataUsingParser", vnfFile); + Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject = generateServiceNodeTemplateMetadataToExpectedObject(resourceReqDetails, resource, componentInstanceDefinition); + List<NodeTemplate> serviceNodeTemplates = fdntCsarHelper.getServiceNodeTemplates(); + Metadata serviceNodeTemplateMetadata = serviceNodeTemplates.get(0).getMetaData(); + Either<Boolean, Map<String, Object>> serviceNodeTemplateToscaMetadataValidatorAgainstParser = ToscaValidation.serviceToscaMetadataValidatorAgainstParser(generateServiceNodeTemplateMetadataToExpectedObject, serviceNodeTemplateMetadata); + if (serviceNodeTemplateToscaMetadataValidatorAgainstParser.isRight()) + status.add(false); + } + return status; + } + + //--------------------------Input verification-------------------------------- + + //--------------------------Resource-------------------------------- + public List<Boolean> validateResourceInputs(ToscaDefinition toscaMainAmdocsDefinition, ToscaDefinition toscaMainVfDefinition, String vnfFile, List<Boolean> status) throws Exception { + reportStartTestPrint("validateResourceInputs", vnfFile); + Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaMainAmdocsDefinition.getTopology_template().getInputs(); + Map<String, ToscaInputsTopologyTemplateDefinition> actualInputsMap = toscaMainVfDefinition.getTopology_template().getInputs(); + Either<Boolean, Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidator(expectedInputsMap, actualInputsMap); + if (toscaInputsValidator.isRight()) + status.add(false); + return status; + } + + //--------------------------Service-------------------------------- + + public List<Boolean> validateServiceInputs(ToscaDefinition toscaExpectedMainServiceDefinition, ToscaDefinition toscaMainServiceDefinition, String vnfFile, List<Boolean> status) throws Exception { + reportStartTestPrint("validateServiceInputs", vnfFile); + Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaExpectedMainServiceDefinition.getTopology_template().getInputs(); + Map<String, ToscaInputsTopologyTemplateDefinition> actualInputsMap = toscaMainServiceDefinition.getTopology_template().getInputs(); + Either<Boolean, Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidator(expectedInputsMap, actualInputsMap); + if (toscaInputsValidator.isRight()) + status.add(false); + return status; + } + + public List<Boolean> validateServiceModuleMetadata(Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, ToscaDefinition toscaMainServiceDefinition, String vnfFile, List<Boolean> status) { + reportStartTestPrint("validateServiceModuleMetadata", vnfFile); + + Either<Boolean, Map<String, Object>> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupMetadataValidator(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition); + if (toscaServiceModuleMetadataValidator.isRight()) + status.add(false); + return status; + } + + public List<Boolean> validateServiceModuleProperty(Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, ToscaDefinition toscaMainServiceDefinition, String vnfFile, List<Boolean> status) { + reportStartTestPrint("validateServiceModuleProperty", vnfFile); + + Either<Boolean, Map<String, Object>> toscaServiceModulePropertyValidator = ToscaValidation.serviceToscaGroupPropertyValidator(expectedToscaServiceGroupsDefinitionObject, toscaMainServiceDefinition); + if (toscaServiceModulePropertyValidator.isRight()) + status.add(false); + return status; + } + + //--------------------------Service verification against Pavel Parser-------------------------------- + public List<Boolean> validateServiceInputsUsingParser(ISdcCsarHelper fdntCsarHelper, ToscaDefinition toscaExpectedMainServiceDefinition, String vnfFile, List<Boolean> status) throws Exception { + if (fdntCsarHelper == null) { + reportSkipTestPrint("validateServiceInputsUsingParser", status); + } else { + reportStartTestPrint("validateServiceInputsUsingParser", vnfFile); + Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap = toscaExpectedMainServiceDefinition.getTopology_template().getInputs(); + Either<Boolean, Map<String, Object>> toscaInputsValidator = ToscaValidation.toscaInputsValidatorAgainstParser(expectedInputsMap, fdntCsarHelper); + if (toscaInputsValidator.isRight()) + status.add(false); + } + return status; + } + + public List<Boolean> validateServiceModuleMetadataUsingParser(ISdcCsarHelper fdntCsarHelper, Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, String vnfFile, List<Boolean> status) { + reportStartTestPrint("validateServiceModuleMetadataUsingParser", vnfFile); + String customizationUUID = fdntCsarHelper.getServiceNodeTemplates().get(0).getMetaData().getValue("customizationUUID"); + List<Group> actualGroups = fdntCsarHelper.getVfModulesByVf(customizationUUID); + Either<Boolean, Map<String, Object>> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupMetadataValidatorUsingParser(expectedToscaServiceGroupsDefinitionObject, actualGroups); + if (toscaServiceModuleMetadataValidator.isRight()) + status.add(false); + return status; + } + + public List<Boolean> validateServiceModulePropertyUsingParser(ISdcCsarHelper fdntCsarHelper, Map<String, ToscaGroupsTopologyTemplateDefinition> expectedToscaServiceGroupsDefinitionObject, String vnfFile, List<Boolean> status) { + reportStartTestPrint("validateServiceModuleMetadataUsingParser", vnfFile); + String customizationUUID = fdntCsarHelper.getServiceNodeTemplates().get(0).getMetaData().getValue("customizationUUID"); + List<Group> actualGroups = fdntCsarHelper.getVfModulesByVf(customizationUUID); + Either<Boolean, Map<String, Object>> toscaServiceModuleMetadataValidator = ToscaValidation.serviceToscaGroupPropertyValidatorUsingParser(expectedToscaServiceGroupsDefinitionObject, actualGroups); + if (toscaServiceModuleMetadataValidator.isRight()) + status.add(false); + return status; + } + + private Map<String, ToscaGroupsTopologyTemplateDefinition> createExpectedToscaServiceGroupsDefinitionObject(Resource resource, Service service, List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition) { + Map<String, ToscaGroupsTopologyTemplateDefinition> toscaGroupsTopologyTemplateDefinitionMap = new HashMap<>(); + + for (TypeHeatMetaDefinition moduleType : listTypeHeatMetaDefinition) { + if (!moduleType.getTypeName().equals("artifacts")) { + for (GroupHeatMetaDefinition module : moduleType.getGroupHeatMetaDefinition()) { + ToscaGroupsTopologyTemplateDefinition toscaGroupsTopologyTemplateDefinition = new ToscaGroupsTopologyTemplateDefinition(); + String resourceModuleName = buildResourceModuleName(resource, module.getGroupName()); + ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition = setGroupMetadataFromResourceObject(resourceModuleName, resource); + if (!toscaServiceGroupsMetadataDefinition.equals("")) { + String serviceModuleName = buildServiceModuleName(service.getComponentInstances().get(0).getNormalizedName(), toscaServiceGroupsMetadataDefinition.getVfModuleModelName()); + toscaServiceGroupsMetadataDefinition = setGroupMetadataFromServiceObject(toscaServiceGroupsMetadataDefinition, serviceModuleName, service); + toscaGroupsTopologyTemplateDefinition.setMetadata(toscaServiceGroupsMetadataDefinition); + ToscaGroupPropertyDefinition toscaGroupPropertyDefinition = setGroupProperty(module); + toscaGroupsTopologyTemplateDefinition.setProperties(toscaGroupPropertyDefinition); + toscaGroupsTopologyTemplateDefinitionMap.put(serviceModuleName, toscaGroupsTopologyTemplateDefinition); + } else { + getExtendTest().log(Status.FAIL, "module name [" + module.getGroupName() + "] didn't represent in resource"); + } + } + } + } + return toscaGroupsTopologyTemplateDefinitionMap; + + } + + + private Map<String, VfModuleDefinition> createExpectedVfModuleDefinitionObject(Resource resource, Service service, List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition) { + Map<String, VfModuleDefinition> toscaGroupsTopologyTemplateDefinitionMap = new HashMap<>(); + + for (TypeHeatMetaDefinition moduleType : listTypeHeatMetaDefinition) { + if (!moduleType.getTypeName().equals("artifacts")) { + for (GroupHeatMetaDefinition module : moduleType.getGroupHeatMetaDefinition()) { + VfModuleDefinition toscaGroupsTopologyTemplateDefinition = new VfModuleDefinition(); + String resourceModuleName = buildResourceModuleName(resource, module.getGroupName()); + ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition = setGroupMetadataFromResourceObject(resourceModuleName, resource); + if (!toscaServiceGroupsMetadataDefinition.equals("")) { + toscaServiceGroupsMetadataDefinition = setGroupMetadataFromServiceObject(toscaServiceGroupsMetadataDefinition, resourceModuleName, service); + toscaGroupsTopologyTemplateDefinition.setMetadata(toscaServiceGroupsMetadataDefinition); + ToscaGroupPropertyDefinition toscaGroupPropertyDefinition = setGroupProperty(module); + toscaGroupsTopologyTemplateDefinition.setProperties(toscaGroupPropertyDefinition); + toscaGroupsTopologyTemplateDefinition.setArtifacts(getArtifactsUuidListForRI(module, resource, service)); + toscaGroupsTopologyTemplateDefinitionMap.put(toscaServiceGroupsMetadataDefinition.vfModuleModelName, toscaGroupsTopologyTemplateDefinition); + + } else { + getExtendTest().log(Status.FAIL, "module name [" + module.getGroupName() + "] didn't represent in resource"); + } + } + } + } + return toscaGroupsTopologyTemplateDefinitionMap; + + } + + private List<String> getArtifactsUuidListForRI(GroupHeatMetaDefinition module, Resource resource, Service service) { +//TODO check if each heat include its env file + List<String> artifactsUuidList = new ArrayList<>(); + ComponentInstance resourceInstance = null; + for (ComponentInstance componentInstance : service.getComponentInstances()) { + if (componentInstance.getUniqueId().contains(resource.getUniqueId())) { + resourceInstance = componentInstance; + break; + } + } + + Collection<ArtifactDefinition> artifactsDefinitionValues = resourceInstance.getDeploymentArtifacts().values(); + + for (HeatMetaFirstLevelDefinition moduleArtifactDefinition : module.getArtifactList()) { + for (ArtifactDefinition riArtifactDefinition : artifactsDefinitionValues) { + String heatYamlName = moduleArtifactDefinition.getFileName(); + String heatEnvName = heatYamlName.replaceAll("yaml|yml", "env"); + String riArtifactName = riArtifactDefinition.getArtifactName(); + if (riArtifactName.equals(heatYamlName) || riArtifactName.equals(heatEnvName)) { + artifactsUuidList.add(riArtifactDefinition.getArtifactUUID()); + } + } + } + + return artifactsUuidList; + } + + private ToscaGroupPropertyDefinition setGroupProperty(GroupHeatMetaDefinition module) { + ToscaGroupPropertyDefinition toscaGroupPropertyDefinition = new ToscaGroupPropertyDefinition(); + toscaGroupPropertyDefinition.setVf_module_label(module.getGroupName()); + Boolean isBase = module.getPropertyHeatMetaDefinition().getValue(); + if (isBase) { + toscaGroupPropertyDefinition.setInitial_count("1"); + toscaGroupPropertyDefinition.setMin_vf_module_instances("1"); + toscaGroupPropertyDefinition.setMax_vf_module_instances("1"); + toscaGroupPropertyDefinition.setVf_module_type("Base"); + } else { + toscaGroupPropertyDefinition.setInitial_count("0"); + toscaGroupPropertyDefinition.setMin_vf_module_instances("0"); + toscaGroupPropertyDefinition.setMax_vf_module_instances(""); + toscaGroupPropertyDefinition.setVf_module_type("Expansion"); + } + toscaGroupPropertyDefinition.setAvailability_zone_count(""); + toscaGroupPropertyDefinition.setVfc_list(""); + toscaGroupPropertyDefinition.setVf_module_description(""); + toscaGroupPropertyDefinition.setVolume_group(isVolumeGroup(module)); + + return toscaGroupPropertyDefinition; + } + + private String isVolumeGroup(GroupHeatMetaDefinition module) { + String isVolumeGroup = "false"; + for (HeatMetaFirstLevelDefinition artifactList : module.getArtifactList()) { + if (artifactList.getType().equals(ArtifactTypeEnum.HEAT_VOL.getType())) { + isVolumeGroup = "true"; + return isVolumeGroup; + } + } + return isVolumeGroup; + } + + private Map<String, ToscaServiceGroupsMetadataDefinition> createExpectedToscaServiceGroupsPropertyDefinitionObject(Resource resource, Service service, List<TypeHeatMetaDefinition> listTypeHeatMetaDefinition) { + + Map<String, ToscaServiceGroupsMetadataDefinition> toscaServiceGroupsMetadataDefinitionMap = new HashMap<>(); + for (TypeHeatMetaDefinition moduleType : listTypeHeatMetaDefinition) { + Map<String, String> groupProperty = new HashMap<>(); + + ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition = new ToscaServiceGroupsMetadataDefinition(); + for (GroupHeatMetaDefinition module : moduleType.getGroupHeatMetaDefinition()) { + String resourceModuleName = buildResourceModuleName(resource, module.getGroupName()); + toscaServiceGroupsMetadataDefinition = setGroupMetadataFromResourceObject(resourceModuleName, resource); + if (!toscaServiceGroupsMetadataDefinition.equals("")) { + String serviceModuleName = buildServiceModuleName(service.getComponentInstances().get(0).getNormalizedName(), toscaServiceGroupsMetadataDefinition.getVfModuleModelName()); + toscaServiceGroupsMetadataDefinition = setGroupMetadataFromServiceObject(toscaServiceGroupsMetadataDefinition, serviceModuleName, service); + toscaServiceGroupsMetadataDefinitionMap.put(serviceModuleName, toscaServiceGroupsMetadataDefinition); + } else { + getExtendTest().log(Status.FAIL, "module name [" + module.getGroupName() + "] didn't represent in resource"); + } + } + } + return toscaServiceGroupsMetadataDefinitionMap; + + } + + private ToscaServiceGroupsMetadataDefinition setGroupMetadataFromServiceObject(ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition, String serviceModuleName, Service service) { + for (GroupInstance groupInstance : service.getComponentInstances().get(0).getGroupInstances()) { + if (groupInstance.getName().contains(serviceModuleName)) { + toscaServiceGroupsMetadataDefinition.setVfModuleModelCustomizationUUID(groupInstance.getCustomizationUUID()); + return toscaServiceGroupsMetadataDefinition; + } + } + return toscaServiceGroupsMetadataDefinition; + } + + private ToscaServiceGroupsMetadataDefinition setGroupMetadataFromResourceObject(String resourceModuleName, Resource resource) { + ToscaServiceGroupsMetadataDefinition toscaServiceGroupsMetadataDefinition = new ToscaServiceGroupsMetadataDefinition(); + for (GroupDefinition group : resource.getGroups()) { + if (group.getName().contains(resourceModuleName)) { + toscaServiceGroupsMetadataDefinition.setVfModuleModelName(group.getName()); + toscaServiceGroupsMetadataDefinition.setVfModuleModelInvariantUUID(group.getInvariantUUID()); + toscaServiceGroupsMetadataDefinition.setVfModuleModelUUID(group.getGroupUUID()); + toscaServiceGroupsMetadataDefinition.setVfModuleModelVersion(group.getVersion()); + return toscaServiceGroupsMetadataDefinition; + } + } + return toscaServiceGroupsMetadataDefinition; + } - public static String buildResourceModuleName(Resource resource, String groupName ){ - return resource.getSystemName()+".."+groupName+".."+"module-"; - } - public static String buildServiceModuleName(String resourceInstanceNormalizedName, String resourceGroupName ){ - return resourceInstanceNormalizedName+".."+resourceGroupName; - } + public static String buildResourceModuleName(Resource resource, String groupName) { + return resource.getSystemName() + ".." + groupName + ".." + "module-"; + } + + public static String buildServiceModuleName(String resourceInstanceNormalizedName, String resourceGroupName) { + return resourceInstanceNormalizedName + ".." + resourceGroupName; + } - @Override + @Override protected UserRoleEnum getRole() { - return UserRoleEnum.DESIGNER; + return UserRoleEnum.DESIGNER; } - public static ToscaDefinition addGenericInputsToToscaObject(ToscaDefinition toscaDefinition, String genericName) throws Exception { - Resource genericResource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, genericName, "1.0"); - ToscaTopologyTemplateDefinition topologyTemplate = toscaDefinition.getTopology_template(); - Map<String, ToscaInputsTopologyTemplateDefinition> newInput = new HashMap<String, ToscaInputsTopologyTemplateDefinition>(); - for (PropertyDefinition property : genericResource.getProperties()) { - ToscaInputsTopologyTemplateDefinition input = new ToscaInputsTopologyTemplateDefinition(); + public static ToscaDefinition addGenericInputsToToscaObject(ToscaDefinition toscaDefinition, String genericName) throws Exception { + Resource genericResource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, genericName, "1.0"); + ToscaTopologyTemplateDefinition topologyTemplate = toscaDefinition.getTopology_template(); + Map<String, ToscaInputsTopologyTemplateDefinition> newInput = new HashMap<>(); + for (PropertyDefinition property : genericResource.getProperties()) { + ToscaInputsTopologyTemplateDefinition input = new ToscaInputsTopologyTemplateDefinition(); // input.setConstraints(property.getConstraints()); - input.setDefault(property.getDefaultValue()); - input.setDescription(property.getDescription()); + input.setDefault(property.getDefaultValue()); + input.setDescription(property.getDescription()); // input.setEntry_schema(property.getSchema()); - input.setName(property.getName()); + input.setName(property.getName()); // input.setRequired(property.get); - input.setStatus(property.getStatus()); - input.setType(property.getType()); - input.setValue(property.getValue()); - newInput.put(property.getName(),input); - } - - topologyTemplate.addInputs(newInput); - toscaDefinition.setTopology_template(topologyTemplate); - return toscaDefinition; - } - - public static ToscaDefinition setNameToToscaInput(ToscaDefinition toscaDefinition) { - Map<String, ToscaInputsTopologyTemplateDefinition> inputs = toscaDefinition.getTopology_template().getInputs(); - for (String name : inputs.keySet()) { - inputs.get(name).setName(name); - } - toscaDefinition.getTopology_template().setInputs(inputs); - return toscaDefinition; - } - - public static ToscaDefinition addAndGenerateResourceMetadataToExpectedObject(ToscaDefinition toscaDefinition, ResourceReqDetails resourceReqDetails, Component component) { - - Map<String, String> metadata = convertResourceMetadataToMap(resourceReqDetails, component); - toscaDefinition.setMetadata(metadata); - return toscaDefinition; - } - - public static Map<String, String> convertResourceMetadataToMap(ResourceReqDetails resourceReqDetails, Component component) { - Map<String, String> metadata = new HashMap<>(); - - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, resourceReqDetails.getCategories().get(0).getName()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, resourceReqDetails.getDescription()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, component.getInvariantUUID()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, resourceReqDetails.getResourceType()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, component.getUUID()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, component.getName()); - - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_NAME.value, resourceReqDetails.getVendorName()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_MODEL_NUMBER.value, resourceReqDetails.getResourceVendorModelNumber()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_RELEASE.value, resourceReqDetails.getVendorRelease()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SUBCATEGORY.value, resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName()); - return metadata; - } - - public static Map<String, String> convertResourceNodeTemplateMetadataToMap(ComponentInstance componentInstance) throws Exception{ - - Resource resource = AtomicOperationUtils.getResourceObject(componentInstance.getComponentUid()); - Map<String, String> metadata = new HashMap<>(); - - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, resource.getCategories().get(0).getName()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, resource.getDescription()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, resource.getInvariantUUID()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, resource.getResourceType().toString()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, resource.getUUID()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, resource.getName()); - - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_NAME.value, resource.getVendorName()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_MODEL_NUMBER.value, resource.getResourceVendorModelNumber()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_RELEASE.value, resource.getVendorRelease()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SUBCATEGORY.value, resource.getCategories().get(0).getSubcategories().get(0).getName()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CUSTOMIZATION_UUID.value, componentInstance.getCustomizationUUID()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.VERSION.value, componentInstance.getComponentVersion()); - - return metadata; - } - - public static Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject(ResourceReqDetails resourceReqDetails, Component component, ComponentInstance componentInstanceDefinition) { - - Map<String, String> metadata = convertResourceMetadataToMap(resourceReqDetails, component); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CUSTOMIZATION_UUID.value, componentInstanceDefinition.getCustomizationUUID()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.VERSION.value, componentInstanceDefinition.getComponentVersion()); - - return metadata; - } - - public static Map<String, Map<String, String>> generateResourceNodeTemplateMetadataToExpectedObject(Component component) throws Exception { - - Map<String, Map<String, String>> resourcesNodeTemplateMetadataMap = new HashMap<>(); - if(component.getComponentInstances() != null && component.getComponentInstances().size() != 0){ - for (ComponentInstance componentInstance:component.getComponentInstances()){ - Map<String, String> metadata = convertResourceNodeTemplateMetadataToMap(componentInstance); - resourcesNodeTemplateMetadataMap.put(componentInstance.getName(), metadata); - } - } - return resourcesNodeTemplateMetadataMap; - } - - public static Map<String, String> generateServiceMetadataToExpectedObject(ServiceReqDetails serviceReqDetails, Component component) { - - Map<String, String> metadata = new HashMap<>(); - - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, serviceReqDetails.getCategories().get(0).getName()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, serviceReqDetails.getDescription()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, component.getInvariantUUID()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, "Service"); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, component.getUUID()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, component.getName()); - - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_TYPE.value, serviceReqDetails.getServiceType()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_ROLE.value, serviceReqDetails.getServiceRole()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAMING_POLICY.value, serviceReqDetails.getNamingPolicy()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.ECOMP_GENERATED_NAMING.value, serviceReqDetails.getEcompGeneratedNaming().toString()); - metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_ECOMP_NAMING.value, serviceReqDetails.getEcompGeneratedNaming().toString());//equals to ECOMP_GENERATED_NAMING - - return metadata; - } - - public static void reportStartTestPrint (String testName, String vnfFile){ + input.setStatus(property.getStatus()); + input.setType(property.getType()); + input.setValue(property.getValue()); + newInput.put(property.getName(), input); + } + + topologyTemplate.addInputs(newInput); + toscaDefinition.setTopology_template(topologyTemplate); + return toscaDefinition; + } + + public static ToscaDefinition setNameToToscaInput(ToscaDefinition toscaDefinition) { + Map<String, ToscaInputsTopologyTemplateDefinition> inputs = toscaDefinition.getTopology_template().getInputs(); + for (String name : inputs.keySet()) { + inputs.get(name).setName(name); + } + toscaDefinition.getTopology_template().setInputs(inputs); + return toscaDefinition; + } + + public static ToscaDefinition addAndGenerateResourceMetadataToExpectedObject(ToscaDefinition toscaDefinition, ResourceReqDetails resourceReqDetails, Component component) { + + Map<String, String> metadata = convertResourceMetadataToMap(resourceReqDetails, component); + toscaDefinition.setMetadata(metadata); + return toscaDefinition; + } + + public static Map<String, String> convertResourceMetadataToMap(ResourceReqDetails resourceReqDetails, Component component) { + Map<String, String> metadata = new HashMap<>(); + + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, resourceReqDetails.getCategories().get(0).getName()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, resourceReqDetails.getDescription()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, component.getInvariantUUID()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, resourceReqDetails.getResourceType()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, component.getUUID()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, component.getName()); + + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_NAME.value, resourceReqDetails.getVendorName()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_MODEL_NUMBER.value, resourceReqDetails.getResourceVendorModelNumber()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_RELEASE.value, resourceReqDetails.getVendorRelease()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SUBCATEGORY.value, resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName()); + return metadata; + } + + public static Map<String, String> convertResourceNodeTemplateMetadataToMap(ComponentInstance componentInstance) throws Exception { + + Resource resource = AtomicOperationUtils.getResourceObject(componentInstance.getComponentUid()); + Map<String, String> metadata = new HashMap<>(); + + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, resource.getCategories().get(0).getName()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, resource.getDescription()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, resource.getInvariantUUID()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, resource.getResourceType().toString()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, resource.getUUID()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, resource.getName()); + + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_NAME.value, resource.getVendorName()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_MODEL_NUMBER.value, resource.getResourceVendorModelNumber()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.RESOURCE_VENDOR_RELEASE.value, resource.getVendorRelease()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SUBCATEGORY.value, resource.getCategories().get(0).getSubcategories().get(0).getName()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CUSTOMIZATION_UUID.value, componentInstance.getCustomizationUUID()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.VERSION.value, componentInstance.getComponentVersion()); + + return metadata; + } + + public static Map<String, String> generateServiceNodeTemplateMetadataToExpectedObject(ResourceReqDetails resourceReqDetails, Component component, ComponentInstance componentInstanceDefinition) { + + Map<String, String> metadata = convertResourceMetadataToMap(resourceReqDetails, component); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CUSTOMIZATION_UUID.value, componentInstanceDefinition.getCustomizationUUID()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.VERSION.value, componentInstanceDefinition.getComponentVersion()); + + return metadata; + } + + public static Map<String, Map<String, String>> generateResourceNodeTemplateMetadataToExpectedObject(Component component) throws Exception { + + Map<String, Map<String, String>> resourcesNodeTemplateMetadataMap = new HashMap<>(); + if (component.getComponentInstances() != null && !component.getComponentInstances().isEmpty()) { + for (ComponentInstance componentInstance : component.getComponentInstances()) { + Map<String, String> metadata = convertResourceNodeTemplateMetadataToMap(componentInstance); + resourcesNodeTemplateMetadataMap.put(componentInstance.getName(), metadata); + } + } + return resourcesNodeTemplateMetadataMap; + } + + public static Map<String, String> generateServiceMetadataToExpectedObject(ServiceReqDetails serviceReqDetails, Component component) { + + Map<String, String> metadata = new HashMap<>(); + + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.CATEGORY.value, serviceReqDetails.getCategories().get(0).getName()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.DESCRIPTION.value, serviceReqDetails.getDescription()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.INVARIANT_UUID.value, component.getInvariantUUID()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.TYPE.value, "Service"); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.UUID.value, component.getUUID()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAME.value, component.getName()); + + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_TYPE.value, serviceReqDetails.getServiceType()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_ROLE.value, serviceReqDetails.getServiceRole()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.NAMING_POLICY.value, serviceReqDetails.getNamingPolicy()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.ECOMP_GENERATED_NAMING.value, serviceReqDetails.getEcompGeneratedNaming().toString()); + metadata.put(ToscaMetadataFieldsPresentationEnum.ToscaMetadataFieldsEnum.SERVICE_ECOMP_NAMING.value, serviceReqDetails.getEcompGeneratedNaming().toString());//equals to ECOMP_GENERATED_NAMING + + return metadata; + } + + public static void reportStartTestPrint(String testName, String vnfFile) { // reportMessageInColor("info", "blue", "Running test \" + testName + \" with zip file - \" + vnfFile"); - SetupCDTest.getExtendTest().log(Status.INFO, "<html><font color=\"blue\"> Running test " + testName + " with zip file - " + vnfFile + "</font></html>"); - } - public static void reportSkipTestPrint (String testName, List<Boolean> status){ + SetupCDTest.getExtendTest().log(Status.INFO, "<html><font color=\"blue\"> Running test " + testName + " with zip file - " + vnfFile + "</font></html>"); + } + + public static void reportSkipTestPrint(String testName, List<Boolean> status) { // reportMessageInColor("error", "orange", "Skip test \" + testName + \" due to previous tosca parser error"); - SetupCDTest.getExtendTest().log(Status.ERROR, "<html><font color=\"orange\"> Skip test " + testName + " due to previous tosca parser error" + "</font></html>"); - status.add(false); - } - - public static void reportMessageInColor(String status, String color, String message){ - String printLine = getReportMessageInColor(color, message); - SetupCDTest.getExtendTest().log(Status.valueOf(status), printLine); + SetupCDTest.getExtendTest().log(Status.ERROR, "<html><font color=\"orange\"> Skip test " + testName + " due to previous tosca parser error" + "</font></html>"); + status.add(false); + } + + public static void reportMessageInColor(String status, String color, String message) { + String printLine = getReportMessageInColor(color, message); + SetupCDTest.getExtendTest().log(Status.valueOf(status), printLine); // SetupCDTest.getExtendTest().log(Status.valueOf(status), getReportMessageInColor(color, message)); - } - /** - * @param color = red, green, orange, blue ... - * @param message - message string - * @return string in desired color - */ - public static String getReportMessageInColor(String color, String message){ - String returnValue = ("<html><font color=\\\"+color+\"\">" + message + "</font></html>").toString(); - return returnValue; - } + } + + /** + * @param color = red, green, orange, blue ... + * @param message - message string + * @return string in desired color + */ + public static String getReportMessageInColor(String color, String message) { + String returnValue = ("<html><font color=\\\"+color+\"\">" + message + "</font></html>").toString(); + return returnValue; + } /* @Test() - public void printTest(){ + public void printTest(){ System.out.println("print"); reportMessageInColor("ERROR", "green", "green"); reportMessageInColor("INFO", "orange", "orange"); @@ -722,66 +824,62 @@ public class ToscaValidationTest extends SetupCDTest{ }*/ + // help method to toscaValidation tests + private ISdcCsarHelper initSdcCsarHelper(File serviceCsarFileName, File filesFolder) { + ISdcCsarHelper fdntCsarHelper; + try { + SetupCDTest.getExtendTest().log(Status.INFO, "Tosca parser is going to convert service csar file to ISdcCsarHelper object..."); + fdntCsarHelper = factory.getSdcCsarHelper(filesFolder.getPath() + serviceCsarFileName); + } catch (Exception e) { + SetupCDTest.getExtendTest().log(Status.ERROR, "Tosca parser FAILED to convert service csar file to ISdcCsarHelper object..."); + SetupCDTest.getExtendTest().log(Status.FAIL, e); + fdntCsarHelper = null; + } + return fdntCsarHelper; + } - // help method to toscaValidation tests - private ISdcCsarHelper initSdcCsarHelper(File serviceCsarFileName, File filesFolder) { - ISdcCsarHelper fdntCsarHelper; - try{ - SetupCDTest.getExtendTest().log(Status.INFO, "Tosca parser is going to convert service csar file to ISdcCsarHelper object..."); - fdntCsarHelper = factory.getSdcCsarHelper(filesFolder.getPath() + serviceCsarFileName); - }catch(Exception e){ - SetupCDTest.getExtendTest().log(Status.ERROR, "Tosca parser FAILED to convert service csar file to ISdcCsarHelper object..."); - SetupCDTest.getExtendTest().log(Status.FAIL, e); - fdntCsarHelper = null; - } - return fdntCsarHelper; - } - - - /** - * @param resourceReqDetails to create Vsp - * @return updated resourceReqDetails after Vsp was created - */ - private ResourceReqDetails createCustomizedVsp(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception { - Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filePath, vnfFile, user); - VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; - vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left); - resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); - return resourceReqDetails; - } - - /** - * @param resourceReqDetails to download csar file via UI - * @return Tosca definition object from main yaml file - */ - private ToscaDefinition downloadAndGetToscaMainYamlObjectUI(ResourceReqDetails resourceReqDetails, File filesFolder) throws Exception { - DownloadManager.downloadCsarByNameFromVSPRepository(resourceReqDetails.getName(), false); - File amdocsCsarFileName = FileHandling.getLastModifiedFileNameFromDir(filesFolder.getAbsolutePath()); - return ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(amdocsCsarFileName); - } - - /** - * @param toscaMainAmdocsDefinition object to add generic properties - * @param genericName resource name - * @return updated toscaMainAmdocsDefinition object - */ - private ToscaDefinition addGenericPropertiesToToscaDefinitionObject(ToscaDefinition toscaMainAmdocsDefinition, String genericName) throws Exception { - toscaMainAmdocsDefinition = setNameToToscaInput(toscaMainAmdocsDefinition); - toscaMainAmdocsDefinition = addGenericInputsToToscaObject(toscaMainAmdocsDefinition, genericName); - return toscaMainAmdocsDefinition; - } - - /** - * @param resource to download csar file via API - * @return Tosca definition object from main yaml file - */ - private ToscaDefinition downloadAndGetToscaMainYamlObjectApi(Resource resource, File filesFolder) throws Exception { - File VfCsarFileName = new File(File.separator + "VfCsar_" + ElementFactory.generateUUIDforSufix() + ".csar"); - OnboardingUtillViaApis.downloadToscaCsarToDirectory(resource, new File(filesFolder.getPath() + VfCsarFileName)); - return ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + VfCsarFileName)); - } + /** + * @param resourceReqDetails to create Vsp + * @return updated resourceReqDetails after Vsp was created + */ + private ResourceReqDetails createCustomizedVsp(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception { + VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filePath, vnfFile, user); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + return resourceReqDetails; + } + + /** + * @param resourceReqDetails to download csar file via UI + * @return Tosca definition object from main yaml file + */ + private ToscaDefinition downloadAndGetToscaMainYamlObjectUI(ResourceReqDetails resourceReqDetails, File filesFolder) throws Exception { + DownloadManager.downloadCsarByNameFromVSPRepository(resourceReqDetails.getName(), false); + File amdocsCsarFileName = FileHandling.getLastModifiedFileNameFromDir(filesFolder.getAbsolutePath()); + return ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(amdocsCsarFileName); + } + + /** + * @param toscaMainAmdocsDefinition object to add generic properties + * @param genericName resource name + * @return updated toscaMainAmdocsDefinition object + */ + private ToscaDefinition addGenericPropertiesToToscaDefinitionObject(ToscaDefinition toscaMainAmdocsDefinition, String genericName) throws Exception { + toscaMainAmdocsDefinition = setNameToToscaInput(toscaMainAmdocsDefinition); + toscaMainAmdocsDefinition = addGenericInputsToToscaObject(toscaMainAmdocsDefinition, genericName); + return toscaMainAmdocsDefinition; + } + + /** + * @param resource to download csar file via API + * @return Tosca definition object from main yaml file + */ + private ToscaDefinition downloadAndGetToscaMainYamlObjectApi(Resource resource, File filesFolder) throws Exception { + File vfCsarFileName = new File(File.separator + "VfCsar_" + ElementFactory.generateUUIDforSufix() + ".csar"); + OnboardingUtillViaApis.downloadToscaCsarToDirectory(resource, new File(filesFolder.getPath() + vfCsarFileName)); + return ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(filesFolder.getPath() + vfCsarFileName)); + } } 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 new file mode 100644 index 0000000000..4f1b9a1e82 --- /dev/null +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/UpgradeServices.java @@ -0,0 +1,418 @@ +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.be.model.Service; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.datatypes.*; +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.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.verificator.PropertiesAssignmentVerificator; +import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator; +import org.openecomp.sdc.ci.tests.verificator.VfVerificator; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Map; + +public class UpgradeServices extends SetupCDTest{ + + + protected User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + private String filePath; + + @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); + //2. Create CR, certify + ResourceReqDetails crMetaData = createCRAndCertify(); + //3. Create PNF, certify + ResourceReqDetails pnfMetaData = createPnfAndCertify(); + + //4. Create Service1. Service composition - add 2 VFi + Service service1 = createService(); + getExtendTest().log(Status.INFO, "Add VFi to service twice"); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + 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"); + 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"); + canvasManager1.createElementOnCanvas(crMetaData.getName()); + canvasManager1.createElementOnCanvas(pnfMetaData.getName()); + + //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<String, String> 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(); + getExtendTest().log(Status.INFO, "Add VFi to service"); + 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(); + + //8. Create Service3. Service composition - add VFi. Leave service in "checked out" state + Service service3 = createService(); + getExtendTest().log(Status.INFO, "Add VFi to service"); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + 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(); + + //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.clickCertifyButtonNoUpgradePopupDismiss(vfResource.getName()); + + //10. Validate that Service1 can be upgraded (checked), Service2 and Service3 are locked + //TODO - add validation in UI + + //11. Click Upgrade button + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPGRADE_SERVICES_OK.getValue()); + GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPGRADE_SERVICES_CLOSE.getValue()); + + //12. Open Service1, verify version (1.1), state(checked in), VFi version (v2.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 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<String, String> 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(); + 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(); + 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()); + 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()); + 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); + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + GeneralUIUtils.findComponentAndClick(vfMetaData.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 + CompositionPage.moveToPropertiesScreen(); + PropertiesAssignmentPage.findSearchBoxAndClick(propName); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(propName), serviceName); + PropertiesAssignmentPage.clickOnSaveButton(); + PropertiesAssignmentPage.findSearchBoxAndClick(propUUID); + PropertiesAssignmentPage.editPropertyValue(PropertyNameBuilder.buildSimpleField(propUUID), serviceUUIDv1); + PropertiesAssignmentPage.clickOnSaveButton(); + 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 + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click(); + GeneralUIUtils.findComponentAndClick(service2.getName()); + ServiceVerificator.verifyVersionUI("1.1"); + ServiceVerificator.verifyServiceLifecycleInUI(LifeCycleStateEnum.CHECKIN); + ServiceGeneralPage.getLeftMenu().moveToCompositionScreen(); + CanvasManager canvasManager4 = CanvasManager.getCanvasManager(); + canvasManager4.clickOnCanvaElement(vfElement1); + 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<String, String> 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); + 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<String, String> 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 20cd8886fd..1c4aadeda7 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 @@ -21,7 +21,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; -import com.clearspring.analytics.util.Pair; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; @@ -37,9 +36,10 @@ 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.pages.TesterOperationPage; import org.openecomp.sdc.ci.tests.utilities.*; 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; import org.openecomp.sdc.ci.tests.verificator.VFCArtifactVerificator; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -51,8 +51,6 @@ import java.util.Map; import java.util.stream.Collectors; import static org.testng.Assert.assertTrue; -import org.openecomp.sdc.ci.tests.utils.general.VendorLicenseModelRestUtils; -import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils; public class VFCArtifacts extends SetupCDTest { @@ -215,13 +213,13 @@ public class VFCArtifacts extends SetupCDTest { String snmpFile = "Fault-alarms-ASDC-vprobes-vLB.zip"; AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - Pair<String, VendorSoftwareProductObject> createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); - String vspName = createVSP.left; + VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); + String vspName = createVSP.getName(); resourceMetaData.setName(vspName); - VendorSoftwareProductObject resourceMeta = createVSP.right; - String vspid = resourceMeta.getVspId(); - VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, resourceMeta, getUser()); - VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), resourceMeta, true); +// 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"; @@ -249,13 +247,12 @@ public class VFCArtifacts extends SetupCDTest { String updatedSnmpPollFile = "vprobes-vLBAgent.zip"; AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - Pair<String, VendorSoftwareProductObject> createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); - String vspName = createVSP.left; + VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); + String vspName = createVSP.getName(); resourceMetaData.setName(vspName); - VendorSoftwareProductObject resourceMeta = createVSP.right; - String vspid = resourceMeta.getVspId(); - String montoringComponentId = VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpPollFile, null, resourceMeta, getUser()); - VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), resourceMeta, true); + 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"; @@ -263,15 +260,9 @@ public class VFCArtifacts extends SetupCDTest { DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); HomePage.showVspRepository(); OnboardingUiUtils.importVSP(createVSP); + ResourceGeneralPage.clickCertifyButton(vspName); - ResourceGeneralPage.clickSubmitForTestingButton(vspName); - - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vspName); - TesterOperationPage.certifyComponent(vspName); - - reloginWithNewRole(UserRoleEnum.DESIGNER); - VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpPollFile, null, montoringComponentId, getUser(), resourceMeta); + VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpPollFile, null, monitoringComponentId, getUser(), createVSP); DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); HomePage.showVspRepository(); OnboardingUiUtils.updateVSP(createVSP); @@ -295,13 +286,12 @@ public class VFCArtifacts extends SetupCDTest { String updatedSnmpFile = "vprobes-vLB-Modified.zip"; AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(getUser()); - Pair<String, VendorSoftwareProductObject> createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); - String vspName = createVSP.left; + VendorSoftwareProductObject createVSP = VendorSoftwareProductRestUtils.createVSP(resourceMetaData, vnfFile, filePath, getUser(), amdocsLicenseMembers); + String vspName = createVSP.getName(); resourceMetaData.setName(vspName); - VendorSoftwareProductObject resourceMeta = createVSP.right; - String vspid = resourceMeta.getVspId(); - String monitoringId = VendorSoftwareProductRestUtils.addVFCArtifacts(filePath, snmpFile, null, resourceMeta, getUser()); - VendorSoftwareProductRestUtils.prepareVspForUse(getUser(), resourceMeta, true); + 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"; @@ -316,15 +306,9 @@ public class VFCArtifacts extends SetupCDTest { resourceMetaData.setVersion("0.1"); VFCArtifactVerificator.setActualVfcArtifactList(key, resourceMetaData, getUser()); } - - ResourceGeneralPage.clickSubmitForTestingButton(vspName); - - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vspName); - TesterOperationPage.certifyComponent(vspName); - - reloginWithNewRole(UserRoleEnum.DESIGNER); - VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpFile, null, monitoringId, getUser(), resourceMeta); + + ResourceGeneralPage.clickCertifyButton(vspName); + VendorSoftwareProductRestUtils.updateVspWithVfcArtifacts(filePath, updatedSnmpFile, null, monitoringId, getUser(), createVSP); DownloadManager.downloadCsarByNameFromVSPRepository(vspName, vspid); HomePage.showVspRepository(); OnboardingUiUtils.updateVSP(createVSP); 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 dbe0a971c6..921984592c 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 @@ -20,14 +20,7 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import java.awt.AWTException; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +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; @@ -36,32 +29,16 @@ import org.openecomp.sdc.ci.tests.datatypes.*; 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.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.AttFtpClient; 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.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.TesterOperationPage; -import org.openecomp.sdc.ci.tests.pages.ToscaArtifactsPage; -import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; +import org.openecomp.sdc.ci.tests.pages.*; import org.openecomp.sdc.ci.tests.utilities.*; -import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils; -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; 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.validation.ErrorValidationUtils; import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator; import org.openecomp.sdc.ci.tests.verificator.VfModuleVerificator; @@ -69,13 +46,13 @@ import org.openecomp.sdc.ci.tests.verificator.VfVerificator; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.AssertJUnit; -import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.aventstack.extentreports.Status; -import com.clearspring.analytics.util.Pair; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; public class Vf extends SetupCDTest { @@ -94,46 +71,14 @@ public class Vf extends SetupCDTest { @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<String> 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 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.clickSubmitForTestingButton(atomicResourceMetaData.getName()); + ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName()); - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); - TesterOperationPage.certifyComponent(atomicResourceMetaData.getName()); - - reloginWithNewRole(UserRoleEnum.DESIGNER); ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); ResourceUIUtils.createVF(vfMetaData, getUser()); @@ -145,7 +90,8 @@ public class Vf extends SetupCDTest { CanvasElement cpElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); AssertJUnit.assertNotNull(cpElement); ServiceVerificator.verifyNumOfComponentInstances(vfMetaData, "0.1", 2, getUser()); - canvasManager.linkElements(cpElement, computeElement); + + canvasManager.linkElements(computeElement.getElementNameOnCanvas() , cpElement.getElementNameOnCanvas()); vfMetaData.setVersion("0.1"); VfVerificator.verifyLinkCreated(vfMetaData, getUser(), 1); @@ -163,7 +109,7 @@ public class Vf extends SetupCDTest { ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); - List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>(); + List<ArtifactInfo> 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) { @@ -217,7 +163,8 @@ public class Vf extends SetupCDTest { 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"); +// 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"; @@ -266,7 +213,7 @@ public class Vf extends SetupCDTest { try{ atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName()); + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); ResourceUIUtils.createVF(vfMetaData, getUser()); @@ -274,9 +221,8 @@ public class Vf extends SetupCDTest { vfCanvasManager = CanvasManager.getCanvasManager(); CompositionPage.searchForElement(atomicResourceMetaData.getName()); vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); - - - CompositionPage.clickSubmitForTestingButton(vfMetaData.getName()); + + CompositionPage.clickCertifyButton(vfMetaData.getName()); assert(false); } catch(Exception e){ @@ -285,11 +231,6 @@ public class Vf extends SetupCDTest { AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError)); - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName()); - TesterOperationPage.certifyComponent(atomicResourceMetaData.getName()); - - reloginWithNewRole(UserRoleEnum.DESIGNER); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); vfCanvasManager = CanvasManager.getCanvasManager(); @@ -305,71 +246,6 @@ public class Vf 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<PropertyTypeEnum> 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<String, String> elementsIntancesMap = new HashMap<String, String>(); - 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<String, String> propertiesNameTypeJson = ResponseParser.getPropertiesNameType(restResponse); - - List<WebElement> 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 addAllInformationalArtifactPlaceholdersInVfTest() throws Exception{ @@ -399,28 +275,10 @@ public class Vf extends SetupCDTest { String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); } - - ToscaArtifactsPage.clickSubmitForTestingButton(vfMetaData.getName()); + ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName()); VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser()); } - @Test(enabled=false) - public void testDownload() throws Exception{ -// ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); -// ResourceUIUtils.createResource(vfMetaData, getUser()); -// -// final int numOfToscaArtifacts = 2; -// ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen(); -// 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 vfCertificationTest() throws Exception{ ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); @@ -430,16 +288,11 @@ public class Vf extends SetupCDTest { ResourceGeneralPage.clickCheckinButton(vfName); GeneralUIUtils.findComponentAndClick(vfName); - ResourceGeneralPage.clickSubmitForTestingButton(vfName); - - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vfName); - TesterOperationPage.certifyComponent(vfName); + ResourceGeneralPage.clickCertifyButton(vfName); vfMetaData.setVersion("1.0"); VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.CERTIFIED); - reloginWithNewRole(UserRoleEnum.DESIGNER); GeneralUIUtils.findComponentAndClick(vfName); VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED); } @@ -491,22 +344,7 @@ public class Vf extends SetupCDTest { } // 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<PropertyTypeEnum> 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 addDeploymentArtifactAndVerifyInCompositionScreen() throws Exception{ ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); @@ -541,14 +379,8 @@ public class Vf extends SetupCDTest { vfMetaData.setVersion("0.2"); VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - - ResourceGeneralPage.clickSubmitForTestingButton(vfMetaData.getName()); - - reloginWithNewRole(UserRoleEnum.TESTER); - GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); - TesterOperationPage.certifyComponent(vfMetaData.getName()); - - reloginWithNewRole(UserRoleEnum.DESIGNER); + + ResourceGeneralPage.clickCertifyButton(vfMetaData.getName()); GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); ResourceGeneralPage.clickCheckoutButton(); @@ -597,7 +429,7 @@ public class Vf extends SetupCDTest { ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser()); - ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName()); + ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName()); ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); ResourceUIUtils.createVF(vfMetaData, getUser()); @@ -607,7 +439,7 @@ public class Vf extends SetupCDTest { canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); try{ - CompositionPage.clickSubmitForTestingButton(vfMetaData.getName()); + CompositionPage.clickCertifyButton(vfMetaData.getName()); assert(false); } catch(Exception e){ @@ -643,25 +475,26 @@ public class Vf extends SetupCDTest { public void exportToscaWithModulePropertiesVFTest() throws AWTException, Exception { String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip"; ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); - String vspName = vsp.left; - ResourceGeneralPage.clickSubmitForTestingButton(vsp.left); + 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 exportToscaWithModulePropertiesTemplateCheckVFTest() throws AWTException, 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); + 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()); + } - @Override 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 e0eaf74de6..414f77b2f1 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 @@ -20,41 +20,19 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import java.awt.AWTException; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.openecomp.sdc.be.dao.api.ActionStatus; +import com.aventstack.extentreports.Status; 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.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.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.enums.*; 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.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.TesterOperationPage; -import org.openecomp.sdc.ci.tests.pages.ToscaArtifactsPage; +import org.openecomp.sdc.ci.tests.pages.*; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; import org.openecomp.sdc.ci.tests.utilities.*; import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils; @@ -62,7 +40,6 @@ 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; import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; -import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator; import org.openecomp.sdc.ci.tests.verificator.VfModuleVerificator; import org.openecomp.sdc.ci.tests.verificator.VfVerificator; @@ -73,13 +50,15 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.aventstack.extentreports.Status; -import com.clearspring.analytics.util.Pair; +import java.io.File; +import java.util.*; +import static org.assertj.core.api.Assertions.assertThat; public class VfAPI extends SetupCDTest { private String filePath; + @BeforeClass public void beforeClass(){ filePath = FileHandling.getFilePath(""); @@ -281,7 +260,7 @@ public class VfAPI extends SetupCDTest { } } - @Test +/* @Test public void changeInstanceVersionTest() throws Exception{ ResourceReqDetails atomicResourceMetaData = null; @@ -329,7 +308,7 @@ public class VfAPI extends SetupCDTest { ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0"); } - } + }*/ // future removed from ui @Test(enabled = false) @@ -401,18 +380,21 @@ public class VfAPI extends SetupCDTest { 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()){ - ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, filePath,"asc_heat 0 2.yaml", informArtifact.getValue()); + fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX; + ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, + FileHandling.getFilePath("uniqueFileNames"),fileName, + informArtifact.getValue()); + fileNameCounter++; } - - AssertJUnit.assertTrue(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)); + assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue(); } @Test @@ -432,8 +414,10 @@ public class VfAPI extends SetupCDTest { String typeFromScreen = ToscaArtifactsPage.getArtifactType(i); AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType())); } - - ToscaArtifactsPage.clickSubmitForTestingButton(vfMetaData.getName()); + + //TODO Andrey should click on certify button + ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName()); + vfMetaData.setVersion("1.0"); VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser()); } @@ -571,7 +555,7 @@ public class VfAPI extends SetupCDTest { AssertJUnit.assertTrue("asc_heat-0-2.yaml".equals(actualArtifactFileName)); } - @Test + /*@Test public void checkoutVfTest() throws Exception{ ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser()); ResourceUIUtils.createVF(vfMetaData, getUser()); @@ -598,7 +582,7 @@ public class VfAPI extends SetupCDTest { vfMetaData.setUniqueId(null); VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT); - } + }*/ @Test public void deleteInstanceFromVfCanvasApi() throws Exception{ @@ -641,7 +625,7 @@ public class VfAPI extends SetupCDTest { } - @Test + /*@Test public void submitVfForTestingWithNonCertifiedAssetApi() throws Exception{ String fileName = "vFW_VFC4.yml"; ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser()); @@ -667,7 +651,8 @@ public class VfAPI extends SetupCDTest { canvasManager.createElementOnCanvas(atomicResourceMetaData.getName()); try{ - CompositionPage.clickSubmitForTestingButton(vfMetaData.getName()); + //TODO Andrey should click on certify button + CompositionPage.clickCertifyButton(vfMetaData.getName()); assert(false); } catch(Exception e){ @@ -678,7 +663,7 @@ public class VfAPI extends SetupCDTest { finally{ ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1"); } - } + }*/ @Test public void isDisabledAndReadOnlyInCheckinApi() throws Exception{ @@ -704,20 +689,49 @@ public class VfAPI extends SetupCDTest { AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(ResourceMetadataEnum.CATEGORY.getValue())); AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue())); } + + @Test + 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" + + //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(); + + //Find the created VF on Home page + CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG); + HomePage.navigateToHomePage(); + GeneralUIUtils.findComponentAndClick(vfMetaData.getName()); + + //Copy current URL, navigate to OB screen and paste URL + String url = GeneralUIUtils.copyCurrentURL(); + CompositionPage.moveToOnboardScreen(); + GeneralUIUtils.navigateToURL(url); + GeneralUIUtils.ultimateWait(); + + //Validate that main menu button is Home and not Onboarding + 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 AWTException, Exception { + public void exportToscaWithModulePropertiesVFTest() throws Exception { String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip"; ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser()); - String vspName = vsp.left; - ResourceGeneralPage.clickSubmitForTestingButton(vsp.left); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); + 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 AWTException, Exception { + 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()); 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 9847d341c0..28ff2cc8ca 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 @@ -21,7 +21,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity; import com.aventstack.extentreports.Status; -import com.clearspring.analytics.util.Pair; import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.Resource; @@ -45,7 +44,6 @@ import org.openecomp.sdc.ci.tests.utils.Utils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openqa.selenium.WebElement; -import org.testng.SkipException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -114,8 +112,8 @@ public class VfArtifacts extends SetupCDTest{ String vnfFile = VFW_FNAT_30_1607_E2E_ZIP; File updateEnvFile = null; ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.left; + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = vsp.getName(); Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts(); List<HeatWithParametersDefinition> envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); @@ -139,8 +137,8 @@ public class VfArtifacts extends SetupCDTest{ String vnfFile = VFW_FNAT_30_1607_E2E_ZIP; File updateEnvFile = null; ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.left; + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = vsp.getName(); Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts(); List<HeatWithParametersDefinition> envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); @@ -163,8 +161,8 @@ public class VfArtifacts extends SetupCDTest{ String vnfFile = VLANDSLIDE_LDST_30_1607_E2E_ZIP; File updateEnvFile = null; ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.left; + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = vsp.getName(); Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "0.1"); Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts(); List<HeatWithParametersDefinition> envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); @@ -192,8 +190,8 @@ public class VfArtifacts extends SetupCDTest{ String updatedVnfFile= VLANDSLIDE_LDSA_30_1607_E2E_ZIP; String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> CreatedVsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = CreatedVsp.left; + 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 @@ -218,9 +216,9 @@ public class VfArtifacts extends SetupCDTest{ String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String,VendorSoftwareProductObject> vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - Map<String, File> currentZipEnvfiles=ArtifactBusinessLogic.createEnvFilesListFromCsar(vsp.left,downloadDirPath); - GeneralUIUtils.findComponentAndClick(vsp.left); + VendorSoftwareProductObject vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + Map<String, File> currentZipEnvfiles=ArtifactBusinessLogic.createEnvFilesListFromCsar(vsp.getName(),downloadDirPath); + GeneralUIUtils.findComponentAndClick(vsp.getName()); ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen(); List<String> deploymentArtifcatsList = DeploymentArtifactPage.getDeploymentArtifactsNamesWorkSpace(); @@ -242,9 +240,9 @@ public class VfArtifacts extends SetupCDTest{ String downloadDirPath=SetupCDTest.getConfig().getWindowsDownloadDirectory(); String vnfFile = VSAEGW_FDNT_30_1607_E2E_ZIP; ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - Map<String, File> currentZipEnvfiles=ArtifactBusinessLogic.createEnvFilesListFromCsar(vsp.left,downloadDirPath); - GeneralUIUtils.findComponentAndClick(vsp.left); + VendorSoftwareProductObject vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + Map<String, File> currentZipEnvfiles=ArtifactBusinessLogic.createEnvFilesListFromCsar(vsp.getName(),downloadDirPath); + GeneralUIUtils.findComponentAndClick(vsp.getName()); ResourceGeneralPage.getLeftMenu().moveToCompositionScreen(); CompositionPage.clickOnTabTestID(CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB); List<WebElement> deploymentArtifcatsList = CompositionPage.getCompositionEnvArtifacts(); @@ -262,13 +260,13 @@ public class VfArtifacts extends SetupCDTest{ @Test // Download ENV file from VF level Update parameters in UI. - public void downloadEnvVFLevelUpdateParameters() throws AWTException, Exception { + 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); - Pair<String, VendorSoftwareProductObject> CreatedVsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, CreatedVsp.left, "0.1"); + VendorSoftwareProductObject vendorSoftwareProductObject= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vendorSoftwareProductObject.getName(), "0.1"); Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts(); List<HeatWithParametersDefinition> envFilesList = ArtifactBusinessLogic.extractHeatWithParametersDefinition(deploymentArtifacts); @@ -288,8 +286,8 @@ public class VfArtifacts extends SetupCDTest{ DeploymentArtifactPage.clickSaveEnvParameters(); GeneralUIUtils.waitForLoader(); - ExtentTestActions.log(Status.INFO, String.format("Going to get the %s updated resource ...", CreatedVsp.left)); - resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, CreatedVsp.left, "0.1"); + 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<String,List<HeatWithParametersDefinition>> envFilesListupdated = new HashMap<>(); ExtentTestActions.log(Status.INFO, String.format("Mapping the %s artifact parameters ...", artifactName)); @@ -311,19 +309,20 @@ public class VfArtifacts extends SetupCDTest{ public void checkDefaultCreatedEnvArtifacts() throws Exception{ String vnfFile = VIXIA_IXLA_30_1607_E2E_ZIP; ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.left; + VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); + String vspName = vsp.getName(); Map<String, File> generatedEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); HomeUtils.findComponentAndClick(vspName); GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); for(Entry<String, File> 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"); - } - ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), "1", ArtifactTypeEnum.HEAT_ENV); - ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), "1", ArtifactTypeEnum.HEAT); +// 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); } } @@ -333,8 +332,8 @@ public class VfArtifacts extends SetupCDTest{ String stringForLog = String.format("%s:%s:%s:%s", vnfFile, updatedVnfFile, expectedHeatVersion, expectedHeatEnvVersion); setLog(stringForLog); ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.left; + 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<String, File> generatedUpdatedEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); @@ -348,7 +347,8 @@ public class VfArtifacts extends SetupCDTest{ // ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), expectedHeatVersion, ArtifactTypeEnum.HEAT); } if(true){ - throw new SkipException("Test skipped, new artifact version design should be developed"); +// 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"); } } @@ -358,13 +358,14 @@ public class VfArtifacts extends SetupCDTest{ String vnfFile = VFW_FCGI_30_1607_E2E_ZIP; String updatedVnfFile = VFW_FCGI_30_1607_E2E_ZIP; ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); - Pair<String, VendorSoftwareProductObject> vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, vnfsRepositoryPath, vnfFile, getUser()); - String vspName = vsp.left; + 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<String, File> generatedUpdatedSecondTimeEnvFileList = ArtifactBusinessLogic.createEnvFilesListFromCsar(vspName, filePath); HomeUtils.findComponentAndClick(vspName); GeneralUIUtils.moveToStep(StepsEnum.DEPLOYMENT_ARTIFACT); @@ -372,10 +373,11 @@ public class VfArtifacts extends SetupCDTest{ 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"); +// 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); +// ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), "3", ArtifactTypeEnum.HEAT_ENV); +// ArtifactUIUtils.validateArtifactVersionByTypeAndLabel(envFileEntry.getKey(), "1", ArtifactTypeEnum.HEAT); } } 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 bb4d754bbf..4f6e74522d 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 @@ -20,9 +20,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import java.util.ArrayList; -import java.util.List; - import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.User; @@ -42,10 +39,13 @@ import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.openqa.selenium.WebElement; -import org.testng.Assert; -import org.testng.SkipException; import org.testng.annotations.Test; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + public class VfDeploymentInformationalArtifacts extends SetupCDTest { @@ -197,7 +197,7 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + assertThat(errorMessage).contains(checkUIResponseOnError); } // US824719 - Import VSP - VF informational artifacts @@ -215,7 +215,7 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + assertThat(errorMessage).contains(checkUIResponseOnError); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -229,225 +229,7 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // START US825779 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1443736 - Update With One New Deployment Artifact - @Test - public void updateWithOneNewDeploymentArtifact() throws Exception { - - if(true){ - throw new SkipException("Open bug 310971 and 369139"); - } - - String fileName = "ImportTC1443736.csar"; - String folder ="US825779"; - - List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>(); - - 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")); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1443736.csar"; - deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1")); - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, null, null, null); - } - - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1443737 - Update With One Removed Deployment Artifact - @Test - public void updateWithOneRemovedDeploymentArtifact() throws Exception { - - if(true){ - throw new SkipException("Open bug 310971 and 369139"); - } - - String fileName = "ImportTC1443737.csar"; - String folder ="US825779"; - - List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>(); - - 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")); - ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1"); - deploymentArtifacts.add(artifactInfo); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1443737.csar"; - deploymentArtifacts.remove(artifactInfo); - - List<ArtifactInfo> deploymentArtifactsNotExist = new ArrayList<ArtifactInfo>(); - deploymentArtifactsNotExist.add(artifactInfo); - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, null, deploymentArtifactsNotExist, null); - } - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1443738 - Update With One New Version Deployment Artifact - @Test - public void updateWithOneNewVersionDeploymentArtifact() throws Exception { - - if(true){ - throw new SkipException("Open bug 310971 and 369139"); - } - - String fileName = "ImportTC1443738.csar"; - String folder ="US825779"; - - List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>(); - - 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")); - ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1"); - deploymentArtifacts.add(artifactInfo); - - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1443738.csar"; - artifactInfo.setArtifactVersion("2"); - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, null, null, null); - } - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1443887 - Update With One New Informational Artifact - @Test - public void updateWithOneNewInformationalArtifact() throws Exception { - - if(true){ - throw new SkipException("Open bug 310971 and 369139"); - } - - String fileName = "ImportTC1443887.csar"; - String folder ="US825779"; - - List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>(); - 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); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1443887.csar"; - - List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>(); - informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, informationalArtifacts, null, null); - } - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1443888 - Update With One Removed Informational Artifact - @Test - public void updateWithOneRemovedInformationalArtifact() throws Exception { - - if(true){ - throw new SkipException("Open bug 310971 and 369139"); - } - - String folder ="US825779"; - String fileName = "ImportTC1443888.csar"; - - List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>(); - 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<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>(); - ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"); - informationalArtifacts.add(artifactInfo); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1443888.csar"; - - informationalArtifacts.remove(artifactInfo); - - List<ArtifactInfo> informationalArtifactNotExist = new ArrayList<ArtifactInfo>(); - informationalArtifactNotExist.add(artifactInfo); - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, informationalArtifacts, null, informationalArtifactNotExist); - } - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1443890 - Update With One New Artifact Version Informational Artifact - @Test - public void updateWithOneNewArtifactVersionInformationalArtifact() throws Exception { - - if(true){ - throw new SkipException("Open bug 310971 and 369139"); - } - - String folder ="US825779"; - String fileName = "ImportTC1443890.csar"; - - List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>(); - 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<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>(); - ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"); - informationalArtifacts.add(artifactInfo); - - importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1443890.csar"; - artifactInfo.setArtifactVersion("2"); - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, informationalArtifacts, null, null); - } - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1443893 - Update CSAR With Same Artifacts As Imported - @Test - public void updateCSARWithSameArtifactsAsImported() throws Exception { - - if(true){ - throw new SkipException("Open bug 310971 and 369139"); - } - - String folder ="US825779"; - String fileName = "ImportUpdateTC1443893.csar"; - - List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>(); - 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, "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")); - - List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>(); - 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); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "ImportUpdateTC1443893.csar"; - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, informationalArtifacts, null, null); - } - + // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update // TC1443954 - Update With Multiple Changes In Deployment And Informational Artifacts @Test @@ -537,8 +319,8 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { ResourceUIUtils.updateVfWithCsar(filePath, fileName); String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_ALRADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name()); + assertThat(errorMessage).contains(checkUIResponseOnError); } // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update @@ -560,13 +342,13 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); fileName = "UpdateTC1444207.csar"; - String filePath = FileHandling.getFilePath(folder); ; + String filePath = FileHandling.getFilePath(folder); ResourceUIUtils.updateVfWithCsar(filePath, fileName); String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_ALRADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name()); + assertThat(errorMessage).contains(checkUIResponseOnError); } @@ -592,8 +374,8 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { ResourceUIUtils.updateVfWithCsar(filePath, fileName); String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); - String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_ALRADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name()); + assertThat(errorMessage).contains(checkUIResponseOnError); } // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update @@ -615,7 +397,7 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + assertThat(errorMessage).contains(checkUIResponseOnError); } // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update @@ -637,40 +419,9 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest { String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText(); String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name()); - Assert.assertTrue(errorMessage.contains(checkUIResponseOnError)); + assertThat(errorMessage).contains(checkUIResponseOnError); } - - // TODO: only after below TODO's it complete test - // TODO: verify that if delete/edit button need to be disabled then check that there is no such buttons - // TODO: in composition & artifact pages - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update - // TC1444530 - Update Deployment Artifact With Invalid Type - @Test - public void updateDeploymentArtifactWithInvalidType() throws Exception { - - if(true){ - throw new SkipException("Open bug 310971 and 369139"); - } - String folder ="US825779"; - String fileName = "ImportTC1444530.csar"; - - List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>(); - - 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); - - GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1"); - - fileName = "UpdateTC1444530.csar"; - deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1")); - - updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, null, null, null); - } - - // US825779 - Story: [BE] Import VSP - VF informational artifacts - Update // TC1444531 - Update Informational Artifact With Invalid Type @Test 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 7f67978aea..7b7fb8ed39 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 @@ -20,13 +20,13 @@ package org.openecomp.sdc.ci.tests.execute.setup; +import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; + import java.util.HashMap; import java.util.LinkedList; import java.util.Map.Entry; import java.util.Set; -import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; - public class ArtifactsCorrelationManager { private static HashMap<String, LinkedList<HeatMetaFirstLevelDefinition>> vNFArtifactsCorrelationMap = new HashMap<String, LinkedList<HeatMetaFirstLevelDefinition>>(); 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 a20e3db2de..f34ada6a70 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 @@ -20,24 +20,16 @@ package org.openecomp.sdc.ci.tests.execute.setup; -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.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; - 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.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + public class AttFtpClient { private static final AttFtpClient instance = new AttFtpClient(); 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 0a66f5f610..31b878a94b 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 @@ -33,10 +33,8 @@ import org.openecomp.sdc.ci.tests.utils.rest.AutomationUtils; import org.testng.ITestContext; import java.io.File; -import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; -import java.util.Date; import java.util.GregorianCalendar; public class ExtentManager { 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 6718150115..f90b7107e4 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 @@ -20,19 +20,18 @@ package org.openecomp.sdc.ci.tests.execute.setup; -import java.io.File; -import java.io.IOException; -import java.util.UUID; - -import org.openecomp.sdc.ci.tests.api.SomeInterface; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; - import com.aventstack.extentreports.ExtentTest; import com.aventstack.extentreports.MediaEntityBuilder; import com.aventstack.extentreports.Status; import com.aventstack.extentreports.markuputils.ExtentColor; import com.aventstack.extentreports.markuputils.Markup; import com.aventstack.extentreports.markuputils.MarkupHelper; +import org.openecomp.sdc.ci.tests.api.SomeInterface; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; + +import java.io.File; +import java.io.IOException; +import java.util.UUID; public class ExtentTestActions { 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 f996514dc0..d082f2d174 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 @@ -20,25 +20,19 @@ package org.openecomp.sdc.ci.tests.execute.setup; -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; - -import org.slf4j.LoggerFactory; - +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; import com.github.markusbernhardt.proxy.ProxySearch; import com.github.markusbernhardt.proxy.ProxySearch.Strategy; import com.github.markusbernhardt.proxy.util.PlatformUtil; import com.github.markusbernhardt.proxy.util.PlatformUtil.Platform; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; import net.lightbody.bmp.BrowserMobProxyServer; +import org.slf4j.LoggerFactory; + +import java.net.*; +import java.util.HashMap; +import java.util.List; public class MobProxy { 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 ad923d5a1a..b86b694e0a 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 @@ -20,13 +20,12 @@ package org.openecomp.sdc.ci.tests.execute.setup; -import java.io.IOException; - +import com.aventstack.extentreports.Status; import org.openecomp.sdc.ci.tests.execute.setup.ExtentManager.suiteNameXml; import org.testng.ITestContext; import org.testng.ITestResult; -import com.aventstack.extentreports.Status; +import java.io.IOException; public class ReportAfterTestManager extends ExtentTestActions { 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 c8ef880a2c..397233730a 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 @@ -20,24 +20,15 @@ package org.openecomp.sdc.ci.tests.execute.setup; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Arrays; -import java.util.Map; -import java.util.UUID; -import java.util.logging.FileHandler; -import java.util.logging.Handler; -import java.util.logging.LogManager; -import java.util.logging.Logger; - +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.LoggerContext; +import com.aventstack.extentreports.ExtentTest; +import com.aventstack.extentreports.Status; +import net.lightbody.bmp.core.har.Har; import org.json.simple.JSONObject; -import org.littleshoot.proxy.impl.ClientToProxyConnection; -import org.littleshoot.proxy.impl.ProxyToServerConnection; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.config.UserCredentialsFromFile; -import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestManager; import org.openecomp.sdc.ci.tests.api.SomeInterface; +import org.openecomp.sdc.ci.tests.config.UserCredentialsFromFile; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.UserCredentials; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; @@ -59,33 +50,25 @@ import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.ITestContext; import org.testng.ITestResult; -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 com.aventstack.extentreports.ExtentReports; -import com.aventstack.extentreports.ExtentTest; -import com.aventstack.extentreports.Status; +import org.testng.annotations.*; -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.LoggerContext; -import groovyjarjarantlr.Utils; -import net.lightbody.bmp.BrowserMobProxyServer; -import net.lightbody.bmp.core.har.Har; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Arrays; +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 RE_RUN = "<html><font color=\"red\">ReRun - </font></html>"; 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); + lc.getLogger("org.apache").setLevel(Level.INFO); } /**************** CONSTANTS ****************/ @@ -95,11 +78,11 @@ public abstract class SetupCDTest extends DriverFactory { 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; @@ -107,10 +90,10 @@ public abstract class SetupCDTest extends DriverFactory { private static boolean localEnv = true; private static OnboardCSVReport csvReport; private final UserCredentialsFromFile credentialsIns = UserCredentialsFromFile.getInstance(); - - protected static ITestContext myContext; - - + + protected static ITestContext myContext; + + /**************** METHODS ****************/ public static ExtentTest getExtendTest() { SomeInterface testManager = new ExtentTestManager(); @@ -119,26 +102,26 @@ public abstract class SetupCDTest extends DriverFactory { 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) @@ -147,10 +130,10 @@ public abstract class SetupCDTest extends DriverFactory { myContext=context; setErrorConfigurationFile(); setUrl(); - ExtentManager.initReporter(getReportFolder(), REPORT_FILE_NAME, context); + 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(); @@ -161,10 +144,10 @@ public abstract class SetupCDTest extends DriverFactory { } } } - + @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") ) { @@ -175,28 +158,28 @@ public abstract class SetupCDTest extends DriverFactory { }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"); + 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(); @@ -204,9 +187,9 @@ public abstract class SetupCDTest extends DriverFactory { finally{ try { if (getConfig().getCaptureTraffic()){ - addTrafficFileToReport(result); + 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...."); @@ -220,15 +203,15 @@ public abstract class SetupCDTest extends DriverFactory { quitDriver(); } } - + } catch (Exception e) { e.printStackTrace(); - getExtendTest().log(Status.ERROR, "Exception:"+ e.toString()); - } - - - - ExtentTestManager.endTest(); + 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)) { @@ -238,8 +221,8 @@ public abstract class SetupCDTest extends DriverFactory { addResultToCSV(result, context); } // ExtentManager.closeReporter(); - FileHandling.cleanCurrentDownloadDir(); - } + FileHandling.cleanCurrentDownloadDir(); + } } public void addResultToCSV(ITestResult result, ITestContext context) { @@ -249,44 +232,44 @@ public abstract class SetupCDTest extends DriverFactory { 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); + getCsvReport().writeRow(result.getInstanceName(), name.replace(RE_RUN,""), status); // } } - + public void generateReport4Jenkins(ITestContext context) { - String suiteName = ExtentManager.getSuiteName(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); - - + 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); @@ -295,12 +278,12 @@ public abstract class SetupCDTest extends DriverFactory { } 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(); @@ -324,11 +307,11 @@ public abstract class SetupCDTest extends DriverFactory { 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); @@ -339,16 +322,16 @@ public abstract class SetupCDTest extends DriverFactory { 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); @@ -357,7 +340,7 @@ public abstract class SetupCDTest extends DriverFactory { } } } - + protected void loginToSystem(UserRoleEnum role) throws Exception { UserCredentials credentials = new UserCredentials(role.getUserId(), role.getPassword(), role.getFirstName(), role.getLastName(), role.name()); if (localEnv){ @@ -371,7 +354,7 @@ public abstract class SetupCDTest extends DriverFactory { Assert.assertTrue(buttonOK.isDisplayed(), "OK button is not displayed."); buttonOK.click(); } - GeneralUIUtils.ultimateWait(); + GeneralUIUtils.ultimateWait(); getWindowTest().setUser(credentials); } @@ -379,12 +362,12 @@ public abstract class SetupCDTest extends DriverFactory { 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); @@ -408,18 +391,18 @@ public abstract class SetupCDTest extends DriverFactory { 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(); } @@ -450,7 +433,7 @@ public abstract class SetupCDTest extends DriverFactory { user.setFirstName(role.getFirstName()); user.setRole(role.name()); user.setLastName(role.getLastName()); - + getWindowTest().setUser(user); } @@ -536,9 +519,9 @@ public abstract class SetupCDTest extends DriverFactory { } } }*/ - + public void addTrafficFileToReport(ITestResult result) { - try { + try { // Get the HAR data Har har = MobProxy.getPoxyServer().getHar(); String shortUUID = UUID.randomUUID().toString().split("-")[0]; @@ -546,36 +529,36 @@ public abstract class SetupCDTest extends DriverFactory { 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("---------------------"); @@ -585,11 +568,11 @@ public abstract class SetupCDTest extends DriverFactory { 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)); 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 1dc099e9ea..da89c51633 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 @@ -20,26 +20,27 @@ package org.openecomp.sdc.ci.tests.execute.setup; -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.UUID; - +import net.lightbody.bmp.BrowserMobProxyServer; +import net.lightbody.bmp.client.ClientUtil; +import net.lightbody.bmp.proxy.CaptureType; import org.openecomp.sdc.ci.tests.config.Config; import org.openecomp.sdc.ci.tests.utilities.FileHandling; import org.openqa.selenium.Platform; +import org.openqa.selenium.UnexpectedAlertBehaviour; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; -//import org.openqa.selenium.firefox.FirefoxOptions; // Selenium 3.4.0 change import org.openqa.selenium.firefox.FirefoxProfile; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.LocalFileDetector; import org.openqa.selenium.remote.RemoteWebDriver; -import net.lightbody.bmp.BrowserMobProxyServer; -import net.lightbody.bmp.client.ClientUtil; -import net.lightbody.bmp.proxy.CaptureType; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.UUID; + +//import org.openqa.selenium.firefox.FirefoxOptions; // Selenium 3.4.0 change public class WebDriverThread { @@ -86,11 +87,13 @@ public class WebDriverThread { 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.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); 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 8df3c596fe..3e61861cf0 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 @@ -20,10 +20,10 @@ package org.openecomp.sdc.ci.tests.execute.setup; -import java.io.File; - import org.openecomp.sdc.be.model.User; +import java.io.File; + public class WindowTest { public WindowTest(){ |