aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java15
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/manifestInvalidMetadata4.mf4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/sampleManifest2.mf8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/validManifest.mf8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/manifest/ValidNonManoToscaPNF.mf7
6 files changed, 63 insertions, 12 deletions
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 36cd58dabf..5be982bede 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
@@ -16,6 +16,7 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_MANIFEST;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME;
@@ -62,6 +63,7 @@ import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.api.ValidationManager;
import org.openecomp.core.validation.util.MessageContainerUtil;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
@@ -638,6 +640,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
Manifest onboardingManifest = new SOL004ManifestOnboarding();
onboardingManifest.parse(manifestInputStream);
etsiService.moveNonManoFileToArtifactFolder(handler, onboardingManifest);
+ //VSP PNF resource type is supported only for sol004 csar for now, default VSP resource type is VF
+ packageInfo.setResourceType(getResourceType(onboardingManifest));
}
}
packageInfo.setTranslatedFile(ByteBuffer.wrap(
@@ -647,6 +651,17 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return packageInfo;
}
+ private String getResourceType(Manifest onboardingManifest) {
+ //Valid manifest should contain whether vnf or pnf related metadata data exclusively in SOL004 standard,
+ // validation of manifest done during package upload stage
+ if(onboardingManifest != null && !onboardingManifest.getMetadata().isEmpty()
+ && MANIFEST_PNF_METADATA.stream().anyMatch(e -> onboardingManifest.getMetadata().containsKey(e))){
+ return ResourceTypeEnum.PNF.name();
+ }
+ //VNF is default resource type
+ return ResourceTypeEnum.VF.name();
+ }
+
private InputStream getManifest(FileContentHandler handler) throws IOException {
ToscaMetadata metadata = getMetadata(handler);
return getManifestInputStream(handler, metadata.getMetaEntries().get(TOSCA_META_ENTRY_MANIFEST));
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
index 3900059234..e53642dc74 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
@@ -35,6 +35,7 @@ import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -84,6 +85,8 @@ import java.util.Optional;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyObject;
@@ -159,7 +162,7 @@ public class VendorSoftwareProductManagerImplTest {
}
@Test
- public void testCreatePackageEtsi(){
+ public void testCreatePackageEtsiVNF(){
try(InputStream metadataInput = getClass().getResourceAsStream("/vspmanager.csar/metadata/ValidETSItosca.meta");
InputStream manifestInput = getClass().getResourceAsStream("/vspmanager.csar/manifest/ValidNonManoTosca.mf")) {
@@ -176,7 +179,8 @@ public class VendorSoftwareProductManagerImplTest {
when(vspInfoDaoMock.get(any())).thenReturn(vsp);
when(licenseArtifactsServiceMock.createLicenseArtifacts(any(),any(), any(), any())).thenReturn(new FileContentHandler());
- vendorSoftwareProductManager.createPackage("0", new Version());
+ PackageInfo packageInfo = vendorSoftwareProductManager.createPackage("0", new Version());
+ assertEquals(packageInfo.getResourceType(), ResourceTypeEnum.VF.name());
} catch (IOException e) {
fail();
}
@@ -204,6 +208,31 @@ public class VendorSoftwareProductManagerImplTest {
}
@Test
+ public void testCreatePackageEtsiPNF(){
+ try(InputStream metadataInput = getClass().getResourceAsStream("/vspmanager.csar/metadata/ValidETSItosca.meta");
+ InputStream manifestInput = getClass().getResourceAsStream("/vspmanager.csar/manifest/ValidNonManoToscaPNF.mf")) {
+
+ FileContentHandler handler = new FileContentHandler();
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, IOUtils.toByteArray(metadataInput));
+ handler.addFile(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME, IOUtils.toByteArray(manifestInput));
+ ToscaServiceModel toscaMetadata = new ToscaServiceModel(handler, new HashMap<>(), "");
+ when(enrichedServiceModelDaoMock.getServiceModel(any(), any())).thenReturn(toscaMetadata );
+ VspDetails vsp =
+ createVspDetails("0", new Version(), "Vsp_PNF", "Test-vsp-pnf", "vendorName", "esy", "icon",
+ "category", "subCategory", "123", null);
+ //want to avoid triggering populateVersionsForVlm method
+ vsp.setVlmVersion(null);
+
+ when(vspInfoDaoMock.get(any())).thenReturn(vsp);
+ when(licenseArtifactsServiceMock.createLicenseArtifacts(any(),any(), any(), any())).thenReturn(new FileContentHandler());
+ PackageInfo packageInfo = vendorSoftwareProductManager.createPackage("0", new Version());
+ assertEquals(packageInfo.getResourceType(), ResourceTypeEnum.PNF.name());
+ } catch (IOException e) {
+ fail();
+ }
+ }
+
+ @Test
public void testCreate() {
//doReturn(VERSION01).when(versioningManagerMock).create(anyObject(), anyObject(), anyObject());
doReturn("{}")
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/manifestInvalidMetadata4.mf b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/manifestInvalidMetadata4.mf
index 04f2fa18de..b4ef43f60a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/manifestInvalidMetadata4.mf
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/manifestInvalidMetadata4.mf
@@ -1,3 +1,3 @@
metadata:
- pnf_product_name: RadioNode
- pnf_release_date_time: 2019-12-14T11:25:00+00:00
+ pnfd_name: RadioNode
+ pnfd_release_date_time: 2019-12-14T11:25:00+00:00
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/sampleManifest2.mf b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/sampleManifest2.mf
index c6cb025038..fdeb261165 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/sampleManifest2.mf
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/sampleManifest2.mf
@@ -1,8 +1,8 @@
metadata:
- pnf_product_name: RadioNode
- pnf_provider_id: Bilal Iqbal
- pnf_package_version: 1.0
- pnf_release_date_time: 2019-12-14T11:25:00+00:00
+ pnfd_name: RadioNode
+ pnfd_provider: Bilal Iqbal
+ pnfd_archive_version: 1.0
+ pnfd_release_date_time: 2019-12-14T11:25:00+00:00
Source: Definitions/MainServiceTemplate.yaml
Algorithm: SHA-abc
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/validManifest.mf b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/validManifest.mf
index f34feafdf7..6d9ea720f7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/validManifest.mf
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/manifest/validManifest.mf
@@ -1,8 +1,8 @@
metadata:
- pnf_product_name: RadioNode
- pnf_provider_id: Bilal Iqbal
- pnf_package_version: 1.0
- pnf_release_date_time: 2019-12-14T11:25:00+00:00
+ pnfd_name: RadioNode
+ pnfd_provider: Bilal Iqbal
+ pnfd_archive_version: 1.0
+ pnfd_release_date_time: 2019-12-14T11:25:00+00:00
Source: Artifacts/Deployment/Events/RadioNode_pnf_v1.yaml
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/manifest/ValidNonManoToscaPNF.mf b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/manifest/ValidNonManoToscaPNF.mf
new file mode 100644
index 0000000000..bda3264f5d
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/manifest/ValidNonManoToscaPNF.mf
@@ -0,0 +1,7 @@
+metadata:
+pnfd_name: MRF
+pnfd_provider: SunShineCompany
+pnfd_archive_version: 1.0
+pnfd_release_date_time: 2017-01-01T10:00:00+03:00
+
+Source: MainServiceTemplate.yaml \ No newline at end of file