summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org
diff options
context:
space:
mode:
authorzhaoxiangjun666 <xjzhaop@isoftstone.com>2020-09-27 20:15:36 +0800
committerChristophe Closset <christophe.closset@intl.att.com>2020-10-12 11:40:43 +0000
commit78712174a6f275fc722482ee7783dd705497baf6 (patch)
tree8d223d0b2252e1bdf19217ed60ea833c7a81194a /catalog-be/src/main/java/org
parent969d2d7c2caed78d297ccf8e0ebc9120831c18b0 (diff)
Add test code for Test Topology Auto Design- Service Import
Issue-ID: SDC-3297 Change-Id: Ia8e1f53b96a559d606356cd3072e1dac98c694e0 Signed-off-by: zhaoxiangjun666 <xjzhaop@isoftstone.com>
Diffstat (limited to 'catalog-be/src/main/java/org')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java73
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java19
2 files changed, 50 insertions, 42 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index 857c5e32b7..b47c3928e8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -522,8 +522,7 @@ public class ServiceImportBusinessLogic{
return Either.right(createArtifactsFromCsar.right().value());
}
return Either.left(createArtifactsFromCsar.left().value());
- }catch(Exception e)
- {
+ }catch(Exception e) {
log.debug("Exception occured in getResourceResponseFormatEither, message:{}", e.getMessage(), e);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
}
@@ -3026,39 +3025,7 @@ public class ServiceImportBusinessLogic{
serviceImportParseLogic.validateResourceFieldsBeforeUpdate(oldResource, newResource, inTransaction, isNested);
serviceImportParseLogic
.validateCapabilityTypesCreate(user, serviceImportParseLogic.getCapabilityTypeOperation(), newResource, AuditingActionEnum.IMPORT_RESOURCE, inTransaction);
- newResource.setContactId(newResource.getContactId().toLowerCase());
- newResource.setCreatorUserId(user.getUserId());
- newResource.setCreatorFullName(user.getFullName());
- newResource.setLastUpdaterUserId(user.getUserId());
- newResource.setLastUpdaterFullName(user.getFullName());
- newResource.setUniqueId(oldResource.getUniqueId());
- newResource.setVersion(oldResource.getVersion());
- newResource.setInvariantUUID(oldResource.getInvariantUUID());
- newResource.setLifecycleState(oldResource.getLifecycleState());
- newResource.setUUID(oldResource.getUUID());
- newResource.setNormalizedName(oldResource.getNormalizedName());
- newResource.setSystemName(oldResource.getSystemName());
- if (oldResource.getCsarUUID() != null) {
- newResource.setCsarUUID(oldResource.getCsarUUID());
- }
- if (oldResource.getImportedToscaChecksum() != null) {
- newResource.setImportedToscaChecksum(oldResource.getImportedToscaChecksum());
- }
- if (newResource.getDerivedFromGenericType() == null || newResource.getDerivedFromGenericType().isEmpty()) {
- newResource.setDerivedFromGenericType(oldResource.getDerivedFromGenericType());
- }
- if (newResource.getDerivedFromGenericVersion() == null || newResource.getDerivedFromGenericVersion().isEmpty()) {
- newResource.setDerivedFromGenericVersion(oldResource.getDerivedFromGenericVersion());
- }
- if (newResource.getToscaArtifacts() == null || newResource.getToscaArtifacts().isEmpty()) {
- serviceBusinessLogic.setToscaArtifactsPlaceHolders(newResource, user);
- }
- if (newResource.getInterfaces() == null || newResource.getInterfaces().isEmpty()) {
- newResource.setInterfaces(oldResource.getInterfaces());
- }
- if (CollectionUtils.isEmpty(newResource.getProperties())) {
- newResource.setProperties(oldResource.getProperties());
- }
+ createNewResourceToOldResource(newResource, oldResource, user);
Either<Resource, StorageOperationStatus> overrideResource = toscaOperationFacade
.overrideComponent(newResource, oldResource);
@@ -3084,6 +3051,42 @@ public class ServiceImportBusinessLogic{
}
}
+ protected void createNewResourceToOldResource(Resource newResource, Resource oldResource, User user) {
+ newResource.setContactId(newResource.getContactId().toLowerCase());
+ newResource.setCreatorUserId(user.getUserId());
+ newResource.setCreatorFullName(user.getFullName());
+ newResource.setLastUpdaterUserId(user.getUserId());
+ newResource.setLastUpdaterFullName(user.getFullName());
+ newResource.setUniqueId(oldResource.getUniqueId());
+ newResource.setVersion(oldResource.getVersion());
+ newResource.setInvariantUUID(oldResource.getInvariantUUID());
+ newResource.setLifecycleState(oldResource.getLifecycleState());
+ newResource.setUUID(oldResource.getUUID());
+ newResource.setNormalizedName(oldResource.getNormalizedName());
+ newResource.setSystemName(oldResource.getSystemName());
+ if (oldResource.getCsarUUID() != null) {
+ newResource.setCsarUUID(oldResource.getCsarUUID());
+ }
+ if (oldResource.getImportedToscaChecksum() != null) {
+ newResource.setImportedToscaChecksum(oldResource.getImportedToscaChecksum());
+ }
+ if (newResource.getDerivedFromGenericType() == null || newResource.getDerivedFromGenericType().isEmpty()) {
+ newResource.setDerivedFromGenericType(oldResource.getDerivedFromGenericType());
+ }
+ if (newResource.getDerivedFromGenericVersion() == null || newResource.getDerivedFromGenericVersion().isEmpty()) {
+ newResource.setDerivedFromGenericVersion(oldResource.getDerivedFromGenericVersion());
+ }
+ if (newResource.getToscaArtifacts() == null || newResource.getToscaArtifacts().isEmpty()) {
+ serviceBusinessLogic.setToscaArtifactsPlaceHolders(newResource, user);
+ }
+ if (newResource.getInterfaces() == null || newResource.getInterfaces().isEmpty()) {
+ newResource.setInterfaces(oldResource.getInterfaces());
+ }
+ if (CollectionUtils.isEmpty(newResource.getProperties())) {
+ newResource.setProperties(oldResource.getProperties());
+ }
+ }
+
protected Map<String, Resource> createResourcesFromYamlNodeTypesList(String yamlName, Service service, Map<String, Object> mappedToscaTemplate, boolean needLock,
Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
index 65576d1567..935a5d6796 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
@@ -2198,13 +2198,18 @@ public class ServiceImportParseLogic {
}
public void associateComponentInstancePropertiesToComponent(String yamlName, Resource resource, Map<String, List<ComponentInstanceProperty>> instProperties) {
- Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addPropToInst = toscaOperationFacade
- .associateComponentInstancePropertiesToComponent(instProperties, resource.getUniqueId());
- if (addPropToInst.isRight()) {
- log.debug("failed to associate properties of resource {} status is {}", resource.getUniqueId(),
- addPropToInst.right().value());
- throw new ComponentException(componentsUtils.getResponseFormat(
- componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName));
+ try {
+ Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addPropToInst = toscaOperationFacade
+ .associateComponentInstancePropertiesToComponent(instProperties, resource.getUniqueId());
+ if (addPropToInst.isRight()) {
+ log.debug("failed to associate properties of resource {} status is {}", resource.getUniqueId(),
+ addPropToInst.right().value());
+ throw new ComponentException(componentsUtils.getResponseFormat(
+ componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName));
+ }
+ } catch (Exception e) {
+ log.debug("Exception occured when findNodeTypeArtifactsToHandle, error is:{}", e.getMessage());
+ throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
}