2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications copyright (c) 2021 Nokia
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule;
24 import org.junit.jupiter.api.Test;
25 import org.openecomp.sdc.heat.datatypes.manifest.FileData;
26 import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
27 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
28 import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
30 import java.util.List;
31 import java.util.Optional;
33 import static org.junit.jupiter.api.Assertions.assertFalse;
34 import static org.junit.jupiter.api.Assertions.assertTrue;
37 public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNamingConventionImpl {
39 private static final String ARTIFACT_1 = "cloudtech_k8s_charts.zip";
40 private static final String ARTIFACT_2 = "cloudtech_azure_day0.zip";
41 private static final String ARTIFACT_3 = "cloudtech_aws_configtemplate.zip";
42 private static final String ARTIFACT_4 = "k8s_charts.zip";
43 private static final String ARTIFACT_5 = "cloudtech_openstack_configtemplate.zip";
44 private static final String PMDICT_YAML = "pmdict.yaml";
48 void testIsCloudSpecificArtifact() {
49 assertTrue(isCloudSpecificArtifact(ARTIFACT_1));
50 assertTrue(isCloudSpecificArtifact(ARTIFACT_2));
51 assertTrue(isCloudSpecificArtifact(ARTIFACT_3));
52 assertFalse(isCloudSpecificArtifact(ARTIFACT_4));
53 assertFalse(isCloudSpecificArtifact(ARTIFACT_5));
57 void shouldMapPmDictionaryTypeFromExistingManifestToPmDictionaryTypeInNewManifest() {
59 VspDetails vspDetails = new VspDetails();
60 FilesDataStructure fileDataStructure = new FilesDataStructure();
61 fileDataStructure.setArtifacts(List.of(PMDICT_YAML));
62 ManifestContent existingManifest = prepareManifestWithPmDictFileWithType(FileData.Type.PM_DICTIONARY);
65 Optional<ManifestContent> newManifest = new ManifestCreatorNamingConventionImpl()
66 .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest);
69 assertTrue(newManifest.isPresent());
70 assertTrue(newManifest.get()
73 .allMatch(fd -> fd.getType().equals(FileData.Type.PM_DICTIONARY) &&
74 fd.getFile().equals(PMDICT_YAML)));
78 void shouldMapPmDictionaryWithOtherTypeFromExistingManifestToOtherTypeInNewManifest() {
80 VspDetails vspDetails = new VspDetails();
81 FilesDataStructure fileDataStructure = new FilesDataStructure();
82 fileDataStructure.setArtifacts(List.of(PMDICT_YAML));
83 ManifestContent existingManifest = prepareManifestWithPmDictFileWithType(FileData.Type.OTHER);
86 Optional<ManifestContent> newManifest = new ManifestCreatorNamingConventionImpl()
87 .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest);
90 assertTrue(newManifest.isPresent());
91 assertTrue(newManifest.get()
94 .allMatch(fd -> fd.getType().equals(FileData.Type.OTHER) &&
95 fd.getFile().equals(PMDICT_YAML)));
98 private ManifestContent prepareManifestWithPmDictFileWithType(FileData.Type fileType) {
99 ManifestContent existingManifest = new ManifestContent();
100 FileData fileData = new FileData();
101 fileData.setFile(PMDICT_YAML);
102 fileData.setType(fileType);
103 existingManifest.setData(List.of(fileData));
104 return existingManifest;