diff options
Diffstat (limited to 'integration-tests/src/test')
25 files changed, 758 insertions, 249 deletions
diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/data/providers/OnboardingDataProviders.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/data/providers/OnboardingDataProviders.java index 16c9521ac6..10d7b38899 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/data/providers/OnboardingDataProviders.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/data/providers/OnboardingDataProviders.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; -import org.onap.sdc.backend.ci.tests.datatypes.enums.XnfTypeEnum; +import org.onap.sdc.backend.ci.tests.datatypes.enums.PackageTypeEnum; import org.onap.sdc.backend.ci.tests.utils.general.FileHandling; import org.onap.sdc.backend.ci.tests.utils.general.OnboardingUtils; import org.slf4j.Logger; @@ -40,7 +40,7 @@ import org.testng.annotations.DataProvider; public final class OnboardingDataProviders { private static final Logger LOGGER = LoggerFactory.getLogger(OnboardingDataProviders.class); - private static final String VNF_FILE_PATH = FileHandling.getXnfRepositoryPath(XnfTypeEnum.VNF); + private static final String VNF_FILE_PATH = FileHandling.getPackageRepositoryPath(PackageTypeEnum.VNF); private OnboardingDataProviders() { @@ -61,55 +61,55 @@ public final class OnboardingDataProviders { @DataProvider(name = "VNF_List", parallel = true) private static Object[][] vnfList() { - final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF); + final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.VNF); LOGGER.debug(String.format("There are %s package file(s) to test", fileNamesFromFolder.size())); return provideData(fileNamesFromFolder, VNF_FILE_PATH); } @DataProvider(name = "PNF_List", parallel = true) private static Object[][] pnfList() { - return provideData(OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.PNF), - FileHandling.getXnfRepositoryPath(XnfTypeEnum.PNF)); + return provideData(OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.PNF), + FileHandling.getPackageRepositoryPath(PackageTypeEnum.PNF)); } @DataProvider(name = "CNF_List", parallel = true) private static Object[][] cnfList() { - final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.CNF); + final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.CNF); LOGGER.debug(String.format("There are %s package file(s) to test", fileNamesFromFolder.size())); - return provideData(fileNamesFromFolder, FileHandling.getXnfRepositoryPath(XnfTypeEnum.CNF)); + return provideData(fileNamesFromFolder, FileHandling.getPackageRepositoryPath(PackageTypeEnum.CNF)); } @DataProvider(name = "Invalid_CNF_List", parallel = true) private static Object[][] invalidCnfList() { - final List<String> fileNamesFromFolder = OnboardingUtils.getInvalidXnfNamesFileList(XnfTypeEnum.CNF); + final List<String> fileNamesFromFolder = OnboardingUtils.getInvalidXnfNamesFileList(PackageTypeEnum.CNF); LOGGER.debug(String.format("There are %s package file(s) to test", fileNamesFromFolder.size())); - return provideData(fileNamesFromFolder, FileHandling.getXnfRepositoryPath(XnfTypeEnum.CNF) + File.separator + OnboardingUtils.INVALID_XNFS_SUBPATH); + return provideData(fileNamesFromFolder, FileHandling.getPackageRepositoryPath(PackageTypeEnum.CNF) + File.separator + OnboardingUtils.INVALID_XNFS_SUBPATH); } @DataProvider(name = "CNF_Helm_Validator_List", parallel = true) private static Object[][] cnfForHelmValidatorList() { - final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.CNF_HELM); + final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.CNF_HELM); LOGGER.debug(String.format("There are %s package file(s) to test", fileNamesFromFolder.size())); - return provideData(fileNamesFromFolder, FileHandling.getXnfRepositoryPath(XnfTypeEnum.CNF_HELM)); + return provideData(fileNamesFromFolder, FileHandling.getPackageRepositoryPath(PackageTypeEnum.CNF_HELM)); } @DataProvider(name = "CNF_With_Warning_Helm_Validator_List", parallel = true) private static Object[][] cnfWithWarningForHelmValidatorList() { - final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesWithWarningsFileList(XnfTypeEnum.CNF_HELM); + final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesWithWarningsFileList(PackageTypeEnum.CNF_HELM); LOGGER.debug(String.format("There are %s package file(s) to test", fileNamesFromFolder.size())); - return provideData(fileNamesFromFolder, FileHandling.getXnfRepositoryPath(XnfTypeEnum.CNF_HELM) + File.separator + OnboardingUtils.WITH_WARNINGS_XNFS_SUBPATH); + return provideData(fileNamesFromFolder, FileHandling.getPackageRepositoryPath(PackageTypeEnum.CNF_HELM) + File.separator + OnboardingUtils.WITH_WARNINGS_XNFS_SUBPATH); } @DataProvider(name = "Invalid_CNF_Helm_Validator_List", parallel = true) private static Object[][] invalidCnfForHelmValidatorList() { - final List<String> fileNamesFromFolder = OnboardingUtils.getInvalidXnfNamesFileList(XnfTypeEnum.CNF_HELM); + final List<String> fileNamesFromFolder = OnboardingUtils.getInvalidXnfNamesFileList(PackageTypeEnum.CNF_HELM); LOGGER.debug(String.format("There are %s package file(s) to test", fileNamesFromFolder.size())); - return provideData(fileNamesFromFolder, FileHandling.getXnfRepositoryPath(XnfTypeEnum.CNF_HELM) + File.separator + OnboardingUtils.INVALID_XNFS_SUBPATH); + return provideData(fileNamesFromFolder, FileHandling.getPackageRepositoryPath(PackageTypeEnum.CNF_HELM) + File.separator + OnboardingUtils.INVALID_XNFS_SUBPATH); } @DataProvider(name = "Single_VNF", parallel = true) private static Object[][] singleVNF() { - final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF); + final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.VNF); final List<String> newList = new ArrayList<>(); newList.add(fileNamesFromFolder.get(0)); LOGGER.debug(String.format("There are %s zip file(s) to test", fileNamesFromFolder.size())); @@ -118,7 +118,7 @@ public final class OnboardingDataProviders { @DataProvider(name = "softwareInformationPnf", parallel = true) private static Object[][] softwareInformationPnf() { - final List<String> pnfPackageFileNameList = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.PNF); + final List<String> pnfPackageFileNameList = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.PNF); if (CollectionUtils.isEmpty(pnfPackageFileNameList)) { fail("Could not create softwareInformationPnf datasource"); } @@ -130,7 +130,7 @@ public final class OnboardingDataProviders { pnfPackage)); } - final String folderPath = FileHandling.getXnfRepositoryPath(XnfTypeEnum.PNF); + final String folderPath = FileHandling.getPackageRepositoryPath(PackageTypeEnum.PNF); final Object[][] parametersArray = new Object[1][]; parametersArray[0] = new Object[]{folderPath, softwareInformationPnfPackage.get(), Arrays.asList("5gDUv18.05.201", "5gDUv18.06.205")}; @@ -139,7 +139,7 @@ public final class OnboardingDataProviders { @DataProvider(name = "etsiVnfCnfOnboardPackages") private static Object[][] etsiVnf() { - final List<String> vnfPackageFileNameList = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.ETSI); + final List<String> vnfPackageFileNameList = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.ETSI); if (CollectionUtils.isEmpty(vnfPackageFileNameList)) { fail("Could not create etsiSingleVnfCnf datasource"); } @@ -153,7 +153,7 @@ public final class OnboardingDataProviders { etsiPackages)); } - final String folderPath = FileHandling.getXnfRepositoryPath(XnfTypeEnum.ETSI); + final String folderPath = FileHandling.getPackageRepositoryPath(PackageTypeEnum.ETSI); final Object[][] parametersArray = new Object[2][]; parametersArray[0] = new Object[]{folderPath, etsiPackages.get(0)}; parametersArray[1] = new Object[]{folderPath, etsiPackages.get(1)}; @@ -176,7 +176,7 @@ public final class OnboardingDataProviders { fail(String.format("Could not create vfcList datasource, one of the vfc file '%s' was not found", vfcFiles)); } - final String folderPath = FileHandling.getXnfRepositoryPath(XnfTypeEnum.VFC); + final String folderPath = FileHandling.getPackageRepositoryPath(PackageTypeEnum.VFC); final Object[][] parametersArray = new Object[2][]; parametersArray[0] = new Object[]{folderPath, vfcFiles.get(0)}; parametersArray[1] = new Object[]{folderPath, vfcFiles.get(1)}; diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/enums/XnfTypeEnum.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/enums/PackageTypeEnum.java index 152612a77f..0e67cdaeb9 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/enums/XnfTypeEnum.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/enums/PackageTypeEnum.java @@ -25,7 +25,7 @@ import lombok.Getter; @AllArgsConstructor @Getter -public enum XnfTypeEnum { +public enum PackageTypeEnum { CNF("CNF"), CNF_HELM("CNF_HELM"), diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/FileHandling.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/FileHandling.java index dcb3ecb14b..81ca398813 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/FileHandling.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/FileHandling.java @@ -8,9 +8,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -43,9 +43,9 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; import org.apache.commons.io.FileUtils; -import org.onap.sdc.backend.ci.tests.datatypes.enums.XnfTypeEnum; -import org.openecomp.sdc.be.model.DataTypeDefinition; import org.onap.sdc.backend.ci.tests.api.ComponentBaseTest; +import org.onap.sdc.backend.ci.tests.datatypes.enums.PackageTypeEnum; +import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.common.util.GeneralUtility; import org.yaml.snakeyaml.Yaml; @@ -59,9 +59,9 @@ public class FileHandling { Map<?, ?> map = (Map<?, ?>) yaml.load(inputStream); return map; } - + /** - * The method return map fetched objects by pattern from yaml file + * The method return map fetched objects by pattern from yaml file * @param yamlFile * @param pattern * @return @@ -72,19 +72,19 @@ public class FileHandling { Map<String, Object> objectMap = getObjectMapByPattern(yamlFileToMap, pattern); return objectMap; } - + @SuppressWarnings("unchecked") public static Map<String, Object> getObjectMapByPattern(Map<?, ?> parseUpdetedEnvFile, String pattern) { Map<String, Object> objectMap = null; - + Object objectUpdetedEnvFile = parseUpdetedEnvFile.get(pattern); if(objectUpdetedEnvFile instanceof HashMap){ objectMap = (Map<String, Object>) objectUpdetedEnvFile; } return objectMap; } - - + + public static Map<String, DataTypeDefinition> parseDataTypesYaml(String filePath) throws Exception { @SuppressWarnings("unchecked") Map<String, DataTypeDefinition> dataTypesMap = (Map<String, DataTypeDefinition>) parseYamlFile(filePath); @@ -104,11 +104,11 @@ public class FileHandling { public static String getBasePath() { return System.getProperty("user.dir") + File.separator; } - + public static String getSdcVnfsPath() { return getBasePath() + Paths.get("..", "..", "sdc-vnfs").toString(); } - + public static String getDriversPath() { return getBasePath() + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "ci" + File.separator + "drivers" + File.separator; @@ -117,7 +117,7 @@ public class FileHandling { public static String getResourcesFilesPath() { return getSdcVnfsPath()+ File.separator + "ui-tests" + File.separator + "Files" + File.separator; } - + public static String getResourcesEnvFilesPath() { return getBasePath() + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "Files" + File.separator + "ResourcesEnvFiles" +File.separator; @@ -132,14 +132,13 @@ public class FileHandling { return getCiFilesPath() + File.separator + "conf" + File.separator; } - - private static EnumMap<XnfTypeEnum, String> XNF_REPOSITORY_PATHS_MAP = new EnumMap<>(Map.of( - XnfTypeEnum.PNF, getPnfRepositoryPath(), - XnfTypeEnum.CNF, getCnfRepositoryPath(), - XnfTypeEnum.CNF_HELM, getCnfRepositoryForHelmValidatorPath(), - XnfTypeEnum.VNF, getVnfRepositoryPath(), - XnfTypeEnum.ETSI, getEtsiRepositoryPath(), - XnfTypeEnum.VFC, getVfcRepositoryPath() + private static final EnumMap<PackageTypeEnum, String> PACKAGE_REPOSITORY_PATHS_MAP = new EnumMap<>(Map.of( + PackageTypeEnum.PNF, getPnfRepositoryPath(), + PackageTypeEnum.CNF, getCnfRepositoryPath(), + PackageTypeEnum.CNF_HELM, getCnfRepositoryForHelmValidatorPath(), + PackageTypeEnum.VNF, getVnfRepositoryPath(), + PackageTypeEnum.ETSI, getEtsiRepositoryPath(), + PackageTypeEnum.VFC, getVfcRepositoryPath() )); public static String getVnfRepositoryPath() { @@ -162,14 +161,14 @@ public class FileHandling { private static String getVfcRepositoryPath() { return getFilePath("VFCs"); } - public static String getXnfRepositoryPath(XnfTypeEnum xnfTypeEnum) { - return XNF_REPOSITORY_PATHS_MAP.get(xnfTypeEnum); + public static String getPackageRepositoryPath(PackageTypeEnum packageTypeEnum) { + return PACKAGE_REPOSITORY_PATHS_MAP.get(packageTypeEnum); } public static String getPortMirroringRepositoryPath() { return getFilePath("PortMirroring"); } - + public static File getConfigFile(String configFileName) throws Exception { File configFile = new File(FileHandling.getBasePath() + File.separator + "conf" + File.separator + configFileName); if (!configFile.exists()) { @@ -182,13 +181,13 @@ public class FileHandling { try { File dir = new File(filepath); List<String> filenames = new ArrayList<String>(); - + FilenameFilter extensionFilter = new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(extension); } }; - + if (dir.isDirectory()) { for (File file : dir.listFiles(extensionFilter)) { filenames.add(file.getName()); @@ -206,13 +205,13 @@ public class FileHandling { List<String> filenames = new ArrayList<String>(); try { File dir = new File(filepath); - + FilenameFilter extensionFilter = new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(extension); } }; - + if (dir.isDirectory()) { for (File file : dir.listFiles(extensionFilter)) { filenames.add(file.getName()); @@ -225,18 +224,18 @@ public class FileHandling { } return filenames; } - + public static String[] getArtifactsFromZip(String filepath, String zipFilename){ try { ZipFile zipFile = new ZipFile(filepath + File.separator + zipFilename); Enumeration<? extends ZipEntry> entries = zipFile.entries(); - + String[] artifactNames = new String[zipFile.size() - 1]; int i = 0; while(entries.hasMoreElements()){ ZipEntry nextElement = entries.nextElement(); - if (!nextElement.isDirectory()){ + if (!nextElement.isDirectory()){ if (!nextElement.getName().equals("MANIFEST.json")){ String name = nextElement.getName(); artifactNames[i++] = name; @@ -246,28 +245,28 @@ public class FileHandling { zipFile.close(); return artifactNames; } catch(ZipException zipEx) { - System.err.println("Error in zip file named : " + zipFilename); + System.err.println("Error in zip file named : " + zipFilename); zipEx.printStackTrace(); } catch (IOException e) { System.err.println("Unhandled exception : "); e.printStackTrace(); } - + return null; - + } public static List<String> getFileNamesFromZip(String zipFileLocation){ try{ ZipFile zipFile = new ZipFile(zipFileLocation); Enumeration<? extends ZipEntry> entries = zipFile.entries(); - + List<String> artifactNames = new ArrayList<>(); int i = 0; while(entries.hasMoreElements()){ ZipEntry nextElement = entries.nextElement(); - if (!nextElement.isDirectory()){ + if (!nextElement.isDirectory()){ String name = nextElement.getName(); artifactNames.add(name); } @@ -276,7 +275,7 @@ public class FileHandling { return artifactNames; } catch(ZipException zipEx){ - System.err.println("Error in zip file named : " + zipFileLocation); + System.err.println("Error in zip file named : " + zipFileLocation); zipEx.printStackTrace(); } catch (IOException e) { System.err.println("Unhandled exception : "); @@ -284,7 +283,7 @@ public class FileHandling { } return null; } - + public static List<String> getZipFileNamesFromFolder(String filepath) { List<String> fileNamesListFromFolder = filterFileNamesListFromFolder(filepath, ".zip"); fileNamesListFromFolder.addAll(filterFileNamesListFromFolder(filepath, ".csar")); @@ -301,7 +300,7 @@ public class FileHandling { } return fileCounter; } - + /** * @param dirPath * @return last modified file name from dirPath directory @@ -336,7 +335,7 @@ public class FileHandling { System.out.println("Failed to clean " + dir); } } - + public static void createDirectory(String directoryPath) { File directory = new File(String.valueOf(directoryPath)); if (! directory.exists()){ @@ -385,7 +384,7 @@ public class FileHandling { return dir.getPath(); } - + public static boolean isFileDownloaded(String downloadPath, String fileName) { boolean flag = false; File dir = new File(downloadPath); @@ -396,13 +395,13 @@ public class FileHandling { } return flag; } - + public static String getMD5OfFile(File file) throws IOException { String content = FileUtils.readFileToString(file); String md5 = GeneralUtility.calculateMD5Base64EncodedByString(content); return md5; } - + public static File createEmptyFile(String fileToCreate) { File file= new File(fileToCreate); try { @@ -417,7 +416,7 @@ public class FileHandling { } return file; } - + public static File createEmptyFile(File fileToCreate) { try { if(fileToCreate.exists()){ @@ -431,9 +430,9 @@ public class FileHandling { } return fileToCreate; } - + public static void deleteFile(File file){ - + try{ if(file.exists()){ file.deleteOnExit(); @@ -446,8 +445,8 @@ public class FileHandling { } } - - + + /** * get file list from directory by extension array * @param directory @@ -455,10 +454,10 @@ public class FileHandling { * @return */ public static List<File> getHeatAndHeatEnvArtifactsFromZip(File directory, String[] okFileExtensions){ - + List<File> fileList = new ArrayList<>(); File[] files = directory.listFiles(); - + for (String extension : okFileExtensions){ for(File file : files){ if (file.getName().toLowerCase().endsWith(extension)){ diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/OnboardingUtils.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/OnboardingUtils.java index 6630345559..18ac63b349 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/OnboardingUtils.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/OnboardingUtils.java @@ -24,8 +24,7 @@ package org.onap.sdc.backend.ci.tests.utils.general; import static org.onap.sdc.backend.ci.tests.utils.general.FileHandling.filterFileNamesListFromFolder; import java.io.File; -import java.nio.file.Paths; -import org.onap.sdc.backend.ci.tests.datatypes.enums.XnfTypeEnum; +import org.onap.sdc.backend.ci.tests.datatypes.enums.PackageTypeEnum; import org.onap.sdc.backend.ci.tests.datatypes.http.HttpHeaderEnum; import org.onap.sdc.backend.ci.tests.datatypes.http.HttpRequest; import org.onap.sdc.backend.ci.tests.datatypes.http.RestResponse; @@ -190,8 +189,8 @@ public class OnboardingUtils { * @return * The method returns XNF names list from Files directory under sdc repository */ - public static List<String> getXnfNamesFileList(XnfTypeEnum xnfTypeEnum) { - String filepath = FileHandling.getXnfRepositoryPath(xnfTypeEnum); + public static List<String> getXnfNamesFileList(PackageTypeEnum packageTypeEnum) { + String filepath = FileHandling.getPackageRepositoryPath(packageTypeEnum); List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath); fileNamesFromFolder.removeAll(excludeXnfList); return fileNamesFromFolder; @@ -201,8 +200,8 @@ public class OnboardingUtils { * @return * The method returns names list of invalid XNF packages from Files directory under sdc repository */ - public static List<String> getInvalidXnfNamesFileList(XnfTypeEnum xnfTypeEnum) { - String filepath = FileHandling.getXnfRepositoryPath(xnfTypeEnum) + File.separator + INVALID_XNFS_SUBPATH; + public static List<String> getInvalidXnfNamesFileList(PackageTypeEnum packageTypeEnum) { + String filepath = FileHandling.getPackageRepositoryPath(packageTypeEnum) + File.separator + INVALID_XNFS_SUBPATH; return FileHandling.getZipFileNamesFromFolder(filepath); } @@ -210,8 +209,8 @@ public class OnboardingUtils { * @return * The method returns names list of XNF packages with warnings from Files directory under sdc repository */ - public static List<String> getXnfNamesWithWarningsFileList(XnfTypeEnum xnfTypeEnum) { - String filepath = FileHandling.getXnfRepositoryPath(xnfTypeEnum) + File.separator + WITH_WARNINGS_XNFS_SUBPATH; + public static List<String> getXnfNamesWithWarningsFileList(PackageTypeEnum packageTypeEnum) { + String filepath = FileHandling.getPackageRepositoryPath(packageTypeEnum) + File.separator + WITH_WARNINGS_XNFS_SUBPATH; return FileHandling.getZipFileNamesFromFolder(filepath); } @@ -236,7 +235,7 @@ public class OnboardingUtils { * @return a list of VFC files */ public static List<String> getVfcFilenameList() { - final String filepath = FileHandling.getXnfRepositoryPath(XnfTypeEnum.VFC); + final String filepath = FileHandling.getPackageRepositoryPath(PackageTypeEnum.VFC); List<String> fileNamesListFromFolder = filterFileNamesListFromFolder(filepath, ".yml"); fileNamesListFromFolder.addAll(filterFileNamesListFromFolder(filepath, ".yaml")); return fileNamesListFromFolder; @@ -247,7 +246,7 @@ public class OnboardingUtils { * The method returns VNF names list from Files directory under sdc-vnfs repository excluding zip files that known as failed in tosca parser */ public static List<String> getVnfNamesFileListExcludeToscaParserFailure() { - List<String> fileNamesFromFolder = getXnfNamesFileList(XnfTypeEnum.VNF); + List<String> fileNamesFromFolder = getXnfNamesFileList(PackageTypeEnum.VNF); fileNamesFromFolder.removeAll(excludeXnfListForToscaParser); return fileNamesFromFolder; } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/dataProvider/OnbordingDataProviders.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/dataProvider/OnbordingDataProviders.java index 41b247c338..b49307e5dd 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/dataProvider/OnbordingDataProviders.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/dataProvider/OnbordingDataProviders.java @@ -21,7 +21,7 @@ package org.onap.sdc.frontend.ci.tests.dataProvider; -import org.onap.sdc.backend.ci.tests.datatypes.enums.XnfTypeEnum; +import org.onap.sdc.backend.ci.tests.datatypes.enums.PackageTypeEnum; import org.onap.sdc.backend.ci.tests.utils.general.OnboardingUtils; import org.onap.sdc.frontend.ci.tests.utilities.FileHandling; import org.openecomp.sdc.logging.api.Logger; @@ -52,25 +52,25 @@ public class OnbordingDataProviders { @DataProvider(name = "VNF_List", parallel = true) private static Object[][] VnfList() throws Exception { - List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF); + List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.VNF); return provideData(fileNamesFromFolder, filepath); } @DataProvider(name = "CNF_List", parallel = true) private static Object[][] cnfList() { - List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.CNF); + List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.CNF); return provideData(fileNamesFromFolder, FileHandling.getCnfRepositoryPath()); } @DataProvider(name = "CNF_Helm_Validator_List", parallel = true) private static Object[][] cnfForHelmValidatorList() { - List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.CNF_HELM); + List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.CNF_HELM); return provideData(fileNamesFromFolder, FileHandling.getCnfForHelmValidatorRepositoryPath()); } @DataProvider(name = "CNF_With_Warning_Helm_Validator_List", parallel = true) private static Object[][] cnfWithWarningForHelmValidatorList() { - List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesWithWarningsFileList(XnfTypeEnum.CNF_HELM); + List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesWithWarningsFileList(PackageTypeEnum.CNF_HELM); Object[][] objects = provideData(fileNamesFromFolder, FileHandling.getCnfWithWarningForHelmValidatorRepositoryPath()); return objects; @@ -78,13 +78,13 @@ public class OnbordingDataProviders { @DataProvider(name = "Invalid_CNF_Helm_Validator_List", parallel = true) private static Object[][] invalidCnfForHelmValidatorList() { - List<String> fileNamesFromFolder = OnboardingUtils.getInvalidXnfNamesFileList(XnfTypeEnum.CNF_HELM); + List<String> fileNamesFromFolder = OnboardingUtils.getInvalidXnfNamesFileList(PackageTypeEnum.CNF_HELM); return provideData(fileNamesFromFolder, FileHandling.getInvalidCnfForHelmValidatorRepositoryPath()); } @DataProvider(name = "Invalid_CNF_List", parallel = true) private static Object[][] invalidCnfList() { - List<String> fileNamesFromFolder = OnboardingUtils.getInvalidXnfNamesFileList(XnfTypeEnum.CNF); + List<String> fileNamesFromFolder = OnboardingUtils.getInvalidXnfNamesFileList(PackageTypeEnum.CNF); return provideData(fileNamesFromFolder, FileHandling.getCnfRepositoryPath()); } @@ -110,7 +110,7 @@ public class OnbordingDataProviders { @DataProvider(name = "Single_Vsp_Test_Csar", parallel = true) private static Object[][] singleVspTestCsar() throws Exception { - List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF); + List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.VNF); if (!fileNamesFromFolder.contains(VSP_VGW_CSAR)) { Assert.fail("Vsp Test file is not exits in the path"); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/CategorySelect.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/CategorySelect.java new file mode 100644 index 0000000000..41e5ba6dfd --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/CategorySelect.java @@ -0,0 +1,36 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.datatypes; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * Represents values in a category select html element + */ +@AllArgsConstructor +@Getter +public enum CategorySelect { + COMMON_NETWORK_RESOURCES("resourceNewCategory.network l4+.common network resources"); + + final String option; +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/ComponentProperty.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/ComponentProperty.java new file mode 100644 index 0000000000..4ee0e4ee84 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/ComponentProperty.java @@ -0,0 +1,55 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.datatypes; + +import java.util.List; +import java.util.Map; +import lombok.EqualsAndHashCode; +import lombok.Getter; + +/** + * Represents a property from a Component. + * + * @param <T> the type of the property + */ +@Getter +@EqualsAndHashCode +public class ComponentProperty<T> { + + private final String name; + @EqualsAndHashCode.Exclude + private final T value; + + public ComponentProperty(final String name) { + this.name = name; + this.value = null; + } + + public ComponentProperty(final String name, final T value) { + this.name = name; + if (!(value instanceof Map) && !(value instanceof String) && !(value instanceof List)) { + throw new UnsupportedOperationException("Properties should only be of type String, List or Map"); + } + this.value = value; + } + +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/ModelName.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/ModelName.java new file mode 100644 index 0000000000..d5df5df198 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/ModelName.java @@ -0,0 +1,36 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.datatypes; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * Stores default SDC model names + */ +@AllArgsConstructor +@Getter +public enum ModelName { + ETSI_SOL001_v2_5_1("ETSI SOL001 v2.5.1"); + + private String name; +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/VspCreateData.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/VspCreateData.java new file mode 100644 index 0000000000..ac0552289b --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/VspCreateData.java @@ -0,0 +1,39 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.datatypes; + +import lombok.Data; + +/** + * Represents the data to create a VSP + */ +@Data +public class VspCreateData { + + private String name; + private String vendor; + private CategorySelect category; + private String description; + private VspOnboardingProcedure onboardingProcedure; + private String model; + +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/VspOnboardingProcedure.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/VspOnboardingProcedure.java new file mode 100644 index 0000000000..847798275a --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/VspOnboardingProcedure.java @@ -0,0 +1,26 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.datatypes; + +public enum VspOnboardingProcedure { + MANUAL, NETWORK_PACKAGE +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiModelUiTests.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiModelUiTests.java new file mode 100644 index 0000000000..ce3254f296 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiModelUiTests.java @@ -0,0 +1,195 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.execute.sanity; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasKey; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.fail; + +import com.aventstack.extentreports.Status; +import java.nio.file.Path; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import org.onap.sdc.backend.ci.tests.datatypes.enums.PackageTypeEnum; +import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory; +import org.onap.sdc.frontend.ci.tests.datatypes.CategorySelect; +import org.onap.sdc.frontend.ci.tests.datatypes.ComponentProperty; +import org.onap.sdc.frontend.ci.tests.datatypes.ModelName; +import org.onap.sdc.frontend.ci.tests.datatypes.VspCreateData; +import org.onap.sdc.frontend.ci.tests.datatypes.VspOnboardingProcedure; +import org.onap.sdc.frontend.ci.tests.exception.UnzipException; +import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory; +import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest; +import org.onap.sdc.frontend.ci.tests.flow.CheckComponentPropertiesFlow; +import org.onap.sdc.frontend.ci.tests.flow.CreateResourceFromVspFlow; +import org.onap.sdc.frontend.ci.tests.flow.CreateVlmFlow; +import org.onap.sdc.frontend.ci.tests.flow.CreateVspFlow; +import org.onap.sdc.frontend.ci.tests.flow.DownloadCsarArtifactFlow; +import org.onap.sdc.frontend.ci.tests.flow.ImportVspFlow; +import org.onap.sdc.frontend.ci.tests.flow.exception.UiTestFlowRuntimeException; +import org.onap.sdc.frontend.ci.tests.pages.ComponentPage; +import org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage; +import org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage; +import org.onap.sdc.frontend.ci.tests.pages.TopNavComponent; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; +import org.onap.sdc.frontend.ci.tests.utilities.FileHandling; +import org.openqa.selenium.WebDriver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.Test; +import org.yaml.snakeyaml.Yaml; + +public class EtsiModelUiTests extends SetupCDTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(EtsiModelUiTests.class); + + private WebDriver webDriver; + + @Test + public void etsiNetworkServiceTest() throws UnzipException { + webDriver = DriverFactory.getDriver(); + + createVlm(); + final String resourceName = createVsp(); + ResourceCreatePage resourceCreatePage = importVsp(resourceName); + resourceCreatePage = createVf(resourceName, resourceCreatePage); + resourceCreatePage.isLoaded(); + final ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage = checkVfProperties(resourceCreatePage); + resourcePropertiesAssignmentPage.isLoaded(); + final DownloadCsarArtifactFlow downloadCsarArtifactFlow = downloadCsarArtifact(resourcePropertiesAssignmentPage); + final ToscaArtifactsPage toscaArtifactsPage = downloadCsarArtifactFlow.getLandedPage() + .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected ToscaArtifactsPage")); + toscaArtifactsPage.isLoaded(); + final String downloadedCsarName = toscaArtifactsPage.getDownloadedArtifactList().get(0); + checkCsarPackage(resourceName, downloadedCsarName); + toscaArtifactsPage.goToHomePage(); + } + + private ResourcePropertiesAssignmentPage checkVfProperties(final ComponentPage componentPage) { + final Set<ComponentProperty<?>> componentPropertySet = Set.of( + new ComponentProperty<>("descriptor_id", "descriptor_id"), + new ComponentProperty<>("descriptor_version", "v1.0.1"), + new ComponentProperty<>("flavour_description", "flavour_description"), + new ComponentProperty<>("flavour_id", "flavour_id"), + new ComponentProperty<>("product_name", "product_name"), + new ComponentProperty<>("provider", "provider"), + new ComponentProperty<>("software_version", "v1.0.1"), + new ComponentProperty<>("vnfm_info", List.of("etsivnfm:v1.0.1")) + ); + + final CheckComponentPropertiesFlow checkComponentPropertiesFlow = new CheckComponentPropertiesFlow(componentPropertySet, webDriver); + final Optional<ResourcePropertiesAssignmentPage> run = checkComponentPropertiesFlow.run(componentPage); + return run.orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return ResourceCreatePage")); + } + + private ResourceCreatePage createVf(final String resourceName, final ResourceCreatePage resourceCreatePage) { + final CreateResourceFromVspFlow createResourceFlow = new CreateResourceFromVspFlow(webDriver, resourceName); + final ResourceCreatePage resourceCreatePage1 = createResourceFlow.run(resourceCreatePage) + .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return ResourceCreatePage")); + resourceCreatePage1.isLoaded(); + return resourceCreatePage1; + } + + private ResourceCreatePage importVsp(final String resourceName) { + final ImportVspFlow importVspFlow = new ImportVspFlow(webDriver, resourceName); + return importVspFlow.run() + .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return ResourceCreatePage")); + } + + private String createVsp() { + final String resourceName = ElementFactory.addRandomSuffixToName(ElementFactory.getResourcePrefix()); + final String virtualLinkableVnf = "Vnf-ETSI-SOL001-2.5.1.csar"; + final String rootFolder = org.onap.sdc.backend.ci.tests.utils.general.FileHandling.getPackageRepositoryPath(PackageTypeEnum.ETSI); + var vspCreateData = new VspCreateData(); + vspCreateData.setName(resourceName); + vspCreateData.setCategory(CategorySelect.COMMON_NETWORK_RESOURCES); + vspCreateData.setDescription("description"); + vspCreateData.setOnboardingProcedure(VspOnboardingProcedure.NETWORK_PACKAGE); + vspCreateData.setModel(ModelName.ETSI_SOL001_v2_5_1.getName()); + final CreateVspFlow createVspFlow = new CreateVspFlow(webDriver, vspCreateData, virtualLinkableVnf, rootFolder); + createVspFlow.run(new TopNavComponent(webDriver)); + return resourceName; + } + + private void createVlm() { + getExtendTest().log(Status.INFO, "Creating a VLM"); + final CreateVlmFlow createVlmFlow = new CreateVlmFlow(webDriver); + createVlmFlow.run(); + } + + private DownloadCsarArtifactFlow downloadCsarArtifact(final ComponentPage componentPage) { + final DownloadCsarArtifactFlow downloadCsarArtifactFlow = new DownloadCsarArtifactFlow(webDriver); + downloadCsarArtifactFlow.run(componentPage); + return downloadCsarArtifactFlow; + } + + private void checkCsarPackage(final String serviceName, final String downloadedCsarName) throws UnzipException { + final String downloadFolderPath = getConfig().getDownloadAutomationFolder(); + final Map<String, byte[]> filesFromZip = FileHandling.getFilesFromZip(downloadFolderPath, downloadedCsarName); + final String mainDefinitionFileName = String.format("resource-%s-template.yml", serviceName.substring(0, 1).toUpperCase() + serviceName.substring(1).toLowerCase()); + final Path mainDefinitionFilePath = Path.of("Definitions", mainDefinitionFileName); + final byte[] mainDefinitionFile = filesFromZip.get(mainDefinitionFilePath.toString()); + final Map<String, Object> mainDefinitionYamlMap = loadYamlObject(mainDefinitionFile); + final Map<String, Object> topologyTemplateTosca = getMapEntry(mainDefinitionYamlMap, "topology_template"); + assertThat(String.format("'%s' should contain a topology_template entry", mainDefinitionFilePath), topologyTemplateTosca, notNullValue()); + final Map<String, Object> substitutionMappingsTosca = getMapEntry(topologyTemplateTosca, "substitution_mappings"); + assertThat(String.format("'%s' should contain a substitution_mappings entry", mainDefinitionFilePath), substitutionMappingsTosca, notNullValue()); + final var nodeType = (String) substitutionMappingsTosca.get("node_type"); + assertThat("substitution_mappings->node_type should be as expected", nodeType, is("org.openecomp.resource.EtsiDummyVnf")); + + final Map<String, Object> nodeTemplatesTosca = getMapEntry(topologyTemplateTosca, "node_templates"); + assertThat(String.format("'%s' should contain a node_templates entry", mainDefinitionFilePath), nodeTemplatesTosca, notNullValue()); + final var expectedNode1 = "external_connection_point"; + assertThat(String.format("'%s' should contain a node_template %s entry", mainDefinitionFilePath, expectedNode1), + nodeTemplatesTosca, hasKey(expectedNode1)); + final var expectedNode2 = "vnf_virtual_link"; + assertThat(String.format("'%s' should contain a node_template %s entry", mainDefinitionFilePath, expectedNode2), + nodeTemplatesTosca, hasKey(expectedNode2)); + final var notExpectedNode1 = "etsi_dummy_vnf"; + assertThat(String.format("'%s' should not contain a node_template %s entry, as it represents the substitutable node", + mainDefinitionFilePath, notExpectedNode1), + nodeTemplatesTosca, not(hasKey(notExpectedNode1)) + ); + } + + private Map<String, Object> getMapEntry(final Map<String, Object> yamlObj, final String entryName) { + try { + return (Map<String, Object>) yamlObj.get(entryName); + } catch (final Exception e) { + final String errorMsg = String.format("Could not get the '%s' entry.", entryName); + LOGGER.error(errorMsg, e); + fail(errorMsg + "Error message: " + e.getMessage()); + } + return null; + } + + private Map<String, Object> loadYamlObject(final byte[] mainDefinitionFileBytes) { + return new Yaml().load(new String(mainDefinitionFileBytes)); + } + +} + diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiNetworkServiceUiTests.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiNetworkServiceUiTests.java index b662148d8b..936fa6ee85 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiNetworkServiceUiTests.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiNetworkServiceUiTests.java @@ -34,21 +34,26 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; +import java.util.Set; import org.apache.commons.io.FilenameUtils; import org.junit.jupiter.api.Assertions; import org.onap.sdc.backend.ci.tests.datatypes.enums.ComponentType; import org.onap.sdc.backend.ci.tests.datatypes.enums.ServiceCategoriesEnum; -import org.onap.sdc.backend.ci.tests.datatypes.enums.XnfTypeEnum; +import org.onap.sdc.backend.ci.tests.datatypes.enums.PackageTypeEnum; import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory; +import org.onap.sdc.frontend.ci.tests.datatypes.CategorySelect; import org.onap.sdc.frontend.ci.tests.datatypes.ComponentData; +import org.onap.sdc.frontend.ci.tests.datatypes.ComponentProperty; import org.onap.sdc.frontend.ci.tests.datatypes.ServiceCreateData; +import org.onap.sdc.frontend.ci.tests.datatypes.VspCreateData; +import org.onap.sdc.frontend.ci.tests.datatypes.VspOnboardingProcedure; import org.onap.sdc.frontend.ci.tests.datatypes.composition.RelationshipInformation; import org.onap.sdc.frontend.ci.tests.exception.UnzipException; import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory; import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest; import org.onap.sdc.frontend.ci.tests.flow.AddNodeToCompositionFlow; -import org.onap.sdc.frontend.ci.tests.flow.CheckEtsiNsPropertiesFlow; +import org.onap.sdc.frontend.ci.tests.flow.CheckComponentPropertiesFlow; import org.onap.sdc.frontend.ci.tests.flow.CreateResourceFromVspFlow; import org.onap.sdc.frontend.ci.tests.flow.CreateServiceFlow; import org.onap.sdc.frontend.ci.tests.flow.CreateVlmFlow; @@ -100,17 +105,17 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest { final ServiceCreateData serviceCreateData = createServiceFormData(); final CreateServiceFlow createServiceFlow = createService(serviceCreateData); - final CheckEtsiNsPropertiesFlow checkEtsiNsPropertiesFlow = checkServiceProperties(); - ServiceComponentPage serviceComponentPage = checkEtsiNsPropertiesFlow.getLandedPage() + final CheckComponentPropertiesFlow checkComponentPropertiesFlow = checkServiceProperties(); + ComponentPage componentPage = checkComponentPropertiesFlow.getLandedPage() .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected ServiceComponentPage")); //adding node - addNodesAndCreateRelationships(resourceName, serviceCreateData, serviceComponentPage); + componentPage = addNodesAndCreateRelationships(resourceName, serviceCreateData, componentPage); final Map<String, Object> propertyMap = createPropertyToEditMap(); - editProperties(serviceComponentPage, propertyMap); + editProperties(componentPage, propertyMap); - final DownloadCsarArtifactFlow downloadCsarArtifactFlow = downloadCsarArtifact(serviceComponentPage); + final DownloadCsarArtifactFlow downloadCsarArtifactFlow = downloadCsarArtifact(componentPage); final ToscaArtifactsPage toscaArtifactsPage = downloadCsarArtifactFlow.getLandedPage() .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected ToscaArtifactsPage")); @@ -121,8 +126,8 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest { checkEtsiNsPackage(createServiceFlow.getServiceCreateData().getName(), downloadedCsarName, propertyMap); } - private void addNodesAndCreateRelationships(final String resourceName, final ServiceCreateData serviceCreateData, - final ServiceComponentPage serviceComponentPage) { + private ServiceComponentPage addNodesAndCreateRelationships(final String resourceName, final ServiceCreateData serviceCreateData, + final ComponentPage componentPage) { //add first VF node final ComponentData parentComponent = new ComponentData(); parentComponent.setName(serviceCreateData.getName()); @@ -132,7 +137,7 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest { resourceToAdd.setName(resourceName); resourceToAdd.setVersion("1.0"); resourceToAdd.setComponentType(ComponentType.RESOURCE); - CompositionPage compositionPage = serviceComponentPage.goToComposition(); + CompositionPage compositionPage = componentPage.goToComposition(); AddNodeToCompositionFlow addNodeToCompositionFlow = addNodeToComposition(parentComponent, resourceToAdd, compositionPage); virtualLinkableVnf1 = addNodeToCompositionFlow.getCreatedComponentInstance() .orElseThrow(() -> new UiTestFlowRuntimeException("Could not get the created component instance")); @@ -160,7 +165,9 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest { createRelationshipFlow = new CreateRelationshipFlow(webDriver, relationshipInfoVirtualLinkToVnf2); compositionPage = (CompositionPage) createRelationshipFlow.run(compositionPage) .orElseThrow(() -> new UiTestFlowRuntimeException("Expecting a CompositionPage instance")); - compositionPage.goToServiceGeneral(); + final ServiceComponentPage serviceComponentPage = compositionPage.goToServiceGeneral(); + serviceComponentPage.isLoaded(); + return serviceComponentPage; } private ResourceCreatePage createAndCertifyVf(final String resourceName, final ResourceCreatePage resourceCreatePage) { @@ -212,8 +219,13 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest { private String createVsp() { final String resourceName = ElementFactory.addRandomSuffixToName(ElementFactory.getResourcePrefix()); final String virtualLinkableVnf = "etsi-vnf-virtual-linkable.csar"; - final String rootFolder = org.onap.sdc.backend.ci.tests.utils.general.FileHandling.getXnfRepositoryPath(XnfTypeEnum.VNF); - final CreateVspFlow createVspFlow = new CreateVspFlow(webDriver, resourceName, virtualLinkableVnf, rootFolder); + final String rootFolder = org.onap.sdc.backend.ci.tests.utils.general.FileHandling.getPackageRepositoryPath(PackageTypeEnum.VNF); + var vspCreateData = new VspCreateData(); + vspCreateData.setName(resourceName); + vspCreateData.setCategory(CategorySelect.COMMON_NETWORK_RESOURCES); + vspCreateData.setDescription("description"); + vspCreateData.setOnboardingProcedure(VspOnboardingProcedure.NETWORK_PACKAGE); + final CreateVspFlow createVspFlow = new CreateVspFlow(webDriver, vspCreateData, virtualLinkableVnf, rootFolder); createVspFlow.run(new TopNavComponent(webDriver)); return resourceName; } @@ -238,20 +250,31 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest { return createServiceFlow; } - private CheckEtsiNsPropertiesFlow checkServiceProperties() { - final CheckEtsiNsPropertiesFlow checkEtsiNsPropertiesFlow = new CheckEtsiNsPropertiesFlow(webDriver); - checkEtsiNsPropertiesFlow.run(); - return checkEtsiNsPropertiesFlow; + private CheckComponentPropertiesFlow checkServiceProperties() { + final Set<ComponentProperty<?>> componentPropertySet = Set.of( + new ComponentProperty<>("descriptor_id"), + new ComponentProperty<>("designer"), + new ComponentProperty<>("flavour_id"), + new ComponentProperty<>("invariant_id"), + new ComponentProperty<>("name"), + new ComponentProperty<>("ns_profile"), + new ComponentProperty<>("version"), + new ComponentProperty<>("service_availability_level") + ); + + final var checkVfPropertiesFlow = new CheckComponentPropertiesFlow(componentPropertySet, webDriver); + checkVfPropertiesFlow.run(); + return checkVfPropertiesFlow; } - private void editProperties(final ServiceComponentPage serviceComponentPage, final Map<String, Object> propertyMap) { + private void editProperties(final ComponentPage componentPage, final Map<String, Object> propertyMap) { final EditComponentPropertiesFlow editComponentPropertiesFlow = new EditComponentPropertiesFlow(webDriver, propertyMap); - editComponentPropertiesFlow.run(serviceComponentPage); + editComponentPropertiesFlow.run(componentPage); } - private DownloadCsarArtifactFlow downloadCsarArtifact(final ServiceComponentPage serviceComponentPage) { + private DownloadCsarArtifactFlow downloadCsarArtifact(final ComponentPage componentPage) { final DownloadCsarArtifactFlow downloadCsarArtifactFlow = new DownloadCsarArtifactFlow(webDriver); - downloadCsarArtifactFlow.run(serviceComponentPage); + downloadCsarArtifactFlow.run(componentPage); return downloadCsarArtifactFlow; } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java index c149b24907..40b6990a67 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java @@ -32,8 +32,11 @@ import org.onap.sdc.backend.ci.tests.data.providers.OnboardingDataProviders; import org.onap.sdc.backend.ci.tests.datatypes.enums.ComponentType; import org.onap.sdc.backend.ci.tests.datatypes.enums.ServiceCategoriesEnum; import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory; +import org.onap.sdc.frontend.ci.tests.datatypes.CategorySelect; import org.onap.sdc.frontend.ci.tests.datatypes.ComponentData; import org.onap.sdc.frontend.ci.tests.datatypes.ServiceCreateData; +import org.onap.sdc.frontend.ci.tests.datatypes.VspCreateData; +import org.onap.sdc.frontend.ci.tests.datatypes.VspOnboardingProcedure; import org.onap.sdc.frontend.ci.tests.exception.UnzipException; import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory; import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; @@ -96,7 +99,12 @@ public class EtsiOnboardVnfCnfUiTests extends SetupCDTest { * @param vnfCnfFile file to be onboarded */ private void runOnboardEtsiVnfCnf(final String resourceName, final String rootFolder, final String vnfCnfFile) { - final CreateVspFlow createVspFlow = new CreateVspFlow(webDriver, resourceName, vnfCnfFile, rootFolder); + var vspCreateData = new VspCreateData(); + vspCreateData.setName(resourceName); + vspCreateData.setCategory(CategorySelect.COMMON_NETWORK_RESOURCES); + vspCreateData.setDescription("description"); + vspCreateData.setOnboardingProcedure(VspOnboardingProcedure.NETWORK_PACKAGE); + final CreateVspFlow createVspFlow = new CreateVspFlow(webDriver, vspCreateData, vnfCnfFile, rootFolder); createVspFlow.run(topNavComponent); final ImportVspFlow importVspFlow = new ImportVspFlow(webDriver, resourceName); ResourceCreatePage resourceCreatePage = importVspFlow.run() diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/OnboardingFlowsUi.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/OnboardingFlowsUi.java index 5d1b3b3a60..84f25d1cd9 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/OnboardingFlowsUi.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/OnboardingFlowsUi.java @@ -41,7 +41,7 @@ import org.onap.sdc.backend.ci.tests.datatypes.ServiceReqDetails; import org.onap.sdc.backend.ci.tests.datatypes.VendorLicenseModel; import org.onap.sdc.backend.ci.tests.datatypes.VendorSoftwareProductObject; import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum; -import org.onap.sdc.backend.ci.tests.datatypes.enums.XnfTypeEnum; +import org.onap.sdc.backend.ci.tests.datatypes.enums.PackageTypeEnum; import org.onap.sdc.backend.ci.tests.utils.Utils; import org.onap.sdc.backend.ci.tests.utils.general.AtomicOperationUtils; import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory; @@ -51,7 +51,10 @@ import org.onap.sdc.backend.ci.tests.utils.general.VendorSoftwareProductRestUtil import org.onap.sdc.frontend.ci.tests.dataProvider.OnbordingDataProviders; import org.onap.sdc.frontend.ci.tests.datatypes.CanvasElement; import org.onap.sdc.frontend.ci.tests.datatypes.CanvasManager; +import org.onap.sdc.frontend.ci.tests.datatypes.CategorySelect; import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum; +import org.onap.sdc.frontend.ci.tests.datatypes.VspCreateData; +import org.onap.sdc.frontend.ci.tests.datatypes.VspOnboardingProcedure; import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory; import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest; @@ -147,7 +150,7 @@ public class OnboardingFlowsUi extends SetupCDTest { @Test public void onboardVNFTestSanity() throws Exception { - List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF); + List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(PackageTypeEnum.VNF); String vnfFile = fileNamesFromFolder.get(0); ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService(); @@ -391,7 +394,12 @@ public class OnboardingFlowsUi extends SetupCDTest { String.format("Creating VSP '%s' by onboarding package '%s' with software version '%s'", resourceName, pnfFile, swVersionsToString)); final WebDriver webDriver = DriverFactory.getDriver(); - final CreateVspFlow createVspFlow = new CreateVspFlow(webDriver, resourceName, pnfFile, rootFolder); + var vspCreateData = new VspCreateData(); + vspCreateData.setName(resourceName); + vspCreateData.setCategory(CategorySelect.COMMON_NETWORK_RESOURCES); + vspCreateData.setDescription("description"); + vspCreateData.setOnboardingProcedure(VspOnboardingProcedure.NETWORK_PACKAGE); + final CreateVspFlow createVspFlow = new CreateVspFlow(webDriver, vspCreateData, pnfFile, rootFolder); createVspFlow.run(new TopNavComponent(webDriver)); final ImportVspFlow importVspFlow = new ImportVspFlow(webDriver, resourceName); diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CheckComponentPropertiesFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CheckComponentPropertiesFlow.java new file mode 100644 index 0000000000..5796c846d1 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CheckComponentPropertiesFlow.java @@ -0,0 +1,86 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.sdc.frontend.ci.tests.flow; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import com.aventstack.extentreports.Status; +import java.util.Optional; +import java.util.Set; +import org.onap.sdc.frontend.ci.tests.datatypes.ComponentProperty; +import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; +import org.onap.sdc.frontend.ci.tests.pages.ComponentPage; +import org.onap.sdc.frontend.ci.tests.pages.PageObject; +import org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage; +import org.openqa.selenium.WebDriver; + +/** + * Check the properties in a Component + */ +public class CheckComponentPropertiesFlow extends AbstractUiTestFlow { + + private final Set<ComponentProperty<?>> componentPropertySet; + private ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage; + + public CheckComponentPropertiesFlow(final Set<ComponentProperty<?>> componentPropertySet, final WebDriver webDriver) { + super(webDriver); + this.componentPropertySet = componentPropertySet; + } + + /** + * Starts the flow in a {@link ComponentPage}. From there go to the {@link ResourcePropertiesAssignmentPage} and check for the + * properties. It does not require any page object, but can receive a {@link ComponentPage} + * + * @param pageObjects any required page object for the flow + * @return the {@link ComponentPage} + */ + @Override + public Optional<ResourcePropertiesAssignmentPage> run(final PageObject... pageObjects) { + extendTest.log(Status.INFO, "Checking component properties"); + final ComponentPage componentPage = getParameter(pageObjects, ComponentPage.class).orElseGet(() -> new ComponentPage(webDriver)); + componentPage.isLoaded(); + resourcePropertiesAssignmentPage = componentPage.goToPropertiesAssignment(); + resourcePropertiesAssignmentPage.isLoaded(); + if (componentPropertySet.isEmpty()) { + extendTest.log(Status.INFO, "Finished checking component properties. No properties were given."); + return Optional.of(resourcePropertiesAssignmentPage); + } + componentPropertySet.forEach(this::checkProperty); + ExtentTestActions.takeScreenshot(Status.INFO, "vf-properties-present", "VF properties are present"); + extendTest.log(Status.INFO, "Finished checking component properties"); + return Optional.of(resourcePropertiesAssignmentPage); + } + + @Override + public Optional<ResourcePropertiesAssignmentPage> getLandedPage() { + return Optional.ofNullable(resourcePropertiesAssignmentPage); + } + + private void checkProperty(final ComponentProperty<?> componentProperty) { + extendTest.log(Status.INFO, String.format("Checking property '%s'", componentProperty)); + assertThat(String.format("'%s' property should be present", componentProperty), + resourcePropertiesAssignmentPage.isPropertyPresent(componentProperty.getName()), is(true)); + if (componentProperty.getValue() != null) { + final Object propertyValue = resourcePropertiesAssignmentPage.getPropertyValue(componentProperty.getName()); + assertThat("'%s' property should have the expected value", propertyValue, is(componentProperty.getValue())); + } + } +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CheckEtsiNsPropertiesFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CheckEtsiNsPropertiesFlow.java deleted file mode 100644 index 343c7f670a..0000000000 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CheckEtsiNsPropertiesFlow.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.sdc.frontend.ci.tests.flow; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -import com.aventstack.extentreports.Status; -import java.util.Optional; -import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; -import org.onap.sdc.frontend.ci.tests.pages.PageObject; -import org.onap.sdc.frontend.ci.tests.pages.ResourceLeftSideMenu; -import org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage; -import org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent; -import org.onap.sdc.frontend.ci.tests.pages.ServiceComponentPage; -import org.onap.sdc.frontend.ci.tests.pages.TopNavComponent; -import org.openqa.selenium.WebDriver; - -/** - * Check the required properties in a Service of category ETSI NFV Network Service. - */ -public class CheckEtsiNsPropertiesFlow extends AbstractUiTestFlow { - - private ServiceComponentPage serviceComponentPage; - - public CheckEtsiNsPropertiesFlow(final WebDriver webDriver) { - super(webDriver); - } - - /** - * Starts the flow in the {@link ServiceComponentPage}. From there go to the {@link ResourcePropertiesAssignmentPage} and check for the - * properties. It does not require any page object, but can receive: - * <ul> - * <li>{@link ServiceComponentPage} or its children:</li> - * <ul> - * <li>{@link TopNavComponent}</li> - * <li>{@link ResourceLeftSideMenu}</li> - * <li>{@link ResourceWorkspaceTopBarComponent}</li> - * </ul> - * </ul> - * - * @param pageObjects any required page object for the flow - * @return the {@link ServiceComponentPage} - */ - @Override - public Optional<ServiceComponentPage> run(final PageObject... pageObjects) { - extendTest.log(Status.INFO, "Checking ETSI NFV Network Service properties"); - serviceComponentPage = getParameter(pageObjects, ServiceComponentPage.class).orElseGet(() -> new ServiceComponentPage(webDriver)); - serviceComponentPage.isLoaded(); - final ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage = serviceComponentPage.goToPropertiesAssignment(); - checkProperty(resourcePropertiesAssignmentPage, "descriptor_id"); - checkProperty(resourcePropertiesAssignmentPage, "designer"); - checkProperty(resourcePropertiesAssignmentPage, "flavour_id"); - checkProperty(resourcePropertiesAssignmentPage, "invariant_id"); - checkProperty(resourcePropertiesAssignmentPage, "name"); - checkProperty(resourcePropertiesAssignmentPage, "ns_profile"); - checkProperty(resourcePropertiesAssignmentPage, "version"); - checkProperty(resourcePropertiesAssignmentPage, "ns_profile"); - checkProperty(resourcePropertiesAssignmentPage, "service_availability_level"); - ExtentTestActions.takeScreenshot(Status.INFO, "etsi-ns-properties-present", "ETSI NS properties are present"); - extendTest.log(Status.INFO, "Finished checking ETSI NFV Network Service properties"); - return Optional.of(serviceComponentPage); - } - - @Override - public Optional<ServiceComponentPage> getLandedPage() { - return Optional.ofNullable(serviceComponentPage); - } - - private void checkProperty(final ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage, final String propertyName) { - extendTest.log(Status.INFO, String.format("Checking property '%s'", propertyName)); - assertThat(String.format("'%s' property should be present", propertyName), - resourcePropertiesAssignmentPage.isPropertyPresent(propertyName), is(true)); - } -} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVspFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVspFlow.java index 948b8650c8..4c9d91ce0f 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVspFlow.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVspFlow.java @@ -24,6 +24,7 @@ import static org.hamcrest.core.Is.is; import com.aventstack.extentreports.Status; import java.util.Optional; +import org.onap.sdc.frontend.ci.tests.datatypes.VspCreateData; import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; import org.onap.sdc.frontend.ci.tests.pages.OnboardHomePage; import org.onap.sdc.frontend.ci.tests.pages.PageObject; @@ -38,14 +39,14 @@ import org.openqa.selenium.WebDriver; */ public class CreateVspFlow extends AbstractUiTestFlow { - private final String resourceName; + private final VspCreateData vspCreateData; private final String packageFile; private final String rootFolder; private HomePage homePage; - public CreateVspFlow(final WebDriver webDriver, final String resourceName, final String packageFile, final String rootFolder) { + public CreateVspFlow(final WebDriver webDriver, final VspCreateData vspCreateData, final String packageFile, final String rootFolder) { super(webDriver); - this.resourceName = resourceName; + this.vspCreateData = vspCreateData; this.packageFile = packageFile; this.rootFolder = rootFolder; } @@ -53,7 +54,7 @@ public class CreateVspFlow extends AbstractUiTestFlow { @Override public Optional<PageObject> run(final PageObject... pageObjects) { extendTest.log(Status.INFO, - String.format("Creating VSP '%s' by onboarding ETSI VNF/CNF package '%s'", resourceName, packageFile)); + String.format("Creating VSP '%s' by onboarding ETSI VNF/CNF package '%s'", vspCreateData.getName(), packageFile)); final TopNavComponent topNavComponent = findParameter(pageObjects, TopNavComponent.class); extendTest.log(Status.INFO, "Accessing the Onboard Home Page"); topNavComponent.isLoaded(); @@ -93,15 +94,15 @@ public class CreateVspFlow extends AbstractUiTestFlow { extendTest.log(Status.INFO, "Creating a new VSP"); final VspCreationModal vspCreationModal = onboardHomePage.clickOnCreateNewVsp(); vspCreationModal.isLoaded(); - vspCreationModal.fillCreationForm(resourceName); + vspCreationModal.fillCreationForm(vspCreateData); ExtentTestActions.takeScreenshot(Status.INFO, "vsp-creation-form", "Creating VSP with given information"); final SoftwareProductOnboarding softwareProductOnboarding = vspCreationModal.clickOnCreate(); softwareProductOnboarding.isLoaded(); - extendTest.log(Status.INFO, String.format("VSP '%s' created", resourceName)); + extendTest.log(Status.INFO, String.format("VSP '%s' created", vspCreateData.getName())); final String actualResourceName = softwareProductOnboarding.getResourceName(); - assertThat(String.format("Should be in the Software Product '%s' page", resourceName), - actualResourceName, is(resourceName)); + assertThat(String.format("Should be in the Software Product '%s' page", vspCreateData.getName()), + actualResourceName, is(vspCreateData.getName())); return softwareProductOnboarding; } @@ -112,12 +113,12 @@ public class CreateVspFlow extends AbstractUiTestFlow { */ private void uploadPackage(final SoftwareProductOnboarding softwareProductOnboarding) { extendTest.log(Status.INFO, - String.format("Uploading package '%s' to VSP '%s'", packageFile, resourceName) + String.format("Uploading package '%s' to VSP '%s'", packageFile, vspCreateData.getName()) ); softwareProductOnboarding.uploadFile(rootFolder + packageFile); softwareProductOnboarding.attachmentScreenIsLoaded(); extendTest.log(Status.INFO, - String.format("Package '%s' was uploaded to VSP '%s'.", packageFile, resourceName) + String.format("Package '%s' was uploaded to VSP '%s'.", packageFile, vspCreateData.getName()) ); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AbstractPageObject.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AbstractPageObject.java index 1ad049ff13..47b655924c 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AbstractPageObject.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AbstractPageObject.java @@ -75,6 +75,16 @@ public abstract class AbstractPageObject implements PageObject { } /** + * Find an element based on the provided xpath. + * + * @param xpath the xpath expression to search for the element + * @return the WebElement if found, otherwise throws an exception + */ + protected WebElement findElement(final String xpath) { + return webDriver.findElement(By.xpath(xpath)); + } + + /** * Find elements based on the provided locator. * * @param locator the By locator diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java index 686f63c552..196c560429 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java @@ -23,18 +23,13 @@ import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import org.onap.sdc.frontend.ci.tests.datatypes.ResourceCreateData; -import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; -import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper; import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent; -import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent.NotificationType; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Handles the Resource Create Page UI actions @@ -78,6 +73,15 @@ public class ResourceCreatePage extends ComponentPage { setInputField(By.xpath(XpathSelector.NAME_INPUT.getXpath()), name); } + /** + * Gets the name field value. + * + * @return the name field value + */ + public String getName() { + return findElement(XpathSelector.NAME_INPUT.getXpath()).getText(); + } + private void setCategory(final String category) { setSelectField(By.xpath(XpathSelector.CATEGORY_SELECT.getXpath()), category); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java index 12ac5e492a..cb4345c7cc 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java @@ -22,18 +22,16 @@ package org.onap.sdc.frontend.ci.tests.pages; import com.aventstack.extentreports.Status; import java.util.List; import java.util.Map; - +import lombok.AllArgsConstructor; +import lombok.Getter; import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; -import lombok.AllArgsConstructor; -import lombok.Getter; - /** * Handles the Resource Properties Assignment Page UI actions. */ -public class ResourcePropertiesAssignmentPage extends AbstractPageObject { +public class ResourcePropertiesAssignmentPage extends ComponentPage { private ResourcePropertiesAssignmentTab resourcePropertiesAssignmentTab; private ResourcePropertiesAssignmentInputTab resourcePropertiesAssignmentInputTab; @@ -46,6 +44,7 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject { @Override public void isLoaded() { + super.isLoaded(); waitForElementVisibility((By.xpath(XpathSelector.MAIN_DIV.getXpath()))); waitForElementVisibility(By.xpath(XpathSelector.TITLE_DIV.getXpath())); resourcePropertiesAssignmentTab.isLoaded(); @@ -75,6 +74,16 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject { resourcePropertiesAssignmentTab.setPropertyValue(propertyName, value); } + /** + * Retrieves a property value. + * + * @param propertyName the property name + * @return the property value + */ + public Object getPropertyValue(final String propertyName) { + return resourcePropertiesAssignmentTab.getPropertyValue(propertyName); + } + public boolean isPropertyPresent(final String propertyName) { return resourcePropertiesAssignmentTab.isPropertyPresent(propertyName); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentTab.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentTab.java index 32a20dd138..81ce7ffec1 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentTab.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentTab.java @@ -21,12 +21,15 @@ package org.onap.sdc.frontend.ci.tests.pages; import static org.junit.jupiter.api.Assertions.assertTrue; +import com.aventstack.extentreports.Status; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; - +import java.util.stream.Collectors; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper; import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent; @@ -36,11 +39,6 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; -import com.aventstack.extentreports.Status; - -import lombok.AllArgsConstructor; -import lombok.Getter; - /** * Handles the Resource Properties Assignment Properties Tab UI actions */ @@ -129,6 +127,32 @@ public class ResourcePropertiesAssignmentTab extends AbstractPageObject { } /** + * Gets the property value. Only properties with a text value like string, float, integer or a list of string, float, integer are supported. + * + * @param propertyName the property name + * @return the value of the given property + */ + public Object getPropertyValue(final String propertyName) { + isPropertiesTableLoaded(); + final Map<String, String> propertyNamesAndTypes = getPropertyNamesAndTypes(); + final String propertyType = propertyNamesAndTypes.get(propertyName); + final WebElement propertyRow = getPropertyRow(propertyName); + switch (propertyType) { + case "string": + case "float": + case "integer": + final WebElement propertyInput = propertyRow.findElement(By.xpath(XpathSelector.INPUT_PROPERTY.getXpath(propertyName))); + return propertyInput.getAttribute("value"); + case "list": + final List<WebElement> elements = propertyRow + .findElements(By.xpath(XpathSelector.INPUT_PROPERTY_LIST_STRING_TYPE_VALUE.getXpath(propertyName))); + return elements.stream().map(webElement -> webElement.getAttribute("value")).collect(Collectors.toList()); + default: + throw new UnsupportedOperationException(String.format("Retrieve value of property type %s is not yet supported", propertyType)); + } + } + + /** * Checks if a property exists. * @param propertyName the property name * @return the value of the property @@ -346,6 +370,7 @@ public class ResourcePropertiesAssignmentTab extends AbstractPageObject { PROPERTY_ADD_VALUE_COMPLEX_TYPE("//a[contains(@data-tests-id, 'add-to-list-%s')]"), INPUT_PROPERTY_COMPLEX_TYPE_KEY("//input[contains(@data-tests-id, 'value-prop-key-%s')]"), INPUT_PROPERTY_COMPLEX_TYPE_VALUE("//input[contains(@data-tests-id, 'value-prop-%s')]"), + INPUT_PROPERTY_LIST_STRING_TYPE_VALUE("//input[starts-with(@data-tests-id, 'value-prop-%s')]"), INPUT_PROPERTY("//input[@data-tests-id='value-prop-%s']"), SELECT_INPUT_PROPERTY("//select[@data-tests-id='value-prop-%s']"), PROPERTY_TYPES("//*[contains(@data-tests-id, 'propertyType')]"), diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCreationModal.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCreationModal.java index 5950b2d895..4109911b0e 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCreationModal.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/VspCreationModal.java @@ -21,7 +21,11 @@ package org.onap.sdc.frontend.ci.tests.pages; import lombok.AllArgsConstructor; import lombok.Getter; +import org.onap.sdc.frontend.ci.tests.datatypes.CategorySelect; +import org.onap.sdc.frontend.ci.tests.datatypes.VspCreateData; +import org.onap.sdc.frontend.ci.tests.datatypes.VspOnboardingProcedure; import org.openqa.selenium.By; +import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; @@ -49,17 +53,17 @@ public class VspCreationModal extends AbstractPageObject { } /** - * Fills the creation form for the given vsp name. + * Fills the creation form with the given data. * - * @param vspName the name of the Vendor Software Product + * @param vspCreateData the data to fill the Vendor Software Product create form */ - public void fillCreationForm(final String vspName) { - fillName(vspName); - selectVendorFirstVendor(); - selectCategory("resourceNewCategory.network l4+.common network resources"); - fillDescription(vspName); - selectNetworkPackageOnboardingProcedure(); - selectDefaultModel(); + public void fillCreationForm(final VspCreateData vspCreateData) { + fillName(vspCreateData.getName()); + selectVendorOrElseAny(vspCreateData.getVendor()); + selectCategory(vspCreateData.getCategory()); + fillDescription(vspCreateData.getDescription()); + selectOnboardingProcedure(vspCreateData.getOnboardingProcedure()); + selectModel(vspCreateData.getModel()); } /** @@ -91,6 +95,19 @@ public class VspCreationModal extends AbstractPageObject { } /** + * Selects the given vendor option. If a null value is given, selects the first option available. + * + * @param vendor the vendor option to select + */ + public void selectVendorOrElseAny(final String vendor) { + if (vendor == null) { + selectVendorFirstVendor(); + return; + } + setSelectValue(XpathSelector.VENDOR_SELECT, vendor); + } + + /** * Selects the first vendor in the vendor list. */ public void selectVendorFirstVendor() { @@ -104,20 +121,41 @@ public class VspCreationModal extends AbstractPageObject { clickElement(XpathSelector.DEFAULT_MODEL_RADIO); } + public void selectModel(final String model) { + if (model == null) { + selectDefaultModel(); + return; + } + clickElement(XpathSelector.OTHER_MODEL_RADIO); + final WebElement modelSelect = findSubElement(wrappingElement, XpathSelector.MODEL_SELECT.getXpath()); + modelSelect.sendKeys(model); + modelSelect.sendKeys(Keys.ENTER); + } + /** * Selects a category in the category list based on the option value. * * @param categoryOptionValue the option value */ - public void selectCategory(final String categoryOptionValue) { - setSelectValue(XpathSelector.CATEGORY_SELECT, categoryOptionValue); + public void selectCategory(final CategorySelect categoryOptionValue) { + setSelectValue(XpathSelector.CATEGORY_SELECT, categoryOptionValue.getOption()); } /** * Selects the network package onboarding procedure option. + * + * @param vspOnboardingProcedure the onboarding procedure to select */ - public void selectNetworkPackageOnboardingProcedure() { - wrappingElement.findElement(By.xpath(XpathSelector.ONBOARDING_METHOD_RADIO.getXpath())).click(); + public void selectOnboardingProcedure(final VspOnboardingProcedure vspOnboardingProcedure) { + if (VspOnboardingProcedure.MANUAL == vspOnboardingProcedure) { + wrappingElement.findElement(By.xpath(XpathSelector.ONBOARDING_MANUAL_PROCEDURE_RADIO.getXpath())).click(); + return; + } + if (VspOnboardingProcedure.NETWORK_PACKAGE == vspOnboardingProcedure) { + wrappingElement.findElement(By.xpath(XpathSelector.ONBOARDING_PACKAGE_PROCEDURE_RADIO.getXpath())).click(); + return; + } + throw new UnsupportedOperationException(String.format("Onboarding procedure option '%s' not yet supported", vspOnboardingProcedure)); } private void setInputValue(final XpathSelector inputTestId, final String value) { @@ -146,8 +184,11 @@ public class VspCreationModal extends AbstractPageObject { VENDOR_SELECT("new-vsp-vendor", "//select[@data-test-id='%s']"), CATEGORY_SELECT("new-vsp-category", "//select[@data-test-id='%s']"), DESCRIPTION_TXT("new-vsp-description", "//textarea[@data-test-id='%s']"), - ONBOARDING_METHOD_RADIO("new-vsp-creation-procedure-heat", "//input[@data-test-id='%s']/parent::label"), + ONBOARDING_PACKAGE_PROCEDURE_RADIO("new-vsp-creation-procedure-heat", "//input[@data-test-id='%s']/parent::label"), + ONBOARDING_MANUAL_PROCEDURE_RADIO("new-vsp-creation-procedure-manual", "//input[@data-test-id='%s']/parent::label"), DEFAULT_MODEL_RADIO("model-option-default", "//input[@data-test-id='%s']/parent::label"), + OTHER_MODEL_RADIO("model-option-other", "//input[@data-test-id='%s']/parent::label"), + MODEL_SELECT("model-option-select", "//div[@data-test-id='%s']//input"), CREATE_BTN("form-submit-button", "//*[@data-test-id='%s']"); @Getter diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/ToscaArtifactsPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/ToscaArtifactsPage.java index a691fba06e..f85c18a9d5 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/ToscaArtifactsPage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/ToscaArtifactsPage.java @@ -24,12 +24,12 @@ import java.util.ArrayList; import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; -import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject; +import org.onap.sdc.frontend.ci.tests.pages.ComponentPage; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -public class ToscaArtifactsPage extends AbstractPageObject { +public class ToscaArtifactsPage extends ComponentPage { private final List<String> downloadedArtifactList = new ArrayList<>(); private WebElement wrappingElement; diff --git a/integration-tests/src/test/resources/Files/ETSI/Vnf-ETSI-SOL001-2.5.1.csar b/integration-tests/src/test/resources/Files/ETSI/Vnf-ETSI-SOL001-2.5.1.csar Binary files differnew file mode 100644 index 0000000000..eb97b0c02f --- /dev/null +++ b/integration-tests/src/test/resources/Files/ETSI/Vnf-ETSI-SOL001-2.5.1.csar diff --git a/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml b/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml index 6c6e595767..cb662b562b 100644 --- a/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml +++ b/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml @@ -49,6 +49,7 @@ <include name="addComponentInput"/> </methods> </class> + <class name="org.onap.sdc.frontend.ci.tests.execute.sanity.EtsiModelUiTests"/> </classes> </test> </suite> |