From 4871b522afd7dfee773dc891cb94d3f1eaafb040 Mon Sep 17 00:00:00 2001 From: vasraz Date: Mon, 19 Dec 2022 18:29:41 +0000 Subject: Fix 'Artifact type CONTROLLER_BLUEPRINT_ARCHIVE is not recognized based on its type'-bug Signed-off-by: Vasyl Razinkov Change-Id: Iab23331c5eb2e8ff5526a877adab8babbadd86d9 Issue-ID: SDC-3216 --- .../impl/VendorSoftwareProductManagerImpl.java | 8 +- .../OrchestrationTemplateProcessZipHandler.java | 17 ++- .../ManifestCreatorNamingConventionImpl.java | 128 ++++++++++++--------- .../ManifestCreatorNamingConventionImplTest.java | 45 ++++---- 4 files changed, 108 insertions(+), 90 deletions(-) (limited to 'openecomp-be') diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java index 001c6c7e37..baabc74822 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java @@ -636,27 +636,25 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa return MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, validationErrors)) ? null : validationErrors; } - private FileContentHandler addDummyHeatBase(InputStream zipFileManifest, FileContentHandler fileContentMap) { + private void addDummyHeatBase(InputStream zipFileManifest, FileContentHandler fileContentMap) { ManifestContent manifestContent = JsonUtil.json2Object(zipFileManifest, ManifestContent.class); for (FileData fileData : manifestContent.getData()) { if ((fileData.getFile()).contains("dummy_ignore.yaml")) { String filePath = new File("").getAbsolutePath() + "/resources"; File envFilePath = new File(filePath + "/base_template.env"); File baseFilePath = new File(filePath + "/base_template.yaml"); - try (InputStream envStream = new FileInputStream(envFilePath); InputStream baseStream = new FileInputStream(baseFilePath);) { + try (InputStream envStream = new FileInputStream(envFilePath); InputStream baseStream = new FileInputStream(baseFilePath)) { fileContentMap.addFile("base_template_dummy_ignore.env", envStream); fileContentMap.addFile("base_template_dummy_ignore.yaml", baseStream); } catch (Exception e) { - LOGGER.error("File not found error {}", e); + LOGGER.error("File not found error ", e); } } } - return fileContentMap; } private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version, String onboardingMethod) { // The apis of CompositionEntityDataManager used here are stateful! - // so, it must be re-created from scratch when it is used! CompositionEntityDataManager compositionEntityDataManager = CompositionEntityDataManagerFactory.getInstance().createInterface(); compositionEntityDataManager.addEntity(vspInfoDao.getQuestionnaire(vspId, version), null); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java index 4754a2d384..46e5fe81a7 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java @@ -73,11 +73,10 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp UploadFileResponse uploadFileResponse = new UploadFileResponse(); Optional fileContent = OrchestrationUtil .getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse, candidateData.getContentData().array()); - if (!fileContent.isPresent()) { + if (fileContent.isEmpty()) { response.addStructureErrors(uploadFileResponse.getErrors()); return response; } - Map> uploadErrors = uploadFileResponse.getErrors(); FileContentHandler fileContentMap = fileContent.get(); try (InputStream zipFileManifest = fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) { addDummyHeatBase(zipFileManifest, fileContentMap); @@ -90,16 +89,17 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp return response; } ManifestContent zipManifestFile = readManifestFromZip(fileContentMap); - String manifest = null; + String manifest; if (zipManifestFile == null) { manifest = candidateService.createManifest(vspDetails, structure); } else { manifest = candidateService.createManifestFromExisting(vspDetails, structure, zipManifestFile); } + Map> uploadErrors = uploadFileResponse.getErrors(); fileContentMap.addFile(SdcCommon.MANIFEST_NAME, manifest.getBytes()); Optional zipByteArrayInputStream = candidateService .fetchZipFileByteArrayInputStream(vspId, candidateData, manifest, OnboardingTypesEnum.ZIP, uploadErrors); - if (!zipByteArrayInputStream.isPresent()) { + if (zipByteArrayInputStream.isEmpty()) { return response; } HeatStructureTree tree = createAndValidateHeatTree(response, fileContentMap); @@ -146,22 +146,21 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp return zipManifestFile; } - private FileContentHandler addDummyHeatBase(InputStream zipFileManifest, FileContentHandler fileContentMap) { + private void addDummyHeatBase(InputStream zipFileManifest, FileContentHandler fileContentMap) { ManifestContent manifestContent = JsonUtil.json2Object(zipFileManifest, ManifestContent.class); for (FileData fileData : manifestContent.getData()) { - if (Objects.nonNull(fileData.getType()) && fileData.getType().equals(FileData.Type.HELM) && fileData.getBase()) { + if (Objects.nonNull(fileData.getType()) && fileData.getType().equals(FileData.Type.HELM) && Boolean.TRUE.equals(fileData.getBase())) { String filePath = new File("").getAbsolutePath() + "/resources"; File envFilePath = new File(filePath + "/base_template.env"); File baseFilePath = new File(filePath + "/base_template.yaml"); - try (InputStream envStream = new FileInputStream(envFilePath); InputStream baseStream = new FileInputStream(baseFilePath);) { + try (InputStream envStream = new FileInputStream(envFilePath); InputStream baseStream = new FileInputStream(baseFilePath)) { fileContentMap.addFile("base_template_dummy_ignore.env", envStream); fileContentMap.addFile("base_template_dummy_ignore.yaml", baseStream); } catch (Exception e) { - LOGGER.error("File not found error {}", e); + LOGGER.error("File not found error ", e); } } } - return fileContentMap; } private Map> getErrors(OrchestrationTemplateActionResponse orchestrationTemplateActionResponse) { diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java index 48601a28a7..f55447cc38 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java @@ -29,6 +29,7 @@ import java.util.regex.Pattern; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.sdc.heat.datatypes.manifest.FileData; +import org.openecomp.sdc.heat.datatypes.manifest.FileData.Type; import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.services.HeatFileAnalyzer; @@ -44,10 +45,13 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { protected static final Logger logger = LoggerFactory.getLogger(ManifestCreatorNamingConventionImpl.class); private static final String CLOUD_SPECIFIC_FIXED_KEY_WORD = "cloudtech"; - private static final String[][] CLOUD_SPECIFIC_KEY_WORDS = {{"k8s", "azure", "aws"}, /* cloud specific technology */ - {"charts", "day0", "configtemplate"} /*cloud specific sub type*/}; + private static final String[][] CLOUD_SPECIFIC_KEY_WORDS = { + {"k8s", "azure", "aws"}, // cloud specific technology + {"charts", "day0", "configtemplate"} // cloud specific subtype + }; private static final String CONTROLLER_BLUEPRINT_ARCHIVE_FIXED_KEY_WORD = "CBA"; private static final String HELM_KEY_WORD = "HELM"; + private static final String PM_DICTIONARY = "PM_DICTIONARY"; @Override public Optional createManifest(VspDetails vspDetails, FilesDataStructure filesDataStructure) { @@ -58,8 +62,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { addModulesToManifestFileDataList(filesDataStructure, fileDataList); addNestedToManifest(filesDataStructure, fileDataList); addArtifactsToManifestFileDataList(filesDataStructure, fileDataList); - ManifestContent manifestContent = createManifest(vspDetails, fileDataList); - return Optional.of(manifestContent); + return Optional.of(createManifest(vspDetails, fileDataList)); } @Override @@ -72,8 +75,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { addModulesToManifestFileDataList(filesDataStructure, fileDataList); addNestedToManifest(filesDataStructure, fileDataList); addArtifactsToManifestFileDataList(filesDataStructure, fileDataList, existingManifest); - ManifestContent manifestContent = createManifest(vspDetails, fileDataList); - return Optional.of(manifestContent); + return Optional.of(createManifest(vspDetails, fileDataList)); } private void addArtifactsToManifestFileDataList(FilesDataStructure filesDataStructure, List fileDataList, @@ -81,30 +83,35 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { Collection forArtifacts = CollectionUtils.union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned()); if (CollectionUtils.isNotEmpty(forArtifacts)) { for (String artifact : forArtifacts) { - if (isCloudSpecificArtifact(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact)); - } else if (isControllerBlueprintArchive(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact)); - } else if (isHelm(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact)); - } else if (isPmDictionary(artifact, existingManifest)) { - fileDataList.add(createBaseFileData(FileData.Type.PM_DICTIONARY, artifact)); + List manifestData = existingManifest.getData(); + if (isCloudSpecificArtifact(artifact, manifestData)) { + fileDataList.add(createBaseFileData(Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact)); + } else if (isControllerBlueprintArchive(artifact, manifestData)) { + fileDataList.add(createBaseFileData(Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact)); + } else if (isHelm(artifact, manifestData)) { + fileDataList.add(createBaseFileData(Type.HELM, artifact)); + } else if (isPmDictionary(artifact, manifestData)) { + fileDataList.add(createBaseFileData(Type.PM_DICTIONARY, artifact)); } else { - fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact)); + fileDataList.add(createBaseFileData(Type.OTHER, artifact)); } } } } - private boolean isPmDictionary(String artifact, ManifestContent existingManifest) { - return existingManifest.getData().stream().filter(fileData -> FileData.Type.PM_DICTIONARY.equals(fileData.getType())).map(FileData::getFile) - .anyMatch(pmDictionaryFile -> pmDictionaryFile.equals(artifact)); + private boolean isPmDictionary(String artifact, List data) { + if (CollectionUtils.isNotEmpty(data) && data.stream() + .anyMatch(fileData -> fileData.getFile().equals(artifact) && Type.PM_DICTIONARY.equals(fileData.getType()))) { + return true; + } else { + return artifact.toUpperCase().contains(PM_DICTIONARY); + } } private void addNestedToManifest(FilesDataStructure filesDataStructure, List fileDataList) { if (CollectionUtils.isNotEmpty(filesDataStructure.getNested())) { for (String nested : filesDataStructure.getNested()) { - fileDataList.add(createBaseFileData(FileData.Type.HEAT, nested)); + fileDataList.add(createBaseFileData(Type.HEAT, nested)); } } } @@ -147,11 +154,11 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { fileDataList.add(createModuleFileData(fileName, false, processedFiles, fileContentHandler.getFileList(), fileDataList)); } else { if (HeatFileAnalyzer.isYamlFile(fileName)) { - fileDataList.add(createBasicFileData(fileName, FileData.Type.HEAT, null)); + fileDataList.add(createBasicFileData(fileName, Type.HEAT, null)); } else if (HeatFileAnalyzer.isEnvFile(fileName)) { - fileDataList.add(createBasicFileData(fileName, FileData.Type.HEAT_ENV, null)); + fileDataList.add(createBasicFileData(fileName, Type.HEAT_ENV, null)); } else { - fileDataList.add(createBasicFileData(fileName, FileData.Type.OTHER, null)); + fileDataList.add(createBasicFileData(fileName, Type.OTHER, null)); } } } @@ -167,39 +174,56 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { return Pattern.matches(Constants.BASE_HEAT_REGEX, fileName) && !isVolFile(fileName); } - protected boolean isCloudSpecificArtifact(String artifact) { - if (artifact.contains(CLOUD_SPECIFIC_FIXED_KEY_WORD)) { - for (int i = 0; i < CLOUD_SPECIFIC_KEY_WORDS.length; i++) { - if (Arrays.stream(CLOUD_SPECIFIC_KEY_WORDS[i]).noneMatch(str -> artifact.contains(str))) { - return false; - } - } + protected boolean isCloudSpecificArtifact(String artifact, List data) { + if (CollectionUtils.isNotEmpty(data) && data.stream() + .anyMatch(fileData -> fileData.getFile().equals(artifact) && Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT.equals(fileData.getType()))) { return true; } else { - return false; + if (artifact.contains(CLOUD_SPECIFIC_FIXED_KEY_WORD)) { + for (final String[] cloudSpecificKeyWord : CLOUD_SPECIFIC_KEY_WORDS) { + if (Arrays.stream(cloudSpecificKeyWord).noneMatch(artifact::contains)) { + return false; + } + } + return true; + } else { + return false; + } } } - private boolean isControllerBlueprintArchive(String artifact) { - return artifact.toUpperCase().contains(CONTROLLER_BLUEPRINT_ARCHIVE_FIXED_KEY_WORD); + private boolean isControllerBlueprintArchive(String artifact, List data) { + if (CollectionUtils.isNotEmpty(data) && data.stream() + .anyMatch(fileData -> fileData.getFile().equals(artifact) && Type.CONTROLLER_BLUEPRINT_ARCHIVE.equals(fileData.getType()))) { + return true; + } else { + return artifact.toUpperCase().contains(CONTROLLER_BLUEPRINT_ARCHIVE_FIXED_KEY_WORD); + } } - private boolean isHelm(String artifact) { - return artifact.toUpperCase().contains(HELM_KEY_WORD); + private boolean isHelm(String artifact, List data) { + if (CollectionUtils.isNotEmpty(data) && data.stream() + .anyMatch(fileData -> fileData.getFile().equals(artifact) && Type.HELM.equals(fileData.getType()))) { + return true; + } else { + return artifact.toUpperCase().contains(HELM_KEY_WORD); + } } private void addArtifactsToManifestFileDataList(FilesDataStructure filesDataStructure, List fileDataList) { Collection forArtifacts = CollectionUtils.union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned()); if (CollectionUtils.isNotEmpty(forArtifacts)) { for (String artifact : forArtifacts) { - if (isCloudSpecificArtifact(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact)); - } else if (isControllerBlueprintArchive(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact)); - } else if (isHelm(artifact)) { - fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact)); + if (isCloudSpecificArtifact(artifact, null)) { + fileDataList.add(createBaseFileData(Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact)); + } else if (isControllerBlueprintArchive(artifact, null)) { + fileDataList.add(createBaseFileData(Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact)); + } else if (isHelm(artifact, null)) { + fileDataList.add(createBaseFileData(Type.HELM, artifact)); + } else if (isPmDictionary(artifact, null)) { + fileDataList.add(createBaseFileData(Type.PM_DICTIONARY, artifact)); } else { - fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact)); + fileDataList.add(createBaseFileData(Type.OTHER, artifact)); } } } @@ -208,9 +232,9 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { private void addModulesToManifestFileDataList(FilesDataStructure filesDataStructure, List fileDataList) { if (CollectionUtils.isNotEmpty(filesDataStructure.getModules())) { for (Module module : filesDataStructure.getModules()) { - FileData.Type type = module.getType(); + Type type = module.getType(); if (type == null) { - type = FileData.Type.HEAT; + type = Type.HEAT; } FileData fileData = createBaseFileData(type, module.getYaml()); fileData.setBase(module.getIsBase()); @@ -223,7 +247,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { private void addEnv(Module module, FileData fileData) { if (Objects.nonNull(module.getEnv())) { - FileData env = createBaseFileData(FileData.Type.HEAT_ENV, module.getEnv()); + FileData env = createBaseFileData(Type.HEAT_ENV, module.getEnv()); fileData.addFileData(env); } } @@ -231,15 +255,15 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { private void addVolume(Module module, FileData fileData) { String volModule = module.getVol(); if (Objects.nonNull(volModule)) { - FileData vol = createBaseFileData(FileData.Type.HEAT_VOL, volModule); + FileData vol = createBaseFileData(Type.HEAT_VOL, volModule); if (Objects.nonNull(module.getVolEnv())) { - vol.addFileData(createBaseFileData(FileData.Type.HEAT_ENV, module.getVolEnv())); + vol.addFileData(createBaseFileData(Type.HEAT_ENV, module.getVolEnv())); } fileData.addFileData(vol); } } - private FileData createBaseFileData(FileData.Type heat, String yaml) { + private FileData createBaseFileData(Type heat, String yaml) { FileData fileData = new FileData(); fileData.setType(heat); fileData.setFile(yaml); @@ -248,17 +272,17 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { private FileData createModuleFileData(String moduleFileName, boolean isBase, Set processedFiles, Set fileNames, List fileDataList) { - FileData moduleFileData = createBasicFileData(moduleFileName, FileData.Type.HEAT, isBase); + FileData moduleFileData = createBasicFileData(moduleFileName, Type.HEAT, isBase); Optional volFile = fetchRelatedVolume(moduleFileName, fileNames); volFile.ifPresent(vol -> { markFileAsProcessed(vol, processedFiles); removeFromFileDataListIfAlreadyProcessed(fileDataList, vol); - FileData volFileData = createBasicFileData(vol, FileData.Type.HEAT_VOL, null); + FileData volFileData = createBasicFileData(vol, Type.HEAT_VOL, null); Optional envFile = fetchRelatedEnv(vol, fileNames); envFile.ifPresent(env -> { markFileAsProcessed(env, processedFiles); removeFromFileDataListIfAlreadyProcessed(fileDataList, env); - FileData envFileData = createBasicFileData(env, FileData.Type.HEAT_ENV, null); + FileData envFileData = createBasicFileData(env, Type.HEAT_ENV, null); volFileData.addFileData(envFileData); }); moduleFileData.addFileData(volFileData); @@ -266,7 +290,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { Optional envFile = fetchRelatedEnv(moduleFileName, fileNames); envFile.ifPresent(env -> { markFileAsProcessed(env, processedFiles); - FileData envFileData = createBasicFileData(env, FileData.Type.HEAT_ENV, null); + FileData envFileData = createBasicFileData(env, Type.HEAT_ENV, null); moduleFileData.addFileData(envFileData); }); return moduleFileData; @@ -276,7 +300,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator { fileDataList.removeIf(fileData -> fileData.getFile().equals(vol)); } - private FileData createBasicFileData(String fileName, FileData.Type type, Boolean isBase) { + private FileData createBasicFileData(String fileName, Type type, Boolean isBase) { FileData fileData = new FileData(); if (isBase != null) { fileData.setBase(isBase); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java index 2cea0f73e3..b58a1f90d8 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java @@ -21,20 +21,18 @@ package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.Optional; import org.junit.jupiter.api.Test; import org.openecomp.sdc.heat.datatypes.manifest.FileData; import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; -import java.util.List; -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - - -public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNamingConventionImpl { +class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNamingConventionImpl { private static final String ARTIFACT_1 = "cloudtech_k8s_charts.zip"; private static final String ARTIFACT_2 = "cloudtech_azure_day0.zip"; @@ -43,14 +41,13 @@ public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNami private static final String ARTIFACT_5 = "cloudtech_openstack_configtemplate.zip"; private static final String PMDICT_YAML = "pmdict.yaml"; - @Test void testIsCloudSpecificArtifact() { - assertTrue(isCloudSpecificArtifact(ARTIFACT_1)); - assertTrue(isCloudSpecificArtifact(ARTIFACT_2)); - assertTrue(isCloudSpecificArtifact(ARTIFACT_3)); - assertFalse(isCloudSpecificArtifact(ARTIFACT_4)); - assertFalse(isCloudSpecificArtifact(ARTIFACT_5)); + assertTrue(isCloudSpecificArtifact(ARTIFACT_1, null)); + assertTrue(isCloudSpecificArtifact(ARTIFACT_2, null)); + assertTrue(isCloudSpecificArtifact(ARTIFACT_3, null)); + assertFalse(isCloudSpecificArtifact(ARTIFACT_4, null)); + assertFalse(isCloudSpecificArtifact(ARTIFACT_5, null)); } @Test @@ -63,15 +60,15 @@ public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNami // when Optional newManifest = new ManifestCreatorNamingConventionImpl() - .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest); + .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest); // then assertTrue(newManifest.isPresent()); assertTrue(newManifest.get() - .getData() - .stream() - .allMatch(fd -> fd.getType().equals(FileData.Type.PM_DICTIONARY) && - fd.getFile().equals(PMDICT_YAML))); + .getData() + .stream() + .allMatch(fd -> fd.getType().equals(FileData.Type.PM_DICTIONARY) && + fd.getFile().equals(PMDICT_YAML))); } @Test @@ -84,15 +81,15 @@ public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNami // when Optional newManifest = new ManifestCreatorNamingConventionImpl() - .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest); + .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest); // then assertTrue(newManifest.isPresent()); assertTrue(newManifest.get() - .getData() - .stream() - .allMatch(fd -> fd.getType().equals(FileData.Type.OTHER) && - fd.getFile().equals(PMDICT_YAML))); + .getData() + .stream() + .allMatch(fd -> fd.getType().equals(FileData.Type.OTHER) && + fd.getFile().equals(PMDICT_YAML))); } private ManifestContent prepareManifestWithPmDictFileWithType(FileData.Type fileType) { -- cgit 1.2.3-korg