aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2022-08-26 13:59:23 +0100
committerMichael Morris <michael.morris@est.tech>2022-09-14 08:24:38 +0000
commite4a10c8950c35f21fd192f54c8a293af2dd02b1a (patch)
treea3f6760d9b9424b6fed62f2755ba079c02776f75 /openecomp-be
parent1db6e26a7fa6b1afcf1562b239866198dc54ed92 (diff)
Fix 'Optional license in onboarding'-bug
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I6b63629e834b8a5002372d6af59ae0a3a9460542 Issue-ID: SDC-3601
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java17
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VendorLicenseModelDaoZusammenImpl.java14
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertor.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/test/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertorTest.java22
5 files changed, 40 insertions, 29 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index 234ee43f05..001c6c7e37 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
@@ -99,6 +99,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.LicenseType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
@@ -142,7 +143,7 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager {
- private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductManager.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class);
private VspMergeDao vspMergeDao;
private OrchestrationTemplateDao orchestrationTemplateDao;
private OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager;
@@ -386,7 +387,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private Map<String, List<ErrorMessage>> compile(String vendorSoftwareProductId, Version version, ToscaServiceModel serviceModel) {
if (isServiceModelMissing(serviceModel)) {
- return null;
+ return Collections.emptyMap();
}
enrichedServiceModelDao.deleteAll(vendorSoftwareProductId, version);
if (CollectionUtils.isNotEmpty(serviceModel.getModelList())) {
@@ -552,9 +553,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
populateVersionsForVlm(vspDetails.getVendorId(), vlmVersion);
}
final PackageInfo packageInfo = createPackageInfo(vspDetails);
- final ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils()));
- final FileContentHandler licenseArtifacts = licenseArtifactsService
- .createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion, vspDetails.getFeatureGroups());
+ final ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = new ToscaFileOutputServiceCsarImpl(
+ new AsdPackageHelper(new ManifestUtils()));
final ETSIService etsiService = new ETSIServiceImpl();
if (etsiService.hasEtsiSol261Metadata(toscaServiceModel.getArtifactFiles())) {
final FileContentHandler handler = toscaServiceModel.getArtifactFiles();
@@ -566,6 +566,11 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
packageInfo.setVendorRelease(etsiService.getHighestCompatibleSpecificationVersion(handler).getOriginalValue());
}
}
+ FileContentHandler licenseArtifacts = null;
+ if (!LicenseType.EXTERNAL.name().equals(vspDetails.getLicenseType())) {
+ licenseArtifacts = licenseArtifactsService
+ .createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion, vspDetails.getFeatureGroups());
+ }
packageInfo.setTranslatedFile(ByteBuffer.wrap(toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts)));
packageInfoDao.create(packageInfo);
return packageInfo;
@@ -613,7 +618,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private Map<String, List<ErrorMessage>> validateOrchestrationTemplate(OrchestrationTemplateEntity orchestrationTemplate) throws IOException {
if (isOrchestrationTemplateMissing(orchestrationTemplate)) {
- return null;
+ return Collections.emptyMap();
}
Map<String, List<ErrorMessage>> validationErrors = new HashMap<>();
FileContentHandler fileContentMap = CommonUtil
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java
index d43797e498..2f1d385e48 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java
@@ -19,18 +19,24 @@
*/
package org.openecomp.sdc.vendorlicense;
+import static org.openecomp.sdc.common.api.Constants.VENDOR_LICENSE_MODEL;
+import static org.openecomp.sdc.common.api.Constants.VF_LICENSE_MODEL;
+
import java.io.File;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
public final class VendorLicenseConstants {
public static final String VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE = "VendorLicenseModel";
public static final String EXTERNAL_ARTIFACTS_DIR = "Artifacts";
//todo change when separating external from internal artifacts
- public static final String VNF_ARTIFACT_NAME_WITH_PATH = EXTERNAL_ARTIFACTS_DIR + File.separator + "vf-license-model.xml";
- public static final String VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH = EXTERNAL_ARTIFACTS_DIR + File.separator + "vendor-license-model.xml";
+ public static final String VNF_ARTIFACT_NAME_WITH_PATH = EXTERNAL_ARTIFACTS_DIR + File.separator + VF_LICENSE_MODEL;
+ public static final String VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH = EXTERNAL_ARTIFACTS_DIR + File.separator + VENDOR_LICENSE_MODEL;
public static final String VENDOR_LICENSE_MODEL_ARTIFACT_REGEX_REMOVE = " xmlns=\"\"";
public static final String UNSUPPORTED_OPERATION_ERROR = "An error has occurred: Unsupported operation for 1707 release.";
+ @NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class UniqueValues {
public static final String VENDOR_NAME = "Vendor name";
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VendorLicenseModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VendorLicenseModelDaoZusammenImpl.java
index 8f974c4df8..0453b305f3 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VendorLicenseModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VendorLicenseModelDaoZusammenImpl.java
@@ -15,6 +15,7 @@
*/
package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
+import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
import static org.openecomp.sdc.versioning.dao.impl.zusammen.ItemZusammenDaoImpl.ItemInfoProperty.ITEM_TYPE;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
@@ -44,7 +45,8 @@ public class VendorLicenseModelDaoZusammenImpl implements VendorLicenseModelDao
@Override
public void registerVersioning(String versionableEntityType) {
- VersionableEntityMetadata metadata = new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "VendorLicenseModel", null, null);
+ VersionableEntityMetadata metadata = new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE,
+ null, null);
ActionVersioningManagerFactory.getInstance().createInterface().register(versionableEntityType, metadata);
}
@@ -52,7 +54,7 @@ public class VendorLicenseModelDaoZusammenImpl implements VendorLicenseModelDao
public Collection<VendorLicenseModelEntity> list(VendorLicenseModelEntity vendorLicenseModelEntity) {
ElementToVLMGeneralConvertor convertor = new ElementToVLMGeneralConvertor();
return zusammenAdaptor.listItems(ZusammenUtil.createSessionContext()).stream()
- .filter(item -> "VendorLicenseModel".equals(item.getInfo().getProperty(ITEM_TYPE.getName()))).map(item -> {
+ .filter(item -> VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE.equals(item.getInfo().getProperty(ITEM_TYPE.getName()))).map(item -> {
VendorLicenseModelEntity entity = convertor.convert(item);
entity.setId(item.getId().getValue());
entity.setVersion(null);
@@ -109,10 +111,10 @@ public class VendorLicenseModelDaoZusammenImpl implements VendorLicenseModelDao
}
private void addVlmToInfo(Info info, VendorLicenseModelEntity vendorLicenseModel) {
- info.addProperty(InfoPropertyName.name.name(), vendorLicenseModel.getVendorName());
- info.addProperty(InfoPropertyName.description.name(), vendorLicenseModel.getDescription());
- info.addProperty(InfoPropertyName.iconRef.name(), vendorLicenseModel.getIconRef());
+ info.addProperty(InfoPropertyName.NAME.name(), vendorLicenseModel.getVendorName());
+ info.addProperty(InfoPropertyName.DESCRIPTION.name(), vendorLicenseModel.getDescription());
+ info.addProperty(InfoPropertyName.ICON_REF.name(), vendorLicenseModel.getIconRef());
}
- public enum InfoPropertyName {name, description, iconRef,}
+ public enum InfoPropertyName {NAME, DESCRIPTION, ICON_REF,}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertor.java
index e274e264c0..aef20cf490 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertor.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertor.java
@@ -55,9 +55,9 @@ public class ElementToVLMGeneralConvertor extends ElementConvertor {
private VendorLicenseModelEntity mapInfoToVendorLicenseModelEntity(Info info) {
VendorLicenseModelEntity vendorLicenseModelEntity = new VendorLicenseModelEntity();
- vendorLicenseModelEntity.setVendorName(info.getProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.name.name()));
- vendorLicenseModelEntity.setDescription(info.getProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.description.name()));
- vendorLicenseModelEntity.setIconRef(info.getProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.iconRef.name()));
+ vendorLicenseModelEntity.setVendorName(info.getProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.NAME.name()));
+ vendorLicenseModelEntity.setDescription(info.getProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.DESCRIPTION.name()));
+ vendorLicenseModelEntity.setIconRef(info.getProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.ICON_REF.name()));
return vendorLicenseModelEntity;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/test/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertorTest.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/test/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertorTest.java
index 45660a6854..9d9f002c9b 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/test/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/test/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertorTest.java
@@ -15,15 +15,16 @@
*/
package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.item.Info;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VendorLicenseModelDaoZusammenImpl;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-public class ElementToVLMGeneralConvertorTest {
+class ElementToVLMGeneralConvertorTest {
private static final String ENTITY_NAME = "entityTestName";
private static final String ENTITY_DESCRIPTION = "entityTestDesc";
@@ -31,30 +32,27 @@ public class ElementToVLMGeneralConvertorTest {
private ElementToVLMGeneralConvertor converter = new ElementToVLMGeneralConvertor();
@Test
- public void shouldConvertElementToVendorLicenseModelEntity() {
+ void shouldConvertElementToVendorLicenseModelEntity() {
ZusammenElement elementToConvert = new ZusammenElement();
Info info = new Info();
- info.addProperty("name",ENTITY_NAME);
- info.addProperty("description",ENTITY_DESCRIPTION);
+ info.addProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.NAME.name(), ENTITY_NAME);
+ info.addProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.DESCRIPTION.name(), ENTITY_DESCRIPTION);
elementToConvert.setInfo(info);
VendorLicenseModelEntity result = converter.convert(elementToConvert);
assertEquals(ENTITY_NAME, result.getVendorName());
assertEquals(ENTITY_DESCRIPTION, result.getDescription());
-
-
}
@Test
- public void shouldConvertElementInfoToVendorLicenseModelEntity() {
+ void shouldConvertElementInfoToVendorLicenseModelEntity() {
ElementInfo elementInfo = new ElementInfo();
Info info = new Info();
- info.addProperty("name",ENTITY_NAME);
- info.addProperty("description",ENTITY_DESCRIPTION);
+ info.addProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.NAME.name(), ENTITY_NAME);
+ info.addProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.DESCRIPTION.name(), ENTITY_DESCRIPTION);
elementInfo.setInfo(info);
VendorLicenseModelEntity result = converter.convert(elementInfo);
assertEquals(ENTITY_NAME, result.getVendorName());
assertEquals(ENTITY_DESCRIPTION, result.getDescription());
}
-
}