summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/VSPPackage.zipbin33617 -> 0 bytes
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml.versionsBackup159
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilder.java25
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java27
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilder.java27
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java47
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java27
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java35
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java22
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java35
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java38
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java21
-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/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java54
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java68
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java59
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java156
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java61
19 files changed, 582 insertions, 707 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/VSPPackage.zip b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/VSPPackage.zip
deleted file mode 100644
index ca55484a3c..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/VSPPackage.zip
+++ /dev/null
Binary files differ
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml.versionsBackup b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml.versionsBackup
deleted file mode 100644
index 839a192ec5..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml.versionsBackup
+++ /dev/null
@@ -1,159 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId>
- <version>1.0-SNAPSHOT</version>
- <dependencies>
- <dependency>
- <groupId>org.openecomp.core</groupId>
- <artifactId>openecomp-utilities-lib</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.core</groupId>
- <artifactId>openecomp-nosqldb-core</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-vendor-software-product-core</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.core</groupId>
- <artifactId>openecomp-heat-lib</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.core</groupId>
- <artifactId>openecomp-tosca-lib</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>6.9.10</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>RELEASE</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-translator-core</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.dataformat</groupId>
- <artifactId>jackson-dataformat-xml</artifactId>
- <version>2.7.4</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.woodstox</groupId>
- <artifactId>woodstox-core-asl</artifactId>
- <version>4.4.1</version>
- </dependency>
-
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-vendor-license-core</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-enrichment-core</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-validation-api</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-validation-impl</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-enrichment-impl</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>${commons.io.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-model-impl</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-validation-manager</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-logging-core</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-logging-api</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-healing-core</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-healing-impl</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-healing-api</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.19.1</version>
- <configuration>
- <useSystemClassLoader>false</useSystemClassLoader>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <parent>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>backend</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
-
-</project> \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilder.java
new file mode 100644
index 0000000000..1c728bdfbb
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilder.java
@@ -0,0 +1,25 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+/**
+ * The Compute error builder.
+ */
+public class ComputeErrorBuilder {
+ private static final String COMPUTE_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
+ + ": name : must match %s";
+
+ /**
+ * Gets image name format error builder.
+ *
+ * @return the image name format error builder
+ */
+ public static ErrorCode getComputeNameFormatErrorBuilder(String pattern) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.COMPUTE_NAME_FORMAT_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(COMPUTE_NAME_FORMAT_MSG, pattern));
+ 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
index 63d716504b..97476a2dfd 100644
--- 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
@@ -17,6 +17,8 @@ public class DeploymentFlavorErrorBuilder {
"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 DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
+ + ": name : must match %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 " +
@@ -92,4 +94,12 @@ public class DeploymentFlavorErrorBuilder {
builder.withMessage(String.format(FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG));
return builder.build();
}
+
+ public static ErrorCode getDeploymentFlavorNameFormatErrorBuilder(String pattern){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG, pattern));
+ 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
index 95bff60479..24883b5c13 100644
--- 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
@@ -1,13 +1,10 @@
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;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.*;
+
/**
* The Image error builder.
*/
@@ -15,7 +12,8 @@ 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 VFC_IMAGE_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
+ + ": name : must match %s";
private static final String IMAGE_INVALID_FORMAT_MSG = "The format value doesn't meet the "
+ "expected attribute value.";
@@ -28,11 +26,24 @@ public class ImageErrorBuilder {
*
* @return the duplicate image name error builder
*/
- public static ErrorCode getDuplicateImageNameErrorBuilder(String imageName, String componenetId) {
+ public static ErrorCode getDuplicateImageNameErrorBuilder(String imageName, String componentId) {
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 ));
+ builder.withMessage(String.format(VFC_IMAGE_DUPLICATE_NAME_MSG, imageName, componentId ));
+ return builder.build();
+ }
+
+ /**
+ * Gets image name format error builder.
+ *
+ * @return the image name format error builder
+ */
+ public static ErrorCode getImageNameFormatErrorBuilder(String pattern) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(IMAGE_NAME_FORMAT_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VFC_IMAGE_NAME_FORMAT_MSG, pattern));
return builder.build();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilder.java
new file mode 100644
index 0000000000..fc8ecf26a4
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilder.java
@@ -0,0 +1,27 @@
+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.NIC_NAME_FORMAT_NOT_ALLOWED;
+
+/**
+ * The NIC error builder.
+ */
+public class NicErrorBuilder {
+ private static final String NIC_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
+ + ": name : must match %s";
+
+ /**
+ * Gets image name format error builder.
+ *
+ * @return the image name format error builder
+ */
+ public static ErrorCode getNicNameFormatErrorBuilder(String imageName, String pattern) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(NIC_NAME_FORMAT_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NIC_NAME_FORMAT_MSG, pattern));
+ return builder.build();
+ }
+}
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
index a2d1d708c1..cd102ebb1d 100644
--- 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
@@ -12,15 +12,15 @@ 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.VendorSoftwareProductConstants;
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.ComputeErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.DuplicateComputeInComponentErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
@@ -34,14 +34,11 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEnti
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;
@@ -92,9 +89,13 @@ public class ComputeManagerImpl implements ComputeManager {
onboardingMethodUpdateErrorCode.message());
throw new CoreException(onboardingMethodUpdateErrorCode);
} else {
+
//validateComponentId(compute.getVspId(),compute.getVersion(),compute.getComponentId());
- validateCompute(compute);
- createdCompute = createCompute(compute);
+ Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
+ (),compute.getComponentId());
+
+ validateVfcCompute(compute, vfcComputeList, LoggerTragetServiceName.CREATE_COMPUTE);
+ createdCompute = createCompute(compute);
}
mdcDataDebugMessage
@@ -108,7 +109,7 @@ public class ComputeManagerImpl implements ComputeManager {
return compositionEntityDataManager.createCompute(compute);
}
- private void validateCompute(ComputeEntity compute) {
+ /*private void validateCompute(ComputeEntity compute) {
Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
(),compute.getComponentId());
@@ -123,7 +124,7 @@ public class ComputeManagerImpl implements ComputeManager {
throw new CoreException(duplicateComputeInComponentErrorBuilder);
}
- }
+ }*/
private void validateComputeUpdate(ComputeEntity compute) {
Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
@@ -347,7 +348,7 @@ public class ComputeManagerImpl implements ComputeManager {
retrieved.setQuestionnaireData(null);
vfcComputeList.remove(retrieved);
if(vspInfoDao.isManual(compute.getVspId(), compute.getVersion()))
- validateVfcCompute(compute, vfcComputeList);
+ validateVfcCompute(compute, vfcComputeList, LoggerTragetServiceName.UPDATE_COMPUTE);
//Set format to default value in order to handle FTL validation when compute format is null
/*if(compute.getComputeCompositionData().getFormat() == null)
@@ -384,22 +385,32 @@ public class ComputeManagerImpl implements ComputeManager {
}
}
- private void validateVfcCompute(ComputeEntity compute, Collection<ComputeEntity> vfcComputeList) {
- if (isComputeNameDuplicate(vfcComputeList,compute.getComputeCompositionData().getName(), compute.getId())) {
- ErrorCode errorCode = DuplicateComputeInComponentErrorBuilder.getDuplicateComputeNameErrorBuilder(compute
+ private void validateVfcCompute(ComputeEntity compute, Collection<ComputeEntity> vfcComputeList, String event) {
+ if(!compute.getComputeCompositionData().getName().matches(VendorSoftwareProductConstants.NAME_PATTERN))
+ {
+ ErrorCode errorCode = ComputeErrorBuilder.getComputeNameFormatErrorBuilder(
+ VendorSoftwareProductConstants.NAME_PATTERN);
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ event, ErrorLevel.ERROR.name(),
+ errorCode.id(),errorCode.message());
+ throw new CoreException(errorCode);
+ }
+
+ 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(),
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ event, ErrorLevel.ERROR.name(),
errorCode.id(),errorCode.message());
- throw new CoreException(errorCode);
- }
+ 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)) {
+ if (compute.getComputeCompositionData().getName().equalsIgnoreCase(name) && !compute.getId().equals(computeId)) {
return true;
}
}
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
index 7069d778a7..2e964458d5 100644
--- 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
@@ -10,6 +10,7 @@ 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.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
@@ -23,17 +24,14 @@ import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMet
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;
@@ -112,6 +110,18 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
private void validateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity, String
user, Version activeVersion) {
+
+ if(!deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel().matches(VendorSoftwareProductConstants.NAME_PATTERN))
+ {
+ ErrorCode errorCode = DeploymentFlavorErrorBuilder.getDeploymentFlavorNameFormatErrorBuilder(
+ VendorSoftwareProductConstants.NAME_PATTERN);
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_NIC, ErrorLevel.ERROR.name(),
+ errorCode.id(),errorCode.message());
+
+ throw new CoreException(errorCode);
+ }
//Validation for unique model.
Collection<DeploymentFlavorEntity> listDeploymentFlavors =
listDeploymentFlavors(deploymentFlavorEntity.getVspId(),
@@ -357,6 +367,17 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
updateDeploymentFlavorErrorBuilder.message());
throw new CoreException(updateDeploymentFlavorErrorBuilder);
}
+ else {
+ if(!deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel().matches(VendorSoftwareProductConstants.NAME_PATTERN))
+ {
+ ErrorCode errorCode = DeploymentFlavorErrorBuilder.getDeploymentFlavorNameFormatErrorBuilder(
+ VendorSoftwareProductConstants.NAME_PATTERN);
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ errorCode.id(),errorCode.message());
+ throw new CoreException(errorCode);
+ }
+ }
//deploymentFlavorEntity.setVersion(activeVersion);
DeploymentFlavorEntity retrieved =
getDeploymentFlavor(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion(),
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
index e180138119..6a8f9e0c45 100644
--- 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
@@ -12,9 +12,7 @@ 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.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
@@ -34,10 +32,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ima
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;
@@ -66,7 +62,8 @@ public class ImageManagerImpl implements ImageManager {
VersionableEntityAction.Write, user).getActiveVersion();
imageEntity.setVersion(activeVersion);*/
- if (!vspInfoDao.isManual(imageEntity.getVspId(), imageEntity.getVersion())) {
+ boolean isManual = vspInfoDao.isManual(imageEntity.getVspId(), imageEntity.getVersion());
+ if (!isManual) {
ErrorCode errorCode = NotSupportedHeatOnboardMethodErrorBuilder
.getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
@@ -80,7 +77,7 @@ public class ImageManagerImpl implements ImageManager {
Collection<ImageEntity> vfcImageList = listImages(imageEntity.getVspId() ,
imageEntity.getVersion(), imageEntity.getComponentId());
- validateVfcImage(imageEntity, vfcImageList);
+ validateVfcImage(isManual, imageEntity, vfcImageList, LoggerTragetServiceName.CREATE_IMAGE);
compositionEntityDataManager.createImage(imageEntity);
return imageEntity;
}
@@ -219,11 +216,11 @@ public class ImageManagerImpl implements ImageManager {
/*Version activeVersion =
getVersionInfo(image.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
image.setVersion(activeVersion);*/
-
+ boolean isManual = vspInfoDao.isManual(image.getVspId(), image.getVersion());
ImageEntity retrieved = getImageEntity(image.getVspId(), image.getVersion(), image.getComponentId(),
image.getId());
- if(!vspInfoDao.isManual(image.getVspId(), image.getVersion())) {
+ if(!isManual) {
final Image imageCompositionData = image.getImageCompositionData();
final String fileName = imageCompositionData.getFileName();
//final String format = imageCompositionData.getFormat();
@@ -239,7 +236,7 @@ public class ImageManagerImpl implements ImageManager {
//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);
+ validateVfcImage(isManual, image, vfcImageList, LoggerTragetServiceName.UPDATE_IMAGE);
//Set format to default value in order to handle FTL validation when image format is null
/*if(image.getImageCompositionData().getFormat() == null)
@@ -325,13 +322,25 @@ public class ImageManagerImpl implements ImageManager {
return false;
}
- private void validateVfcImage(ImageEntity image, Collection<ImageEntity> vfcImageList) {
+ private void validateVfcImage(boolean isManual, ImageEntity image, Collection<ImageEntity> vfcImageList, String event) {
+ if(isManual && !image.getImageCompositionData().getFileName().matches(VendorSoftwareProductConstants.NAME_PATTERN))
+ {
+ ErrorCode errorCode = ImageErrorBuilder.getImageNameFormatErrorBuilder(
+ VendorSoftwareProductConstants.NAME_PATTERN);
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ event, ErrorLevel.ERROR.name(),
+ errorCode.id(),errorCode.message());
+
+ throw new CoreException(errorCode);
+ }
+
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(),
+ event, ErrorLevel.ERROR.name(),
errorCode.id(),errorCode.message());
throw new CoreException(errorCode);
@@ -354,6 +363,4 @@ public class ImageManagerImpl implements ImageManager {
.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
index ef33812ddc..06e54528b7 100644
--- 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
@@ -2,7 +2,6 @@ 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;
@@ -14,8 +13,8 @@ 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.services.ManualVspDataCollectionService;
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;
@@ -25,12 +24,12 @@ import java.util.Optional;
public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private ManualVspDataCollectionService
+ manualVspDataCollectionService = new ManualVspDataCollectionService();
@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;
@@ -40,7 +39,8 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
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");
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Release Vendor not found : "
+ + ex.getMessage());
}
releaseVendor.ifPresent(vspModelInfo::setReleaseVendor);
@@ -51,7 +51,8 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
} 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");
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect allowed flavors : "
+ + ex.getMessage());
allowedFlavors = null;
}
if (MapUtils.isNotEmpty(allowedFlavors)) {
@@ -66,7 +67,8 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
} 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");
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp component images : "
+ + ex.getMessage());
vspComponentImages = null;
}
if (MapUtils.isNotEmpty(vspComponentImages)) {
@@ -80,7 +82,8 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
} 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");
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp components : "
+ + ex.getMessage());
vspComponents = null;
}
if (MapUtils.isNotEmpty(vspComponents)) {
@@ -94,7 +97,8 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
} 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");
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp component nics : "
+ + ex.getMessage());
vspComponentNics = null;
}
if (MapUtils.isNotEmpty(vspComponentNics)) {
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 b196b3f54c..0304353113 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
@@ -31,18 +31,13 @@ import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager;
import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
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.errors.*;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
@@ -55,7 +50,6 @@ 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;
@@ -145,6 +139,19 @@ public class NicManagerImpl implements NicManager {
String networkId = nic.getNicCompositionData().getNetworkId();
NetworkType networkType = nic.getNicCompositionData().getNetworkType();
String networkDescription = nic.getNicCompositionData().getNetworkDescription();
+
+ if(!nic.getNicCompositionData().getName().matches(VendorSoftwareProductConstants.NAME_PATTERN))
+ {
+ ErrorCode errorCode = NicErrorBuilder.getNicNameFormatErrorBuilder(nic
+ .getNicCompositionData().getName(), VendorSoftwareProductConstants.NAME_PATTERN);
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
+ errorCode.id(),errorCode.message());
+
+ throw new CoreException(errorCode);
+ }
+
listNics.forEach(nicEntity -> {
Nic nicdata = nicEntity.getNicCompositionData();
if (nic.getNicCompositionData().getName().equalsIgnoreCase(nicdata.getName())) {
@@ -265,6 +272,18 @@ public class NicManagerImpl implements NicManager {
schemaInput.setManual(vspInfoDao.isManual(nic.getVspId(), nic.getVersion()));
schemaInput.setNic(retrieved.getNicCompositionData());
+ if(schemaInput.isManual() && !nic.getNicCompositionData().getName().matches(VendorSoftwareProductConstants.NAME_PATTERN))
+ {
+ ErrorCode errorCode = NicErrorBuilder.getNicNameFormatErrorBuilder(nic
+ .getNicCompositionData().getName(), VendorSoftwareProductConstants.NAME_PATTERN);
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_NIC, ErrorLevel.ERROR.name(),
+ errorCode.id(),errorCode.message());
+
+ throw new CoreException(errorCode);
+ }
+
CompositionEntityValidationData validationData = compositionEntityDataManager
.validateEntity(nic, SchemaTemplateContext.composition, schemaInput);
if (CollectionUtils.isEmpty(validationData.getErrors())) {
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 959cf15789..07e84803aa 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
@@ -29,6 +29,7 @@ import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.core.validation.util.MessageContainerUtil;
import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
@@ -47,6 +48,7 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.api.annotations.Metrics;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.messages.AuditMessages;
import org.openecomp.sdc.logging.types.LoggerServiceName;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
@@ -90,6 +92,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
+import static org.openecomp.sdc.logging.messages.AuditMessages.HEAT_VALIDATION_ERROR;
import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME;
@@ -225,6 +228,7 @@ public class OrchestrationTemplateCandidateManagerImpl
throw new CoreException(new OrchestrationTemplateNotFoundErrorBuilder(vspId).build());
}
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_VALIDATION_STARTED + vspId);
OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
UploadFileResponse uploadFileResponse = new UploadFileResponse();
OrchestrationTemplateCandidateData candidateDataEntity = candidate.get();
@@ -233,6 +237,8 @@ public class OrchestrationTemplateCandidateManagerImpl
if (!fileContent.isPresent()) {
response.addStructureErrors(uploadFileResponse.getErrors());
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
+ HEAT_VALIDATION_ERROR));
return response;
}
@@ -246,6 +252,8 @@ public class OrchestrationTemplateCandidateManagerImpl
Messages.FOUND_UNASSIGNED_FILES.getErrorMessage(), ErrorLevel.ERROR);
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
+ HEAT_VALIDATION_ERROR));
return response;
}
@@ -258,6 +266,8 @@ public class OrchestrationTemplateCandidateManagerImpl
Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
.fetchZipFileByteArrayInputStream(vspId, candidateDataEntity, manifest, uploadErrors);
if (!zipByteArrayInputStream.isPresent()) {
+ response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
+ HEAT_VALIDATION_ERROR));
return response;
}
@@ -275,8 +285,18 @@ public class OrchestrationTemplateCandidateManagerImpl
deleteUploadDataAndContent(vspId, version);
saveHotData(vspId, version, zipByteArrayInputStream.get(), fileContentMap, tree);
+ response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
+ HEAT_VALIDATION_ERROR));
+ if ( MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, response.getErrors
+ ()))) {
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_VALIDATION_COMPLETED + vspId);
+ }
+
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_TRANSLATION_STARTED + vspId);
+
TranslatorOutput translatorOutput =
HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap);
+
ToscaServiceModel toscaServiceModel = translatorOutput.getToscaServiceModel();
if (toscaServiceModel != null) {
serviceModelDao.storeServiceModel(vspId, version, toscaServiceModel);
@@ -287,7 +307,10 @@ public class OrchestrationTemplateCandidateManagerImpl
.getNonUnifiedToscaServiceModel()));
retainComponentQuestionnaireData(vspId, version, componentsQuestionnaire,
componentNicsQuestionnaire, componentMibList, processes, processArtifact);
+
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_TRANSLATION_COMPLETED + vspId);
}
+
uploadFileResponse.addStructureErrors(uploadErrors);
ActivityLogEntity activityLogEntity =
@@ -299,7 +322,6 @@ public class OrchestrationTemplateCandidateManagerImpl
return response;
}
-
@Override
public Optional<FilesDataStructure> getFilesDataStructure(
String vspId, Version version, String user) {
@@ -462,7 +484,7 @@ public class OrchestrationTemplateCandidateManagerImpl
componentArtifactDao.listArtifacts(new
ComponentMonitoringUploadEntity(vspId, activeVersion, componentEntity.getId(),
null));
- if(CollectionUtils.isNotEmpty(componentMib)){
+ if (CollectionUtils.isNotEmpty(componentMib)) {
componentMibList.put(componentName,componentMib);
}
@@ -614,4 +636,14 @@ public class OrchestrationTemplateCandidateManagerImpl
return vspDetails;
}
-}
+ private void printAuditForErrors(List<ErrorMessage> errorList, String vspId, String auditType) {
+
+ errorList.forEach(errorMessage -> {
+ if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) {
+ logger.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
+ vspId));
+ }
+ });
+ }
+
+ }
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 0b48c334c6..89246376e4 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
@@ -48,6 +48,7 @@ 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.messages.AuditMessages;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerServiceName;
@@ -594,6 +595,14 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
enrichmentManager.setModel(serviceModel);
Map<String, List<ErrorMessage>> enrichErrors = enrichmentManager.enrich();
+ if (MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, enrichErrors))) {
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.ENRICHMENT_COMPLETED
+ + vendorSoftwareProductId);
+ } else {
+ enrichErrors.values().forEach(errorList ->
+ auditIfContainsErrors(errorList,vendorSoftwareProductId,AuditMessages.ENRICHMENT_ERROR));
+ }
+
enrichedServiceModelDao
.storeServiceModel(vendorSoftwareProductId, version, enrichmentManager.getModel());
@@ -993,6 +1002,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
packageInfoDao.create(packageInfo);
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_PACKAGE + vspId);
+
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return packageInfo;
}
@@ -1178,4 +1189,14 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
String user) {
return vendorSoftwareProductDao.listComputesByVsp(vspId, version);
}
+
+ private void auditIfContainsErrors(List<ErrorMessage> errorList, String vspId,String auditType) {
+
+ errorList.forEach(errorMessage -> {
+ if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) {
+ logger.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
+ vspId));
+ }
+ });
+ }
}
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
deleted file mode 100644
index 981bfe941a..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ManualVspDataCollectionService.java
+++ /dev/null
@@ -1,418 +0,0 @@
-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/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
index c8f473c8c7..103762c56d 100644
--- 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
@@ -140,11 +140,12 @@ public class ComputeManagerImplTest {
}
@Test
- public void testCreateManualImageWithDuplicateName() {
+ public void testCreateManualComputeWithDuplicateName() {
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);
+ expectedDiffName.setId(COMPUTE1_ID + "Name");
ComputeData computeData = expectedDiffName.getComputeCompositionData();
computeData.setName(COMPUTE1_ID + "Name");
expectedDiffName.setComputeCompositionData(computeData);
@@ -162,6 +163,28 @@ public class ComputeManagerImplTest {
}
}
+ @Test
+ public void testCreateManualComputeWithIncorrectNameFormat() {
+ 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(expectedDiffName, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.COMPUTE_NAME_FORMAT_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
@Test
public void testUpdateNonExistingComputeId_negative() {
@@ -192,6 +215,33 @@ public class ComputeManagerImplTest {
}
@Test
+ public void testUpdateComputeWithIncorrectNameFormat() {
+ 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());
+
+ doReturn(true).when(vspInfoDao).isManual(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);
+
+ try {
+ computeManager.updateCompute(computeEntity, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.COMPUTE_NAME_FORMAT_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
+
+ @Test
public void testIllegalComputeUpdate() {
doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
.when(computeDao).get(anyObject());
@@ -207,7 +257,7 @@ public class ComputeManagerImplTest {
ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
ComputeData computeData = new ComputeData();
- computeData.setName(COMPUTE1_ID + " name updated");
+ computeData.setName(COMPUTE1_ID + "_name_updated");
computeData.setDescription(COMPUTE1_ID + " desc updated");
computeEntity.setComputeCompositionData(computeData);
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
index e082b25435..598b97b34e 100644
--- 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
@@ -22,8 +22,6 @@ 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;
@@ -99,7 +97,7 @@ public class DeplomentFlavorManagerImplTest {
DeploymentFlavorEntity expectedDiffName = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
DeploymentFlavor deploymentFlavor = expectedDiffName.getDeploymentFlavorCompositionData();
- deploymentFlavor.setModel(DF1_ID + " Name");
+ deploymentFlavor.setModel(DF1_ID + "Name");
expectedDiffName.setDeploymentFlavorCompositionData(deploymentFlavor);
List<DeploymentFlavorEntity> list = new ArrayList<DeploymentFlavorEntity>();
list.add(expectedDiffName);
@@ -116,6 +114,28 @@ public class DeplomentFlavorManagerImplTest {
}
@Test
+ public void testCreateManualDepFlavorWithIncorrectNameFormat() {
+ 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(expectedDiffName, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
+ @Test
public void testCreateManualDepFlavorWithFGNotInVSP() {
DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
final DeploymentFlavor deploymentFlavor =
@@ -253,7 +273,7 @@ public class DeplomentFlavorManagerImplTest {
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" );
+ , DF1_ID.equals(deploymentFlavorEntity.getId()) ? DF1_ID+"name" : DF2_ID+"name" );
}
}
@@ -286,7 +306,7 @@ public class DeplomentFlavorManagerImplTest {
DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(VSP_ID, VERSION, DF1_ID);
DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel(DF1_ID + " name");
+ deploymentFlavor.setModel(DF1_ID + "_name");
deploymentFlavor.setDescription(DF1_ID + " desc updated");
deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
@@ -296,6 +316,36 @@ public class DeplomentFlavorManagerImplTest {
verify(deploymentFlavorDaoMock).update(deploymentFlavorEntity);
}
+ @Test
+ public void testManualUpdateDepFlavorIncorrectNameFormat() {
+ 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);
+
+ try {
+ deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
+
@Test
public void testGetNonExistingDepFlavorId_negative() {
testGet_negative(VSP_ID, VERSION, "non existing image id", USER,
@@ -378,7 +428,7 @@ public class DeplomentFlavorManagerImplTest {
DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel(deploymentFlavorId + " name");
+ deploymentFlavor.setModel(deploymentFlavorId + "name");
deploymentFlavor.setDescription(deploymentFlavorId + " desc");
deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
@@ -388,8 +438,12 @@ public class DeplomentFlavorManagerImplTest {
private void testUpdate_negative(String vspId, Version version, String
deploymentFlavorId, String user, String expectedErrorCode) {
try {
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
+ DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
+ deploymentFlavor.setModel("Name");
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
deploymentFlavorManager
- .updateDeploymentFlavor(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId), user);
+ .updateDeploymentFlavor(deploymentFlavorEntity, 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
index ec676e517b..c29cb42953 100644
--- 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
@@ -84,7 +84,7 @@ public class ImageManagerImplTest {
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" );
+ IMAGE1_ID.equals(image.getId()) ? IMAGE1_ID+"_name" : IMAGE2_ID+"_name" );
}
}
@@ -105,13 +105,35 @@ public class ImageManagerImplTest {
}
@Test
+ public void testCreateManualImageWithIncorrectNameFormat() {
+ 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(expectedDiffName, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.IMAGE_NAME_FORMAT_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
+
+ @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");
+ image.setFileName(IMAGE1_ID + "_Name");
expectedDiffName.setImageCompositionData(image);
List<ImageEntity> vfcImageList = new ArrayList<ImageEntity>();
vfcImageList.add(expectedDiffName);
@@ -143,7 +165,7 @@ public class ImageManagerImplTest {
ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Image imageData = new Image();
- imageData.setFileName(IMAGE1_ID + " name");
+ imageData.setFileName(IMAGE1_ID + "_name");
imageData.setDescription(IMAGE1_ID + " desc updated");
imageEntity.setImageCompositionData(imageData);
@@ -154,6 +176,33 @@ public class ImageManagerImplTest {
}
@Test
+ public void testUpdateImageWithIncorrectNameFormat() {
+ 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());
+
+ doReturn(true).when(vspInfoDao).isManual(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);
+
+ try {
+ imageManager.updateImage(imageEntity, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.IMAGE_NAME_FORMAT_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
+
+ @Test
public void testIllegalImageUpdate() {
doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID))
.when(imageDao).get(anyObject());
@@ -169,7 +218,7 @@ public class ImageManagerImplTest {
ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Image imageData = new Image();
- imageData.setFileName(IMAGE1_ID + " name updated");
+ imageData.setFileName(IMAGE1_ID + "_name_updated");
imageData.setDescription(IMAGE1_ID + " desc updated");
imageEntity.setImageCompositionData(imageData);
@@ -345,7 +394,7 @@ public class ImageManagerImplTest {
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.setFileName(imageId + "_name");
imageData.setDescription(imageId + " desc");
imageEntity.setImageCompositionData(imageData);
return imageEntity;
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
index 4bbbec166e..8ea853c5fa 100644
--- 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
@@ -1,6 +1,9 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
import static org.openecomp.sdc.generator.util.GeneratorConstants.ALLOWED_FLAVORS_PROPERTY;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.IMAGES_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;
@@ -10,6 +13,10 @@ import static org.openecomp.sdc.translator.services.heattotosca.Constants.GLOBAL
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
import org.openecomp.sdc.generator.core.utils.GeneratorUtils;
import org.openecomp.sdc.generator.datatypes.tosca.ComputeFlavor;
import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
@@ -36,43 +43,112 @@ 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 org.openecomp.sdc.vendorsoftwareproduct.services.ManualVspDataCollectionService;
+import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
public class ManualVspToscaManagerImplTest {
+ private static final String USER = "manualVspToscaTestUser";
+ private static final String INVALID_VSP_ID = "Invalid_Vsp_Id";
+ private static final String VSP_ID = "Vsp_Id_1";
+ private static final String VSP_VERSION = "1.0";
+
+ private static final String RELEASE_VENDOR = "Vendor-1";
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 String VENDOR_MODEL_1 = "Deployment_Flavor_Model_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 DISK_SIZE_1 = "2 GB";
+ private static final String MEM_SIZE_1 = "8 GB";
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 String VENDOR_MODEL_2 = "Deployment_Flavor_Model_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 DISK_SIZE_2 = "3 GB";
+ private static final String MEM_SIZE_2 = "2 GB";
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();
+ @Spy
+ @InjectMocks
+ private ManualVspToscaManagerImpl manualVspToscaManagerMock;
+
+ @Mock
+ private ManualVspDataCollectionService manualVspDataCollectionServiceMock;
+
+ @Test
+ public void testGatherVspInformationInvalidVsp() {
+ MockitoAnnotations.initMocks(this);
+ VspModelInfo expectedVspData = new VspModelInfo();
+ doThrow(new RuntimeException())
+ .when(manualVspDataCollectionServiceMock)
+ .getReleaseVendor(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ doThrow(new RuntimeException())
+ .when(manualVspDataCollectionServiceMock)
+ .getAllowedFlavors(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ doThrow(new RuntimeException())
+ .when(manualVspDataCollectionServiceMock)
+ .getVspComponentImages(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ doThrow(new RuntimeException())
+ .when(manualVspDataCollectionServiceMock)
+ .getVspComponents(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ doThrow(new RuntimeException())
+ .when(manualVspDataCollectionServiceMock)
+ .getVspComponentNics(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ VspModelInfo vspModelInfo = manualVspToscaManagerMock.gatherVspInformation(INVALID_VSP_ID,
+ Version.valueOf(VSP_VERSION), USER);
+ Assert.assertEquals(expectedVspData, vspModelInfo);
+ }
+
+
+ @Test
+ public void testGatherVspInformationValidVsp() {
+ MockitoAnnotations.initMocks(this);
+ Map<String, DeploymentFlavorModel> deploymentFlavorData = getDeploymentFlavorData();
+ Map<String, List<Nic>> componentNics = getComponentNics();
+ Map<String, String> componentData = getComponentData();
+ Map<String, List<MultiFlavorVfcImage>> vfcImageData = getVfcImageData();
+ doReturn(Optional.of(RELEASE_VENDOR)).when(manualVspDataCollectionServiceMock)
+ .getReleaseVendor(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ doReturn(deploymentFlavorData).when(manualVspDataCollectionServiceMock)
+ .getAllowedFlavors(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ doReturn(vfcImageData).when(manualVspDataCollectionServiceMock)
+ .getVspComponentImages(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ doReturn(componentData).when(manualVspDataCollectionServiceMock)
+ .getVspComponents(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ doReturn(componentNics).when(manualVspDataCollectionServiceMock)
+ .getVspComponentNics(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ VspModelInfo vspModelInfo = manualVspToscaManagerMock.gatherVspInformation(VSP_ID,
+ Version.valueOf(VSP_VERSION), USER);
+
+ VspModelInfo expectedVspData = new VspModelInfo();
+ expectedVspData.setReleaseVendor(RELEASE_VENDOR);
+ expectedVspData.setComponents(getComponentData());
+ expectedVspData.setMultiFlavorVfcImages(getVfcImageData());
+ expectedVspData.setAllowedFlavors(getDeploymentFlavorData());
+ expectedVspData.setNics(getComponentNics());
+
+ Assert.assertEquals(expectedVspData, vspModelInfo);
+ }
+
@Test
public void testGenerateToscaInvalidVspId() {
VspModelInfo emptyVspCollectedData = new VspModelInfo();
@@ -87,7 +163,7 @@ public class ManualVspToscaManagerImplTest {
@Test
public void testGenerateToscaNoComponent() {
VspModelInfo vspCollectedData = new VspModelInfo();
- vspCollectedData.setReleaseVendor("Vendor-1");
+ vspCollectedData.setReleaseVendor(RELEASE_VENDOR);
vspCollectedData.setComponents(null);
vspCollectedData.setMultiFlavorVfcImages(null);
vspCollectedData.setAllowedFlavors(getDeploymentFlavorData());
@@ -111,7 +187,6 @@ public class ManualVspToscaManagerImplTest {
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();
@@ -131,7 +206,6 @@ public class ManualVspToscaManagerImplTest {
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();
@@ -139,8 +213,8 @@ public class ManualVspToscaManagerImplTest {
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());
+ .get(componentName + GeneratorConstants.VNF_NODE_TEMPLATE_ID_SUFFIX)
+ .getProperties().get(IMAGES_PROPERTY));
}
@Test
@@ -154,7 +228,6 @@ public class ManualVspToscaManagerImplTest {
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);
@@ -171,7 +244,7 @@ public class ManualVspToscaManagerImplTest {
@Test
public void testGenerateToscaNoManufacturerRefNumAndFeatureGroup() {
VspModelInfo vspCollectedData = new VspModelInfo();
- vspCollectedData.setReleaseVendor("Vendor-1");
+ vspCollectedData.setReleaseVendor(RELEASE_VENDOR);
vspCollectedData.setComponents(getComponentData());
vspCollectedData.setMultiFlavorVfcImages(getVfcImageData());
Map<String, DeploymentFlavorModel> deploymentFlavorData = getDeploymentFlavorData();
@@ -184,7 +257,6 @@ public class ManualVspToscaManagerImplTest {
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();
@@ -204,7 +276,7 @@ public class ManualVspToscaManagerImplTest {
@Test
public void testGenerateToscaNoDeploymentFlavor() {
VspModelInfo vspCollectedData = new VspModelInfo();
- vspCollectedData.setReleaseVendor("Vendor-1");
+ vspCollectedData.setReleaseVendor(RELEASE_VENDOR);
vspCollectedData.setComponents(getComponentData());
vspCollectedData.setMultiFlavorVfcImages(getVfcImageData());
vspCollectedData.setAllowedFlavors(null);
@@ -213,7 +285,6 @@ public class ManualVspToscaManagerImplTest {
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();
@@ -228,7 +299,7 @@ public class ManualVspToscaManagerImplTest {
@Test
public void testGenerateToscaCompleteData() {
VspModelInfo vspCollectedData = new VspModelInfo();
- vspCollectedData.setReleaseVendor("Vendor-1");
+ vspCollectedData.setReleaseVendor(RELEASE_VENDOR);
vspCollectedData.setComponents(getComponentData());
vspCollectedData.setMultiFlavorVfcImages(getVfcImageData());
vspCollectedData.setAllowedFlavors(getDeploymentFlavorData());
@@ -237,31 +308,23 @@ public class ManualVspToscaManagerImplTest {
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));
@@ -284,24 +347,18 @@ public class ManualVspToscaManagerImplTest {
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());
+ private void validateImagePropertyData(NodeTemplate vnfNodeTemplate, String componentName) {
Map<String, MultiFlavorVfcImage> vfcImages = (Map<String, MultiFlavorVfcImage>)
- vfcNodeTemplate.getProperties().get(GeneratorConstants.IMAGES_PROPERTY);
+ vnfNodeTemplate.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);
+ IMAGE_FILE_NAME_1, "md5");
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);
+ IMAGE_FILE_NAME_2, "md5");
Assert.assertEquals(expectedImage2, image2);
}
@@ -311,12 +368,11 @@ public class ManualVspToscaManagerImplTest {
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.assertEquals(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE, vnfNodeTemplate.getType());
Assert.assertNotNull(vnfNodeTemplate.getDirectives());
Assert.assertEquals(true, vnfNodeTemplate.getDirectives().contains(ToscaConstants
.NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE));
-
+ validateImagePropertyData(vnfNodeTemplate, componentName);
Map<String, Object> serviceTemplateFilterProperty = (Map<String, Object>) vnfNodeTemplate
.getProperties().get(SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
Assert.assertNotNull(serviceTemplateFilterProperty);
@@ -372,8 +428,8 @@ public class ManualVspToscaManagerImplTest {
private void validateSubstitutionMappings(SubstitutionMapping substitutionMappings,
List<Nic> nics,
String componentName) {
- Assert.assertEquals(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE + "." + componentName,
- substitutionMappings.getNode_type());
+ Assert.assertEquals(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE, substitutionMappings
+ .getNode_type());
Map<String, List<String>> capabilities = substitutionMappings.getCapabilities();
validateSubstitutionCapabilities(capabilities, componentName);
Map<String, List<String>> requirements = substitutionMappings.getRequirements();
@@ -420,7 +476,7 @@ public class ManualVspToscaManagerImplTest {
Map<String, NodeType> nodeTypes = globalSubstitutionServiceTemplate.getNode_types();
Assert.assertEquals(1, nodeTypes.size());
NodeType deploymentFlavorNodeType =
- nodeTypes.get(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE + "." + componentName);
+ nodeTypes.get(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE);
Assert.assertNotNull(deploymentFlavorNodeType);
Map<String, PropertyDefinition> properties = deploymentFlavorNodeType.getProperties();
Assert.assertNotNull(properties);
@@ -475,9 +531,9 @@ public class ManualVspToscaManagerImplTest {
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);
+ "md5");
MultiFlavorVfcImage image2 = getImageData(IMAGE_VERSION_2, IMAGE_HASH_2, IMAGE_FILE_NAME_2,
- "md5", IMAGE_FILE_FORMAT_2);
+ "md5");
images.add(image1);
images.add(image2);
imageData.put(COMPONENT_ID, images);
@@ -522,10 +578,10 @@ public class ManualVspToscaManagerImplTest {
return computeFlavor;
}
- private VendorInfo getVendorInfo(String manufacturerRefNumber, String vlmId) {
+ private VendorInfo getVendorInfo(String manufacturerRefNumber, String deploymentFlavorModel) {
VendorInfo vendorInfo = new VendorInfo();
vendorInfo.setManufacturer_reference_number(manufacturerRefNumber);
- vendorInfo.setVendor_model(vlmId);
+ vendorInfo.setVendor_model(deploymentFlavorModel);
return vendorInfo;
}
@@ -535,13 +591,13 @@ public class ManualVspToscaManagerImplTest {
return licenseFlavor;
}
- private MultiFlavorVfcImage getImageData(String imageVersion, String fileHash, String fileName,
- String fileHashType, String fileFormat) {
+ private MultiFlavorVfcImage getImageData(String imageVersion, String fileHash,
+ String fileName, String fileHashType) {
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);
+ image.setFile_name(fileName);
return image;
}
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 b2cfba7672..fe275e9d68 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
@@ -110,6 +110,31 @@ public class NicManagerImplTest {
}
@Test
+ public void testCreateWithIncorrectNicNameFormat() {
+ 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(VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED,
+ exception.code().id());
+ }
+ }
+
+ @Test
public void testCreateWithDupNicName() {
NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
Nic nic = nicEntity.getNicCompositionData();
@@ -120,7 +145,7 @@ public class NicManagerImplTest {
NicEntity nicEntityDiffName = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
Nic newNameNic = nicEntityDiffName.getNicCompositionData();
- newNameNic.setName(NIC1_ID + " Name");
+ newNameNic.setName(NIC1_ID + "_Name");
nicEntityDiffName.setNicCompositionData(newNameNic);
nicEntities.add(nicEntityDiffName);
doReturn(nicEntities).when(nicDao).list(anyObject());
@@ -282,7 +307,7 @@ public class NicManagerImplTest {
NicEntity nicEntity = new NicEntity(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
Nic nicData = new Nic();
- nicData.setName(NIC1_ID + " name updated");
+ nicData.setName(NIC1_ID + "_name_updated");
nicData.setDescription(NIC1_ID + " desc updated");
nicData.setNetworkId(NETWORK1_ID);
nicEntity.setNicCompositionData(nicData);
@@ -294,6 +319,36 @@ public class NicManagerImplTest {
verify(nicDao, never()).update(nicEntity);
}
+ @Test
+ public void testUpdateIncorrectNameFormat() {
+ doReturn(createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID))
+ .when(nicDao).get(anyObject());
+
+ CompositionEntityValidationData toBeReturned =
+ new CompositionEntityValidationData(CompositionEntityType.nic, NIC1_ID);
+ toBeReturned.setErrors(Arrays.asList("error1", "error2"));
+ doReturn(toBeReturned)
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ NicEntity nicEntity = new NicEntity(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
+ Nic nicData = new Nic();
+ nicData.setName(NIC1_ID + "_name_updated/*");
+ nicData.setDescription(NIC1_ID + " desc updated");
+ nicData.setNetworkId(NETWORK1_ID);
+ nicEntity.setNicCompositionData(nicData);
+
+ try {
+ nicManager.updateNic(nicEntity, USER);
+ Assert.fail();
+ }
+ catch (CoreException ex) {
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED,
+ ex.code().id());
+ }
+ }
+
@Test
public void testGetNonExistingNicId_negative() {
@@ -426,7 +481,7 @@ public class NicManagerImplTest {
String networkId) {
NicEntity nicEntity = new NicEntity(vspId, version, compId, nicId);
Nic nicData = new Nic();
- nicData.setName(nicId + " name");
+ nicData.setName(nicId + "_name");
nicData.setDescription(nicId + " desc");
nicData.setNetworkId(networkId);
nicEntity.setNicCompositionData(nicData);