summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java34
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java34
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManager.java)13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManagerFactory.java)7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java21
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java18
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java95
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java52
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java22
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java59
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MibUploadErrorBuilder.java)16
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java46
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java76
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java46
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java164
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java27
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java503
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java31
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java396
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java24
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java359
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java117
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImpl.java226
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerFactoryImpl.java)14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java269
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java111
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java186
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java339
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java24
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java25
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java28
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java44
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MibUploadStatus.java)20
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ManualVspDataCollectionService.java418
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java41
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java293
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java432
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java463
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/VSPFullTest.java41
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java113
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java377
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java409
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java374
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java562
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImplTest.java139
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java164
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java117
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java24
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/invalidComponent.json3
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/schema/componentQuestionnaire.json3
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/validComponent.json3
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation/zips/various/vesTest-yml_only.zipbin0 -> 6265 bytes
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager/zips/invalid_ves_file.zipbin0 -> 9111 bytes
71 files changed, 6956 insertions, 643 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
new file mode 100644
index 0000000000..65bceb9864
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
@@ -0,0 +1,34 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+public interface ComputeManager {
+
+ Collection<ListComputeResponse> listCompute(String vspId, Version version, String
+ componentId, String user);
+
+ ComputeEntity createCompute(ComputeEntity compute, String user);
+
+ CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version, String
+ componentId, String computeFlavorId, String user);
+
+ QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String
+ componentId, String computeFlavorId, String user);
+
+ void updateComputeQuestionnaire(String vspId, Version version, String componentId, String
+ computeId, String
+ questionnaireData, String user);
+
+ CompositionEntityValidationData updateCompute(ComputeEntity compute, String user);
+
+ void deleteCompute(String vspId, Version version,String componentId, String computeFlavorId,
+ String user);
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java
new file mode 100644
index 0000000000..26b5bdad17
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java
@@ -0,0 +1,11 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ComputeManagerFactory extends AbstractComponentFactory<ComputeManager> {
+
+ public static ComputeManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ComputeManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
new file mode 100644
index 0000000000..51ba2f4d40
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
@@ -0,0 +1,34 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+public interface DeploymentFlavorManager {
+
+
+ DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity,
+ String user);
+
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version,
+ String user);
+
+ CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId, Version version,
+ String deploymentFlavorId,
+ String user);
+
+ CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId, Version
+ version, String user);
+
+ void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId, String
+ user);
+
+ CompositionEntityValidationData updateDeploymentFlavor(DeploymentFlavorEntity
+ deploymentFlavorEntity, String user);
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java
new file mode 100644
index 0000000000..a367057b63
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class DeploymentFlavorManagerFactory extends
+ AbstractComponentFactory<DeploymentFlavorManager> {
+
+ public static DeploymentFlavorManagerFactory getInstance() {
+ return AbstractFactory.getInstance(DeploymentFlavorManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
new file mode 100644
index 0000000000..6bbfc0b69a
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
@@ -0,0 +1,33 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+public interface ImageManager {
+ ImageEntity createImage(ImageEntity imageEntity, String user);
+
+ CompositionEntityResponse<Image> getImageSchema(String vspId, String user);
+
+ Collection<ImageEntity> listImages(String vspId, Version version, String componentId,
+ String user);
+
+ CompositionEntityResponse<Image> getImage(String vspId, Version version, String componentId,
+ String imageId, String user);
+
+ QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String
+ componentId, String imageId, String user);
+
+ void deleteImage(String vspId, Version version, String componentId, String imageId, String user);
+
+ CompositionEntityValidationData updateImage(ImageEntity imageEntity, String user);
+
+ void updateImageQuestionnaire(String vspId, Version version, String componentId, String imageId,
+ String
+ questionnaireData, String user);
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java
new file mode 100644
index 0000000000..f844186a03
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ImageManagerFactory extends AbstractComponentFactory<ImageManager> {
+
+ public static ImageManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ImageManagerFactory.class);
+ }
+}
+
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
new file mode 100644
index 0000000000..c9a5206383
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public interface ManualVspToscaManager {
+
+ public VspModelInfo gatherVspInformation(String vspId, Version version, String user);
+
+ public ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo);
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
index 7d2db68c1d..f5e34a01be 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
@@ -20,18 +20,19 @@
package org.openecomp.sdc.vendorsoftwareproduct;
-import org.openecomp.core.enrichment.types.ArtifactType;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus;
+import org.openecomp.core.enrichment.types.MonitoringUploadType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.InputStream;
-public interface MibManager {
+public interface MonitoringUploadsManager {
void delete(String vspId, Version version, String componentId,
- ArtifactType artifactType, String user);
+ MonitoringUploadType monitoringUploadType, String user);
void upload(InputStream object, String filename, String vspId, Version version,
- String componentId, ArtifactType artifactType, String user);
+ String componentId, MonitoringUploadType monitoringUploadType, String user);
- MibUploadStatus listFilenames(String vspId, Version version, String componentId, String user);
+ MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId,
+ String user);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java
index f25658bf0f..eb4271be16 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java
@@ -23,9 +23,10 @@ package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-public abstract class MibManagerFactory extends AbstractComponentFactory<MibManager> {
+public abstract class MonitoringUploadsManagerFactory
+ extends AbstractComponentFactory<MonitoringUploadsManager> {
- public static MibManagerFactory getInstance() {
- return AbstractFactory.getInstance(MibManagerFactory.class);
+ public static MonitoringUploadsManagerFactory getInstance() {
+ return AbstractFactory.getInstance(MonitoringUploadsManagerFactory.class);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
index 7e9a002ad1..738e267ca0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.vendorsoftwareproduct;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
@@ -30,6 +31,7 @@ import org.openecomp.sdc.versioning.types.VersionInfo;
import java.io.File;
import java.io.IOException;
+import java.util.Collection;
import java.util.List;
public interface VendorSoftwareProductManager {
@@ -73,6 +75,7 @@ public interface VendorSoftwareProductManager {
File getInformationArtifact(String vspId, Version version, String user);
-
String fetchValidationVsp(String user);
+
+ Collection<ComputeEntity> getComputeByVsp(String vspId, Version version, String user);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java
new file mode 100644
index 0000000000..78d2ef866a
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+
+public class ComponentErrorBuilder {
+
+ private static final String VFC_INVALID_MISSING_IMAGE_MSG =
+ "All VFC need to have atleast a single Image specified. Please fix the VFC Images and re-submit the VSP";
+
+
+ public static ErrorCode VfcMissingImageErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.VFC_INVALID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder
+ .withMessage(String.format(VFC_INVALID_MISSING_IMAGE_MSG));
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java
new file mode 100644
index 0000000000..3ecf6f1a2e
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java
@@ -0,0 +1,18 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class DeleteNicErrorBuilder {
+ private static final String DELETE_NIC_NOT_ALLOWED_MSG =
+ "NIC cannot be deleted for VSPs onboarded with HEAT.";
+
+ public static ErrorCode getDeleteNicForHeatOnboardedVspErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.DELETE_NIC_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DELETE_NIC_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java
new file mode 100644
index 0000000000..63d716504b
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java
@@ -0,0 +1,95 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public class DeploymentFlavorErrorBuilder {
+ private static final String CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG=
+ "Deployment Flavor cannot be added for VSPs onboarded with HEAT.";
+ private static final String FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG=
+ "Invalid request,Feature Group with Id %s does not exist for Vsp with Id %s and version " +
+ "%s.";
+ private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG
+ ="Invalid request,for valid association please provide ComponentId for Compute Flavor";
+ private static final String SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG=
+ "Invalid Request,Same Vfc cannot be associated more than once.";
+ private static final String DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG =
+ "Invalid request, Deployment Flavor with model %s already exists for Vsp with Id %s.";
+ private static final String INVALID_COMPUTE_FLAVOR_ID_MSG =
+ "Invalid request, Compute Flavor with Id %s does not exist for VFC with Id %s.";
+ private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG="VSP cannot be " +
+ "submitted with an invalid Deployment Flavor. All Deployment Flavor should have atleast a VFC included with it's required Compute needs. Please fix the Deployment Flavor and re-submit the VSP.";
+
+ private static final String FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG = "VSP cannot be " +
+ "submitted with an invalid Deployment Flavor. All Deployment Flavor should have " +
+ "FeatureGroup. Please fix the Deployment Flavor and re-submit the VSP.";
+
+ public static ErrorCode getAddDeploymentNotSupportedHeatOnboardErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getFeatureGroupNotexistErrorBuilder( String featureGroupId, String
+ VspId, Version activeVersion){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG,featureGroupId,
+ VspId,activeVersion.toString()));
+ return builder.build();
+ }
+
+ public static ErrorCode getDuplicateVfcAssociationErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getInvalidAssociationErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getDuplicateDeploymentFlavorModelErrorBuilder(String name, String vspId){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG,name,vspId));
+ return builder.build();
+ }
+ public static ErrorCode getInvalidComputeIdErrorBuilder( String computeFlavorId, String
+ vfcId){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_COMPUTE_FLAVOR_ID_MSG,computeFlavorId,
+ vfcId));
+ return builder.build();
+ }
+
+ public static ErrorCode getInvalidComponentComputeAssociationErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getFeatureGroupMandatoryErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG));
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
new file mode 100644
index 0000000000..b242b7169c
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
@@ -0,0 +1,52 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED;
+
+
+public class DuplicateComputeInComponentErrorBuilder {
+
+ private static final String DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG =
+ "Invalid request, Compute with name %s already exists for component with ID %s.";
+ private static final String COMPUTE_HEAT_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
+ + "for VSP onboarded via HEAT.";
+ private static final String COMPUTE_MANUAL_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
+ + "for VSP onboarded manually.";
+
+
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public DuplicateComputeInComponentErrorBuilder(String computeName, String componentId ){
+ builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG,computeName,
+ componentId));
+ }
+
+ /**
+ * Gets duplicate compute name error builder.
+ *
+ * @return the duplicate compute name error builder
+ */
+ public static ErrorCode getDuplicateComputeNameErrorBuilder(String computeName, String componenetId) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG, computeName, componenetId ));
+ return builder.build();
+ }
+
+ public static ErrorCode getComputeHeatReadOnlyErrorBuilder(String name) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(UPDATE_COMPUTE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(COMPUTE_HEAT_READONLY_ATTR_MSG, name));
+ return builder.build();
+ }
+
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java
new file mode 100644
index 0000000000..741dddb4f5
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java
@@ -0,0 +1,22 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class DuplicateNicInComponentErrorBuilder {
+
+ private static final String DUPLICATE_NIC_NAME_NOT_ALLOWED_MSG =
+ "Invalid request, NIC with name %s already exist for component with ID %s.";
+
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public DuplicateNicInComponentErrorBuilder(String nicName, String componentId ){
+ builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_NIC_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DUPLICATE_NIC_NAME_NOT_ALLOWED_MSG,nicName,componentId));
+ }
+ public ErrorCode build() {
+ return builder.build();
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
new file mode 100644
index 0000000000..95bff60479
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
@@ -0,0 +1,59 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_NAME_NOT_ALLOWED;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VFC_IMAGE_INVALID_FORMAT;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+/**
+ * The Image error builder.
+ */
+public class ImageErrorBuilder {
+
+ private static final String VFC_IMAGE_DUPLICATE_NAME_MSG = "Invalid request, Image with name %s"
+ + " already exists for component with ID %s.";
+
+ private static final String IMAGE_INVALID_FORMAT_MSG = "The format value doesn't meet the "
+ + "expected attribute value.";
+
+ private static final String IMAGE_HEAT_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
+ + "for VSP onboarded via HEAT.";
+
+
+ /**
+ * Gets duplicate image name error builder.
+ *
+ * @return the duplicate image name error builder
+ */
+ public static ErrorCode getDuplicateImageNameErrorBuilder(String imageName, String componenetId) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(DUPLICATE_IMAGE_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VFC_IMAGE_DUPLICATE_NAME_MSG, imageName, componenetId ));
+ return builder.build();
+ }
+
+ /**
+ * Gets invalid image format error builder.
+ *
+ * @return the invalid image format error builder
+ */
+ public static ErrorCode getInvalidImageFormatErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VFC_IMAGE_INVALID_FORMAT);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(IMAGE_INVALID_FORMAT_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getImageHeatReadOnlyErrorBuilder(String name) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(UPDATE_IMAGE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(IMAGE_HEAT_READONLY_ATTR_MSG, name));
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MibUploadErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
index bffe805618..5fc29d5a4f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MibUploadErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
@@ -24,11 +24,12 @@ import org.openecomp.sdc.common.errors.BaseErrorBuilder;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.versioning.dao.types.Version;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.MIB_UPLOAD_INVALID;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.MONITORING_UPLOAD_INVALID;
-public class MibUploadErrorBuilder extends BaseErrorBuilder {
+public class MonitoringUploadErrorBuilder extends BaseErrorBuilder {
private static final String UPLOAD_INVALID_DETAILED_MSG =
- "MIB uploaded for vendor software product with Id %s and version %s is invalid: %s";
+ "Monitoring file uploaded for vendor software product with Id %s and version %s is invalid:" +
+ " %s";
/**
@@ -38,8 +39,9 @@ public class MibUploadErrorBuilder extends BaseErrorBuilder {
* @param version the version
* @param error the error
*/
- public MibUploadErrorBuilder(String vendorSoftwareProductId, Version version, String error) {
- getErrorCodeBuilder().withId(MIB_UPLOAD_INVALID);
+ public MonitoringUploadErrorBuilder(String vendorSoftwareProductId, Version version,
+ String error) {
+ getErrorCodeBuilder().withId(MONITORING_UPLOAD_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder().withMessage(String.format(UPLOAD_INVALID_DETAILED_MSG,
vendorSoftwareProductId, version == null ? null : version.toString(), error));
@@ -50,8 +52,8 @@ public class MibUploadErrorBuilder extends BaseErrorBuilder {
*
* @param errorMessage the error message
*/
- public MibUploadErrorBuilder(String errorMessage) {
- getErrorCodeBuilder().withId(MIB_UPLOAD_INVALID);
+ public MonitoringUploadErrorBuilder(String errorMessage) {
+ getErrorCodeBuilder().withId(MONITORING_UPLOAD_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder().withMessage(errorMessage);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
new file mode 100644
index 0000000000..0850d2e704
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
@@ -0,0 +1,46 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_TYPE_UPDATE_NOT_ALLOWED;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class NicInternalNetworkErrorBuilder {
+ private static final String NULL_NETWORKID_NOT_ALLOWED_MSG =
+ "Internal Networks are currently not supported for VSP created Manually, so please fix all the NIC to be of Type External and re-submit the VSP.";
+
+ private static final String NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK_MSG =
+ "Invalid request, Network Description not allowed for Internal Networks";
+ private static final String NETWORK_TYPE_UPDATE_NOT_ALLOWED_MSG =
+ "Invalid request, Network Type Update not allowed for a Nic";
+
+
+ public static ErrorCode getNicNullNetworkIdInternalNetworkIdErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.NULL_NETWORKID_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NULL_NETWORKID_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+
+ public static ErrorCode getNetworkDescriptionInternalNetworkErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK_MSG));
+ return builder.build();
+ }
+
+
+ public static ErrorCode getNetworkTypeErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(NETWORK_TYPE_UPDATE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NETWORK_TYPE_UPDATE_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java
new file mode 100644
index 0000000000..2d75f81fcd
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class NicNetworkIdNotAllowedExternalNetworkErrorBuilder {
+ private static final String NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK_MSG =
+ "Invalid request,NetworkId not allowed for External Networks";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ public NicNetworkIdNotAllowedExternalNetworkErrorBuilder(){
+ builder.withId(VendorSoftwareProductErrorCodes.NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK_MSG));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
new file mode 100644
index 0000000000..7801df8fd7
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
@@ -0,0 +1,76 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class NotSupportedHeatOnboardMethodErrorBuilder {
+ private static final String ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
+ "NIC cannot be added for VSPs onboarded with HEAT.";
+ private static final String ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
+ "Compute flavor cannot be added for VSPs onboarded with HEAT.";
+ private static final String IMAGE_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
+ "Image cannot be added for VSPs onboarded with HEAT.";
+ private static final String DELETE_IMAGE_NOT_ALLOWED_MSG =
+ "Image cannot be deleted for VSPs onboarded with HEAT.";
+ private static final String DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG =
+ "Deployment Flavor cannot be deleted for VSPs onboarded with HEAT.";
+ private static final String EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG =
+ "Deployment Flavor cannot be edited for VSPs onboarded with HEAT.";
+
+
+ public static ErrorCode getAddNicNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getAddComputeNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getAddImageNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(IMAGE_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getDelImageNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(DELETE_IMAGE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DELETE_IMAGE_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getDelDeploymentFlavorNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getUpdateDfNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
new file mode 100644
index 0000000000..8aad900102
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
@@ -0,0 +1,46 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
+ .VSP_INVALID_ONBOARDING_METHOD;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
+ .VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+/**
+ * The type Onboarding method error builder.
+ */
+public class OnboardingMethodErrorBuilder {
+
+ private static final String VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED_MSG =
+ "onboardingMethod update is not allowed.";
+ private static final String VSP_INVALID_ONBOARDING_METHOD_MSG =
+ "The onboardingMethod value doesn't meet the expected attribute value.";
+
+ /**
+ * Gets onboarding update error.
+ *
+ * @return the onboarding update error
+ */
+ public static ErrorCode getOnboardingUpdateError() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+ /**
+ * Get invalid onboarding method error builder error code.
+ *
+ * @return the error code
+ */
+ public static ErrorCode getInvalidOnboardingMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VSP_INVALID_ONBOARDING_METHOD);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VSP_INVALID_ONBOARDING_METHOD_MSG));
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
index 8fe2bfc396..4a84c83338 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
@@ -28,6 +28,8 @@ public class VendorSoftwareProductInvalidErrorBuilder {
private static final String VSP_INVALID_MSG =
"Vendor software product with Id %s and version %s is invalid - does not contain "
+ "service model.";
+ private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG ="VSP has to have a " +
+ "minimum of one Deployment Flavor defined for being able to be instantiated.Please add a Deployment Flavor and re-submit the VSP.";
private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
/**
@@ -36,14 +38,27 @@ public class VendorSoftwareProductInvalidErrorBuilder {
* @param vendorSoftwareProductId the vendor software product id
* @param version the version
*/
- public VendorSoftwareProductInvalidErrorBuilder(String vendorSoftwareProductId, Version version) {
+ public static ErrorCode VendorSoftwareProductMissingServiceModelErrorBuilder(String
+ vendorSoftwareProductId,
+ Version version) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
builder.withCategory(ErrorCategory.APPLICATION);
builder
.withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.toString()));
+ return builder.build();
}
- public ErrorCode build() {
+ /**
+ * Instantiates a new Vendor software product invalid error builder.
+ */
+ public static ErrorCode VspMissingDeploymentFlavorErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder
+ .withMessage(String.format(VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG));
return builder.build();
}
+
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java
index a2aaf2f8f5..05a088f76a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java
@@ -24,6 +24,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.NicManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
public class ComponentManagerFactoryImpl extends ComponentManagerFactory {
@@ -31,7 +33,8 @@ public class ComponentManagerFactoryImpl extends ComponentManagerFactory {
new ComponentManagerImpl(
ComponentDaoFactory.getInstance().createInterface(),
CompositionEntityDataManagerFactory.getInstance().createInterface(),
- NicManagerFactory.getInstance().createInterface()
+ NicManagerFactory.getInstance().createInterface(),
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface()
);
@Override
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
index 75a5377ec3..42c8d12b3a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
@@ -20,9 +20,13 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.VFC_NODE_TYPE_PREFIX;
+
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
@@ -32,9 +36,11 @@ import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.CompositionEditNotAllowedErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
@@ -46,6 +52,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentCo
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentQuestionnaireSchemaInput;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -59,14 +66,16 @@ public class ComponentManagerImpl implements ComponentManager {
private ComponentDao componentDao;
private CompositionEntityDataManager compositionEntityDataManager;
private NicManager nicManager;
+ private VendorSoftwareProductInfoDao vspInfoDao;
public ComponentManagerImpl(
ComponentDao componentDao,
CompositionEntityDataManager compositionEntityDataManager,
- NicManager nicManager) {
+ NicManager nicManager, VendorSoftwareProductInfoDao vspInfoDao) {
this.componentDao = componentDao;
this.compositionEntityDataManager = compositionEntityDataManager;
this.nicManager = nicManager;
+ this.vspInfoDao = vspInfoDao;
}
@Override
@@ -79,7 +88,7 @@ public class ComponentManagerImpl implements ComponentManager {
@Override
public void deleteComponents(String vspId, Version version, String user) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- if (!isManual(vspId, version)) {
+ if (!vspInfoDao.isManual(vspId, version)) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_COMPONENT, ErrorLevel.ERROR.name(),
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete component");
@@ -91,7 +100,7 @@ public class ComponentManagerImpl implements ComponentManager {
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
}
- @Override
+ /*@Override
public ComponentEntity createComponent(ComponentEntity component, String user) {
mdcDataDebugMessage.debugEntryMessage("VSP id", component.getId());
@@ -107,6 +116,91 @@ public class ComponentManagerImpl implements ComponentManager {
//componentDao.updateVspLatestModificationTime(component.getVspId(), component.getVersion());
mdcDataDebugMessage.debugExitMessage("VSP id", component.getId());
return null;
+ }*/
+
+ @Override
+ public ComponentEntity createComponent(ComponentEntity component, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", component.getId());
+ /*Version activeVersion =
+ getVersionInfo(component.getVspId(), VersionableEntityAction.Write, user)
+ .getActiveVersion();
+ component.setVersion(activeVersion);*/
+
+ final String VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
+ "VFCs cannot be added for VSPs onboarded with HEAT.";
+
+ ComponentEntity createdComponent = null;
+
+ if (!vspInfoDao.isManual(component.getVspId(), component.getVersion())) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create component");
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(VendorSoftwareProductErrorCodes.VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING)
+ .withMessage(VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG).build());
+ } else {
+ validateComponentManual(component);
+ updateComponentName(component);
+ createdComponent = createComponent(component);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", component.getId());
+
+ return createdComponent;
+ }
+
+ private ComponentEntity createComponent(ComponentEntity component) {
+ return compositionEntityDataManager.createComponent(component);
+ }
+
+ private void updateComponentName(ComponentEntity component) {
+ final String NAME_PREFIX = VFC_NODE_TYPE_PREFIX + "heat.";
+ ComponentData data = component.getComponentCompositionData();
+ data.setName(NAME_PREFIX + data.getDisplayName());
+ component.setComponentCompositionData(data);
+ }
+
+ private void validateComponentManual(ComponentEntity component) {
+ final String VSP_VFC_COUNT_EXCEED_MSG = "Creation of only one VFC per "
+ + "VSP allowed.";
+
+ final String VSP_VFC_DUPLICATE_NAME_MSG = "VFC with specified name "
+ + "already present in given VSP.";
+
+ Collection<ComponentEntity> vspComponentList = listComponents(component.getVspId()
+ , component.getVersion(), null);
+ if (vspComponentList.size() >= 1) //1707 release only supports 1 VFC in VSP (manual creation)
+ {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create component: "
+ + "vsp component count exceed");
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(VendorSoftwareProductErrorCodes.VSP_VFC_COUNT_EXCEED)
+ .withMessage(VSP_VFC_COUNT_EXCEED_MSG).build());
+ }
+ if (!isVfcNameUnique(vspComponentList,
+ component.getComponentCompositionData().getDisplayName())) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create component: "
+ + "vsp component duplicate name");
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME)
+ .withMessage(VSP_VFC_DUPLICATE_NAME_MSG).build());
+ }
+ }
+
+ private boolean isVfcNameUnique(Collection<ComponentEntity> component, String displayName) {
+ for (ComponentEntity comp : component) {
+ if (comp.getComponentCompositionData().getDisplayName().equalsIgnoreCase(displayName)) {
+ return false;
+ }
+ }
+ return true;
}
@Override
@@ -116,13 +210,19 @@ public class ComponentManagerImpl implements ComponentManager {
ComponentEntity retrieved =
getComponent(component.getVspId(), component.getVersion(), component.getId());
+ if (vspInfoDao.isManual(component.getVspId(), component.getVersion())) {
+ validateComponentUpdateManual(component, retrieved, user);
+ }
+
+
ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
- schemaInput.setManual(isManual(component.getVspId(), component.getVersion()));
+ schemaInput.setManual(vspInfoDao.isManual(component.getVspId(), component.getVersion()));
schemaInput.setComponent(retrieved.getComponentCompositionData());
CompositionEntityValidationData validationData = compositionEntityDataManager
.validateEntity(component, SchemaTemplateContext.composition, schemaInput);
if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ updateComponentName(component);
componentDao.update(component);
//componentDao.updateVspLatestModificationTime(component.getVspId(), component.getVersion());
}
@@ -132,6 +232,54 @@ public class ComponentManagerImpl implements ComponentManager {
return validationData;
}
+ private void validateComponentUpdateManual(ComponentEntity component, ComponentEntity
+ retrieved, String user) {
+ Collection<ComponentEntity> vspComponentList = listComponents(component.getVspId()
+ , component.getVersion(), user);
+ //Removing check from name as we will ignore passed value
+ // and re-genarate new name from displayName
+ // List<String> invalidParameters = new LinkedList<>();
+ // if (!component.getComponentCompositionData().getName().equals(retrieved
+ // .getComponentCompositionData().getName())) {
+ // invalidParameters.add(NAME);
+ // }
+ // if (!invalidParameters.isEmpty()) {
+ // String msg = String.format(VFC_ATTRIBUTE_UPDATE_NOT_ALLOWED_MSG, StringUtils
+ // .join(invalidParameters, ", "));
+ // MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ // LoggerTragetServiceName.UPDATE_COMPONENT, ErrorLevel.ERROR.name(),
+ // LoggerErrorCode.DATA_ERROR.getErrorCode(), msg);
+ //
+ // throw new CoreException(
+ // new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ // .withId(VendorSoftwareProductErrorCodes.VFC_ATTRIBUTE_UPDATE_NOT_ALLOWED)
+ // .withMessage(msg).build());
+ // }
+
+ //VFC name should be unique within VSP
+ //Removing VFC with same ID from list to avoid self compare
+ for(ComponentEntity ce : vspComponentList) {
+ if (ce.getId().equals(component.getId())) {
+ vspComponentList.remove(ce);
+ break;
+ }
+ }
+ if (!isVfcNameUnique(vspComponentList, component.getComponentCompositionData()
+ .getDisplayName())) {
+ final String VSP_VFC_DUPLICATE_NAME_MSG = "VFC with specified name "
+ + "already present in given VSP.";
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_COMPONENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Component with same name already " +
+ "exists for specified VSP");
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME)
+ .withMessage(VSP_VFC_DUPLICATE_NAME_MSG).build());
+
+ }
+ }
+
public CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
String componentId, String user) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
@@ -139,7 +287,7 @@ public class ComponentManagerImpl implements ComponentManager {
ComponentData component = componentEntity.getComponentCompositionData();
ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
- schemaInput.setManual(isManual(vspId, version));
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
schemaInput.setComponent(component);
CompositionEntityResponse<ComponentData> response = new CompositionEntityResponse<>();
@@ -155,7 +303,7 @@ public class ComponentManagerImpl implements ComponentManager {
public void deleteComponent(String vspId, Version version, String componentId, String user) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- if (!isManual(vspId, version)) {
+ if (!vspInfoDao.isManual(vspId, version)) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_COMPONENT, ErrorLevel.ERROR.name(),
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete component");
@@ -228,7 +376,7 @@ public class ComponentManagerImpl implements ComponentManager {
schemaInput);
}
- private boolean isManual(String vspId, Version version) {
+ /*private boolean isManual(String vspId, Version version) {
return false;
- }
+ }*/
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
new file mode 100644
index 0000000000..71985fa83e
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
+
+public class ComputeManagerFactoryImpl extends ComputeManagerFactory {
+
+ private static final ComputeManager INSTANCE =
+ new ComputeManagerImpl(
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ ComputeDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(),
+ DeploymentFlavorDaoFactory.getInstance().createInterface(),
+ ComponentDaoFactory.getInstance().createInterface()
+
+ );
+
+ @Override
+ public ComputeManager createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
new file mode 100644
index 0000000000..a2d1d708c1
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
@@ -0,0 +1,503 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DuplicateComputeInComponentErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComputeCompositionSchemaInput;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
+import org.openecomp.sdc.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class ComputeManagerImpl implements ComputeManager {
+
+ private static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private ComputeDao computeDao;
+ private CompositionEntityDataManager compositionEntityDataManager;
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private DeploymentFlavorDao deploymentFlavorDao;
+ private ComponentDao componentDao;
+ private static final String MANUAL = "Manual";
+
+ public ComputeManagerImpl(
+ VendorSoftwareProductInfoDao vspInfoDao,
+ ComputeDao computeDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ DeploymentFlavorDao deploymentFlavorDao,
+ ComponentDao componentDao
+ ) {
+ this.computeDao = computeDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.vspInfoDao = vspInfoDao;
+ this.deploymentFlavorDao = deploymentFlavorDao;
+ this.componentDao = componentDao;
+ }
+
+ @Override
+ public ComputeEntity createCompute(ComputeEntity compute, String user) {
+ ComputeEntity createdCompute = null;
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", compute.getVspId(),
+ compute.getComponentId());
+
+ /*Version activeVersion =
+ getVersionInfo(compute.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
+ compute.setVersion(activeVersion);*/
+ //if (!isManual(compute.getVspId(), activeVersion)) {
+ if (!vspInfoDao.isManual(compute.getVspId(), compute.getVersion())) {
+ ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
+ .getAddComputeNotSupportedHeatOnboardMethodErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ onboardingMethodUpdateErrorCode.message());
+ throw new CoreException(onboardingMethodUpdateErrorCode);
+ } else {
+ //validateComponentId(compute.getVspId(),compute.getVersion(),compute.getComponentId());
+ validateCompute(compute);
+ createdCompute = createCompute(compute);
+ }
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", compute.getVspId(), compute.getComponentId());
+
+ return createdCompute;
+ }
+
+ private ComputeEntity createCompute(ComputeEntity compute) {
+
+ return compositionEntityDataManager.createCompute(compute);
+ }
+
+ private void validateCompute(ComputeEntity compute) {
+ Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
+ (),compute.getComponentId());
+
+ if (!isComputeNameUnique(vfcComputeList,compute.getComputeCompositionData().getName())) {
+ final ErrorCode duplicateComputeInComponentErrorBuilder =
+ new DuplicateComputeInComponentErrorBuilder(compute.getComputeCompositionData().getName(),
+ compute.getComponentId()).build();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ duplicateComputeInComponentErrorBuilder.message());
+ throw new CoreException(duplicateComputeInComponentErrorBuilder);
+ }
+
+ }
+
+ private void validateComputeUpdate(ComputeEntity compute) {
+ Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
+ (),compute.getComponentId());
+
+ for (ComputeEntity ce : vfcComputeList) {
+ if (ce.getId().equals(compute.getId())) {
+ vfcComputeList.remove(ce);
+ break;
+ }
+ }
+
+ if (!isComputeNameUnique(vfcComputeList,compute.getComputeCompositionData().getName())) {
+ final ErrorCode duplicateComputeInComponentErrorBuilder =
+ new DuplicateComputeInComponentErrorBuilder(compute.getComputeCompositionData().getName(),
+ compute.getComponentId()).build();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ duplicateComputeInComponentErrorBuilder.message());
+ throw new CoreException(duplicateComputeInComponentErrorBuilder);
+ }
+
+ }
+
+ @Override
+ public Collection<ListComputeResponse> listCompute(String vspId, Version version,
+ String componentId, String user) {
+
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ //validateComponentId(vspId, version, componentId);
+ ComputeEntity entity = new ComputeEntity(vspId, version, componentId, null);
+ Collection<ComputeEntity> computes = computeDao.list(entity);
+
+ Collection<ListComputeResponse> computeResponse =
+ getListComputeResponse(vspId, version, user, computes);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ return computeResponse;
+ }
+
+ private Collection<ListComputeResponse> getListComputeResponse(String vspId, Version version,
+ String user,
+ Collection<ComputeEntity> computes) {
+ Set<String> vspComputes = getComputeAssociatedWithDepFlavors(vspId, version, user);
+ Collection<ListComputeResponse> computeResponse = new ArrayList<ListComputeResponse>();
+ for(ComputeEntity computeEntity : computes) {
+ ListComputeResponse response = new ListComputeResponse();
+ response.setComputeEntity(computeEntity);
+ if(vspComputes.contains(computeEntity.getId())) {
+ response.setAssociatedWithDeploymentFlavor(true);
+ } else {
+ response.setAssociatedWithDeploymentFlavor(false);
+ }
+ computeResponse.add(response);
+ }
+ return computeResponse;
+ }
+
+ private Set<String> getComputeAssociatedWithDepFlavors(String vspId, Version version,
+ String user) {
+ final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
+ Set<String> vspComputes = new HashSet<String>();
+ for(DeploymentFlavorEntity entity : deploymentFlavorEntities) {
+ final List<ComponentComputeAssociation> componentComputeAssociations =
+ entity.getDeploymentFlavorCompositionData().getComponentComputeAssociations();
+ if(componentComputeAssociations != null && !componentComputeAssociations.isEmpty()) {
+ for(ComponentComputeAssociation association : componentComputeAssociations) {
+ vspComputes.add(association.getComputeFlavorId());
+ }
+ }
+ }
+ return vspComputes;
+ }
+
+ private boolean isComputeNameUnique(Collection<ComputeEntity> vfcComputeList, String name) {
+ for (ComputeEntity compute : vfcComputeList) {
+ if (compute.getComputeCompositionData().getName().equalsIgnoreCase(name)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private Collection<ComputeEntity> listCompute(String vspId, Version version,String componentId) {
+ Collection<ComputeEntity> computeEntities =
+ computeDao.list(new ComputeEntity(vspId, version, componentId, null));
+
+ return computeEntities;
+ }
+
+ @Override
+ public CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version,
+ String componentId,
+ String computeFlavorId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
+ componentId, computeFlavorId);
+
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+ ComputeEntity computeEntity = getCompute(vspId, version, componentId, computeFlavorId);
+ ComputeData compute = computeEntity.getComputeCompositionData();
+
+ ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ schemaInput.setCompute(compute);
+
+ CompositionEntityResponse<ComputeData> response = new CompositionEntityResponse<>();
+ response.setId(computeFlavorId);
+ response.setData(compute);
+ response.setSchema(getComputeCompositionSchema(schemaInput));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id, compute id", vspId,
+ componentId, computeFlavorId);
+
+ return response;
+ }
+
+ private ComputeEntity getCompute(String vspId, Version version, String componentId, String
+ computeFlavorId) {
+ //validateComponentId(vspId,version,componentId);
+ ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId, version, componentId,
+ computeFlavorId));
+ VersioningUtil
+ .validateEntityExistence(retrieved, new ComputeEntity(vspId, version, componentId,
+ computeFlavorId), VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ /*private void validateComponentId(String vspId, Version version, String componentId) {
+ ComponentEntity retrivedComponent = componentDao.get(new ComponentEntity(vspId, version,
+ componentId));
+ VersioningUtil
+ .validateEntityExistence(retrivedComponent, new ComponentEntity(vspId, version,
+ componentId),VspDetails.ENTITY_TYPE);
+ }*/
+
+ @Override
+ public QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String
+ componentId, String computeId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, componentId", vspId, componentId, computeId);
+
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+ //validateComponentId(vspId,version,componentId);
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ //validateComponentId(vspId,version,componentId);
+ ComputeEntity computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId, computeId);
+ VersioningUtil
+ .validateEntityExistence(computeQuestionnaire, new ComputeEntity(vspId, version, componentId,
+ computeId), VspDetails.ENTITY_TYPE);
+ questionnaireResponse.setData(computeQuestionnaire.getQuestionnaireData());
+ questionnaireResponse.setSchema(getComputeQuestionnaireSchema(null));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId,
+ componentId, computeId);
+
+ return questionnaireResponse;
+ }
+
+
+ protected String getComputeQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute,
+ schemaInput);
+ }
+
+
+ @Override
+ public void updateComputeQuestionnaire(String vspId, Version version, String componentId, String
+ computeId,
+ String questionnaireData, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
+ componentId, computeId);
+
+ /*Version activeVersion =
+ getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
+ getComponent(vspId, activeVersion, componentId);*/
+ ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId,version,componentId,
+ computeId));
+ VersioningUtil.validateEntityExistence(retrieved, new ComputeEntity(vspId, version,
+ componentId, computeId), VspDetails.ENTITY_TYPE);
+
+ computeDao.updateQuestionnaireData(vspId, version, componentId, computeId, questionnaireData);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id, compute id", vspId,
+ componentId, computeId);
+ }
+
+ @Override
+ public CompositionEntityValidationData updateCompute(ComputeEntity compute, String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
+ compute.getId());
+
+ /*Version activeVersion =
+ getVersionInfo(image.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
+ image.setVersion(activeVersion);*/
+
+ ComputeEntity retrieved = getComputeEntity(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ compute.getId());
+
+ if(!vspInfoDao.isManual(compute.getVspId(), compute.getVersion())) {
+ final ComputeData computeCompositionData = compute.getComputeCompositionData();
+ final String name = computeCompositionData.getName();
+ //final String format = computeCompositionData.getFormat();
+ validateHeatVspComputeUpdate("Name", name, retrieved.getComputeCompositionData()
+ .getName());
+ /*validateHeatVspComputeUpdate("format", format, retrieved.getComputeCompositionData()
+ .getFormat());*/
+ }
+
+ Collection<ComputeEntity> vfcComputeList = listComputes(compute.getVspId() ,
+ compute.getVersion(), compute.getComponentId());
+
+ //Set to null so that retrieved object is equal to one in list and gets removed.
+ retrieved.setQuestionnaireData(null);
+ vfcComputeList.remove(retrieved);
+ if(vspInfoDao.isManual(compute.getVspId(), compute.getVersion()))
+ validateVfcCompute(compute, vfcComputeList);
+
+ //Set format to default value in order to handle FTL validation when compute format is null
+ /*if(compute.getComputeCompositionData().getFormat() == null)
+ compute.getComputeCompositionData().setFormat(ComputeFormat.qcow2.name());*/
+
+ ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
+ schemaInput.setCompute(compute.getComputeCompositionData());
+
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(compute, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ computeDao.update(compute);
+ }
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
+ compute.getId());
+
+ return validationData;
+ }
+
+ private void validateHeatVspComputeUpdate(String name, String value, String retrivedValue) {
+
+ if(value != null && !value.equals(retrivedValue)) {
+
+ final ErrorCode updateHeatComputeErrorBuilder =
+ DuplicateComputeInComponentErrorBuilder.getComputeHeatReadOnlyErrorBuilder(name);
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ updateHeatComputeErrorBuilder.message());
+ throw new CoreException(updateHeatComputeErrorBuilder);
+ }
+ }
+
+ private void validateVfcCompute(ComputeEntity compute, Collection<ComputeEntity> vfcComputeList) {
+ if (isComputeNameDuplicate(vfcComputeList,compute.getComputeCompositionData().getName(), compute.getId())) {
+ ErrorCode errorCode = DuplicateComputeInComponentErrorBuilder.getDuplicateComputeNameErrorBuilder(compute
+ .getComputeCompositionData().getName(), compute.getComponentId());
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
+ errorCode.id(),errorCode.message());
+
+ throw new CoreException(errorCode);
+ }
+ }
+
+ private boolean isComputeNameDuplicate(Collection<ComputeEntity> computes, String name, String computeId) {
+ for (ComputeEntity compute : computes) {
+ if (compute.getComputeCompositionData().getName().equals(name) && !compute.getId().equals(computeId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ private ComputeEntity getComputeEntity(String vspId, Version version, String componentId,
+ String computeId) {
+ //validateComponentId(vspId,version,componentId);
+ ComputeEntity computeEntity = computeDao.get(new ComputeEntity(vspId, version, componentId, computeId));
+ VersioningUtil.validateEntityExistence(computeEntity, new ComputeEntity(vspId, version, componentId,
+ computeId), VspDetails.ENTITY_TYPE);
+ return computeEntity;
+ }
+
+ private Collection<ComputeEntity> listComputes(String vspId, Version version, String componentId) {
+ return computeDao.list(new ComputeEntity(vspId, version, componentId, null));
+ }
+
+ @Override
+ public void deleteCompute(String vspId, Version version, String componentId, String
+ computeFlavorId, String user) {
+ final String VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG =
+ "Composition entities may not be created / deleted for Vendor Software Product "
+ + "whose entities were uploaded";
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
+ componentId, computeFlavorId);
+
+ /*Version activeVersion =
+ getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();*/
+ if (!vspInfoDao.isManual(vspId, version)) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.DELETE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete compute");
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
+ .withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
+ }
+ ComputeEntity retrived = getCompute(vspId,version,componentId,computeFlavorId);
+ if (retrived != null){
+ deleteComputeFromDeploymentFlavors(vspId,version,computeFlavorId);
+ computeDao.delete(new ComputeEntity(vspId, version, componentId, computeFlavorId));
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id, compute id", vspId,
+ componentId, computeFlavorId);
+ }
+
+ private void deleteComputeFromDeploymentFlavors(String vspId, Version activeVersion,
+ String computeFlavorId) {
+ //Collection<DeploymentFlavorEntity> listDF = listDeploymentFlavors(vspId, activeVersion);
+ Collection<DeploymentFlavorEntity> listDF = deploymentFlavorDao.list(new DeploymentFlavorEntity
+ (vspId, activeVersion, null));
+ for(DeploymentFlavorEntity df : listDF) {
+ DeploymentFlavorEntity deploymentFlavorEntity=removeComputeFromDF(df, computeFlavorId);
+ if(deploymentFlavorEntity!=null)
+ deploymentFlavorDao.update(deploymentFlavorEntity);
+ }
+ }
+
+ private DeploymentFlavorEntity removeComputeFromDF(DeploymentFlavorEntity df, String
+ computeFlavorId) {
+ DeploymentFlavor flavor = df.getDeploymentFlavorCompositionData();
+ List<ComponentComputeAssociation> associations = flavor.getComponentComputeAssociations();
+ if (associations != null) {
+ List<ComponentComputeAssociation> updatedAssociations = new ArrayList<>();
+ for (ComponentComputeAssociation ca : associations) {
+ if (ca.getComputeFlavorId() != null && ca.getComputeFlavorId().equals(computeFlavorId)) {
+ ComponentComputeAssociation updateCaremoveCompute = new ComponentComputeAssociation();
+ updateCaremoveCompute.setComponentId(ca.getComponentId());
+ updatedAssociations.add(updateCaremoveCompute);
+ } else {
+ updatedAssociations.add(ca);
+ }
+ }
+ flavor.setComponentComputeAssociations(updatedAssociations);
+ df.setDeploymentFlavorCompositionData(flavor);
+ return df;
+ }
+ return null;
+ }
+
+ protected String getComputeCompositionSchema(SchemaTemplateInput schemaInput){
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.compute, schemaInput);
+ }
+
+ /*boolean isManual(String vspId, Version version) {
+
+ VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
+ String onboardingMethod = vsp.getOnboardingMethod();
+ if (MANUAL.equals(onboardingMethod)) {
+ return true;
+ }
+ return false;
+ }*/
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java
new file mode 100644
index 0000000000..aef8be1fef
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java
@@ -0,0 +1,31 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager;
+import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+
+public class DeploymentFlavorManagerFactoryImpl extends DeploymentFlavorManagerFactory {
+
+ private static final DeploymentFlavorManager INSTANCE = new DeploymentFlavorManagerImpl(
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ DeploymentFlavorDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(),
+ ComponentDaoFactory.getInstance().createInterface(),
+ ComputeDaoFactory.getInstance().createInterface()
+ );
+
+ @Override
+ public DeploymentFlavorManager createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
new file mode 100644
index 0000000000..7069d778a7
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
@@ -0,0 +1,396 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DeploymentFlavorErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.DeploymentFlavorCompositionSchemaInput;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
+import org.openecomp.sdc.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
+
+ private static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private DeploymentFlavorDao deploymentFlavorDao;
+ private CompositionEntityDataManager compositionEntityDataManager;
+ private ComponentDao componentDao;
+ private ComputeDao computeDao;
+
+ public DeploymentFlavorManagerImpl(
+ VendorSoftwareProductInfoDao vspInfoDao,
+ DeploymentFlavorDao deploymentFlavorDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ ComponentDao componentDao,
+ ComputeDao computeDao
+
+ ) {
+
+ this.vspInfoDao = vspInfoDao;
+ this.deploymentFlavorDao = deploymentFlavorDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.componentDao = componentDao;
+ this.computeDao = computeDao;
+
+ }
+
+ @Override
+ public Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return listDeploymentFlavors(vspId, version);
+ }
+
+ private Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version) {
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
+ return deploymentFlavorEntities;
+ }
+
+ @Override
+ public DeploymentFlavorEntity createDeploymentFlavor(
+ DeploymentFlavorEntity deploymentFlavorEntity, String user) {
+ DeploymentFlavorEntity createDeploymentFlavor = null;
+ mdcDataDebugMessage.debugEntryMessage("VSP id ", deploymentFlavorEntity.getVspId());
+ /*Version activeVersion =
+ getVersionInfo(deploymentFlavorEntity.getVspId(), VersionableEntityAction.Write, user)
+ .getActiveVersion();
+ deploymentFlavorEntity.setVersion(activeVersion);*/
+
+ if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
+ deploymentFlavorEntity.getVersion())) {
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getAddDeploymentNotSupportedHeatOnboardErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), deploymentFlavorErrorBuilder.message());
+ throw new CoreException(deploymentFlavorErrorBuilder);
+ } else {
+ validateDeploymentFlavor(deploymentFlavorEntity, user, deploymentFlavorEntity.getVersion());
+ createDeploymentFlavor =
+ compositionEntityDataManager.createDeploymentFlavor(deploymentFlavorEntity);
+ }
+ return createDeploymentFlavor;
+ }
+
+ private void validateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity, String
+ user, Version activeVersion) {
+ //Validation for unique model.
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors =
+ listDeploymentFlavors(deploymentFlavorEntity.getVspId(),
+ activeVersion);
+ isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
+
+ List<String> featureGroups =
+ getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), user, activeVersion);
+ String featureGroup = deploymentFlavorEntity.getDeploymentFlavorCompositionData()
+ .getFeatureGroupId();
+ if (featureGroup != null && featureGroup.trim().length()>0) {
+ if (isEmpty(featureGroups) || (!(validFeatureGroup(featureGroups, featureGroup)))) {
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getFeatureGroupNotexistErrorBuilder(featureGroup, deploymentFlavorEntity.getVspId(),
+ activeVersion);
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), deploymentFlavorErrorBuilder.message());
+ throw new CoreException(deploymentFlavorErrorBuilder);
+ }
+ }
+
+ validateComponentComputeAssociation(deploymentFlavorEntity, activeVersion);
+ }
+
+ private void isDeploymentFlavorModelDuplicate(DeploymentFlavorEntity deploymentFlavorEntity,
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors) {
+ listDeploymentFlavors.forEach(deploymentFlavor -> {
+ if (deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel().equalsIgnoreCase(
+ deploymentFlavor.getDeploymentFlavorCompositionData().getModel())) {
+ ErrorCode deploymentFlavorModelErrorBuilder = DeploymentFlavorErrorBuilder
+ .getDuplicateDeploymentFlavorModelErrorBuilder(
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel(),
+ deploymentFlavorEntity.getVspId());
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), deploymentFlavorModelErrorBuilder.message());
+ throw new CoreException(deploymentFlavorModelErrorBuilder);
+ }
+ });
+ }
+
+ private List<String> getFeatureGroupListForVsp(String vspId,
+ String user, Version activeVersion) {
+ /*VersionedVendorSoftwareProductInfo versionedVendorSoftwareProductInfo = getVspDetails(
+ vspId,activeVersion, user);
+ return versionedVendorSoftwareProductInfo.getVspDetails()
+ .getFeatureGroups();*/
+
+ final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, activeVersion));
+ return vspDetails.getFeatureGroups();
+ }
+
+ private boolean isEmpty(Collection coll) {
+ return (coll == null || coll.isEmpty());
+ }
+
+ private boolean validFeatureGroup(List<String> featureGroups, String featureGroupId) {
+ Iterator<String> iterator = featureGroups.iterator();
+ boolean valid = false;
+ while (iterator.hasNext()) {
+ String fgId = iterator.next().trim();
+ if (fgId.equals(featureGroupId)) {
+ valid = true;
+ break;
+ } else {
+ valid = false;
+ }
+ }
+ return valid;
+ }
+
+ private void validateComponentComputeAssociation(DeploymentFlavorEntity deploymentFlavorEntity,
+ Version activeVersion) {
+ List<ComponentComputeAssociation> componentComputeAssociationList = deploymentFlavorEntity
+ .getDeploymentFlavorCompositionData().getComponentComputeAssociations();
+ List<String> vfcList = new ArrayList<>();
+ if (!isEmpty(componentComputeAssociationList)) {
+ componentComputeAssociationList.forEach(componentComputeAssociation -> {
+ if ((componentComputeAssociation.getComponentId() == null || componentComputeAssociation
+ .getComponentId().trim().length() == 0) &&
+ (componentComputeAssociation
+ .getComputeFlavorId() != null && componentComputeAssociation
+ .getComputeFlavorId().trim().length() > 0)) {
+ ErrorCode invalidAssociationErrorBuilder = DeploymentFlavorErrorBuilder
+ .getInvalidAssociationErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), invalidAssociationErrorBuilder.message());
+ throw new CoreException(invalidAssociationErrorBuilder);
+ } else if (componentComputeAssociation.getComponentId() != null &&
+ componentComputeAssociation.getComponentId().trim().length() > 0 ) {
+ ComponentEntity component = getComponent(deploymentFlavorEntity.getVspId(), activeVersion,
+ componentComputeAssociation.getComponentId());
+ if (componentComputeAssociation
+ .getComputeFlavorId() != null && componentComputeAssociation
+ .getComputeFlavorId().trim().length() > 0 ) {
+ ComputeEntity computeFlavor = computeDao.get(new ComputeEntity(deploymentFlavorEntity
+ .getVspId(), activeVersion, componentComputeAssociation.getComponentId(),
+ componentComputeAssociation.getComputeFlavorId()));
+ if (computeFlavor == null) {
+ ErrorCode invalidComputeIdErrorBuilder = DeploymentFlavorErrorBuilder
+ .getInvalidComputeIdErrorBuilder(componentComputeAssociation.getComputeFlavorId(),
+ componentComputeAssociation.getComponentId());
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ invalidComputeIdErrorBuilder.message());
+ throw new CoreException(invalidComputeIdErrorBuilder);
+ }
+ }
+ vfcList.add(componentComputeAssociation.getComponentId());
+ }
+ });
+ Map<String, Integer> frequencyMapping = CollectionUtils.getCardinalityMap(vfcList);
+
+ for (Integer vfcCount : frequencyMapping.values()) {
+ if (vfcCount != 1) {
+ ErrorCode duplicateVfcAssociationErrorBuilder = DeploymentFlavorErrorBuilder
+ .getDuplicateVfcAssociationErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ duplicateVfcAssociationErrorBuilder.message());
+ throw new CoreException(duplicateVfcAssociationErrorBuilder);
+ }
+ }
+ }
+ }
+
+ private ComponentEntity getComponent(String vspId, Version version, String componentId) {
+ ComponentEntity retrieved = componentDao.get(new ComponentEntity(vspId, version, componentId));
+ VersioningUtil
+ .validateEntityExistence(retrieved, new ComponentEntity(vspId, version, componentId),
+ VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ @Override
+ public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId,
+ Version version,
+ String deploymentFlavorId,
+ String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
+
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+ DeploymentFlavorEntity deploymentFlavorEntity = getDeploymentFlavor(vspId,version,
+ deploymentFlavorId);
+ DeploymentFlavor deploymentFlavor = deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+ DeploymentFlavorCompositionSchemaInput schemaInput = new
+ DeploymentFlavorCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ schemaInput.setDeploymentFlavor(deploymentFlavor);
+ List<String> featureGroups =
+ getFeatureGroupListForVsp(vspId, user, version);
+ schemaInput.setFeatureGroupIds(featureGroups);
+ CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
+ response.setId(deploymentFlavorId);
+ response.setSchema((SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.deployment,
+ schemaInput)));
+ response.setData(deploymentFlavor);
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, deployment flavor id ", vspId, deploymentFlavorId);
+
+ return response;
+ }
+
+ private DeploymentFlavorEntity getDeploymentFlavor(String vspId, Version version, String
+ deploymentFlavorId) {
+ DeploymentFlavorEntity retrieved = deploymentFlavorDao.get(new DeploymentFlavorEntity(vspId,
+ version, deploymentFlavorId));
+ VersioningUtil
+ .validateEntityExistence(retrieved, new DeploymentFlavorEntity(vspId, version,
+ deploymentFlavorId ), VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ @Override
+ public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId,
+ Version version,
+ String user) {
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+ DeploymentFlavorCompositionSchemaInput schemaInput= new
+ DeploymentFlavorCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ List<String> featureGroups =
+ getFeatureGroupListForVsp(vspId, user, version);
+ schemaInput.setFeatureGroupIds(featureGroups);
+ CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
+ response.setSchema((SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.deployment,
+ schemaInput)));
+ return response;
+ }
+
+ @Override
+ public void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId,
+ String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
+ /*Version activeVersion =
+ getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();*/
+ DeploymentFlavorEntity deploymentFlavorEntity = getDeploymentFlavor(vspId,version,
+ deploymentFlavorId);
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final ErrorCode deleteDeploymentFlavorErrorBuilder =
+ NotSupportedHeatOnboardMethodErrorBuilder
+ .getDelDeploymentFlavorNotSupportedHeatOnboardMethodErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.DELETE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ deleteDeploymentFlavorErrorBuilder.message());
+ throw new CoreException(deleteDeploymentFlavorErrorBuilder);
+ }
+ if(deploymentFlavorEntity != null) {
+ deploymentFlavorDao.delete(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
+
+ }
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
+ }
+
+ public CompositionEntityValidationData updateDeploymentFlavor(DeploymentFlavorEntity
+ deploymentFlavorEntity, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, deploymentFlavor id", deploymentFlavorEntity
+ .getVspId(), deploymentFlavorEntity.getId());
+ /*Version activeVersion =
+ getVersionInfo(deploymentFlavorEntity.getVspId(), VersionableEntityAction.Write, user)
+ .getActiveVersion();*/
+
+ if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
+ deploymentFlavorEntity.getVersion())) {
+ final ErrorCode updateDeploymentFlavorErrorBuilder =
+ NotSupportedHeatOnboardMethodErrorBuilder
+ .getUpdateDfNotSupportedHeatOnboardMethodErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ updateDeploymentFlavorErrorBuilder.message());
+ throw new CoreException(updateDeploymentFlavorErrorBuilder);
+ }
+ //deploymentFlavorEntity.setVersion(activeVersion);
+ DeploymentFlavorEntity retrieved =
+ getDeploymentFlavor(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion(),
+ deploymentFlavorEntity.getId());
+
+
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors = listDeploymentFlavors
+ (deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion());
+ listDeploymentFlavors.remove(retrieved);
+ isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
+
+ //validateComponentComputeAssociation(deploymentFlavorEntity, activeVersion);
+ validateComponentComputeAssociation(deploymentFlavorEntity, deploymentFlavorEntity.getVersion());
+
+ DeploymentFlavorCompositionSchemaInput schemaInput = new
+ DeploymentFlavorCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
+ deploymentFlavorEntity.getVersion()));
+ schemaInput.setDeploymentFlavor(retrieved.getDeploymentFlavorCompositionData());
+
+ List<String> featureGroups =
+ getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), user,
+ deploymentFlavorEntity.getVersion());
+ schemaInput.setFeatureGroupIds(featureGroups);
+
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(deploymentFlavorEntity, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ deploymentFlavorDao.update(deploymentFlavorEntity);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, deploymentFlavor id",
+ deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getId());
+ return validationData;
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java
new file mode 100644
index 0000000000..9689615c70
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.ImageManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ImageManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
+
+public class ImageManagerFactoryImpl extends ImageManagerFactory {
+
+ private static final ImageManager INSTANCE =
+ new ImageManagerImpl(
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ ImageDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface()
+ );
+
+ @Override
+ public ImageManager createInterface() {
+ return INSTANCE;
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
new file mode 100644
index 0000000000..e180138119
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
@@ -0,0 +1,359 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.ImageManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.ImageErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ImageFormat;
+import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.image.ImageDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ImageCompositionSchemaInput;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
+import org.openecomp.sdc.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+
+import java.util.Collection;
+
+public class ImageManagerImpl implements ImageManager {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private ImageDao imageDao;
+ private CompositionEntityDataManager compositionEntityDataManager;
+
+ public ImageManagerImpl(
+ VendorSoftwareProductInfoDao vspInfoDao,
+ ImageDao imageDao,
+ CompositionEntityDataManager compositionEntityDataManager
+
+ ) {
+
+ this.vspInfoDao = vspInfoDao;
+ this.imageDao = imageDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+
+ }
+
+ @Override
+ public ImageEntity createImage(ImageEntity imageEntity, String user) {
+ /*Version activeVersion = getVersionInfo(imageEntity.getVspId(),
+ VersionableEntityAction.Write, user).getActiveVersion();
+
+ imageEntity.setVersion(activeVersion);*/
+ if (!vspInfoDao.isManual(imageEntity.getVspId(), imageEntity.getVersion())) {
+
+ ErrorCode errorCode = NotSupportedHeatOnboardMethodErrorBuilder
+ .getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_IMAGE, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message());
+
+ throw new CoreException(errorCode);
+ }
+
+ Collection<ImageEntity> vfcImageList = listImages(imageEntity.getVspId() ,
+ imageEntity.getVersion(), imageEntity.getComponentId());
+ validateVfcImage(imageEntity, vfcImageList);
+ compositionEntityDataManager.createImage(imageEntity);
+ return imageEntity;
+ }
+
+ @Override
+ public Collection<ImageEntity> listImages(String vspId, Version version, String componentId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ Collection<ImageEntity> imageEntities = listImages(vspId, version, componentId);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+
+ return imageEntities;
+ }
+
+ private Collection<ImageEntity> listImages(String vspId, Version version, String componentId) {
+ return imageDao.list(new ImageEntity(vspId, version, componentId, null));
+ }
+
+ @Override
+ public CompositionEntityResponse getImageSchema(String vspId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, image id", vspId);
+
+ CompositionEntityResponse<Image> response = new CompositionEntityResponse<>();
+ ImageCompositionSchemaInput inputSchema = new ImageCompositionSchemaInput();
+ Image image = new Image();
+ //image.setFormat(ImageFormat.qcow2.name());
+ inputSchema.setImage(image);
+ response.setSchema(getImageCompositionSchema(inputSchema));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, image id", vspId);
+ return response;
+ }
+
+ @Override
+ public CompositionEntityResponse<Image> getImage(String vspId, Version version, String
+ componentId, String imageId, String user) {
+
+ mdcDataDebugMessage.debugEntryMessage("VSP id, componentId, image id", vspId, componentId,
+ imageId);
+
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+
+ ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
+
+ Image image = imageEntity.getImageCompositionData();
+ //Set format to default value in order to handle FTL validation when image format is null
+ /*if(image.getFormat() == null)
+ image.setFormat(ImageFormat.qcow2.name());*/
+
+ ImageCompositionSchemaInput schemaInput = new ImageCompositionSchemaInput();
+ schemaInput.setImage(image);
+
+ CompositionEntityResponse<Image> response = new CompositionEntityResponse<>();
+ response.setId(imageId);
+ response.setData(image);
+ response.setSchema(getImageCompositionSchema(schemaInput));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, componentId, image id", vspId, componentId,
+ imageId);
+
+ return response;
+ }
+
+ @Override
+ public QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String
+ componentId, String imageId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
+ validateComponentId(vspId,version,componentId);*/
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ //validateComponentId(vspId,version,componentId);
+
+ ImageEntity retrieved = imageDao.getQuestionnaireData(vspId, version, componentId, imageId);
+ VersioningUtil.validateEntityExistence(retrieved, new ImageEntity(vspId, version, componentId,
+ imageId), ComponentEntity.ENTITY_TYPE);
+ questionnaireResponse.setData(retrieved.getQuestionnaireData());
+ questionnaireResponse.setSchema(getImageQuestionnaireSchema(null));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+
+ return questionnaireResponse;
+ }
+
+ @Override
+ public void deleteImage(String vspId, Version version, String componentId, String imageId, String
+ user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", vspId, componentId, imageId);
+
+ /*Version activeVersion =
+ getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
+ ComponentEntity component = getComponent(vspId, activeVersion, componentId);*/
+ ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final ErrorCode deleteImageErrorBuilder =
+ NotSupportedHeatOnboardMethodErrorBuilder
+ .getDelImageNotSupportedHeatOnboardMethodErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.DELETE_IMAGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ deleteImageErrorBuilder.message());
+ throw new CoreException(deleteImageErrorBuilder);
+ }
+ if (imageEntity != null) {
+ imageDao.delete(new ImageEntity(vspId, version, componentId, imageId));
+ }
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", vspId, componentId, imageId);
+ }
+
+ private void validateHeatVspImageUpdate(String name, String value, String retrivedValue) {
+
+ if(value != null && !value.equals(retrivedValue)) {
+
+ final ErrorCode updateHeatImageErrorBuilder =
+ ImageErrorBuilder.getImageHeatReadOnlyErrorBuilder(name);
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ updateHeatImageErrorBuilder.message());
+ throw new CoreException(updateHeatImageErrorBuilder);
+ }
+ }
+
+ @Override
+ public CompositionEntityValidationData updateImage(ImageEntity image, String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
+ image.getId());
+
+ /*Version activeVersion =
+ getVersionInfo(image.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
+ image.setVersion(activeVersion);*/
+
+ ImageEntity retrieved = getImageEntity(image.getVspId(), image.getVersion(), image.getComponentId(),
+ image.getId());
+
+ if(!vspInfoDao.isManual(image.getVspId(), image.getVersion())) {
+ final Image imageCompositionData = image.getImageCompositionData();
+ final String fileName = imageCompositionData.getFileName();
+ //final String format = imageCompositionData.getFormat();
+ validateHeatVspImageUpdate("fileName", fileName, retrieved.getImageCompositionData()
+ .getFileName());
+ /*validateHeatVspImageUpdate("format", format, retrieved.getImageCompositionData()
+ .getFormat());*/
+ }
+
+ Collection<ImageEntity> vfcImageList = listImages(image.getVspId() ,
+ image.getVersion(), image.getComponentId());
+
+ //Set to null so that retrieved object is equal to one in list and gets removed.
+ retrieved.setQuestionnaireData(null);
+ vfcImageList.remove(retrieved);
+ validateVfcImage(image, vfcImageList);
+
+ //Set format to default value in order to handle FTL validation when image format is null
+ /*if(image.getImageCompositionData().getFormat() == null)
+ image.getImageCompositionData().setFormat(ImageFormat.qcow2.name());*/
+
+ ImageCompositionSchemaInput schemaInput = new ImageCompositionSchemaInput();
+ schemaInput.setImage(image.getImageCompositionData());
+
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(image, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ imageDao.update(image);
+ }
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
+ image.getId());
+
+ return validationData;
+ }
+
+ @Override
+ public void updateImageQuestionnaire(String vspId, Version version, String componentId, String
+ imageId, String questionnaireData, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id, imageId", vspId, componentId,
+ imageId);
+
+ getImageEntity(vspId, version, componentId, imageId);
+
+ /*Version activeVersion =
+ getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
+
+ getComponent(vspId, activeVersion, componentId);*/
+
+ final ImageDetails image = JsonUtil.json2Object(questionnaireData, ImageDetails.class);
+ final String format = image.getFormat();
+ try {
+ if (format != null) {
+ final ImageFormat imageFormat = ImageFormat.valueOf(format);
+ }
+ } catch (IllegalArgumentException exception) {
+ ErrorCode errorCode = ImageErrorBuilder.getInvalidImageFormatErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message() );
+ throw new CoreException(errorCode);
+ }
+
+ //Validate Format is read only for HEAT Onboarding
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final QuestionnaireResponse imageQuestionnaire = getImageQuestionnaire(vspId, version,
+ componentId, imageId, user);
+ final String data = imageQuestionnaire.getData();
+ if (data != null) {
+ String retrivedFormat = JsonUtil.json2Object(data, ImageDetails.class).getFormat();
+ validateHeatVspImageUpdate("format", format, retrivedFormat);
+ }
+ }
+
+ imageDao.updateQuestionnaireData(vspId, version, componentId, imageId, questionnaireData);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id, imageId", vspId, componentId,
+ imageId);
+ }
+
+ private ImageEntity getImageEntity(String vspId, Version version, String componentId,
+ String imageId) {
+ //validateComponentId(vspId,version,componentId);
+
+ ImageEntity imageEntity = imageDao.get(new ImageEntity(vspId, version, componentId, imageId));
+
+ VersioningUtil.validateEntityExistence(imageEntity, new ImageEntity(vspId, version, componentId,
+ imageId), VspDetails.ENTITY_TYPE);
+ return imageEntity;
+ }
+
+
+ private boolean isImageNameDuplicate(Collection<ImageEntity> images, String fileName) {
+ for (ImageEntity image : images) {
+ if (image.getImageCompositionData().getFileName().equalsIgnoreCase(fileName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void validateVfcImage(ImageEntity image, Collection<ImageEntity> vfcImageList) {
+ if (isImageNameDuplicate(vfcImageList,image.getImageCompositionData().getFileName())) {
+ ErrorCode errorCode = ImageErrorBuilder.getDuplicateImageNameErrorBuilder(image
+ .getImageCompositionData().getFileName(), image.getComponentId());
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
+ errorCode.id(),errorCode.message());
+
+ throw new CoreException(errorCode);
+ }
+ }
+
+ protected String getImageCompositionSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.image,
+ schemaInput);
+ }
+
+ protected String getImageQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image,
+ schemaInput);
+ }
+
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
new file mode 100644
index 0000000000..ef33812ddc
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
@@ -0,0 +1,117 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.apache.commons.collections4.MapUtils;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.generator.core.services.ManualVspToscaGenerationService;
+import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
+import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
+import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.ManualVspDataCollectionService;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
+
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ @Override
+ public VspModelInfo gatherVspInformation(String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+ ManualVspDataCollectionService
+ manualVspDataCollectionService = new ManualVspDataCollectionService();
+ VspModelInfo vspModelInfo = new VspModelInfo();
+ //Get Release Vendor Name
+ Optional<String> releaseVendor;
+ try {
+ releaseVendor = manualVspDataCollectionService.getReleaseVendor(vspId, version, user);
+ } catch (Exception ex) {
+ releaseVendor = Optional.empty();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Release Vendor not found");
+ }
+ releaseVendor.ifPresent(vspModelInfo::setReleaseVendor);
+
+ //Get Allowed Deployment flavors information
+ Map<String, DeploymentFlavorModel> allowedFlavors;
+ try {
+ allowedFlavors = manualVspDataCollectionService.getAllowedFlavors(vspId, version, user);
+ } catch (Exception ex) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect allowed flavors");
+ allowedFlavors = null;
+ }
+ if (MapUtils.isNotEmpty(allowedFlavors)) {
+ vspModelInfo.setAllowedFlavors(allowedFlavors);
+ }
+
+ //Get VFC Image information
+ Map<String, List<MultiFlavorVfcImage>> vspComponentImages;
+ try {
+ vspComponentImages =
+ manualVspDataCollectionService.getVspComponentImages(vspId, version, user);
+ } catch (Exception ex) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp component images");
+ vspComponentImages = null;
+ }
+ if (MapUtils.isNotEmpty(vspComponentImages)) {
+ vspModelInfo.setMultiFlavorVfcImages(vspComponentImages);
+ }
+
+ //Get VFC component information
+ Map<String, String> vspComponents;
+ try {
+ vspComponents = manualVspDataCollectionService.getVspComponents(vspId, version, user);
+ } catch (Exception ex) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp components");
+ vspComponents = null;
+ }
+ if (MapUtils.isNotEmpty(vspComponents)) {
+ vspModelInfo.setComponents(vspComponents);
+ }
+
+ //Get VSP component nic information
+ Map<String, List<Nic>> vspComponentNics;
+ try {
+ vspComponentNics = manualVspDataCollectionService.getVspComponentNics(vspId, version, user);
+ } catch (Exception ex) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp component nics");
+ vspComponentNics = null;
+ }
+ if (MapUtils.isNotEmpty(vspComponentNics)) {
+ vspModelInfo.setNics(vspComponentNics);
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return vspModelInfo;
+ }
+
+ @Override
+ public ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+ ManualVspToscaGenerationService vspToscaGenerator = new ManualVspToscaGenerationService();
+ ToscaServiceModel manualVspToscaServiceModel =
+ vspToscaGenerator.createManualVspToscaServiceModel(vspModelInfo);
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return manualVspToscaServiceModel;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImpl.java
deleted file mode 100644
index 185cfa091b..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImpl.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.impl;
-
-import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.enrichment.types.ArtifactType;
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.core.utilities.file.FileContentHandler;
-import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.Messages;
-import org.openecomp.sdc.common.utils.CommonUtil;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
-import org.openecomp.sdc.logging.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorCode;
-import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
-import org.openecomp.sdc.vendorsoftwareproduct.MibManager;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.MibUploadErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus;
-import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-public class MibManagerImpl implements MibManager {
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private ActivityLogManager activityLogManager;
- private MibDao mibDao;
-
- public MibManagerImpl(MibDao mibDao,
- ActivityLogManager activityLogManager) {
- this.mibDao = mibDao;
-
- this.activityLogManager = activityLogManager;
- mibDao.registerVersioning(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
- }
-
- @Override
- public void delete(String vspId, Version version, String componentId,
- ArtifactType artifactType, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
-
- MibEntity mibEntity =
- setValuesForComponentArtifactEntityUpload(vspId, version, null, componentId, null,
- artifactType, null);
- Optional<MibEntity> retrieved = mibDao.getByType(mibEntity);
-
- if (!retrieved.isPresent()) {
- throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
- mibEntity.getEntityType(),
- artifactType.name(),
- VspDetails.ENTITY_TYPE,
- mibEntity.getFirstClassCitizenId(),
- version).build());
- }
-
- mibDao.delete(retrieved.get());
-
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
- }
-
- @Override
- public void upload(InputStream object, String filename, String vspId,
- Version version, String componentId, ArtifactType artifactType,
- String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
-
- if (object == null) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPLOAD_MIB, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid MIB zip file");
- throw new CoreException(new MibUploadErrorBuilder(
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()).build());
- } else {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- try {
- byte[] uploadedFileData = FileUtils.toByteArray(object);
- validateMibZipContent(vspId, version, uploadedFileData, errors);
- if (MapUtils.isNotEmpty(errors)) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPLOAD_MIB, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid MIB zip file");
- throw new CoreException(
- new MibUploadErrorBuilder(errors.values().iterator().next().get(0).getMessage())
- .build());
- }
-
- createArtifactInDatabase(vspId, version, filename, componentId, artifactType,
- uploadedFileData);
-
- } catch (Exception exception) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPLOAD_MIB, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid MIB zip file");
- throw new CoreException(new MibUploadErrorBuilder(exception.getMessage()).build());
- }
- }
-
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vspId, String.valueOf(version.getMajor() + 1),
- ActivityType.UPLOAD_ARTIFACT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
-
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
- }
-
- private void createArtifactInDatabase(String vspId, Version version, String filename,
- String componentId, ArtifactType artifactType,
- byte[] uploadedFileData) {
- String artifactId = CommonMethods.nextUuId();
- MibEntity mibEntity =
- setValuesForComponentArtifactEntityUpload(vspId, version, filename, componentId,
- artifactId, artifactType, uploadedFileData);
- mibDao.create(mibEntity);
- }
-
- @Override
- public MibUploadStatus listFilenames(String vspId, Version version, String componentId,
- String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
-
- MibEntity current =
- new MibEntity(vspId, version, componentId, null);
-
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
-
- return setMibUploadStatusValues(current);
- }
-
-
- private MibUploadStatus setMibUploadStatusValues(
- MibEntity mibEntity) {
- MibUploadStatus mibUploadStatus = new MibUploadStatus();
-
- Collection<MibEntity> artifactNames =
- mibDao.list(mibEntity);
- Map<ArtifactType, String> artifactTypeToFilename =
- VendorSoftwareProductUtils.filterNonTrapOrPollArtifacts(artifactNames);
-
- if (MapUtils.isNotEmpty(artifactTypeToFilename)) {
- if (artifactTypeToFilename.containsKey(ArtifactType.SNMP_TRAP)) {
- mibUploadStatus.setSnmpTrap(artifactTypeToFilename.get(ArtifactType.SNMP_TRAP));
- }
- if (artifactTypeToFilename.containsKey(ArtifactType.SNMP_POLL)) {
- mibUploadStatus.setSnmpPoll(artifactTypeToFilename.get(ArtifactType.SNMP_POLL));
- }
- }
-
- return mibUploadStatus;
- }
-
- private MibEntity setValuesForComponentArtifactEntityUpload(
- String vspId, Version version, String filename, String componentId, String artifactId,
- ArtifactType artifactType, byte[] uploadedFileData) {
-
- MibEntity mibEntity = new MibEntity();
-
- mibEntity.setVspId(vspId);
- mibEntity.setVersion(version);
- mibEntity.setComponentId(componentId);
- mibEntity.setId(artifactId);
- mibEntity.setType(artifactType);
- mibEntity.setArtifactName(filename);
-
- if (Objects.nonNull(uploadedFileData)) {
- mibEntity.setArtifact(ByteBuffer.wrap(uploadedFileData));
- }
-
- return mibEntity;
- }
-
- private void validateMibZipContent(String vspId, Version version, byte[] uploadedFileData,
- Map<String, List<ErrorMessage>> errors) {
- FileContentHandler contentMap;
- try {
- contentMap = CommonUtil.loadUploadFileContent(uploadedFileData);
- VendorSoftwareProductUtils.validateContentZipData(contentMap, errors);
- } catch (IOException exception) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_MIB, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid MIB zip file");
- throw new CoreException(
- new MibUploadErrorBuilder(vspId, version, Messages.INVALID_ZIP_FILE.getErrorMessage())
- .build());
- }
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
index 8c887e0140..6569312f02 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
@@ -21,17 +21,17 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.MibManager;
-import org.openecomp.sdc.vendorsoftwareproduct.MibManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
+import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
-public class MibManagerFactoryImpl extends MibManagerFactory {
- private static final MibManager INSTANCE =
- new MibManagerImpl(MibDaoFactory.getInstance().createInterface(),
+public class MonitoringUploadsManagerFactoryImpl extends MonitoringUploadsManagerFactory {
+ private static final MonitoringUploadsManager INSTANCE =
+ new MonitoringUploadsManagerImpl(MonitoringUploadDaoFactory.getInstance().createInterface(),
ActivityLogManagerFactory.getInstance().createInterface());
@Override
- public MibManager createInterface() {
+ public MonitoringUploadsManager createInterface() {
return INSTANCE;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
new file mode 100644
index 0000000000..73558b465a
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
@@ -0,0 +1,269 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.apache.commons.collections4.MapUtils;
+import org.openecomp.core.enrichment.types.MonitoringUploadType;
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.activityLog.ActivityLogManager;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.common.utils.CommonUtil;
+import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerErrorDescription;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.MonitoringUploadErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
+import org.openecomp.sdcrests.activitylog.types.ActivityType;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private ActivityLogManager activityLogManager;
+ private ComponentArtifactDao componentArtifactDao;
+ private static final Logger logger =
+ LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class);
+
+ MonitoringUploadsManagerImpl(ComponentArtifactDao componentArtifactDao,
+ ActivityLogManager activityLogManager) {
+ this.componentArtifactDao = componentArtifactDao;
+
+ this.activityLogManager = activityLogManager;
+ componentArtifactDao.registerVersioning(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
+ }
+
+ @Override
+ public void delete(String vspId, Version version, String componentId,
+ MonitoringUploadType monitoringUploadType, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity =
+ setValuesForComponentArtifactEntityUpload(vspId, version, null, componentId, null,
+ monitoringUploadType, null);
+ Optional<ComponentMonitoringUploadEntity> retrieved = componentArtifactDao.getByType(
+ componentMonitoringUploadEntity);
+
+ if (!retrieved.isPresent()) {
+ throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
+ componentMonitoringUploadEntity.getEntityType(),
+ monitoringUploadType.name(),
+ VspDetails.ENTITY_TYPE,
+ componentMonitoringUploadEntity.getFirstClassCitizenId(),
+ version).build());
+ }
+
+ componentArtifactDao.delete(retrieved.get());
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+ @Override
+ public void upload(InputStream object, String filename, String vspId,
+ Version version, String componentId,
+ MonitoringUploadType type,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ if (object == null) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPLOAD_MONITORING_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid " + type
+ .toString() + " zip file");
+ throw new CoreException(new MonitoringUploadErrorBuilder(
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()).build());
+ } else {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ try {
+ byte[] uploadedFileData = FileUtils.toByteArray(object);
+ final FileContentHandler upload =
+ validateZip(vspId, version, uploadedFileData, errors);
+ if (type.equals(MonitoringUploadType.VES_EVENTS)) {
+ validateVesEventUpload(upload, errors, vspId, version);
+ }
+ if (MapUtils.isNotEmpty(errors)) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPLOAD_MONITORING_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid " + type
+ .toString() + " zip file");
+ throw new CoreException(
+ new MonitoringUploadErrorBuilder(
+ errors.values().iterator().next().get(0).getMessage())
+ .build());
+ }
+
+ createArtifactInDatabase(vspId, version, filename, componentId, type,
+ uploadedFileData);
+
+ } catch (Exception exception) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPLOAD_MONITORING_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid " + type.toString() + "zip file");
+ throw new CoreException(new MonitoringUploadErrorBuilder(exception.getMessage()).build());
+ }
+ }
+
+ ActivityLogEntity activityLogEntity =
+ new ActivityLogEntity(vspId, String.valueOf(version.getMajor() + 1),
+ ActivityType.UPLOAD_MONITORING_FILE.toString(), user, true, "", "");
+ activityLogManager.addActionLog(activityLogEntity, user);
+ logger.audit("Uploaded Monitoring File for component id:" + componentId + " ,vspId:" + vspId);
+
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+ private void validateVesEventUpload(FileContentHandler upload,
+ Map<String, List<ErrorMessage>> errors, String vspId,
+ Version version) {
+ if (!CommonUtil.validateAllFilesYml(upload)) {
+ ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
+ .add(new ErrorMessage(ErrorLevel.ERROR,
+ Messages.VES_ZIP_SHOULD_CONTAIN_YML_ONLY.getErrorMessage()));
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.VALIDATE_MONITORING_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VES_FILE);
+ throw new CoreException(
+ new MonitoringUploadErrorBuilder(
+ Messages.VES_ZIP_SHOULD_CONTAIN_YML_ONLY.getErrorMessage())
+ .build());
+ }
+ }
+
+ private void createArtifactInDatabase(String vspId, Version version, String filename,
+ String componentId,
+ MonitoringUploadType type,
+ byte[] uploadedFileData) {
+ String artifactId = CommonMethods.nextUuId();
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity =
+ setValuesForComponentArtifactEntityUpload(vspId, version, filename, componentId,
+ artifactId, type, uploadedFileData);
+ componentArtifactDao.create(componentMonitoringUploadEntity);
+ }
+
+ @Override
+ public MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ ComponentMonitoringUploadEntity current =
+ new ComponentMonitoringUploadEntity(vspId, version, componentId, null);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ return setMonitoringUploadStatusValues(current);
+ }
+
+
+ private MonitoringUploadStatus setMonitoringUploadStatusValues(
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ MonitoringUploadStatus monitoringUploadStatus = new MonitoringUploadStatus();
+
+ Collection<ComponentMonitoringUploadEntity> artifactNames =
+ componentArtifactDao.list(componentMonitoringUploadEntity);
+ Map<MonitoringUploadType, String> artifactTypeToFilename =
+ VendorSoftwareProductUtils.mapArtifactsByType(artifactNames);
+
+ if (MapUtils.isNotEmpty(artifactTypeToFilename)) {
+ if (artifactTypeToFilename.containsKey(MonitoringUploadType.SNMP_TRAP)) {
+ monitoringUploadStatus
+ .setSnmpTrap(artifactTypeToFilename.get(MonitoringUploadType.SNMP_TRAP));
+ }
+ if (artifactTypeToFilename.containsKey(MonitoringUploadType.SNMP_POLL)) {
+ monitoringUploadStatus
+ .setSnmpPoll(artifactTypeToFilename.get(MonitoringUploadType.SNMP_POLL));
+ }
+ if (artifactTypeToFilename.containsKey(MonitoringUploadType.VES_EVENTS)) {
+ monitoringUploadStatus
+ .setVesEvent(artifactTypeToFilename.get(MonitoringUploadType.VES_EVENTS));
+ }
+ }
+
+ return monitoringUploadStatus;
+ }
+
+ private ComponentMonitoringUploadEntity setValuesForComponentArtifactEntityUpload(
+ String vspId, Version version, String filename, String componentId, String artifactId,
+ MonitoringUploadType monitoringUploadType, byte[] uploadedFileData) {
+
+ ComponentMonitoringUploadEntity
+ entity = new ComponentMonitoringUploadEntity();
+
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ entity.setComponentId(componentId);
+ entity.setId(artifactId);
+ entity.setType(monitoringUploadType);
+ entity.setArtifactName(filename);
+
+ if (Objects.nonNull(uploadedFileData)) {
+ entity.setArtifact(ByteBuffer.wrap(uploadedFileData));
+ }
+
+ return entity;
+ }
+
+ private FileContentHandler validateZip(String vspId, Version version, byte[] uploadedFileData,
+ Map<String, List<ErrorMessage>> errors) {
+ FileContentHandler contentMap;
+ try {
+ contentMap = CommonUtil.validateAndUploadFileContent(uploadedFileData);
+ VendorSoftwareProductUtils.validateContentZipData(contentMap, errors);
+ } catch (IOException exception) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.VALIDATE_MONITORING_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid Monitoring zip file");
+ throw new CoreException(
+ new MonitoringUploadErrorBuilder(vspId, version,
+ Messages.INVALID_ZIP_FILE.getErrorMessage())
+ .build());
+ }
+ return contentMap;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java
index 1d911701f9..6110519d81 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java
@@ -24,6 +24,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.NetworkManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
import org.openecomp.sdc.vendorsoftwareproduct.NicManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
public class NicManagerFactoryImpl extends NicManagerFactory {
@@ -31,7 +32,8 @@ public class NicManagerFactoryImpl extends NicManagerFactory {
new NicManagerImpl(
NicDaoFactory.getInstance().createInterface(),
CompositionEntityDataManagerFactory.getInstance().createInterface(),
- NetworkManagerFactory.getInstance().createInterface());
+ NetworkManagerFactory.getInstance().createInterface(),
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface());
@Override
public NicManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
index d73e0f5def..b196b3f54c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
@@ -31,20 +32,30 @@ import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager;
import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.CompositionEditNotAllowedErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DeleteNicErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DuplicateNicInComponentErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicNetworkIdNotAllowedExternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.NicCompositionSchemaInput;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -58,13 +69,16 @@ public class NicManagerImpl implements NicManager {
private NicDao nicDao;
private CompositionEntityDataManager compositionEntityDataManager;
private NetworkManager networkManager;
+ private VendorSoftwareProductInfoDao vspInfoDao;
public NicManagerImpl(NicDao nicDao,
CompositionEntityDataManager compositionEntityDataManager,
- NetworkManager networkManager) {
+ NetworkManager networkManager,
+ VendorSoftwareProductInfoDao vspInfoDao) {
this.nicDao = nicDao;
this.compositionEntityDataManager = compositionEntityDataManager;
this.networkManager = networkManager;
+ this.vspInfoDao = vspInfoDao;
}
@Override
@@ -96,15 +110,21 @@ public class NicManagerImpl implements NicManager {
@Override
public NicEntity createNic(NicEntity nic, String user) {
+ NicEntity createdNic = null;
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", nic.getVspId(),
nic.getComponentId());
- if (!isManual(nic.getVspId(), nic.getVersion())) {
+ if (!vspInfoDao.isManual(nic.getVspId(), nic.getVersion())) {
+ ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
+ .getAddNicNotSupportedHeatOnboardMethodErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create nic");
- throw new CoreException(
- new CompositionEditNotAllowedErrorBuilder(nic.getVspId(), nic.getVersion()).build());
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ onboardingMethodUpdateErrorCode.message());
+ throw new CoreException(onboardingMethodUpdateErrorCode);
+ } else {
+ validateNic(nic, user);
+ createdNic = createNic(nic);
}
//nicDao.updateVspLatestModificationTime(nic.getVspId(), nic.getVersion());
@@ -112,7 +132,63 @@ public class NicManagerImpl implements NicManager {
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", nic.getVspId(), nic.getComponentId());
- return null;
+ return createdNic;
+ }
+
+ private NicEntity createNic(NicEntity nic) {
+ return compositionEntityDataManager.createNic(nic);
+ }
+
+ private void validateNic(NicEntity nic, String user) {
+ Collection<NicEntity> listNics = listNics(nic.getVspId(), nic.getVersion(), nic
+ .getComponentId(), user);
+ String networkId = nic.getNicCompositionData().getNetworkId();
+ NetworkType networkType = nic.getNicCompositionData().getNetworkType();
+ String networkDescription = nic.getNicCompositionData().getNetworkDescription();
+ listNics.forEach(nicEntity -> {
+ Nic nicdata = nicEntity.getNicCompositionData();
+ if (nic.getNicCompositionData().getName().equalsIgnoreCase(nicdata.getName())) {
+ final ErrorCode duplicateNicInComponentErrorBuilder =
+ new DuplicateNicInComponentErrorBuilder(nic.getNicCompositionData().getName(),
+ nic.getComponentId()).build();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ duplicateNicInComponentErrorBuilder.message());
+ throw new CoreException(duplicateNicInComponentErrorBuilder);
+ }
+
+ });
+
+ if (networkType.equals(NetworkType.Internal)) {
+ if (!(networkId == null || networkId.equals(""))) {
+ //NetworkEntity ne = getNetwork(nic.getVspId(), activeVersion, networkId);
+ final CompositionEntityResponse<Network> network =
+ networkManager.getNetwork(nic.getVspId(), nic.getVersion(), networkId,
+ user);
+ }
+
+ if (!(networkDescription == null || networkDescription.equals(""))) {
+ final ErrorCode nicNetworkDescriptionErrorBuilder =
+ new NicInternalNetworkErrorBuilder()
+ .getNetworkDescriptionInternalNetworkErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), nicNetworkDescriptionErrorBuilder.message());
+ throw new CoreException(nicNetworkDescriptionErrorBuilder);
+ }
+
+ } else if (networkType.equals(NetworkType.External)) {
+ if (!(networkId == null || networkId.equals(""))) {
+ final ErrorCode nicNetworkIdNotAllowedExternalNetworkErrorBuilder =
+ new NicNetworkIdNotAllowedExternalNetworkErrorBuilder().build();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ nicNetworkIdNotAllowedExternalNetworkErrorBuilder.message());
+ throw new CoreException(nicNetworkIdNotAllowedExternalNetworkErrorBuilder);
+ }
+ }
}
@Override
@@ -125,7 +201,7 @@ public class NicManagerImpl implements NicManager {
Nic nic = nicEntity.getNicCompositionData();
NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
- schemaInput.setManual(isManual(vspId, version));
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
schemaInput.setNic(nic);
Map<String, String> networksNameById = listNetworksNameById(vspId, version, user);
nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
@@ -157,15 +233,20 @@ public class NicManagerImpl implements NicManager {
mdcDataDebugMessage
.debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
- if (!isManual(vspId, version)) {
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final ErrorCode deleteNicErrorBuilder =
+ new DeleteNicErrorBuilder().getDeleteNicForHeatOnboardedVspErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_NIC, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete nic");
- throw new CoreException(
- new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ deleteNicErrorBuilder.message());
+ throw new CoreException(deleteNicErrorBuilder);
}
- //nicDao.updateVspLatestModificationTime(vspId, version);
+ NicEntity nicEntity = getNic(vspId, version, componentId, nicId);
+ if (nicEntity != null) {
+ nicDao.delete(nicEntity);
+ }
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", vspId, componentId, nicId);
@@ -181,7 +262,7 @@ public class NicManagerImpl implements NicManager {
getNic(nic.getVspId(), nic.getVersion(), nic.getComponentId(), nic.getId());
NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
- schemaInput.setManual(isManual(nic.getVspId(), nic.getVersion()));
+ schemaInput.setManual(vspInfoDao.isManual(nic.getVspId(), nic.getVersion()));
schemaInput.setNic(retrieved.getNicCompositionData());
CompositionEntityValidationData validationData = compositionEntityDataManager
@@ -244,7 +325,7 @@ public class NicManagerImpl implements NicManager {
}
// todo *************************** move to reusable place! *************************
- private boolean isManual(String vspId, Version version) {
+ /*private boolean isManual(String vspId, Version version) {
return false;
- }
+ }*/
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
index 77d496f0c8..b5464e5708 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
@@ -22,12 +22,11 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
-import org.openecomp.sdc.activitylog.dao.ActivityLogDaoFactory;
import org.openecomp.sdc.healing.factory.HealingManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
@@ -51,7 +50,7 @@ public class OrchestrationTemplateCandidateManagerFactoryImpl extends
CompositionEntityDataManagerFactory.getInstance().createInterface(),
NicDaoFactory.getInstance().createInterface(),
ComponentDaoFactory.getInstance().createInterface(),
- MibDaoFactory.getInstance().createInterface(),
+ MonitoringUploadDaoFactory.getInstance().createInterface(),
ProcessDaoFactory.getInstance().createInterface(),
ActivityLogManagerFactory.getInstance().createInterface());
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
index 99a438f3a8..959cf15789 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
@@ -19,14 +19,12 @@
*/
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues
- .PROCESS_NAME;
+
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.apache.xalan.xslt.Process;
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.types.ServiceElement;
+import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
@@ -55,14 +53,16 @@ import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
import org.openecomp.sdc.validation.util.ValidationManagerUtil;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
@@ -79,24 +79,25 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStru
import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdcrests.activitylog.types.ActivityType;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Collection;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME;
public class OrchestrationTemplateCandidateManagerImpl
implements OrchestrationTemplateCandidateManager {
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static final Logger logger =
LoggerFactory.getLogger(OrchestrationTemplateCandidateManagerImpl.class);
-
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private VendorSoftwareProductDao vendorSoftwareProductDao;
private VendorSoftwareProductInfoDao vspInfoDao;
private OrchestrationTemplateDao orchestrationTemplateDataDao;
@@ -107,10 +108,27 @@ public class OrchestrationTemplateCandidateManagerImpl
private CompositionEntityDataManager compositionEntityDataManager;
private NicDao nicDao;
private ComponentDao componentDao;
- private MibDao mibDao;
+ private ComponentArtifactDao componentArtifactDao;
private ActivityLogManager activityLogManager;
private ProcessDao processDao;
+ /**
+ * Instantiates a new Orchestration template candidate manager.
+ *
+ * @param vendorSoftwareProductDao the vendor software product dao
+ * @param vspInfoDao the vsp info dao
+ * @param orchestrationTemplateDataDao the orchestration template data dao
+ * @param candidateService the candidate service
+ * @param healingManager the healing manager
+ * @param compositionDataExtractor the composition data extractor
+ * @param serviceModelDao the service model dao
+ * @param compositionEntityDataManager the composition entity data manager
+ * @param nicDao the nic dao
+ * @param componentDao the component dao
+ * @param componentArtifactDao the mib dao
+ * @param processDao the process dao
+ * @param activityLogManager the activity log manager
+ */
public OrchestrationTemplateCandidateManagerImpl(
VendorSoftwareProductDao vendorSoftwareProductDao, VendorSoftwareProductInfoDao
vspInfoDao,
@@ -121,7 +139,7 @@ public class OrchestrationTemplateCandidateManagerImpl
CompositionEntityDataManager compositionEntityDataManager,
NicDao nicDao,
ComponentDao componentDao,
- MibDao mibDao,
+ ComponentArtifactDao componentArtifactDao,
ProcessDao processDao,
ActivityLogManager activityLogManager) {
this.vendorSoftwareProductDao = vendorSoftwareProductDao;
@@ -134,7 +152,7 @@ public class OrchestrationTemplateCandidateManagerImpl
this.compositionEntityDataManager = compositionEntityDataManager;
this.nicDao = nicDao;
this.componentDao = componentDao;
- this.mibDao = mibDao;
+ this.componentArtifactDao = componentArtifactDao;
this.processDao = processDao;
this.activityLogManager = activityLogManager;
}
@@ -237,38 +255,43 @@ public class OrchestrationTemplateCandidateManagerImpl
String manifest = candidateService.createManifest(vspDetails, structure);
fileContentMap.addFile(SdcCommon.MANIFEST_NAME, manifest.getBytes());
- HeatStructureTree tree = createAndValidateHeatTree(response, fileContentMap);
-
Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
.fetchZipFileByteArrayInputStream(vspId, candidateDataEntity, manifest, uploadErrors);
if (!zipByteArrayInputStream.isPresent()) {
return response;
}
- Map<String,String> componentsQustanniare = new HashMap<>();
- Map<String, Map<String, String>> componentNicsQustanniare = new HashMap<>();
- Map<String, Collection<MibEntity>> componentMIBList = new HashMap<>();
+
+ HeatStructureTree tree = createAndValidateHeatTree(response, fileContentMap);
+
+ Map<String, String> componentsQuestionnaire = new HashMap<>();
+ Map<String, Map<String, String>> componentNicsQuestionnaire = new HashMap<>();
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList = new HashMap<>();
Map<String, Collection<ProcessEntity>> processes = new HashMap<>();
Map<String, ProcessEntity> processArtifact = new HashMap<>();
- backupComponentsQuestionnaireBeforeDelete(vspId, version, componentsQustanniare,
- componentNicsQustanniare, componentMIBList, processes, processArtifact);
+ backupComponentsQuestionnaireBeforeDelete(vspId, version, componentsQuestionnaire,
+ componentNicsQuestionnaire, componentMibList, processes, processArtifact);
deleteUploadDataAndContent(vspId, version);
saveHotData(vspId, version, zipByteArrayInputStream.get(), fileContentMap, tree);
- ToscaServiceModel toscaServiceModel =
- HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap)
- .getToscaServiceModel();
+ TranslatorOutput translatorOutput =
+ HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap);
+ ToscaServiceModel toscaServiceModel = translatorOutput.getToscaServiceModel();
if (toscaServiceModel != null) {
serviceModelDao.storeServiceModel(vspId, version, toscaServiceModel);
+ //Extracting the compostion data from the output service model of the first phase of
+ // translation
compositionEntityDataManager.saveCompositionData(vspId, version,
- compositionDataExtractor.extractServiceCompositionData(toscaServiceModel));
- retainComponentQuestionnaireData(vspId, version, componentsQustanniare,
- componentNicsQustanniare, componentMIBList, processes, processArtifact);
+ compositionDataExtractor.extractServiceCompositionData(translatorOutput
+ .getNonUnifiedToscaServiceModel()));
+ retainComponentQuestionnaireData(vspId, version, componentsQuestionnaire,
+ componentNicsQuestionnaire, componentMibList, processes, processArtifact);
}
uploadFileResponse.addStructureErrors(uploadErrors);
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspId, String.valueOf(version.getMajor()+1),
+ ActivityLogEntity activityLogEntity =
+ new ActivityLogEntity(vspId, String.valueOf(version.getMajor() + 1),
ActivityType.UPLOAD_HEAT.toString(), user, true, "", "");
activityLogManager.addActionLog(activityLogEntity, user);
@@ -367,9 +390,10 @@ public class OrchestrationTemplateCandidateManagerImpl
private void retainComponentQuestionnaireData(String vspId, Version activeVersion,
Map<String, String> componentsQustanniare,
- Map<String, Map<String, String>> componentNicsQustanniare,
- Map<String, Collection<MibEntity>> componentMIBList,
- Map<String,Collection<ProcessEntity>> processes,
+ Map<String, Map<String, String>>
+ componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
+ Map<String, Collection<ProcessEntity>> processes,
Map<String, ProcessEntity> processArtifact) {
//VSP processes
restoreProcess(vspId, activeVersion, GENERAL_COMPONENT_ID, GENERAL_COMPONENT_ID, processes,
@@ -378,27 +402,31 @@ public class OrchestrationTemplateCandidateManagerImpl
components = vendorSoftwareProductDao.listComponents(vspId, activeVersion);
components.forEach(componentEntity -> {
String componentName = componentEntity.getComponentCompositionData().getName();
- if( componentsQustanniare.containsKey(componentName) ){
+ if (componentsQustanniare.containsKey(componentName)) {
componentDao.updateQuestionnaireData(vspId, activeVersion,
- componentEntity.getId(),componentsQustanniare.get(componentEntity.getComponentCompositionData()
+ componentEntity.getId(),
+ componentsQustanniare.get(componentEntity.getComponentCompositionData()
.getName()));
- if( componentNicsQustanniare.containsKey(componentName) ){
- Map<String, String> nicsQustanniare=componentNicsQustanniare.get(componentName);
+ if (componentNicsQustanniare.containsKey(componentName)) {
+ Map<String, String> nicsQustanniare = componentNicsQustanniare.get(componentName);
Collection<NicEntity>
- nics=nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
- nics.forEach(nicEntity -> {
- if(nicsQustanniare.containsKey(nicEntity.getNicCompositionData().getName())){
- nicDao.updateQuestionnaireData(vspId, activeVersion,componentEntity.getId
- (),nicEntity.getId(),nicsQustanniare.get(nicEntity.getNicCompositionData().getName()));
+ nics =
+ nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
+ nics.forEach(nicEntity -> {
+ if (nicsQustanniare.containsKey(nicEntity.getNicCompositionData().getName())) {
+ nicDao.updateQuestionnaireData(vspId, activeVersion,
+ componentEntity.getId(), nicEntity.getId(),
+ nicsQustanniare.get(nicEntity.getNicCompositionData().getName()));
}
});
}
- //MIB
- if(componentMIBList.containsKey(componentName)) {
- Collection<MibEntity> mibList = componentMIBList.get(componentName);
+ //MIB //todo add for VES_EVENTS
+ if (componentMibList.containsKey(componentName)) {
+ Collection<ComponentMonitoringUploadEntity> mibList =
+ componentMibList.get(componentName);
mibList.forEach(mib -> {
mib.setComponentId(componentEntity.getId());
- mibDao.create(mib);
+ componentArtifactDao.create(mib);
});
}
//VFC processes
@@ -411,43 +439,47 @@ public class OrchestrationTemplateCandidateManagerImpl
private void backupComponentsQuestionnaireBeforeDelete(String vspId, Version activeVersion,
Map<String, String> componentsQustanniare,
Map<String, Map<String, String>>
- componentNicsQustanniare,
- Map<String, Collection<MibEntity>>
- componentMIBList,
- Map<String, Collection<ProcessEntity>> componentProcesses,
+ componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>>
+ componentMibList,
+ Map<String, Collection<ProcessEntity>>
+ componentProcesses,
Map<String, ProcessEntity> processArtifact) {
//backup VSP processes
backupProcess(vspId, activeVersion, GENERAL_COMPONENT_ID, GENERAL_COMPONENT_ID,
- componentProcesses,processArtifact);
- Collection<ComponentEntity> componentsCompositionAndQuestionnaire= vendorSoftwareProductDao
+ componentProcesses, processArtifact);
+ Collection<ComponentEntity> componentsCompositionAndQuestionnaire = vendorSoftwareProductDao
.listComponentsCompositionAndQuestionnaire(vspId,
activeVersion);
- componentsCompositionAndQuestionnaire.forEach(componentEntity ->{
- String componentName=componentEntity.getComponentCompositionData().getName();
- componentsQustanniare.put(componentName,componentEntity
+ componentsCompositionAndQuestionnaire.forEach(componentEntity -> {
+ String componentName = componentEntity.getComponentCompositionData().getName();
+ componentsQustanniare.put(componentName, componentEntity
.getQuestionnaireData());
Collection<NicEntity>
- nics=nicDao.list(new NicEntity(vspId, activeVersion,componentEntity.getId(),null));
+ nics = nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
//backup mib
- Collection<MibEntity> componentMIB = mibDao.listArtifacts(new
- MibEntity(vspId, activeVersion, componentEntity.getId(), null));
- if(CollectionUtils.isNotEmpty(componentMIB)){
- componentMIBList.put(componentName,componentMIB);
+ Collection<ComponentMonitoringUploadEntity> componentMib =
+ componentArtifactDao.listArtifacts(new
+ ComponentMonitoringUploadEntity(vspId, activeVersion, componentEntity.getId(),
+ null));
+ if(CollectionUtils.isNotEmpty(componentMib)){
+ componentMibList.put(componentName,componentMib);
}
//backup component processes
backupProcess(vspId, activeVersion, componentEntity.getId(), componentName,
- componentProcesses,processArtifact);
- if(CollectionUtils.isNotEmpty(nics)) {
+ componentProcesses, processArtifact);
+ if (CollectionUtils.isNotEmpty(nics)) {
Map<String, String> nicsQustanniare = new HashMap<>();
nics.forEach(nicEntity -> {
- NicEntity nic = nicDao.get(new NicEntity(vspId, activeVersion, componentEntity.getId(),
- nicEntity.getId()));
- NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId,activeVersion,
- componentEntity.getId(),nicEntity.getId());
+ NicEntity nic = nicDao.get(new NicEntity(vspId, activeVersion, componentEntity.getId(),
+ nicEntity.getId()));
+ NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, activeVersion,
+ componentEntity.getId(), nicEntity.getId());
nicsQustanniare
- .put(nicEntity.getNicCompositionData().getName(), nicQuestionnaire.getQuestionnaireData());
+ .put(nicEntity.getNicCompositionData().getName(),
+ nicQuestionnaire.getQuestionnaireData());
});
componentNicsQustanniare.put(componentName, nicsQustanniare);
}
@@ -456,17 +488,18 @@ public class OrchestrationTemplateCandidateManagerImpl
private void backupProcess(String vspId, Version activeVersion, String componentId,
String componentName, Map<String,
- Collection<ProcessEntity>> processes,
- Map<String,ProcessEntity> processArtifact){
+ Collection<ProcessEntity>> processes,
+ Map<String, ProcessEntity> processArtifact) {
Collection<ProcessEntity> processList = vendorSoftwareProductDao.listProcesses(vspId,
activeVersion, componentId);
- if(!processList.isEmpty()){
- processes.put(componentName,processList);
+ if (!processList.isEmpty()) {
+ processes.put(componentName, processList);
processList.forEach(process -> {
//ProcessArtifactEntity artifact = vendorSoftwareProductDao.getProcessArtifact(vspId,
// activeVersion, componentId, process.getId());
- ProcessEntity artifact = processDao.get(new ProcessEntity(vspId,activeVersion,componentId,process.getId()));
- if(artifact.getArtifact()!=null) {
+ ProcessEntity artifact =
+ processDao.get(new ProcessEntity(vspId, activeVersion, componentId, process.getId()));
+ if (artifact.getArtifact() != null) {
processArtifact.put(process.getId(), artifact);
}
});
@@ -474,9 +507,10 @@ public class OrchestrationTemplateCandidateManagerImpl
}
private void restoreProcess(String vspId, Version activeVersion, String componentId,
- String componentName, Map<String, Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact){
- if(processes.containsKey(componentName)) {
+ String componentName,
+ Map<String, Collection<ProcessEntity>> processes,
+ Map<String, ProcessEntity> processArtifact) {
+ if (processes.containsKey(componentName)) {
Collection<ProcessEntity> processList = processes.get(componentName);
processList.forEach(process -> {
//Reatin VFC process
@@ -550,7 +584,7 @@ public class OrchestrationTemplateCandidateManagerImpl
byte[] uploadedFileData) {
FileContentHandler contentMap = null;
try {
- contentMap = CommonUtil.loadUploadFileContent(uploadedFileData);
+ contentMap = CommonUtil.validateAndUploadFileContent(uploadedFileData);
} catch (IOException exception) {
uploadFileResponse.addStructureError(
SdcCommon.UPLOAD_FILE,
@@ -574,7 +608,7 @@ public class OrchestrationTemplateCandidateManagerImpl
return healingParams;
}
- public VspDetails getVspDetails(String vspId, Version version) {
+ private VspDetails getVspDetails(String vspId, Version version) {
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
vspDetails.setValidationData(orchestrationTemplateDataDao.getValidationData(vspId, version));
return vspDetails;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
index 4fa67ff2d3..339e05c16f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
@@ -225,7 +225,7 @@ public class ProcessManagerImpl implements ProcessManager {
vendorSoftwareProductDao.uploadProcessArtifact(vspId, version, componentId, processId, artifact,
artifactFileName);
ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspId, String.valueOf(version.getMajor()+1),
- ActivityType.UPLOAD_ARTIFACT.toString(), user, true, "", "");
+ ActivityType.UPLOAD_MONITORING_FILE.toString(), user, true, "", "");
activityLogManager.addActionLog(activityLogEntity, user);
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
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 995044588c..0b48c334c6 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
@@ -42,6 +42,7 @@ import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -56,8 +57,11 @@ import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
import org.openecomp.sdc.validation.util.ValidationManagerUtil;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
+import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
@@ -65,15 +69,22 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.VendorSoftwareProductNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.CreatePackageForNonFinalVendorSoftwareProductErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DeploymentFlavorErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.FileCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.InformationArtifactCreationErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.OnboardingMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageInvalidErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder;
@@ -82,12 +93,18 @@ import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataMana
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.ComponentValidationResult;
+import org.openecomp.sdc.vendorsoftwareproduct.types.DeploymentFlavorValidationResult;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentQuestionnaireSchemaInput;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
@@ -115,8 +132,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@@ -141,8 +160,29 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private InformationArtifactGenerator informationArtifactGenerator;
private PackageInfoDao packageInfoDao;
private ActivityLogManager activityLogManager;
-
-
+ private DeploymentFlavorDao deploymentFlavorDao;
+ private NicDao nicDao;
+ private ManualVspToscaManager manualVspToscaManager;
+
+ /**
+ * Instantiates a new Vendor software product manager.
+ *
+ * @param versioningManager the versioning manager
+ * @param vendorSoftwareProductDao the vendor software product dao
+ * @param orchestrationTemplateDataDao the orchestration template data dao
+ * @param vspInfoDao the vsp info dao
+ * @param vendorLicenseFacade the vendor license facade
+ * @param serviceModelDao the service model dao
+ * @param enrichedServiceModelDao the enriched service model dao
+ * @param healingManager the healing manager
+ * @param licenseArtifactsService the license artifacts service
+ * @param compositionEntityDataManager the composition entity data manager
+ * @param informationArtifactGenerator the information artifact generator
+ * @param packageInfoDao the package info dao
+ * @param activityLogManager the activity log manager
+ * @param deploymentFlavorDao the deployment flavor dao
+ * @param nicDao the nic dao
+ */
public VendorSoftwareProductManagerImpl(
VersioningManager versioningManager,
VendorSoftwareProductDao vendorSoftwareProductDao,
@@ -155,7 +195,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
VendorLicenseArtifactsService licenseArtifactsService,
InformationArtifactGenerator informationArtifactGenerator,
PackageInfoDao packageInfoDao,
- ActivityLogManager activityLogManager) {
+ ActivityLogManager activityLogManager,
+ DeploymentFlavorDao deploymentFlavorDao,
+ NicDao nicDao,
+ ManualVspToscaManager manualVspToscaManager) {
this.versioningManager = versioningManager;
this.vendorSoftwareProductDao = vendorSoftwareProductDao;
this.orchestrationTemplateDao = orchestrationTemplateDataDao;
@@ -168,6 +211,9 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
this.informationArtifactGenerator = informationArtifactGenerator;
this.packageInfoDao = packageInfoDao;
this.activityLogManager = activityLogManager;
+ this.deploymentFlavorDao = deploymentFlavorDao;
+ this.nicDao = nicDao;
+ this.manualVspToscaManager = manualVspToscaManager;
registerToVersioning();
}
@@ -276,8 +322,20 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
validationResponse
.setUploadDataErrors(validateUploadData(uploadData), LoggerServiceName.Submit_VSP,
LoggerTragetServiceName.SUBMIT_VSP);
+
validationResponse.setQuestionnaireValidationResult(
- validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion()));
+ validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(), vspDetails
+ .getOnboardingMethod()));
+
+ if (vspDetails.getOnboardingMethod().equals("Manual")) {
+ validationResponse.setDeploymentFlavorValidationResult(
+ deploymentFlavorValidation(vspDetails.getId(), vspDetails.getVersion()));
+ validationResponse.setComponentValidationResult(
+ componentValidation(vspDetails.getId(), vspDetails.getVersion()));
+ //Generate Tosca service model for Manual Onboarding flow
+ VspModelInfo vspModelInfo = manualVspToscaManager.gatherVspInformation(vspId, version, user);
+ serviceModel = manualVspToscaManager.generateToscaModel(vspModelInfo);
+ }
validationResponse.setCompilationErrors(
compile(vspId, vspDetails.getVersion(), serviceModel),
@@ -294,7 +352,6 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
-
return validationResponse;
}
@@ -310,43 +367,199 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return dependencyTracker.isCyclicDependencyPresent();
}
- private static List<ErrorCode> validateCompletedVendorSoftwareProduct(
+ private DeploymentFlavorValidationResult deploymentFlavorValidation(String vspId,
+ Version version) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ Set<CompositionEntityValidationData> validationData = new HashSet<>();
+ Collection<DeploymentFlavorEntity> deploymentFlavors =
+ vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
+ if (!CollectionUtils.isEmpty(deploymentFlavors)) {
+ deploymentFlavors.forEach(deploymentFlavor -> {
+ DeploymentFlavorEntity deployment = vendorSoftwareProductDao.getDeploymentFlavor(vspId,
+ version, deploymentFlavor.getId());
+ DeploymentFlavor deploymentlocalFlavor = deployment.getDeploymentFlavorCompositionData();
+ if (deploymentlocalFlavor != null) {
+ if (deploymentlocalFlavor.getFeatureGroupId() == null ) {
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder.
+ getFeatureGroupMandatoryErrorBuilder();
+ CompositionEntityValidationData compositionEntityValidationData = new
+ CompositionEntityValidationData(CompositionEntityType.deployment,
+ deploymentFlavor.getId());
+ compositionEntityValidationData.setEntityName(deploymentlocalFlavor.getModel());
+ List<String> errors = new ArrayList<>();
+ errors.add(deploymentFlavorErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ }
+ List<ComponentComputeAssociation> componetComputeAssociations = new ArrayList<>();
+ componetComputeAssociations = deploymentlocalFlavor.getComponentComputeAssociations();
+ if (CollectionUtils.isEmpty(componetComputeAssociations)) {
+ CompositionEntityValidationData compositionEntityValidationData = new
+ CompositionEntityValidationData(CompositionEntityType.deployment,deploymentFlavor
+ .getId());
+ compositionEntityValidationData.setEntityName(deployment
+ .getDeploymentFlavorCompositionData().getModel());
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getInvalidComponentComputeAssociationErrorBuilder();
+ List<String> errors = new ArrayList<>();
+ errors.add(deploymentFlavorErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ } else {
+ componetComputeAssociations.forEach(componetComputeAssociation -> {
+ if (componetComputeAssociation == null
+ || !(componetComputeAssociation.getComponentId() != null
+ && componetComputeAssociation.getComputeFlavorId() != null)) {
+ CompositionEntityValidationData compositionEntityValidationData = new
+ CompositionEntityValidationData(CompositionEntityType.deployment,
+ deploymentFlavor.getId());
+ compositionEntityValidationData.setEntityName(deployment
+ .getDeploymentFlavorCompositionData().getModel());
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getInvalidComponentComputeAssociationErrorBuilder();
+ List<String> errors = new ArrayList<>();
+ errors.add(deploymentFlavorErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ }
+ });
+ }
+ }
+ });
+ }
+ if (CollectionUtils.isEmpty(validationData)) {
+ return null;
+ }
+ DeploymentFlavorValidationResult deploymentFlavorValidationResult = new
+ DeploymentFlavorValidationResult(validationData);
+ return deploymentFlavorValidationResult;
+
+ }
+
+ private ComponentValidationResult componentValidation(String vspId, Version version) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ Set<CompositionEntityValidationData> validationData = new HashSet<>();
+ Collection<ComponentEntity> components = vendorSoftwareProductDao.listComponents(vspId,version);
+ if (!CollectionUtils.isEmpty(components)) {
+ components.forEach(component -> {
+ validateImage(vspId, version, validationData, component);
+ validateNic(vspId, version, validationData, component);
+
+ });
+ }
+ if (CollectionUtils.isEmpty(validationData)) {
+ return null;
+ }
+ ComponentValidationResult componentValidationResult =
+ new ComponentValidationResult(validationData);
+ return componentValidationResult;
+ }
+
+ private void validateNic(String vspId, Version version,
+ Set<CompositionEntityValidationData> validationData,
+ ComponentEntity component) {
+ Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId,version, component.getId(),null));
+ if (CollectionUtils.isNotEmpty(nics)) {
+ nics.forEach(nicEntity -> {
+ NicEntity nic = nicDao.get(new NicEntity(vspId, version, component.getId(),
+ nicEntity.getId()));
+ NetworkType networkType = nic.getNicCompositionData().getNetworkType();
+ String networkId = nic.getNicCompositionData().getNetworkId();
+ if (networkType.equals(NetworkType.Internal) && networkId == null) {
+ CompositionEntityValidationData compositionEntityValidationData = new
+ CompositionEntityValidationData(CompositionEntityType.nic, nic.getId());
+ compositionEntityValidationData.setEntityName(nic.getNicCompositionData().getName());
+ ErrorCode nicInternalNetworkErrorBuilder = NicInternalNetworkErrorBuilder
+ .getNicNullNetworkIdInternalNetworkIdErrorBuilder();
+ List<String> errors = new ArrayList<>();
+ errors.add(nicInternalNetworkErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ }
+ });
+ }
+ }
+
+ private void validateImage(String vspId, Version version,
+ Set<CompositionEntityValidationData> validationData,
+ ComponentEntity component) {
+ Collection<ImageEntity> images = vendorSoftwareProductDao.listImages(vspId,version,
+ component.getId());
+ if (CollectionUtils.isEmpty(images)) {
+ CompositionEntityValidationData compositionEntityValidationData = new
+ CompositionEntityValidationData(component.getType(),component.getId());
+ compositionEntityValidationData.setEntityName(component.getComponentCompositionData()
+ .getDisplayName());
+ ErrorCode vfcMissingImageErrorBuilder =
+ ComponentErrorBuilder.VfcMissingImageErrorBuilder();
+ List<String> errors = new ArrayList<>();
+ errors.add(vfcMissingImageErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ }
+ }
+
+
+
+ private List<ErrorCode> validateCompletedVendorSoftwareProduct(
VspDetails vspDetails, UploadDataEntity uploadData, Object serviceModel) {
- List<ErrorCode> errros = new ArrayList<>();
+ List<ErrorCode> errors = new ArrayList<>();
if (vspDetails.getName() == null) {
- errros.add(createMissingMandatoryFieldError("name"));
+ errors.add(createMissingMandatoryFieldError("name"));
}
if (vspDetails.getDescription() == null) {
- errros.add(createMissingMandatoryFieldError("description"));
+ errors.add(createMissingMandatoryFieldError("description"));
}
if (vspDetails.getVendorId() == null) {
- errros.add(createMissingMandatoryFieldError("vendor Id"));
- }
- if (vspDetails.getVlmVersion() == null) {
- errros.add(createMissingMandatoryFieldError(
- "licensing version (in the format of: {integer}.{integer})"));
+ errors.add(createMissingMandatoryFieldError("vendor Id"));
}
if (vspDetails.getCategory() == null) {
- errros.add(createMissingMandatoryFieldError("category"));
+ errors.add(createMissingMandatoryFieldError("category"));
}
if (vspDetails.getSubCategory() == null) {
- errros.add(createMissingMandatoryFieldError("sub category"));
+ errors.add(createMissingMandatoryFieldError("sub category"));
+ }
+ if (vspDetails.getOnboardingMethod().equals("Manual")) {
+ //Manual Onboarding specific validations
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities = vendorSoftwareProductDao
+ .listDeploymentFlavors(vspDetails.getId(), vspDetails.getVersion());
+ if (CollectionUtils.isEmpty(deploymentFlavorEntities) ) {
+ ErrorCode vspMissingDeploymentFlavorErrorBuilder =
+ VendorSoftwareProductInvalidErrorBuilder.VspMissingDeploymentFlavorErrorBuilder();
+ errors.add(vspMissingDeploymentFlavorErrorBuilder);
+ }
+ errors.addAll(validateMandatoryLicenseFields(vspDetails));
+ } else {
+ //Heat flow specific VSP validations
+ if (uploadData == null || uploadData.getContentData() == null || serviceModel == null) {
+ errors.add(VendorSoftwareProductInvalidErrorBuilder
+ .VendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
+ vspDetails.getVersion()));
+ }
+ if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null
+ || vspDetails.getFeatureGroups() != null) {
+ errors.addAll(validateMandatoryLicenseFields(vspDetails));
+ }
+ }
+ return errors.isEmpty() ? null : errors;
+ }
+
+ private List<ErrorCode> validateMandatoryLicenseFields(VspDetails vspDetails) {
+ List<ErrorCode> errors = new ArrayList<>();
+ if (vspDetails.getVlmVersion() == null) {
+ errors.add(createMissingMandatoryFieldError(
+ "licensing version (in the format of: {integer}.{integer})"));
}
if (vspDetails.getLicenseAgreement() == null) {
- errros.add(createMissingMandatoryFieldError("license agreement"));
+ errors.add(createMissingMandatoryFieldError("license agreement"));
}
if (CollectionUtils.isEmpty(vspDetails.getFeatureGroups())) {
- errros.add(createMissingMandatoryFieldError("feature groups"));
- }
- if (uploadData == null || uploadData.getContentData() == null || serviceModel == null) {
- errros.add(
- new VendorSoftwareProductInvalidErrorBuilder(vspDetails.getId(), vspDetails.getVersion())
- .build());
+ errors.add(createMissingMandatoryFieldError("feature groups"));
}
-
- return errros.isEmpty() ? null : errros;
+ return errors;
}
private static ErrorCode createMissingMandatoryFieldError(String fieldName) {
@@ -498,6 +711,20 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
mdcDataDebugMessage.debugEntryMessage("VSP id", vspDetails.getId());
VspDetails retrieved = vspInfoDao.get(vspDetails);
+ if (!retrieved.getOnboardingMethod().equals(vspDetails.getOnboardingMethod())) {
+ final ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder
+ .getOnboardingUpdateError();
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_VSP, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), onboardingMethodUpdateErrorCode.message());
+
+ throw new CoreException(onboardingMethodUpdateErrorCode);
+ }
+
+ //If any existing feature group is removed from VSP which is also associated in DF then
+ //update DF to remove feature group associations.
+ updateDeploymentFlavor(vspDetails, user);
updateUniqueName(retrieved.getName(), vspDetails.getName());
vspDetails.setOldVersion(retrieved.getOldVersion());
@@ -508,6 +735,28 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
}
+ private void updateDeploymentFlavor(VspDetails vspDetails, String user) {
+ final List<String> featureGroups = vspDetails.getFeatureGroups();
+ if (featureGroups != null && !featureGroups.isEmpty() ) {
+ /*final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ listDeploymentFlavors(vspDetails.getId(), vspDetails.getVersion(), user);*/
+
+ final Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao
+ .list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails
+ .getVersion(), null));
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ final String featureGroupId =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData().getFeatureGroupId();
+ if ( !featureGroups.contains(featureGroupId)) {
+ DeploymentFlavor deploymentFlavorCompositionData =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+ deploymentFlavorCompositionData.setFeatureGroupId(null);
+ vendorSoftwareProductDao.updateDeploymentFlavor(deploymentFlavorEntity);
+ }
+ }
+ }
+ }
+
@Override
public VspDetails getVsp(String vspId, Version version, String user) {
@@ -554,9 +803,12 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
Version finalVersion = checkinFinalVersion.calculateNextFinal();
createPackage(vspId, finalVersion, user);
return finalVersion;
- } catch (IOException e) {
- throw new Exception(e.getMessage());
+ } catch (IOException ex) {
+ throw new Exception(ex.getMessage());
}
+ default:
+ //do nothing
+ break;
}
return versionInfo.getActiveVersion();
}
@@ -798,15 +1050,9 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return null;
}
- FileContentHandler fileContentMap = new FileContentHandler();
-
- try {
- fileContentMap =
- CommonUtil.loadUploadFileContent(uploadData.getContentData().array());
- } catch (Exception e){
- ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, e.getMessage());
- validationErrors.put("Upload file", Arrays.asList(errorMessage));
- }
+ FileContentHandler fileContentMap =
+ CommonUtil.validateAndUploadFileContent(uploadData.getContentData().array());
+ //todo - check
ValidationManager validationManager =
ValidationManagerUtil.initValidationManager(fileContentMap);
validationErrors.putAll(validationManager.validate());
@@ -824,7 +1070,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
- private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version) {
+ private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version,
+ String onboardingMethod) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
// The apis of CompositionEntityDataManager used here are stateful!
@@ -854,6 +1101,14 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()),
JsonUtil.json2Object(component.getQuestionnaireData(), Map.class))));
+ Collection<ComputeEntity> computes = vendorSoftwareProductDao.listComputesByVsp(vspId, version);
+ computes.forEach(compute -> compositionEntityDataManager.addEntity(compute, null));
+
+ if ("Manual".equals(onboardingMethod) ) {
+ Collection<ImageEntity> images = vendorSoftwareProductDao.listImagesByVsp(vspId, version);
+ images.forEach(image -> compositionEntityDataManager.addEntity(image, null));
+ }
+
Map<CompositionEntityId, Collection<String>> errorsByEntityId =
compositionEntityDataManager.validateEntitiesQuestionnaire();
if (MapUtils.isNotEmpty(errorsByEntityId)) {
@@ -894,8 +1149,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
OutputStream out = new BufferedOutputStream(new FileOutputStream(infoArtifactFile));
out.write(infoArtifactAsByteBuffer.array());
out.close();
- } catch (IOException e) {
- throw new CoreException(new InformationArtifactCreationErrorBuilder(vspId).build(), e);
+ } catch (IOException ex) {
+ throw new CoreException(new InformationArtifactCreationErrorBuilder(vspId).build(), ex);
}
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
@@ -917,4 +1172,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
oldVspName, newVspName);
}
+
+ @Override
+ public Collection<ComputeEntity> getComputeByVsp(String vspId, Version version,
+ String user) {
+ return vendorSoftwareProductDao.listComputesByVsp(vspId, version);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
index 3751195d6c..44c9d155c6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
@@ -28,11 +28,15 @@ import org.openecomp.sdc.vendorlicense.VendorLicenseArtifactServiceFactory;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.versioning.VersioningManagerFactory;
public class VspManagerFactoryImpl extends VspManagerFactory {
@@ -49,7 +53,10 @@ public class VspManagerFactoryImpl extends VspManagerFactory {
VendorLicenseArtifactServiceFactory.getInstance().createInterface(),
InformationArtifactGeneratorFactory.getInstance().createInterface(),
PackageInfoDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface());
+ ActivityLogManagerFactory.getInstance().createInterface(),
+ DeploymentFlavorDaoFactory.getInstance().createInterface(),
+ NicDaoFactory.getInstance().createInterface(),
+ new ManualVspToscaManagerImpl());
@Override
public VendorSoftwareProductManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java
new file mode 100644
index 0000000000..8fa655138e
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdc.vendorsoftwareproduct.types;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+
+import java.util.Set;
+
+public class ComponentValidationResult {
+ private boolean valid;
+ private Set<CompositionEntityValidationData> validationData;
+
+ public ComponentValidationResult(Set<CompositionEntityValidationData> validationData) {
+ this.validationData = validationData;
+ valid = validationData == null;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public Set<CompositionEntityValidationData> getValidationData() {
+ return validationData;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java
new file mode 100644
index 0000000000..6f02c98012
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java
@@ -0,0 +1,25 @@
+package org.openecomp.sdc.vendorsoftwareproduct.types;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+
+import java.util.Set;
+
+public class DeploymentFlavorValidationResult {
+ private boolean valid;
+ private Set<CompositionEntityValidationData> validationData;
+
+ public DeploymentFlavorValidationResult(Set<CompositionEntityValidationData> validationData){
+ this.validationData = validationData;
+ valid = validationData == null;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public Set<CompositionEntityValidationData> getValidationData() {
+ return validationData;
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java
new file mode 100644
index 0000000000..7306fe948f
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java
@@ -0,0 +1,28 @@
+package org.openecomp.sdc.vendorsoftwareproduct.types;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+
+public class ListComputeResponse {
+
+ private ComputeEntity computeEntity;
+ private boolean associatedWithDeploymentFlavor;
+
+ public boolean isAssociatedWithDeploymentFlavor() {
+ return associatedWithDeploymentFlavor;
+ }
+
+ public void setAssociatedWithDeploymentFlavor(boolean associatedWithDeploymentFlavor) {
+ this.associatedWithDeploymentFlavor = associatedWithDeploymentFlavor;
+ }
+
+ public ComputeEntity getComputeEntity() {
+ return computeEntity;
+ }
+
+ public void setComputeEntity(
+ ComputeEntity computeEntity) {
+ this.computeEntity = computeEntity;
+ }
+
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
index eb03ba62b4..ea5bef13dc 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
@@ -22,10 +22,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.types;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.types.LoggerServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
@@ -41,6 +41,9 @@ public class ValidationResponse {
private Map<String, List<ErrorMessage>> uploadDataErrors;
private Map<String, List<ErrorMessage>> compilationErrors;
private QuestionnaireValidationResult questionnaireValidationResult;
+ private ComponentValidationResult componentValidationResult;
+ private DeploymentFlavorValidationResult deploymentFlavorValidationResult;
+
public boolean isValid() {
return valid;
@@ -67,6 +70,7 @@ public class ValidationResponse {
VendorSoftwareProductUtils.setErrorsIntoLogger(vspErrors, serviceName, targetServiceName);
}
+
public Collection<ErrorCode> getLicensingDataErrors() {
return licensingDataErrors;
}
@@ -145,4 +149,40 @@ public class ValidationResponse {
}
+ public ComponentValidationResult getComponentValidationResult() {
+ return componentValidationResult;
+ }
+
+ /**
+ * Sets Component validation result.
+ *
+ * @param componentValidationResult the Component validation result
+ */
+ public void setComponentValidationResult(
+ ComponentValidationResult componentValidationResult) {
+ this.componentValidationResult = componentValidationResult;
+ if (componentValidationResult != null && !componentValidationResult.isValid()) {
+ valid = false;
+ }
+ }
+
+
+ public DeploymentFlavorValidationResult getDeploymentFlavorValidationResult() {
+ return deploymentFlavorValidationResult;
+ }
+
+ /**
+ * Sets Deployment validation result.
+ *
+ * @param deploymentFlavorValidationResult the Deployment validation result
+ */
+ public void setDeploymentFlavorValidationResult(
+ DeploymentFlavorValidationResult deploymentFlavorValidationResult) {
+ this.deploymentFlavorValidationResult = deploymentFlavorValidationResult;
+ if (deploymentFlavorValidationResult != null && !deploymentFlavorValidationResult.isValid()) {
+ valid = false;
+ }
+ }
+
+
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MibUploadStatus.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java
index 046d53054e..ad604e822e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MibUploadStatus.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java
@@ -20,17 +20,21 @@
package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator;
-public class MibUploadStatus {
+public class MonitoringUploadStatus {
private String snmpTrap;
private String snmpPoll;
+ private String vesEvent;
- public MibUploadStatus(String snmpTrap, String snmpPoll) {
+ //todo 1802 tech debt story : refactor this to be a map of type-filename
+
+
+ public MonitoringUploadStatus(String snmpTrap, String snmpPoll) {
this.snmpTrap = snmpTrap;
this.snmpPoll = snmpPoll;
}
- public MibUploadStatus() {
+ public MonitoringUploadStatus() {
}
public String getSnmpTrap() {
@@ -45,7 +49,17 @@ public class MibUploadStatus {
return snmpPoll;
}
+ public String getVesEvent() {
+ return vesEvent;
+ }
+
+ public void setVesEvent(String vesEvent) {
+ this.vesEvent = vesEvent;
+ }
+
public void setSnmpPoll(String snmpPoll) {
this.snmpPoll = snmpPoll;
+
+
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ManualVspDataCollectionService.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ManualVspDataCollectionService.java
new file mode 100644
index 0000000000..981bfe941a
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ManualVspDataCollectionService.java
@@ -0,0 +1,418 @@
+package org.openecomp.sdc.vendorsoftwareproduct.utils;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.generator.datatypes.tosca.ComputeFlavor;
+import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
+import org.openecomp.sdc.generator.datatypes.tosca.LicenseFlavor;
+import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
+import org.openecomp.sdc.generator.datatypes.tosca.VendorInfo;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager;
+import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.ImageManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ImageManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
+import org.openecomp.sdc.vendorsoftwareproduct.NicManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
+import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute;
+import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.image.ImageDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+
+public class ManualVspDataCollectionService {
+
+ private static final DeploymentFlavorManager deploymentFlavorManager =
+ DeploymentFlavorManagerFactory.getInstance().createInterface();
+ private static final ComputeManager computeManager =
+ ComputeManagerFactory.getInstance().createInterface();
+ private static final ImageManager imageManager =
+ ImageManagerFactory.getInstance().createInterface();
+ private static final ComponentManager componentManager =
+ ComponentManagerFactory.getInstance().createInterface();
+ private static final VendorSoftwareProductManager vendorSoftwareProductManager =
+ VspManagerFactory.getInstance().createInterface();
+ private static final NicManager nicManager =
+ NicManagerFactory.getInstance().createInterface();
+ private static final VendorLicenseFacade vendorLicenseFacade =
+ VendorLicenseFacadeFactory.getInstance().createInterface();
+
+
+ /**
+ * Gets vendor name for the vsp.
+ *
+ * @param vspId the vsp id
+ * @param version the version
+ * @param user the user
+ * @return the release vendor name
+ */
+ public Optional<String> getReleaseVendor(String vspId, Version version, String user) {
+ String vendorName = null;
+ VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version, user);
+ if (Objects.nonNull(vspDetails)) {
+ vendorName = vspDetails.getVendorName();
+ }
+ return Optional.ofNullable(vendorName);
+ }
+
+ /**
+ * Gets the deployment flavor data for manually onboarded VSPs.
+ *
+ * @param vspId the vsp id
+ * @param version the version
+ * @param user the user
+ * @return the allowed flavors
+ */
+ public Map<String, DeploymentFlavorModel> getAllowedFlavors(String vspId, Version version,
+ String user) {
+ Map<String, DeploymentFlavorModel> allowedFlavors = new HashMap<>();
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
+ if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) {
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ DeploymentFlavor deploymentFlavorCompositionData =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+
+ VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version, user);
+ String vspVlmId;
+ Version vlmVersion;
+ if (Objects.nonNull(vspDetails)) {
+ vspVlmId = vspDetails.getVendorId();
+ vlmVersion = vspDetails.getVlmVersion();
+ if (StringUtils.isNotEmpty(vspVlmId)) {
+ DeploymentFlavorModel deploymentFlavorModel = new DeploymentFlavorModel();
+ String featureGroupId = deploymentFlavorCompositionData.getFeatureGroupId();
+ if (Objects.isNull(featureGroupId)) {
+ //No feature group associated with deployment flavor. So excluding this deployment
+ // flavor for Tosca model
+ continue;
+ }
+ //Gather and set License flavor info
+ LicenseFlavor licenseFlavor = getLicenseFlavor(featureGroupId);
+ deploymentFlavorModel.setLicense_flavor(licenseFlavor);
+ //Get sp_part_number
+ Optional<String> partNumber = getPartNumber(vspVlmId, vlmVersion, featureGroupId,
+ user);
+ partNumber.ifPresent(deploymentFlavorModel::setSp_part_number);
+ //Gather and set Vendor Info
+ Optional<VendorInfo> vendorInfo = getVendorInfo(vspVlmId, vlmVersion, featureGroupId,
+ user);
+ vendorInfo.ifPresent(deploymentFlavorModel::setVendor_info);
+ //Gather and set Compute info
+ List<ComponentComputeAssociation> componentComputeAssociations =
+ deploymentFlavorCompositionData.getComponentComputeAssociations();
+ if (CollectionUtils.isNotEmpty(componentComputeAssociations)) {
+ for (ComponentComputeAssociation componentComputeAssociation :
+ componentComputeAssociations) {
+ String componentId = componentComputeAssociation.getComponentId();
+ String computeFlavorId = componentComputeAssociation.getComputeFlavorId();
+ Optional<ComputeFlavor> computeFlavor =
+ getComputeFlavor(vspId, version, componentId, computeFlavorId, user);
+ computeFlavor.ifPresent(deploymentFlavorModel::setCompute_flavor);
+ }
+ }
+ partNumber.ifPresent(spPartNumber -> allowedFlavors.put(spPartNumber,
+ deploymentFlavorModel));
+ }
+ }
+ }
+ }
+ return allowedFlavors;
+ }
+
+ /**
+ * Gets the component image data for manually onboarded VSPs.
+ *
+ * @param vspId the vsp id
+ * @param version the version
+ * @param user the user
+ * @return the vsp component images
+ */
+ public Map<String, List<MultiFlavorVfcImage>> getVspComponentImages(String vspId,
+ Version version,
+ String user) {
+ Map<String, List<MultiFlavorVfcImage>> vspComponentImages = new HashMap<>();
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ DeploymentFlavor deploymentFlavorCompositionData =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+
+ List<ComponentComputeAssociation> componentComputeAssociations =
+ deploymentFlavorCompositionData.getComponentComputeAssociations();
+ if (CollectionUtils.isNotEmpty(componentComputeAssociations)) {
+ for (ComponentComputeAssociation componentComputeAssociation :
+ componentComputeAssociations) {
+ String componentId = componentComputeAssociation.getComponentId();
+ List<MultiFlavorVfcImage> componentImages =
+ getComponentImages(vspId, version, componentId, user);
+ if (CollectionUtils.isNotEmpty(componentImages)) {
+ vspComponentImages.put(componentId, componentImages);
+ }
+ }
+ }
+ }
+ return vspComponentImages;
+ }
+
+ /**
+ * Gets the component data for manually onboarded VSPs.
+ *
+ * @param vspId the vsp id
+ * @param version the version
+ * @param user the user
+ * @return the vsp components
+ */
+ public Map<String, String> getVspComponents(String vspId, Version version, String user) {
+ Map<String, String> componentIdNameMap = new HashMap<>();
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ DeploymentFlavor deploymentFlavorCompositionData =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+
+ List<ComponentComputeAssociation> componentComputeAssociations =
+ deploymentFlavorCompositionData.getComponentComputeAssociations();
+ if (CollectionUtils.isNotEmpty(componentComputeAssociations)) {
+ for (ComponentComputeAssociation componentComputeAssociation :
+ componentComputeAssociations) {
+ String componentId = componentComputeAssociation.getComponentId();
+ Optional<String> componentName = getComponentName(vspId, version, componentId, user);
+ componentName.ifPresent(name -> componentIdNameMap.put(componentId, name));
+ }
+ }
+ }
+ return componentIdNameMap;
+ }
+
+ /**
+ * Gets the NIC data for manually onboarded VSPs.
+ *
+ * @param vspId the vsp id
+ * @param version the version
+ * @param user the user
+ * @return the vsp component nics
+ */
+ public Map<String, List<Nic>> getVspComponentNics(String vspId, Version version, String user) {
+ Map<String, List<Nic>> vspComponentNics = new HashMap<>();
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
+ if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) {
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ DeploymentFlavor deploymentFlavorCompositionData =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+ if (Objects.nonNull(deploymentFlavorCompositionData)) {
+ List<ComponentComputeAssociation> componentComputeAssociations =
+ deploymentFlavorCompositionData.getComponentComputeAssociations();
+ if (CollectionUtils.isNotEmpty(componentComputeAssociations)) {
+ for (ComponentComputeAssociation componentComputeAssociation :
+ componentComputeAssociations) {
+ String componentId = componentComputeAssociation.getComponentId();
+ List<Nic> componentNics = getComponentNics(vspId, version, componentId, user);
+ if (CollectionUtils.isNotEmpty(componentNics)) {
+ vspComponentNics.put(componentId, componentNics);
+ }
+ }
+ }
+ }
+ }
+ }
+ return vspComponentNics;
+ }
+
+ private List<Nic> getComponentNics(String vspId, Version version, String componentId,
+ String user) {
+ List<Nic> componentNics = new ArrayList<>();
+ Collection<NicEntity> nics = nicManager.listNics(vspId, version, componentId, user);
+ if (Objects.nonNull(nics)) {
+ for (NicEntity nicEntity : nics) {
+ String nicId = nicEntity.getId();
+ CompositionEntityResponse<Nic> nicCompositionEntityResponse =
+ nicManager.getNic(vspId, version, componentId, nicId, user);
+ if (Objects.nonNull(nicCompositionEntityResponse)
+ && Objects.nonNull(nicCompositionEntityResponse.getData())) {
+ componentNics.add(nicCompositionEntityResponse.getData());
+ }
+ }
+ }
+ return componentNics;
+ }
+
+ private LicenseFlavor getLicenseFlavor(String featureGroupId) {
+ LicenseFlavor licenseFlavor = new LicenseFlavor();
+ licenseFlavor.setFeature_group_uuid(featureGroupId);
+ return licenseFlavor;
+ }
+
+ private Optional<String> getPartNumber(String vlmId, Version version,
+ String featureGroupId, String user) {
+ FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId, user);
+ if (Objects.nonNull(featureGroup)) {
+ return Optional.ofNullable(featureGroup.getFeatureGroup().getPartNumber());
+ }
+ return Optional.empty();
+ }
+
+ private Optional<VendorInfo> getVendorInfo(String vlmId, Version version,
+ String featureGroupId, String user) {
+ VendorInfo vendorInfo = null;
+ FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId, user);
+ if (Objects.nonNull(featureGroup)) {
+ //Process Feature group to get Manufacturer ref no.
+ String manufacturerReferenceNumber = featureGroup.getEntityManufacturerReferenceNumber();
+ vendorInfo = new VendorInfo();
+ vendorInfo.setVendor_model(vlmId);
+ if (Objects.nonNull(manufacturerReferenceNumber)) {
+ vendorInfo.setManufacturer_reference_number(manufacturerReferenceNumber);
+ }
+ }
+ return Optional.ofNullable(vendorInfo);
+ }
+
+ private Optional<ComputeFlavor> getComputeFlavor(String vspId, Version version,
+ String componentId, String computeFlavorId,
+ String user) {
+ ComputeFlavor computeFlavor = null;
+ QuestionnaireResponse computeQuestionnaire;
+ try {
+ computeQuestionnaire = computeManager.getComputeQuestionnaire(vspId, version, componentId,
+ computeFlavorId, user);
+ } catch (Exception ex) {
+ computeQuestionnaire = null;
+ }
+ if (Objects.nonNull(computeQuestionnaire)) {
+ String computeQuestionnaireData = computeQuestionnaire.getData();
+ if (Objects.nonNull(computeQuestionnaireData)) {
+ Compute compute;
+ try {
+ compute = JsonUtil.json2Object(computeQuestionnaireData, Compute.class);
+ } catch (Exception ex) {
+ compute = null;
+ }
+ if (Objects.nonNull(compute.getVmSizing())) {
+ computeFlavor = new ComputeFlavor();
+ if (Objects.nonNull(compute.getVmSizing().getNumOfCPUs())) {
+ computeFlavor.setNum_cpus(compute.getVmSizing().getNumOfCPUs());
+ }
+ if (Objects.nonNull(compute.getVmSizing().getFileSystemSizeGB())) {
+ computeFlavor.setDisk_size(compute.getVmSizing().getFileSystemSizeGB() + "GB");
+ }
+ if (Objects.nonNull(compute.getVmSizing().getMemoryRAM())) {
+ computeFlavor.setMem_size(compute.getVmSizing().getMemoryRAM() + "GB");
+ }
+ }
+ }
+ }
+ return Optional.ofNullable(computeFlavor);
+ }
+
+ private FeatureGroupModel getFeatureGroup(String vlmId, Version version, String featureGroupId,
+ String user) {
+ FeatureGroupEntity fgInput = new FeatureGroupEntity();
+ fgInput.setVendorLicenseModelId(vlmId);
+ fgInput.setVersion(version);
+ fgInput.setId(featureGroupId);
+ return vendorLicenseFacade.getFeatureGroupModel(fgInput, user);
+ }
+
+ private Optional<String> getComponentName(String vspId, Version version, String componentId,
+ String user) {
+ CompositionEntityResponse<ComponentData> component =
+ componentManager.getComponent(vspId, version, componentId, user);
+ if (Objects.nonNull(component.getData())) {
+ return Optional.ofNullable(component.getData().getDisplayName());
+ }
+ return Optional.empty();
+ }
+
+ private List<MultiFlavorVfcImage> getComponentImages(String vspId, Version version,
+ String componentId, String user) {
+ List<MultiFlavorVfcImage> componentImages = new ArrayList<>();
+ MultiFlavorVfcImage multiFlavorVfcImage = null;
+ Collection<ImageEntity> imageEntities =
+ imageManager.listImages(vspId, version, componentId, user);
+ if (Objects.nonNull(imageEntities)) {
+ for (ImageEntity imageEntity : imageEntities) {
+ String imageId = imageEntity.getId();
+ QuestionnaireResponse imageQuestionnaire =
+ imageManager.getImageQuestionnaire(vspId, version, componentId, imageId, user);
+ CompositionEntityResponse<Image> imageCompositionData =
+ imageManager.getImage(vspId, version, componentId, imageId, user);
+ if (Objects.nonNull(imageQuestionnaire)
+ && Objects.nonNull(imageQuestionnaire.getData())
+ && Objects.nonNull(imageCompositionData)) {
+ ImageDetails imageDetails;
+ try {
+ imageDetails = JsonUtil.json2Object(imageQuestionnaire.getData(),
+ ImageDetails.class);
+ } catch (Exception ex) {
+ imageDetails = null;
+ }
+ if (Objects.nonNull(imageDetails)
+ && Objects.nonNull(imageDetails.getVersion())) {
+ //Image version is used as a key for the image block
+ //So excluding the population if questionnaire data is absent or invalid
+ multiFlavorVfcImage = new MultiFlavorVfcImage();
+ Image image = imageCompositionData.getData();
+ Optional<String> toscaImageFileName = getToscaImageFileName(image, imageDetails);
+ toscaImageFileName.ifPresent(multiFlavorVfcImage::setFile_name);
+ multiFlavorVfcImage.setSoftware_version(imageDetails.getVersion());
+ if (Objects.nonNull(imageDetails.getMd5())) {
+ multiFlavorVfcImage.setFile_hash(imageDetails.getMd5());
+ }
+ multiFlavorVfcImage.setFile_hash_type("md5");
+ componentImages.add(multiFlavorVfcImage);
+ }
+ }
+ }
+ }
+ return componentImages;
+ }
+
+ private Optional<String> getToscaImageFileName(Image image, ImageDetails imageDetails) {
+ String toscaImageFileName = null;
+ StringBuilder builder = new StringBuilder();
+ if (Objects.nonNull(image.getFileName())) {
+ builder.append(image.getFileName());
+ builder.append("-");
+ builder.append(imageDetails.getVersion());
+ if (Objects.nonNull(imageDetails.getFormat())) {
+ builder.append(".");
+ builder.append(imageDetails.getFormat());
+ }
+ }
+ toscaImageFileName = builder.toString();
+ if (toscaImageFileName.isEmpty()) {
+ return Optional.empty();
+ }
+ return Optional.ofNullable(toscaImageFileName);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
index 3e7e83d3ba..08528408d6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
@@ -22,7 +22,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.utils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.enrichment.types.ArtifactType;
+import org.openecomp.core.enrichment.types.MonitoringUploadType;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.Messages;
@@ -35,7 +35,7 @@ import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerServiceName;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.slf4j.MDC;
@@ -47,6 +47,8 @@ import java.util.List;
import java.util.Map;
public class VendorSoftwareProductUtils {
+
+ private static final String MANUAL = "Manual";
protected static Logger logger =
(Logger) LoggerFactory.getLogger(VendorSoftwareProductUtils.class);
@@ -92,12 +94,7 @@ public class VendorSoftwareProductUtils {
public static void validateContentZipData(FileContentHandler contentMap,
Map<String, List<ErrorMessage>> errors) {
MDC.put(LoggerConstants.ERROR_DESCRIPTION, LoggerErrorDescription.INVALID_ZIP);
- if (contentMap == null) {
- ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors).add(
- new ErrorMessage(ErrorLevel.ERROR,
- Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage()));
-
- } else if (contentMap.getFileList().size() == 0) {
+ if (contentMap.getFileList().size() == 0) {
ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
.add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
}
@@ -105,27 +102,26 @@ public class VendorSoftwareProductUtils {
/**
- * Filter non trap or poll artifacts map.
+ * Maps all artifacts by type.
*
* @param artifacts the artifacts
* @return the map
*/
- public static Map<ArtifactType, String> filterNonTrapOrPollArtifacts(
- Collection<MibEntity> artifacts) {
- Map<ArtifactType, String> artifactTypeToFilename = new HashMap<>();
+ public static Map<MonitoringUploadType, String> mapArtifactsByType(
+ Collection<ComponentMonitoringUploadEntity> artifacts) {
+ Map<MonitoringUploadType, String> artifactTypeToFilename = new HashMap<>();
- for (MibEntity entity : artifacts) {
- if (isTrapOrPoll(entity.getType())) {
- artifactTypeToFilename.put(entity.getType(), entity.getArtifactName());
- }
+ for (ComponentMonitoringUploadEntity entity : artifacts) {
+ artifactTypeToFilename.put(entity.getType(), entity.getArtifactName());
}
return artifactTypeToFilename;
}
- private static boolean isTrapOrPoll(ArtifactType type) {
- return type.equals(ArtifactType.SNMP_POLL) || type.equals(ArtifactType.SNMP_TRAP);
+ private static boolean isTrapOrPoll(MonitoringUploadType type) {
+ return type.equals(MonitoringUploadType.SNMP_POLL) ||
+ type.equals(MonitoringUploadType.SNMP_TRAP);
}
@@ -178,4 +174,13 @@ public class VendorSoftwareProductUtils {
}
}
+ /*public static boolean isManual(String vspId, Version version, VendorSoftwareProductInfoDao
+ vspInfoDao) {
+ String onboardingMethod = vspInfoDao.get(new VspDetails(vspId, version)).getOnboardingMethod();
+ if (MANUAL.equals(onboardingMethod)) {
+ return true;
+ }
+ return false;
+ }*/
+
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json
index f736c8f115..71d42932d9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json
@@ -5,7 +5,10 @@
"org.openecomp.sdc.vendorsoftwareproduct.NicManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.NicManagerFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.OrchestrationTemplateCandidateManagerFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.ProcessManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.ProcessManagerFactoryImpl",
- "org.openecomp.sdc.vendorsoftwareproduct.MibManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.MibManagerFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.MonitoringUploadsManagerFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.ComponentDependencyModelManagerFactoryImpl",
- "org.openecomp.sdc.vendorsoftwareproduct.factories.VspServiceFactory": "org.openecomp.sdc.vendorsoftwareproduct.factories.impl.VspServiceFactoryImpl"
+ "org.openecomp.sdc.vendorsoftwareproduct.factories.VspServiceFactory": "org.openecomp.sdc.vendorsoftwareproduct.factories.impl.VspServiceFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.ComputeManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.ComputeManagerFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.DeploymentFlavorManagerFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.ImageManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.ImageManagerFactoryImpl"
} \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java
new file mode 100644
index 0000000000..ab7a70b6a7
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java
@@ -0,0 +1,293 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED;
+
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class ComputeTest {
+
+ /*private static final String USER1 = "componentsTestUser1";
+ private static final String USER2 = "componentsTestUser2";
+ private static final Version VERSION01 = new Version(0, 1);
+ private static final VendorSoftwareProductManager vendorSoftwareProductManager =
+ new VendorSoftwareProductManagerImpl();
+ private static final VendorSoftwareProductDao vendorSoftwareProductDao =
+ VendorSoftwareProductDaoFactory
+ .getInstance().createInterface();
+
+ private static String vsp1Id;
+ private static String vsp2Id;
+ private static String comp1 = "{\"displayName\": \"VFC_Manual\", " +
+ "\"description\": \"desc manual\"}";
+ private static String compute1 = "{\"name\": \"Compute_A\", " +
+ "\"description\": \"desc manual compute\"}";
+ private static String computeDelete = "{\"name\": \"Compute_Delete\", " +
+ "\"description\": \"desc manual compute delete\"}";
+
+ private static String comp1Id;
+ private static String compute1Id;
+ private ComputeEntity createdCompute;
+
+ static ComponentEntity createComponent(String vspId, Version version, String compId) {
+ ComponentEntity componentEntity = new ComponentEntity(vspId, version, compId);
+ ComponentData compData = new ComponentData();
+ compData.setName(compId + " name");
+ compData.setDisplayName(compId + " display name");
+ compData.setDescription(compId + " desc");
+ componentEntity.setComponentCompositionData(compData);
+ vendorSoftwareProductDao.createComponent(componentEntity);
+ return componentEntity;
+ }
+
+ static ComputeEntity createComputeEntity(String vspId, String componentId, String data ){
+ ComputeEntity comp = new ComputeEntity();
+ comp.setVspId(vspId);
+ comp.setComponentId(componentId);
+ comp.setCompositionData(data);
+ return comp;
+ }
+
+ @BeforeClass
+ private void init() {
+ VspDetails
+ vsp1 = vendorSoftwareProductManager.createNewVsp(VSPCommon
+ .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp1", "vendorName",
+ "vlm1Id", "icon", "category", "subCategory", "123", null,
+ VSPCommon.OnboardingMethod.HEAT.name()), USER1
+ );
+ vsp1Id = vsp1.getId(); //HEAT onboarded
+
+ VspDetails vsp2 = vendorSoftwareProductManager.createNewVsp(VSPCommon
+ .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp3",
+ "vendorName",
+ "vlm1Id", "icon", "category", "subCategory", "123", null, VSPCommon
+ .OnboardingMethod.Manual.name()), USER1);
+ vsp2Id = vsp2.getId(); //MANUAL onboarded
+
+ ComponentEntity component = new ComponentEntity();
+ component.setVspId(vsp2Id);
+ component.setCompositionData(comp1);
+ ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(component, USER1);
+ comp1Id = createdComp.getId();
+ }
+
+ @Test
+ public void testListWhenNone() {
+
+ final Collection<ListComputeResponse> listComputeResponses =
+ vendorSoftwareProductManager.listCompute(vsp2Id, null, comp1Id, USER1);
+ Assert.assertEquals(listComputeResponses.size(), 0);
+ }
+
+ @Test
+ public void testCreateComputeInHeatOnboardedVsp_negative() {
+ ComputeEntity comp = createComputeEntity(vsp1Id,comp1Id,compute1);
+ try {
+ createdCompute = vendorSoftwareProductManager.createCompute(comp, USER1);
+ Assert.fail();
+ }
+ catch(CoreException exception){
+ Assert.assertEquals(exception.code().id(),ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ }
+ }
+
+ @Test(dependsOnMethods = "testListWhenNone")
+ public void testCreateCompute() {
+ ComputeEntity comp = createComputeEntity(vsp2Id,comp1Id,compute1);
+
+ createdCompute = vendorSoftwareProductManager.createCompute(comp, USER1);
+ compute1Id = createdCompute.getId();
+ Assert.assertNotNull(compute1Id);
+ Assert.assertNotNull(createdCompute.getCompositionData());
+ Assert.assertNotNull(
+ vendorSoftwareProductManager.getCompute(vsp2Id, VERSION01, comp1Id,compute1Id,
+ USER1).getData());
+ }
+
+ @Test(dependsOnMethods = "testCreateCompute")
+ public void testCreateComputeNegative() {
+ ComputeEntity comp = createComputeEntity(vsp2Id,comp1Id,compute1);
+
+ try {
+ ComputeEntity createdCompute = vendorSoftwareProductManager.createCompute(comp, USER1);
+ Assert.fail();
+ }
+ catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(),DUPLICATE_COMPUTE_NAME_NOT_ALLOWED);
+ }
+ }
+
+ @Test
+ public void testGetNonExistingComponentId_negative() {
+ testGet_negative(vsp1Id, null, "non existing component id", compute1Id, USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testGetNonExistingVspId_negative() {
+ testGet_negative("non existing vsp id", null, comp1Id, compute1Id, USER1,
+ VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST);
+ }
+
+ @Test
+ public void testGetNonExistingComputeId_negative() {
+ testGet_negative(vsp1Id, null, comp1Id, "non existing compute id", USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test(dependsOnMethods = "testCreateCompute")
+ public void testGetCompute() {
+ testGet(vsp2Id, VERSION01, comp1Id, compute1Id, USER1, createdCompute);
+ }
+
+
+ @Test(dependsOnMethods = "testCreateCompute")
+ public void testListCompute() {
+
+ final Collection<ListComputeResponse> actual =
+ vendorSoftwareProductManager.listCompute(vsp2Id, null, comp1Id, USER1);
+ Assert.assertEquals(actual.size(), 1);
+ actual.forEach(listComputeResponse -> {
+ Assert.assertEquals(listComputeResponse.isAssociatedWithDeploymentFlavor(), false);
+ } );
+ }
+
+
+ @Test(dependsOnMethods = "testListCompute")
+ public void testListComputeAssociatedWithDeployment() {
+
+ //Create DF and associate compute1Id CF to it
+ String deployment1Id = null;
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vsp2Id,
+ VERSION01, deployment1Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("DF_testListComputeAssociatedWithDeployment");
+ deploymentFlavor.setDescription("creating a deployment flavor with compute flavor association");
+ ComponentComputeAssociation association = new ComponentComputeAssociation();
+ association.setComponentId(comp1Id);
+ association.setComputeFlavorId(compute1Id);
+ List<ComponentComputeAssociation> associations = new ArrayList<ComponentComputeAssociation>();
+ associations.add(association);
+ deploymentFlavor.setComponentComputeAssociations(associations);
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+
+ DeploymentFlavorEntity createddeployment = vendorSoftwareProductManager.createDeploymentFlavor
+ (deploymentFlavorEntity, USER1);
+ Assert.assertEquals((createddeployment.getId() != null), true);
+ deployment1Id = createddeployment.getId();
+
+ final Collection<ListComputeResponse> actual =
+ vendorSoftwareProductManager.listCompute(vsp2Id, null, comp1Id, USER1);
+ Assert.assertEquals(actual.size(), 1);
+ actual.forEach(listComputeResponse -> {
+ Assert.assertEquals(listComputeResponse.isAssociatedWithDeploymentFlavor(), true);
+ } );
+ }
+
+ @Test
+ public void testUpdateNonExistingComponentId_negative() {
+ testUpdate_negative(vsp1Id, "non existing component id", USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testUpdateNonExistingVspId_negative() {
+ testUpdate_negative("non existing vsp id", comp1Id, USER1,
+ VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST);
+ }
+
+ @Test
+ public void testDelete() {
+ ComputeEntity comp = createComputeEntity(vsp2Id,comp1Id,computeDelete);
+
+ ComputeEntity created = vendorSoftwareProductManager.createCompute(comp, USER1);
+
+ vendorSoftwareProductManager.deleteCompute(vsp2Id,comp1Id,created.getId(),USER1);
+ testGet_negative(vsp2Id,null, comp1Id, created.getId(),USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testDeleteNonExistingComputeId_negative() {
+ testDelete_negative(vsp2Id,comp1Id,"InvalidComputeId",USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testDeleteNonExistingComponentId_negative() {
+ testDelete_negative(vsp2Id,"InvalidComponentId",compute1Id,USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testDeleteNonExistingVspId_negative() {
+ testDelete_negative("InvalidVspId",comp1Id,compute1Id,USER1,
+ VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST);
+ }
+
+ private void testGet(String vspId, Version version, String componentId, String computeId, String
+ user, ComputeEntity expected) {
+ CompositionEntityResponse<ComputeData>
+ response = vendorSoftwareProductManager.getCompute(vspId, null, componentId, computeId,
+ user);
+ Assert.assertEquals(response.getId(), expected.getId());
+ Assert.assertEquals(response.getData(), expected.getComputeCompositionData());
+ Assert.assertNotNull(response.getSchema());
+ }
+
+ private void testGet_negative(String vspId, Version version, String componentId, String computeId,
+ String user, String expectedErrorCode) {
+ try {
+ vendorSoftwareProductManager.getCompute(vspId, version, componentId, computeId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private void testDelete_negative(String vspId, String componentId, String computeId, String user,
+ String expectedErrorCode){
+ try {
+ vendorSoftwareProductManager.deleteCompute(vspId, componentId, computeId, user);
+ Assert.fail();
+ }
+ catch(CoreException exception){
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private void testUpdate_negative(String vspId, String componentId, String user,
+ String expectedErrorCode) {
+ try {
+ vendorSoftwareProductManager
+ .updateComponent(new ComponentEntity(vspId, null, componentId), user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }*/
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java
new file mode 100644
index 0000000000..e3fa0a8480
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java
@@ -0,0 +1,432 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID;
+import static org.openecomp.sdc.versioning.errors.VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST;
+import static org.openecomp.sdc.versioning.errors.VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND;
+
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl;
+import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class DeploymentFlavorTest {
+ /*private static final String USER1 = "deploymentTestUser1";
+ private static final String USER2 = "deploymentTestUser2";
+ private static final Version VERSION01 = new Version(0, 1);
+ private static final VendorSoftwareProductManager vendorSoftwareProductManager =
+ new VendorSoftwareProductManagerImpl();
+ private static final VendorSoftwareProductDao vendorSoftwareProductDao =
+ VendorSoftwareProductDaoFactory.getInstance().createInterface();
+
+ private static String vsp1Id;
+ private static String vsp2Id;
+ private static String vsp3Id;
+ private static String component11Id;
+ private static String component21Id;
+ private static String deployment1Id = "deployment1";
+ private static String deployment2Id = "deployment2";
+
+ @BeforeClass
+ private void init() {
+ List<String> featureGroups = new ArrayList<>();
+ featureGroups.add("fg01");
+ featureGroups.add("fg02");
+ vsp1Id = vendorSoftwareProductManager.createNewVsp(VSPCommon
+ .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp1", "vendorName1",
+ "vlm1Id", "icon", "category", "subCategory", "123", featureGroups,
+ VSPCommon.OnboardingMethod.
+ Manual.name()), USER1).getId();
+ component11Id = ComponentsTest.createComponent(vsp1Id, VERSION01, "component11").getId();
+
+ vsp2Id = vendorSoftwareProductManager.createNewVsp(VSPCommon
+ .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp2", "vendorName1",
+ "vlm1Id", "icon", "category", "subCategory", "123", null,
+ VSPCommon.OnboardingMethod.Manual.name()), USER1).getId();
+ component21Id = ComponentsTest.createComponent(vsp2Id, VERSION01, "component21").getId();
+
+ vsp3Id = vendorSoftwareProductManager.createNewVsp(VSPCommon
+ .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp3forDeployment",
+ "vendorName1",
+ "vlm1Id", "icon", "category", "subCategory", "123", null,
+ VSPCommon.OnboardingMethod.HEAT.name()), USER1).getId();
+ }
+
+ static DeploymentFlavorEntity createDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel(deploymentFlavorId + " name");
+ deploymentFlavor.setDescription(deploymentFlavorId + " desc");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ DeploymentFlavorEntity createdDeployment = vendorSoftwareProductManager
+ .createDeploymentFlavor(deploymentFlavorEntity, USER1);
+ deployment2Id = createdDeployment.getId();
+ return deploymentFlavorEntity;
+ }
+
+ @Test
+ public void testCreate() {
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("TestDeploymentcreatewithoutFG");
+ deploymentFlavor.setDescription("creating a deployment flavor without any FG and any " +
+ "association");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ DeploymentFlavorEntity createddeployment = vendorSoftwareProductManager.createDeploymentFlavor
+ (deploymentFlavorEntity, USER1);
+ Assert.assertEquals((createddeployment.getId() != null), true);
+ deployment1Id = createddeployment.getId();
+ }
+
+ @Test(dependsOnMethods = "testCreate")
+ public void testUniqueModelCreate() {
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("TestDeploymentcreatewithoutFG");
+ deploymentFlavor.setDescription("creating a deployment flavor without any FG and any " +
+ "association");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ try {
+ vendorSoftwareProductManager.createDeploymentFlavor
+ (deploymentFlavorEntity, USER1);
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED);
+ }
+ }
+
+ @Test
+ public void testInvalidFeatureGroup() {
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("TestInvalidFeatureGroup");
+ deploymentFlavor.setDescription("creating a deployment flavor with invalid FG and without any" +
+ " " +
+ "association");
+ deploymentFlavor.setFeatureGroupId("fg01");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ try {
+ vendorSoftwareProductManager.createDeploymentFlavor
+ (deploymentFlavorEntity, USER1);
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), FEATURE_GROUP_NOT_EXIST_FOR_VSP);
+ }
+ }
+
+ @Test
+ public void testInvalidAssociation() {
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("testInvalidAssociation");
+ deploymentFlavor.setDescription("creating a deployment flavor with wrong association with " +
+ "null compute flavor id");
+ List<ComponentComputeAssociation> componentComputeAssociationList = new ArrayList<>();
+ ComponentComputeAssociation componentComputeAssociation = new ComponentComputeAssociation();
+ componentComputeAssociation.setComputeFlavorId("72138712");
+ componentComputeAssociationList.add(componentComputeAssociation);
+ deploymentFlavor.setComponentComputeAssociations(componentComputeAssociationList);
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ try {
+ vendorSoftwareProductManager.createDeploymentFlavor
+ (deploymentFlavorEntity, USER1);
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), INVALID_COMPONENT_COMPUTE_ASSOCIATION);
+ }
+
+ }
+
+ @Test
+ public void testInvalidComputeFlavorIdAssociation() {
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("testInvalidComputeFlavorIdAssociation");
+ deploymentFlavor.setDescription("creating a deployment flavor with wrong compute flavor id in" +
+ " assocation");
+ List<ComponentComputeAssociation> componentComputeAssociationList = new ArrayList<>();
+ ComponentComputeAssociation componentComputeAssociation = new ComponentComputeAssociation();
+ componentComputeAssociation.setComponentId(component21Id);
+ componentComputeAssociation.setComputeFlavorId("123123");
+ componentComputeAssociationList.add(componentComputeAssociation);
+ deploymentFlavor.setComponentComputeAssociations(componentComputeAssociationList);
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ try {
+ vendorSoftwareProductManager.createDeploymentFlavor
+ (deploymentFlavorEntity, USER1);
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), INVALID_COMPUTE_FLAVOR_ID);
+ }
+
+ }
+
+ @Test
+ public void testInvalidVfcIdAssociation() {
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("testInvalidVfcIdAssociation");
+ deploymentFlavor.setDescription("creating a deployment flavor with invalid vfcid association");
+ List<ComponentComputeAssociation> componentComputeAssociationList = new ArrayList<>();
+ ComponentComputeAssociation componentComputeAssociation = new ComponentComputeAssociation();
+ componentComputeAssociation.setComponentId("WRONGVFCID");
+ componentComputeAssociation.setComputeFlavorId("123123");
+ componentComputeAssociationList.add(componentComputeAssociation);
+ deploymentFlavor.setComponentComputeAssociations(componentComputeAssociationList);
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ try {
+ vendorSoftwareProductManager.createDeploymentFlavor
+ (deploymentFlavorEntity, USER1);
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+ }
+
+ @Test
+ public void testNegativeforVspHeatOnboarded() {
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vsp3Id, VERSION01, deployment1Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("TestDeploymentcreatewithoutFG");
+ deploymentFlavor.setDescription("creating a deployment flavor for VSP onboarded with HEAT");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ try {
+ vendorSoftwareProductManager.createDeploymentFlavor
+ (deploymentFlavorEntity, USER1);
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(),
+ CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ }
+ }
+
+ @Test
+ public void testGetNegative_InvalidVspId(){
+ testGetNegative("InvalidVspId", VERSION01, deployment1Id, USER1, VERSIONABLE_ENTITY_NOT_EXIST);
+ }
+
+ @Test
+ public void testGetNegative_InvalidDeploymentFlavorId(){
+ testGetNegative(vsp1Id, VERSION01, deployment1Id, USER1, VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testGet(){
+ DeploymentFlavorEntity expected = createDeploymentFlavor(vsp1Id, VERSION01,deployment2Id);
+ testGet(vsp1Id, VERSION01, deployment2Id, USER1, expected);
+ }
+
+ private void testGet(String vspId, Version version, String componentId, String user,
+ DeploymentFlavorEntity expected) {
+ CompositionEntityResponse<DeploymentFlavor> response = vendorSoftwareProductManager
+ .getDeploymentFlavor(vspId, null, componentId, user);
+ Assert.assertEquals(response.getId(), expected.getId());
+ Assert.assertEquals(response.getData().getDescription(),
+ expected.getDeploymentFlavorCompositionData().getDescription());
+ Assert.assertEquals(response.getData().getModel(),
+ expected.getDeploymentFlavorCompositionData().getModel());
+ Assert.assertEquals(response.getData().getFeatureGroupId(),
+ expected.getDeploymentFlavorCompositionData().getFeatureGroupId());
+ Assert.assertEquals(response.getData().getComponentComputeAssociations(),
+ expected.getDeploymentFlavorCompositionData().getComponentComputeAssociations());
+ Assert.assertNotNull(response.getSchema());
+ }
+
+ private void testGetNegative(String vspId, Version version, String deploymentFlavorId, String User,
+ String expectedErrorCode){
+ try{
+ vendorSoftwareProductManager.getDeploymentFlavor(vspId, version, deploymentFlavorId, User);
+ Assert.fail();
+ } catch (CoreException exception){
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ @Test
+ public void testUpdateNegative_InvalidVspId(){
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity("InvalidVspId",
+ VERSION01,deployment2Id);
+ DeploymentFlavor deploymentFlavorData = new DeploymentFlavor();
+ deploymentFlavorData.setModel(deployment2Id);
+ deploymentFlavorData.setDescription("updating a deployment flavor with invalid VspId and without any" +
+ "association");
+ deploymentFlavorData.setFeatureGroupId("fg01");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavorData);
+
+ testUpdateNegative(deploymentFlavorEntity, USER1, VERSIONABLE_ENTITY_NOT_EXIST);
+ }
+
+ @Test
+ public void testUpdateNegative_InvalidDeploymentFlavorId(){
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vsp1Id,
+ VERSION01,"InvalidDeploymentFlavorId");
+ testUpdateNegative(deploymentFlavorEntity, USER1, VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test(dependsOnMethods = "testCreate")
+ public void testUpdateNegative_InvalidFeatureGroup(){
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vsp2Id,
+ VERSION01,deployment1Id);
+ DeploymentFlavor deploymentFlavorData = new DeploymentFlavor();
+ deploymentFlavorData.setModel("TestDeploymentCreateWithoutFG");
+ deploymentFlavorData.setDescription("updating a deployment flavor with invalid FeatureGroupId and without any" +
+ "association");
+ deploymentFlavorData.setFeatureGroupId("fg01");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavorData);
+ String expectedError = "#/featureGroupId: "
+ +deploymentFlavorData.getFeatureGroupId()+" is not a valid value. Possible values: ";
+
+ final CompositionEntityValidationData validationData = vendorSoftwareProductManager
+ .updateDeploymentFlavor(deploymentFlavorEntity, USER1);
+ final Collection<String> errors = validationData.getErrors();
+ final Object[] objects = errors.toArray();
+ Assert.assertEquals(errors.size(), 1);
+ Assert.assertEquals(objects[0], expectedError);
+ }
+
+ @Test(dependsOnMethods = "testCreate")
+ public void testUpdateNegative_InvalidComputeFlavorIdAssociation(){
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vsp2Id,
+ VERSION01,deployment1Id);
+ DeploymentFlavor deploymentFlavorData = new DeploymentFlavor();
+ deploymentFlavorData.setModel("TestDeploymentcreatewithInvalidComputFlavorId");
+ deploymentFlavorData.setDescription("updating a deployment flavor with wrong compute flavor id in" +
+ " assocation");
+ List<ComponentComputeAssociation> componentComputeAssociationList = new ArrayList<>();
+ ComponentComputeAssociation componentComputeAssociation = new ComponentComputeAssociation();
+ componentComputeAssociation.setComponentId(component21Id);
+ componentComputeAssociation.setComputeFlavorId("123123");
+ componentComputeAssociationList.add(componentComputeAssociation);
+ deploymentFlavorData.setComponentComputeAssociations(componentComputeAssociationList);
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavorData);
+
+ testUpdateNegative(deploymentFlavorEntity, USER1, INVALID_COMPUTE_FLAVOR_ID);
+ }
+
+ @Test
+ public void testUpdate(){
+ //Creating a separate deployment flavor for testing deletion
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vsp1Id, VERSION01, deployment2Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("TestDeploymentCreateforUpdate");
+ deploymentFlavor.setDescription("creating a deployment flavor for updation");
+ deploymentFlavor.setFeatureGroupId("fg01");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ DeploymentFlavorEntity createdDeployment = vendorSoftwareProductManager.createDeploymentFlavor
+ (deploymentFlavorEntity, USER1);
+ deployment2Id = createdDeployment.getId();
+
+ final DeploymentFlavor deploymentFlavorCompositionData = createdDeployment.getDeploymentFlavorCompositionData();
+ deploymentFlavorCompositionData.setModel("TestDeploymentCreateforUpdate"); //no change
+ deploymentFlavorCompositionData.setDescription("updating deployment flavor"); //allow change
+ deploymentFlavorCompositionData.setFeatureGroupId("fg01"); //no change
+ createdDeployment.setDeploymentFlavorCompositionData(deploymentFlavorCompositionData);
+
+ vendorSoftwareProductManager.updateDeploymentFlavor(createdDeployment, USER1);
+ CompositionEntityResponse<DeploymentFlavor> deploymentFlavorCompositionEntityResponse = vendorSoftwareProductManager
+ .getDeploymentFlavor(vsp1Id, VERSION01, deployment2Id, USER1);
+ final DeploymentFlavor data = deploymentFlavorCompositionEntityResponse.getData();
+
+ Assert.assertEquals(
+ data.getDescription(),createdDeployment.getDeploymentFlavorCompositionData().getDescription());
+ }
+
+ @Test
+ public void testUpdateVspWithNoFeatureGroup(){
+ //Creating a separate deployment flavor for testing deletion
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("TestDeploymentCreateforUpdate");
+ deploymentFlavor.setDescription("creating a deployment flavor for updation");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ DeploymentFlavorEntity createdDeployment = vendorSoftwareProductManager
+ .createDeploymentFlavor(deploymentFlavorEntity, USER1);
+ deployment1Id = createdDeployment.getId();
+
+ final DeploymentFlavor deploymentFlavorCompositionData = createdDeployment.getDeploymentFlavorCompositionData();
+ deploymentFlavorCompositionData.setModel("TestDeploymentCreateforUpdate"); //no change
+ deploymentFlavorCompositionData.setDescription("updating deployment flavor"); //allow change
+ createdDeployment.setDeploymentFlavorCompositionData(deploymentFlavorCompositionData);
+
+ vendorSoftwareProductManager.updateDeploymentFlavor(createdDeployment, USER1);
+ CompositionEntityResponse<DeploymentFlavor> deploymentFlavorCompositionEntityResponse =
+ vendorSoftwareProductManager.getDeploymentFlavor(vsp2Id, VERSION01, deployment1Id, USER1);
+ final DeploymentFlavor data = deploymentFlavorCompositionEntityResponse.getData();
+
+ Assert.assertEquals(data.getDescription(),createdDeployment.getDeploymentFlavorCompositionData()
+ .getDescription());
+ }
+
+ private void testUpdateNegative(DeploymentFlavorEntity deploymentFlavorEntity, String user,
+ String expectedErrorCode) {
+ try {
+ vendorSoftwareProductManager
+ .updateDeploymentFlavor(deploymentFlavorEntity, user);
+ System.out.print("updated");
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ @Test
+ public void testDelete(){
+ //Creating a separate deployment flavor for testing deletion
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment2Id);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("TestDeploymentcreateWithoutFG");
+ deploymentFlavor.setDescription("creating a deployment flavor without any FG and any " +
+ "association");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ DeploymentFlavorEntity createddeployment = vendorSoftwareProductManager.createDeploymentFlavor
+ (deploymentFlavorEntity, USER1);
+ deployment2Id = createddeployment.getId();
+ vendorSoftwareProductManager.deleteDeploymentFlavor(vsp2Id, deployment2Id, USER1);
+ testDeleteNegative(vsp2Id, deployment2Id, USER1,
+ VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testDeleteNegative_InvalidVspId(){
+ testDeleteNegative("InvalidVspId", deployment2Id, USER1,
+ VERSIONABLE_ENTITY_NOT_EXIST);
+ }
+
+ @Test
+ public void testDeleteNegative_NonExistingDeploymentFlavorId(){
+ testDeleteNegative(vsp2Id, "NonExistingDeploymentFlavorId", USER1,
+ VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ private void testDeleteNegative(String vspId, String deploymentId, String user,
+ String expectedErrorCode) {
+ try {
+ vendorSoftwareProductManager
+ .deleteDeploymentFlavor(vspId, deploymentId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }*/
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
new file mode 100644
index 0000000000..afd797573a
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
@@ -0,0 +1,463 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.ImageErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
+import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.image.ImageDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.util.Collection;
+
+public class ImagesTest {
+
+ /*private static final String USER1 = "imageTestUser1";
+ private static final String USER2 = "imageTestUser2";
+ private static final Version VERSION01 = new Version(0, 1);
+ private static final VendorSoftwareProductManager vendorSoftwareProductManager =
+ new VendorSoftwareProductManagerImpl();
+ private static final VendorSoftwareProductDao vendorSoftwareProductDao =
+ VendorSoftwareProductDaoFactory
+ .getInstance().createInterface();
+
+ private static String image1Id;
+
+
+ private static String comp1 = "{\"displayName\": \"VFC_Manual\", " +
+ "\"description\": \"desc manual\"}";
+
+ private static String vsp1Id;
+ private static String vsp2Id;
+ private static String vsp3Id;
+ private static String comp1Id;
+
+ private static String image2Id;
+
+ @BeforeClass
+ private void init() {
+ VspDetails
+ vsp1 = vendorSoftwareProductManager.createNewVsp(VSPCommon
+ .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp1", "vendorName",
+ "vlm1Id", "icon", "category", "subCategory", "123", null,
+ VSPCommon.OnboardingMethod.Manual.name()), USER1
+ );
+ vsp1Id = vsp1.getId();
+
+ VspDetails vsp2 = vendorSoftwareProductManager.createNewVsp(VSPCommon
+ .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp2", "vendorName",
+ "vlm1Id", "icon", "category", "subCategory", "123", null, VSPCommon.OnboardingMethod.
+ Manual.name()), USER1);
+ vsp2Id = vsp2.getId();
+
+ VspDetails vsp3 = vendorSoftwareProductManager.createNewVsp(VSPCommon
+ .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp3",
+ "vendorName",
+ "vlm1Id", "icon", "category", "subCategory", "123", null, VSPCommon
+ .OnboardingMethod.HEAT.name()), USER1);
+ vsp3Id = vsp3.getId();
+
+ ComponentEntity comp = new ComponentEntity();
+ comp.setVspId(vsp2Id);
+ comp.setCompositionData(comp1);
+ ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(comp, USER1);
+ comp1Id = createdComp.getId();
+ }
+
+ @Test
+ public void testListImagesNonExistingVspId_negative() {
+ testList_negative("non existing vsp id", null, image1Id, USER1,
+ VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
+ "Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
+ }
+
+ @Test
+ public void testListImagesNonExistingVfcId_negative() {
+ testList_negative(vsp1Id, VERSION01, "444", USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
+ "Vendor Software Product Component with Id 444 does not exist for Vendor Software Product "
+ + "with id "+vsp1Id+ " and version "+VERSION01);
+ }
+
+ @Test
+ public void testListImages() {
+ createImageEntity("media-vsrx-vmdisk-15.1X49-D40.6.aki", "aki");
+ createImageEntity("riverbed-15.1X49-D40.6.vdi", "vdi");
+ final Collection<ImageEntity> imageEntities =
+ vendorSoftwareProductManager.listImages(vsp2Id, VERSION01, comp1Id, USER1);
+ System.out.println("size::"+imageEntities.size());
+ }
+
+ @Test
+ public void testCreateNonExistingVspId_negative() {
+ testCreate_negative(new ImageEntity("non existing vsp id", null, null, null), USER1,
+ VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
+ "Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist.");
+ }
+
+ @Test
+ public void testCreateNonExistingVfcId_negative() {
+ testCreate_negative(new ImageEntity(vsp1Id, VERSION01, "222", null), USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
+ "Vendor Software Product Component with Id 222 does not exist for Vendor Software Product "
+ + "with id "+vsp1Id + " and version "+VERSION01);
+ }
+
+ @Test(dependsOnMethods = "testUpdateNonExistingImageId_negative")
+ public void testCreateOnAvailableVsp_negative() {
+ vendorSoftwareProductManager.checkin(vsp1Id, USER1);
+ testCreate_negative(new ImageEntity(vsp1Id, null, null, null), USER1,
+ VersioningErrorCodes.EDIT_ON_UNLOCKED_ENTITY,
+ "Can not edit versionable entity VendorSoftwareProduct with id "+vsp1Id+ " since it is not"
+ + " checked out.");
+ }
+
+ @Test(dependsOnMethods = "testCreateOnAvailableVsp_negative")
+ public void testCreateOnVspOtherUser_negative() {
+ vendorSoftwareProductManager.checkout(vsp1Id, USER1);
+ testCreate_negative(new ImageEntity(vsp1Id, null, null, null), USER2,
+ VersioningErrorCodes.EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER,
+ "Versionable entity VendorSoftwareProduct with id " +vsp1Id+
+ " can not be edited since it is locked by other user "+ USER1+ ".");
+ }
+
+ @Test(dependsOnMethods = "testCreateOnVspOtherUser_negative")
+ public void testOnUndoCheckoutImagesDeleted() {
+
+ ComponentEntity comp = new ComponentEntity();
+ comp.setVspId(vsp1Id);
+ comp.setCompositionData(comp1);
+ ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(comp, USER1);
+ String compId = createdComp.getId();
+
+ vendorSoftwareProductManager.checkin(vsp1Id, USER1);
+ vendorSoftwareProductManager.checkout(vsp1Id, USER1);
+
+ for(int i = 1; i<=3; i++) {
+ ImageEntity imageEntity = new ImageEntity();
+ imageEntity.setVspId(vsp1Id);
+ imageEntity.setComponentId(compId);
+ Image image = new Image();
+ image.setFileName(i + "testimage.aki");
+ //image.setVersion("9.2.0");
+ image.setDescription("riverbed image");
+ //image.setFormat("aki");
+ //image.setMd5("233343DDDD");
+ imageEntity.setImageCompositionData(image);
+ ImageEntity createdImage = vendorSoftwareProductManager.createImage(imageEntity, USER1);
+ }
+
+ Collection<ImageEntity> imageEntities =
+ vendorSoftwareProductManager.listImages(vsp1Id, null, compId, USER1);
+
+ Assert.assertEquals(imageEntities.size(), 3);
+
+ vendorSoftwareProductManager.undoCheckout(vsp1Id, USER1);
+
+ imageEntities = vendorSoftwareProductManager.listImages(vsp1Id, null, compId, USER1);
+
+ Assert.assertEquals(imageEntities.size(), 0);
+ }
+
+ @Test
+ public void testCreateOnHeatVsp_negative() {
+ final ErrorCode addImageNotSupportedHeatOnboardMethodErrorBuilder =
+ NotSupportedHeatOnboardMethodErrorBuilder
+ .getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
+ testCreate_negative(new ImageEntity(vsp3Id, null, null, null), USER1,
+ addImageNotSupportedHeatOnboardMethodErrorBuilder.id(),
+ addImageNotSupportedHeatOnboardMethodErrorBuilder.message()
+ );
+ }
+
+ @Test(dependsOnMethods = "testListImages")
+ public void testCreateImage() {
+ ImageEntity createdImage = createImageEntity("riverbed-WX-IMG-9.2.0.qcow2", "qcow2");
+ Assert.assertNotNull(image1Id);
+ Assert.assertNotNull(createdImage.getCompositionData());
+ Assert.assertNotNull(
+ vendorSoftwareProductManager.getImage(vsp2Id, VERSION01, comp1Id,image1Id,
+ USER1).getData());
+ }
+
+ @Test(dependsOnMethods = "testCreateImage")
+ public void testCreateDupImageNameForSameComponent_negative() {
+ ImageEntity createdImage = null;
+ try {
+ createdImage = createImageEntity("riverbed-WX-IMG-9.2.0.qcow2", "qcow2");
+ Assert.fail();
+ }
+ catch(CoreException exception) {
+ Assert.assertEquals(exception.code().id(), VendorSoftwareProductErrorCodes.
+ DUPLICATE_IMAGE_NAME_NOT_ALLOWED);
+ Assert.assertEquals(exception.getMessage(),
+ String.format("Invalid request, Image with name riverbed-WX-IMG-9.2.0.qcow2 already " +
+ "exists for component with ID "+comp1Id)+".");
+ }
+ }
+
+ @Test
+ public void testGet() {
+ ImageEntity createdImage = createImageEntity("read-riverbed-WX-IMG-9.2.0.qcow2", "qcow2");
+ testGet(vsp2Id, VERSION01, comp1Id, createdImage.getId(), USER1, createdImage);
+ }
+
+ @Test
+ public void testGetNonExistingVspId_negative() {
+ testGet_negative("non existing vsp id", null, null, image1Id, USER1,
+ VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
+ "Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
+ }
+
+ @Test
+ public void testGetNonExistingVfcId_negative() {
+ testGet_negative(vsp1Id, VERSION01, "111", null, USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
+ "Vendor Software Product Component with Id 111 does not exist for Vendor Software Product "
+ + "with id "+vsp1Id + " and version "+VERSION01);
+ }
+
+ @Test
+ public void testUpdateNonExistingVspId_negative() {
+ ImageEntity imageEntity = new ImageEntity("non existing vsp id", null, null, image1Id);
+
+ testUpdate_negative(imageEntity, USER1,
+ VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
+ "Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
+ }
+
+ @Test(dependsOnMethods = "testUpdateNonExistingVspId_negative")
+ public void testUpdateNonExistingVfcId_negative() {
+ ImageEntity imageEntity = new ImageEntity(vsp1Id, VERSION01, "111", null);
+
+ testUpdate_negative(imageEntity, USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
+ "Vendor Software Product Component with Id 111 does not exist for Vendor Software Product "
+ + "with id "+vsp1Id + " and version "+VERSION01);
+ }
+
+ @Test(dependsOnMethods = "testUpdateNonExistingVfcId_negative")
+ public void testUpdateNonExistingImageId_negative() {
+ ImageEntity imageEntity = new ImageEntity(vsp2Id, VERSION01, comp1Id, "222");
+
+ testUpdate_negative(imageEntity, USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
+ "Vendor Software Product Component Image with Id 222 does not exist for Vendor " +
+ "Software Product with id "+vsp2Id+ " and version "+VERSION01 );
+ }
+
+ @Test(dependsOnMethods = "testCreateImage")
+ public void testUpdate() {
+ ImageEntity imageEntity = createImageEntity("testimage1","qcow2");
+ testGet(vsp2Id, VERSION01, comp1Id, imageEntity.getId(),USER1, imageEntity );
+
+ final Image imageCompositionData = imageEntity.getImageCompositionData();
+ //imageCompositionData.setVersion("10.0");
+ imageCompositionData.setDescription("updated image");
+
+ vendorSoftwareProductManager.updateImage(imageEntity, USER1);
+
+ testGet(vsp2Id, VERSION01, comp1Id, imageEntity.getId(),USER1, imageEntity );
+ image2Id = imageEntity.getId();
+ }
+
+ @Test(dependsOnMethods = "testUpdate")
+ public void testUpdateNegative_UniqueName() {
+ final CompositionEntityResponse<Image> image =
+ vendorSoftwareProductManager.getImage(vsp2Id, VERSION01, comp1Id,
+ image2Id, USER1);
+ final Image data = image.getData();
+
+ final Image imageCompositionData = data;
+ imageCompositionData.setFileName("riverbed-WX-IMG-9.2.0.qcow2");
+
+ ImageEntity entity = new ImageEntity(vsp2Id, VERSION01, comp1Id, image2Id );
+ entity.setImageCompositionData(imageCompositionData);
+ testUpdate_negative(entity, USER1, ImageErrorBuilder.getDuplicateImageNameErrorBuilder(
+ "riverbed-WX-IMG-9.2.0.qcow2", comp1Id).id()
+ ,ImageErrorBuilder.getDuplicateImageNameErrorBuilder("riverbed-WX-IMG-9.2.0.qcow2", comp1Id)
+ .message() );
+ }
+
+ @Test(dependsOnMethods = "testUpdateNegative_UniqueName")
+ public void testDeleteImage() {
+ CompositionEntityResponse<Image> image =
+ vendorSoftwareProductManager.getImage(vsp2Id, VERSION01, comp1Id, image2Id, USER1);
+
+ Assert.assertNotNull(image.getData());
+
+ vendorSoftwareProductManager.deleteImage(vsp2Id, comp1Id, image2Id, USER1);
+
+ testGet_negative(vsp2Id, VERSION01, comp1Id, image2Id, USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
+ "Vendor Software Product Component Image with Id "+image2Id+ " does not exist for " +
+ "Vendor Software Product with id "+vsp2Id+ " and version "+VERSION01 );
+
+ }
+
+ @Test
+ public void testDeleteNonExistingVspId_negative() {
+ ImageEntity imageEntity = new ImageEntity("non existing vsp id", null, null, image1Id);
+
+ testDelete_negative(imageEntity, USER1,
+ VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
+ "Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
+ }
+
+ @Test(dependsOnMethods = "testDeleteNonExistingVspId_negative")
+ public void testDeleteNonExistingVfcId_negative() {
+ ImageEntity imageEntity = new ImageEntity(vsp1Id, VERSION01, "111", null);
+
+ testDelete_negative(imageEntity, USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
+ "Vendor Software Product Component with Id 111 does not exist for Vendor Software Product "
+ + "with id "+vsp1Id + " and version "+VERSION01);
+ }
+
+ @Test(dependsOnMethods = "testDeleteNonExistingVfcId_negative")
+ public void testDeleteNonExistingImageId_negative() {
+ ImageEntity imageEntity = new ImageEntity(vsp2Id, VERSION01, comp1Id, "222");
+
+ testDelete_negative(imageEntity, USER1,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
+ "Vendor Software Product Component Image with Id 222 does not exist for Vendor " +
+ "Software Product with id "+vsp2Id+ " and version "+VERSION01 );
+ }
+
+ @Test
+ public void testUpdateandGetQuestionnaire() {
+ ImageEntity imageEntity = createImageEntity("newimage_testUpdateandGetQuestionnaire.vdi","vdi");
+ vendorSoftwareProductManager.updateImageQuestionnaire(vsp2Id, comp1Id, imageEntity.getId(),
+ "{\"format\":\"vdi\",\"version\":\"1.2\",\"md5\":\"ssd3344\"}",
+ USER1);
+
+ final QuestionnaireResponse imageQuestionnaire =
+ vendorSoftwareProductManager.getImageQuestionnaire(vsp2Id, VERSION01, comp1Id,
+ imageEntity.getId(), USER1);
+
+ String imageDetails = imageQuestionnaire.getData();
+ Assert.assertEquals("vdi", JsonUtil.json2Object(imageDetails, ImageDetails.class).getFormat());
+ Assert.assertEquals("1.2", JsonUtil.json2Object(imageDetails, ImageDetails.class).getVersion());
+ Assert.assertEquals("ssd3344", JsonUtil.json2Object(imageDetails, ImageDetails.class).getMd5());
+ }
+
+ @Test
+ public void testUpdateQuestionnaireInvalidFormat_negative() {
+ ImageEntity imageEntity = createImageEntity("newimage.vdi","vdi");
+ try {
+ vendorSoftwareProductManager.updateImageQuestionnaire(vsp2Id, comp1Id, imageEntity.getId(),
+ "{\"format\":\"invalidformat\",\"version\":\"1.2\",\"md5\":\"ssd3344\"}",
+ USER1);
+ Assert.fail();
+ }
+ catch(CoreException exception) {
+ Assert.assertEquals(exception.code().id(), "VFC_IMAGE_INVALID_FORMAT");
+ Assert.assertEquals(exception.getMessage(), "The format value doesn't meet the expected "
+ + "attribute value.");
+ }
+ }
+
+ private ImageEntity createImageEntity(String fileName, String format) {
+ ImageEntity imageEntity = new ImageEntity();
+ imageEntity.setVspId(vsp2Id);
+ imageEntity.setComponentId(comp1Id);
+ Image image = new Image();
+ image.setFileName(fileName);
+ //image.setVersion("9.2.0");
+ image.setDescription("riverbed image");
+ //image.setFormat(format);
+ // image.setMd5("233343DDDD");
+ imageEntity.setImageCompositionData(image);
+
+ ImageEntity createdImage = vendorSoftwareProductManager.createImage(imageEntity, USER1);
+ image1Id = createdImage.getId();
+ return createdImage;
+ }
+
+ private void testGet(String vspId, Version version, String componentId, String imageId, String
+ user, ImageEntity expected) {
+ CompositionEntityResponse<Image>
+ response = vendorSoftwareProductManager.getImage(vspId, null, componentId, imageId, user);
+ Assert.assertEquals(response.getId(), expected.getId());
+ Assert.assertEquals(expected.getImageCompositionData().getFileName(), response.getData().
+ getFileName());
+ Assert.assertEquals(expected.getImageCompositionData().getDescription(), response.getData().
+ getDescription());
+ Assert.assertNotNull(response.getSchema());
+ }
+
+ private void testCreate_negative(ImageEntity image, String user,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+ vendorSoftwareProductManager.createImage(image, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
+ }
+
+ private void testGet_negative(String vspId, Version version, String componentId, String imageId,
+ String user,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+ vendorSoftwareProductManager.getImage(vspId, version, componentId, imageId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
+ }
+
+ private void testList_negative(String vspId, Version version, String componentId, String user,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+ vendorSoftwareProductManager.listImages(vspId, version, componentId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
+ }
+
+ private void testUpdate_negative(ImageEntity imageEntity,
+ String user,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+
+ vendorSoftwareProductManager.updateImage(imageEntity, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
+ }
+
+ private void testDelete_negative(ImageEntity imageEntity,
+ String user,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+
+ vendorSoftwareProductManager.updateImage(imageEntity, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
+ }*/
+} \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/VSPFullTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/VSPFullTest.java
index d4dea70f2f..be2de13c16 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/VSPFullTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/VSPFullTest.java
@@ -20,43 +20,6 @@
package org.openecomp.sdc.vendorsoftwareproduct;
-import org.apache.commons.collections4.MapUtils;
-import org.apache.commons.io.IOUtils;
-import org.openecomp.core.enrichment.types.ArtifactType;
-import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
-import org.openecomp.core.util.UniqueValueUtil;
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.utils.VSPCommon;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
public class VSPFullTest {
/*
@@ -71,7 +34,7 @@ public class VSPFullTest {
private static VendorLicenseFacade vendorLicenseFacade =
VendorLicenseFacadeFactory.getInstance().createInterface();
private OrchestrationTemplateCandidateManager candidateManager;
- private MibManager mibManager;
+ private MonitoringUploadsManager mibManager;
private NicManager nicManager;
@Test
@@ -106,7 +69,7 @@ public class VSPFullTest {
mibManager
.upload(zis1, "MMSC.zip", vspId, VERSION01,
components.iterator().next().getId(),
- ArtifactType.SNMP_TRAP,
+ MonitoringUploadType.SNMP_TRAP,
USER1);
//check in
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java
index 34af0e67b2..7cfcb05589 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java
@@ -8,6 +8,7 @@ import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
@@ -24,6 +25,7 @@ import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -47,6 +49,8 @@ public class ComponentManagerImplTest {
private CompositionEntityDataManager compositionEntityDataManagerMock;
@Mock
private NicManager nicManagerMock;
+ @Mock
+ private VendorSoftwareProductInfoDao vspInfoDao;
@InjectMocks
@Spy
private ComponentManagerImpl componentManager;
@@ -95,25 +99,102 @@ public class ComponentManagerImplTest {
/* @Test
public void testCreate() {
COMP1_ID = testCreate(VSP_ID);
+ }*/
+ @Test
+ public void testCreate() {
+ ComponentEntity expected = new ComponentEntity(VSP_ID, null, null);
+ ComponentData compData = new ComponentData();
+ compData.setName("comp1 name");
+ compData.setDescription("comp1 desc");
+ expected.setComponentCompositionData(compData);
+
+ doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ Collection<ComponentEntity> vspComponentList = new ArrayList<>();
+ doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
+ doReturn(expected).when(compositionEntityDataManagerMock).createComponent(anyObject());
+
+ ComponentEntity created = componentManager.createComponent(expected, USER);
+ Assert.assertNotNull(created);
+ //expected.setId(created.getId());
+ //expected.setVersion(VERSION);
+
+ //ComponentEntity actual = componentDaoMock.getComponent(VSP_ID, VERSION, created.getId());
+
+ //Assert.assertEquals(actual, expected);
+ //return created.getId();
+ }
+
+ @Test
+ public void testCreateWithVspCompListMoreThanOne() {
+ ComponentEntity expected = new ComponentEntity(VSP_ID, null, null);
+ ComponentData compData = new ComponentData();
+ compData.setName("comp1 name");
+ compData.setDescription("comp1 desc");
+ expected.setComponentCompositionData(compData);
+
+ doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ Collection<ComponentEntity> vspComponentList = new ArrayList<>();
+ vspComponentList.add(expected);
+ doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
+
+ try {
+ ComponentEntity created = componentManager.createComponent(expected, USER);
+ } catch (CoreException exception) {
+ Assert.assertEquals("Creation of only one VFC per VSP allowed.", exception.code().message());
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.VSP_VFC_COUNT_EXCEED,
+ exception.code().id());
}
+ }
- private String testCreate(String VSP_ID) {
- ComponentEntity expected = new ComponentEntity(VSP_ID, null, null);
- ComponentData compData = new ComponentData();
- compData.setName("comp1 name");
- compData.setDescription("comp1 desc");
- expected.setComponentCompositionData(compData);
+ @Test
+ public void testUpdateComp() {
+ ComponentEntity expected = new ComponentEntity(VSP_ID, null, COMP1_ID);
+ ComponentData compData = new ComponentData();
+ compData.setName("comp1 name");
+ compData.setDescription("comp1 desc");
+ expected.setComponentCompositionData(compData);
+
+ doReturn(expected).when(componentDaoMock).get(anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ Collection<ComponentEntity> vspComponentList = new ArrayList<>();
+ vspComponentList.add(expected);
+ doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
+ doReturn(new CompositionEntityValidationData(null,null)).when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(),anyObject(),anyObject());
+
+ CompositionEntityValidationData created = componentManager.updateComponent(expected, USER);
+ Assert.assertNotNull(created);
+ }
- ComponentEntity created = componentManager.createComponent(expected, USER);
- Assert.assertNotNull(created);
- expected.setId(created.getId());
- expected.setVersion(VERSION);
+ @Test
+ public void testUpdateCompWithSameVfcDisplayName() {
+ ComponentEntity expected = new ComponentEntity(VSP_ID, null, COMP1_ID);
+ ComponentData compData = new ComponentData();
+ compData.setName("comp1 name");
+ compData.setDescription("comp1 desc");
+ compData.setDisplayName("comp1 displayname");
+ expected.setComponentCompositionData(compData);
- ComponentEntity actual = componentDaoMock.getComponent(VSP_ID, VERSION, created.getId());
+ doReturn(expected).when(componentDaoMock).get(anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ Collection<ComponentEntity> vspComponentList = new ArrayList<>();
+ vspComponentList.add(expected);
+ ComponentEntity expected2 = new ComponentEntity(VSP_ID+"2", null, COMP1_ID+"2");
+ expected2.setComponentCompositionData(compData);
+ vspComponentList.add(expected2);
+ doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
+ doReturn(new CompositionEntityValidationData(null,null)).when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(),anyObject(),anyObject());
- Assert.assertEquals(actual, expected);
- return created.getId();
- }*/
+ try {
+ CompositionEntityValidationData created = componentManager.updateComponent(expected, USER);
+ } catch (CoreException exception) {
+ Assert.assertEquals("VFC with specified name already present in given VSP.",
+ exception.code().message());
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME,
+ exception.code().id());
+ }
+ }
/* @Test
public void testCreateWithExistingName_negative() {
@@ -133,7 +214,7 @@ public class ComponentManagerImplTest {
@Test
public void testCreateOnUploadVsp_negative() {
testCreate_negative(new ComponentEntity(VSP_ID, VERSION, null), USER,
- VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ VendorSoftwareProductErrorCodes.VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@Test
@@ -159,6 +240,8 @@ public class ComponentManagerImplTest {
compData.setName(COMP1_ID + " name"); // no change
compData.setDisplayName(COMP1_ID + " display name"); // no change
compData.setVfcCode(COMP1_ID + " display name"); // no change
+ compData.setNfcCode(COMP1_ID + " display name"); // no change
+ compData.setNfcFunction(COMP1_ID + " display name"); // no change
compData.setDescription(COMP1_ID + " desc updated"); // allowed change
component.setComponentCompositionData(compData);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java
new file mode 100644
index 0000000000..c8f473c8c7
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java
@@ -0,0 +1,377 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
+import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DuplicateComputeInComponentErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.*;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Created by DIVESHM on 5/16/2017.
+ */
+
+
+public class ComputeManagerImplTest {
+
+ private static final String COMPUTE_NOT_EXIST_MSG =
+ "Vendor Software Product COMPUTE with Id compute1 does not exist for Vendor Software Product with " +
+ "id VSP_ID and version 0.1";
+
+ private static final String USER = "computeTestUser";
+ private static final String VSP_ID = "VSP_ID";
+ private static final Version VERSION = new Version(0, 1);
+ private static final String COMPONENT_ID = "COMPONENT_ID";
+ private static final String COMPUTE1_ID = "compute1";
+ private static final String COMPUTE2_ID = "compute2";
+
+ @Mock
+ private ComputeDao computeDao;
+
+ @Mock
+ private CompositionEntityDataManager compositionEntityDataManagerMock;
+
+ @Mock
+ private NetworkManager networkManagerMock;
+
+ @Mock
+ private VendorSoftwareProductInfoDao vspInfoDao;
+
+ @Mock
+ private ComputeEntity computeEntity;
+
+ @Mock
+ private ListComputeResponse listComputeResponse;
+
+ @Mock
+ private DeploymentFlavorEntity deploymentFlavorEntity;
+
+ @Mock
+ private DeploymentFlavorDao deploymentFlavorDao;
+
+ @Mock
+ private ComponentComputeAssociation componentComputeAssociation;
+
+ @Mock
+ DeploymentFlavor deploymentFlavor;
+
+ @InjectMocks
+ @Spy
+ private ComputeManagerImpl computeManager;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testListWhenNone() {
+ Collection<ListComputeResponse> computes = computeManager.listCompute(VSP_ID, VERSION, COMPONENT_ID, USER);
+ Assert.assertEquals(computes.size(), 0);
+ }
+
+ @Test
+ public void testList(){
+ doReturn(Arrays.asList(
+ createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID),
+ createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE2_ID)))
+ .when(computeDao).list(anyObject());
+
+
+ Collection<ListComputeResponse> computes = computeManager.listCompute(VSP_ID, VERSION, COMPONENT_ID, USER);
+ Assert.assertEquals(computes.size(), 2);
+ for (ListComputeResponse compute : computes) {
+ Assert.assertEquals(compute.getComputeEntity().getComputeCompositionData().getName(),
+ COMPUTE1_ID.equals(compute.getComputeEntity().getId())
+ ? "compute1name"
+ : "compute2name");
+ };
+ }
+
+ @Test
+ public void testCreateOnNotManualCompute_negative() {
+
+ testCreate_negative(new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, null), USER,
+ VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ }
+
+ @Test
+ public void testCreateManualCompute() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ computeManager.createCompute(expected, USER);
+ verify(compositionEntityDataManagerMock).createCompute(expected);
+ verify(compositionEntityDataManagerMock).createCompute(expected);
+ }
+
+ @Test
+ public void testCreateManualImageWithDuplicateName() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ ComputeEntity expectedDiffName = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ ComputeData computeData = expectedDiffName.getComputeCompositionData();
+ computeData.setName(COMPUTE1_ID + "Name");
+ expectedDiffName.setComputeCompositionData(computeData);
+ List<ComputeEntity> vfcImageList = new ArrayList<ComputeEntity>();
+ vfcImageList.add(expectedDiffName);
+ doReturn(vfcImageList).when(computeDao).list(anyObject());
+
+ try {
+ computeManager.createCompute(expected, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
+
+
+ @Test
+ public void testUpdateNonExistingComputeId_negative() {
+
+ testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testUpdateCompute() {
+ doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
+ .when(computeDao).get(anyObject());
+
+ doReturn(new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID))
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
+
+ ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(COMPUTE1_ID + "name");
+ computeData.setDescription(COMPUTE1_ID + "desc updated");
+ computeEntity.setComputeCompositionData(computeData);
+
+ CompositionEntityValidationData validationData =
+ computeManager.updateCompute(computeEntity, USER);
+ Assert.assertTrue(validationData == null || validationData.getErrors() == null);
+ verify(computeDao).update(computeEntity);
+ }
+
+ @Test
+ public void testIllegalComputeUpdate() {
+ doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
+ .when(computeDao).get(anyObject());
+
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ CompositionEntityValidationData toBeReturned =
+ new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID);
+ toBeReturned.setErrors(Arrays.asList("error1", "error2"));
+ doReturn(toBeReturned)
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
+
+ ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(COMPUTE1_ID + " name updated");
+ computeData.setDescription(COMPUTE1_ID + " desc updated");
+ computeEntity.setComputeCompositionData(computeData);
+
+ CompositionEntityValidationData validationData = computeManager.updateCompute(computeEntity, USER);
+ Assert.assertNotNull(validationData);
+ Assert.assertEquals(validationData.getErrors().size(), 2);
+
+ verify(computeDao, never()).update(computeEntity);
+ }
+
+ @Test
+ public void testUpdateHEATComputeName() throws Exception {
+ doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
+ .when(computeDao).get(anyObject());
+ ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(COMPUTE1_ID + " name updated");
+ computeData.setDescription(COMPUTE1_ID + " desc updated");
+ computeEntity.setComputeCompositionData(computeData);
+
+ try {
+ computeManager.updateCompute(computeEntity, USER);
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED);
+ }
+
+ }
+
+ @Test
+ public void testUpdateManualComputeQuestionnaire() throws Exception {
+ String json = "{\"md5\" :\"FFDSD33SS\"}";
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ doReturn(new ComputeEntity(null,null,null,null)).when(computeDao).get(anyObject());
+
+ computeManager.updateComputeQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, json, USER);
+ verify(computeDao).updateQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, json);
+ }
+
+ @Test
+ public void testGetNonExistingComputeId_negative() {
+ testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing compute id", USER,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testGet() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(expected).when(computeDao).get(anyObject());
+ String compositionSchema = "schema string";
+ doReturn(compositionSchema).when(computeManager).getComputeCompositionSchema(anyObject());
+
+ CompositionEntityResponse<ComputeData> response =
+ computeManager.getCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER);
+ Assert.assertEquals(response.getId(), expected.getId());
+ Assert.assertEquals(response.getData().getName(), expected.getComputeCompositionData().getName());
+ Assert.assertEquals(response.getData().getDescription(), expected.getComputeCompositionData().
+ getDescription());
+ Assert.assertEquals(response.getSchema(), compositionSchema);
+ }
+
+ @Test
+ public void testGetQuestionnaire() throws Exception {
+ ComputeEntity compute = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ compute.setQuestionnaireData("{}");
+ doReturn(compute).when(computeDao).getQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+
+ String schema = "schema string";
+
+
+ doReturn(schema).when(computeManager).getComputeQuestionnaireSchema(anyObject());
+
+ QuestionnaireResponse questionnaire =
+ computeManager.getComputeQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER);
+
+ Assert.assertNotNull(questionnaire);
+ Assert.assertEquals(questionnaire.getData(), compute.getQuestionnaireData());
+ Assert.assertEquals(questionnaire.getSchema(), schema);
+ Assert.assertNull(questionnaire.getErrorMessage());
+ }
+
+ @Test
+ public void testDeleteOnNotManualCompute() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(expected).when(computeDao).get(anyObject());
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER,
+ VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ }
+
+ @Test
+ public void testDeleteOnManualCompute() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(expected).when(computeDao).get(anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ computeManager.deleteCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER);
+ verify(computeDao).delete(anyObject());
+ }
+
+ @Test
+ public void testDeleteOnNotExistCompute() {
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER,
+ VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ }
+
+
+ private void testDelete_negative(String vspId, Version version, String componentId, String computeId,
+ String user,
+ String expectedErrorCode) {
+ try {
+ computeManager.deleteCompute(vspId, version, componentId, computeId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private void testGet_negative(String vspId, Version version, String componentId, String computeId,
+ String user, String expectedErrorCode) {
+ try {
+ computeManager.getCompute(vspId, version, componentId, computeId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private void testList_negative(String vspId, Version version, String componentId, String user,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+ computeManager.listCompute(vspId, version, componentId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
+ }
+
+
+
+ private void testUpdate_negative(String vspId, Version version, String componentId, String computeId,
+ String user, String expectedErrorCode) {
+ try {
+ computeManager.updateCompute(new ComputeEntity(vspId, version, componentId, computeId), user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private void testCreate_negative(ComputeEntity computeEntity1, String user, String expectedErrorCode) {
+ try {
+ computeManager.createCompute(computeEntity1, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ static ComputeEntity createCompute(String vspId, Version version, String compId, String computeId){
+ ComputeEntity computeEntity1 = new ComputeEntity(vspId, version, compId, computeId);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(computeId+"name");
+ computeData.setDescription(computeId+"desc");
+ computeEntity1.setComputeCompositionData(computeData);
+ return computeEntity1;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java
new file mode 100644
index 0000000000..e082b25435
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java
@@ -0,0 +1,409 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+public class DeplomentFlavorManagerImplTest {
+ private static final String USER = "depFlavorTestUser";
+ private static final String VSP_ID = "VSP_ID";
+ private static final Version VERSION = new Version(0, 1);
+ private static final String COMPONENT_ID = "COMPONENT_ID";
+ private static final String DF1_ID = "df1";
+ private static final String DF2_ID = "df2";
+
+ @Mock
+ private CompositionEntityDataManager compositionEntityDataManagerMock;
+ @Mock
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ @Mock
+ DeploymentFlavorDao deploymentFlavorDaoMock;
+ @Mock
+ ComponentDao componentDaoMock;
+ @Mock
+ ComputeDao computeDaoMock;
+ @InjectMocks
+ @Spy
+ private DeploymentFlavorManagerImpl deploymentFlavorManager;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testListWhenNone() {
+ final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION, USER);
+ Assert.assertEquals(deploymentFlavorEntities.size(), 0);
+ }
+
+ @Test
+ public void testCreateOnNotManual_negative() {
+
+ testCreate_negative(new DeploymentFlavorEntity(VSP_ID, VERSION, null), USER,
+ VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ }
+
+ @Test
+ public void testCreateManualDepFlavor() {
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ doReturn(vspDetails).when(vspInfoDao).get(anyObject());
+
+ deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ verify(compositionEntityDataManagerMock).createDeploymentFlavor(expected);
+ }
+
+ @Test
+ public void testCreateManualDepFlavorWithDuplicateName() {
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ DeploymentFlavorEntity expectedDiffName = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavor deploymentFlavor = expectedDiffName.getDeploymentFlavorCompositionData();
+ deploymentFlavor.setModel(DF1_ID + " Name");
+ expectedDiffName.setDeploymentFlavorCompositionData(deploymentFlavor);
+ List<DeploymentFlavorEntity> list = new ArrayList<DeploymentFlavorEntity>();
+ list.add(expectedDiffName);
+ doReturn(list).when(deploymentFlavorDaoMock).list(anyObject());
+
+ try {
+ deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
+
+ @Test
+ public void testCreateManualDepFlavorWithFGNotInVSP() {
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ final DeploymentFlavor deploymentFlavor =
+ JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
+ deploymentFlavor.setFeatureGroupId("fg3");
+ expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
+
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ List<String> featureGrps = new ArrayList<String>();
+ featureGrps.add("fg1");
+ featureGrps.add("fg2");
+
+ VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ vspDetails.setFeatureGroups(featureGrps);
+ doReturn(vspDetails).when(vspInfoDao).get(anyObject());
+
+
+ try {
+ deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP,
+ ex.code().id());
+ }
+ }
+
+ @Test
+ public void testCreateManualDepFlavorWithNullCompInAssociation() {
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ final DeploymentFlavor deploymentFlavor =
+ JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
+ ComponentComputeAssociation association = new ComponentComputeAssociation();
+ association.setComponentId(null);
+ association.setComputeFlavorId("CF1");
+ List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
+ list.add(association);
+ deploymentFlavor.setComponentComputeAssociations(list);
+ expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
+
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ doReturn(vspDetails).when(vspInfoDao).get(anyObject());
+
+ try {
+ deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION,
+ ex.code().id());
+ Assert.assertEquals("Invalid request,for valid association please provide ComponentId for Compute Flavor",
+ ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testCreateManualDepFlavorWithInvalidComputeInAssociation() {
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ final DeploymentFlavor deploymentFlavor =
+ JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
+ ComponentComputeAssociation association = new ComponentComputeAssociation();
+ association.setComponentId(COMPONENT_ID);
+ association.setComputeFlavorId("CF1");
+ List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
+ list.add(association);
+ deploymentFlavor.setComponentComputeAssociations(list);
+ expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
+
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ doReturn(vspDetails).when(vspInfoDao).get(anyObject());
+
+ ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, USER);
+ doReturn(component).when(componentDaoMock).get(anyObject());
+
+ doReturn(null).when(computeDaoMock).get(anyObject());
+
+ try {
+ deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID,
+ ex.code().id());
+ }
+ }
+
+ @Test
+ public void testCreateManualDepFlavorWithDuplicateVfcAssociation() {
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ final DeploymentFlavor deploymentFlavor =
+ JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
+ ComponentComputeAssociation association = new ComponentComputeAssociation();
+ association.setComponentId(COMPONENT_ID);
+ association.setComputeFlavorId("CF1");
+ List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
+ list.add(association);
+ list.add(association);
+ deploymentFlavor.setComponentComputeAssociations(list);
+ expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
+
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ doReturn(vspDetails).when(vspInfoDao).get(anyObject());
+
+ ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, USER);
+ doReturn(component).when(componentDaoMock).get(anyObject());
+
+ ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, "CF1");
+ doReturn(computeEntity).when(computeDaoMock).get(anyObject());
+
+ try {
+ deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
+
+ @Test
+ public void testList() {
+
+ doReturn(Arrays.asList(
+ createDeploymentFlavor(VSP_ID, VERSION, DF1_ID),
+ createDeploymentFlavor(VSP_ID, VERSION, DF2_ID)))
+ .when(deploymentFlavorDaoMock).list(anyObject());
+
+
+ final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION, USER);
+ Assert.assertEquals(deploymentFlavorEntities.size(), 2);
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ Assert.assertEquals(deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel()
+ , DF1_ID.equals(deploymentFlavorEntity.getId()) ? DF1_ID+" name" : DF2_ID+" name" );
+ }
+ }
+
+ @Test
+ public void testUpdateHeatDepFlavor() {
+ testUpdate_negative(VSP_ID, VERSION, DF1_ID, USER,
+ VendorSoftwareProductErrorCodes.EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ }
+
+ @Test
+ public void testUpdateNonExistingManualDepFlavorId_negative() {
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ testUpdate_negative(VSP_ID, VERSION, DF1_ID, USER,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testManualUpdateDepFlavor() {
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ doReturn(createDeploymentFlavor(VSP_ID, VERSION, DF1_ID))
+ .when(deploymentFlavorDaoMock).get(anyObject());
+
+ doReturn(new CompositionEntityValidationData(CompositionEntityType.image, DF1_ID))
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
+
+ VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ doReturn(vspDetails).when(vspInfoDao).get(anyObject());
+
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel(DF1_ID + " name");
+ deploymentFlavor.setDescription(DF1_ID + " desc updated");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+
+ CompositionEntityValidationData validationData =
+ deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity, USER);
+ Assert.assertTrue(validationData == null || validationData.getErrors() == null);
+ verify(deploymentFlavorDaoMock).update(deploymentFlavorEntity);
+ }
+
+ @Test
+ public void testGetNonExistingDepFlavorId_negative() {
+ testGet_negative(VSP_ID, VERSION, "non existing image id", USER,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testGet() {
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
+
+ VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
+ doReturn(vspDetails).when(vspInfoDao).get(anyObject());
+
+ CompositionEntityResponse<DeploymentFlavor> response =
+ deploymentFlavorManager.getDeploymentFlavor(VSP_ID, VERSION, DF1_ID, USER);
+ Assert.assertEquals(response.getId(), expected.getId());
+ Assert.assertEquals(response.getData().getModel(), expected.getDeploymentFlavorCompositionData().
+ getModel());
+ Assert.assertEquals(response.getData().getDescription(), expected.getDeploymentFlavorCompositionData().
+ getDescription());
+ }
+
+ @Test
+ public void testDeleteDepFlavorOnHEAT() {
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
+ testDelete_negative(VSP_ID, VERSION, DF1_ID, USER,
+ VendorSoftwareProductErrorCodes.DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ }
+
+ @Test
+ public void testDeleteOnNotExistImage() {
+ testDelete_negative(VSP_ID, VERSION, DF1_ID, USER,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testDeleteOnManualImage() {
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ deploymentFlavorManager.deleteDeploymentFlavor(VSP_ID, VERSION, DF1_ID, USER);
+ verify(deploymentFlavorDaoMock).delete(anyObject());
+ }
+
+ private void testList_negative(String vspId, Version version, String componentId, String user,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+ deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
+ }
+
+ private void testCreate_negative(DeploymentFlavorEntity deploymentFlavorEntity, String user, String
+ expectedErrorCode) {
+ try {
+ deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private void testDelete_negative(String vspId, Version version, String deploymentFlavorId,
+ String user,
+ String expectedErrorCode) {
+ try {
+ deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ static DeploymentFlavorEntity createDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
+
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel(deploymentFlavorId + " name");
+ deploymentFlavor.setDescription(deploymentFlavorId + " desc");
+
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
+ return deploymentFlavorEntity;
+ }
+
+ private void testUpdate_negative(String vspId, Version version, String
+ deploymentFlavorId, String user, String expectedErrorCode) {
+ try {
+ deploymentFlavorManager
+ .updateDeploymentFlavor(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId), user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private void testGet_negative(String vspId, Version version, String deploymentFlavorId,
+ String user, String expectedErrorCode) {
+ try {
+ deploymentFlavorManager.getDeploymentFlavor(vspId, version, deploymentFlavorId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java
new file mode 100644
index 0000000000..ec676e517b
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java
@@ -0,0 +1,374 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
+public class ImageManagerImplTest {
+
+ private static final String IMAGE_NOT_EXIST_MSG =
+ "Vendor Software Product Image with Id image1 does not exist for Vendor Software Product with" +
+ " " +
+ "id VSP_ID and version 0.1";
+
+ private static final String USER = "imageTestUser";
+ private static final String VSP_ID = "VSP_ID";
+ private static final Version VERSION = new Version(0, 1);
+ private static final String COMPONENT_ID = "COMPONENT_ID";
+ private static final String IMAGE1_ID = "image1";
+ private static final String IMAGE2_ID = "image2";
+
+ @Mock
+ private ImageDao imageDao;
+ @Mock
+ private CompositionEntityDataManager compositionEntityDataManagerMock;
+ @Mock
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ @InjectMocks
+ @Spy
+ private ImageManagerImpl imageManager;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testListWhenNone() {
+ final Collection<ImageEntity> imageEntities =
+ imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID, USER);
+ Assert.assertEquals(imageEntities.size(), 0);
+ }
+
+ @Test
+ public void testList() {
+
+ doReturn(Arrays.asList(
+ createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID),
+ createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE2_ID)))
+ .when(imageDao).list(anyObject());
+
+
+ final Collection<ImageEntity> images =
+ imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID, USER);
+ Assert.assertEquals(images.size(), 2);
+ for (ImageEntity image : images) {
+ Assert.assertEquals(image.getImageCompositionData().getFileName(),
+ IMAGE1_ID.equals(image.getId()) ? IMAGE1_ID+" name" : IMAGE2_ID+" name" );
+ }
+ }
+
+ @Test
+ public void testCreateOnNotManualImage_negative() {
+
+ testCreate_negative(new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, null), USER,
+ VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ }
+
+ @Test
+ public void testCreateManualImage() {
+ ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ imageManager.createImage(expected, USER);
+ verify(compositionEntityDataManagerMock).createImage(expected);
+ verify(compositionEntityDataManagerMock).createImage(expected);
+ }
+
+ @Test
+ public void testCreateManualImageWithDuplicateName() {
+ ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ ImageEntity expectedDiffName = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ Image image = expectedDiffName.getImageCompositionData();
+ image.setFileName(IMAGE1_ID + " Name");
+ expectedDiffName.setImageCompositionData(image);
+ List<ImageEntity> vfcImageList = new ArrayList<ImageEntity>();
+ vfcImageList.add(expectedDiffName);
+ doReturn(vfcImageList).when(imageDao).list(anyObject());
+ try {
+ imageManager.createImage(expected, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_NAME_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
+
+ @Test
+ public void testUpdateNonExistingImageId_negative() {
+ testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testUpdateImage() {
+ doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID))
+ .when(imageDao).get(anyObject());
+
+ doReturn(new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID))
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
+
+ ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ Image imageData = new Image();
+ imageData.setFileName(IMAGE1_ID + " name");
+ imageData.setDescription(IMAGE1_ID + " desc updated");
+ imageEntity.setImageCompositionData(imageData);
+
+ CompositionEntityValidationData validationData =
+ imageManager.updateImage(imageEntity, USER);
+ Assert.assertTrue(validationData == null || validationData.getErrors() == null);
+ verify(imageDao).update(imageEntity);
+ }
+
+ @Test
+ public void testIllegalImageUpdate() {
+ doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID))
+ .when(imageDao).get(anyObject());
+
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ CompositionEntityValidationData toBeReturned =
+ new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID);
+ toBeReturned.setErrors(Arrays.asList("error1", "error2"));
+ doReturn(toBeReturned)
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
+
+ ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ Image imageData = new Image();
+ imageData.setFileName(IMAGE1_ID + " name updated");
+ imageData.setDescription(IMAGE1_ID + " desc updated");
+ imageEntity.setImageCompositionData(imageData);
+
+ CompositionEntityValidationData validationData = imageManager.updateImage(imageEntity, USER);
+ Assert.assertNotNull(validationData);
+ Assert.assertEquals(validationData.getErrors().size(), 2);
+
+ verify(imageDao, never()).update(imageEntity);
+ }
+
+ @Test
+ public void testUpdateHEATImageFileName() throws Exception {
+ doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID))
+ .when(imageDao).get(anyObject());
+ ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ Image imageData = new Image();
+ imageData.setFileName(IMAGE1_ID + " name updated");
+ imageData.setDescription(IMAGE1_ID + " desc updated");
+ imageEntity.setImageCompositionData(imageData);
+
+ try {
+ imageManager.updateImage(imageEntity, USER);
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED);
+ }
+
+ }
+
+ @Test
+ public void testGetNonExistingImageId_negative() {
+ testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing image id", USER,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testGet() {
+ ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ doReturn(expected).when(imageDao).get(anyObject());
+ String compositionSchema = "schema string";
+ doReturn(compositionSchema).when(imageManager).getImageCompositionSchema(anyObject());
+
+ CompositionEntityResponse<Image> response =
+ imageManager.getImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER);
+ Assert.assertEquals(response.getId(), expected.getId());
+ Assert.assertEquals(response.getData().getFileName(), expected.getImageCompositionData().
+ getFileName());
+ Assert.assertEquals(response.getData().getDescription(), expected.getImageCompositionData().
+ getDescription());
+ Assert.assertEquals(response.getSchema(), compositionSchema);
+ }
+
+ @Test
+ public void testDeleteOnNotManualImage() {
+ ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ doReturn(expected).when(imageDao).get(anyObject());
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER,
+ VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED);
+ }
+
+ @Test
+ public void testDeleteOnNotExistImage() {
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testDeleteOnManualImage() {
+ ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ doReturn(expected).when(imageDao).get(anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ imageManager.deleteImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER);
+ verify(imageDao).delete(anyObject());
+ }
+
+ @Test
+ public void testGetQuestionnaire() throws Exception {
+ ImageEntity image = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ image.setQuestionnaireData("{}");
+ doReturn(image).when(imageDao).getQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+
+ String schema = "schema string";
+ doReturn(schema).when(imageManager).getImageQuestionnaireSchema(anyObject());
+
+ QuestionnaireResponse questionnaire =
+ imageManager.getImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER);
+ Assert.assertNotNull(questionnaire);
+ Assert.assertEquals(questionnaire.getData(), image.getQuestionnaireData());
+ Assert.assertEquals(questionnaire.getSchema(), schema);
+ Assert.assertNull(questionnaire.getErrorMessage());
+ }
+
+ @Test
+ public void testUpdateManualImageQuestionnaire() throws Exception {
+ String json = "{\"md5\" :\"FFDSD33SS\"}";
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ doReturn(new ImageEntity()).when(imageDao).get(anyObject());
+
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json, USER);
+ verify(imageDao).updateQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json);
+ }
+
+ @Test
+ public void testUpdateHEATImageQuestionnaireWithFormat() throws Exception {
+ String json = "{\"format\" :\"qcow2\"}";
+ ImageEntity image = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ image.setQuestionnaireData(json);
+ doReturn(image).when(imageDao).get(anyObject());
+
+ doReturn(false).when(vspInfoDao).isManual(anyObject(), anyObject());
+ doReturn(image).when(imageDao).getQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+
+ String updJson = "{\"format\" :\"aki\"}";
+ try {
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson,
+ USER);
+ Assert.fail();
+ }
+ catch(CoreException ex) {
+ Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED);
+ }
+ }
+
+ @Test
+ public void testUpdateHEATImageQuestionnaireWithInvalidFormat() throws Exception {
+ String json = "{\"format\" :\"qcow2\"}";
+ ImageEntity image = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
+ image.setQuestionnaireData(json);
+ doReturn(image).when(imageDao).get(anyObject());
+
+ String updJson = "{\"format\" :\"a22\"}";
+ try {
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson,
+ USER);
+ Assert.fail();
+ }
+ catch(CoreException ex) {
+ Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.VFC_IMAGE_INVALID_FORMAT);
+ }
+ }
+
+ private void testList_negative(String vspId, Version version, String componentId, String user,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+ imageManager.listImages(vspId, version, componentId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
+ }
+
+ private void testCreate_negative(ImageEntity image, String user, String expectedErrorCode) {
+ try {
+ imageManager.createImage(image, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private void testDelete_negative(String vspId, Version version, String componentId, String nicId,
+ String user,
+ String expectedErrorCode) {
+ try {
+ imageManager.deleteImage(vspId, version, componentId, nicId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ static ImageEntity createImage(String vspId, Version version, String compId, String imageId) {
+ ImageEntity imageEntity = new ImageEntity(vspId, version, compId, imageId);
+ Image imageData = new Image();
+ imageData.setFileName(imageId + " name");
+ imageData.setDescription(imageId + " desc");
+ imageEntity.setImageCompositionData(imageData);
+ return imageEntity;
+ }
+
+ private void testUpdate_negative(String vspId, Version version, String componentId, String
+ imageId, String user, String expectedErrorCode) {
+ try {
+ imageManager.updateImage(new ImageEntity(vspId, version, componentId, imageId), user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private void testGet_negative(String vspId, Version version, String componentId, String imageId,
+ String user, String expectedErrorCode) {
+ try {
+ imageManager.getImage(vspId, version, componentId, imageId, user);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java
new file mode 100644
index 0000000000..4bbbec166e
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java
@@ -0,0 +1,562 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import static org.openecomp.sdc.generator.util.GeneratorConstants.ALLOWED_FLAVORS_PROPERTY;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_NODE_TEMPLATE_ID_SUFFIX;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.BINDING_REQUIREMENT_ID;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.COUNT_PROPERTY_NAME;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME;
+import static org.openecomp.sdc.translator.services.heattotosca.Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.sdc.generator.core.utils.GeneratorUtils;
+import org.openecomp.sdc.generator.datatypes.tosca.ComputeFlavor;
+import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
+import org.openecomp.sdc.generator.datatypes.tosca.LicenseFlavor;
+import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
+import org.openecomp.sdc.generator.datatypes.tosca.VendorInfo;
+import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
+import org.openecomp.sdc.generator.util.GeneratorConstants;
+import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
+import org.openecomp.sdc.tosca.datatypes.model.RequirementDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
+import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
+import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ManualVspToscaManagerImplTest {
+
+ private static final String COMPONENT_ID = "Component_id";
+ private static final String COMPONENT_NAME = "Component_name";
+ private static final String SP_PART_NUMBER_1 = "Part_number_123";
+ private static final String FEATURE_GROUP_ID_1 = "Feature_Group_id_1";
+ private static final String MANUFACTURER_REF_1 = "Manufacturer_Ref_1";
+ private static final String VENDOR_MODEL_1 = "VLM_1";
+ private static final int NUM_CPUS_1 = 1;
+ private static final String DISK_SIZE_1 = "2GB";
+ private static final String MEM_SIZE_1 = "8GB";
+
+ private static final String SP_PART_NUMBER_2 = "Part_number_345";
+ private static final String FEATURE_GROUP_ID_2 = "Feature_Group_id_2";
+ private static final String MANUFACTURER_REF_2 = "Manufacturer_Ref_2";
+ private static final String VENDOR_MODEL_2 = "VLM_2";
+ private static final int NUM_CPUS_2 = 4;
+ private static final String DISK_SIZE_2 = "3GB";
+ private static final String MEM_SIZE_2 = "2GB";
+
+ private static final String IMAGE_VERSION_1 = "3.16.1";
+ private static final String IMAGE_HASH_1 = "65edfgye3256hjutve";
+ private static final String IMAGE_FILE_NAME_1 = "image-file-name1";
+ private static final String IMAGE_FILE_FORMAT_1 = "qcow2";
+ private static final String IMAGE_VERSION_2 = "3.1.9";
+ private static final String IMAGE_HASH_2 = "84rtedfe3256hjutaw";
+ private static final String IMAGE_FILE_NAME_2 = "image-file-name1";
+ private static final String IMAGE_FILE_FORMAT_2 = "iso";
+
+ private ManualVspToscaManager manualVspToscaManager = new ManualVspToscaManagerImpl();
+
+ @Test
+ public void testGenerateToscaInvalidVspId() {
+ VspModelInfo emptyVspCollectedData = new VspModelInfo();
+ ToscaServiceModel toscaServiceModel =
+ manualVspToscaManager.generateToscaModel(emptyVspCollectedData);
+ Assert.assertNotNull(toscaServiceModel);
+ Assert.assertNotNull(toscaServiceModel.getServiceTemplates());
+ //Service model should contain only the packed global types
+ Assert.assertEquals(19, toscaServiceModel.getServiceTemplates().size());
+ }
+
+ @Test
+ public void testGenerateToscaNoComponent() {
+ VspModelInfo vspCollectedData = new VspModelInfo();
+ vspCollectedData.setReleaseVendor("Vendor-1");
+ vspCollectedData.setComponents(null);
+ vspCollectedData.setMultiFlavorVfcImages(null);
+ vspCollectedData.setAllowedFlavors(getDeploymentFlavorData());
+ vspCollectedData.setNics(getComponentNics());
+ ToscaServiceModel toscaServiceModel =
+ manualVspToscaManager.generateToscaModel(vspCollectedData);
+ Assert.assertNotNull(toscaServiceModel);
+ Assert.assertNotNull(toscaServiceModel.getServiceTemplates());
+ //Service model should contain only the packed global types
+ Assert.assertEquals(19, toscaServiceModel.getServiceTemplates().size());
+ }
+
+ @Test
+ public void testGenerateToscaReleaseVendorNotPresent() {
+ VspModelInfo vspCollectedData = new VspModelInfo();
+ vspCollectedData.setComponents(getComponentData());
+ vspCollectedData.setMultiFlavorVfcImages(getVfcImageData());
+ vspCollectedData.setAllowedFlavors(getDeploymentFlavorData());
+ vspCollectedData.setNics(getComponentNics());
+ ToscaServiceModel toscaServiceModel =
+ manualVspToscaManager.generateToscaModel(vspCollectedData);
+ Assert.assertNotNull(toscaServiceModel);
+ Assert.assertNotNull(toscaServiceModel.getServiceTemplates());
+ //Service model should contain only the packed global types
+ Assert.assertEquals(22, toscaServiceModel.getServiceTemplates().size());
+ Map<String, ServiceTemplate> serviceTemplates = toscaServiceModel.getServiceTemplates();
+ String entryDefinitionServiceTemplate = toscaServiceModel.getEntryDefinitionServiceTemplate();
+ ServiceTemplate mainServiceTemplate = serviceTemplates.get(entryDefinitionServiceTemplate);
+ Assert.assertNotNull(mainServiceTemplate);
+ Assert.assertNull(mainServiceTemplate.getMetadata().get("releaseVendor"));
+ }
+
+ @Test
+ public void testGenerateToscaNoImages() {
+ VspModelInfo vspCollectedData = new VspModelInfo();
+ vspCollectedData.setComponents(getComponentData());
+ vspCollectedData.setMultiFlavorVfcImages(null);
+ vspCollectedData.setAllowedFlavors(getDeploymentFlavorData());
+ vspCollectedData.setNics(getComponentNics());
+ ToscaServiceModel toscaServiceModel =
+ manualVspToscaManager.generateToscaModel(vspCollectedData);
+ Assert.assertNotNull(toscaServiceModel);
+ Assert.assertNotNull(toscaServiceModel.getServiceTemplates());
+ //Service model should contain only the packed global types
+ Assert.assertEquals(22, toscaServiceModel.getServiceTemplates().size());
+ Map<String, ServiceTemplate> serviceTemplates = toscaServiceModel.getServiceTemplates();
+ String entryDefinitionServiceTemplate = toscaServiceModel.getEntryDefinitionServiceTemplate();
+ ServiceTemplate mainServiceTemplate = serviceTemplates.get(entryDefinitionServiceTemplate);
+ Assert.assertNotNull(mainServiceTemplate);
+ String componentName = vspCollectedData.getComponents().get(COMPONENT_ID);
+ Assert.assertNull(mainServiceTemplate.getTopology_template().getNode_templates()
+ .get(componentName + GeneratorConstants.VFC_NODE_TEMPLATE_ID_SUFFIX)
+ .getProperties());
+ }
+
+ @Test
+ public void testGenerateToscaNoPorts() {
+ VspModelInfo vspCollectedData = new VspModelInfo();
+ vspCollectedData.setComponents(getComponentData());
+ vspCollectedData.setMultiFlavorVfcImages(getVfcImageData());
+ vspCollectedData.setAllowedFlavors(getDeploymentFlavorData());
+ vspCollectedData.setNics(null);
+ ToscaServiceModel toscaServiceModel =
+ manualVspToscaManager.generateToscaModel(vspCollectedData);
+ Assert.assertNotNull(toscaServiceModel);
+ Assert.assertNotNull(toscaServiceModel.getServiceTemplates());
+ //Service model should contain only the packed global types
+ Assert.assertEquals(22, toscaServiceModel.getServiceTemplates().size());
+ Map<String, ServiceTemplate> serviceTemplates = toscaServiceModel.getServiceTemplates();
+ String componentName = vspCollectedData.getComponents().get(COMPONENT_ID);
+ String substitutionServiceTemplateFileName =
+ componentName + GeneratorConstants.TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX;
+ ServiceTemplate substitutionServiceTemplate =
+ serviceTemplates.get(substitutionServiceTemplateFileName);
+ Assert.assertNotNull(substitutionServiceTemplate);
+ //Only component node template should be present since there are no ports
+ Assert.assertEquals(1, substitutionServiceTemplate.getTopology_template().getNode_templates()
+ .size());
+ }
+
+ @Test
+ public void testGenerateToscaNoManufacturerRefNumAndFeatureGroup() {
+ VspModelInfo vspCollectedData = new VspModelInfo();
+ vspCollectedData.setReleaseVendor("Vendor-1");
+ vspCollectedData.setComponents(getComponentData());
+ vspCollectedData.setMultiFlavorVfcImages(getVfcImageData());
+ Map<String, DeploymentFlavorModel> deploymentFlavorData = getDeploymentFlavorData();
+ deploymentFlavorData.get(SP_PART_NUMBER_1).getVendor_info()
+ .setManufacturer_reference_number(null);
+ deploymentFlavorData.get(SP_PART_NUMBER_1).getLicense_flavor().setFeature_group_uuid(null);
+ vspCollectedData.setAllowedFlavors(deploymentFlavorData);
+ vspCollectedData.setNics(getComponentNics());
+ ToscaServiceModel toscaServiceModel =
+ manualVspToscaManager.generateToscaModel(vspCollectedData);
+ Assert.assertNotNull(toscaServiceModel);
+ Assert.assertNotNull(toscaServiceModel.getServiceTemplates());
+ //Service model should contain only the packed global types
+ Assert.assertEquals(22, toscaServiceModel.getServiceTemplates().size());
+ Map<String, ServiceTemplate> serviceTemplates = toscaServiceModel.getServiceTemplates();
+ String entryDefinitionServiceTemplate = toscaServiceModel.getEntryDefinitionServiceTemplate();
+ ServiceTemplate mainServiceTemplate = serviceTemplates.get(entryDefinitionServiceTemplate);
+ Assert.assertNotNull(mainServiceTemplate);
+ String componentName = vspCollectedData.getComponents().get(COMPONENT_ID);
+ Map<String, DeploymentFlavorModel> actualDeploymentFlavor = (Map<String, DeploymentFlavorModel>)
+ mainServiceTemplate.getTopology_template().getNode_templates()
+ .get(componentName + GeneratorConstants.VNF_CONFIG_NODE_TEMPLATE_ID_SUFFIX)
+ .getProperties().get(ALLOWED_FLAVORS_PROPERTY);
+ Assert.assertNull(actualDeploymentFlavor.get(SP_PART_NUMBER_1).getVendor_info()
+ .getManufacturer_reference_number());
+ Assert.assertNull(actualDeploymentFlavor.get(SP_PART_NUMBER_1).getLicense_flavor()
+ .getFeature_group_uuid());
+ }
+
+ @Test
+ public void testGenerateToscaNoDeploymentFlavor() {
+ VspModelInfo vspCollectedData = new VspModelInfo();
+ vspCollectedData.setReleaseVendor("Vendor-1");
+ vspCollectedData.setComponents(getComponentData());
+ vspCollectedData.setMultiFlavorVfcImages(getVfcImageData());
+ vspCollectedData.setAllowedFlavors(null);
+ vspCollectedData.setNics(getComponentNics());
+ ToscaServiceModel toscaServiceModel =
+ manualVspToscaManager.generateToscaModel(vspCollectedData);
+ Assert.assertNotNull(toscaServiceModel);
+ Assert.assertNotNull(toscaServiceModel.getServiceTemplates());
+ //Service model should contain only the packed global types
+ Assert.assertEquals(22, toscaServiceModel.getServiceTemplates().size());
+ Map<String, ServiceTemplate> serviceTemplates = toscaServiceModel.getServiceTemplates();
+ String entryDefinitionServiceTemplate = toscaServiceModel.getEntryDefinitionServiceTemplate();
+ ServiceTemplate mainServiceTemplate = serviceTemplates.get(entryDefinitionServiceTemplate);
+ Assert.assertNotNull(mainServiceTemplate);
+ String componentName = vspCollectedData.getComponents().get(COMPONENT_ID);
+ Assert.assertNull(mainServiceTemplate.getTopology_template().getNode_templates()
+ .get(componentName + GeneratorConstants.VNF_CONFIG_NODE_TEMPLATE_ID_SUFFIX)
+ .getProperties());
+ }
+
+ @Test
+ public void testGenerateToscaCompleteData() {
+ VspModelInfo vspCollectedData = new VspModelInfo();
+ vspCollectedData.setReleaseVendor("Vendor-1");
+ vspCollectedData.setComponents(getComponentData());
+ vspCollectedData.setMultiFlavorVfcImages(getVfcImageData());
+ vspCollectedData.setAllowedFlavors(getDeploymentFlavorData());
+ vspCollectedData.setNics(getComponentNics());
+ ToscaServiceModel toscaServiceModel =
+ manualVspToscaManager.generateToscaModel(vspCollectedData);
+ Assert.assertNotNull(toscaServiceModel);
+ Assert.assertNotNull(toscaServiceModel.getServiceTemplates());
+ //Service model should contain only the packed global types
+ Assert.assertEquals(22, toscaServiceModel.getServiceTemplates().size());
+ Map<String, ServiceTemplate> serviceTemplates = toscaServiceModel.getServiceTemplates();
+ String entryDefinitionServiceTemplate = toscaServiceModel.getEntryDefinitionServiceTemplate();
+ ServiceTemplate mainServiceTemplate = serviceTemplates.get(entryDefinitionServiceTemplate);
+ Assert.assertNotNull(mainServiceTemplate);
+ String componentName = vspCollectedData.getComponents().get(COMPONENT_ID);
+
+ Assert.assertNotNull(mainServiceTemplate.getTopology_template().getNode_templates()
+ .get(componentName + GeneratorConstants.VFC_NODE_TEMPLATE_ID_SUFFIX));
+ Assert.assertNotNull(mainServiceTemplate.getTopology_template().getNode_templates()
+ .get(componentName + GeneratorConstants.VNF_NODE_TEMPLATE_ID_SUFFIX));
+ //Validate vnf configuration node template
+ validateVnfConfigurationNodeTemplate(mainServiceTemplate, componentName);
+ //Validate vfc node template
+ validateVfcNodeTemplateinMainServiceTemplate(mainServiceTemplate, componentName);
+ //Validate vnf node template
+ validateVnfNodeTemplate(mainServiceTemplate, componentName);
+
+ //Validate substitution service template
+ ServiceTemplate substitutionServiceTemplate = toscaServiceModel.getServiceTemplates()
+ .get(componentName + GeneratorConstants.TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX);
+ List<Nic> nics = vspCollectedData.getNics().get(COMPONENT_ID);
+ validateSubstitutionServiceTemplate(substitutionServiceTemplate, nics, componentName);
+
+ //Validate global substitution service template
+ ServiceTemplate globalSubstitutionServiceTemplate = toscaServiceModel.getServiceTemplates()
+ .get(ToscaUtil.getServiceTemplateFileName(GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME));
+ validateGlobalSubstitutionServiceTemplate(globalSubstitutionServiceTemplate, nics,
+ componentName);
+ }
+
+ private void validateVnfConfigurationNodeTemplate(ServiceTemplate mainServiceTemplate,
+ String componentName) {
+ NodeTemplate vnfConfigNodeTemplate =
+ mainServiceTemplate.getTopology_template().getNode_templates()
+ .get(componentName + GeneratorConstants.VNF_CONFIG_NODE_TEMPLATE_ID_SUFFIX);
+ Assert.assertNotNull(vnfConfigNodeTemplate);
+ Assert.assertEquals(ToscaNodeType.VNF_CONFIG_NODE_TYPE, vnfConfigNodeTemplate.getType());
+ Map<String, DeploymentFlavorModel> allowedFlavors = (Map<String, DeploymentFlavorModel>)
+ vnfConfigNodeTemplate.getProperties().get(GeneratorConstants.ALLOWED_FLAVORS_PROPERTY);
+ Map<String, DeploymentFlavorModel> deploymentFlavorData = getDeploymentFlavorData();
+ Assert.assertNotNull(allowedFlavors);
+ Assert.assertEquals(deploymentFlavorData.size(), allowedFlavors.size());
+ Assert.assertEquals(deploymentFlavorData, allowedFlavors);
+ }
+
+ private void validateVfcNodeTemplateinMainServiceTemplate(ServiceTemplate mainServiceTemplate,
+ String componentName) {
+ NodeTemplate vfcNodeTemplate =
+ mainServiceTemplate.getTopology_template().getNode_templates()
+ .get(componentName + GeneratorConstants.VFC_NODE_TEMPLATE_ID_SUFFIX);
+ Assert.assertNotNull(vfcNodeTemplate);
+ Assert.assertEquals(ToscaNodeType.MULTIFLAVOR_VFC_NODE_TYPE, vfcNodeTemplate.getType());
+ Map<String, MultiFlavorVfcImage> vfcImages = (Map<String, MultiFlavorVfcImage>)
+ vfcNodeTemplate.getProperties().get(GeneratorConstants.IMAGES_PROPERTY);
+ Assert.assertNotNull(vfcImages);
+ Assert.assertEquals(2, vfcImages.size());
+ MultiFlavorVfcImage image1 = vfcImages.get(IMAGE_VERSION_1);
+ MultiFlavorVfcImage expectedImage1 = getImageData(IMAGE_VERSION_1, IMAGE_HASH_1,
+ IMAGE_FILE_NAME_1, "md5", IMAGE_FILE_FORMAT_1);
+ Assert.assertEquals(expectedImage1, image1);
+ MultiFlavorVfcImage image2 = vfcImages.get(IMAGE_VERSION_2);
+ MultiFlavorVfcImage expectedImage2 = getImageData(IMAGE_VERSION_2, IMAGE_HASH_2,
+ IMAGE_FILE_NAME_2, "md5", IMAGE_FILE_FORMAT_2);
+ Assert.assertEquals(expectedImage2, image2);
+ }
+
+ private void validateVnfNodeTemplate(ServiceTemplate mainServiceTemplate,
+ String componentName) {
+ NodeTemplate vnfNodeTemplate =
+ mainServiceTemplate.getTopology_template().getNode_templates()
+ .get(componentName + GeneratorConstants.VNF_NODE_TEMPLATE_ID_SUFFIX);
+ Assert.assertNotNull(vnfNodeTemplate);
+ Assert.assertEquals(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE + "." + componentName,
+ vnfNodeTemplate.getType());
+ Assert.assertNotNull(vnfNodeTemplate.getDirectives());
+ Assert.assertEquals(true, vnfNodeTemplate.getDirectives().contains(ToscaConstants
+ .NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE));
+
+ Map<String, Object> serviceTemplateFilterProperty = (Map<String, Object>) vnfNodeTemplate
+ .getProperties().get(SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
+ Assert.assertNotNull(serviceTemplateFilterProperty);
+ String substituteServiceTemplate = serviceTemplateFilterProperty
+ .get(SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME).toString();
+ String expectedServiceTemplateName = componentName + GeneratorConstants
+ .TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX;
+ Assert.assertEquals(expectedServiceTemplateName, substituteServiceTemplate);
+ int count = (int) serviceTemplateFilterProperty.get(COUNT_PROPERTY_NAME);
+ Assert.assertEquals(1, count);
+ }
+
+ private void validateSubstitutionServiceTemplate(ServiceTemplate substitutionServiceTemplate,
+ List<Nic> nics,
+ String componentName) {
+ Assert.assertNotNull(substitutionServiceTemplate);
+ int expectedNumberOfNodeTemplates = nics.size() + 1; //1 component node template
+ Map<String, NodeTemplate> substitutionNodeTemplates =
+ substitutionServiceTemplate.getTopology_template().getNode_templates();
+ Assert.assertEquals(expectedNumberOfNodeTemplates, substitutionNodeTemplates.size());
+ NodeTemplate componentNodeTemplate = substitutionNodeTemplates.get(componentName);
+ Assert.assertNotNull(componentNodeTemplate);
+ Assert.assertEquals(ToscaNodeType.VFC_NODE_TYPE_PREFIX + componentName, componentNodeTemplate
+ .getType());
+ for (Nic nic : nics) {
+ String nicName = nic.getName();
+ NodeTemplate nicNodeTemplate =
+ substitutionNodeTemplates.get(nicName + PORT_NODE_TEMPLATE_ID_SUFFIX);
+ validateNicNodeTemplate(nicNodeTemplate, componentName);
+ }
+ SubstitutionMapping substitutionMappings =
+ substitutionServiceTemplate.getTopology_template().getSubstitution_mappings();
+ validateSubstitutionMappings(substitutionMappings, nics, componentName);
+ }
+
+ private void validateNicNodeTemplate(NodeTemplate nicNodeTemplate,
+ String componentName) {
+ Assert.assertNotNull(nicNodeTemplate);
+ Assert.assertEquals(ToscaNodeType.NETWORK_PORT, nicNodeTemplate.getType());
+ List<Map<String, RequirementAssignment>> nicNodeTemplateRequirements =
+ nicNodeTemplate.getRequirements();
+ Assert.assertNotNull(nicNodeTemplateRequirements);
+ Assert.assertEquals(1, nicNodeTemplateRequirements.size());
+ RequirementAssignment expectedRequirementAssignment = new RequirementAssignment();
+ expectedRequirementAssignment.setCapability(ToscaCapabilityType.NATIVE_NETWORK_BINDABLE);
+ expectedRequirementAssignment.setRelationship(ToscaRelationshipType.NATIVE_NETWORK_BINDS_TO);
+ expectedRequirementAssignment.setNode(componentName);
+ Assert.assertEquals(true, new ToscaAnalyzerServiceImpl()
+ .isRequirementExistInNodeTemplate(nicNodeTemplate, BINDING_REQUIREMENT_ID,
+ expectedRequirementAssignment));
+ }
+
+ private void validateSubstitutionMappings(SubstitutionMapping substitutionMappings,
+ List<Nic> nics,
+ String componentName) {
+ Assert.assertEquals(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE + "." + componentName,
+ substitutionMappings.getNode_type());
+ Map<String, List<String>> capabilities = substitutionMappings.getCapabilities();
+ validateSubstitutionCapabilities(capabilities, componentName);
+ Map<String, List<String>> requirements = substitutionMappings.getRequirements();
+ validateSubstitutionRequirements(requirements, nics);
+ }
+
+ private void validateSubstitutionCapabilities(Map<String, List<String>> capabilities,
+ String componentName) {
+ List<String> supportedCapabilities = GeneratorUtils.supportedCapabilities;
+ Assert.assertEquals(supportedCapabilities.size(), capabilities.size());
+ for (String capability : supportedCapabilities) {
+ String expectedCapabilityId = capability + "_" + componentName;
+ Assert.assertEquals(true, capabilities.containsKey(expectedCapabilityId));
+ List<String> expectedCapabilityValue = new ArrayList<>(2);
+ expectedCapabilityValue.add(componentName);
+ expectedCapabilityValue.add(capability);
+ List<String> actualCapabilityValue = capabilities.get(expectedCapabilityId);
+ Assert.assertEquals(expectedCapabilityValue, actualCapabilityValue);
+ }
+ }
+
+ private void validateSubstitutionRequirements(Map<String, List<String>> requirements,
+ List<Nic> nics) {
+ List<String> supportedRequirements = GeneratorUtils.supportedRequirements;
+ for(Nic nic : nics) {
+ String nicNodeTemplateId = nic.getName() + PORT_NODE_TEMPLATE_ID_SUFFIX;
+ for (String requirement : supportedRequirements) {
+ String expectedRequirementId = requirement + "_" + nicNodeTemplateId;
+ Assert.assertEquals(true, requirements.containsKey(expectedRequirementId));
+ List<String> expectedRequirementValue = new ArrayList<>(2);
+ expectedRequirementValue.add(nicNodeTemplateId);
+ expectedRequirementValue.add(requirement);
+ List<String> actualRequirementValue = requirements.get(expectedRequirementId);
+ Assert.assertEquals(expectedRequirementValue, actualRequirementValue);
+ }
+ }
+ }
+
+ private void validateGlobalSubstitutionServiceTemplate(ServiceTemplate
+ globalSubstitutionServiceTemplate,
+ List<Nic> nics,
+ String componentName) {
+ Assert.assertNotNull(globalSubstitutionServiceTemplate);
+ Map<String, NodeType> nodeTypes = globalSubstitutionServiceTemplate.getNode_types();
+ Assert.assertEquals(1, nodeTypes.size());
+ NodeType deploymentFlavorNodeType =
+ nodeTypes.get(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE + "." + componentName);
+ Assert.assertNotNull(deploymentFlavorNodeType);
+ Map<String, PropertyDefinition> properties = deploymentFlavorNodeType.getProperties();
+ Assert.assertNotNull(properties);
+ PropertyDefinition numCpusProperty = properties.get(GeneratorConstants.NUM_CPUS);
+ Assert.assertNotNull(numCpusProperty);
+ Assert.assertEquals(PropertyType.INTEGER.getDisplayName(), numCpusProperty.getType());
+ Assert.assertEquals(true, numCpusProperty.getRequired());
+
+ PropertyDefinition diskSizeProperty = properties.get(GeneratorConstants.DISK_SIZE);
+ Assert.assertNotNull(diskSizeProperty);
+ Assert.assertEquals(PropertyType.SCALAR_UNIT_SIZE.getDisplayName(), diskSizeProperty.getType());
+ Assert.assertEquals(true, diskSizeProperty.getRequired());
+
+ PropertyDefinition memSizeProperty = properties.get(GeneratorConstants.MEM_SIZE);
+ Assert.assertNotNull(memSizeProperty);
+ Assert.assertEquals(PropertyType.SCALAR_UNIT_SIZE.getDisplayName(), memSizeProperty.getType());
+ Assert.assertEquals(true, memSizeProperty.getRequired());
+
+ List<Map<String, RequirementDefinition>> requirements =
+ deploymentFlavorNodeType.getRequirements();
+ List<String> supportedRequirements = GeneratorUtils.supportedRequirements;
+ for (Nic nic : nics) {
+ boolean found = false;
+ String nicNodeTemplateId = nic.getName() + PORT_NODE_TEMPLATE_ID_SUFFIX;
+ for (String requirementId : supportedRequirements) {
+ String expectedRequirementId = requirementId + "_" + nicNodeTemplateId;
+ for (Map<String, RequirementDefinition> requirement : requirements) {
+ if (requirement.containsKey(expectedRequirementId)) {
+ found = true;
+ break;
+ }
+ }
+ }
+ Assert.assertEquals(true, found);
+ }
+
+ Map<String, CapabilityDefinition> capabilities = deploymentFlavorNodeType.getCapabilities();
+ List<String> supportedCapabilities = GeneratorUtils.supportedCapabilities;
+ for (String capabilityId : supportedCapabilities) {
+ String expectedCapabilityId = capabilityId + "_" + componentName;
+ Assert.assertEquals (true, capabilities.containsKey(expectedCapabilityId));
+ }
+ }
+
+ private Map<String, String> getComponentData() {
+ Map<String, String> componentData = new HashMap<>();
+ componentData.put(COMPONENT_ID, COMPONENT_NAME);
+ return componentData;
+ }
+
+ private Map<String, List<MultiFlavorVfcImage>> getVfcImageData() {
+ Map<String, List<MultiFlavorVfcImage>> imageData = new HashMap<>();
+ List<MultiFlavorVfcImage> images = new ArrayList<>(2);
+ MultiFlavorVfcImage image1 = getImageData(IMAGE_VERSION_1, IMAGE_HASH_1, IMAGE_FILE_NAME_1,
+ "md5", IMAGE_FILE_FORMAT_1);
+ MultiFlavorVfcImage image2 = getImageData(IMAGE_VERSION_2, IMAGE_HASH_2, IMAGE_FILE_NAME_2,
+ "md5", IMAGE_FILE_FORMAT_2);
+ images.add(image1);
+ images.add(image2);
+ imageData.put(COMPONENT_ID, images);
+ return imageData;
+ }
+
+ private Map<String, DeploymentFlavorModel> getDeploymentFlavorData() {
+ Map<String, DeploymentFlavorModel> deploymentFlavorData = new HashMap<>();
+ ComputeFlavor computeFlavor1 = getComputeFlavorData(NUM_CPUS_1, DISK_SIZE_1, MEM_SIZE_1);
+ LicenseFlavor licenseFlavor1 = getLicenseFlavor(FEATURE_GROUP_ID_1);
+ VendorInfo vendorInfo1 = getVendorInfo(MANUFACTURER_REF_1, VENDOR_MODEL_1);
+ DeploymentFlavorModel deploymentFlavor1 = getDeploymentFlavorModel(SP_PART_NUMBER_1,
+ computeFlavor1, vendorInfo1, licenseFlavor1);
+
+ ComputeFlavor computeFlavor2 = getComputeFlavorData(NUM_CPUS_2, DISK_SIZE_2, MEM_SIZE_2);
+ LicenseFlavor licenseFlavor2 = getLicenseFlavor(FEATURE_GROUP_ID_2);
+ VendorInfo vendorInfo2 = getVendorInfo(MANUFACTURER_REF_2, VENDOR_MODEL_2);
+
+ DeploymentFlavorModel deploymentFlavor2 = getDeploymentFlavorModel(SP_PART_NUMBER_2,
+ computeFlavor2, vendorInfo2, licenseFlavor2);
+
+ deploymentFlavorData.put(SP_PART_NUMBER_1, deploymentFlavor1);
+ deploymentFlavorData.put(SP_PART_NUMBER_2, deploymentFlavor2);
+ return deploymentFlavorData;
+ }
+
+ private DeploymentFlavorModel getDeploymentFlavorModel(String spPartNumber, ComputeFlavor
+ computeFlavor, VendorInfo vendorInfo, LicenseFlavor licenseFlavor) {
+ DeploymentFlavorModel deploymentFlavor = new DeploymentFlavorModel();
+ deploymentFlavor.setSp_part_number(spPartNumber);
+ deploymentFlavor.setCompute_flavor(computeFlavor);
+ deploymentFlavor.setLicense_flavor(licenseFlavor);
+ deploymentFlavor.setVendor_info(vendorInfo);
+ return deploymentFlavor;
+ }
+
+ private ComputeFlavor getComputeFlavorData(int numCpus, String diskSize, String memSize ) {
+ ComputeFlavor computeFlavor = new ComputeFlavor();
+ computeFlavor.setNum_cpus(numCpus);
+ computeFlavor.setDisk_size(diskSize);
+ computeFlavor.setMem_size(memSize);
+ return computeFlavor;
+ }
+
+ private VendorInfo getVendorInfo(String manufacturerRefNumber, String vlmId) {
+ VendorInfo vendorInfo = new VendorInfo();
+ vendorInfo.setManufacturer_reference_number(manufacturerRefNumber);
+ vendorInfo.setVendor_model(vlmId);
+ return vendorInfo;
+ }
+
+ private LicenseFlavor getLicenseFlavor(String featureGroupId) {
+ LicenseFlavor licenseFlavor = new LicenseFlavor();
+ licenseFlavor.setFeature_group_uuid(featureGroupId);
+ return licenseFlavor;
+ }
+
+ private MultiFlavorVfcImage getImageData(String imageVersion, String fileHash, String fileName,
+ String fileHashType, String fileFormat) {
+ MultiFlavorVfcImage image = new MultiFlavorVfcImage();
+ image.setSoftware_version(imageVersion);
+ image.setFile_hash(fileHash);
+ image.setFile_hash_type(fileHashType);
+ image.setFile_name(fileName+"-"+IMAGE_VERSION_2+"."+fileFormat);
+ return image;
+ }
+
+ private Map<String, List<Nic>> getComponentNics() {
+ Map<String, List<Nic>> nicData = new HashMap<>();
+ List<Nic> nicList = new ArrayList<>(2);
+ Nic nic1 = new Nic();
+ nic1.setName("Nic_1");
+
+ Nic nic2 = new Nic();
+ nic2.setName("Nic_2");
+
+ nicList.add(nic1);
+ nicList.add(nic2);
+ nicData.put(COMPONENT_ID, nicList);
+ return nicData;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImplTest.java
deleted file mode 100644
index 54e979cdaf..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImplTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.impl;
-
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.core.enrichment.types.ArtifactType;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Optional;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
-public class MibManagerImplTest {
-
- private static final String USER1 = "ComponentsUploadTestUser";
- private static final String COMPONENT_ID = "COMPONENT_ID";
- private static final String VSP_ID = "vspId";
- private static final Version VERSION = new Version(0, 1);
- private static final String trapFileName = "MMSC.zip";
- private static final String pollFileName = "MNS OAM FW.zip";
- private static final String notZipFileName = "notZipFile";
- private static final String zipWithFoldersFileName = "zipFileWithFolder.zip";
- private static final String emptyZipFileName = "emptyZip.zip";
- private static final String ZIP_DIR = "/vspmanager/zips/";
-
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
- private MibDao mibDaoMock;
- @InjectMocks
- private MibManagerImpl mibManager;
-
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test(expectedExceptions = CoreException.class)
- public void testUploadEmptyZip() {
- InputStream zis = getFileInputStream(ZIP_DIR + emptyZipFileName);
- mibManager.upload(zis, emptyZipFileName, VSP_ID, VERSION, COMPONENT_ID,
- ArtifactType.SNMP_TRAP, USER1);
- }
-
- @Test
- public void testUploadInvalidZip() {
- URL url = this.getClass().getResource("/notZipFile");
- try {
- mibManager
- .upload(url.openStream(), notZipFileName, VSP_ID, VERSION, COMPONENT_ID,
- ArtifactType.SNMP_TRAP, USER1);
- Assert.fail();
- } catch (Exception exception) {
- Assert.assertEquals(exception.getMessage(), "Invalid zip file");
- }
- }
-
- @Test
- public void testUploadZipWithFolders() {
- InputStream zis = getFileInputStream(ZIP_DIR + zipWithFoldersFileName);
-
- try {
- mibManager
- .upload(zis, zipWithFoldersFileName, VSP_ID, VERSION, COMPONENT_ID,
- ArtifactType.SNMP_TRAP, USER1);
- Assert.fail();
- } catch (Exception exception) {
- Assert.assertEquals(exception.getMessage(), "Zip file should not contain folders");
- }
- }
-
-
- @Test
- public void testListMibFilenames() {
- MibEntity artifact1 =
- new MibEntity(VSP_ID, VERSION, COMPONENT_ID, "artifact1");
- artifact1.setType(ArtifactType.SNMP_TRAP);
- artifact1.setArtifactName(trapFileName);
-
- MibEntity artifact2 =
- new MibEntity(VSP_ID, VERSION, COMPONENT_ID, "artifact2");
- artifact2.setType(ArtifactType.SNMP_POLL);
- artifact2.setArtifactName(pollFileName);
-
- doReturn(Arrays.asList(artifact1, artifact2))
- .when(mibDaoMock).list(anyObject());
-
- MibUploadStatus mibUploadStatus =
- mibManager.listFilenames(VSP_ID, VERSION, COMPONENT_ID, USER1);
-
- Assert.assertEquals(mibUploadStatus.getSnmpTrap(), trapFileName);
- Assert.assertEquals(mibUploadStatus.getSnmpPoll(), pollFileName);
- }
-
- @Test (expectedExceptions = CoreException.class)
- public void testDeleteComponentMibWhenNone() {
- doReturn(Optional.empty()).when(mibDaoMock).getByType(any());
- mibManager.delete(VSP_ID, VERSION, COMPONENT_ID, ArtifactType.SNMP_POLL, USER1);
-
- verify(mibDaoMock, never()).delete(anyObject());
- }
-
- @Test
- public void testDeleteComponentMib() {
- doReturn(Optional.of(new MibEntity(VSP_ID, VERSION, COMPONENT_ID, "artifactId"))).when
- (mibDaoMock).getByType(anyObject());
-
- mibManager.delete(VSP_ID, VERSION, COMPONENT_ID, ArtifactType.SNMP_POLL, USER1);
-
- verify(mibDaoMock).delete(anyObject());
- }
-
-
- private InputStream getFileInputStream(String fileName) {
- URL url = this.getClass().getResource(fileName);
- try {
- return url.openStream();
- } catch (IOException exception) {
- exception.printStackTrace();
- return null;
- }
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
new file mode 100644
index 0000000000..534c630e40
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
@@ -0,0 +1,164 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.core.enrichment.types.MonitoringUploadType;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Optional;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
+public class MonitoringUploadsManagerImplTest {
+
+ private static final String USER1 = "ComponentsUploadTestUser";
+ private static final String COMPONENT_ID = "COMPONENT_ID";
+ private static final String VSP_ID = "vspId";
+ private static final Version VERSION = new Version(0, 1);
+ private static final String trapFileName = "MMSC.zip";
+ private static final String pollFileName = "MNS OAM FW.zip";
+ private static final String vesFileName = "vesTest-yml_only.zip";
+ private static final String invalidVesFileName = "invalid_ves_file.zip";
+ private static final String notZipFileName = "notZipFile";
+ private static final String zipWithFoldersFileName = "zipFileWithFolder.zip";
+ private static final String emptyZipFileName = "emptyZip.zip";
+ private static final String ZIP_DIR = "/vspmanager/zips/";
+
+ @Mock
+ private ComponentArtifactDao componentArtifactDaoMock;
+ @InjectMocks
+ private MonitoringUploadsManagerImpl moitoringUploadsManager;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test(expectedExceptions = CoreException.class)
+ public void testUploadEmptyZip() {
+ InputStream zis = getFileInputStream(ZIP_DIR + emptyZipFileName);
+ moitoringUploadsManager.upload(zis, emptyZipFileName, VSP_ID, VERSION, COMPONENT_ID,
+ MonitoringUploadType.SNMP_TRAP, USER1);
+ }
+
+ @Test
+ public void testUploadInvalidZip() {
+ URL url = this.getClass().getResource("/notZipFile");
+ try {
+ moitoringUploadsManager
+ .upload(url.openStream(), notZipFileName, VSP_ID, VERSION, COMPONENT_ID,
+ MonitoringUploadType.VES_EVENTS, USER1);
+ Assert.fail();
+ } catch (Exception exception) {
+ Assert.assertEquals(exception.getMessage(), "Invalid zip file");
+ }
+ }
+
+ @Test
+ public void testUploadZipWithFolders() {
+ InputStream zis = getFileInputStream(ZIP_DIR + zipWithFoldersFileName);
+
+ try {
+ moitoringUploadsManager
+ .upload(zis, zipWithFoldersFileName, VSP_ID, VERSION, COMPONENT_ID,
+ MonitoringUploadType.SNMP_TRAP, USER1);
+ Assert.fail();
+ } catch (Exception exception) {
+ Assert.assertEquals(exception.getMessage(), "Zip file should not contain folders");
+ }
+ }
+
+ @Test
+ public void testUploadVEsEventZipWithNonYamlFiles() {
+ InputStream zis = getFileInputStream(ZIP_DIR + invalidVesFileName);
+
+ try {
+ moitoringUploadsManager
+ .upload(zis, invalidVesFileName, VSP_ID, VERSION, COMPONENT_ID,
+ MonitoringUploadType.VES_EVENTS, USER1);
+ Assert.fail();
+ } catch (Exception exception) {
+ Assert.assertEquals(exception.getMessage(),
+ "Wrong VES EVENT Artifact was uploaded - all files contained in Artifact must be YAML " +
+ "files (using .yaml/.yml extensions)");
+ }
+ }
+
+
+ @Test
+ public void testListMonitoringFilenames() {
+ ComponentMonitoringUploadEntity artifact1 =
+ new ComponentMonitoringUploadEntity(VSP_ID, VERSION, COMPONENT_ID, "artifact1");
+ artifact1.setType(MonitoringUploadType.SNMP_TRAP);
+ artifact1.setArtifactName(trapFileName);
+
+ ComponentMonitoringUploadEntity artifact2 =
+ new ComponentMonitoringUploadEntity(VSP_ID, VERSION, COMPONENT_ID, "artifact2");
+ artifact2.setType(MonitoringUploadType.SNMP_POLL);
+ artifact2.setArtifactName(pollFileName);
+
+ ComponentMonitoringUploadEntity artifact3 =
+ new ComponentMonitoringUploadEntity(VSP_ID, VERSION, COMPONENT_ID, "artifact3");
+ artifact3.setType(MonitoringUploadType.VES_EVENTS);
+ artifact3.setArtifactName(vesFileName);
+
+ doReturn(Arrays.asList(artifact1, artifact2, artifact3))
+ .when(componentArtifactDaoMock).list(anyObject());
+
+ MonitoringUploadStatus monitoringUploadStatus =
+ moitoringUploadsManager.listFilenames(VSP_ID, VERSION, COMPONENT_ID, USER1);
+
+ Assert.assertEquals(monitoringUploadStatus.getSnmpTrap(), trapFileName);
+ Assert.assertEquals(monitoringUploadStatus.getSnmpPoll(), pollFileName);
+ Assert.assertEquals(monitoringUploadStatus.getVesEvent(), vesFileName);
+ }
+
+ @Test (expectedExceptions = CoreException.class)
+ public void testDeleteComponentMibWhenNone() {
+ doReturn(Optional.empty()).when(componentArtifactDaoMock).getByType(any());
+ moitoringUploadsManager
+ .delete(VSP_ID, VERSION, COMPONENT_ID, MonitoringUploadType.SNMP_POLL, USER1);
+
+ verify(componentArtifactDaoMock, never()).delete(anyObject());
+ }
+
+ @Test
+ public void testDeleteComponentMonitoringUpload() {
+ doReturn(Optional
+ .of(new ComponentMonitoringUploadEntity(VSP_ID, VERSION, COMPONENT_ID, "artifactId")))
+ .when
+ (componentArtifactDaoMock).getByType(anyObject());
+
+ moitoringUploadsManager
+ .delete(VSP_ID, VERSION, COMPONENT_ID, MonitoringUploadType.SNMP_POLL, USER1);
+
+ verify(componentArtifactDaoMock).delete(anyObject());
+ }
+
+
+ private InputStream getFileInputStream(String fileName) {
+ URL url = this.getClass().getResource(fileName);
+ try {
+ return url.openStream();
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java
index a143fd36e8..b2cfba7672 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java
@@ -7,14 +7,17 @@ import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
@@ -22,6 +25,7 @@ import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -29,6 +33,7 @@ import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class NicManagerImplTest {
private static final String NIC_NOT_EXIST_MSG =
@@ -50,6 +55,8 @@ public class NicManagerImplTest {
private CompositionEntityDataManager compositionEntityDataManagerMock;
@Mock
private NetworkManager networkManagerMock;
+ @Mock
+ private VendorSoftwareProductInfoDao vspInfoDao;
@InjectMocks
@Spy
private NicManagerImpl nicManager;
@@ -87,6 +94,112 @@ public class NicManagerImplTest {
}
}
+ @Test
+ public void testCreate() {
+ NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
+ Nic nic = nicEntity.getNicCompositionData();
+ nic.setNetworkType(NetworkType.Internal);
+ nicEntity.setNicCompositionData(nic);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ Collection<NicEntity> nicEntities = new ArrayList<>();
+ doReturn(nicEntities).when(nicDao).list(anyObject());
+ doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
+
+ NicEntity created = nicManager.createNic(nicEntity,USER);
+ Assert.assertNotNull(created);
+ }
+
+ @Test
+ public void testCreateWithDupNicName() {
+ NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
+ Nic nic = nicEntity.getNicCompositionData();
+ nic.setNetworkType(NetworkType.Internal);
+ nicEntity.setNicCompositionData(nic);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ Collection<NicEntity> nicEntities = new ArrayList<>();
+
+ NicEntity nicEntityDiffName = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
+ Nic newNameNic = nicEntityDiffName.getNicCompositionData();
+ newNameNic.setName(NIC1_ID + " Name");
+ nicEntityDiffName.setNicCompositionData(newNameNic);
+ nicEntities.add(nicEntityDiffName);
+ doReturn(nicEntities).when(nicDao).list(anyObject());
+ doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
+
+ try {
+ NicEntity created = nicManager.createNic(nicEntity,USER);
+ } catch (CoreException exception) {
+ Assert.assertEquals("Invalid request, NIC with name "+ nic.getName() +
+ " already exist for component with ID "+ nicEntity.getComponentId() +".",
+ exception.code().message());
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_NIC_NAME_NOT_ALLOWED,
+ exception.code().id());
+ }
+ }
+
+ @Test
+ public void testCreateWithExternalNetworkType() {
+ NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
+ Nic nic = nicEntity.getNicCompositionData();
+ nic.setNetworkType(NetworkType.External);
+ nicEntity.setNicCompositionData(nic);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ Collection<NicEntity> nicEntities = new ArrayList<>();
+ doReturn(nicEntities).when(nicDao).list(anyObject());
+ doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
+
+ try {
+ NicEntity created = nicManager.createNic(nicEntity,USER);
+ } catch (CoreException exception) {
+ Assert.assertEquals("Invalid request,NetworkId not allowed for External Networks",
+ exception.code().message());
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK,
+ exception.code().id());
+ }
+ }
+
+ @Test
+ public void testCreateWithNetworkDesc() {
+ NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
+ Nic nic = nicEntity.getNicCompositionData();
+ nic.setNetworkType(NetworkType.Internal);
+ nic.setNetworkDescription(NIC1_ID);
+ nicEntity.setNicCompositionData(nic);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ Collection<NicEntity> nicEntities = new ArrayList<>();
+ doReturn(nicEntities).when(nicDao).list(anyObject());
+ doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
+
+ try {
+ NicEntity created = nicManager.createNic(nicEntity,USER);
+ } catch (CoreException exception) {
+ Assert.assertEquals("Invalid request, Network Description not allowed for Internal Networks",
+ exception.code().message());
+ Assert.assertEquals(VendorSoftwareProductErrorCodes
+ .NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK,exception.code().id());
+ }
+ }
+
+ @Test
+ public void testDeleteNic() {
+ NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(nicEntity).when(nicDao).get(anyObject());
+
+ nicManager.deleteNic(VSP_ID,new Version(0,1),COMPONENT_ID,NIC1_ID,USER);
+
+ }
+
+ @Test
+ public void testUpdateNicQuestionnaire() {
+ NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
+
+ doReturn(nicEntity).when(nicDao).get(anyObject());
+
+ nicManager.updateNicQuestionnaire(VSP_ID,new Version(0,1),COMPONENT_ID,NIC1_ID,"Ques",USER);
+
+ }
+
// @Test(dependsOnMethods = "testListWhenNone")
// public void testCreate() {
// NIC1_ID = testCreate(VSP_ID, COMPONENT_ID, NETWORK1_ID, NETWORK1_ID.getNetworkCompositionData().getName());
@@ -122,7 +235,7 @@ public class NicManagerImplTest {
public void testCreateOnUploadVsp_negative() {
testCreate_negative(new NicEntity(VSP_ID, VERSION, COMPONENT_ID, null), USER,
- VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ VendorSoftwareProductErrorCodes.ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@Test
@@ -230,7 +343,7 @@ public class NicManagerImplTest {
@Test
public void testDeleteOnUploadVsp_negative() {
testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER,
- VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ VendorSoftwareProductErrorCodes.DELETE_NIC_NOT_ALLOWED);
}
@Test(expectedExceptions = CoreException.class,
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 5a2f76b6fa..f79a56bebf 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
@@ -20,8 +20,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
@@ -29,7 +27,6 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory;
-import org.openecomp.core.enrichment.types.ArtifactType;
import org.openecomp.core.factory.impl.AbstractFactoryBase;
import org.openecomp.core.model.dao.EnrichedServiceModelDao;
import org.openecomp.core.model.dao.ServiceModelDao;
@@ -48,7 +45,8 @@ import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
-import org.openecomp.sdc.vendorsoftwareproduct.MibManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
+import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
@@ -105,9 +103,6 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
-/**
- * Created by TALIO on 4/23/2016
- */
public class VendorSoftwareProductManagerImplTest {
private static final String INVALID_VERSION_MSG = "Invalid requested version.";
@@ -147,6 +142,8 @@ public class VendorSoftwareProductManagerImplTest {
private PackageInfoDao packageInfoDao;
@Mock
private VendorSoftwareProductInfoDao vspInfoDaoMock;
+ @Mock
+ private ManualVspToscaManager manualVspToscaManager;
@Spy
@@ -154,7 +151,7 @@ public class VendorSoftwareProductManagerImplTest {
private VendorSoftwareProductManagerImpl vendorSoftwareProductManager;
private OrchestrationTemplateCandidateManager candidateManager;
- private MibManager mibManager;
+ private MonitoringUploadsManager monitoringUploadsManager;
@Captor
private ArgumentCaptor<ActivityLogEntity> activityLogEntityArg;
@@ -467,6 +464,7 @@ public class VendorSoftwareProductManagerImplTest {
VSP_ID, USER1, VersionableEntityAction.Read);
VspDetails vsp = new VspDetails(VSP_ID, VERSION01);
+ vsp.setOnboardingMethod("Manual");
doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
VspQuestionnaireEntity vspQuestionnaire = new VspQuestionnaireEntity(VSP_ID, VERSION01);
@@ -757,20 +755,21 @@ public class VendorSoftwareProductManagerImplTest {
return fileNames;
}
-
+ /*
+ //Disabled for sonar null pointer issue for componentEntities
private Pair<String, String> uploadMib(String vspId, String user, String filePath,
String fileName) {
List<ComponentEntity> componentEntities = null;
//(List<ComponentEntity>) vendorSoftwareProductManager.listComponents(vspId, null, user);
- mibManager.upload(getFileInputStream(filePath),
+ monitoringUploadsManager.upload(getFileInputStream(filePath),
fileName, vspId,
- VERSION01, componentEntities.get(0).getId(), ArtifactType.SNMP_POLL, user);
+ VERSION01, componentEntities.get(0).getId(), MonitoringUploadType.SNMP_POLL, user);
//TODO: add validate of addActionLog() func call
return new ImmutablePair<>(componentEntities.get(0).getId(),
componentEntities.get(0).getComponentCompositionData()
.getDisplayName());
- }
+ }*/
private void createPackageFromUpload(String vspId, String user, String filePath)
throws IOException {
@@ -901,6 +900,7 @@ public class VendorSoftwareProductManagerImplTest {
vspDetails.setVlmVersion(new Version(1, 0));
vspDetails.setLicenseAgreement(licenseAgreement);
vspDetails.setFeatureGroups(featureGroups);
+ vspDetails.setOnboardingMethod("HEAT");
return vspDetails;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java
index 134dbfb5d4..3d98ab76c6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java
@@ -7,9 +7,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.
@@ -92,6 +92,8 @@ public class CandidateServiceImplTest {
vspDetails.setName("vspTest");
vspDetails.setDescription("Test description");
vspDetails.setVersion(new Version(0, 1));
+ //vspDetails.setOnboardingMethod(VSPCommon.OnboardingMethod.HEAT.name());
+ vspDetails.setOnboardingMethod("HEAT");
FilesDataStructure structure = JsonUtil.json2Object(getExpectedJson(), FilesDataStructure.class);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java
index d6060e6114..a85153ecef 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java
@@ -26,7 +26,7 @@ import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.ToscaUtil;
-import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java
index fdbf400406..33cf18c463 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java
@@ -252,12 +252,16 @@ public class SchemaGeneratorTest {
}
@Test
- public void testGenerateNicCompositionManual() {
+ public void testGenerateNicCompositionManual() {Nic nic = new Nic();
+ nic.setName("upload nic1 name");
+ nic.setDescription("upload nic1 desc");
+ nic.setNetworkType(NetworkType.Internal);
NicCompositionSchemaInput input = new NicCompositionSchemaInput();
+
input.setManual(true);
input.setNetworkIds(
Arrays.asList("manual networkId1", "manual networkId2", "manual networkId3"));
-
+ input.setNic(nic);
String schema = SchemaGenerator
.generate(SchemaTemplateContext.composition, CompositionEntityType.nic, input);
validateSchema(schema);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java
index e1073db941..4d925c00cd 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java
@@ -72,7 +72,8 @@ public class HeatCleanupOnNewUploadTest {/*
VspDetails vspDetails = vendorSoftwareProductManager.createVsp(VSPCommon
.createVspDetails(null, null, "VSPTestEmpty", "Test-vsp-empty", "vendorName", "vlm1Id",
- "icon", "category", "subCategory", "123", null), USER1);
+ "icon", "category", "subCategory", "123", null, VSPCommon.OnboardingMethod.HEAT.name()),
+ USER1);
vspId = vspDetails.getId();
vspActiveVersion = vspDetails.getVersion();
}
@@ -106,7 +107,7 @@ public class HeatCleanupOnNewUploadTest {/*
String componentId = components.get(0).getId();
vendorSoftwareProductManager
- .upload(mib, "vDNS.zip", vspId, componentId, ArtifactType.SNMP_TRAP, USER1);
+ .upload(mib, "vDNS.zip", vspId, componentId, MonitoringUploadType.SNMP_TRAP, USER1);
vendorSoftwareProductManager
.createProcess(new ProcessEntity(vspId, vspActiveVersion, componentId, null), USER1);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/invalidComponent.json b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/invalidComponent.json
index 9b10297572..be9e13adde 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/invalidComponent.json
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/invalidComponent.json
@@ -6,9 +6,6 @@
"drivers": ",Lz-m3R7iwRREmjBA3Ss6b0K8YBcH4SS66UJSG8OGTlaMs6Be"
},
"image": {
- "ephemeralDiskSizePerVM": 8,
- "format": "iso",
- "bootDiskSizePerVM": 100,
"providedBy": "Vendor"
},
"dnsConfiguration": "dolore adipisicing proident aute amet",
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/schema/componentQuestionnaire.json b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/schema/componentQuestionnaire.json
index e0bd377e26..7870df8ab2 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/schema/componentQuestionnaire.json
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/schema/componentQuestionnaire.json
@@ -157,11 +157,12 @@
"MemoryRAM": {
"type": "string",
"enum": [
+ "1 GB",
"2 GB",
"4 GB",
"8 GB"
],
- "default": "2 GB"
+ "default": "1 GB"
}
},
"additionalProperties": false
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/validComponent.json b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/validComponent.json
index 4e9e9aa6c0..316d8c5bed 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/validComponent.json
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/quesionnaire/validComponent.json
@@ -6,9 +6,6 @@
"drivers": ",Lz-m3R7iwRREmjBA3Ss6b0K8YBcH4SS66UJSG8OGTlaMs6Be"
},
"image": {
- "ephemeralDiskSizePerVM": 8,
- "format": "iso",
- "bootDiskSizePerVM": 100,
"providedBy": "Vendor"
},
"dnsConfiguration": "dolore adipisicing proident aute amet",
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation/zips/various/vesTest-yml_only.zip b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation/zips/various/vesTest-yml_only.zip
new file mode 100644
index 0000000000..8522252232
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation/zips/various/vesTest-yml_only.zip
Binary files differ
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager/zips/invalid_ves_file.zip b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager/zips/invalid_ves_file.zip
new file mode 100644
index 0000000000..d96a5b6e16
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager/zips/invalid_ves_file.zip
Binary files differ