From 78712174a6f275fc722482ee7783dd705497baf6 Mon Sep 17 00:00:00 2001 From: zhaoxiangjun666 Date: Sun, 27 Sep 2020 20:15:36 +0800 Subject: Add test code for Test Topology Auto Design- Service Import Issue-ID: SDC-3297 Change-Id: Ia8e1f53b96a559d606356cd3072e1dac98c694e0 Signed-off-by: zhaoxiangjun666 --- .../impl/ServiceImportBusinessLogic.java | 73 +++++++++++----------- .../components/impl/ServiceImportParseLogic.java | 19 +++--- 2 files changed, 50 insertions(+), 42 deletions(-) (limited to 'catalog-be/src/main/java/org') 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 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 createResourcesFromYamlNodeTypesList(String yamlName, Service service, Map mappedToscaTemplate, boolean needLock, Map>> nodeTypesArtifactsToHandle, List nodeTypesNewCreatedArtifacts, Map 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> instProperties) { - Either>, 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>, 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); } } -- cgit 1.2.3-korg