aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test
diff options
context:
space:
mode:
authorAdam Wudzinski <adam.wudzinski@nokia.com>2021-01-15 17:38:30 +0100
committerAdam Wudzinski <adam.wudzinski@nokia.com>2021-01-18 16:58:27 +0100
commitf3b0ef4dc7cc21b273ea160781b5170b2d105e1a (patch)
tree04550aed49f28b599d2702a519ad7d51a855aac8 /openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test
parentbd5a1006210092f9ac5c48352cc94f6264e961ef (diff)
Map VSP PM_DICTIONARY Type to VF PM_DICTIONARY Type
File defined in ZIP VSP package as PM_DICTIONARY will be now mapped to PM_DICTIONARY type in VF. Also PmDictionaryValidator is run on files with PM_DICTIONARY type in ZIP Manifest file, instead of file naming convention. Issue-ID: SDC-3390 Signed-off-by: Adam Wudzinski <adam.wudzinski@nokia.com> Change-Id: I2e21353b9e80b6bb68c4c6d408ad1ffa33314e7b
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test')
-rw-r--r--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.java75
1 files changed, 66 insertions, 9 deletions
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 1a9bc2aa4c..2cea0f73e3 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
@@ -3,13 +3,14 @@
* SDC
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications copyright (c) 2021 Nokia
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,15 +21,18 @@
package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule;
-import org.junit.Test;
+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.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import java.util.Optional;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNamingConventionImpl {
@@ -37,13 +41,66 @@ public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNami
private static final String ARTIFACT_3 = "cloudtech_aws_configtemplate.zip";
private static final String ARTIFACT_4 = "k8s_charts.zip";
private static final String ARTIFACT_5 = "cloudtech_openstack_configtemplate.zip";
+ private static final String PMDICT_YAML = "pmdict.yaml";
+
@Test
- public void testIsCloudSpecificArtifact() {
+ void testIsCloudSpecificArtifact() {
assertTrue(isCloudSpecificArtifact(ARTIFACT_1));
assertTrue(isCloudSpecificArtifact(ARTIFACT_2));
assertTrue(isCloudSpecificArtifact(ARTIFACT_3));
assertFalse(isCloudSpecificArtifact(ARTIFACT_4));
assertFalse(isCloudSpecificArtifact(ARTIFACT_5));
}
+
+ @Test
+ void shouldMapPmDictionaryTypeFromExistingManifestToPmDictionaryTypeInNewManifest() {
+ // given
+ VspDetails vspDetails = new VspDetails();
+ FilesDataStructure fileDataStructure = new FilesDataStructure();
+ fileDataStructure.setArtifacts(List.of(PMDICT_YAML));
+ ManifestContent existingManifest = prepareManifestWithPmDictFileWithType(FileData.Type.PM_DICTIONARY);
+
+ // when
+ Optional<ManifestContent> newManifest = new ManifestCreatorNamingConventionImpl()
+ .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)));
+ }
+
+ @Test
+ void shouldMapPmDictionaryWithOtherTypeFromExistingManifestToOtherTypeInNewManifest() {
+ // given
+ VspDetails vspDetails = new VspDetails();
+ FilesDataStructure fileDataStructure = new FilesDataStructure();
+ fileDataStructure.setArtifacts(List.of(PMDICT_YAML));
+ ManifestContent existingManifest = prepareManifestWithPmDictFileWithType(FileData.Type.OTHER);
+
+ // when
+ Optional<ManifestContent> newManifest = new ManifestCreatorNamingConventionImpl()
+ .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)));
+ }
+
+ private ManifestContent prepareManifestWithPmDictFileWithType(FileData.Type fileType) {
+ ManifestContent existingManifest = new ManifestContent();
+ FileData fileData = new FileData();
+ fileData.setFile(PMDICT_YAML);
+ fileData.setType(fileType);
+ existingManifest.setData(List.of(fileData));
+ return existingManifest;
+ }
}