summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2022-09-15 14:27:20 +0100
committerMichael Morris <michael.morris@est.tech>2022-09-19 08:39:08 +0000
commit3935993a90fe768585ab5e908d6334567c1823de (patch)
tree6539da2e6809e0faa6859e5b9deb2ce6cdd93181
parent0d38a72c022fa93dba0bf052f893e51fb73d3552 (diff)
Import unknown group types during Service import
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: Ic435ee0c440dd8ed64339bab08e921687d23b9c0 Issue-ID: SDC-4176
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java34
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/OnboardedCsarInfo.java58
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java50
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java71
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java123
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/model/ToscaTypeImportData.java13
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java4
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupTypeData.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java46
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperation.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java60
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java6
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementLifecycleOperation.java38
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java18
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadata.java32
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java15
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java33
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UniqueIdBuilder.java93
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/GroupTypeDefinitionTest.java90
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadataTest.java32
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UniqueIdBuilderTest.java306
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinition.java88
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaTypeDataDefinition.java34
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java2
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinitionTest.java274
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/AtomicOperationUtils.java2035
31 files changed, 1798 insertions, 1797 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java
index b845b104fe..5f49bd7bf2 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarInfo.java
@@ -89,13 +89,11 @@ public abstract class CsarInfo {
private boolean isUpdate;
@Getter
private Map<String, Resource> createdNodes;
- protected Map<String, Object> datatypeDefinitions;
protected Map<String, Object> artifacttypeDefinitions;
private Map<String, Object> policytypeDefinitions;
-
- public CsarInfo(User modifier, String csarUUID, Map<String, byte[]> csar, String vfResourceName, String mainTemplateName,
- String mainTemplateContent, boolean isUpdate) {
+ protected CsarInfo(User modifier, String csarUUID, Map<String, byte[]> csar, String vfResourceName, String mainTemplateName,
+ String mainTemplateContent, boolean isUpdate) {
this.vfResourceName = vfResourceName;
this.modifier = modifier;
this.csarUUID = csarUUID;
@@ -109,13 +107,13 @@ public abstract class CsarInfo {
this.createdNodes = new HashMap<>();
this.nonManoConfiguration = NonManoConfigurationManager.getInstance().getNonManoConfiguration();
}
-
+
public String getVfResourceName() {
return vfResourceName;
}
- public CsarInfo(final User modifier, final String csarUUID, final String csarVersionId, final Map<String, byte[]> csarContent,
- final String vfResourceName, final String mainTemplateName, final String mainTemplateContent, final boolean isUpdate) {
+ protected CsarInfo(final User modifier, final String csarUUID, final String csarVersionId, final Map<String, byte[]> csarContent,
+ final String vfResourceName, final String mainTemplateName, final String mainTemplateContent, final boolean isUpdate) {
this(modifier, csarUUID, csarContent, vfResourceName, mainTemplateName, mainTemplateContent, isUpdate);
this.csarVersionId = csarVersionId;
}
@@ -169,16 +167,18 @@ public abstract class CsarInfo {
public void setUpdate(boolean isUpdate) {
this.isUpdate = isUpdate;
}
-
+
public abstract Map<String, NodeTypeInfo> extractTypesInfo();
-
+
/**
* Get the data types defined in the CSAR
- *
+ *
* @return map with the data type name as key and representaion of the data type defintion as value
*/
public abstract Map<String, Object> getDataTypes();
+ public abstract Map<String, Object> getGroupTypes();
+
public abstract Map<String, Object> getArtifactTypes();
public Map<String, Object> getPolicyTypes() {
@@ -188,11 +188,10 @@ public abstract class CsarInfo {
}
return policytypeDefinitions;
}
-
+
@SuppressWarnings("unchecked")
protected Map<String, Object> getTypesFromTemplate(final Map<String, Object> mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum type) {
- final Either<Object, ResultStatusEnum> dataTypesEither = findToscaElement(mappedToscaTemplate, type,
- ToscaElementTypeEnum.MAP);
+ final Either<Object, ResultStatusEnum> dataTypesEither = findToscaElement(mappedToscaTemplate, type, ToscaElementTypeEnum.MAP);
if (dataTypesEither != null && dataTypesEither.isLeft()) {
return (Map<String, Object>) dataTypesEither.left().value();
}
@@ -200,15 +199,14 @@ public abstract class CsarInfo {
}
@SuppressWarnings("unchecked")
- protected Map<String, Object> getTypesFromTemplate(final Map<String, Object> mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum type, Collection<String> names) {
+ protected Map<String, Object> getTypesFromTemplate(final Map<String, Object> mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum type,
+ Collection<String> names) {
Map<String, Object> allTypes = getTypesFromTemplate(mappedToscaTemplate, type);
final Map<String, Object> typesToReturn = new HashMap<>();
final Stream<Map.Entry<String, Object>> requestedTypes = allTypes.entrySet().stream().filter(entry -> names.contains(entry.getKey()));
- requestedTypes.forEach(requestedType -> {
- typesToReturn.put(requestedType.getKey(), requestedType.getValue());
- });
+ requestedTypes.forEach(requestedType -> typesToReturn.put(requestedType.getKey(), requestedType.getValue()));
return typesToReturn;
}
@@ -223,7 +221,7 @@ public abstract class CsarInfo {
@SuppressWarnings("unchecked")
protected NodeTypeInfo buildNodeTypeInfo(final Map.Entry<String, Object> nodeType, final String templateFileName,
- final Map<String, Object> mappedToscaTemplate) {
+ final Map<String, Object> mappedToscaTemplate) {
final NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
nodeTypeInfo.setSubstitutionMapping(false);
nodeTypeInfo.setNested(true);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/OnboardedCsarInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/OnboardedCsarInfo.java
index 8ab05b9bc8..68a51e3ed3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/OnboardedCsarInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/OnboardedCsarInfo.java
@@ -22,6 +22,10 @@
package org.openecomp.sdc.be.components.csar;
import static org.openecomp.sdc.be.components.impl.ImportUtils.findToscaElement;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DATA_TYPES;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.GROUP_TYPES;
+
+import fj.data.Either;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -38,13 +42,12 @@ import org.openecomp.sdc.be.model.NodeTypeInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.tosca.CsarUtils;
import org.openecomp.sdc.be.utils.TypeUtils;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.common.api.Constants;
import org.yaml.snakeyaml.Yaml;
-import fj.data.Either;
/**
- * Provides access to the contents of a CSAR which has been created through the SDC onboarding
- * process
+ * Provides access to the contents of a CSAR which has been created through the SDC onboarding process
*/
public class OnboardedCsarInfo extends CsarInfo {
@@ -55,13 +58,13 @@ public class OnboardedCsarInfo extends CsarInfo {
}
public OnboardedCsarInfo(final User modifier, final String csarUUID, final Map<String, byte[]> csar, final String vfResourceName,
- final String mainTemplateName, final String mainTemplateContent, final boolean isUpdate) {
+ final String mainTemplateName, final String mainTemplateContent, final boolean isUpdate) {
super(modifier, csarUUID, csar, vfResourceName, mainTemplateName, mainTemplateContent, isUpdate);
this.globalSubstitutes = getGlobalSubstitutes(csar);
}
public OnboardedCsarInfo(final User modifier, final String csarUUID, final String csarVersionId, final Map<String, byte[]> csarContent,
- final String vfResourceName, final String mainTemplateName, final String mainTemplateContent, final boolean isUpdate) {
+ final String vfResourceName, final String mainTemplateName, final String mainTemplateContent, final boolean isUpdate) {
super(modifier, csarUUID, csarVersionId, csarContent, vfResourceName, mainTemplateName, mainTemplateContent, isUpdate);
this.globalSubstitutes = getGlobalSubstitutes(csar);
}
@@ -93,13 +96,13 @@ public class OnboardedCsarInfo extends CsarInfo {
@SuppressWarnings("unchecked")
private void extractNodeTypeInfo(final Map<String, NodeTypeInfo> nodeTypesInfo, final Set<String> nodeTypesUsedInNodeTemplates,
- final Map.Entry<String, byte[]> entry) {
+ final Map.Entry<String, byte[]> entry) {
if (isAServiceTemplate(entry.getKey()) && !isGlobalSubstitute(entry.getKey())) {
final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(new String(entry.getValue()));
findToscaElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.SUBSTITUTION_MAPPINGS, ToscaElementTypeEnum.MAP).right()
- .on(sub -> handleSubstitutionMappings(nodeTypesInfo, entry, mappedToscaTemplate, (Map<String, Object>) sub));
+ .on(sub -> handleSubstitutionMappings(nodeTypesInfo, entry, mappedToscaTemplate, (Map<String, Object>) sub));
final Either<Object, ResultStatusEnum> nodeTypesEither =
- findToscaElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TEMPLATES, ToscaElementTypeEnum.MAP);
+ findToscaElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TEMPLATES, ToscaElementTypeEnum.MAP);
if (nodeTypesEither.isLeft()) {
final Map<String, Map<String, Object>> nodeTemplates = (Map<String, Map<String, Object>>) nodeTypesEither.left().value();
nodeTypesUsedInNodeTemplates.addAll(findNodeTypesUsedInNodeTemplates(nodeTemplates));
@@ -113,15 +116,16 @@ public class OnboardedCsarInfo extends CsarInfo {
private boolean isGlobalSubstitute(final String fileName) {
return fileName.equalsIgnoreCase(Constants.GLOBAL_SUBSTITUTION_TYPES_SERVICE_TEMPLATE)
- || fileName.equalsIgnoreCase(Constants.ABSTRACT_SUBSTITUTE_GLOBAL_TYPES_SERVICE_TEMPLATE);
+ || fileName.equalsIgnoreCase(Constants.ABSTRACT_SUBSTITUTE_GLOBAL_TYPES_SERVICE_TEMPLATE);
}
private ResultStatusEnum handleSubstitutionMappings(final Map<String, NodeTypeInfo> nodeTypesInfo, final Map.Entry<String, byte[]> entry,
- final Map<String, Object> mappedToscaTemplate, final Map<String, Object> substitutionMappings) {
+ final Map<String, Object> mappedToscaTemplate,
+ final Map<String, Object> substitutionMappings) {
final Set<String> nodeTypesDefinedInTemplate = findNodeTypesDefinedInTemplate(mappedToscaTemplate);
if (substitutionMappings.containsKey(TypeUtils.ToscaTagNamesEnum.NODE_TYPE.getElementName())
- && !nodeTypesDefinedInTemplate.contains(substitutionMappings.get(TypeUtils.ToscaTagNamesEnum.NODE_TYPE.getElementName()))) {
+ && !nodeTypesDefinedInTemplate.contains(substitutionMappings.get(TypeUtils.ToscaTagNamesEnum.NODE_TYPE.getElementName()))) {
NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
nodeTypeInfo.setSubstitutionMapping(true);
nodeTypeInfo.setType((String) substitutionMappings.get(TypeUtils.ToscaTagNamesEnum.NODE_TYPE.getElementName()));
@@ -135,7 +139,7 @@ public class OnboardedCsarInfo extends CsarInfo {
@SuppressWarnings("unchecked")
private Set<String> findNodeTypesDefinedInTemplate(final Map<String, Object> mappedToscaTemplate) {
final Either<Object, ResultStatusEnum> nodeTypesEither =
- findToscaElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES, ToscaElementTypeEnum.MAP);
+ findToscaElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES, ToscaElementTypeEnum.MAP);
if (nodeTypesEither.isLeft()) {
final Map<String, Object> nodeTypes = (Map<String, Object>) nodeTypesEither.left().value();
return nodeTypes.keySet();
@@ -149,7 +153,7 @@ public class OnboardedCsarInfo extends CsarInfo {
final String yamlFileContents = new String(entry.getValue());
final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(yamlFileContents);
Either<Object, ResultStatusEnum> nodeTypesEither =
- findToscaElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES, ToscaElementTypeEnum.MAP);
+ findToscaElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES, ToscaElementTypeEnum.MAP);
if (nodeTypesEither.isLeft()) {
Map<String, Object> nodeTypes = (Map<String, Object>) nodeTypesEither.left().value();
for (Map.Entry<String, Object> nodeType : nodeTypes.entrySet()) {
@@ -174,9 +178,9 @@ public class OnboardedCsarInfo extends CsarInfo {
private void addGlobalSubstitutionsToNodeTypes(final Set<String> nodeTypesUsedInNodeTemplates, final Map<String, NodeTypeInfo> nodeTypesInfo) {
for (Map.Entry<String, byte[]> entry : globalSubstitutes) {
final String yamlFileContents = new String(entry.getValue());
- final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(yamlFileContents);
+ final Map<String, Object> mappedToscaTemplate = new Yaml().load(yamlFileContents);
final Either<Object, ResultStatusEnum> nodeTypesEither =
- findToscaElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES, ToscaElementTypeEnum.MAP);
+ findToscaElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES, ToscaElementTypeEnum.MAP);
if (nodeTypesEither.isLeft()) {
final Map<String, Object> nodeTypes = (Map<String, Object>) nodeTypesEither.left().value();
for (final Map.Entry<String, Object> nodeType : nodeTypes.entrySet()) {
@@ -204,16 +208,22 @@ public class OnboardedCsarInfo extends CsarInfo {
@Override
public Map<String, Object> getDataTypes() {
- if (datatypeDefinitions == null) {
- datatypeDefinitions = new HashMap<>();
- for (Map.Entry<String, byte[]> entry : globalSubstitutes) {
- final String yamlFileContents = new String(entry.getValue());
- final Map<String, Object> mappedToscaTemplate = new Yaml().load(yamlFileContents);
- datatypeDefinitions.putAll(getTypesFromTemplate(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.DATA_TYPES));
- }
- datatypeDefinitions.putAll(getTypesFromTemplate(mappedToscaMainTemplate, TypeUtils.ToscaTagNamesEnum.DATA_TYPES));
+ return getTypes(DATA_TYPES);
+ }
+
+ @Override
+ public Map<String, Object> getGroupTypes() {
+ return getTypes(GROUP_TYPES);
+ }
+
+ private Map<String, Object> getTypes(ToscaTagNamesEnum toscaTag) {
+ final Map<String, Object> types = new HashMap<>();
+ for (Map.Entry<String, byte[]> entry : globalSubstitutes) {
+ final Map<String, Object> mappedToscaTemplate = new Yaml().load(new String(entry.getValue()));
+ types.putAll(getTypesFromTemplate(mappedToscaTemplate, toscaTag));
}
- return datatypeDefinitions;
+ types.putAll(getTypesFromTemplate(mappedToscaMainTemplate, toscaTag));
+ return types;
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
index 4a9fa5eb18..aeef3acd64 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
@@ -79,17 +79,17 @@ public class ServiceCsarInfo extends CsarInfo {
final List<Path> importFilePaths = getTemplateImportFilePaths(mappedToscaMainTemplate, fileParentDir);
importFilePaths.stream().filter(path -> !filesHandled.contains(path)).forEach(
- importFilePath -> {
- byte[] importFile = csar.get(importFilePath.toString());
- if (importFile != null) {
- filesHandled.add(importFilePath);
- Map<String, Object> mappedImportFile = new Yaml().load(new String(csar.get(importFilePath.toString())));
- templateImports.put(importFilePath.toString(), mappedImportFile);
- templateImports.putAll(getTemplateImports(csar, mappedImportFile, importFilePath.getParent(), filesHandled));
- } else {
- log.info("Import {} cannot be found in CSAR", importFilePath.toString());
- }
- });
+ importFilePath -> {
+ byte[] importFile = csar.get(importFilePath.toString());
+ if (importFile != null) {
+ filesHandled.add(importFilePath);
+ Map<String, Object> mappedImportFile = new Yaml().load(new String(csar.get(importFilePath.toString())));
+ templateImports.put(importFilePath.toString(), mappedImportFile);
+ templateImports.putAll(getTemplateImports(csar, mappedImportFile, importFilePath.getParent(), filesHandled));
+ } else {
+ log.info("Import {} cannot be found in CSAR", importFilePath.toString());
+ }
+ });
return templateImports;
}
@@ -105,7 +105,8 @@ public class ServiceCsarInfo extends CsarInfo {
if (importsList.get(0) instanceof String) {
List<Path> importPaths = new ArrayList<>();
importsList.stream()
- .forEach(importPath -> importPaths.add(fileParentDir == null ? Paths.get((String) importPath) : fileParentDir.resolve(Paths.get((String) importPath)).normalize()));
+ .forEach(importPath -> importPaths.add(fileParentDir == null ? Paths.get((String) importPath)
+ : fileParentDir.resolve(Paths.get((String) importPath)).normalize()));
return importPaths;
} else if (importsList.get(0) instanceof Map) {
return getTemplateImportFilePathsMultiLineGrammar(importsList, fileParentDir);
@@ -145,11 +146,19 @@ public class ServiceCsarInfo extends CsarInfo {
@Override
public Map<String, Object> getDataTypes() {
- final Map<String, Object> definitions = new HashMap<>();
- mainTemplateImports.entrySet().stream()
- .forEach(entry -> definitions.putAll(getTypesFromTemplate(entry.getValue(), TypeUtils.ToscaTagNamesEnum.DATA_TYPES)));
- definitions.putAll(getTypesFromTemplate(getMappedToscaMainTemplate(), TypeUtils.ToscaTagNamesEnum.DATA_TYPES));
- return definitions;
+ return getTypes(ToscaTagNamesEnum.DATA_TYPES);
+ }
+
+ @Override
+ public Map<String, Object> getGroupTypes() {
+ return getTypes(ToscaTagNamesEnum.GROUP_TYPES);
+ }
+
+ private Map<String, Object> getTypes(ToscaTagNamesEnum toscaTag) {
+ final Map<String, Object> types = new HashMap<>();
+ mainTemplateImports.entrySet().stream().forEach(entry -> types.putAll(getTypesFromTemplate(entry.getValue(), toscaTag)));
+ types.putAll(getTypesFromTemplate(getMappedToscaMainTemplate(), toscaTag));
+ return types;
}
public Map<String, Object> getArtifactTypes() {
@@ -210,7 +219,7 @@ public class ServiceCsarInfo extends CsarInfo {
findToscaElement((Map<String, Object>) nodeTypeDef.getMappedNodeType().getValue(), TypeUtils.ToscaTagNamesEnum.DERIVED_FROM,
ToscaElementTypeEnum.STRING);
if (derivedFromTypeEither.isLeft()) {
- recursiveNodeTypesToGet.add((String)derivedFromTypeEither.left().value());
+ recursiveNodeTypesToGet.add((String) derivedFromTypeEither.left().value());
}
});
recursiveNodeTypesToGet.removeAll(nodeTypesToGet);
@@ -251,7 +260,8 @@ public class ServiceCsarInfo extends CsarInfo {
private NodeTypeMetadata getMetaDataFromTemplate(Map<String, Object> mappedResourceTemplate, String nodeTemplateType) {
NodeTypeMetadata nodeTypeMetadata = new NodeTypeMetadata();
- Either<Map<String, Object>, ImportUtils.ResultStatusEnum> metadataEither = ImportUtils.findFirstToscaMapElement(mappedResourceTemplate, TypeUtils.ToscaTagNamesEnum.METADATA);
+ Either<Map<String, Object>, ImportUtils.ResultStatusEnum> metadataEither = ImportUtils.findFirstToscaMapElement(mappedResourceTemplate,
+ TypeUtils.ToscaTagNamesEnum.METADATA);
if (metadataEither.isLeft() && metadataEither.left().value().get("type").equals(ResourceTypeEnum.VFC.getValue())) {
Map<String, Object> metadata = metadataEither.left().value();
createMetadataFromTemplate(nodeTypeMetadata, metadata, nodeTemplateType);
@@ -261,7 +271,7 @@ public class ServiceCsarInfo extends CsarInfo {
return nodeTypeMetadata;
}
- private void createMetadataFromTemplate(NodeTypeMetadata nodeTypeMetadata, Map<String, Object> metadata, String nodeTemplateType) {
+ private void createMetadataFromTemplate(NodeTypeMetadata nodeTypeMetadata, Map<String, Object> metadata, String nodeTemplateType) {
nodeTypeMetadata.setToscaName(nodeTemplateType);
nodeTypeMetadata.setContactId(getModifier().getUserId());
nodeTypeMetadata.setDescription((String) metadata.get("description"));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
index 09a84887aa..b57e2cb2cb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
@@ -148,7 +148,6 @@ public class YamlTemplateParsingHandler {
private static final int SUB_MAPPING_CAPABILITY_OWNER_NAME_IDX = 0;
private static final int SUB_MAPPING_CAPABILITY_NAME_IDX = 1;
private static final Logger log = Logger.getLogger(YamlTemplateParsingHandler.class);
- private static final String WITH_ATTRIBUTE = "with attribute '{}': '{}'";
private final Gson gson = new Gson();
private final JanusGraphDao janusGraphDao;
private final GroupTypeBusinessLogic groupTypeBusinessLogic;
@@ -184,8 +183,8 @@ public class YamlTemplateParsingHandler {
parsedToscaYamlInfo.setInputs(getInputs(mappedTopologyTemplateInputs));
parsedToscaYamlInfo.setOutputs(getOutputs(mappedTopologyTemplateOutputs));
parsedToscaYamlInfo.setInstances(getInstances(
- mappedToscaTemplate,
- createdNodesToscaResourceNames
+ mappedToscaTemplate,
+ createdNodesToscaResourceNames
));
associateRelationshipTemplatesToInstances(parsedToscaYamlInfo.getInstances(), mappedTopologyTemplate);
parsedToscaYamlInfo.setGroups(getGroups(mappedToscaTemplate, component.getModel()));
@@ -389,32 +388,32 @@ public class YamlTemplateParsingHandler {
}
private Map<String, UploadComponentInstanceInfo> getInstances(
- Map<String, Object> toscaJson,
- Map<String, String> createdNodesToscaResourceNames
+ Map<String, Object> toscaJson,
+ Map<String, String> createdNodesToscaResourceNames
) {
Map<String, Object> nodeTemplates = findFirstToscaMapElement(toscaJson, NODE_TEMPLATES)
- .left().on(err -> new HashMap<>());
+ .left().on(err -> new HashMap<>());
if (nodeTemplates.isEmpty()) {
return Collections.emptyMap();
}
return getInstances(
- toscaJson,
- createdNodesToscaResourceNames,
- nodeTemplates
+ toscaJson,
+ createdNodesToscaResourceNames,
+ nodeTemplates
);
}
private Map<String, UploadComponentInstanceInfo> getInstances(
- Map<String, Object> toscaJson,
- Map<String, String> createdNodesToscaResourceNames,
- Map<String, Object> nodeTemplates
+ Map<String, Object> toscaJson,
+ Map<String, String> createdNodesToscaResourceNames,
+ Map<String, Object> nodeTemplates
) {
Map<String, Object> substitutionMappings = getSubstitutionMappings(toscaJson);
return nodeTemplates.entrySet().stream()
.map(node -> buildModuleComponentInstanceInfo(
- node,
- substitutionMappings,
- createdNodesToscaResourceNames
+ node,
+ substitutionMappings,
+ createdNodesToscaResourceNames
))
.collect(Collectors.toMap(UploadComponentInstanceInfo::getName, i -> i));
}
@@ -504,7 +503,7 @@ public class YamlTemplateParsingHandler {
interfaceDefinition.getOperations()
.forEach((operationType, operationValue) ->
operationUiList.add(buildOperation(interfaceDefinition.getType(), operationType, (Map<String, Object>) operationValue))
- ));
+ ));
return operationUiList;
}
@@ -793,9 +792,9 @@ public class YamlTemplateParsingHandler {
@SuppressWarnings("unchecked")
private UploadComponentInstanceInfo buildModuleComponentInstanceInfo(
- Map.Entry<String, Object> nodeTemplateJsonEntry,
- Map<String, Object> substitutionMappings,
- Map<String, String> createdNodesToscaResourceNames
+ Map.Entry<String, Object> nodeTemplateJsonEntry,
+ Map<String, Object> substitutionMappings,
+ Map<String, String> createdNodesToscaResourceNames
) {
UploadComponentInstanceInfo nodeTemplateInfo = new UploadComponentInstanceInfo();
nodeTemplateInfo.setName(nodeTemplateJsonEntry.getKey());
@@ -860,12 +859,12 @@ public class YamlTemplateParsingHandler {
}
private void updateInterfaces(
- UploadComponentInstanceInfo nodeTemplateInfo,
- Map<String, Object> nodeTemplateJsonMap
- ){
+ UploadComponentInstanceInfo nodeTemplateInfo,
+ Map<String, Object> nodeTemplateJsonMap
+ ) {
if (nodeTemplateJsonMap.containsKey(INTERFACES.getElementName())) {
Map<String, UploadInterfaceInfo> interfaces = buildInterfacesModuleFromYaml(
- nodeTemplateJsonMap
+ nodeTemplateJsonMap
);
if (!interfaces.isEmpty()) {
nodeTemplateInfo.setInterfaces(interfaces);
@@ -946,7 +945,8 @@ public class YamlTemplateParsingHandler {
return moduleRequirements;
}
- private void addModuleNodeTemplateReq(Map<String, List<UploadReqInfo>> moduleRequirements, Object requirementJson, String requirementName, String nodeName) {
+ private void addModuleNodeTemplateReq(Map<String, List<UploadReqInfo>> moduleRequirements, Object requirementJson, String requirementName,
+ String nodeName) {
UploadReqInfo requirement = buildModuleNodeTemplateReg(requirementJson, nodeName);
requirement.setName(requirementName);
if (moduleRequirements.containsKey(requirementName)) {
@@ -1107,7 +1107,7 @@ public class YamlTemplateParsingHandler {
if (nodeTemplateJsonMap.containsKey(RELATIONSHIP.getElementName())) {
final String template = (String) nodeTemplateJsonMap.get(RELATIONSHIP.getElementName());
if (StringUtils.isNotEmpty(nodeName) && template.contains(nodeName)) {
- regTemplateInfo.setRelationshipTemplate(template);
+ regTemplateInfo.setRelationshipTemplate(template);
}
}
}
@@ -1115,7 +1115,7 @@ public class YamlTemplateParsingHandler {
}
private Map<String, UploadAttributeInfo> buildAttributeModuleFromYaml(
- Map<String, Object> nodeTemplateJsonMap) {
+ Map<String, Object> nodeTemplateJsonMap) {
Map<String, UploadAttributeInfo> moduleAttribute = new HashMap<>();
Either<Map<String, Object>, ResultStatusEnum> toscaAttributes = findFirstToscaMapElement(nodeTemplateJsonMap, ATTRIBUTES);
if (toscaAttributes.isLeft()) {
@@ -1142,7 +1142,7 @@ public class YamlTemplateParsingHandler {
}
private Map<String, UploadInterfaceInfo> buildInterfacesModuleFromYaml(
- Map<String, Object> nodeTemplateJsonMap
+ Map<String, Object> nodeTemplateJsonMap
) {
Map<String, UploadInterfaceInfo> moduleInterfaces = new HashMap<>();
Either<Map<String, Object>, ResultStatusEnum> toscaInterfaces = findFirstToscaMapElement(nodeTemplateJsonMap, INTERFACES);
@@ -1286,8 +1286,8 @@ public class YamlTemplateParsingHandler {
) {
if (value instanceof Map) {
log.debug("Creating interface operation input '{}'", inputName);
- Gson gson = new Gson();
- Type type = new TypeToken<LinkedHashMap<String, Object>>(){}.getType();
+ Type type = new TypeToken<LinkedHashMap<String, Object>>() {
+ }.getType();
String stringValue = gson.toJson(value, type);
operationInput.setValue(stringValue);
}
@@ -1307,10 +1307,10 @@ public class YamlTemplateParsingHandler {
}
final ArtifactDataDefinition artifactDataDefinition = new ArtifactDataDefinition();
if (operationDefinitionMap.get(IMPLEMENTATION.getElementName()) instanceof Map &&
- ((Map)operationDefinitionMap.get(IMPLEMENTATION.getElementName())).containsKey("primary")) {
-
- final Object primary = ((Map)operationDefinitionMap.get(IMPLEMENTATION.getElementName())).get("primary");
- if(primary instanceof Map) {
+ ((Map) operationDefinitionMap.get(IMPLEMENTATION.getElementName())).containsKey("primary")) {
+
+ final Object primary = ((Map) operationDefinitionMap.get(IMPLEMENTATION.getElementName())).get("primary");
+ if (primary instanceof Map) {
Map<String, Object> implDetails = (Map) primary;
if (implDetails.get("file") != null) {
@@ -1324,10 +1324,9 @@ public class YamlTemplateParsingHandler {
artifactDataDefinition.setArtifactVersion(implDetails.get("artifact_version").toString());
}
- if(implDetails.get("properties") instanceof Map) {
- List<PropertyDataDefinition> operationProperties = artifactDataDefinition.getProperties() == null ? new ArrayList<>() : artifactDataDefinition.getProperties();
+ if (implDetails.get("properties") instanceof Map) {
Map<String, Object> properties = (Map<String, Object>) implDetails.get("properties");
- properties.forEach((k,v) -> {
+ properties.forEach((k, v) -> {
ToscaPropertyType type = getTypeFromObject(v);
if (type != null) {
PropertyDataDefinition propertyDef = new PropertyDataDefinition();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java
index 6bbeed0dd0..474df3f9e5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CommonImportManager.java
@@ -69,8 +69,7 @@ public class CommonImportManager {
private final ModelOperation modelOperation;
@Autowired
- public CommonImportManager(final ComponentsUtils componentsUtils,
- final PropertyOperation propertyOperation,
+ public CommonImportManager(final ComponentsUtils componentsUtils, final PropertyOperation propertyOperation,
final ModelOperation modelOperation) {
this.componentsUtils = componentsUtils;
this.propertyOperation = propertyOperation;
@@ -509,8 +508,8 @@ public class CommonImportManager {
}
private <T extends ToscaTypeDataDefinition> T setNonToscaMetaDataOnType(Map<String, ToscaTypeMetadata> toscaTypeMetadata, T toscaTypeDefinition) {
- String toscaType = toscaTypeDefinition.getType();
- ToscaTypeMetadata typeMetaData = toscaTypeMetadata.get(toscaType);
+ final String toscaType = toscaTypeDefinition.getType();
+ final ToscaTypeMetadata typeMetaData = toscaTypeMetadata.get(toscaType);
if (typeMetaData == null) {
log.debug("failing while trying to associate metadata for type {}. type not exist", toscaType);
throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
@@ -538,7 +537,7 @@ public class CommonImportManager {
public void addTypesToDefaultImports(final ElementTypeEnum elementTypeEnum, final String typesYaml, final String modelName) {
modelOperation.addTypesToDefaultImports(elementTypeEnum, typesYaml, modelName);
}
-
+
public void updateTypesInAdditionalTypesImport(final ElementTypeEnum elementTypeEnum, final String dataTypeYml, final String modelName) {
modelOperation.updateTypesInAdditionalTypesImport(elementTypeEnum, dataTypeYml, modelName);
}
@@ -548,7 +547,4 @@ public class CommonImportManager {
T3 createElement(T1 firstArg, T2 secondArg);
}
-
-
-
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 9e04572075..ac01be010d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -3727,7 +3727,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (sourceAttributeName.equals(destAttribute.getName())) {
log.debug("Start to copy the attribute exists {}", sourceAttributeName);
sourceAttribute.setUniqueId(
- UniqueIdBuilder.buildResourceInstanceUniuqeId("attribute", destComponentInstanceId.split("\\.")[1], sourceAttributeName));
+ UniqueIdBuilder.buildResourceInstanceUniqueId("attribute", destComponentInstanceId.split("\\.")[1], sourceAttributeName));
Either<ComponentInstanceAttribute, ResponseFormat> updateAttributeValueEither = createOrUpdateAttributeValueForCopyPaste(
ComponentTypeEnum.SERVICE, destComponent.getUniqueId(), destComponentInstanceId, sourceAttribute, userId);
if (updateAttributeValueEither.isRight()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java
index 135003e7f8..7ed833ac1d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java
@@ -33,7 +33,6 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.components.impl.model.ToscaTypeImportData;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
@@ -73,7 +72,8 @@ public class GroupTypeImportManager {
}
public Either<List<ImmutablePair<GroupTypeDefinition, Boolean>>, ResponseFormat> createGroupTypes(ToscaTypeImportData toscaTypeImportData,
- String modelName, final boolean includeToModelDefaultImports) {
+ String modelName,
+ final boolean includeToModelDefaultImports) {
final Either<List<ImmutablePair<GroupTypeDefinition, Boolean>>, ResponseFormat> elementTypes = commonImportManager.createElementTypes(
toscaTypeImportData, this::createGroupTypesFromYml, this::upsertGroupTypesByDao, modelName);
if (includeToModelDefaultImports && StringUtils.isNotEmpty(modelName)) {
@@ -100,7 +100,7 @@ public class GroupTypeImportManager {
List<GroupTypeDefinition> groupTypesToCreate, String modelName) {
return commonImportManager.createElementTypesWithVersionByDao(groupTypesToCreate, this::validateGroupType,
groupType -> new ImmutablePair<>(ElementTypeEnum.GROUP_TYPE, UniqueIdBuilder.buildGroupTypeUid(groupType.getModel(),
- groupType.getType(), groupType.getVersion(), NodeTypeEnum.GroupType.getName()).toLowerCase()),
+ groupType.getType(), groupType.getVersion())),
groupTypeOperation::getLatestGroupTypeByType,
groupTypeOperation::addGroupType, this::updateGroupType, modelName);
}
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 1e867e66da..a5e20f30eb 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
@@ -36,6 +36,7 @@ import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -60,6 +61,7 @@ import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.impl.exceptions.BusinessLogicException;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
+import org.openecomp.sdc.be.components.impl.model.ToscaTypeImportData;
import org.openecomp.sdc.be.components.impl.utils.CINodeFilterUtils;
import org.openecomp.sdc.be.components.impl.utils.CreateServiceFromYamlParameter;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
@@ -81,8 +83,8 @@ import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SubPropertyToscaFunction;
+import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -102,6 +104,7 @@ import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.DistributionStatusEnum;
import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupTypeDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
@@ -133,10 +136,12 @@ import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
+import org.openecomp.sdc.be.model.normatives.ToscaTypeMetadata;
import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.ArtifactTypeOperation;
+import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
@@ -144,6 +149,7 @@ import org.openecomp.sdc.be.tosca.CsarUtils;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
import org.openecomp.sdc.be.ui.model.OperationUi;
import org.openecomp.sdc.be.utils.TypeUtils;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.Constants;
@@ -193,6 +199,9 @@ public class ServiceImportBusinessLogic {
private ApplicationDataTypeCache applicationDataTypeCache;
private final ArtifactTypeOperation artifactTypeOperation;
+ private final GroupTypeImportManager groupTypeImportManager;
+ private final GroupTypeOperation groupTypeOperation;
+
public ServiceImportBusinessLogic(final GroupBusinessLogic groupBusinessLogic, final ArtifactsBusinessLogic artifactsBusinessLogic,
final ComponentsUtils componentsUtils, final ToscaOperationFacade toscaOperationFacade,
final ServiceBusinessLogic serviceBusinessLogic, final CsarBusinessLogic csarBusinessLogic,
@@ -203,7 +212,8 @@ public class ServiceImportBusinessLogic {
final ResourceImportManager resourceImportManager, final JanusGraphDao janusGraphDao,
final IGraphLockOperation graphLockOperation, final ToscaFunctionService toscaFunctionService,
final DataTypeBusinessLogic dataTypeBusinessLogic, final ArtifactTypeOperation artifactTypeOperation,
- ArtifactTypeImportManager artifactTypeImportManager) {
+ final ArtifactTypeImportManager artifactTypeImportManager, final GroupTypeImportManager groupTypeImportManager,
+ final GroupTypeOperation groupTypeOperation) {
this.componentsUtils = componentsUtils;
this.toscaOperationFacade = toscaOperationFacade;
this.serviceBusinessLogic = serviceBusinessLogic;
@@ -223,6 +233,8 @@ public class ServiceImportBusinessLogic {
this.dataTypeBusinessLogic = dataTypeBusinessLogic;
this.artifactTypeOperation = artifactTypeOperation;
this.artifactTypeImportManager = artifactTypeImportManager;
+ this.groupTypeImportManager = groupTypeImportManager;
+ this.groupTypeOperation = groupTypeOperation;
}
@Autowired
@@ -267,19 +279,28 @@ public class ServiceImportBusinessLogic {
if (MapUtils.isNotEmpty(dataTypesToCreate)) {
dataTypeBusinessLogic.createDataTypeFromYaml(new Yaml().dump(dataTypesToCreate), service.getModel(), true);
dataTypesToCreate.entrySet().stream().forEach(createdOrUpdatedDataType -> {
- applicationDataTypeCache.reload(service.getModel(), UniqueIdBuilder.buildDataTypeUid(service.getModel(), createdOrUpdatedDataType.getKey()));
+ applicationDataTypeCache.reload(service.getModel(),
+ UniqueIdBuilder.buildDataTypeUid(service.getModel(), createdOrUpdatedDataType.getKey()));
});
}
final Map<String, Object> artifactTypesToCreate = getArtifactTypesToCreate(service.getModel(), csarInfo);
if (MapUtils.isNotEmpty(artifactTypesToCreate)) {
- artifactTypeImportManager.createArtifactTypes(new Yaml().dump(artifactTypesToCreate), service.getModel(),true);
+ artifactTypeImportManager.createArtifactTypes(new Yaml().dump(artifactTypesToCreate), service.getModel(), true);
}
final List<NodeTypeDefinition> nodeTypesToCreate = getNodeTypesToCreate(service.getModel(), csarInfo);
if (CollectionUtils.isNotEmpty(nodeTypesToCreate)) {
createNodeTypes(nodeTypesToCreate, service.getModel(), csarInfo.getModifier());
}
+
+ final Map<String, Object> groupTypesToCreate = getGroupTypesToCreate(service.getModel(), csarInfo);
+ if (MapUtils.isNotEmpty(groupTypesToCreate)) {
+ final Map<String, ToscaTypeMetadata> toscaTypeMetadata = fillToscaTypeMetadata(groupTypesToCreate);
+ final ToscaTypeImportData toscaTypeImportData = new ToscaTypeImportData(new Yaml().dump(groupTypesToCreate), toscaTypeMetadata);
+ groupTypeImportManager.createGroupTypes(toscaTypeImportData, service.getModel(), true);
+ }
+
Map<String, NodeTypeInfo> nodeTypesInfo = csarInfo.extractTypesInfo();
Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes = serviceImportParseLogic
.findNodeTypesArtifactsToHandle(nodeTypesInfo, csarInfo, service);
@@ -298,6 +319,47 @@ public class ServiceImportBusinessLogic {
}
}
+ private Map<String, ToscaTypeMetadata> fillToscaTypeMetadata(final Map<String, Object> groupTypesToCreate) {
+ final Map<String, ToscaTypeMetadata> toscaTypeMetadata = new HashMap<>();
+ groupTypesToCreate.entrySet().forEach(entry -> {
+ final ToscaTypeMetadata metadata = new ToscaTypeMetadata();
+ metadata.setIcon(getIconFromGroupType(entry.getValue()));
+ metadata.setDisplayName(extractDisplayName(entry.getKey()));
+ toscaTypeMetadata.put(entry.getKey(), metadata);
+ });
+ return toscaTypeMetadata;
+ }
+
+ private String extractDisplayName(final String key) {
+ final String[] split = key.split("\\.");
+ return split[split.length - 1];
+ }
+
+ private String getIconFromGroupType(final Object value) {
+ final Either<GroupTypeDefinition, StorageOperationStatus> groupType = groupTypeOperation.getLatestGroupTypeByType(
+ (String) ((LinkedHashMap) value).get(ToscaTagNamesEnum.DERIVED_FROM.getElementName()), null);
+ if (groupType.isLeft()) {
+ return groupType.left().value().getIcon();
+ }
+ return null;
+ }
+
+ private Map<String, Object> getGroupTypesToCreate(final String model, final CsarInfo csarInfo) {
+ final Map<String, Object> groupTypesToCreate = new HashMap<>();
+ final Map<String, Object> groupTypes = csarInfo.getGroupTypes();
+ if (MapUtils.isNotEmpty(groupTypes)) {
+ for (final Entry<String, Object> entry : groupTypes.entrySet()) {
+ final Either<GroupTypeDefinition, StorageOperationStatus> result
+ = groupTypeOperation.getGroupTypeByUid(UniqueIdBuilder.buildGroupTypeUid(model, entry.getKey(), "1.0"));
+ if (result.isRight() && result.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
+ groupTypesToCreate.put(entry.getKey(), entry.getValue());
+ log.info("Deploying new group type {} to model {} from package {}", entry.getKey(), model, csarInfo.getCsarUUID());
+ }
+ }
+ }
+ return groupTypesToCreate;
+ }
+
private Map<String, Object> getDatatypesToCreate(final String model, final CsarInfo csarInfo) {
final Map<String, Object> dataTypesToCreate = new HashMap<>();
@@ -306,11 +368,11 @@ public class ServiceImportBusinessLogic {
UniqueIdBuilder.buildDataTypeUid(model, dataTypeEntry.getKey()));
if (result.isRight() && result.right().value().equals(JanusGraphOperationStatus.NOT_FOUND)) {
dataTypesToCreate.put(dataTypeEntry.getKey(), dataTypeEntry.getValue());
- log.info("Deploying unknown type " + dataTypeEntry.getKey() + " to model " + model + " from package " + csarInfo.getCsarUUID());
+ log.info("Deploying unknown type {} to model {} from package {}", dataTypeEntry.getKey(), model, csarInfo.getCsarUUID());
}
if (hasNewProperties(result, (Map<String, Map<String, Object>>) dataTypeEntry.getValue())) {
dataTypesToCreate.put(dataTypeEntry.getKey(), dataTypeEntry.getValue());
- log.info("Deploying new version of type " + dataTypeEntry.getKey() + " to model " + model + " from package " + csarInfo.getCsarUUID());
+ log.info("Deploying new version of type {} to model {} from package {}", dataTypeEntry.getKey(), model, csarInfo.getCsarUUID());
}
}
return dataTypesToCreate;
@@ -322,7 +384,7 @@ public class ServiceImportBusinessLogic {
if (MapUtils.isNotEmpty(artifactTypesMap)) {
for (final Entry<String, Object> artifactTypeEntry : artifactTypesMap.entrySet()) {
final Either<ArtifactTypeDefinition, StorageOperationStatus> result =
- artifactTypeOperation.getArtifactTypeByUid(UniqueIdBuilder.buildArtifactTypeUid(model,artifactTypeEntry.getKey()));
+ artifactTypeOperation.getArtifactTypeByUid(UniqueIdBuilder.buildArtifactTypeUid(model, artifactTypeEntry.getKey()));
if (result.isRight() && StorageOperationStatus.NOT_FOUND.equals(result.right().value())) {
artifactTypesToCreate.put(artifactTypeEntry.getKey(), artifactTypeEntry.getValue());
log.info("Deploying new artifact type={}, to model={}, from package={}",
@@ -332,10 +394,11 @@ public class ServiceImportBusinessLogic {
}
return artifactTypesToCreate;
}
-
- private boolean hasNewProperties(final Either<DataTypeDefinition, JanusGraphOperationStatus> result, final Map<String, Map<String, Object>> dataType) {
+
+ private boolean hasNewProperties(final Either<DataTypeDefinition, JanusGraphOperationStatus> result,
+ final Map<String, Map<String, Object>> dataType) {
return result.isLeft() && dataType.containsKey("properties") && result.left().value().getProperties() != null
- && result.left().value().getProperties().size() != dataType.get("properties").size();
+ && result.left().value().getProperties().size() != dataType.get("properties").size();
}
private void createNodeTypes(List<NodeTypeDefinition> nodeTypesToCreate, String model, User user) {
@@ -347,7 +410,7 @@ public class ServiceImportBusinessLogic {
nodeTypeMetadataList.add(nodeType.getNodeTypeMetadata());
});
nodeTypesMetadataList.setNodeMetadataList(nodeTypeMetadataList);
- resourceImportManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, user, model,true, false);
+ resourceImportManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, user, model, true, false);
}
private List<NodeTypeDefinition> getNodeTypesToCreate(final String model, final ServiceCsarInfo csarInfo) {
@@ -361,10 +424,10 @@ public class ServiceImportBusinessLogic {
} else if (result.isLeft()) {
Resource latestResource = (Resource) result.left().value();
Entry<String, Object> latestMappedToscaTemplate = getResourceToscaTemplate(latestResource.getUniqueId(),
- latestResource.getToscaArtifacts().get(ToscaExportHandler.ASSET_TOSCA_TEMPLATE), csarInfo.getModifier().getUserId());
+ latestResource.getToscaArtifacts().get(ToscaExportHandler.ASSET_TOSCA_TEMPLATE), csarInfo.getModifier().getUserId());
Map<String, Object> mappedToscaTemplate = (Map<String, Object>) nodeTypeDefinition.getMappedNodeType().getValue();
Map<String, Object> newMappedToscaTemplate =
- getNewChangesToToscaTemplate(mappedToscaTemplate, (Map<String, Object>) latestMappedToscaTemplate.getValue());
+ getNewChangesToToscaTemplate(mappedToscaTemplate, (Map<String, Object>) latestMappedToscaTemplate.getValue());
if (!newMappedToscaTemplate.equals(latestMappedToscaTemplate.getValue())) {
latestMappedToscaTemplate.setValue(newMappedToscaTemplate);
nodeTypeDefinition.setMappedNodeType(latestMappedToscaTemplate);
@@ -378,15 +441,14 @@ public class ServiceImportBusinessLogic {
private Entry<String, Object> getResourceToscaTemplate(String uniqueId, ArtifactDefinition assetToscaTemplate, String userId) {
String assetToToscaTemplate = assetToscaTemplate.getUniqueId();
ImmutablePair<String, byte[]> toscaTemplate = artifactsBusinessLogic.
- handleDownloadRequestById(uniqueId, assetToToscaTemplate, userId, ComponentTypeEnum.RESOURCE, null, null);
+ handleDownloadRequestById(uniqueId, assetToToscaTemplate, userId, ComponentTypeEnum.RESOURCE, null, null);
Map<String, Object> mappedToscaTemplate = new Yaml().load(new String(toscaTemplate.right));
Either<Map<String, Object>, ImportUtils.ResultStatusEnum> eitherNodeTypes =
- findFirstToscaMapElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES);
+ findFirstToscaMapElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES);
if (eitherNodeTypes.isRight()) {
throw new ComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE);
}
- Entry<String, Object> entry = eitherNodeTypes.left().value().entrySet().iterator().next();
- return entry;
+ return eitherNodeTypes.left().value().entrySet().iterator().next();
}
private Map<String, Object> getNewChangesToToscaTemplate(Map<String, Object> mappedToscaTemplate, Map<String, Object> latestMappedToscaTemplate) {
@@ -1929,9 +1991,9 @@ public class ServiceImportBusinessLogic {
}
final var property = new ComponentInstanceProperty(curPropertyDef, value, null);
String validatedPropValue = serviceBusinessLogic.validatePropValueBeforeCreate(property, value, true, allDataTypes);
-
+
addSubPropertyYamlToscaFunctions(validatedPropValue, value, property.getType(), propertyInfo, allDataTypes);
-
+
if (CollectionUtils.isNotEmpty(propertyInfo.getSubPropertyToscaFunctions())) {
validatedPropValue = value;
}
@@ -1984,12 +2046,14 @@ public class ServiceImportBusinessLogic {
instProperties.put(currentCompInstance.getUniqueId(), instPropList);
return componentsUtils.getResponseFormat(ActionStatus.OK);
}
-
+
private boolean tryHandlingAsYamlToscaFunction(String validatedPropValue, String value, UploadPropInfo propertyInfo) {
- return StringUtils.isEmpty(validatedPropValue) && StringUtils.isNotEmpty(value) && propertyInfo.getToscaFunction() == null && CollectionUtils.isEmpty(propertyInfo.getSubPropertyToscaFunctions());
+ return StringUtils.isEmpty(validatedPropValue) && StringUtils.isNotEmpty(value) && propertyInfo.getToscaFunction() == null
+ && CollectionUtils.isEmpty(propertyInfo.getSubPropertyToscaFunctions());
}
-
- private void addSubPropertyYamlToscaFunctions(final String validatedPropValue, final String value, final String propertyType, final UploadPropInfo propertyInfo, final Map<String, DataTypeDefinition> allDataTypes) {
+
+ private void addSubPropertyYamlToscaFunctions(final String validatedPropValue, final String value, final String propertyType,
+ final UploadPropInfo propertyInfo, final Map<String, DataTypeDefinition> allDataTypes) {
if (StringUtils.isNotEmpty(validatedPropValue) || StringUtils.isEmpty(value) || ToscaPropertyType.isValidType(propertyType) != null) {
return;
}
@@ -1998,14 +2062,14 @@ public class ServiceImportBusinessLogic {
final DataTypeDefinition dataTypeDefinition = allDataTypes.get(propertyType);
final List<String> propertyNames =
- dataTypeDefinition.getProperties().stream().map(PropertyDataDefinition::getName).collect(Collectors.toList());
+ dataTypeDefinition.getProperties().stream().map(PropertyDataDefinition::getName).collect(Collectors.toList());
boolean hasSubPropertyValues = jsonObject.entrySet().stream().allMatch(entry -> propertyNames.contains(entry.getKey()));
if (hasSubPropertyValues) {
for (final PropertyDefinition prop : dataTypeDefinition.getProperties()) {
if (propertyInfo.getSubPropertyToscaFunctions().stream()
- .anyMatch(subPropertyToscaFunction -> subPropertyToscaFunction.getSubPropertyPath().get(0).equals(prop.getName()))) {
+ .anyMatch(subPropertyToscaFunction -> subPropertyToscaFunction.getSubPropertyPath().get(0).equals(prop.getName()))) {
continue;
}
Optional<SubPropertyToscaFunction> subPropertyToscaFunction = createSubPropertyYamlToscaFunction(jsonObject, prop, allDataTypes);
@@ -2018,14 +2082,15 @@ public class ServiceImportBusinessLogic {
log.info("Cannot create YAML value for {}", value);
}
}
-
- private Optional<SubPropertyToscaFunction> createSubPropertyYamlToscaFunction(final JsonObject jsonObject, final PropertyDefinition prop, final Map<String, DataTypeDefinition> allDataTypes) {
+
+ private Optional<SubPropertyToscaFunction> createSubPropertyYamlToscaFunction(final JsonObject jsonObject, final PropertyDefinition prop,
+ final Map<String, DataTypeDefinition> allDataTypes) {
JsonElement propJsonElement = jsonObject.get(prop.getName());
if (propJsonElement != null) {
final String subPropValue = propJsonElement.toString();
final ComponentInstanceProperty subProperty = new ComponentInstanceProperty(prop, subPropValue, null);
final String validateSubPropValue =
- serviceBusinessLogic.validatePropValueBeforeCreate(subProperty, subPropValue, true, allDataTypes);
+ serviceBusinessLogic.validatePropValueBeforeCreate(subProperty, subPropValue, true, allDataTypes);
if (StringUtils.isEmpty(validateSubPropValue) && StringUtils.isNotEmpty(subPropValue)) {
try {
@@ -2114,7 +2179,7 @@ public class ServiceImportBusinessLogic {
private void mergeOperationInputDefinitions(ListDataDefinition<OperationInputDefinition> inputsFromNodeType,
ListDataDefinition<OperationInputDefinition> instanceInputs) {
if (inputsFromNodeType == null || CollectionUtils.isEmpty(inputsFromNodeType.getListToscaDataDefinition()) || instanceInputs == null
- || CollectionUtils.isEmpty(instanceInputs.getListToscaDataDefinition())) {
+ || CollectionUtils.isEmpty(instanceInputs.getListToscaDataDefinition())) {
return;
}
instanceInputs.getListToscaDataDefinition().forEach(
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/model/ToscaTypeImportData.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/model/ToscaTypeImportData.java
index a5416dd73d..61757956ff 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/model/ToscaTypeImportData.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/model/ToscaTypeImportData.java
@@ -20,23 +20,18 @@
package org.openecomp.sdc.be.components.impl.model;
import java.util.Map;
+import lombok.Getter;
import org.openecomp.sdc.be.model.normatives.ToscaTypeMetadata;
+@Getter
public class ToscaTypeImportData {
- private String toscaTypesYml;
- private Map<String, ToscaTypeMetadata> toscaTypeMetadata;
+ private final String toscaTypesYml;
+ private final Map<String, ToscaTypeMetadata> toscaTypeMetadata;
public ToscaTypeImportData(String toscaTypesYml, Map<String, ToscaTypeMetadata> toscaTypeMetadata) {
this.toscaTypesYml = toscaTypesYml;
this.toscaTypeMetadata = toscaTypeMetadata;
}
- public String getToscaTypesYml() {
- return toscaTypesYml;
- }
-
- public Map<String, ToscaTypeMetadata> getToscaTypeMetadata() {
- return toscaTypeMetadata;
- }
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
index 6b92c4a3ea..e4b6dd4021 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
@@ -91,6 +91,7 @@ import org.openecomp.sdc.be.model.ComponentMetadataDefinition;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupTypeDefinition;
import org.openecomp.sdc.be.model.IPropertyInputCommon;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
@@ -113,6 +114,7 @@ import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.ArtifactTypeOperation;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.servlets.AbstractValidationsServlet;
@@ -139,6 +141,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
private final ArtifactTypeOperation artifactTypeOperation = mock(ArtifactTypeOperation.class);
private final DataTypeBusinessLogic dataTypeBusinessLogic = mock(DataTypeBusinessLogic.class);
private final ArtifactTypeImportManager artifactTypeImportManager = mock(ArtifactTypeImportManager.class);
+ private final GroupTypeOperation groupTypeOperation = mock(GroupTypeOperation.class);
@InjectMocks
private ServiceImportBusinessLogic sIBL;
@@ -260,6 +263,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
.thenReturn(resourceTemplate);
when(toscaOperationFacade.updatePropertyOfComponent(eq(oldService), any(PropertyDefinition.class))).thenReturn(Either.left(null));
when(toscaOperationFacade.updateComponentInstancePropsToComponent(anyMap(), anyString())).thenReturn(Either.left(null));
+ when(groupTypeOperation.getGroupTypeByUid(anyString())).thenReturn(Either.left(new GroupTypeDefinition()));
Service result = sIBL.createService(oldService, AuditingActionEnum.CREATE_RESOURCE, user, payload, payloadName);
assertNotNull(result);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupTypeData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupTypeData.java
index 9fde326a43..92eca86efb 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupTypeData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupTypeData.java
@@ -31,9 +31,9 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public class GroupTypeData extends GraphNode {
- private static Type listType = new TypeToken<List<String>>() {
+ private static final Type listType = new TypeToken<List<String>>() {
}.getType();
- private static Type mapType = new TypeToken<HashMap<String, String>>() {
+ private static final Type mapType = new TypeToken<HashMap<String, String>>() {
}.getType();
private GroupTypeDataDefinition groupTypeDataDefinition;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java
index c1045e6746..4da57ab444 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java
@@ -725,8 +725,8 @@ public class ArtifactsOperations extends BaseOperation {
if (triple.getMiddle()) {
List<String> pathKeys = new ArrayList<>();
pathKeys.add(instanceId);
- status = deleteToscaDataDeepElement(componentId, edgeLabelEnum, vertexTypeEnum, artifactFromGraph.getArtifactLabel(), pathKeys,
- JsonPresentationFields.ARTIFACT_LABEL);
+ status = deleteToscaDataDeepElement(componentId, edgeLabelEnum, artifactFromGraph.getArtifactLabel(), pathKeys
+ );
} else {
status = deleteToscaDataElement(componentId, edgeLabelEnum, vertexTypeEnum, artifactFromGraph.getArtifactLabel(),
JsonPresentationFields.ARTIFACT_LABEL);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java
index 054ed9fe7e..af8414dc81 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java
@@ -46,7 +46,6 @@ import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.dao.jsongraph.utils.IdBuilderUtils;
-import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
@@ -597,7 +596,6 @@ public abstract class BaseOperation {
public <T extends ToscaDataDefinition> StorageOperationStatus deleteToscaDataDeepElementsBlockOfToscaElement(String toscaElementUid,
EdgeLabelEnum edgeLabel,
- VertexTypeEnum vertexLabel,
String key) {
StorageOperationStatus statusRes = null;
Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
@@ -609,7 +607,7 @@ public abstract class BaseOperation {
statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
}
if (statusRes == null) {
- statusRes = deleteToscaDataDeepElementsBlockToToscaElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, key);
+ statusRes = deleteToscaDataDeepElementsBlockToToscaElement(getToscaElementRes.left().value(), edgeLabel, key);
}
if (statusRes == null) {
statusRes = StorageOperationStatus.OK;
@@ -619,7 +617,6 @@ public abstract class BaseOperation {
public <T extends ToscaDataDefinition> StorageOperationStatus deleteToscaDataDeepElementsBlockToToscaElement(GraphVertex toscaElement,
EdgeLabelEnum edgeLabel,
- VertexTypeEnum vertexLabel,
String key) {
StorageOperationStatus result = null;
GraphVertex toscaDataVertex = null;
@@ -1081,10 +1078,9 @@ public abstract class BaseOperation {
*
* @param toscaElementUid
* @param edgeLabel
- * @param vertexLabel
* @return
*/
- public StorageOperationStatus removeToscaData(String toscaElementUid, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel) {
+ public StorageOperationStatus removeToscaData(String toscaElementUid, EdgeLabelEnum edgeLabel) {
StorageOperationStatus statusRes = StorageOperationStatus.OK;
Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
@@ -1095,7 +1091,7 @@ public abstract class BaseOperation {
statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
}
if (statusRes == StorageOperationStatus.OK) {
- statusRes = removeToscaDataVertex(getToscaElementRes.left().value(), edgeLabel, vertexLabel);
+ statusRes = removeToscaDataVertex(getToscaElementRes.left().value(), edgeLabel);
}
return statusRes;
}
@@ -1105,10 +1101,9 @@ public abstract class BaseOperation {
*
* @param toscaElement
* @param edgeLabel
- * @param vertexLabel
* @return
*/
- public StorageOperationStatus removeToscaDataVertex(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel) {
+ private StorageOperationStatus removeToscaDataVertex(GraphVertex toscaElement, EdgeLabelEnum edgeLabel) {
StorageOperationStatus result = null;
GraphVertex toscaDataVertex = null;
Iterator<Edge> edges = null;
@@ -1208,7 +1203,7 @@ public abstract class BaseOperation {
statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
}
if (statusRes == StorageOperationStatus.OK) {
- statusRes = deleteToscaDataElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, uniqueKey, mapKeyField);
+ statusRes = deleteToscaDataElement(getToscaElementRes.left().value(), edgeLabel, uniqueKey);
}
return statusRes;
}
@@ -1218,14 +1213,12 @@ public abstract class BaseOperation {
*
* @param toscaElementUid
* @param edgeLabel
- * @param vertexLabel
* @param uniqueKey
* @param pathKeys
- * @param mapKeyField
* @return
*/
- public StorageOperationStatus deleteToscaDataDeepElement(String toscaElementUid, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel,
- String uniqueKey, List<String> pathKeys, JsonPresentationFields mapKeyField) {
+ public StorageOperationStatus deleteToscaDataDeepElement(String toscaElementUid, EdgeLabelEnum edgeLabel,
+ String uniqueKey, List<String> pathKeys) {
StorageOperationStatus statusRes = StorageOperationStatus.OK;
Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
getToscaElementRes = janusGraphDao.getVertexById(toscaElementUid, JsonParseFlagEnum.NoParse);
@@ -1236,7 +1229,7 @@ public abstract class BaseOperation {
statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
}
if (statusRes == StorageOperationStatus.OK) {
- statusRes = deleteToscaDataDeepElement(getToscaElementRes.left().value(), edgeLabel, vertexLabel, uniqueKey, pathKeys, mapKeyField);
+ statusRes = deleteToscaDataDeepElement(getToscaElementRes.left().value(), edgeLabel, uniqueKey, pathKeys);
}
return statusRes;
}
@@ -1246,21 +1239,19 @@ public abstract class BaseOperation {
*
* @param toscaElement
* @param edgeLabel
- * @param vertexLabel
* @param uniqueKey
* @param pathKeys
- * @param mapKeyField
* @return
*/
- public StorageOperationStatus deleteToscaDataDeepElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel,
- String uniqueKey, List<String> pathKeys, JsonPresentationFields mapKeyField) {
+ public StorageOperationStatus deleteToscaDataDeepElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
+ String uniqueKey, List<String> pathKeys) {
List<String> uniqueKeys = new ArrayList<>();
uniqueKeys.add(uniqueKey);
- return deleteToscaDataDeepElements(toscaElement, edgeLabel, vertexLabel, uniqueKeys, pathKeys, mapKeyField);
+ return deleteToscaDataDeepElements(toscaElement, edgeLabel, uniqueKeys, pathKeys);
}
- public StorageOperationStatus deleteToscaDataDeepElements(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel,
- List<String> uniqueKeys, List<String> pathKeys, JsonPresentationFields mapKeyField) {
+ public StorageOperationStatus deleteToscaDataDeepElements(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
+ List<String> uniqueKeys, List<String> pathKeys) {
StorageOperationStatus result = null;
GraphVertex toscaDataVertex;
Map<String, ToscaDataDefinition> existingToscaDataMap = null;
@@ -1304,13 +1295,11 @@ public abstract class BaseOperation {
*
* @param toscaElement
* @param edgeLabel
- * @param vertexLabel
* @param uniqueKey
- * @param mapKeyField
* @return
*/
- public StorageOperationStatus deleteToscaDataElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexLabel,
- String uniqueKey, JsonPresentationFields mapKeyField) {
+ public StorageOperationStatus deleteToscaDataElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel,
+ String uniqueKey) {
List<String> uniqueKeys = new ArrayList<>();
uniqueKeys.add(uniqueKey);
return deleteToscaDataElements(toscaElement, edgeLabel, uniqueKeys);
@@ -1470,8 +1459,7 @@ public abstract class BaseOperation {
}
protected GroupInstanceDataDefinition buildGroupInstanceDataDefinition(GroupDataDefinition group,
- ComponentInstanceDataDefinition componentInstance,
- Map<String, ArtifactDataDefinition> instDeplArtifMap) {
+ ComponentInstanceDataDefinition componentInstance) {
String componentInstanceName = componentInstance.getName();
Long creationDate = System.currentTimeMillis();
GroupInstanceDataDefinition groupInstance = new GroupInstanceDataDefinition();
@@ -1485,7 +1473,7 @@ public abstract class BaseOperation {
groupInstance.setGroupName(group.getName());
groupInstance.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(groupInstance.getName()));
groupInstance
- .setUniqueId(UniqueIdBuilder.buildResourceInstanceUniuqeId(componentInstance.getUniqueId(), groupUid, groupInstance.getNormalizedName()));
+ .setUniqueId(UniqueIdBuilder.buildResourceInstanceUniqueId(componentInstance.getUniqueId(), groupUid, groupInstance.getNormalizedName()));
groupInstance.setArtifacts(group.getArtifacts());
groupInstance.setArtifactsUuid(group.getArtifactsUuid());
groupInstance.setProperties(group.getProperties());
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperation.java
index 67eaae74ea..184e337e9b 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperation.java
@@ -143,12 +143,12 @@ public class GroupsOperation extends BaseOperation {
private StorageOperationStatus removeCalculatedCapabilityFromComponent(String componentId, String groupId) {
return deleteToscaDataDeepElementsBlockOfToscaElement(componentId, EdgeLabelEnum.CALCULATED_CAPABILITIES,
- VertexTypeEnum.CALCULATED_CAPABILITIES, groupId);
+ groupId);
}
private StorageOperationStatus removeCalculatedCapabilityPropertiesFromComponent(String componentId, String groupId) {
return deleteToscaDataDeepElementsBlockOfToscaElement(componentId, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES,
- VertexTypeEnum.CALCULATED_CAP_PROPERTIES, groupId);
+ groupId);
}
public Either<List<GroupDefinition>, StorageOperationStatus> createGroups(Component component, Map<String, GroupDataDefinition> groups) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java
index 786c98d1a7..0de48b7d77 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java
@@ -87,9 +87,9 @@ public class InterfaceOperation extends BaseOperation {
public Either<String, StorageOperationStatus> deleteInterface(final Component component, final String interfacesToDelete) {
final String componentId = component.getUniqueId();
if (isVfc(component)) {
- return deleteInterface(componentId, interfacesToDelete, EdgeLabelEnum.INTERFACE_ARTIFACTS, VertexTypeEnum.INTERFACE_ARTIFACTS);
+ return deleteInterface(componentId, interfacesToDelete, EdgeLabelEnum.INTERFACE_ARTIFACTS);
} else {
- return deleteInterface(componentId, interfacesToDelete, EdgeLabelEnum.INTERFACE, VertexTypeEnum.INTERFACE);
+ return deleteInterface(componentId, interfacesToDelete, EdgeLabelEnum.INTERFACE);
}
}
@@ -98,7 +98,7 @@ public class InterfaceOperation extends BaseOperation {
}
private Either<String, StorageOperationStatus> deleteInterface(final String componentId, final String interfacesToDelete,
- final EdgeLabelEnum edgeLabel, final VertexTypeEnum vertexType) {
+ final EdgeLabelEnum edgeLabel) {
StorageOperationStatus statusRes = deleteToscaDataElements(componentId, edgeLabel, Collections.singletonList(interfacesToDelete));
if (!statusRes.equals(StorageOperationStatus.OK)) {
return Either.right(statusRes);
@@ -109,7 +109,7 @@ public class InterfaceOperation extends BaseOperation {
}
final Map<String, InterfaceDataDefinition> interfaceDataDefinitionMap = interfaceEither.left().value();
if (MapUtils.isEmpty(interfaceDataDefinitionMap)) {
- statusRes = removeToscaData(componentId, edgeLabel, vertexType);
+ statusRes = removeToscaData(componentId, edgeLabel);
if (!statusRes.equals(StorageOperationStatus.OK)) {
return Either.right(statusRes);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
index 910b9e3afa..901da1dd73 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
@@ -154,7 +154,7 @@ public class NodeTemplateOperation extends BaseOperation {
}
public static String createCapPropertyKey(String key, String instanceId) {
- StringBuffer sb = new StringBuffer(instanceId);
+ StringBuilder sb = new StringBuilder(instanceId);
sb.append(ModelConverter.CAP_PROP_DELIM).append(instanceId).append(ModelConverter.CAP_PROP_DELIM).append(key);
return sb.toString();
}
@@ -189,7 +189,7 @@ public class NodeTemplateOperation extends BaseOperation {
componentInstanceData = buildComponentInstanceDataDefinition(componentInstance, container.getUniqueId(),
newInstanceNameRes.left().value(), true, originToscaElement);
addComponentInstanceRes = addComponentInstanceToTopologyTemplate(container, originToscaElement, componentInstanceData,
- metadataVertex.left().value(), allowDeleted, user);
+ metadataVertex.left().value(), allowDeleted);
if (addComponentInstanceRes.isRight()) {
StorageOperationStatus status = addComponentInstanceRes.right().value();
if (status == StorageOperationStatus.NOT_FOUND) {
@@ -240,7 +240,7 @@ public class NodeTemplateOperation extends BaseOperation {
: calcCap.get(componentInstanceData.getUniqueId());
/******** capability ****************************/
StorageOperationStatus status = deleteToscaDataDeepElementsBlockOfToscaElement(updatedContainer.getUniqueId(),
- EdgeLabelEnum.CALCULATED_CAPABILITIES, VertexTypeEnum.CALCULATED_CAPABILITIES, componentInstanceData.getUniqueId());
+ EdgeLabelEnum.CALCULATED_CAPABILITIES, componentInstanceData.getUniqueId());
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove calculated capabilty for instance {} in container {}. error {] ",
componentInstanceData.getUniqueId(), updatedContainer.getUniqueId(), status);
@@ -263,7 +263,7 @@ public class NodeTemplateOperation extends BaseOperation {
/******** capability property ****************************/
status = deleteToscaDataDeepElementsBlockOfToscaElement(updatedContainer.getUniqueId(), EdgeLabelEnum.CALCULATED_CAP_PROPERTIES,
- VertexTypeEnum.CALCULATED_CAP_PROPERTIES, componentInstanceData.getUniqueId());
+ componentInstanceData.getUniqueId());
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
"Failed to remove calculated capabilty properties for instance {} in container {}. error {] ",
@@ -302,7 +302,7 @@ public class NodeTemplateOperation extends BaseOperation {
calcReg == null || !calcReg.containsKey(componentInstanceData.getUniqueId()) ? new MapListRequirementDataDefinition()
: calcReg.get(componentInstanceData.getUniqueId());
status = deleteToscaDataDeepElementsBlockOfToscaElement(updatedContainer.getUniqueId(), EdgeLabelEnum.CALCULATED_REQUIREMENTS,
- VertexTypeEnum.CALCULATED_REQUIREMENTS, componentInstanceData.getUniqueId());
+ componentInstanceData.getUniqueId());
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility
.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove calculated Requirements for instance {} in container {}. error {] ",
@@ -372,7 +372,7 @@ public class NodeTemplateOperation extends BaseOperation {
.getVertexById(updatedContainer.getUniqueId(), JsonParseFlagEnum.NoParse);
if (getToscaElementRes.isLeft()) {
deleteToscaDataDeepElementsBlockToToscaElement(getToscaElementRes.left().value(), EdgeLabelEnum.INST_PROPERTIES,
- VertexTypeEnum.INST_PROPERTIES, componentInstance.getUniqueId());
+ componentInstance.getUniqueId());
}
StorageOperationStatus status = addToscaDataDeepElementsBlockToToscaElement(updatedContainer.getUniqueId(),
EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES, instProperties,
@@ -439,8 +439,7 @@ public class NodeTemplateOperation extends BaseOperation {
public Either<TopologyTemplate, StorageOperationStatus> addComponentInstanceToTopologyTemplate(
TopologyTemplate container, ToscaElement originToscaElement,
- ComponentInstanceDataDefinition componentInstance, GraphVertex metadataVertex, boolean allowDeleted,
- User user) {
+ ComponentInstanceDataDefinition componentInstance, GraphVertex metadataVertex, boolean allowDeleted) {
Either<TopologyTemplate, StorageOperationStatus> result = null;
Either<ToscaElement, StorageOperationStatus> updateContainerComponentRes = null;
@@ -728,14 +727,14 @@ public class NodeTemplateOperation extends BaseOperation {
private StorageOperationStatus deleteComponentInstanceToscaDataFromContainerComponent(GraphVertex containerV, String componentInstanceId) {
StorageOperationStatus status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.CALCULATED_CAPABILITIES,
- VertexTypeEnum.CALCULATED_CAPABILITIES, componentInstanceId);
+ componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove calculated capabilty for instance {} in container {}. error {] ",
componentInstanceId, containerV.getUniqueId(), status);
return status;
}
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES,
- VertexTypeEnum.CALCULATED_CAP_PROPERTIES, componentInstanceId);
+ componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
"Failed to remove calculated capabilty properties for instance {} in container {}. error {] ", componentInstanceId,
@@ -743,7 +742,7 @@ public class NodeTemplateOperation extends BaseOperation {
return status;
}
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.CALCULATED_REQUIREMENTS,
- VertexTypeEnum.CALCULATED_REQUIREMENTS, componentInstanceId);
+ componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility
.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove calculated requirement for instance {} in container {}. error {] ",
@@ -751,7 +750,7 @@ public class NodeTemplateOperation extends BaseOperation {
return status;
}
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.FULLFILLED_CAPABILITIES,
- VertexTypeEnum.FULLFILLED_CAPABILITIES, componentInstanceId);
+ componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility
.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove fullfilled capabilities for instance {} in container {}. error {] ",
@@ -759,35 +758,35 @@ public class NodeTemplateOperation extends BaseOperation {
return status;
}
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.FULLFILLED_REQUIREMENTS,
- VertexTypeEnum.FULLFILLED_REQUIREMENTS, componentInstanceId);
+ componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility
.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove fullfilled requirement for instance {} in container {}. error {] ",
componentInstanceId, containerV.getUniqueId(), status);
return status;
}
- status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES,
+ status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_ATTRIBUTES,
componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove attributes for instance {} in container {}. error {] ",
componentInstanceId, containerV.getUniqueId(), status);
return status;
}
- status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES,
+ status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_PROPERTIES,
componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove properties for instance {} in container {}. error {] ",
componentInstanceId, containerV.getUniqueId(), status);
return status;
}
- status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS,
+ status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_INPUTS,
componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove instance inputs for instance {} in container {}. error {] ",
componentInstanceId, containerV.getUniqueId(), status);
return status;
}
- status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_GROUPS, VertexTypeEnum.INST_GROUPS,
+ status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_GROUPS,
componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility
@@ -796,21 +795,21 @@ public class NodeTemplateOperation extends BaseOperation {
return status;
}
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS,
- VertexTypeEnum.INST_DEPLOYMENT_ARTIFACTS, componentInstanceId);
+ componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility
.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove instance deployment artifacts for instance {} in container {}. error {] ",
componentInstanceId, containerV.getUniqueId(), status);
return status;
}
- status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INSTANCE_ARTIFACTS, VertexTypeEnum.INSTANCE_ARTIFACTS,
+ status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INSTANCE_ARTIFACTS,
componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to remove instance artifacts for instance {} in container {}. error {] ",
componentInstanceId, containerV.getUniqueId(), status);
return status;
}
- status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.EXTERNAL_REFS, VertexTypeEnum.EXTERNAL_REF,
+ status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.EXTERNAL_REFS,
componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility
@@ -819,7 +818,7 @@ public class NodeTemplateOperation extends BaseOperation {
return status;
}
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_INTERFACES,
- VertexTypeEnum.INST_INTERFACES, componentInstanceId);
+ componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
"Failed to remove service instance interfaces for instance {} in container {}. " +
@@ -1191,7 +1190,10 @@ public class NodeTemplateOperation extends BaseOperation {
listRequirementDataDefinition.getListToscaDataDefinition().stream()
.filter(e -> requirementDataDefinition.getOwnerId().equals(e.getOwnerId()) && requirementDataDefinition.getName().equals(e.getName()))
- .forEach(r -> {r.setExternal(requirementDataDefinition.isExternal()); r.setExternalName(requirementDataDefinition.getExternalName());});
+ .forEach(r -> {
+ r.setExternal(requirementDataDefinition.isExternal());
+ r.setExternalName(requirementDataDefinition.getExternalName());
+ });
return updateCalculatedReqOnGraph(componentId, containerV, existingReqs);
}
@@ -1474,7 +1476,7 @@ public class NodeTemplateOperation extends BaseOperation {
Optional<GroupDefinition> groupOptional = groups.stream().filter(g -> g.getUniqueId().equals(groupArtifacts.getKey())).findFirst();
if (groupOptional.isPresent()) {
GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition((GroupDataDefinition) groupOptional.get(),
- (ComponentInstanceDataDefinition) componentInstance, null);
+ (ComponentInstanceDataDefinition) componentInstance);
groupInstance.setGroupInstanceArtifacts(
groupArtifacts.getValue().stream().map(ArtifactDataDefinition::getUniqueId).collect(Collectors.toList()));
groupInstance.setGroupInstanceArtifactsUuid(
@@ -1522,7 +1524,7 @@ public class NodeTemplateOperation extends BaseOperation {
dataDefinition.setIcon(resourceInstance.getIcon());
if (generateUid) {
dataDefinition.setUniqueId(
- UniqueIdBuilder.buildResourceInstanceUniuqeId(containerComponentId, ciOriginComponentUid, dataDefinition.getNormalizedName()));
+ UniqueIdBuilder.buildResourceInstanceUniqueId(containerComponentId, ciOriginComponentUid, dataDefinition.getNormalizedName()));
resourceInstance.setUniqueId(dataDefinition.getUniqueId());
}
if (StringUtils.isEmpty(dataDefinition.getComponentVersion()) && originToscaElement != null) {
@@ -1560,17 +1562,17 @@ public class NodeTemplateOperation extends BaseOperation {
private String buildComponentInstanceName(String instanceSuffixNumber, String instanceName) {
String delimiter = ConfigurationManager.getConfigurationManager().getConfiguration().getComponentInstanceCounterDelimiter();
- if(delimiter == null){
+ if (delimiter == null) {
delimiter = " ";
}
return instanceName + delimiter + (instanceSuffixNumber == null ? 0 : instanceSuffixNumber);
}
- public Either<RequirementCapabilityRelDef, StorageOperationStatus> associateResourceInstances(Component component, String componentId,
+ public Either<RequirementCapabilityRelDef, StorageOperationStatus> associateResourceInstances(String componentId,
RequirementCapabilityRelDef relation) {
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
relations.add(relation);
- Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> associateResourceInstances = associateResourceInstances(component,
+ Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> associateResourceInstances = associateResourceInstances(
componentId, relations);
if (associateResourceInstances.isRight()) {
return Either.right(associateResourceInstances.right().value());
@@ -1580,7 +1582,7 @@ public class NodeTemplateOperation extends BaseOperation {
@SuppressWarnings({"unchecked"})
public <T extends ToscaDataDefinition> Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> associateResourceInstances(
- Component component, String componentId, List<RequirementCapabilityRelDef> relations) {
+ String componentId, List<RequirementCapabilityRelDef> relations) {
Either<GraphVertex, JanusGraphOperationStatus> containerVEither = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.ParseAll);
if (containerVEither.isRight()) {
JanusGraphOperationStatus error = containerVEither.right().value();
@@ -2409,7 +2411,7 @@ public class NodeTemplateOperation extends BaseOperation {
private RelationshipInstDataDefinition buildRelationshipInstData(String fromResInstanceUid, String toInstId, RelationshipInfo relationPair,
boolean originUI) {
RelationshipInstDataDefinition relationshipInstData = new RelationshipInstDataDefinition();
- relationshipInstData.setUniqueId(UniqueIdBuilder.buildRelationsipInstInstanceUid(fromResInstanceUid, toInstId));
+ relationshipInstData.setUniqueId(UniqueIdBuilder.buildRelationshipInstInstanceUid());
relationshipInstData.setType(relationPair.getRelationship().getType());
Long creationDate = System.currentTimeMillis();
relationshipInstData.setCreationTime(creationDate);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
index 4995bdc642..c450457855 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
@@ -419,8 +419,8 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
List<String> uniqueKeys = new ArrayList<>(i.getValue().getMapToscaDataDefinition().keySet());
List<String> pathKeys = new ArrayList<>();
pathKeys.add(i.getKey());
- StorageOperationStatus status = deleteToscaDataDeepElements(nodeTypeVertex, EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS,
- uniqueKeys, pathKeys, JsonPresentationFields.NAME);
+ StorageOperationStatus status = deleteToscaDataDeepElements(nodeTypeVertex, EdgeLabelEnum.INST_INPUTS,
+ uniqueKeys, pathKeys);
if (status != StorageOperationStatus.OK) {
return;
}
@@ -1576,7 +1576,7 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
}
public StorageOperationStatus removePolicyFromToscaElement(GraphVertex componentV, String policyId) {
- return deleteToscaDataElement(componentV, EdgeLabelEnum.POLICIES, VertexTypeEnum.POLICIES, policyId, JsonPresentationFields.UNIQUE_ID);
+ return deleteToscaDataElement(componentV, EdgeLabelEnum.POLICIES, policyId);
}
public StorageOperationStatus updateGroupOfToscaElement(GraphVertex componentV, GroupDefinition groupDefinition) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementLifecycleOperation.java
index cf2db79871..3ee79e73ef 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementLifecycleOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementLifecycleOperation.java
@@ -62,7 +62,6 @@ import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.model.DistributionStatusEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.Model;
@@ -88,7 +87,6 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
public static final String VERSION_DELIMITER = ".";
public static final String VERSION_DELIMITER_REGEXP = "\\.";
- private static final String FAILED_TO_DELETE_LAST_STATE_EDGE_STATUS_IS = "Failed to delete last state edge. Status is {}. ";
private static final String FAILED_TO_GET_VERTICES = "Failed to get vertices by id {}. Status is {}. ";
private static final Logger log = Logger.getLogger(ToscaElementLifecycleOperation.class);
private final ModelOperation modelOperation;
@@ -132,7 +130,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
try {
return janusGraphDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForCheckin(toscaElementId, modifierId, ownerId))
.right().map(status -> handleFailureToPrepareParameters(status, toscaElementId)).left().bind(
- verticesMap -> checkinToscaELement(currState, verticesMap.get(toscaElementId), verticesMap.get(ownerId),
+ verticesMap -> checkinToscaELement(verticesMap.get(toscaElementId), verticesMap.get(ownerId),
verticesMap.get(modifierId), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN).left().bind(checkinResult -> {
//We retrieve the operation
ToscaElementOperation operation = getToscaElementOperation(verticesMap.get(toscaElementId).getLabel());
@@ -236,9 +234,10 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
public Either<ToscaElement, StorageOperationStatus> undoCheckout(String toscaElementId, String model) {
try {
return janusGraphDao.getVertexById(toscaElementId, JsonParseFlagEnum.ParseMetadata).right().map(errorStatus -> {
- CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_VERTICES, toscaElementId);
- return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(errorStatus);
- }).left().bind(this::retrieveAndUpdatePreviousVersion).left().bind(tuple -> updateEdgeToCatalogRootAndReturnPreVersionElement(tuple, model));
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_VERTICES, toscaElementId);
+ return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(errorStatus);
+ }).left().bind(this::retrieveAndUpdatePreviousVersion).left()
+ .bind(tuple -> updateEdgeToCatalogRootAndReturnPreVersionElement(tuple, model));
} catch (Exception e) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Exception occurred during undo checkout tosca element {}. {}", toscaElementId,
e.getMessage());
@@ -324,7 +323,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
private Either<ToscaElement, StorageOperationStatus> handleRelationsBeforeCertifyingAndProcessClone(GraphVertex toscaElement,
GraphVertex modifier, Integer majorVersion) {
- StorageOperationStatus status = handleRelationsOfPreviousToscaElementBeforeCertifying(toscaElement, modifier, majorVersion);
+ StorageOperationStatus status = handleRelationsOfPreviousToscaElementBeforeCertifying(toscaElement, majorVersion);
if (status != StorageOperationStatus.OK) {
return Either.right(logDebugMessageAndReturnStorageOperationStatus(status,
"Failed to handle relations of previous tosca element before certifying {}. Status is {}. ", toscaElement.getUniqueId(), status));
@@ -384,7 +383,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
return result;
}
- private StorageOperationStatus handleRelationsOfPreviousToscaElementBeforeCertifying(GraphVertex toscaElement, GraphVertex modifier,
+ private StorageOperationStatus handleRelationsOfPreviousToscaElementBeforeCertifying(GraphVertex toscaElement,
Integer majorVersion) {
StorageOperationStatus result = null;
if (majorVersion > 0) {
@@ -440,10 +439,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
private boolean isCertifiedVersion(String version) {
String[] versionParts = version.split(VERSION_DELIMITER_REGEXP);
- if (Integer.parseInt(versionParts[0]) > 0 && Integer.parseInt(versionParts[1]) == 0) {
- return true;
- }
- return false;
+ return Integer.parseInt(versionParts[0]) > 0 && Integer.parseInt(versionParts[1]) == 0;
}
private StorageOperationStatus updateOldToscaElementBeforeUndoCheckout(Vertex previousVersionToscaElement) {
@@ -783,7 +779,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
Map<String, GroupInstanceDataDefinition> groupInstanceToCreate = new HashMap<>();
for (GroupDataDefinition group : filteredGroups) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "create new groupInstance {} ", group.getName());
- GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition(group, vfInst, instDeplArtifMap);
+ GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition(group, vfInst);
List<String> artifactsUid = new ArrayList<>();
List<String> artifactsId = new ArrayList<>();
if (instDeplArtifMap != null) {
@@ -842,7 +838,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
ConfigurationManager.getConfigurationManager().getConfiguration().getToscaConformanceLevel());
}
if (!MapUtils.isEmpty(toscaElementVertex.getJson())) {
- nextVersionToscaElementVertex.setJson(new HashMap<String, ToscaDataDefinition>(toscaElementVertex.getJson()));
+ nextVersionToscaElementVertex.setJson(new HashMap<>(toscaElementVertex.getJson()));
}
return nextVersionToscaElementVertex;
}
@@ -899,7 +895,9 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
if (status != JanusGraphOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
"Failed to create edge with label {} from vertex {} to tosca element vertex {} on graph. Status is {}. ",
- EdgeLabelEnum.VERSION, null != previousCertifiedToscaElement ? previousCertifiedToscaElement.property(GraphPropertyEnum.UNIQUE_ID.getProperty()) : null,
+ EdgeLabelEnum.VERSION,
+ null != previousCertifiedToscaElement ? previousCertifiedToscaElement.property(GraphPropertyEnum.UNIQUE_ID.getProperty())
+ : null,
clonedToscaElement.getUniqueId(), status);
result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
@@ -978,16 +976,16 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
nextVersionToscaElementVertex.updateMetadataJsonWithCurrentMetadataProperties();
}
if (!MapUtils.isEmpty(toscaElementVertex.getJson())) {
- nextVersionToscaElementVertex.setJson(new HashMap<String, ToscaDataDefinition>(toscaElementVertex.getJson()));
+ nextVersionToscaElementVertex.setJson(new HashMap<>(toscaElementVertex.getJson()));
}
return nextVersionToscaElementVertex;
}
- private Either<GraphVertex, StorageOperationStatus> checkinToscaELement(LifecycleStateEnum currState, GraphVertex toscaElementVertex,
+ private Either<GraphVertex, StorageOperationStatus> checkinToscaELement(GraphVertex toscaElementVertex,
GraphVertex ownerVertex, GraphVertex modifierVertex,
LifecycleStateEnum nextState) {
Either<GraphVertex, StorageOperationStatus> updateRelationsRes;
- Either<GraphVertex, StorageOperationStatus> result = changeStateToCheckedIn(currState, toscaElementVertex, ownerVertex, modifierVertex);
+ Either<GraphVertex, StorageOperationStatus> result = changeStateToCheckedIn(toscaElementVertex, ownerVertex, modifierVertex);
if (result.isLeft()) {
toscaElementVertex.addMetadataProperty(GraphPropertyEnum.STATE, nextState.name());
toscaElementVertex.setJsonMetadataField(JsonPresentationFields.LAST_UPDATE_DATE, System.currentTimeMillis());
@@ -1016,7 +1014,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
return result;
}
- private Either<GraphVertex, StorageOperationStatus> changeStateToCheckedIn(LifecycleStateEnum currState, GraphVertex toscaElementVertex,
+ private Either<GraphVertex, StorageOperationStatus> changeStateToCheckedIn(GraphVertex toscaElementVertex,
GraphVertex ownerVertex, GraphVertex modifierVertex) {
Either<GraphVertex, StorageOperationStatus> result = null;
LifecycleStateEnum nextState = LifecycleStateEnum.NOT_CERTIFIED_CHECKIN;
@@ -1201,7 +1199,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
if (preV == null) {
return updateEdgeToCatalogRoot(null, curV);
}
- String uniqueIdPreVer = (String) janusGraphDao.getProperty((JanusGraphVertex) preV, GraphPropertyEnum.UNIQUE_ID.getProperty());
+ String uniqueIdPreVer = (String) janusGraphDao.getProperty(preV, GraphPropertyEnum.UNIQUE_ID.getProperty());
LifecycleStateEnum state = LifecycleStateEnum.findState((String) janusGraphDao.getProperty(preV, GraphPropertyEnum.STATE.getProperty()));
if (state == LifecycleStateEnum.CERTIFIED) {
return updateEdgeToCatalogRoot(null, curV);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
index b35ae1ec8c..ceb505ac3c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
@@ -44,7 +44,6 @@ import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.InputDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
@@ -55,7 +54,6 @@ import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -92,7 +90,6 @@ import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.UploadInterfaceInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.catalog.CatalogComponent;
import org.openecomp.sdc.be.model.jsonjanusgraph.config.ContainerInstanceTypesData;
@@ -684,7 +681,7 @@ public class ToscaOperationFacade {
public Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> associateResourceInstances(Component component, String componentId,
List<RequirementCapabilityRelDef> relations) {
Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> reqAndCapListEither = nodeTemplateOperation
- .associateResourceInstances(component, componentId, relations);
+ .associateResourceInstances(componentId, relations);
if (component != null) {
updateInstancesCapAndReqOnComponentFromDB(component);
}
@@ -1347,7 +1344,6 @@ public class ToscaOperationFacade {
maxCounter = currCounter;
}
} catch (NumberFormatException e) {
- continue;
}
}
return currCounter == null ? null : maxCounter;
@@ -1355,7 +1351,7 @@ public class ToscaOperationFacade {
public Either<RequirementCapabilityRelDef, StorageOperationStatus> associateResourceInstances(Component component, String componentId,
RequirementCapabilityRelDef requirementDef) {
- return nodeTemplateOperation.associateResourceInstances(component, componentId, requirementDef);
+ return nodeTemplateOperation.associateResourceInstances(componentId, requirementDef);
}
public Either<List<InputDefinition>, StorageOperationStatus> createAndAssociateInputs(Map<String, InputDefinition> inputs, String componentId) {
@@ -3172,7 +3168,7 @@ public class ToscaOperationFacade {
String componentInstanceId) {
String uniqueId = componentInstance.getUniqueId();
StorageOperationStatus status = nodeTemplateOperation
- .deleteToscaDataDeepElementsBlockOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_GROUPS, VertexTypeEnum.INST_GROUPS,
+ .deleteToscaDataDeepElementsBlockOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_GROUPS,
uniqueId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility
@@ -3335,7 +3331,7 @@ public class ToscaOperationFacade {
final Component component) {
final boolean match = component.getInterfaces().keySet().stream().anyMatch(s -> s.equals(interfaceName));
- StorageOperationStatus status = StorageOperationStatus.OK;
+ StorageOperationStatus status;
final ToscaElementOperation toscaElementOperation = getToscaElementOperation(component);
if (match) {
status = toscaElementOperation.updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.INTERFACE_ARTIFACTS,
@@ -3382,14 +3378,14 @@ public class ToscaOperationFacade {
public StorageOperationStatus deleteAllCalculatedCapabilitiesRequirements(String topologyTemplateId) {
StorageOperationStatus status = topologyTemplateOperation
- .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_CAPABILITIES, VertexTypeEnum.CALCULATED_CAPABILITIES);
+ .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_CAPABILITIES);
if (status == StorageOperationStatus.OK) {
status = topologyTemplateOperation
- .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_REQUIREMENTS, VertexTypeEnum.CALCULATED_REQUIREMENTS);
+ .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_REQUIREMENTS);
}
if (status == StorageOperationStatus.OK) {
status = topologyTemplateOperation
- .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, VertexTypeEnum.CALCULATED_CAP_PROPERTIES);
+ .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES);
}
return status;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadata.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadata.java
index 161e901b7b..ce6b1f4392 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadata.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadata.java
@@ -19,32 +19,18 @@
*/
package org.openecomp.sdc.be.model.normatives;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
public class ToscaTypeMetadata {
private String icon;
private String displayName;
- public ToscaTypeMetadata() {
- }
-
- public ToscaTypeMetadata(String icon, String displayName) {
- this.icon = icon;
- this.displayName = displayName;
- }
-
- public String getIcon() {
- return icon;
- }
-
- public void setIcon(String icon) {
- this.icon = icon;
- }
-
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java
index 685dc85675..2aabee4102 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java
@@ -109,12 +109,14 @@ public class AttributeOperation extends AbstractOperation {
return Either.right(propertiesStatus);
}
final Either<ImmutablePair<DataTypeData, GraphEdge>, JanusGraphOperationStatus> parentNode = janusGraphGenericDao
- .getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.DataType), uniqueId, GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.DataType, DataTypeData.class);
+ .getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.DataType), uniqueId, GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.DataType,
+ DataTypeData.class);
log.debug("After retrieving DERIVED_FROM node of {}. status is {}", uniqueId, parentNode);
if (parentNode.isRight()) {
final JanusGraphOperationStatus janusGraphOperationStatus = parentNode.right().value();
if (janusGraphOperationStatus != JanusGraphOperationStatus.NOT_FOUND) {
- log.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, "Failed to find the parent data type of data type {}. status is {}", uniqueId, janusGraphOperationStatus);
+ log.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, "Failed to find the parent data type of data type {}. status is {}", uniqueId,
+ janusGraphOperationStatus);
return Either.right(janusGraphOperationStatus);
}
} else {
@@ -133,7 +135,8 @@ public class AttributeOperation extends AbstractOperation {
}
private JanusGraphOperationStatus fillProperties(final String uniqueId, final DataTypeDefinition dataTypeDefinition) {
- final Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> findPropertiesOfNode = this.findPropertiesOfNode(NodeTypeEnum.DataType, uniqueId);
+ final Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> findPropertiesOfNode = findPropertiesOfNode(NodeTypeEnum.DataType,
+ uniqueId);
if (findPropertiesOfNode.isRight()) {
final JanusGraphOperationStatus janusGraphOperationStatus = findPropertiesOfNode.right().value();
log.debug("After looking for properties of vertex {}. status is {}", uniqueId, janusGraphOperationStatus);
@@ -163,7 +166,8 @@ public class AttributeOperation extends AbstractOperation {
final String uniqueId) {
final Map<String, PropertyDefinition> resourceProps = new HashMap<>();
final Either<List<ImmutablePair<PropertyData, GraphEdge>>, JanusGraphOperationStatus> childrenNodes = janusGraphGenericDao
- .getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(nodeType), uniqueId, GraphEdgeLabels.PROPERTY, NodeTypeEnum.Property, PropertyData.class);
+ .getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(nodeType), uniqueId, GraphEdgeLabels.PROPERTY, NodeTypeEnum.Property,
+ PropertyData.class);
if (childrenNodes.isRight()) {
final JanusGraphOperationStatus operationStatus = childrenNodes.right().value();
return Either.right(operationStatus);
@@ -300,7 +304,8 @@ public class AttributeOperation extends AbstractOperation {
return StorageOperationStatus.INVALID_VALUE;
}
final JsonElement jsonElement = validateResult.left;
- log.trace("Going to update value in attribute definition {} {}", attributeDefinition.getName(), (jsonElement != null ? jsonElement.toString() : null));
+ log.trace("Going to update value in attribute definition {} {}", attributeDefinition.getName(),
+ (jsonElement != null ? jsonElement.toString() : null));
updateAttributeValue(attributeDefinition, jsonElement);
return StorageOperationStatus.OK;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java
index 621ba97cb3..4b198046d0 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperation.java
@@ -70,7 +70,7 @@ import org.springframework.stereotype.Component;
@Component("group-type-operation")
public class GroupTypeOperation implements IGroupTypeOperation {
- private static final Logger log = Logger.getLogger(GroupTypeOperation.class.getName());
+ private static final Logger log = Logger.getLogger(GroupTypeOperation.class);
private static final String CREATE_FLOW_CONTEXT = "CreateGroupType";
private final PropertyOperation propertyOperation;
private final JanusGraphGenericDao janusGraphGenericDao;
@@ -146,10 +146,11 @@ public class GroupTypeOperation implements IGroupTypeOperation {
return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(error));
}
- private Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> getAllGroupTypePropertiesFromAllDerivedFrom(String firstParentType, String modelName) {
- return janusGraphGenericDao.getNode(GraphPropertiesDictionary.TYPE.getProperty(), firstParentType, GroupTypeData.class, modelName).left().bind(
- parentGroup -> propertyOperation
- .getAllTypePropertiesFromAllDerivedFrom(parentGroup.getUniqueId(), NodeTypeEnum.GroupType, GroupTypeData.class));
+ private Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> getAllGroupTypePropertiesFromAllDerivedFrom(String firstParentType,
+ String modelName) {
+ return janusGraphGenericDao.getNode(GraphPropertiesDictionary.TYPE.getProperty(), firstParentType, GroupTypeData.class, modelName).left()
+ .bind(parentGroup ->
+ propertyOperation.getAllTypePropertiesFromAllDerivedFrom(parentGroup.getUniqueId(), NodeTypeEnum.GroupType, GroupTypeData.class));
}
private StorageOperationStatus mergeCapabilities(GroupTypeDefinition groupTypeDef) {
@@ -313,14 +314,14 @@ public class GroupTypeOperation implements IGroupTypeOperation {
}
public Either<GroupTypeDefinition, StorageOperationStatus> getLatestGroupTypeByType(String type, String model) {
- return getLatestGroupTypeByType(type, model, true);
+ return getLatestGroupTypeByType(type, model, true);
}
public Either<GroupTypeDefinition, StorageOperationStatus> getLatestGroupTypeByType(String type, String model, boolean inTransaction) {
Map<String, Object> mapCriteria = new HashMap<>();
mapCriteria.put(GraphPropertiesDictionary.TYPE.getProperty(), type);
mapCriteria.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true);
- return getGroupTypeByCriteria(type, mapCriteria, model, inTransaction);
+ return getGroupTypeByCriteria(type, mapCriteria, model, inTransaction);
}
public Either<GroupTypeDefinition, StorageOperationStatus> getGroupTypeByCriteria(String type, Map<String, Object> properties,
@@ -333,7 +334,7 @@ public class GroupTypeOperation implements IGroupTypeOperation {
result = Either.right(StorageOperationStatus.INVALID_ID);
return result;
}
- Either<List<GroupTypeData>, StorageOperationStatus> groupTypeEither = janusGraphGenericDao
+ Either<List<GroupTypeData>, StorageOperationStatus> groupTypeEither = janusGraphGenericDao
.getByCriteriaForModel(NodeTypeEnum.GroupType, properties, model, GroupTypeData.class).right()
.map(DaoStatusConverter::convertJanusGraphStatusToStorageStatus);
if (groupTypeEither.isRight()) {
@@ -352,7 +353,7 @@ public class GroupTypeOperation implements IGroupTypeOperation {
private Either<GroupTypeDefinition, StorageOperationStatus> buildGroupTypeDefinition(String uniqueId, GroupTypeData groupTypeNode) {
GroupTypeDefinition groupType = new GroupTypeDefinition(groupTypeNode.getGroupTypeDataDefinition());
Optional<String> modelName = getAssociatedModelName(uniqueId);
- if(modelName.isPresent()) {
+ if (modelName.isPresent()) {
groupType.setModel(modelName.get());
}
return fillDerivedFrom(uniqueId, groupType).left().map(derivedFrom -> fillProperties(uniqueId, groupType, derivedFrom)).left()
@@ -363,7 +364,7 @@ public class GroupTypeOperation implements IGroupTypeOperation {
final Either<ImmutablePair<ModelData, GraphEdge>, JanusGraphOperationStatus> modelName = janusGraphGenericDao.getParentNode(
UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.GroupType), uniqueId, GraphEdgeLabels.MODEL_ELEMENT,
NodeTypeEnum.Model, ModelData.class);
- if(modelName.isRight()) {
+ if (modelName.isRight()) {
return Optional.empty();
}
return Optional.ofNullable(modelName.left().value().getLeft().getName());
@@ -432,7 +433,8 @@ public class GroupTypeOperation implements IGroupTypeOperation {
return getGroupTypeByTypeAndVersion(type, version, model, false);
}
- public Either<GroupTypeDefinition, StorageOperationStatus> getGroupTypeByTypeAndVersion(String type, String version, String model, boolean inTransaction) {
+ public Either<GroupTypeDefinition, StorageOperationStatus> getGroupTypeByTypeAndVersion(String type, String version, String model,
+ boolean inTransaction) {
Map<String, Object> mapCriteria = new HashMap<>();
mapCriteria.put(GraphPropertiesDictionary.TYPE.getProperty(), type);
mapCriteria.put(GraphPropertiesDictionary.VERSION.getProperty(), version);
@@ -454,7 +456,7 @@ public class GroupTypeOperation implements IGroupTypeOperation {
private Either<GroupTypeData, StorageOperationStatus> addGroupTypeToGraph(GroupTypeDefinition groupTypeDefinition) {
log.debug("Got group type {}", groupTypeDefinition);
String gtUniqueId = UniqueIdBuilder.buildGroupTypeUid(groupTypeDefinition.getModel(), groupTypeDefinition.getType(),
- groupTypeDefinition.getVersion(), "grouptype");
+ groupTypeDefinition.getVersion());
GroupTypeData groupTypeData = buildGroupTypeData(groupTypeDefinition, gtUniqueId);
log.debug("Before adding group type to graph. groupTypeData = {}", groupTypeData);
Either<GroupTypeData, JanusGraphOperationStatus> createGTResult = janusGraphGenericDao.createNode(groupTypeData, GroupTypeData.class);
@@ -501,7 +503,7 @@ public class GroupTypeOperation implements IGroupTypeOperation {
final GraphNode from = new UniqueIdData(NodeTypeEnum.Model, UniqueIdBuilder.buildModelUid(model));
final GraphNode to = new UniqueIdData(NodeTypeEnum.GroupType, groupTypeDefinition.getUniqueId());
log.info("Connecting model {} to type {}", from, to);
- return janusGraphGenericDao.createRelation(from , to, GraphEdgeLabels.MODEL_ELEMENT, Collections.emptyMap());
+ return janusGraphGenericDao.createRelation(from, to, GraphEdgeLabels.MODEL_ELEMENT, Collections.emptyMap());
}
private Either<GraphRelation, JanusGraphOperationStatus> connectToDerivedFrom(String ctUniqueId, String derivedFrom) {
@@ -620,7 +622,8 @@ public class GroupTypeOperation implements IGroupTypeOperation {
log.debug(
"#updateGroupDerivedFrom - updating group derived from relation for group type with id {}. old derived type {}. new derived type {}",
groupTypeId, currDerivedFromGroupType, updatedGroupType.getDerivedFrom());
- StorageOperationStatus deleteDerivedRelationStatus = deleteDerivedFromGroupType(groupTypeId, currDerivedFromGroupType, updatedGroupType.getModel());
+ StorageOperationStatus deleteDerivedRelationStatus = deleteDerivedFromGroupType(groupTypeId, currDerivedFromGroupType,
+ updatedGroupType.getModel());
if (deleteDerivedRelationStatus != StorageOperationStatus.OK) {
return Either.right(deleteDerivedRelationStatus);
}
@@ -649,7 +652,7 @@ public class GroupTypeOperation implements IGroupTypeOperation {
}
log.debug("#deleteDerivedFromGroupType - deleting derivedFrom relation for group type with id {} and its derived type {}", groupTypeId,
derivedFromType);
- return getLatestGroupTypeByType(derivedFromType, model).either(
+ return getLatestGroupTypeByType(derivedFromType, model).either(
derivedFromNode -> derivedFromOperation.removeDerivedFromRelation(groupTypeId, derivedFromNode.getUniqueId(), NodeTypeEnum.GroupType),
err -> err);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UniqueIdBuilder.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UniqueIdBuilder.java
index 225fe6c656..871afe6fa3 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UniqueIdBuilder.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UniqueIdBuilder.java
@@ -19,39 +19,36 @@
*/
package org.openecomp.sdc.be.model.operations.impl;
-import java.util.HashMap;
+import java.util.EnumMap;
import java.util.Map;
import java.util.UUID;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.resources.data.ResourceCategoryData;
-import org.openecomp.sdc.be.resources.data.ServiceCategoryData;
import org.openecomp.sdc.be.resources.data.TagData;
import org.openecomp.sdc.be.resources.data.UserData;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.util.ValidationUtils;
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class UniqueIdBuilder {
- private static final String HEAT_PARAM_PREFIX = "heat_";
- private static String DOT = ".";
- private static UserData userData = new UserData();
- private static TagData tagData = new TagData();
- private static ResourceCategoryData resCategoryData = new ResourceCategoryData();
- private static ServiceCategoryData serCategoryData = new ServiceCategoryData();
- private static Map<NodeTypeEnum, String> nodeTypeToUniqueKeyMapper = new HashMap<>();
+ static final String HEAT_PARAM_PREFIX = "heat_";
+ static final String DOT = ".";
+ private static final UserData userData = new UserData();
+ private static final TagData tagData = new TagData();
+ private static final Map<NodeTypeEnum, String> nodeTypeToUniqueKeyMapper = new EnumMap<>(NodeTypeEnum.class);
static {
nodeTypeToUniqueKeyMapper.put(NodeTypeEnum.User, userData.getUniqueIdKey());
nodeTypeToUniqueKeyMapper.put(NodeTypeEnum.Tag, tagData.getUniqueIdKey());
- nodeTypeToUniqueKeyMapper.put(NodeTypeEnum.ResourceCategory, resCategoryData.getUniqueIdKey());
- nodeTypeToUniqueKeyMapper.put(NodeTypeEnum.ServiceCategory, serCategoryData.getUniqueIdKey());
}
public static String buildPropertyUniqueId(String resourceId, String propertyName) {
- return resourceId + DOT + propertyName;
+ return buildUid(resourceId, propertyName);
}
static String buildHeatParameterUniqueId(String resourceId, String propertyName) {
@@ -90,15 +87,15 @@ public class UniqueIdBuilder {
}
public static String buildCapabilityTypeUid(final String modelName, String type) {
- return StringUtils.isEmpty(modelName) ? type : modelName + DOT + type;
+ return StringUtils.isEmpty(modelName) ? type : buildUid(modelName, type);
}
public static String buildRelationshipTypeUid(final String modelName, final String type) {
- return StringUtils.isEmpty(modelName) ? type : modelName + DOT + type;
+ return StringUtils.isEmpty(modelName) ? type : buildUid(modelName, type);
}
public static String buildInterfaceTypeUid(final String modelName, String type) {
- return StringUtils.isEmpty(modelName) ? type : modelName + DOT + type;
+ return StringUtils.isEmpty(modelName) ? type : buildUid(modelName, type);
}
public static String buildAttributeUid(String resourceId, String attName) {
@@ -106,7 +103,7 @@ public class UniqueIdBuilder {
}
public static String buildRequirementUid(String resourceId, String reqName) {
- return resourceId + DOT + reqName;
+ return buildUid(resourceId, reqName);
}
public static String buildCapabilityUid(String resourceId, String capabilityName) {
@@ -121,11 +118,11 @@ public class UniqueIdBuilder {
return buildTypeUid(parentId, instanceId, artifactLabel);
}
- public static String buildResourceInstanceUniuqeId(String serviceId, String resourceId, String logicalName) {
+ public static String buildResourceInstanceUniqueId(String serviceId, String resourceId, String logicalName) {
return buildTypeUid(serviceId, resourceId, logicalName);
}
- public static String buildRelationsipInstInstanceUid(String resourceInstUid, String requirement) {
+ public static String buildRelationshipInstInstanceUid() {
return generateUUID();
}
@@ -140,28 +137,28 @@ public class UniqueIdBuilder {
* TODO Pavel To be removed when new category logic comes in
*/
static String buildServiceCategoryUid(String categoryName, NodeTypeEnum type) {
- return type.getName() + DOT + categoryName;
+ return buildUid(type.getName(), categoryName);
}
// New logic
public static String buildCategoryUid(String categoryName, NodeTypeEnum type) {
- return type.getName() + DOT + categoryName;
+ return buildUid(type.getName(), categoryName);
}
public static String buildComponentCategoryUid(String categoryName, VertexTypeEnum type) {
- return type.getName() + DOT + ValidationUtils.normalizeCategoryName4Uniqueness(categoryName);
+ return buildUid(type.getName(), ValidationUtils.normalizeCategoryName4Uniqueness(categoryName));
}
public static String buildSubCategoryUid(String categoryUid, String subCategoryName) {
- return categoryUid + DOT + subCategoryName;
+ return buildUid(categoryUid, subCategoryName);
}
public static String buildGroupingUid(String subCategoryUid, String groupingName) {
- return subCategoryUid + DOT + groupingName;
+ return buildUid(subCategoryUid, groupingName);
}
static String buildResourceInstancePropertyValueUid(String resourceInstanceUniqueId, Integer index) {
- return resourceInstanceUniqueId + DOT + "property" + DOT + index;
+ return buildUid(resourceInstanceUniqueId, NodeTypeEnum.Property, index);
}
public static String buildComponentPropertyUniqueId(String resourceId, String propertyName) {
@@ -169,57 +166,67 @@ public class UniqueIdBuilder {
}
static String buildResourceInstanceAttributeValueUid(String resourceInstanceUniqueId, Integer index) {
- return resourceInstanceUniqueId + DOT + "attribute" + DOT + index;
+ return buildUid(resourceInstanceUniqueId, NodeTypeEnum.Attribute, index);
}
static String buildResourceInstanceInputValueUid(String resourceInstanceUniqueId, Integer index) {
- return resourceInstanceUniqueId + DOT + "input" + DOT + index;
+ return buildUid(resourceInstanceUniqueId, NodeTypeEnum.Input, index);
}
static String buildAdditionalInformationUniqueId(String resourceUniqueId) {
- return resourceUniqueId + DOT + "additionalinformation";
+ return buildUid(resourceUniqueId, "additionalinformation");
}
public static String buildDataTypeUid(final String modelName, final String name) {
- return StringUtils.isEmpty(modelName) ? name + DOT + "datatype" : modelName + DOT + name + DOT + "datatype";
+ return buildTypeUidWithModel(modelName, name, "datatype");
}
public static String buildInvariantUUID() {
return generateUUID();
}
- public static String buildGroupTypeUid(String modelName, String type, String version, String resourceName) {
- return buildTypeUidWithModel(modelName, type, version, resourceName);
+ public static String buildGroupTypeUid(final String modelName, final String type, final String version) {
+ return buildTypeUidWithModel(modelName, type, version, "grouptype");
}
public static String buildPolicyTypeUid(String modelName, String type, String version, String resourceName) {
return buildTypeUidWithModel(modelName, type, version, resourceName);
}
- static String buildTypeUidWithModel(String modelName, String type, String version, String resourceName) {
- if (StringUtils.isEmpty(modelName)){
- return buildTypeUid(type, version, resourceName);
- }
- return modelName + DOT + buildTypeUid(type, version, resourceName);
+ private static String buildTypeUidWithModel(String modelName, String type, String version, String resourceName) {
+ return StringUtils.isEmpty(modelName) ?
+ buildTypeUid(type, version, resourceName) : modelName + DOT + buildTypeUid(type, version, resourceName);
}
static String buildTypeUid(String type, String version, String resourceName) {
- return type + DOT + version + DOT + resourceName;
+ return type + DOT + buildUid(version, resourceName);
}
public static String buildPolicyUniqueId(String componentId, String name) {
- return componentId + DOT + name + Constants.POLICY_UID_POSTFIX;
+ return buildUid(componentId, name) + Constants.POLICY_UID_POSTFIX;
}
public static String buildGroupPropertyValueUid(String groupUniqueId, Integer index) {
- return groupUniqueId + DOT + "property" + DOT + index;
+ return buildUid(groupUniqueId, NodeTypeEnum.Property, index);
+ }
+
+ static String buildModelUid(final String modelName) {
+ return buildUid(NodeTypeEnum.Model.getName(), modelName);
+ }
+
+ public static String buildArtifactTypeUid(final String modelName, final String name) {
+ return buildTypeUidWithModel(modelName, name, "artifactype");
+ }
+
+ private static String buildTypeUidWithModel(final String modelName, final String name, final String nodeType) {
+ return StringUtils.isEmpty(modelName) ? buildUid(name, nodeType) : modelName + DOT + buildUid(name, nodeType);
}
- public static String buildModelUid(final String modelName) {
- return NodeTypeEnum.Model.getName() + DOT + modelName;
+ private static String buildUid(final String first, final String second) {
+ return first + DOT + second;
}
- public static String buildArtifactTypeUid(final String modelName, final String name) {
- return StringUtils.isEmpty(modelName) ? name + DOT + "artifactype" : modelName + DOT + name + DOT + "artifactype";
+ private static String buildUid(final String first, final NodeTypeEnum nodeType, final Integer index) {
+ return first + DOT + nodeType.getName() + DOT + index;
}
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/GroupTypeDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/GroupTypeDefinitionTest.java
deleted file mode 100644
index bc1922448e..0000000000
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/GroupTypeDefinitionTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.model;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.datatypes.elements.GroupTypeDataDefinition;
-
-import java.util.HashMap;
-import java.util.List;
-
-
-public class GroupTypeDefinitionTest {
-
- private GroupTypeDefinition createTestSubject() {
- return new GroupTypeDefinition();
- }
-
- @Test
- public void testCtor() throws Exception {
- new GroupTypeDefinition(new GroupTypeDataDefinition());
- }
-
- @Test
- public void testGetProperties() throws Exception {
- GroupTypeDefinition testSubject;
- List<PropertyDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getProperties();
- }
-
-
- @Test
- public void testSetProperties() throws Exception {
- GroupTypeDefinition testSubject;
- List<PropertyDefinition> properties = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setProperties(properties);
- }
-
- @Test
- public void testGetCapabilityTypes() throws Exception {
- GroupTypeDefinition testSubject;
- List<PropertyDefinition> properties = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.getCapabilities();
- }
-
- @Test
- public void testSetCapabilityTypes() throws Exception {
- GroupTypeDefinition testSubject;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCapabilities(new HashMap<>());
- }
-
- @Test
- public void testToString() throws Exception {
- GroupTypeDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadataTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadataTest.java
deleted file mode 100644
index bcbdbfa0c8..0000000000
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/normatives/ToscaTypeMetadataTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 Nokia. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.sdc.be.model.normatives;
-
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Test;
-
-public class ToscaTypeMetadataTest {
- @Test
- public void shouldHaveValidGettersAndSetters() {
- assertThat(ToscaTypeMetadata.class, hasValidGettersAndSetters());
- }
-} \ No newline at end of file
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UniqueIdBuilderTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UniqueIdBuilderTest.java
new file mode 100644
index 0000000000..ca7d0f5818
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UniqueIdBuilderTest.java
@@ -0,0 +1,306 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.openecomp.sdc.be.model.operations.impl;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder.DOT;
+import static org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder.HEAT_PARAM_PREFIX;
+
+import java.util.regex.Pattern;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.common.api.Constants;
+
+class UniqueIdBuilderTest {
+
+ private static final String resourceId = "resourceId";
+ private static final String propertyName = "propertyName";
+ private static final String modelName = "modelName";
+ private static final String version = "version";
+ private static final String name = "name";
+ private static final String componentId = "componentId";
+ private static final String groupUniqueId = "groupUniqueId";
+ private static final String attName = "attName";
+ private static final String reqName = "reqName";
+ private static final String capabilityName = "capabilityName";
+ private static final String interfaceName = "interfaceName";
+ private static final String operation = "operation";
+ private static final String type = "type";
+ private static final String artifactLabel = "artifactLabel";
+ private static final String parentId = "parentId";
+ private static final String instanceId = "instanceId";
+ private static final String serviceId = "serviceId";
+ private static final String logicalName = "logicalName";
+ private static final String categoryName = "categoryName";
+ private static final String subcategoryName = "subcategoryName";
+ private static final String groupingName = "groupingName";
+ private static final String resourceInstanceUniqueId = "resourceInstanceUniqueId";
+ private static final String pattern = "\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}";
+
+ @Test
+ void test_buildPropertyUniqueId() {
+ final String result = UniqueIdBuilder.buildPropertyUniqueId(resourceId, propertyName);
+ assertEquals(resourceId + DOT + propertyName, result);
+ }
+
+ @Test
+ void test_buildHeatParameterUniqueId() {
+ final String result = UniqueIdBuilder.buildHeatParameterUniqueId(resourceId, propertyName);
+ assertEquals(resourceId + DOT + HEAT_PARAM_PREFIX + propertyName, result);
+ }
+
+ @Test
+ void test_buildHeatParameterValueUniqueId() {
+ final String result = UniqueIdBuilder.buildHeatParameterValueUniqueId(resourceId, artifactLabel, propertyName);
+ assertEquals(resourceId + DOT + artifactLabel + DOT + propertyName, result);
+ }
+
+ @Test
+ void test_getKeyByNodeType() {
+ for (final NodeTypeEnum value : NodeTypeEnum.values()) {
+ switch (value) {
+ case User:
+ assertEquals("userId", UniqueIdBuilder.getKeyByNodeType(value));
+ break;
+ case Tag:
+ assertEquals("name", UniqueIdBuilder.getKeyByNodeType(value));
+ break;
+ default:
+ assertEquals("uid", UniqueIdBuilder.getKeyByNodeType(value));
+ break;
+ }
+ }
+ }
+
+ @Test
+ void test_buildResourceUniqueId() {
+ final String result = UniqueIdBuilder.buildResourceUniqueId();
+ assertTrue(Pattern.matches(pattern, result));
+ }
+
+ @Test
+ void test_generateUUID() {
+ final String result = UniqueIdBuilder.generateUUID();
+ assertTrue(Pattern.matches(pattern, result));
+ }
+
+ @Test
+ void test_buildComponentUniqueId() {
+ final String result = UniqueIdBuilder.buildComponentUniqueId();
+ assertTrue(Pattern.matches(pattern, result));
+ }
+
+ @Test
+ void test_buildCapabilityTypeUid() {
+ String result = UniqueIdBuilder.buildCapabilityTypeUid(modelName, type);
+ assertEquals(modelName + DOT + type, result);
+ result = UniqueIdBuilder.buildCapabilityTypeUid(null, type);
+ assertEquals(type, result);
+ }
+
+ @Test
+ void test_buildRelationshipTypeUid() {
+ String result = UniqueIdBuilder.buildRelationshipTypeUid(modelName, type);
+ assertEquals(modelName + DOT + type, result);
+ result = UniqueIdBuilder.buildRelationshipTypeUid(null, type);
+ assertEquals(type, result);
+ }
+
+ @Test
+ void test_buildInterfaceTypeUid() {
+ String result = UniqueIdBuilder.buildInterfaceTypeUid(modelName, type);
+ assertEquals(modelName + DOT + type, result);
+ result = UniqueIdBuilder.buildInterfaceTypeUid(null, type);
+ assertEquals(type, result);
+ }
+
+ @Test
+ void test_buildAttributeUid() {
+ final String result = UniqueIdBuilder.buildAttributeUid(resourceId, attName);
+ assertEquals(NodeTypeEnum.Attribute.getName() + DOT + resourceId + DOT + attName, result);
+ }
+
+ @Test
+ void test_buildRequirementUid() {
+ final String result = UniqueIdBuilder.buildRequirementUid(resourceId, reqName);
+ assertEquals(resourceId + DOT + reqName, result);
+ }
+
+ @Test
+ void test_buildCapabilityUid() {
+ final String result = UniqueIdBuilder.buildCapabilityUid(resourceId, capabilityName);
+ assertEquals(NodeTypeEnum.Capability.getName() + DOT + resourceId + DOT + capabilityName, result);
+ }
+
+ @Test
+ void test_buildArtifactByInterfaceUniqueId() {
+ final String result = UniqueIdBuilder.buildArtifactByInterfaceUniqueId(resourceId, interfaceName, operation, artifactLabel);
+ assertEquals(resourceId + DOT + interfaceName + DOT + operation + DOT + artifactLabel, result);
+ }
+
+ @Test
+ void test_buildInstanceArtifactUniqueId() {
+ final String result = UniqueIdBuilder.buildInstanceArtifactUniqueId(parentId, instanceId, artifactLabel);
+ assertEquals(parentId + DOT + instanceId + DOT + artifactLabel, result);
+ }
+
+ @Test
+ void test_buildResourceInstanceUniqueId() {
+ final String result = UniqueIdBuilder.buildResourceInstanceUniqueId(serviceId, resourceId, logicalName);
+ assertEquals(serviceId + DOT + resourceId + DOT + logicalName, result);
+ }
+
+ @Test
+ void test_buildRelationshipInstInstanceUid() {
+ final String result = UniqueIdBuilder.buildRelationshipInstInstanceUid();
+ assertTrue(Pattern.matches(pattern, result));
+ }
+
+ @Test
+ void test_buildResourceCategoryUid() {
+ final String result = UniqueIdBuilder.buildResourceCategoryUid(categoryName, subcategoryName, NodeTypeEnum.Product);
+ assertEquals(NodeTypeEnum.Product.getName() + DOT + categoryName + DOT + subcategoryName, result);
+ }
+
+ @Test
+ void test_buildServiceCategoryUid() {
+ final String result = UniqueIdBuilder.buildServiceCategoryUid(categoryName, NodeTypeEnum.Service);
+ assertEquals(NodeTypeEnum.Service.getName() + DOT + categoryName, result);
+ }
+
+ @Test
+ void test_buildCategoryUid() {
+ final String result = UniqueIdBuilder.buildCategoryUid(categoryName, NodeTypeEnum.Requirement);
+ assertEquals(NodeTypeEnum.Requirement.getName() + DOT + categoryName, result);
+ }
+
+ @Test
+ void test_buildComponentCategoryUid() {
+ final String result = UniqueIdBuilder.buildComponentCategoryUid(categoryName, VertexTypeEnum.TOPOLOGY_TEMPLATE);
+ assertEquals(VertexTypeEnum.TOPOLOGY_TEMPLATE.getName() + DOT + categoryName.toLowerCase(), result);
+ }
+
+ @Test
+ void test_buildSubCategoryUid() {
+ final String result = UniqueIdBuilder.buildSubCategoryUid(categoryName, subcategoryName);
+ assertEquals(categoryName + DOT + subcategoryName, result);
+ }
+
+ @Test
+ void test_buildGroupingUid() {
+ final String result = UniqueIdBuilder.buildGroupingUid(subcategoryName, groupingName);
+ assertEquals(subcategoryName + DOT + groupingName, result);
+ }
+
+ @Test
+ void test_buildResourceInstancePropertyValueUid() {
+ final String result = UniqueIdBuilder.buildResourceInstancePropertyValueUid(resourceInstanceUniqueId, 99);
+ assertEquals(resourceInstanceUniqueId + DOT + NodeTypeEnum.Property.getName() + DOT + 99, result);
+ }
+
+ @Test
+ void test_buildComponentPropertyUniqueId() {
+ final String result = UniqueIdBuilder.buildComponentPropertyUniqueId(resourceId, propertyName);
+ assertEquals(NodeTypeEnum.Property.getName() + DOT + resourceId + DOT + propertyName, result);
+ }
+
+ @Test
+ void test_buildResourceInstanceAttributeValueUid() {
+ final String result = UniqueIdBuilder.buildResourceInstanceAttributeValueUid(resourceInstanceUniqueId, 88);
+ assertEquals(resourceInstanceUniqueId + DOT + NodeTypeEnum.Attribute.getName() + DOT + 88, result);
+ }
+
+ @Test
+ void test_buildResourceInstanceInputValueUid() {
+ final String result = UniqueIdBuilder.buildResourceInstanceInputValueUid(resourceInstanceUniqueId, 77);
+ assertEquals(resourceInstanceUniqueId + DOT + NodeTypeEnum.Input.getName() + DOT + 77, result);
+ }
+
+ @Test
+ void test_buildAdditionalInformationUniqueId() {
+ final String result = UniqueIdBuilder.buildAdditionalInformationUniqueId(resourceId);
+ assertEquals(resourceId + DOT + "additionalinformation", result);
+ }
+
+ @Test
+ void test_buildDataTypeUid() {
+ String result = UniqueIdBuilder.buildDataTypeUid(modelName, name);
+ assertEquals(modelName + DOT + name + DOT + "datatype", result);
+ result = UniqueIdBuilder.buildDataTypeUid(null, name);
+ assertEquals(name + DOT + "datatype", result);
+ }
+
+ @Test
+ void test_buildInvariantUUID() {
+ final String result = UniqueIdBuilder.buildInvariantUUID();
+ assertTrue(Pattern.matches(pattern, result));
+ }
+
+ @Test
+ void test_buildGroupTypeUid() {
+ String result = UniqueIdBuilder.buildGroupTypeUid(modelName, type, version);
+ assertEquals(modelName + DOT + type + DOT + version + DOT + "grouptype", result);
+ result = UniqueIdBuilder.buildGroupTypeUid(null, type, version);
+ assertEquals(type + DOT + version + DOT + "grouptype", result);
+ }
+
+ @Test
+ void test_buildPolicyTypeUid() {
+ String result = UniqueIdBuilder.buildPolicyTypeUid(modelName, type, version, "policytype");
+ assertEquals(modelName + DOT + type + DOT + version + DOT + "policytype", result);
+ result = UniqueIdBuilder.buildPolicyTypeUid(null, type, version, "policytype");
+ assertEquals(type + DOT + version + DOT + "policytype", result);
+ }
+
+ @Test
+ void test_buildTypeUid() {
+ final String result = UniqueIdBuilder.buildTypeUid(type, version, NodeTypeEnum.HeatParameterValue.getName());
+ assertEquals(type + DOT + version + DOT + "heatParameterValue", result);
+ }
+
+ @Test
+ void test_buildPolicyUniqueId() {
+ final String result = UniqueIdBuilder.buildPolicyUniqueId(componentId, name);
+ assertEquals(componentId + DOT + name + Constants.POLICY_UID_POSTFIX, result);
+ }
+
+ @Test
+ void test_buildGroupPropertyValueUid() {
+ final String result = UniqueIdBuilder.buildGroupPropertyValueUid(groupUniqueId, 55);
+ assertEquals(groupUniqueId + DOT + NodeTypeEnum.Property.getName() + DOT + 55, result);
+ }
+
+ @Test
+ void test_buildModelUid() {
+ final String result = UniqueIdBuilder.buildModelUid(modelName);
+ assertEquals(NodeTypeEnum.Model.getName() + DOT + modelName, result);
+ }
+
+ @Test
+ void test_buildArtifactTypeUid() {
+ String result = UniqueIdBuilder.buildArtifactTypeUid(modelName, name);
+ assertEquals(modelName + DOT + name + DOT + "artifactype", result);
+ result = UniqueIdBuilder.buildArtifactTypeUid(null, name);
+ assertEquals(name + DOT + "artifactype", result);
+ }
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinition.java
index 19f88b3196..a2990f90bc 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinition.java
@@ -22,7 +22,13 @@ package org.openecomp.sdc.be.datatypes.elements;
import java.util.List;
import java.util.Map;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+@Getter
+@Setter
+@NoArgsConstructor
public class GroupTypeDataDefinition extends ToscaTypeDataDefinition {
private String uniqueId;
@@ -43,9 +49,6 @@ public class GroupTypeDataDefinition extends ToscaTypeDataDefinition {
*/
private Long modificationTime;
- public GroupTypeDataDefinition() {
- }
-
public GroupTypeDataDefinition(GroupTypeDataDefinition other) {
super(other);
this.uniqueId = other.uniqueId;
@@ -59,83 +62,12 @@ public class GroupTypeDataDefinition extends ToscaTypeDataDefinition {
this.derivedFrom = other.derivedFrom;
}
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public List<String> getMembers() {
- return members;
- }
-
- public void setMembers(List<String> members) {
- this.members = members;
- }
-
- public Map<String, String> getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Map<String, String> metadata) {
- this.metadata = metadata;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public Long getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Long creationTime) {
- this.creationTime = creationTime;
- }
-
- public Long getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
@Override
public String toString() {
- return "GroupTypeDataDefinition [uniqueId=" + uniqueId + ", type=" + getType() + ", name=" + getName() + ", icon=" + getIcon() + ", version=" + version
- + ", members=" + members + ", metadata=" + metadata + ", description=" + description + ", creationTime="
- + creationTime + ", modificationTime=" + modificationTime + "]";
- }
-
- public String getDerivedFrom() {
- return derivedFrom;
- }
-
- public void setDerivedFrom(String derivedFrom) {
- this.derivedFrom = derivedFrom;
- }
-
- public boolean isHighestVersion() {
- return highestVersion;
- }
-
- public void setHighestVersion(boolean isLatestVersion) {
- this.highestVersion = isLatestVersion;
+ return "GroupTypeDataDefinition [uniqueId=" + uniqueId + ", type=" + getType() + ", name=" + getName() + ", icon=" + getIcon() + ", version="
+ + version
+ + ", members=" + members + ", metadata=" + metadata + ", description=" + description + ", creationTime="
+ + creationTime + ", modificationTime=" + modificationTime + "]";
}
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaTypeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaTypeDataDefinition.java
index b6f9fa236d..881122fe66 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaTypeDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaTypeDataDefinition.java
@@ -20,44 +20,24 @@
package org.openecomp.sdc.be.datatypes.elements;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+@Getter
+@Setter
+@NoArgsConstructor
public class ToscaTypeDataDefinition extends ToscaDataDefinition {
private String name;
private String icon;
private String type;
- ToscaTypeDataDefinition() {
- }
-
ToscaTypeDataDefinition(ToscaTypeDataDefinition other) {
- this.name = other.getName();
+ this.name = other.name;
this.icon = other.icon;
this.type = other.type;
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getIcon() {
- return icon;
- }
-
- public void setIcon(String icon) {
- this.icon = icon;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java b/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
index ca349514f3..1d1bfa6eb9 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
@@ -65,7 +65,7 @@ public class TypeUtils {
PARAMETERS("parameters"),
// Import Validations
TOSCA_VERSION("tosca_definitions_version"), TOPOLOGY_TEMPLATE("topology_template"), OCCURRENCES("occurrences"),
- NODE_TEMPLATES("node_templates"), GROUPS("groups"), INPUTS("inputs"),
+ NODE_TEMPLATES("node_templates"), GROUPS("groups"), GROUP_TYPES("group_types"), INPUTS("inputs"),
OUTPUTS("outputs"), RELATIONSHIP_TEMPLATES("relationship_templates"),
SUBSTITUTION_MAPPINGS("substitution_mappings"), NODE_TYPE("node_type"), DIRECTIVES("directives"),
// Attributes
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinitionTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinitionTest.java
deleted file mode 100644
index 2a75b785c5..0000000000
--- a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinitionTest.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.datatypes.elements;
-
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-
-public class GroupTypeDataDefinitionTest {
-
- private GroupTypeDataDefinition createTestSubject() {
- return new GroupTypeDataDefinition();
- }
-
- @Test
- public void testCopyConstructor() throws Exception {
- GroupTypeDataDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- new GroupTypeDataDefinition(testSubject);
- }
-
- @Test
- public void testGetType() throws Exception {
- GroupTypeDataDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getType();
- }
-
-
- @Test
- public void testSetType() throws Exception {
- GroupTypeDataDefinition testSubject;
- String type = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setType(type);
- }
-
-
- @Test
- public void testGetVersion() throws Exception {
- GroupTypeDataDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getVersion();
- }
-
-
- @Test
- public void testSetVersion() throws Exception {
- GroupTypeDataDefinition testSubject;
- String version = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setVersion(version);
- }
-
-
- @Test
- public void testGetMembers() throws Exception {
- GroupTypeDataDefinition testSubject;
- List<String> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getMembers();
- }
-
-
- @Test
- public void testSetMembers() throws Exception {
- GroupTypeDataDefinition testSubject;
- List<String> members = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setMembers(members);
- }
-
-
- @Test
- public void testGetMetadata() throws Exception {
- GroupTypeDataDefinition testSubject;
- Map<String, String> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getMetadata();
- }
-
-
- @Test
- public void testSetMetadata() throws Exception {
- GroupTypeDataDefinition testSubject;
- Map<String, String> metadata = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setMetadata(metadata);
- }
-
-
- @Test
- public void testGetDescription() throws Exception {
- GroupTypeDataDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDescription();
- }
-
-
- @Test
- public void testSetDescription() throws Exception {
- GroupTypeDataDefinition testSubject;
- String description = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDescription(description);
- }
-
-
- @Test
- public void testGetUniqueId() throws Exception {
- GroupTypeDataDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUniqueId();
- }
-
-
- @Test
- public void testSetUniqueId() throws Exception {
- GroupTypeDataDefinition testSubject;
- String uniqueId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setUniqueId(uniqueId);
- }
-
-
- @Test
- public void testGetCreationTime() throws Exception {
- GroupTypeDataDefinition testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreationTime();
- }
-
-
- @Test
- public void testSetCreationTime() throws Exception {
- GroupTypeDataDefinition testSubject;
- Long creationTime = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCreationTime(creationTime);
- }
-
-
- @Test
- public void testGetModificationTime() throws Exception {
- GroupTypeDataDefinition testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModificationTime();
- }
-
-
- @Test
- public void testSetModificationTime() throws Exception {
- GroupTypeDataDefinition testSubject;
- Long modificationTime = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setModificationTime(modificationTime);
- }
-
-
- @Test
- public void testToString() throws Exception {
- GroupTypeDataDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-
-
- @Test
- public void testGetDerivedFrom() throws Exception {
- GroupTypeDataDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDerivedFrom();
- }
-
-
- @Test
- public void testSetDerivedFrom() throws Exception {
- GroupTypeDataDefinition testSubject;
- String derivedFrom = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDerivedFrom(derivedFrom);
- }
-
-
- @Test
- public void testIsHighestVersion() throws Exception {
- GroupTypeDataDefinition testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isHighestVersion();
- }
-
-
- @Test
- public void testSetHighestVersion() throws Exception {
- GroupTypeDataDefinition testSubject;
- boolean isLatestVersion = false;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setHighestVersion(isLatestVersion);
- }
-}
diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/AtomicOperationUtils.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/AtomicOperationUtils.java
index 11e56cce5b..98d6a11427 100644
--- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/AtomicOperationUtils.java
+++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/AtomicOperationUtils.java
@@ -20,302 +20,353 @@
package org.onap.sdc.backend.ci.tests.utils.general;
+import static org.junit.Assert.assertFalse;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
import com.aventstack.extentreports.Status;
import com.google.gson.Gson;
import fj.data.Either;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONException;
-import org.onap.sdc.backend.ci.tests.datatypes.*;
-import org.onap.sdc.backend.ci.tests.datatypes.enums.*;
+import org.onap.sdc.backend.ci.tests.api.ComponentBaseTest;
+import org.onap.sdc.backend.ci.tests.api.ExtentTestActions;
+import org.onap.sdc.backend.ci.tests.api.Urls;
+import org.onap.sdc.backend.ci.tests.config.Config;
+import org.onap.sdc.backend.ci.tests.datatypes.ArtifactReqDetails;
+import org.onap.sdc.backend.ci.tests.datatypes.ComponentInstanceReqDetails;
+import org.onap.sdc.backend.ci.tests.datatypes.DistributionMonitorObject;
+import org.onap.sdc.backend.ci.tests.datatypes.ImportReqDetails;
+import org.onap.sdc.backend.ci.tests.datatypes.ProductReqDetails;
+import org.onap.sdc.backend.ci.tests.datatypes.PropertyReqDetails;
+import org.onap.sdc.backend.ci.tests.datatypes.ResourceReqDetails;
+import org.onap.sdc.backend.ci.tests.datatypes.ServiceDistributionStatus;
+import org.onap.sdc.backend.ci.tests.datatypes.ServiceReqDetails;
+import org.onap.sdc.backend.ci.tests.datatypes.enums.ArtifactTypeEnum;
+import org.onap.sdc.backend.ci.tests.datatypes.enums.LifeCycleStatesEnum;
+import org.onap.sdc.backend.ci.tests.datatypes.enums.NormativeTypesEnum;
+import org.onap.sdc.backend.ci.tests.datatypes.enums.PropertyTypeEnum;
+import org.onap.sdc.backend.ci.tests.datatypes.enums.ResourceCategoryEnum;
+import org.onap.sdc.backend.ci.tests.datatypes.enums.ServiceCategoriesEnum;
+import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum;
import org.onap.sdc.backend.ci.tests.datatypes.http.HttpHeaderEnum;
import org.onap.sdc.backend.ci.tests.datatypes.http.HttpRequest;
import org.onap.sdc.backend.ci.tests.datatypes.http.RestResponse;
import org.onap.sdc.backend.ci.tests.execute.lifecycle.LCSbaseTest;
-import org.onap.sdc.backend.ci.tests.utils.rest.*;
-import org.onap.sdc.backend.ci.tests.datatypes.enums.*;
-import org.onap.sdc.backend.ci.tests.utils.rest.*;
+import org.onap.sdc.backend.ci.tests.tosca.datatypes.ToscaDefinition;
+import org.onap.sdc.backend.ci.tests.utils.CsarToscaTester;
+import org.onap.sdc.backend.ci.tests.utils.DistributionUtils;
+import org.onap.sdc.backend.ci.tests.utils.ToscaParserUtils;
+import org.onap.sdc.backend.ci.tests.utils.Utils;
+import org.onap.sdc.backend.ci.tests.utils.rest.ArtifactRestUtils;
+import org.onap.sdc.backend.ci.tests.utils.rest.AssetRestUtils;
+import org.onap.sdc.backend.ci.tests.utils.rest.BaseRestUtils;
+import org.onap.sdc.backend.ci.tests.utils.rest.ComponentInstanceRestUtils;
+import org.onap.sdc.backend.ci.tests.utils.rest.ConsumerRestUtils;
+import org.onap.sdc.backend.ci.tests.utils.rest.LifecycleRestUtils;
+import org.onap.sdc.backend.ci.tests.utils.rest.ProductRestUtils;
+import org.onap.sdc.backend.ci.tests.utils.rest.PropertyRestUtils;
+import org.onap.sdc.backend.ci.tests.utils.rest.ResourceRestUtils;
+import org.onap.sdc.backend.ci.tests.utils.rest.ResponseParser;
+import org.onap.sdc.backend.ci.tests.utils.rest.ServiceRestUtils;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.*;
-import org.onap.sdc.backend.ci.tests.api.ComponentBaseTest;
-import org.onap.sdc.backend.ci.tests.api.ExtentTestActions;
-import org.onap.sdc.backend.ci.tests.api.Urls;
-import org.onap.sdc.backend.ci.tests.config.Config;
-import org.onap.sdc.backend.ci.tests.tosca.datatypes.ToscaDefinition;
-import org.onap.sdc.backend.ci.tests.utils.CsarToscaTester;
-import org.onap.sdc.backend.ci.tests.utils.DistributionUtils;
-import org.onap.sdc.backend.ci.tests.utils.ToscaParserUtils;
-import org.onap.sdc.backend.ci.tests.utils.Utils;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.DistributionStatusEnum;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.Product;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.util.GeneralUtility;
import org.testng.SkipException;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
+public final class AtomicOperationUtils {
-import static org.junit.Assert.assertFalse;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
+ static final String basicAuthentication = "Basic Y2k6MTIzNDU2";
-public final class AtomicOperationUtils {
+ private AtomicOperationUtils() {
+ throw new UnsupportedOperationException();
+ }
+
+ // *********** RESOURCE ****************
+
+ /**
+ * Import a vfc From tosca file
+ *
+ * @param filePath
+ * @param fileName
+ * @return
+ * @throws IOException
+ * @throws JSONException
+ */
+ public static Either<Resource, RestResponse> importResource(String filePath, String fileName) {
+ try {
+ User designer = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+ ImportReqDetails importReqDetails = ElementFactory.getDefaultImportResource(ElementFactory.getResourcePrefix());
+ importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, filePath, fileName);
+ RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, designer, null);
+ return buildResourceFromResponse(importResourceResponse);
+ } catch (Exception e) {
+ throw new AtomicOperationException(e);
+ }
+ }
+
+ public static Either<Resource, RestResponse> importResource(ImportReqDetails importReqDetails, String filePath, String fileName, User userRole,
+ Boolean validateState) {
+ try {
+ importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, filePath, fileName);
+ RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, userRole, null);
+
+ if (validateState) {
+ assertTrue("Import resource failed with error: " + importResourceResponse.getResponse(),
+ importResourceResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
+ }
+
+ if (importResourceResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(importResourceResponse.getResponse());
+ return Either.left(resourceResponseObject);
+ }
+ return Either.right(importResourceResponse);
+ } catch (Exception e) {
+ throw new AtomicOperationException(e);
+ }
+ }
+
+
+ public static Either<Resource, RestResponse> createResourceByType(ResourceTypeEnum resourceType, UserRoleEnum userRole, Boolean validateState) {
+ try {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ ResourceReqDetails defaultResource = ElementFactory.getDefaultResourceByType(resourceType, defaultUser);
+ RestResponse resourceResp = ResourceRestUtils.createResource(defaultResource, defaultUser);
+
+ if (validateState) {
+ assertTrue("Create resource failed with error: " + resourceResp.getResponse(),
+ resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
+ }
+
+ if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
+ return Either.left(resourceResponseObject);
+ }
+ return Either.right(resourceResp);
+ } catch (Exception e) {
+ throw new AtomicOperationException(e);
+ }
+ }
+
+ public static Either<Resource, RestResponse> createResourceByResourceDetails(final ResourceReqDetails resourceDetails,
+ final UserRoleEnum userRole,
+ final Boolean validateState) {
+ try {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ RestResponse resourceResp = ResourceRestUtils.createResource(resourceDetails, defaultUser);
+
+ if (validateState) {
+ assertEquals("Create resource failed with error: " + resourceResp.getResponse(),
+ ResourceRestUtils.STATUS_CODE_CREATED, (int) resourceResp.getErrorCode());
+ }
+
+ if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
+ return Either.left(resourceResponseObject);
+ }
+ return Either.right(resourceResp);
+ } catch (Exception e) {
+ throw new AtomicOperationException(e);
+ }
+ }
+
+ public static Either<Resource, RestResponse> createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum resourceType,
+ NormativeTypesEnum normativeTypes,
+ ResourceCategoryEnum resourceCategory,
+ UserRoleEnum userRole, Boolean validateState)
+ throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ ResourceReqDetails defaultResource = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(resourceType, normativeTypes,
+ resourceCategory, defaultUser);
+ RestResponse resourceResp = ResourceRestUtils.createResource(defaultResource, defaultUser);
+
+ if (validateState) {
+ assertTrue("Actual Response Code is: " + resourceResp.getErrorCode(),
+ resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
+ }
- static final String basicAuthentication = "Basic Y2k6MTIzNDU2";
-
- private AtomicOperationUtils() {
- throw new UnsupportedOperationException();
- }
-
- // *********** RESOURCE ****************
- /**
- * Import a vfc From tosca file
- *
- * @param filePath
- * @param fileName
- * @return
- * @throws IOException
- * @throws JSONException
- */
- public static Either<Resource, RestResponse> importResource(String filePath, String fileName) {
- try {
- User designer = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
- ImportReqDetails importReqDetails = ElementFactory.getDefaultImportResource(ElementFactory.getResourcePrefix());
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, filePath, fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, designer, null);
- return buildResourceFromResponse(importResourceResponse);
- } catch (Exception e) {
- throw new AtomicOperationException(e);
- }
- }
-
- public static Either<Resource, RestResponse> importResource(ImportReqDetails importReqDetails, String filePath, String fileName, User userRole, Boolean validateState) {
- try {
- importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(importReqDetails, filePath, fileName);
- RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, userRole, null);
-
- if (validateState) {
- assertTrue("Import resource failed with error: " + importResourceResponse.getResponse(),importResourceResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
- }
-
- if (importResourceResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(importResourceResponse.getResponse());
- return Either.left(resourceResponseObject);
- }
- return Either.right(importResourceResponse);
- } catch (Exception e) {
- throw new AtomicOperationException(e);
- }
- }
-
-
- public static Either<Resource, RestResponse> createResourceByType(ResourceTypeEnum resourceType, UserRoleEnum userRole, Boolean validateState) {
- try {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- ResourceReqDetails defaultResource = ElementFactory.getDefaultResourceByType(resourceType, defaultUser);
- RestResponse resourceResp = ResourceRestUtils.createResource(defaultResource, defaultUser);
-
- if (validateState) {
- assertTrue("Create resource failed with error: " + resourceResp.getResponse(),resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
- }
-
- if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
- return Either.left(resourceResponseObject);
- }
- return Either.right(resourceResp);
- } catch (Exception e) {
- throw new AtomicOperationException(e);
- }
- }
-
- public static Either<Resource, RestResponse> createResourceByResourceDetails(final ResourceReqDetails resourceDetails,
- final UserRoleEnum userRole,
- final Boolean validateState) {
- try {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- RestResponse resourceResp = ResourceRestUtils.createResource(resourceDetails, defaultUser);
-
- if (validateState) {
- assertEquals("Create resource failed with error: " + resourceResp.getResponse(),
- ResourceRestUtils.STATUS_CODE_CREATED, (int) resourceResp.getErrorCode());
- }
-
- if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
- return Either.left(resourceResponseObject);
- }
- return Either.right(resourceResp);
- } catch (Exception e) {
- throw new AtomicOperationException(e);
- }
- }
-
- public static Either<Resource, RestResponse> createResourcesByTypeNormTypeAndCatregory(ResourceTypeEnum resourceType, NormativeTypesEnum normativeTypes, ResourceCategoryEnum resourceCategory, UserRoleEnum userRole, Boolean validateState)
- throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- ResourceReqDetails defaultResource = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(resourceType, normativeTypes, resourceCategory, defaultUser);
- RestResponse resourceResp = ResourceRestUtils.createResource(defaultResource, defaultUser);
-
- if (validateState) {
- assertTrue("Actual Response Code is: " + resourceResp.getErrorCode(), resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
- }
-
- if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- // Resource resourceResponseObject = ResponseParser
- // .convertResourceResponseToJavaObject(resourceResp.getResponse());
- Resource resourceResponseObject = ResponseParser.parseToObjectUsingMapper(resourceResp.getResponse(), Resource.class);
- return Either.left(resourceResponseObject);
- }
- return Either.right(resourceResp);
- }
-
- public static Either<Resource, RestResponse> createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum resourceType, Resource resourceNormativeType, ResourceCategoryEnum resourceCategory, UserRoleEnum userRole, Boolean validateState)
- throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- ResourceReqDetails defaultResource = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(resourceType, resourceNormativeType, resourceCategory, defaultUser);
- RestResponse resourceResp = ResourceRestUtils.createResource(defaultResource, defaultUser);
-
- if (validateState) {
- assertTrue("Create resource failed with error: " + resourceResp.getResponse(), resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
- }
-
- if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- // Resource resourceResponseObject = ResponseParser
- // .convertResourceResponseToJavaObject(resourceResp.getResponse());
- Resource resourceResponseObject = ResponseParser.parseToObjectUsingMapper(resourceResp.getResponse(), Resource.class);
- return Either.left(resourceResponseObject);
- }
- return Either.right(resourceResp);
- }
-
- public static Either<Resource, RestResponse> updateResource(ResourceReqDetails resourceReqDetails, User defaultUser, Boolean validateState) {
- try {
-
- RestResponse resourceResp = ResourceRestUtils.updateResource(resourceReqDetails, defaultUser, resourceReqDetails.getUniqueId());
-
- if (validateState) {
- assertTrue("Update resource failed with error: " + resourceResp.getResponse(),resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS);
- }
-
- if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS) {
- Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
- return Either.left(resourceResponseObject);
- }
- return Either.right(resourceResp);
- } catch (Exception e) {
- throw new AtomicOperationException(e);
- }
- }
-
- // *********** SERVICE ****************
-
- public static Either<Service, RestResponse> createDefaultService(UserRoleEnum userRole, Boolean validateState) throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(defaultUser);
- RestResponse createServiceResp = ServiceRestUtils.createService(serviceDetails, defaultUser);
-
- if (validateState) {
- assertTrue("Create service failed with error: " + createServiceResp.getResponse(),createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
- }
-
- if (createServiceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- Service serviceResponseObject = ResponseParser.convertServiceResponseToJavaObject(createServiceResp.getResponse());
- return Either.left(serviceResponseObject);
- }
- return Either.right(createServiceResp);
- }
-
- public static Either<Service, RestResponse> createServiceByCategory(ServiceCategoriesEnum category, UserRoleEnum userRole, Boolean validateState) throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(category, defaultUser);
- RestResponse createServiceResp = ServiceRestUtils.createService(serviceDetails, defaultUser);
-
- if (validateState) {
- assertTrue("Create service failed with error: " + createServiceResp.getResponse(),createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
- }
-
- if (createServiceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- Service serviceResponseObject = ResponseParser.convertServiceResponseToJavaObject(createServiceResp.getResponse());
- return Either.left(serviceResponseObject);
- }
- return Either.right(createServiceResp);
- }
-
- public static Either<Service, RestResponse> createCustomService(ServiceReqDetails serviceDetails, UserRoleEnum userRole, Boolean validateState) throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- RestResponse createServiceResp = ServiceRestUtils.createService(serviceDetails, defaultUser);
-
- if (validateState) {
- assertTrue("Create service failed with error: " + createServiceResp.getResponse(),createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
- }
-
- if (createServiceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- Service serviceResponseObject = ResponseParser.convertServiceResponseToJavaObject(createServiceResp.getResponse());
- return Either.left(serviceResponseObject);
- }
- return Either.right(createServiceResp);
- }
- // *********** PRODUCT ****************
-
- public static Either<Product, RestResponse> createDefaultProduct(UserRoleEnum userRole, Boolean validateState) throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- ProductReqDetails defaultProduct = ElementFactory.getDefaultProduct();
- RestResponse createProductResp = ProductRestUtils.createProduct(defaultProduct, defaultUser);
-
- if (validateState) {
- assertTrue(createProductResp.getErrorCode() == ProductRestUtils.STATUS_CODE_CREATED);
- }
-
- if (createProductResp.getErrorCode() == ProductRestUtils.STATUS_CODE_CREATED) {
- Product productResponseJavaObject = ResponseParser.convertProductResponseToJavaObject(createProductResp.getResponse());
- return Either.left(productResponseJavaObject);
- }
- return Either.right(createProductResp);
- }
-
- // public static ComponentReqDetails
- // convertCompoentToComponentReqDetails(Component component){
- //
- // ComponentReqDetails componentReqDetails =
- // ElementFactory.getDefaultService();
- // componentReqDetails.setName(component.getName());
- // componentReqDetails.setDescription(component.getDescription());
- // componentReqDetails.setTags(component.getTags());
- // componentReqDetails.setContactId(component.getContactId());
- // componentReqDetails.setIcon(component.getIcon());
- // componentReqDetails.setUniqueId(component.getUniqueId());
- // componentReqDetails.setCreatorUserId(component.getCreatorUserId());
- // componentReqDetails.setCreatorFullName(component.getCreatorFullName());
- // componentReqDetails.setLastUpdaterUserId(component.getLastUpdaterUserId());
- // componentReqDetails.setLastUpdaterFullName(component.getLastUpdaterFullName());
- // componentReqDetails.setCreationDate(component.getCreationDate());
- // componentReqDetails.setLastUpdateDate(component.getLastUpdateDate());
- // componentReqDetails.setLifecycleState(component.getLifecycleState());
- // componentReqDetails.setVersion(component.getVersion());
- // componentReqDetails.setUuid(component.getUUID());
- // componentReqDetails.setCategories(component.getCategories());
- // componentReqDetails.setProjectCode(component.getProjectCode());
- //
- // return componentReqDetails;
- // }
-
- // *********** LIFECYCLE ***************
-
- public static Pair<Component, RestResponse> changeComponentState(Component component, UserRoleEnum userRole, LifeCycleStatesEnum targetState, Boolean validateState) throws Exception {
+ if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ // Resource resourceResponseObject = ResponseParser
+ // .convertResourceResponseToJavaObject(resourceResp.getResponse());
+ Resource resourceResponseObject = ResponseParser.parseToObjectUsingMapper(resourceResp.getResponse(), Resource.class);
+ return Either.left(resourceResponseObject);
+ }
+ return Either.right(resourceResp);
+ }
+
+ public static Either<Resource, RestResponse> createResourcesByCustomNormativeTypeAndCatregory(ResourceTypeEnum resourceType,
+ Resource resourceNormativeType,
+ ResourceCategoryEnum resourceCategory,
+ UserRoleEnum userRole, Boolean validateState)
+ throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ ResourceReqDetails defaultResource = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(resourceType, resourceNormativeType,
+ resourceCategory, defaultUser);
+ RestResponse resourceResp = ResourceRestUtils.createResource(defaultResource, defaultUser);
+
+ if (validateState) {
+ assertTrue("Create resource failed with error: " + resourceResp.getResponse(),
+ resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
+ }
+
+ if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ // Resource resourceResponseObject = ResponseParser
+ // .convertResourceResponseToJavaObject(resourceResp.getResponse());
+ Resource resourceResponseObject = ResponseParser.parseToObjectUsingMapper(resourceResp.getResponse(), Resource.class);
+ return Either.left(resourceResponseObject);
+ }
+ return Either.right(resourceResp);
+ }
+
+ public static Either<Resource, RestResponse> updateResource(ResourceReqDetails resourceReqDetails, User defaultUser, Boolean validateState) {
+ try {
+
+ RestResponse resourceResp = ResourceRestUtils.updateResource(resourceReqDetails, defaultUser, resourceReqDetails.getUniqueId());
+
+ if (validateState) {
+ assertTrue("Update resource failed with error: " + resourceResp.getResponse(),
+ resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS) {
+ Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
+ return Either.left(resourceResponseObject);
+ }
+ return Either.right(resourceResp);
+ } catch (Exception e) {
+ throw new AtomicOperationException(e);
+ }
+ }
+
+ // *********** SERVICE ****************
+
+ public static Either<Service, RestResponse> createDefaultService(UserRoleEnum userRole, Boolean validateState) throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(defaultUser);
+ RestResponse createServiceResp = ServiceRestUtils.createService(serviceDetails, defaultUser);
+
+ if (validateState) {
+ assertTrue("Create service failed with error: " + createServiceResp.getResponse(),
+ createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
+ }
+
+ if (createServiceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ Service serviceResponseObject = ResponseParser.convertServiceResponseToJavaObject(createServiceResp.getResponse());
+ return Either.left(serviceResponseObject);
+ }
+ return Either.right(createServiceResp);
+ }
+
+ public static Either<Service, RestResponse> createServiceByCategory(ServiceCategoriesEnum category, UserRoleEnum userRole, Boolean validateState)
+ throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(category, defaultUser);
+ RestResponse createServiceResp = ServiceRestUtils.createService(serviceDetails, defaultUser);
+
+ if (validateState) {
+ assertTrue("Create service failed with error: " + createServiceResp.getResponse(),
+ createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
+ }
+
+ if (createServiceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ Service serviceResponseObject = ResponseParser.convertServiceResponseToJavaObject(createServiceResp.getResponse());
+ return Either.left(serviceResponseObject);
+ }
+ return Either.right(createServiceResp);
+ }
+
+ public static Either<Service, RestResponse> createCustomService(ServiceReqDetails serviceDetails, UserRoleEnum userRole, Boolean validateState)
+ throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ RestResponse createServiceResp = ServiceRestUtils.createService(serviceDetails, defaultUser);
+
+ if (validateState) {
+ assertTrue("Create service failed with error: " + createServiceResp.getResponse(),
+ createServiceResp.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
+ }
+
+ if (createServiceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ Service serviceResponseObject = ResponseParser.convertServiceResponseToJavaObject(createServiceResp.getResponse());
+ return Either.left(serviceResponseObject);
+ }
+ return Either.right(createServiceResp);
+ }
+ // *********** PRODUCT ****************
+
+ public static Either<Product, RestResponse> createDefaultProduct(UserRoleEnum userRole, Boolean validateState) throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ ProductReqDetails defaultProduct = ElementFactory.getDefaultProduct();
+ RestResponse createProductResp = ProductRestUtils.createProduct(defaultProduct, defaultUser);
+
+ if (validateState) {
+ assertTrue(createProductResp.getErrorCode() == ProductRestUtils.STATUS_CODE_CREATED);
+ }
+
+ if (createProductResp.getErrorCode() == ProductRestUtils.STATUS_CODE_CREATED) {
+ Product productResponseJavaObject = ResponseParser.convertProductResponseToJavaObject(createProductResp.getResponse());
+ return Either.left(productResponseJavaObject);
+ }
+ return Either.right(createProductResp);
+ }
+
+ // public static ComponentReqDetails
+ // convertCompoentToComponentReqDetails(Component component){
+ //
+ // ComponentReqDetails componentReqDetails =
+ // ElementFactory.getDefaultService();
+ // componentReqDetails.setName(component.getName());
+ // componentReqDetails.setDescription(component.getDescription());
+ // componentReqDetails.setTags(component.getTags());
+ // componentReqDetails.setContactId(component.getContactId());
+ // componentReqDetails.setIcon(component.getIcon());
+ // componentReqDetails.setUniqueId(component.getUniqueId());
+ // componentReqDetails.setCreatorUserId(component.getCreatorUserId());
+ // componentReqDetails.setCreatorFullName(component.getCreatorFullName());
+ // componentReqDetails.setLastUpdaterUserId(component.getLastUpdaterUserId());
+ // componentReqDetails.setLastUpdaterFullName(component.getLastUpdaterFullName());
+ // componentReqDetails.setCreationDate(component.getCreationDate());
+ // componentReqDetails.setLastUpdateDate(component.getLastUpdateDate());
+ // componentReqDetails.setLifecycleState(component.getLifecycleState());
+ // componentReqDetails.setVersion(component.getVersion());
+ // componentReqDetails.setUuid(component.getUUID());
+ // componentReqDetails.setCategories(component.getCategories());
+ // componentReqDetails.setProjectCode(component.getProjectCode());
+ //
+ // return componentReqDetails;
+ // }
+
+ // *********** LIFECYCLE ***************
+
+ public static Pair<Component, RestResponse> changeComponentState(Component component, UserRoleEnum userRole, LifeCycleStatesEnum targetState,
+ Boolean validateState) throws Exception {
Boolean isValidationFailed = false;
RestResponse lifeCycleStatesResponse = null;
@@ -323,117 +374,129 @@ public final class AtomicOperationUtils {
LifeCycleStatesEnum currentCompState = LifeCycleStatesEnum.findByCompState(component.getLifecycleState().toString());
- if (currentCompState == targetState) {
- component = getComponentObject(component, userRole);
- return Pair.of(component, null);
- }
- String componentType = component.getComponentType().getValue();
- ArrayList<String> lifeCycleStatesEnumList = new ArrayList<>();
- if (currentCompState.equals(LifeCycleStatesEnum.CHECKIN) && targetState.equals(LifeCycleStatesEnum.CHECKOUT)) {
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
- } else {
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
- lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFY.toString());
- }
- for (int i = 0; i < lifeCycleStatesEnumList.size(); i++) {
- if (lifeCycleStatesEnumList.get(i).equals(currentCompState.name())) {
- int a;
- a = (i == lifeCycleStatesEnumList.size() - 1) ? 0 : i + 1;
- for (int n = a; n < lifeCycleStatesEnumList.size(); n++) {
- defaultUser = ElementFactory.getDefaultUser(userRole);
- lifeCycleStatesResponse = LifecycleRestUtils.changeComponentState(component, defaultUser, LifeCycleStatesEnum.findByState(lifeCycleStatesEnumList.get(n)));
- if (lifeCycleStatesResponse.getErrorCode() != LifecycleRestUtils.STATUS_CODE_SUCCESS)
- isValidationFailed = true;
- if (lifeCycleStatesEnumList.get(n).equals(targetState.toString()) || isValidationFailed) {
- break;
- }
- }
- }
- }
- Component componentJavaObject = getComponentObject(component, userRole);
-
- if (validateState && isValidationFailed) {
- assertTrue("change state to [" + targetState.getState() + "] failed" + lifeCycleStatesResponse.getResponse(), false);
- return Pair.of(componentJavaObject, lifeCycleStatesResponse);
- }
-
- if (isValidationFailed) {
- return Pair.of(componentJavaObject, lifeCycleStatesResponse);
- }
-
- return Pair.of(componentJavaObject, lifeCycleStatesResponse);
- }
-
- public static RestResponse distributeService(Component component, Boolean validateState) throws Exception {
-
- Service service = (Service) component;
-
- User opsUser = ElementFactory.getDefaultUser(UserRoleEnum.OPS);
- User governotUser = ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR);
-
- ServiceReqDetails serviceDetails = new ServiceReqDetails(service);
- RestResponse distributionService = null;
-
- RestResponse approveDistribution = LifecycleRestUtils.changeDistributionStatus(serviceDetails, null, governotUser, "approveService", DistributionStatusEnum.DISTRIBUTED);
- if (approveDistribution.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
- distributionService = LifecycleRestUtils.changeDistributionStatus(serviceDetails, null, opsUser, "approveService", DistributionStatusEnum.DISTRIBUTED);
- }
-
- if (validateState) {
- assertTrue("Distribution approve failed with error: " + approveDistribution.getResponse(),approveDistribution.getErrorCode() == ProductRestUtils.STATUS_CODE_SUCCESS);
- assertTrue("Distribute service failed with error: " + distributionService.getResponse(),distributionService.getErrorCode() == ProductRestUtils.STATUS_CODE_SUCCESS);
- return distributionService;
- }
-
- return distributionService;
- }
-
- public static void toscaValidation(Component component, String vnfFile) throws Exception {
-
- ISdcCsarHelper fdntCsarHelper;
- SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
- File csarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.SERVICES, component.getUUID() , vnfFile);
- ExtentTestActions.log(Status.INFO, "Tosca parser is going to convert service csar file to ISdcCsarHelper object...");
- fdntCsarHelper = factory.getSdcCsarHelper(csarFile.getAbsolutePath());
- CsarToscaTester.processCsar(fdntCsarHelper);
- ExtentTestActions.log(Status.INFO, String.format("Tosca parser successfully parsed service CSAR"));
-
- }
-
- // *********** ARTIFACTS *****************
-
- public static Either<ArtifactDefinition, RestResponse> uploadArtifactByType(ArtifactTypeEnum artifactType, Component component, UserRoleEnum userRole, Boolean deploymentTrue, Boolean validateState) throws Exception {
-
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- ArtifactReqDetails artifactDetails = ElementFactory.getArtifactByType(null, artifactType, deploymentTrue);
- if (!deploymentTrue)
- artifactDetails.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL.getType());
- RestResponse uploadArtifactResp = ArtifactRestUtils.uploadArtifact(artifactDetails, component, defaultUser);
-
- if (validateState) {
- assertTrue("artifact upload failed: " + artifactDetails.getArtifactName(), uploadArtifactResp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- if (uploadArtifactResp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
- ArtifactDefinition artifactJavaObject = ResponseParser.convertArtifactDefinitionResponseToJavaObject(uploadArtifactResp.getResponse());
- return Either.left(artifactJavaObject);
- }
- return Either.right(uploadArtifactResp);
- }
-
- // *********** CONTAINERS *****************
- /**
- * Adds Component instance to Component
- *
- * @param compInstParent
- * @param compContainer
- * @return
- */
- public static Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer(Component compInstParent, Component compContainer) {
- return addComponentInstanceToComponentContainer(compInstParent, compContainer, UserRoleEnum.DESIGNER, false);
- }
+ if (currentCompState == targetState) {
+ component = getComponentObject(component, userRole);
+ return Pair.of(component, null);
+ }
+ String componentType = component.getComponentType().getValue();
+ ArrayList<String> lifeCycleStatesEnumList = new ArrayList<>();
+ if (currentCompState.equals(LifeCycleStatesEnum.CHECKIN) && targetState.equals(LifeCycleStatesEnum.CHECKOUT)) {
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
+ } else {
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKOUT.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CHECKIN.toString());
+ lifeCycleStatesEnumList.add(LifeCycleStatesEnum.CERTIFY.toString());
+ }
+ for (int i = 0; i < lifeCycleStatesEnumList.size(); i++) {
+ if (lifeCycleStatesEnumList.get(i).equals(currentCompState.name())) {
+ int a;
+ a = (i == lifeCycleStatesEnumList.size() - 1) ? 0 : i + 1;
+ for (int n = a; n < lifeCycleStatesEnumList.size(); n++) {
+ defaultUser = ElementFactory.getDefaultUser(userRole);
+ lifeCycleStatesResponse = LifecycleRestUtils.changeComponentState(component, defaultUser,
+ LifeCycleStatesEnum.findByState(lifeCycleStatesEnumList.get(n)));
+ if (lifeCycleStatesResponse.getErrorCode() != LifecycleRestUtils.STATUS_CODE_SUCCESS) {
+ isValidationFailed = true;
+ }
+ if (lifeCycleStatesEnumList.get(n).equals(targetState.toString()) || isValidationFailed) {
+ break;
+ }
+ }
+ }
+ }
+ Component componentJavaObject = getComponentObject(component, userRole);
+
+ if (validateState && isValidationFailed) {
+ assertTrue("change state to [" + targetState.getState() + "] failed" + lifeCycleStatesResponse.getResponse(), false);
+ return Pair.of(componentJavaObject, lifeCycleStatesResponse);
+ }
+
+ if (isValidationFailed) {
+ return Pair.of(componentJavaObject, lifeCycleStatesResponse);
+ }
+
+ return Pair.of(componentJavaObject, lifeCycleStatesResponse);
+ }
+
+ public static RestResponse distributeService(Component component, Boolean validateState) throws Exception {
+
+ Service service = (Service) component;
+
+ User opsUser = ElementFactory.getDefaultUser(UserRoleEnum.OPS);
+ User governotUser = ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR);
+
+ ServiceReqDetails serviceDetails = new ServiceReqDetails(service);
+ RestResponse distributionService = null;
+
+ RestResponse approveDistribution = LifecycleRestUtils.changeDistributionStatus(serviceDetails, null, governotUser, "approveService",
+ DistributionStatusEnum.DISTRIBUTED);
+ if (approveDistribution.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
+ distributionService = LifecycleRestUtils.changeDistributionStatus(serviceDetails, null, opsUser, "approveService",
+ DistributionStatusEnum.DISTRIBUTED);
+ }
+
+ if (validateState) {
+ assertTrue("Distribution approve failed with error: " + approveDistribution.getResponse(),
+ approveDistribution.getErrorCode() == ProductRestUtils.STATUS_CODE_SUCCESS);
+ assertTrue("Distribute service failed with error: " + distributionService.getResponse(),
+ distributionService.getErrorCode() == ProductRestUtils.STATUS_CODE_SUCCESS);
+ return distributionService;
+ }
+
+ return distributionService;
+ }
+
+ public static void toscaValidation(Component component, String vnfFile) throws Exception {
+
+ ISdcCsarHelper fdntCsarHelper;
+ SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
+ File csarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.SERVICES, component.getUUID(), vnfFile);
+ ExtentTestActions.log(Status.INFO, "Tosca parser is going to convert service csar file to ISdcCsarHelper object...");
+ fdntCsarHelper = factory.getSdcCsarHelper(csarFile.getAbsolutePath());
+ CsarToscaTester.processCsar(fdntCsarHelper);
+ ExtentTestActions.log(Status.INFO, String.format("Tosca parser successfully parsed service CSAR"));
+
+ }
+
+ // *********** ARTIFACTS *****************
+
+ public static Either<ArtifactDefinition, RestResponse> uploadArtifactByType(ArtifactTypeEnum artifactType, Component component,
+ UserRoleEnum userRole, Boolean deploymentTrue, Boolean validateState)
+ throws Exception {
+
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ ArtifactReqDetails artifactDetails = ElementFactory.getArtifactByType(null, artifactType, deploymentTrue);
+ if (!deploymentTrue) {
+ artifactDetails.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL.getType());
+ }
+ RestResponse uploadArtifactResp = ArtifactRestUtils.uploadArtifact(artifactDetails, component, defaultUser);
+
+ if (validateState) {
+ assertTrue("artifact upload failed: " + artifactDetails.getArtifactName(),
+ uploadArtifactResp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ if (uploadArtifactResp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
+ ArtifactDefinition artifactJavaObject = ResponseParser.convertArtifactDefinitionResponseToJavaObject(uploadArtifactResp.getResponse());
+ return Either.left(artifactJavaObject);
+ }
+ return Either.right(uploadArtifactResp);
+ }
+
+ // *********** CONTAINERS *****************
+
+ /**
+ * Adds Component instance to Component
+ *
+ * @param compInstParent
+ * @param compContainer
+ * @return
+ */
+ public static Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer(Component compInstParent,
+ Component compContainer) {
+ return addComponentInstanceToComponentContainer(compInstParent, compContainer, UserRoleEnum.DESIGNER, false);
+ }
public static Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer(Component compInstParent,
Component compContainer,
@@ -442,11 +505,11 @@ public final class AtomicOperationUtils {
try {
User defaultUser = ElementFactory.getDefaultUser(userRole);
ComponentInstanceReqDetails componentInstanceDetails = ElementFactory.getComponentInstance(compInstParent);
- if (componentInstanceDetails.getOriginType() == null){
+ if (componentInstanceDetails.getOriginType() == null) {
componentInstanceDetails.setOriginType(((Resource) compInstParent).getResourceType().toString());
}
RestResponse createComponentInstance = ComponentInstanceRestUtils.createComponentInstance(componentInstanceDetails,
- defaultUser, compContainer);
+ defaultUser, compContainer);
if (validateState) {
if (createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_NOT_FOUND) {
@@ -454,13 +517,13 @@ public final class AtomicOperationUtils {
} else {
assertTrue("error - " + createComponentInstance.getErrorCode() + "instead - " +
ServiceRestUtils.STATUS_CODE_CREATED,
- createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
+ createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
}
}
if (createComponentInstance.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
ComponentInstance componentInstance = ResponseParser
- .convertComponentInstanceResponseToJavaObject(createComponentInstance.getResponse());
+ .convertComponentInstanceResponseToJavaObject(createComponentInstance.getResponse());
return Either.left(componentInstance);
}
return Either.right(createComponentInstance);
@@ -469,568 +532,620 @@ public final class AtomicOperationUtils {
}
}
- public static Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer(Component compInstParent, Component compContainer, UserRoleEnum userRole, Boolean validateState, String positionX, String positionY) {
- try {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- ComponentInstanceReqDetails componentInstanceDetails = ElementFactory.getComponentInstance(compInstParent);
- componentInstanceDetails.setPosX(positionX);
- componentInstanceDetails.setPosY(positionY);
- if (componentInstanceDetails.getOriginType() == null){
- componentInstanceDetails.setOriginType(((Resource) compInstParent).getResourceType().toString());
- }
- RestResponse createComponentInstance = ComponentInstanceRestUtils.createComponentInstance(componentInstanceDetails, defaultUser, compContainer);
-
- if (validateState) {
- if (createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_NOT_FOUND)
- {
- throw new SkipException("Open bug DE262001");
- }
- else{
- assertTrue("error - " + createComponentInstance.getErrorCode() + "instead - " + ServiceRestUtils.STATUS_CODE_CREATED, createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
- }
- }
-
- if (createComponentInstance.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- ComponentInstance componentInstance = ResponseParser.convertComponentInstanceResponseToJavaObject(createComponentInstance.getResponse());
- return Either.left(componentInstance);
- }
- return Either.right(createComponentInstance);
- } catch (Exception e) {
- throw new AtomicOperationException(e);
- }
- }
-
- public static Resource getResourceObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
- // User defaultUser = ElementFactory.getDefaultUser(userRole);
- RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId());
- return ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- }
-
- public static Resource getResourceObject(String uniqueId) throws Exception {
- RestResponse restResponse = ResourceRestUtils.getResource(uniqueId);
- return ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- }
-
- public static Resource getResourceObjectByNameAndVersion(UserRoleEnum sdncModifierDetails, String resourceName, String resourceVersion) throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(sdncModifierDetails);
- RestResponse resourceResponse = ResourceRestUtils.getResourceByNameAndVersion(defaultUser.getUserId(), resourceName, resourceVersion);
- return ResponseParser.convertResourceResponseToJavaObject(resourceResponse.getResponse());
- }
-
- public static Service getServiceObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- RestResponse serviceResponse = ServiceRestUtils.getService(containerDetails.getUniqueId(), defaultUser);
- return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- }
-
- public static Service getServiceObjectByNameAndVersion(UserRoleEnum sdncModifierDetails, String serviceName, String serviceVersion) throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(sdncModifierDetails);
- RestResponse serviceResponse = ServiceRestUtils.getServiceByNameAndVersion(defaultUser, serviceName, serviceVersion);
- return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- }
-
- public static Service getServiceObject(String uniqueId) throws Exception {
- RestResponse serviceResponse = ServiceRestUtils.getService(uniqueId);
- return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- }
-
- public static Product getProductObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- RestResponse productRest = ProductRestUtils.getProduct(containerDetails.getUniqueId(), defaultUser.getUserId());
- return ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
- }
-
- public static Component getComponentObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
-
- switch (containerDetails.getComponentType()) {
- case RESOURCE:
- RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId());
- containerDetails = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
- break;
- case SERVICE:
- RestResponse serviceResponse = ServiceRestUtils.getService(containerDetails.getUniqueId(), defaultUser);
- containerDetails = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
- break;
- case PRODUCT:
- RestResponse productRest = ProductRestUtils.getProduct(containerDetails.getUniqueId(), defaultUser.getUserId());
- containerDetails = ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
- break;
- default:
- break;
- }
- return containerDetails;
- }
-
- public static Component convertReposnseToComponentObject(Component containerDetails, RestResponse restresponse) {
-
- switch (containerDetails.getComponentType()) {
- case RESOURCE:
- containerDetails = ResponseParser.convertResourceResponseToJavaObject(restresponse.getResponse());
- break;
- case SERVICE:
- containerDetails = ResponseParser.convertServiceResponseToJavaObject(restresponse.getResponse());
- break;
- case PRODUCT:
- containerDetails = ResponseParser.convertProductResponseToJavaObject(restresponse.getResponse());
- break;
- default:
- break;
- }
- return containerDetails;
- }
-
- public static Either<Component, RestResponse> associate2ResourceInstances(Component containerDetails, ComponentInstance fromNode, ComponentInstance toNode, String assocType, UserRoleEnum userRole, Boolean validateState) throws Exception {
-
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- RestResponse associate2ResourceInstancesResponse = ResourceRestUtils.associate2ResourceInstances(containerDetails, fromNode, toNode, assocType, defaultUser);
-
- if (validateState) {
- assertTrue(associate2ResourceInstancesResponse.getErrorCode() == ServiceRestUtils.STATUS_CODE_SUCCESS);
- }
-
- if (associate2ResourceInstancesResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS) {
-
- switch (containerDetails.getComponentType()) {
- case RESOURCE:
- containerDetails = ResponseParser.convertResourceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
- break;
- case SERVICE:
- containerDetails = ResponseParser.convertServiceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
- break;
- case PRODUCT:
- containerDetails = ResponseParser.convertProductResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
- break;
- default:
- break;
- }
-
- return Either.left(containerDetails);
- }
- return Either.right(associate2ResourceInstancesResponse);
-
- }
-
- public static Either<Pair<Component, ComponentInstance>, RestResponse> updateComponentInstance(ComponentInstanceReqDetails componentInstanceReqDetails, User sdncModifierDetails, Component container, boolean validateState) throws Exception {
-
- RestResponse updateComponentInstance = ComponentInstanceRestUtils.updateComponentInstance(componentInstanceReqDetails, sdncModifierDetails, container.getUniqueId(), container.getComponentType());
- if (validateState) {
- assertTrue("Update ComponentInstance failed: " + updateComponentInstance.getResponseMessage(), updateComponentInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
- if (updateComponentInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
- String componentType = container.getComponentType().getValue();
- Component componentObject;
- if(componentType.equals("Resource")){
- componentObject = getResourceObject(container.getUniqueId());
- }else{
- componentObject = getServiceObject(container.getUniqueId());
- }
- ComponentInstance componentInstanceJavaObject = ResponseParser.convertComponentInstanceResponseToJavaObject(updateComponentInstance.getResponse());
- return Either.left(Pair.of(componentObject, componentInstanceJavaObject));
- }
- return Either.right(updateComponentInstance);
- }
-
- public static Either<Pair<Component, ComponentInstance>, RestResponse> changeComponentInstanceVersion(Component containerDetails, ComponentInstance componentInstanceToReplace, Component newInstance, UserRoleEnum userRole, Boolean validateState)
- throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
-
- RestResponse changeComponentInstanceVersionResp = ComponentInstanceRestUtils.changeComponentInstanceVersion(containerDetails, componentInstanceToReplace, newInstance, defaultUser);
- if (validateState) {
- assertTrue("change ComponentInstance version failed: " + changeComponentInstanceVersionResp.getResponseMessage(), changeComponentInstanceVersionResp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- if (changeComponentInstanceVersionResp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
-
- Component compoenntObject = AtomicOperationUtils.getComponentObject(containerDetails, userRole);
- ComponentInstance componentInstanceJavaObject = ResponseParser.convertComponentInstanceResponseToJavaObject(changeComponentInstanceVersionResp.getResponse());
-
- return Either.left(Pair.of(compoenntObject, componentInstanceJavaObject));
- }
-
- return Either.right(changeComponentInstanceVersionResp);
- }
-
- public static ComponentInstance getComponentInstanceByName(Component component, String name) {
- ComponentInstance componentInstance = component.getComponentInstances()
- .stream()
- .filter(ci->ci.getName().equals(name))
- .findFirst()
- .orElse(null);
- if (componentInstance == null) {
- List<String> componentInstancesNameList = component.getComponentInstances().stream().map(ComponentInstance::getName).collect(Collectors.toList());
- assertFalse("Instance name " + name + " not found in container " + component.getComponentType() + " named [" + component.getName()
- + "]. Component instances available are: " + componentInstancesNameList.toString(), true);
- }
- return componentInstance;
- }
-
- // *********** PROPERTIES *****************
-
- public static Either<ComponentInstanceProperty, RestResponse> addCustomPropertyToResource(PropertyReqDetails propDetails, Resource resourceDetails, UserRoleEnum userRole, Boolean validateState) throws Exception {
-
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- Map<String, PropertyReqDetails> propertyToSend = new HashMap<>();
- propertyToSend.put(propDetails.getName(), propDetails);
- Gson gson = new Gson();
- RestResponse addPropertyResponse = PropertyRestUtils.createProperty(resourceDetails.getUniqueId(), gson.toJson(propertyToSend), defaultUser);
-
- if (validateState) {
- assertTrue("add property to resource failed: " + addPropertyResponse.getErrorCode(), addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_CREATED);
- }
-
- if (addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_CREATED) {
- ComponentInstanceProperty compInstProp = null;
- String property = ResponseParser.getJsonObjectValueByKey(addPropertyResponse.getResponse(), propDetails.getName());
- compInstProp = (ResponseParser.convertPropertyResponseToJavaObject(property));
- return Either.left(compInstProp);
- }
- return Either.right(addPropertyResponse);
- }
-
- // Benny
- public static Either<ComponentInstanceProperty, RestResponse> updatePropertyOfResource(PropertyReqDetails propDetails, Resource resourceDetails, String propertyUniqueId, UserRoleEnum userRole, Boolean validateState) throws Exception {
-
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- Map<String, PropertyReqDetails> propertyToSend = new HashMap<>();
- propertyToSend.put(propDetails.getName(), propDetails);
- Gson gson = new Gson();
- RestResponse addPropertyResponse = PropertyRestUtils.updateProperty(resourceDetails.getUniqueId(), propertyUniqueId, gson.toJson(propertyToSend), defaultUser);
-
- if (validateState) {
- assertTrue("add property to resource failed: " + addPropertyResponse.getResponseMessage(), addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- if (addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
- ComponentInstanceProperty compInstProp = null;
- String property = ResponseParser.getJsonObjectValueByKey(addPropertyResponse.getResponse(), propDetails.getName());
- compInstProp = (ResponseParser.convertPropertyResponseToJavaObject(property));
- return Either.left(compInstProp);
- }
- return Either.right(addPropertyResponse);
- }
-
- public static RestResponse deletePropertyOfResource(String resourceId, String propertyId, UserRoleEnum userRole) throws Exception {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- return PropertyRestUtils.deleteProperty(resourceId, propertyId, defaultUser);
- }
-
- public static Either<ComponentInstanceProperty, RestResponse> addDefaultPropertyToResource(PropertyTypeEnum propertyType, Resource resourceDetails, UserRoleEnum userRole, Boolean validateState) throws Exception {
-
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- PropertyReqDetails propDetails = ElementFactory.getPropertyDetails(propertyType);
- Map<String, PropertyReqDetails> propertyToSend = new HashMap<>();
- propertyToSend.put(propDetails.getName(), propDetails);
- Gson gson = new Gson();
- RestResponse addPropertyResponse = PropertyRestUtils.createProperty(resourceDetails.getUniqueId(), gson.toJson(propertyToSend), defaultUser);
-
- if (validateState) {
- assertTrue("add property to resource failed: " + addPropertyResponse.getResponseMessage(), addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_CREATED);
- }
-
- if (addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_CREATED) {
- ComponentInstanceProperty compInstProp = null;
- String property = ResponseParser.getJsonObjectValueByKey(addPropertyResponse.getResponse(), propDetails.getName());
- compInstProp = (ResponseParser.convertPropertyResponseToJavaObject(property));
-
- return Either.left(compInstProp);
- }
- return Either.right(addPropertyResponse);
- }
-
- public static Either<GroupDefinition, RestResponse> updateGroupPropertyOnResource(String maxVFModuleInstacesValue, Resource resource, String groupId, User user, Boolean validateState) throws Exception {
-
-// Gson gson = new Gson();
+ public static Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer(Component compInstParent, Component compContainer,
+ UserRoleEnum userRole, Boolean validateState,
+ String positionX, String positionY) {
+ try {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ ComponentInstanceReqDetails componentInstanceDetails = ElementFactory.getComponentInstance(compInstParent);
+ componentInstanceDetails.setPosX(positionX);
+ componentInstanceDetails.setPosY(positionY);
+ if (componentInstanceDetails.getOriginType() == null) {
+ componentInstanceDetails.setOriginType(((Resource) compInstParent).getResourceType().toString());
+ }
+ RestResponse createComponentInstance = ComponentInstanceRestUtils.createComponentInstance(componentInstanceDetails, defaultUser,
+ compContainer);
+
+ if (validateState) {
+ if (createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_NOT_FOUND) {
+ throw new SkipException("Open bug DE262001");
+ } else {
+ assertTrue("error - " + createComponentInstance.getErrorCode() + "instead - " + ServiceRestUtils.STATUS_CODE_CREATED,
+ createComponentInstance.getErrorCode() == ServiceRestUtils.STATUS_CODE_CREATED);
+ }
+ }
+
+ if (createComponentInstance.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ ComponentInstance componentInstance = ResponseParser.convertComponentInstanceResponseToJavaObject(
+ createComponentInstance.getResponse());
+ return Either.left(componentInstance);
+ }
+ return Either.right(createComponentInstance);
+ } catch (Exception e) {
+ throw new AtomicOperationException(e);
+ }
+ }
+
+ public static Resource getResourceObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
+ // User defaultUser = ElementFactory.getDefaultUser(userRole);
+ RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId());
+ return ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
+ }
+
+ public static Resource getResourceObject(String uniqueId) throws Exception {
+ RestResponse restResponse = ResourceRestUtils.getResource(uniqueId);
+ return ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
+ }
+
+ public static Resource getResourceObjectByNameAndVersion(UserRoleEnum sdncModifierDetails, String resourceName, String resourceVersion)
+ throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(sdncModifierDetails);
+ RestResponse resourceResponse = ResourceRestUtils.getResourceByNameAndVersion(defaultUser.getUserId(), resourceName, resourceVersion);
+ return ResponseParser.convertResourceResponseToJavaObject(resourceResponse.getResponse());
+ }
+
+ public static Service getServiceObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ RestResponse serviceResponse = ServiceRestUtils.getService(containerDetails.getUniqueId(), defaultUser);
+ return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
+ }
+
+ public static Service getServiceObjectByNameAndVersion(UserRoleEnum sdncModifierDetails, String serviceName, String serviceVersion)
+ throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(sdncModifierDetails);
+ RestResponse serviceResponse = ServiceRestUtils.getServiceByNameAndVersion(defaultUser, serviceName, serviceVersion);
+ return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
+ }
+
+ public static Service getServiceObject(String uniqueId) throws Exception {
+ RestResponse serviceResponse = ServiceRestUtils.getService(uniqueId);
+ return ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
+ }
+
+ public static Product getProductObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ RestResponse productRest = ProductRestUtils.getProduct(containerDetails.getUniqueId(), defaultUser.getUserId());
+ return ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
+ }
+
+ public static Component getComponentObject(Component containerDetails, UserRoleEnum userRole) throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+
+ switch (containerDetails.getComponentType()) {
+ case RESOURCE:
+ RestResponse restResponse = ResourceRestUtils.getResource(containerDetails.getUniqueId());
+ containerDetails = ResponseParser.convertResourceResponseToJavaObject(restResponse.getResponse());
+ break;
+ case SERVICE:
+ RestResponse serviceResponse = ServiceRestUtils.getService(containerDetails.getUniqueId(), defaultUser);
+ containerDetails = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse());
+ break;
+ case PRODUCT:
+ RestResponse productRest = ProductRestUtils.getProduct(containerDetails.getUniqueId(), defaultUser.getUserId());
+ containerDetails = ResponseParser.convertProductResponseToJavaObject(productRest.getResponse());
+ break;
+ default:
+ break;
+ }
+ return containerDetails;
+ }
+
+ public static Component convertReposnseToComponentObject(Component containerDetails, RestResponse restresponse) {
+
+ switch (containerDetails.getComponentType()) {
+ case RESOURCE:
+ containerDetails = ResponseParser.convertResourceResponseToJavaObject(restresponse.getResponse());
+ break;
+ case SERVICE:
+ containerDetails = ResponseParser.convertServiceResponseToJavaObject(restresponse.getResponse());
+ break;
+ case PRODUCT:
+ containerDetails = ResponseParser.convertProductResponseToJavaObject(restresponse.getResponse());
+ break;
+ default:
+ break;
+ }
+ return containerDetails;
+ }
+
+ public static Either<Component, RestResponse> associate2ResourceInstances(Component containerDetails, ComponentInstance fromNode,
+ ComponentInstance toNode, String assocType, UserRoleEnum userRole,
+ Boolean validateState) throws Exception {
+
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ RestResponse associate2ResourceInstancesResponse = ResourceRestUtils.associate2ResourceInstances(containerDetails, fromNode, toNode,
+ assocType, defaultUser);
+
+ if (validateState) {
+ assertTrue(associate2ResourceInstancesResponse.getErrorCode() == ServiceRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ if (associate2ResourceInstancesResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS) {
+
+ switch (containerDetails.getComponentType()) {
+ case RESOURCE:
+ containerDetails = ResponseParser.convertResourceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
+ break;
+ case SERVICE:
+ containerDetails = ResponseParser.convertServiceResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
+ break;
+ case PRODUCT:
+ containerDetails = ResponseParser.convertProductResponseToJavaObject(associate2ResourceInstancesResponse.getResponse());
+ break;
+ default:
+ break;
+ }
+
+ return Either.left(containerDetails);
+ }
+ return Either.right(associate2ResourceInstancesResponse);
+
+ }
+
+ public static Either<Pair<Component, ComponentInstance>, RestResponse> updateComponentInstance(
+ ComponentInstanceReqDetails componentInstanceReqDetails, User sdncModifierDetails, Component container, boolean validateState)
+ throws Exception {
+
+ RestResponse updateComponentInstance = ComponentInstanceRestUtils.updateComponentInstance(componentInstanceReqDetails, sdncModifierDetails,
+ container.getUniqueId(), container.getComponentType());
+ if (validateState) {
+ assertTrue("Update ComponentInstance failed: " + updateComponentInstance.getResponseMessage(),
+ updateComponentInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+ if (updateComponentInstance.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
+ String componentType = container.getComponentType().getValue();
+ Component componentObject;
+ if (componentType.equals("Resource")) {
+ componentObject = getResourceObject(container.getUniqueId());
+ } else {
+ componentObject = getServiceObject(container.getUniqueId());
+ }
+ ComponentInstance componentInstanceJavaObject = ResponseParser.convertComponentInstanceResponseToJavaObject(
+ updateComponentInstance.getResponse());
+ return Either.left(Pair.of(componentObject, componentInstanceJavaObject));
+ }
+ return Either.right(updateComponentInstance);
+ }
+
+ public static Either<Pair<Component, ComponentInstance>, RestResponse> changeComponentInstanceVersion(Component containerDetails,
+ ComponentInstance componentInstanceToReplace,
+ Component newInstance,
+ UserRoleEnum userRole,
+ Boolean validateState)
+ throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+
+ RestResponse changeComponentInstanceVersionResp = ComponentInstanceRestUtils.changeComponentInstanceVersion(containerDetails,
+ componentInstanceToReplace, newInstance, defaultUser);
+ if (validateState) {
+ assertTrue("change ComponentInstance version failed: " + changeComponentInstanceVersionResp.getResponseMessage(),
+ changeComponentInstanceVersionResp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ if (changeComponentInstanceVersionResp.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
+
+ Component compoenntObject = AtomicOperationUtils.getComponentObject(containerDetails, userRole);
+ ComponentInstance componentInstanceJavaObject = ResponseParser.convertComponentInstanceResponseToJavaObject(
+ changeComponentInstanceVersionResp.getResponse());
+
+ return Either.left(Pair.of(compoenntObject, componentInstanceJavaObject));
+ }
+
+ return Either.right(changeComponentInstanceVersionResp);
+ }
+
+ public static ComponentInstance getComponentInstanceByName(Component component, String name) {
+ ComponentInstance componentInstance = component.getComponentInstances()
+ .stream()
+ .filter(ci -> ci.getName().equals(name))
+ .findFirst()
+ .orElse(null);
+ if (componentInstance == null) {
+ List<String> componentInstancesNameList = component.getComponentInstances().stream().map(ComponentInstance::getName)
+ .collect(Collectors.toList());
+ assertFalse("Instance name " + name + " not found in container " + component.getComponentType() + " named [" + component.getName()
+ + "]. Component instances available are: " + componentInstancesNameList.toString(), true);
+ }
+ return componentInstance;
+ }
+
+ // *********** PROPERTIES *****************
+
+ public static Either<ComponentInstanceProperty, RestResponse> addCustomPropertyToResource(PropertyReqDetails propDetails,
+ Resource resourceDetails, UserRoleEnum userRole,
+ Boolean validateState) throws Exception {
+
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ Map<String, PropertyReqDetails> propertyToSend = new HashMap<>();
+ propertyToSend.put(propDetails.getName(), propDetails);
+ Gson gson = new Gson();
+ RestResponse addPropertyResponse = PropertyRestUtils.createProperty(resourceDetails.getUniqueId(), gson.toJson(propertyToSend), defaultUser);
+
+ if (validateState) {
+ assertTrue("add property to resource failed: " + addPropertyResponse.getErrorCode(),
+ addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_CREATED);
+ }
+
+ if (addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_CREATED) {
+ ComponentInstanceProperty compInstProp = null;
+ String property = ResponseParser.getJsonObjectValueByKey(addPropertyResponse.getResponse(), propDetails.getName());
+ compInstProp = (ResponseParser.convertPropertyResponseToJavaObject(property));
+ return Either.left(compInstProp);
+ }
+ return Either.right(addPropertyResponse);
+ }
+
+ // Benny
+ public static Either<ComponentInstanceProperty, RestResponse> updatePropertyOfResource(PropertyReqDetails propDetails, Resource resourceDetails,
+ String propertyUniqueId, UserRoleEnum userRole,
+ Boolean validateState) throws Exception {
+
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ Map<String, PropertyReqDetails> propertyToSend = new HashMap<>();
+ propertyToSend.put(propDetails.getName(), propDetails);
+ Gson gson = new Gson();
+ RestResponse addPropertyResponse = PropertyRestUtils.updateProperty(resourceDetails.getUniqueId(), propertyUniqueId,
+ gson.toJson(propertyToSend), defaultUser);
+
+ if (validateState) {
+ assertTrue("add property to resource failed: " + addPropertyResponse.getResponseMessage(),
+ addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ if (addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
+ ComponentInstanceProperty compInstProp = null;
+ String property = ResponseParser.getJsonObjectValueByKey(addPropertyResponse.getResponse(), propDetails.getName());
+ compInstProp = (ResponseParser.convertPropertyResponseToJavaObject(property));
+ return Either.left(compInstProp);
+ }
+ return Either.right(addPropertyResponse);
+ }
+
+ public static RestResponse deletePropertyOfResource(String resourceId, String propertyId, UserRoleEnum userRole) throws Exception {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ return PropertyRestUtils.deleteProperty(resourceId, propertyId, defaultUser);
+ }
+
+ public static Either<ComponentInstanceProperty, RestResponse> addDefaultPropertyToResource(PropertyTypeEnum propertyType,
+ Resource resourceDetails, UserRoleEnum userRole,
+ Boolean validateState) throws Exception {
+
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ PropertyReqDetails propDetails = ElementFactory.getPropertyDetails(propertyType);
+ Map<String, PropertyReqDetails> propertyToSend = new HashMap<>();
+ propertyToSend.put(propDetails.getName(), propDetails);
+ Gson gson = new Gson();
+ RestResponse addPropertyResponse = PropertyRestUtils.createProperty(resourceDetails.getUniqueId(), gson.toJson(propertyToSend), defaultUser);
+
+ if (validateState) {
+ assertTrue("add property to resource failed: " + addPropertyResponse.getResponseMessage(),
+ addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_CREATED);
+ }
+
+ if (addPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_CREATED) {
+ ComponentInstanceProperty compInstProp = null;
+ String property = ResponseParser.getJsonObjectValueByKey(addPropertyResponse.getResponse(), propDetails.getName());
+ compInstProp = (ResponseParser.convertPropertyResponseToJavaObject(property));
+
+ return Either.left(compInstProp);
+ }
+ return Either.right(addPropertyResponse);
+ }
+
+ public static Either<GroupDefinition, RestResponse> updateGroupPropertyOnResource(String maxVFModuleInstacesValue, Resource resource,
+ String groupId, User user, Boolean validateState)
+ throws Exception {
+
// Json group property object
- String propertyObjectJson = "[{\"defaultValue\":null,\"description\":\"The maximum instances of this VF-Module\",\"name\":\"max_vf_module_instances\",\"parentUniqueId\":\"org.openecomp.groups.VfModule.1.0.grouptype.max_vf_module_instances\",\"password\":false,\"required\":false,\"schema\":{\"property\":{}},\"type\":\"integer\",\"uniqueId\":\"org.openecomp.groups.VfModule.1.0.grouptype.max_vf_module_instances.property.3\",\"value\":\"" + maxVFModuleInstacesValue + "\",\"definition\":false,\"getInputValues\":null,\"constraints\":null,\"valueUniqueUid\":null,\"ownerId\":\"org.openecomp.groups.VfModule.1.0.grouptype.max_vf_module_instances\"}]";
-// GroupProperty property = gson.fromJson(propertyObjectJson, GroupProperty.class);
- RestResponse updateGroupPropertyResponse = PropertyRestUtils.updateGroupProperty(resource, groupId, propertyObjectJson, user);
-
- if (validateState) {
- assertTrue("update group property to resource failed: " + updateGroupPropertyResponse.getResponseMessage(), updateGroupPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
- }
-
- if (updateGroupPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
- GroupDefinition responseGroupDefinition = ResponseParser.convertPropertyResponseToObject(updateGroupPropertyResponse.getResponse());
- return Either.left(responseGroupDefinition);
- }
- return Either.right(updateGroupPropertyResponse);
- }
-
-
- public static RestResponse createDefaultConsumer(Boolean validateState) {
- try {
- ConsumerDataDefinition defaultConsumerDefinition = ElementFactory.getDefaultConsumerDetails();
- RestResponse createResponse = ConsumerRestUtils.createConsumer(defaultConsumerDefinition, ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
- BaseRestUtils.checkCreateResponse(createResponse);
-
- if (validateState) {
- assertTrue(createResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
- }
- return createResponse;
- } catch (Exception e) {
- throw new AtomicOperationException(e);
- }
- }
-
- /**
- * Builds Resource From rest response
- *
- * @param resourceResp
- * @return
- */
- public static Either<Resource, RestResponse> buildResourceFromResponse(RestResponse resourceResp) {
- Either<Resource, RestResponse> result;
- if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
- result = Either.left(resourceResponseObject);
- } else {
- result = Either.right(resourceResp);
- }
- return result;
- }
-
- private static class AtomicOperationException extends RuntimeException {
- private AtomicOperationException(Exception e) {
- super(e);
- }
-
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * Import resource from CSAR
- *
- * @param resourceType
- * @param userRole
- * @param fileName
- * @param filePath
- * @return Resource
- * @throws Exception
- */
- public static Resource importResourceFromCsar(ResourceTypeEnum resourceType, UserRoleEnum userRole, String fileName, String... filePath) throws Exception {
- // Get the CSARs path
- String realFilePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI" + File.separator + "csars" ;
- if (filePath != null && filePath.length > 0) {
- StringBuilder result = new StringBuilder();
- for(String currStr: filePath){
- result.append(currStr);
- }
+ String propertyObjectJson =
+ "[{\"defaultValue\":null,\"description\":\"The maximum instances of this VF-Module\",\"name\":\"max_vf_module_instances\",\"parentUniqueId\":\"org.openecomp.groups.VfModule.1.0.groupType.max_vf_module_instances\",\"password\":false,\"required\":false,\"schema\":{\"property\":{}},\"type\":\"integer\",\"uniqueId\":\"org.openecomp.groups.VfModule.1.0.groupType.max_vf_module_instances.property.3\",\"value\":\""
+ + maxVFModuleInstacesValue
+ + "\",\"definition\":false,\"getInputValues\":null,\"constraints\":null,\"valueUniqueUid\":null,\"ownerId\":\"org.openecomp.groups.VfModule.1.0.groupType.max_vf_module_instances\"}]";
+ RestResponse updateGroupPropertyResponse = PropertyRestUtils.updateGroupProperty(resource, groupId, propertyObjectJson, user);
+
+ if (validateState) {
+ assertTrue("update group property to resource failed: " + updateGroupPropertyResponse.getResponseMessage(),
+ updateGroupPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ if (updateGroupPropertyResponse.getErrorCode() == BaseRestUtils.STATUS_CODE_SUCCESS) {
+ GroupDefinition responseGroupDefinition = ResponseParser.convertPropertyResponseToObject(updateGroupPropertyResponse.getResponse());
+ return Either.left(responseGroupDefinition);
+ }
+ return Either.right(updateGroupPropertyResponse);
+ }
+
+
+ public static RestResponse createDefaultConsumer(Boolean validateState) {
+ try {
+ ConsumerDataDefinition defaultConsumerDefinition = ElementFactory.getDefaultConsumerDetails();
+ RestResponse createResponse = ConsumerRestUtils.createConsumer(defaultConsumerDefinition,
+ ElementFactory.getDefaultUser(UserRoleEnum.ADMIN));
+ BaseRestUtils.checkCreateResponse(createResponse);
+
+ if (validateState) {
+ assertTrue(createResponse.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
+ }
+ return createResponse;
+ } catch (Exception e) {
+ throw new AtomicOperationException(e);
+ }
+ }
+
+ /**
+ * Builds Resource From rest response
+ *
+ * @param resourceResp
+ * @return
+ */
+ public static Either<Resource, RestResponse> buildResourceFromResponse(RestResponse resourceResp) {
+ Either<Resource, RestResponse> result;
+ if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
+ result = Either.left(resourceResponseObject);
+ } else {
+ result = Either.right(resourceResp);
+ }
+ return result;
+ }
+
+ private static class AtomicOperationException extends RuntimeException {
+
+ private AtomicOperationException(Exception e) {
+ super(e);
+ }
+
+ private static final long serialVersionUID = 1L;
+ }
+
+ /**
+ * Import resource from CSAR
+ *
+ * @param resourceType
+ * @param userRole
+ * @param fileName
+ * @param filePath
+ * @return Resource
+ * @throws Exception
+ */
+ public static Resource importResourceFromCsar(ResourceTypeEnum resourceType, UserRoleEnum userRole, String fileName, String... filePath)
+ throws Exception {
+ // Get the CSARs path
+ String realFilePath =
+ System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI"
+ + File.separator + "csars";
+ if (filePath != null && filePath.length > 0) {
+ StringBuilder result = new StringBuilder();
+ for (String currStr : filePath) {
+ result.append(currStr);
+ }
// realFilePath = Arrays.toString(filePath);
- realFilePath = result.toString();
- }
-
- // Create default import resource & user
- return importResourceFromCsarFile(resourceType, userRole, fileName, realFilePath);
- }
-
- public static Resource importResourceFromCsarFile(ResourceTypeEnum resourceType, UserRoleEnum userRole, String csarFileName, String csarFilePath) throws Exception{
- RestResponse createResource = getCreateResourceRestResponse(resourceType, userRole, csarFileName, csarFilePath);
- BaseRestUtils.checkCreateResponse(createResource);
- return ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- }
-
- public static Resource importCertifiedResourceFromCsar(ResourceTypeEnum resourceType, UserRoleEnum userRole, String csarFileName, String csarFilePath) throws Exception{
- RestResponse createResource = getCreateCertifiedResourceRestResponse(resourceType, userRole, csarFileName, csarFilePath);
- BaseRestUtils.checkSuccess(createResource);
- return ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
- }
- public static RestResponse getCreateResourceRestResponse(ResourceTypeEnum resourceType, UserRoleEnum userRole,
- String csarFileName, String csarFilePath) throws IOException, Exception {
-
- ImportReqDetails resourceDetails = buildImportReqDetails(resourceType, csarFileName, csarFilePath);
- User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
- RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- return createResource;
- }
-
- public static RestResponse getCreateCertifiedResourceRestResponse(ResourceTypeEnum resourceType, UserRoleEnum userRole,
- String csarFileName, String csarFilePath) throws IOException, Exception {
-
- ImportReqDetails resourceDetails = buildImportReqDetails(resourceType, csarFileName, csarFilePath);
- User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
- RestResponse response = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
- BaseRestUtils.checkCreateResponse(response);
- return LCSbaseTest.certifyResource(resourceDetails, sdncModifierDetails);
- }
-
- private static ImportReqDetails buildImportReqDetails(ResourceTypeEnum resourceType, String csarFileName, String csarFilePath) throws IOException {
- ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
- Path path = Paths.get(csarFilePath + File.separator + csarFileName);
- byte[] data = Files.readAllBytes(path);
- String payloadName = csarFileName;
- String payloadData = Base64.encodeBase64String(data);
- resourceDetails.setPayloadData(payloadData);
- resourceDetails.setCsarUUID(payloadName);
- resourceDetails.setPayloadName(payloadName);
- resourceDetails.setResourceType(resourceType.name());
- return resourceDetails;
- }
-
- public static Resource updateResourceFromCsar(Resource resource, UserRoleEnum userRole, String csarFileName, String csarFilePath) throws Exception{
- User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
-
- byte[] data = null;
- Path path = Paths.get(csarFilePath + File.separator + csarFileName);
- data = Files.readAllBytes(path);
- String payloadName = csarFileName;
- String payloadData = Base64.encodeBase64String(data);
- ImportReqDetails resourceDetails = new ImportReqDetails(resource, payloadName, payloadData);
- resourceDetails.setPayloadData(payloadData);
- resourceDetails.setCsarUUID(payloadName);
- resourceDetails.setPayloadName(payloadName);
-
- String userId = sdncModifierDetails.getUserId();
- Config config = Utils.getConfig();
- String url = String.format(Urls.UPDATE_RESOURCE, config.getCatalogBeHost(), config.getCatalogBePort(), resource.getUniqueId());
-
- Map<String, String> headersMap = ResourceRestUtils.prepareHeadersMap(userId);
-
- Gson gson = new Gson();
- String userBodyJson = gson.toJson(resourceDetails);
- String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson);
- headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5);
- HttpRequest http = new HttpRequest();
- RestResponse updateResourceResponse = http.httpSendPut(url, userBodyJson, headersMap);
- BaseRestUtils.checkSuccess(updateResourceResponse);
- return ResponseParser.parseToObjectUsingMapper(updateResourceResponse.getResponse(), Resource.class);
- }
-
- public static Either<Resource, RestResponse> importResourceByFileName(ResourceTypeEnum resourceType, UserRoleEnum userRole, String fileName, Boolean validateState, String... filePath) throws IOException {
-
- String realFilePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI" + File.separator + "csars" ;
- if (filePath != null && filePath.length > 0) {
- realFilePath = filePath.toString();
- }
-
- try {
- User defaultUser = ElementFactory.getDefaultUser(userRole);
- ResourceReqDetails defaultResource = ElementFactory.getDefaultResource(defaultUser);
- ImportReqDetails defaultImportResource = ElementFactory.getDefaultImportResource(defaultResource);
- ImportUtils.getImportResourceDetailsByPathAndName(defaultImportResource, realFilePath, fileName);
- RestResponse resourceResp = ResourceRestUtils.createResource(defaultImportResource, defaultUser);
-
- if (validateState) {
- assertTrue(resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
- }
-
- if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
- Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
- return Either.left(resourceResponseObject);
- }
- return Either.right(resourceResp);
- } catch (Exception e) {
- throw new AtomicOperationException(e);
- }
- }
-
- public static Either<String, RestResponse> getComponenetArtifactPayload(Component component, String artifactType) throws Exception {
-
- String url;
- Config config = Utils.getConfig();
- if(component.getComponentType().toString().toUpperCase().equals(ComponentTypeEnum.SERVICE.getValue().toUpperCase())){
- url = String.format(Urls.UI_DOWNLOAD_SERVICE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(), component.getToscaArtifacts().get(artifactType).getUniqueId());
- }else{
- url = String.format(Urls.UI_DOWNLOAD_RESOURCE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(), component.getToscaArtifacts().get(artifactType).getUniqueId());
- }
- String userId = component.getLastUpdaterUserId();
- Map<String, String> headersMap = new HashMap<>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.CACHE_CONTROL.getValue(), BaseRestUtils.cacheControlHeader);
- headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication);
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
- if (userId != null) {
- headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId);
- }
- HttpRequest http = new HttpRequest();
- RestResponse response = http.httpSendGet(url, headersMap);
- if (response.getErrorCode() != BaseRestUtils.STATUS_CODE_SUCCESS && response.getResponse().getBytes() == null && response.getResponse().getBytes().length == 0) {
- return Either.right(response);
- }
- return Either.left(response.getResponse());
-
- }
-
- public static RestResponse getDistributionStatusByDistributionId(String distributionId, Boolean validateState) {
-
- try {
- User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.OPS);
- RestResponse response = DistributionUtils.getDistributionStatus(defaultUser, distributionId);
-
- if (validateState) {
- assertTrue(response.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS);
- }
- return response;
-
- } catch (Exception e) {
- throw new AtomicOperationException(e);
- }
- }
-
- public static Either <RestResponse, Map<String, List<DistributionMonitorObject>>> getSortedDistributionStatusMap(Service service, Boolean validateState) {
-
- try {
- ServiceDistributionStatus serviceDistributionObject = DistributionUtils.getLatestServiceDistributionObject(service);
- RestResponse response = getDistributionStatusByDistributionId(serviceDistributionObject.getDistributionID(), true);
- if(validateState) {
- assertTrue(response.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS);
- }
- if(response.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS){
- Map<String, List<DistributionMonitorObject>> parsedDistributionStatus = DistributionUtils.getSortedDistributionStatus(response);
- return Either.right(parsedDistributionStatus);
- }
- return Either.left(response);
- } catch (Exception e) {
- throw new AtomicOperationException(e);
- }
-
- }
-
-
- /**
- * @param service
- * @param pollingCount
- * @param pollingInterval
- * Recommended values for service distribution for pollingCount is 4 and for pollingInterval is 15000ms
- * @throws Exception
- */
- public static Boolean distributeAndValidateService(Service service, int pollingCount, int pollingInterval) throws Exception {
- int firstPollingInterval = 30000; //this value define first be polling topic time, should change if DC configuration changed
- Boolean statusFlag = true;
- AtomicOperationUtils.distributeService(service, true);
- TimeUnit.MILLISECONDS.sleep(firstPollingInterval);
- int timeOut = pollingCount * pollingInterval;
- com.clearspring.analytics.util.Pair<Boolean,Map<String,List<String>>> verifyDistributionStatus = null;
-
- while (timeOut > 0) {
- Map<String,List<DistributionMonitorObject>> sortedDistributionStatusMap = AtomicOperationUtils.getSortedDistributionStatusMap(service, true).right().value();
- verifyDistributionStatus = DistributionUtils.verifyDistributionStatus(sortedDistributionStatusMap);
- if(verifyDistributionStatus.left.equals(false)){
- TimeUnit.MILLISECONDS.sleep(pollingInterval);
- timeOut-=pollingInterval;
- }else {
- timeOut = 0;
- }
- }
-
- if((verifyDistributionStatus.right != null && ! verifyDistributionStatus.right.isEmpty())){
- for(Entry<String, List<String>> entry : verifyDistributionStatus.right.entrySet()){
- if(ComponentBaseTest.getExtendTest() != null){
- ComponentBaseTest.getExtendTest().log(Status.INFO, "Consumer: " + entry.getKey() + " failed on following: "+ entry.getValue());
- }else{
- System.out.println("Consumer: [" + entry.getKey() + "] failed on following: "+ entry.getValue());
- }
- }
- statusFlag = false;
- }
- return statusFlag;
- }
-
- public static Boolean distributeAndValidateService(Service service) throws Exception {
- return distributeAndValidateService(service, 10, 10000);
- }
-
- /**
+ realFilePath = result.toString();
+ }
+
+ // Create default import resource & user
+ return importResourceFromCsarFile(resourceType, userRole, fileName, realFilePath);
+ }
+
+ public static Resource importResourceFromCsarFile(ResourceTypeEnum resourceType, UserRoleEnum userRole, String csarFileName, String csarFilePath)
+ throws Exception {
+ RestResponse createResource = getCreateResourceRestResponse(resourceType, userRole, csarFileName, csarFilePath);
+ BaseRestUtils.checkCreateResponse(createResource);
+ return ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
+ }
+
+ public static Resource importCertifiedResourceFromCsar(ResourceTypeEnum resourceType, UserRoleEnum userRole, String csarFileName,
+ String csarFilePath) throws Exception {
+ RestResponse createResource = getCreateCertifiedResourceRestResponse(resourceType, userRole, csarFileName, csarFilePath);
+ BaseRestUtils.checkSuccess(createResource);
+ return ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
+ }
+
+ public static RestResponse getCreateResourceRestResponse(ResourceTypeEnum resourceType, UserRoleEnum userRole,
+ String csarFileName, String csarFilePath) throws IOException, Exception {
+
+ ImportReqDetails resourceDetails = buildImportReqDetails(resourceType, csarFileName, csarFilePath);
+ User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
+ RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
+ return createResource;
+ }
+
+ public static RestResponse getCreateCertifiedResourceRestResponse(ResourceTypeEnum resourceType, UserRoleEnum userRole,
+ String csarFileName, String csarFilePath) throws IOException, Exception {
+
+ ImportReqDetails resourceDetails = buildImportReqDetails(resourceType, csarFileName, csarFilePath);
+ User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
+ RestResponse response = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails);
+ BaseRestUtils.checkCreateResponse(response);
+ return LCSbaseTest.certifyResource(resourceDetails, sdncModifierDetails);
+ }
+
+ private static ImportReqDetails buildImportReqDetails(ResourceTypeEnum resourceType, String csarFileName, String csarFilePath)
+ throws IOException {
+ ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
+ Path path = Paths.get(csarFilePath + File.separator + csarFileName);
+ byte[] data = Files.readAllBytes(path);
+ String payloadName = csarFileName;
+ String payloadData = Base64.encodeBase64String(data);
+ resourceDetails.setPayloadData(payloadData);
+ resourceDetails.setCsarUUID(payloadName);
+ resourceDetails.setPayloadName(payloadName);
+ resourceDetails.setResourceType(resourceType.name());
+ return resourceDetails;
+ }
+
+ public static Resource updateResourceFromCsar(Resource resource, UserRoleEnum userRole, String csarFileName, String csarFilePath)
+ throws Exception {
+ User sdncModifierDetails = ElementFactory.getDefaultUser(userRole);
+
+ byte[] data = null;
+ Path path = Paths.get(csarFilePath + File.separator + csarFileName);
+ data = Files.readAllBytes(path);
+ String payloadName = csarFileName;
+ String payloadData = Base64.encodeBase64String(data);
+ ImportReqDetails resourceDetails = new ImportReqDetails(resource, payloadName, payloadData);
+ resourceDetails.setPayloadData(payloadData);
+ resourceDetails.setCsarUUID(payloadName);
+ resourceDetails.setPayloadName(payloadName);
+
+ String userId = sdncModifierDetails.getUserId();
+ Config config = Utils.getConfig();
+ String url = String.format(Urls.UPDATE_RESOURCE, config.getCatalogBeHost(), config.getCatalogBePort(), resource.getUniqueId());
+
+ Map<String, String> headersMap = ResourceRestUtils.prepareHeadersMap(userId);
+
+ Gson gson = new Gson();
+ String userBodyJson = gson.toJson(resourceDetails);
+ String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson);
+ headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5);
+ HttpRequest http = new HttpRequest();
+ RestResponse updateResourceResponse = http.httpSendPut(url, userBodyJson, headersMap);
+ BaseRestUtils.checkSuccess(updateResourceResponse);
+ return ResponseParser.parseToObjectUsingMapper(updateResourceResponse.getResponse(), Resource.class);
+ }
+
+ public static Either<Resource, RestResponse> importResourceByFileName(ResourceTypeEnum resourceType, UserRoleEnum userRole, String fileName,
+ Boolean validateState, String... filePath) throws IOException {
+
+ String realFilePath =
+ System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "resources" + File.separator + "CI"
+ + File.separator + "csars";
+ if (filePath != null && filePath.length > 0) {
+ realFilePath = filePath.toString();
+ }
+
+ try {
+ User defaultUser = ElementFactory.getDefaultUser(userRole);
+ ResourceReqDetails defaultResource = ElementFactory.getDefaultResource(defaultUser);
+ ImportReqDetails defaultImportResource = ElementFactory.getDefaultImportResource(defaultResource);
+ ImportUtils.getImportResourceDetailsByPathAndName(defaultImportResource, realFilePath, fileName);
+ RestResponse resourceResp = ResourceRestUtils.createResource(defaultImportResource, defaultUser);
+
+ if (validateState) {
+ assertTrue(resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED);
+ }
+
+ if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) {
+ Resource resourceResponseObject = ResponseParser.convertResourceResponseToJavaObject(resourceResp.getResponse());
+ return Either.left(resourceResponseObject);
+ }
+ return Either.right(resourceResp);
+ } catch (Exception e) {
+ throw new AtomicOperationException(e);
+ }
+ }
+
+ public static Either<String, RestResponse> getComponenetArtifactPayload(Component component, String artifactType) throws Exception {
+
+ String url;
+ Config config = Utils.getConfig();
+ if (component.getComponentType().toString().toUpperCase().equals(ComponentTypeEnum.SERVICE.getValue().toUpperCase())) {
+ url = String.format(Urls.UI_DOWNLOAD_SERVICE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(),
+ component.getToscaArtifacts().get(artifactType).getUniqueId());
+ } else {
+ url = String.format(Urls.UI_DOWNLOAD_RESOURCE_ARTIFACT, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(),
+ component.getToscaArtifacts().get(artifactType).getUniqueId());
+ }
+ String userId = component.getLastUpdaterUserId();
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.CACHE_CONTROL.getValue(), BaseRestUtils.cacheControlHeader);
+ headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication);
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
+ if (userId != null) {
+ headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId);
+ }
+ HttpRequest http = new HttpRequest();
+ RestResponse response = http.httpSendGet(url, headersMap);
+ if (response.getErrorCode() != BaseRestUtils.STATUS_CODE_SUCCESS && response.getResponse().getBytes() == null
+ && response.getResponse().getBytes().length == 0) {
+ return Either.right(response);
+ }
+ return Either.left(response.getResponse());
+
+ }
+
+ public static RestResponse getDistributionStatusByDistributionId(String distributionId, Boolean validateState) {
+
+ try {
+ User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.OPS);
+ RestResponse response = DistributionUtils.getDistributionStatus(defaultUser, distributionId);
+
+ if (validateState) {
+ assertTrue(response.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS);
+ }
+ return response;
+
+ } catch (Exception e) {
+ throw new AtomicOperationException(e);
+ }
+ }
+
+ public static Either<RestResponse, Map<String, List<DistributionMonitorObject>>> getSortedDistributionStatusMap(Service service,
+ Boolean validateState) {
+
+ try {
+ ServiceDistributionStatus serviceDistributionObject = DistributionUtils.getLatestServiceDistributionObject(service);
+ RestResponse response = getDistributionStatusByDistributionId(serviceDistributionObject.getDistributionID(), true);
+ if (validateState) {
+ assertTrue(response.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS);
+ }
+ if (response.getErrorCode() == ResourceRestUtils.STATUS_CODE_SUCCESS) {
+ Map<String, List<DistributionMonitorObject>> parsedDistributionStatus = DistributionUtils.getSortedDistributionStatus(response);
+ return Either.right(parsedDistributionStatus);
+ }
+ return Either.left(response);
+ } catch (Exception e) {
+ throw new AtomicOperationException(e);
+ }
+
+ }
+
+
+ /**
+ * @param service
+ * @param pollingCount
+ * @param pollingInterval Recommended values for service distribution for pollingCount is 4 and for pollingInterval is 15000ms
+ * @throws Exception
+ */
+ public static Boolean distributeAndValidateService(Service service, int pollingCount, int pollingInterval) throws Exception {
+ int firstPollingInterval = 30000; //this value define first be polling topic time, should change if DC configuration changed
+ Boolean statusFlag = true;
+ AtomicOperationUtils.distributeService(service, true);
+ TimeUnit.MILLISECONDS.sleep(firstPollingInterval);
+ int timeOut = pollingCount * pollingInterval;
+ com.clearspring.analytics.util.Pair<Boolean, Map<String, List<String>>> verifyDistributionStatus = null;
+
+ while (timeOut > 0) {
+ Map<String, List<DistributionMonitorObject>> sortedDistributionStatusMap = AtomicOperationUtils.getSortedDistributionStatusMap(service,
+ true).right().value();
+ verifyDistributionStatus = DistributionUtils.verifyDistributionStatus(sortedDistributionStatusMap);
+ if (verifyDistributionStatus.left.equals(false)) {
+ TimeUnit.MILLISECONDS.sleep(pollingInterval);
+ timeOut -= pollingInterval;
+ } else {
+ timeOut = 0;
+ }
+ }
+
+ if ((verifyDistributionStatus.right != null && !verifyDistributionStatus.right.isEmpty())) {
+ for (Entry<String, List<String>> entry : verifyDistributionStatus.right.entrySet()) {
+ if (ComponentBaseTest.getExtendTest() != null) {
+ ComponentBaseTest.getExtendTest().log(Status.INFO, "Consumer: " + entry.getKey() + " failed on following: " + entry.getValue());
+ } else {
+ System.out.println("Consumer: [" + entry.getKey() + "] failed on following: " + entry.getValue());
+ }
+ }
+ statusFlag = false;
+ }
+ return statusFlag;
+ }
+
+ public static Boolean distributeAndValidateService(Service service) throws Exception {
+ return distributeAndValidateService(service, 10, 10000);
+ }
+
+ /**
* @param resource to download csar file via API
* @return Tosca definition object from main yaml file
*/
@@ -1041,12 +1156,13 @@ public final class AtomicOperationUtils {
}
- public static ComponentInstance getServiceComponentInstanceByName(Service service, String name, Boolean validateState){
+ public static ComponentInstance getServiceComponentInstanceByName(Service service, String name, Boolean validateState) {
List<ComponentInstance> compInstances = service.getComponentInstances();
- for (ComponentInstance instance: compInstances){
+ for (ComponentInstance instance : compInstances) {
String compName = instance.getName();
- if (compName.equals(name))
+ if (compName.equals(name)) {
return instance;
+ }
}
if (validateState) {
assertEquals("Component instance name " + name + " not found", name, null);
@@ -1054,13 +1170,14 @@ public final class AtomicOperationUtils {
return null;
}
- public static Pair<Component, ComponentInstance> updateComponentInstanceName(String newName, Component component, String canvasElementName, User user, Boolean validateState) throws Exception {
- ComponentInstanceReqDetails componentInstanceReqDetails = ElementFactory.getDefaultComponentInstance();
- ComponentInstance componentInstanceByName = AtomicOperationUtils.getComponentInstanceByName(component, canvasElementName);
- componentInstanceReqDetails.setName(newName);
- componentInstanceReqDetails.setComponentUid(componentInstanceByName.getComponentUid());
- componentInstanceReqDetails.setUniqueId(componentInstanceByName.getUniqueId());
- return AtomicOperationUtils.updateComponentInstance(componentInstanceReqDetails, user, component, validateState).left().value();
- }
+ public static Pair<Component, ComponentInstance> updateComponentInstanceName(String newName, Component component, String canvasElementName,
+ User user, Boolean validateState) throws Exception {
+ ComponentInstanceReqDetails componentInstanceReqDetails = ElementFactory.getDefaultComponentInstance();
+ ComponentInstance componentInstanceByName = AtomicOperationUtils.getComponentInstanceByName(component, canvasElementName);
+ componentInstanceReqDetails.setName(newName);
+ componentInstanceReqDetails.setComponentUid(componentInstanceByName.getComponentUid());
+ componentInstanceReqDetails.setUniqueId(componentInstanceByName.getUniqueId());
+ return AtomicOperationUtils.updateComponentInstance(componentInstanceReqDetails, user, component, validateState).left().value();
+ }
}