summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java93
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java29
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java1
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java48
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java60
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java51
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java86
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java27
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java246
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java42
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java3
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java3
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java23
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java30
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java89
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java392
-rw-r--r--catalog-ui/src/app/models/attributes.ts30
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html24
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts16
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/attributes/attributes-modal.component.spec.ts20
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/attributes/attributes.component.html4
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java96
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/EntrySchemaDataDefinition.java21
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java1
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java4
-rw-r--r--common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java56
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java4
31 files changed, 986 insertions, 524 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
index ef82eba0a4..cef4d8f6df 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
@@ -21,11 +21,17 @@
package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
@@ -37,16 +43,13 @@ import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
+import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
+import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
/**
* This class holds the business logic relevant for attributes manipulation.
*
@@ -113,15 +116,15 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
// validate property default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue((AttributeDefinition)newAttributeDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttributeDef, eitherAllDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
- handleDefaultValue((AttributeDefinition)newAttributeDef, eitherAllDataTypes);
+ handleAttributeDefaultValue(newAttributeDef, eitherAllDataTypes);
// add the new attribute to resource on graph
- // need to get StorageOpaerationStatus and convert to ActionStatus from
+ // need to get StorageOperationStatus and convert to ActionStatus from
// componentsUtils
Either<AttributeDataDefinition, StorageOperationStatus> either = toscaOperationFacade.addAttributeOfResource(resource, newAttributeDef);
if (either.isRight()) {
@@ -135,13 +138,73 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
commitOrRollback(result);
graphLockOperation.unlockComponent(resourceId, NodeTypeEnum.Resource);
}
+ }
+
+ private Either<Boolean, ResponseFormat> validateAttributeDefaultValue(final AttributeDataDefinition attributeDefinition,
+ final Map<String, DataTypeDefinition> dataTypes) {
+
+ if (!attributeOperation.isAttributeTypeValid(attributeDefinition)) {
+ log.info("Invalid type for attribute '{}' type '{}'", attributeDefinition.getName(), attributeDefinition.getType());
+ final ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY_TYPE, attributeDefinition
+ .getType(), attributeDefinition.getName());
+ return Either.right(responseFormat);
+ }
+ String type = attributeDefinition.getType();
+ String innerType = null;
+ if (type.equals(ToscaPropertyType.LIST.getType()) || type.equals(ToscaPropertyType.MAP.getType())) {
+ final ImmutablePair<String, Boolean> propertyInnerTypeValid = attributeOperation.isAttributeInnerTypeValid(
+ attributeDefinition, dataTypes);
+ innerType = propertyInnerTypeValid.getLeft();
+ if (!propertyInnerTypeValid.getRight()) {
+ log.info("Invalid inner type for attribute '{}' type '{}', dataTypeCount '{}'",
+ attributeDefinition.getName(), attributeDefinition.getType(), dataTypes.size());
+ final ResponseFormat responseFormat = componentsUtils
+ .getResponseFormat(ActionStatus.INVALID_PROPERTY_INNER_TYPE, innerType, attributeDefinition.getName());
+ return Either.right(responseFormat);
+ }
+ }
+ if (!attributeOperation.isAttributeDefaultValueValid(attributeDefinition, dataTypes)) {
+ log.info("Invalid default value for attribute '{}' type '{}'", attributeDefinition.getName(),
+ attributeDefinition.getType());
+ ResponseFormat responseFormat;
+ if (type.equals(ToscaPropertyType.LIST.getType()) || type.equals(ToscaPropertyType.MAP.getType())) {
+ responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE,
+ attributeDefinition.getName(), type, innerType,
+ (String) attributeDefinition.get_default());
+ } else {
+ responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_DEFAULT_VALUE,
+ attributeDefinition.getName(), type, (String) attributeDefinition.get_default());
+ }
+ return Either.right(responseFormat);
+
+ }
+ return Either.left(true);
+ }
+
+ private void handleAttributeDefaultValue(final AttributeDataDefinition newAttributeDefinition,
+ final Map<String, DataTypeDefinition> dataTypes) {
+ final ToscaPropertyType type = ToscaPropertyType.isValidType(newAttributeDefinition.getType());
+ final PropertyValueConverter converter = type.getConverter();
+ // get inner type
+ String innerType = null;
+ final SchemaDefinition schema = newAttributeDefinition.getSchema();
+ if (schema != null) {
+ final PropertyDataDefinition prop = schema.getProperty();
+ if (schema.getProperty() != null) {
+ innerType = prop.getType();
+ }
+ }
+ if (newAttributeDefinition.get_default() != null) {
+ newAttributeDefinition.set_default(converter
+ .convert((String) newAttributeDefinition.get_default(), innerType, dataTypes));
+ }
}
private boolean isAttributeExist(List<AttributeDataDefinition> attributes, String resourceUid, String propertyName) {
boolean isExist = false;
if (attributes != null) {
- isExist = attributes.stream().anyMatch(p -> Objects.equals(p.getName(), propertyName) && Objects.equals(p.getParentUniqueId(), resourceUid));
+ isExist = attributes.stream().anyMatch(p -> Objects.equals(p.getName(), propertyName) && Objects.equals(p.getOwnerId(), resourceUid));
}
return isExist;
@@ -169,8 +232,10 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, ""));
} else {
// verify attribute exist in resource
- Optional<AttributeDataDefinition> optionalAtt = attributes.stream().filter(att -> att.getUniqueId().equals(attributeId) && resourceId.equals(att.getParentUniqueId())).findAny();
- return optionalAtt.<Either<AttributeDataDefinition, ResponseFormat>>map(Either::left).orElseGet(() -> Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, "")));
+ Optional<AttributeDataDefinition> optionalAtt = attributes.stream().filter(att ->
+ att.getUniqueId().equals(attributeId)).findAny();
+ return optionalAtt.<Either<AttributeDataDefinition, ResponseFormat>>map(Either::left).orElseGet(() ->
+ Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, "")));
}
}
@@ -213,13 +278,13 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
// validate attribute default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue((AttributeDefinition)newAttDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttDef, eitherAllDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
// add the new property to resource on graph
- StorageOperationStatus validateAndUpdateAttribute = propertyOperation.validateAndUpdateProperty((AttributeDefinition)newAttDef, eitherAllDataTypes);
+ StorageOperationStatus validateAndUpdateAttribute = attributeOperation.validateAndUpdateAttribute(newAttDef, eitherAllDataTypes);
if (validateAndUpdateAttribute != StorageOperationStatus.OK) {
log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, validateAndUpdateAttribute);
result = Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(validateAndUpdateAttribute), resource.getName()));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
index 2616801c42..d1df40c091 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
@@ -79,6 +79,7 @@ import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.AttributeOperation;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.impl.PolicyTypeOperation;
@@ -116,6 +117,7 @@ public abstract class BaseBusinessLogic {
protected JanusGraphDao janusGraphDao;
protected JanusGraphGenericDao janusGraphGenericDao;
protected PropertyOperation propertyOperation;
+ protected AttributeOperation attributeOperation;
protected ApplicationDataTypeCache applicationDataTypeCache;
protected ToscaOperationFacade toscaOperationFacade;
protected ApplicationDataTypeCache dataTypeCache;
@@ -195,6 +197,11 @@ public abstract class BaseBusinessLogic {
this.propertyOperation = propertyOperation;
}
+ @Autowired
+ public void setAttributeOperation(AttributeOperation attributeOperation) {
+ this.attributeOperation = attributeOperation;
+ }
+
User validateUserNotEmpty(User user, String ecompErrorContext) {
return userValidations.validateUserNotEmpty(user, ecompErrorContext);
}
@@ -478,28 +485,6 @@ public abstract class BaseBusinessLogic {
return Either.left(true);
}
-
- void handleDefaultValue(IComplexDefaultValue newAttributeDef, Map<String, DataTypeDefinition> dataTypes) {
- // convert property
- ToscaPropertyType type = ToscaPropertyType.isValidType(newAttributeDef.getType());
- PropertyValueConverter converter = type.getConverter();
- // get inner type
- String innerType = null;
-
- SchemaDefinition schema = newAttributeDef.getSchema();
- if (schema != null) {
- PropertyDataDefinition prop = schema.getProperty();
- if (schema.getProperty() != null) {
- innerType = prop.getType();
- }
- }
- String convertedValue;
- if (newAttributeDef.getDefaultValue() != null) {
- convertedValue = converter.convert(newAttributeDef.getDefaultValue(), innerType, dataTypes);
- newAttributeDef.setDefaultValue(convertedValue);
- }
- }
-
void validateComponentTypeEnum(ComponentTypeEnum componentTypeEnum, String errorContext, Wrapper<ResponseFormat> errorWrapper) {
if (componentTypeEnum == null) {
BeEcompErrorManager.getInstance().logInvalidInputError(errorContext, "invalid component type", ErrorSeverity.INFO);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index 34236eb644..72aeb2b8f9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -59,7 +59,6 @@ import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.facade.operations.CatalogOperation;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapReqDef;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
index f04eca1744..4127faa820 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
@@ -20,21 +20,33 @@
package org.openecomp.sdc.be.components.impl;
+import static org.apache.commons.collections.CollectionUtils.isEmpty;
+import static org.openecomp.sdc.be.components.impl.ResourceImportManager.PROPERTY_NAME_PATTERN_IGNORE_LENGTH;
+import static org.openecomp.sdc.be.datatypes.elements.Annotation.setAnnotationsName;
+
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken;
import fj.data.Either;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.function.Consumer;
+import java.util.function.Function;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringEscapeUtils;
-import org.apache.tinkerpop.gremlin.structure.T;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.Annotation;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
@@ -42,7 +54,6 @@ import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.AnnotationTypeDefinition;
import org.openecomp.sdc.be.model.AttributeDefinition;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.HeatParameterDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -70,25 +81,6 @@ import org.yaml.snakeyaml.nodes.Tag;
import org.yaml.snakeyaml.representer.Representer;
import org.yaml.snakeyaml.resolver.Resolver;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-import static org.apache.commons.collections.CollectionUtils.isEmpty;
-import static org.openecomp.sdc.be.components.impl.ResourceImportManager.PROPERTY_NAME_PATTERN_IGNORE_LENGTH;
-import static org.openecomp.sdc.be.datatypes.elements.Annotation.setAnnotationsName;
-import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementOperation.createDataType;
-import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementOperation.createDataTypeDefinitionWithName;
-
@Component
public final class ImportUtils {
@@ -616,14 +608,6 @@ public final class ImportUtils {
}
- public static Either<Map<String, AttributeDataDefinition>, ResultStatusEnum> getAttributes(
- Map<String, Object> toscaJson) {
- Function<String, AttributeDataDefinition> elementGenByName = ImportUtils::createAttribute;
- Function<Map<String, Object>, AttributeDataDefinition> func = ImportUtils::createModuleAttribute;
-
- return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.ATTRIBUTES, elementGenByName, func);
- }
-
public static <T> Either<Map<String, T>, ResultStatusEnum> getElements(Map<String, Object> toscaJson,
TypeUtils.ToscaTagNamesEnum elementTagName,
Function<String, T> elementGenByName,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 50b2941f1b..7788066e52 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -2660,7 +2660,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.getComponentInstances()
.stream()
.filter(i -> !i.isCreatedFromCsar())
- .forEach(i->processUiComponentInstance(oldResource, i, instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts, instProperties, instInputs, instAttributes));
+ .forEach(i -> processUiComponentInstance(oldResource, i, instCapabilities, instRequirements,
+ instDeploymentArtifacts, instArtifacts, instProperties, instInputs, instAttributes));
associateComponentInstancePropertiesToComponent(yamlName, resource, instProperties);
associateComponentInstanceInputsToComponent(yamlName, resource, instInputs);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index 4e6628c8dd..7ff916df32 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -28,10 +28,22 @@ import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementO
import static org.openecomp.sdc.be.utils.TypeUtils.setField;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
+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;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import javax.servlet.ServletContext;
import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -62,9 +74,7 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
@@ -96,20 +106,6 @@ import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;
import org.yaml.snakeyaml.Yaml;
-import javax.servlet.ServletContext;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
@Component("resourceImportManager")
public class ResourceImportManager {
@@ -359,7 +355,6 @@ public class ResourceImportManager {
if (StringUtils.isEmpty(resource.getToscaResourceName())) {
setToscaResourceName(toscaJson, resource);
}
- setAttributes(toscaJson, resource);
setCapabilities(toscaJson, resource, parentResource);
setProperties(toscaJson, resource);
setRequirements(toscaJson, resource, parentResource);
@@ -680,28 +675,6 @@ public class ResourceImportManager {
}
}
- private ResultStatusEnum setAttributes(Map<String, Object> toscaJson, Resource resource) {
- ResultStatusEnum result = ResultStatusEnum.OK;
- Either<Map<String, AttributeDataDefinition>, ResultStatusEnum> attributes = ImportUtils
- .getAttributes(toscaJson);
- if (attributes.isLeft()) {
- List<AttributeDataDefinition> attributeList = new ArrayList<>();
- Map<String, AttributeDataDefinition> value = attributes.left().value();
- if (value != null) {
- for (Entry<String, AttributeDataDefinition> entry : value.entrySet()) {
- String name = entry.getKey();
- AttributeDataDefinition attributeDef = entry.getValue();
- attributeDef.setName(name);
- attributeList.add(attributeDef);
- }
- }
- resource.setAttributes(attributeList);
- } else {
- result = attributes.right().value();
- }
- return result;
- }
-
private Resource setDerivedFrom(Map<String, Object> toscaJson, Resource resource) {
Either<String, ResultStatusEnum> toscaDerivedFromElement = ImportUtils
.findFirstToscaStringElement(toscaJson, TypeUtils.ToscaTagNamesEnum.DERIVED_FROM);
@@ -1024,16 +997,17 @@ public class ResourceImportManager {
final Map<String, Object> attributeMap = (Map<String, Object>) value;
- final AttributeDefinition attributeDefinition = new AttributeDefinition();
+ final AttributeDataDefinition attributeDefinition = new AttributeDataDefinition();
attributeDefinition.setName(key);
setField(attributeMap, ToscaTagNamesEnum.DESCRIPTION, attributeDefinition::setDescription);
setField(attributeMap, ToscaTagNamesEnum.TYPE, attributeDefinition::setType);
+ setField(attributeMap, ToscaTagNamesEnum.DEFAULT_VALUE, attributeDefinition::set_default);
setField(attributeMap, ToscaTagNamesEnum.STATUS, attributeDefinition::setStatus);
- setField(attributeMap, ToscaTagNamesEnum.ENTRY_SCHEMA, attributeDefinition::setEntry_schema);
+ setField(attributeMap, ToscaTagNamesEnum.ENTRY_SCHEMA, attributeDefinition::setSchema);
attributeDataDefinitionList.add(attributeDefinition);
} else {
- final AttributeDefinition attributeDefinition = new AttributeDefinition();
+ final AttributeDataDefinition attributeDefinition = new AttributeDataDefinition();
attributeDefinition.setName(key);
attributeDataDefinitionList.add(attributeDefinition);
}
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 b47c3928e8..3b19ea9d86 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
@@ -24,7 +24,6 @@ import static org.openecomp.sdc.be.components.impl.ImportUtils.getPropertyJsonSt
import static org.openecomp.sdc.be.tosca.CsarUtils.VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN;
import fj.data.Either;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
@@ -36,13 +35,10 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Pattern;
-
import lombok.Getter;
import lombok.Setter;
-import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
-import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.components.csar.CsarArtifactsAndGroupsBusinessLogic;
import org.openecomp.sdc.be.components.csar.CsarBusinessLogic;
@@ -71,20 +67,13 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
-import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.CreatedFrom;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
@@ -92,7 +81,6 @@ import org.openecomp.sdc.be.info.NodeTypeInfoToUpdateArtifacts;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
-import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
@@ -102,7 +90,6 @@ 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.InputDefinition;
-import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.NodeTypeInfo;
@@ -115,16 +102,12 @@ 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.UploadCapInfo;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
-import org.openecomp.sdc.be.model.UploadInfo;
import org.openecomp.sdc.be.model.UploadNodeFilterInfo;
import org.openecomp.sdc.be.model.UploadPropInfo;
import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.UploadResourceInfo;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
@@ -132,21 +115,15 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.StorageException;
-import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
-import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
-import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
import org.openecomp.sdc.be.tosca.CsarUtils;
-import org.openecomp.sdc.be.utils.CommonBeUtils;
import org.openecomp.sdc.be.utils.TypeUtils;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
@@ -154,11 +131,9 @@ import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.datastructure.Wrapper;
import org.openecomp.sdc.common.kpi.api.ASDCKpiApi;
import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.openecomp.sdc.common.util.GeneralUtility;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.beans.factory.annotation.Autowired;
-import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
@Getter
@@ -1297,7 +1272,18 @@ public class ServiceImportBusinessLogic{
return eitherGetResource.left().value();
}
- protected void processComponentInstance(String yamlName, Resource resource, List<ComponentInstance> componentInstancesList, Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes, Map<String, List<ComponentInstanceProperty>> instProperties, Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties, Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements, Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts, Map<String, Map<String, ArtifactDefinition>> instArtifacts, Map<String, List<AttributeDataDefinition>> instAttributes, Map<String, Resource> originCompMap, Map<String, List<ComponentInstanceInput>> instInputs, UploadComponentInstanceInfo uploadComponentInstanceInfo) {
+ protected void processComponentInstance(String yamlName, Resource resource,
+ List<ComponentInstance> componentInstancesList,
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ Map<String, List<ComponentInstanceProperty>> instProperties,
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts,
+ Map<String, Map<String, ArtifactDefinition>> instArtifacts,
+ Map<String, List<AttributeDataDefinition>> instAttributes,
+ Map<String, Resource> originCompMap,
+ Map<String, List<ComponentInstanceInput>> instInputs,
+ UploadComponentInstanceInfo uploadComponentInstanceInfo) {
Optional<ComponentInstance> currentCompInstanceOpt = componentInstancesList.stream()
.filter(i -> i.getName().equals(uploadComponentInstanceInfo.getName()))
.findFirst();
@@ -1736,7 +1722,18 @@ public class ServiceImportBusinessLogic{
return eitherGetResource.left().value();
}
- protected void processComponentInstance(String yamlName, Service service, List<ComponentInstance> componentInstancesList, Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes, Map<String, List<ComponentInstanceProperty>> instProperties, Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties, Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements, Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts, Map<String, Map<String, ArtifactDefinition>> instArtifacts, Map<String, List<AttributeDataDefinition>> instAttributes, Map<String, Resource> originCompMap, Map<String, List<ComponentInstanceInput>> instInputs, UploadComponentInstanceInfo uploadComponentInstanceInfo) {
+ protected void processComponentInstance(String yamlName, Service service,
+ List<ComponentInstance> componentInstancesList,
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ Map<String, List<ComponentInstanceProperty>> instProperties,
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts,
+ Map<String, Map<String, ArtifactDefinition>> instArtifacts,
+ Map<String, List<AttributeDataDefinition>> instAttributes,
+ Map<String, Resource> originCompMap,
+ Map<String, List<ComponentInstanceInput>> instInputs,
+ UploadComponentInstanceInfo uploadComponentInstanceInfo) {
log.debug("enter ServiceImportBusinessLogic processComponentInstance");
Optional<ComponentInstance> currentCompInstanceOpt = componentInstancesList.stream()
.filter(i -> i.getName().equals(uploadComponentInstanceInfo.getName()))
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
index 9f54f1fae8..b4b2c15dcb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.be.servlets;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.jcabi.aspects.Loggable;
@@ -32,6 +33,21 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.annotations.tags.Tag;
+import java.io.IOException;
+import javax.inject.Inject;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.openecomp.sdc.be.components.impl.AttributeBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceImportManager;
@@ -42,31 +58,15 @@ import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ServletUtils;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.datastructure.Wrapper;
+import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.stereotype.Controller;
-import javax.inject.Inject;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-
/**
* Web Servlet for actions on Attributes
*
@@ -122,18 +122,17 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.debug("Start handle request of {} modifier id is {} data is {}", url, userId, data);
try {
- Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
- Wrapper<AttributeDataDefinition> attributesWrapper = new Wrapper<>();
- // convert json to AttributeDefinition
+ final Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
+ AttributeDataDefinition attributeDataDefinition = convertJsonToObject(data, errorWrapper);
- buildAttributeFromString(data, attributesWrapper, errorWrapper);
if (errorWrapper.isEmpty()) {
AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<AttributeDataDefinition, ResponseFormat> createAttribute = businessLogic.createAttribute(resourceId, attributesWrapper.getInnerElement(), userId);
+ Either<AttributeDataDefinition, ResponseFormat> createAttribute = businessLogic
+ .createAttribute(resourceId, attributeDataDefinition, userId);
if (createAttribute.isRight()) {
errorWrapper.setInnerElement(createAttribute.right().value());
} else {
- attributesWrapper.setInnerElement(createAttribute.left().value());
+ attributeDataDefinition = createAttribute.left().value();
}
}
@@ -142,10 +141,9 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.info("Failed to create Attribute. Reason - ", errorWrapper.getInnerElement());
response = buildErrorResponse(errorWrapper.getInnerElement());
} else {
- AttributeDataDefinition createdAttDef = attributesWrapper.getInnerElement();
- log.debug("Attribute {} created successfully with id {}", createdAttDef.getName(), createdAttDef.getUniqueId());
+ log.debug("Attribute {} created successfully with id {}", attributeDataDefinition.getName(), attributeDataDefinition.getUniqueId());
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.CREATED);
- response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(createdAttDef));
+ response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(attributeDataDefinition));
}
return response;
@@ -197,21 +195,16 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.debug("modifier id is {}", userId);
try {
- // convert json to PropertyDefinition
- Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
- Wrapper<AttributeDataDefinition> attributesWrapper = new Wrapper<>();
- // convert json to AttributeDefinition
-
- buildAttributeFromString(data, attributesWrapper, errorWrapper);
-
+ final Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
+ AttributeDataDefinition attributeDataDefinition = convertJsonToObject(data, errorWrapper);
if (errorWrapper.isEmpty()) {
AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<AttributeDataDefinition, ResponseFormat> eitherUpdateAttribute = businessLogic.updateAttribute(resourceId, attributeId, attributesWrapper.getInnerElement(), userId);
- // update property
+ Either<AttributeDataDefinition, ResponseFormat> eitherUpdateAttribute = businessLogic
+ .updateAttribute(resourceId, attributeId, attributeDataDefinition, userId);
if (eitherUpdateAttribute.isRight()) {
errorWrapper.setInnerElement(eitherUpdateAttribute.right().value());
} else {
- attributesWrapper.setInnerElement(eitherUpdateAttribute.left().value());
+ attributeDataDefinition = eitherUpdateAttribute.left().value();
}
}
@@ -220,10 +213,9 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.info("Failed to update Attribute. Reason - ", errorWrapper.getInnerElement());
response = buildErrorResponse(errorWrapper.getInnerElement());
} else {
- AttributeDataDefinition updatedAttribute = attributesWrapper.getInnerElement();
- log.debug("Attribute id {} updated successfully ", updatedAttribute.getUniqueId());
+ log.debug("Attribute id {} updated successfully ", attributeDataDefinition.getUniqueId());
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(updatedAttribute));
+ response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(attributeDataDefinition));
}
return response;
@@ -295,7 +287,7 @@ public class AttributeServlet extends AbstractValidationsServlet {
Wrapper<ResponseFormat> errorWrapper) {
try {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
- final AttributeDataDefinition attribute = gson.fromJson(data, AttributeDefinition.class);
+ final AttributeDataDefinition attribute = gson.fromJson(data, AttributeDataDefinition.class);
if (attribute == null) {
log.info(ATTRIBUTE_CONTENT_IS_INVALID, data);
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
@@ -311,4 +303,18 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.info(ATTRIBUTE_CONTENT_IS_INVALID, data);
}
}
+
+ private AttributeDataDefinition convertJsonToObject(final String data,
+ final Wrapper<ResponseFormat> errorWrapper) {
+
+ final ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.readValue(data, AttributeDataDefinition.class);
+ } catch (final IOException e) {
+ log.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, ATTRIBUTE_CONTENT_IS_INVALID, data);
+ ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
+ errorWrapper.setInnerElement(responseFormat);
+ return null;
+ }
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 08c3d18157..9eebbc50cb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -25,6 +25,10 @@ import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
import static org.apache.commons.collections.MapUtils.isNotEmpty;
import static org.openecomp.sdc.be.components.utils.PropertiesUtils.resolvePropertyValueFromInput;
import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.addInterfaceTypeElement;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import fj.data.Either;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Collection;
@@ -46,6 +50,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.commons.lang3.tuple.Triple;
+import org.onap.sdc.tosca.datatypes.model.AttributeDefinition;
import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.be.components.impl.exceptions.SdcResourceNotFoundException;
import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -58,7 +63,6 @@ import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterPropertyDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.RequirementSubstitutionFilterCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementSubstitutionFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition;
@@ -123,9 +127,6 @@ import org.yaml.snakeyaml.nodes.NodeTuple;
import org.yaml.snakeyaml.nodes.Tag;
import org.yaml.snakeyaml.representer.Represent;
import org.yaml.snakeyaml.representer.Representer;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import fj.data.Either;
@org.springframework.stereotype.Component("tosca-export-handler")
public class ToscaExportHandler {
@@ -1079,14 +1080,28 @@ public class ToscaExportHandler {
if (component instanceof Resource) {
final List<AttributeDataDefinition> attributes = ((Resource) component).getAttributes();
if (CollectionUtils.isNotEmpty(attributes)) {
- final Map<String, AttributeDataDefinition> attributeDataDefinitionMap
- = attributes.stream().collect(Collectors.toMap(AttributeDataDefinition::getName, a -> a));
+ final Map<String, Object> attributeDataDefinitionMap = new HashMap<>();
+ attributes.forEach(attributeDataDefinition ->
+ buildAttributeData(attributeDataDefinition, attributeDataDefinitionMap));
+
toscaNodeType.setAttributes(attributeDataDefinitionMap);
}
}
return toscaNodeType;
}
+ private void buildAttributeData(final AttributeDataDefinition originalAttributeDataDefinition,
+ final Map<String, Object> attributeDataDefinitionMap) {
+
+ attributeDataDefinitionMap.put(originalAttributeDataDefinition.getName(),
+ new ObjectMapper().convertValue(new AttributeDefinition(
+ originalAttributeDataDefinition.getType(),
+ originalAttributeDataDefinition.getDescription(),
+ originalAttributeDataDefinition.get_default(),
+ originalAttributeDataDefinition.getStatus(),
+ originalAttributeDataDefinition.getEntry_schema()), Object.class));
+ }
+
private Either<Map<String, Object>, ToscaError> createProxyInterfaceTypes(Component container) {
Map<String, Object> proxyInterfaceTypes = new HashMap<>();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java
index b5e5866fe4..856c430f65 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java
@@ -25,7 +25,6 @@ import java.util.Map;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
@Getter
@Setter
@@ -41,6 +40,6 @@ public class ToscaNodeType {
private Map<String, ToscaCapability> capabilities;
private List<Map<String, ToscaRequirement>> requirements;
- private Map<String, AttributeDataDefinition> attributes;
+ private Map<String, Object> attributes;
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
index db4c699d04..0b11b2e0cf 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
@@ -17,81 +17,77 @@
* limitations under the License.
* ============LICENSE_END=========================================================
* Modifications copyright (c) 2019 Nokia
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
*/
+
package org.openecomp.sdc.be.components.impl;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
-import junit.framework.Assert;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
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.PropertyOperation;
+import org.openecomp.sdc.be.model.operations.impl.AttributeOperation;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyObject;
-import static org.mockito.Mockito.when;
-
-import org.openecomp.sdc.be.model.DataTypeDefinition;
-
-public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
+public class AttributeBusinessLogicTest extends BaseBusinessLogicMock {
private AttributeBusinessLogic createTestSubject() {
return new AttributeBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation );
}
- UserValidations userValidations = Mockito.mock(UserValidations.class);
- ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
- JanusGraphDao janusGraphDao = Mockito.mock(JanusGraphDao.class);
- ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
- ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
- PropertyOperation propertyOperation = Mockito.mock(PropertyOperation.class);
- Field baseBusinessLogic;
- Field baseBusinessLogic1;
- Field baseBusinessLogic2;
- Field baseBusinessLogic3;
- AttributeBusinessLogic attributeBusinessLogic=createTestSubject();
- IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class);
+ private UserValidations userValidations = Mockito.mock(UserValidations.class);
+ private ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
+ private JanusGraphDao janusGraphDao = Mockito.mock(JanusGraphDao.class);
+ private ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ private ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
+ private AttributeOperation attributeOperation = Mockito.mock(AttributeOperation.class);
+ private Field baseBusinessLogic;
+ private AttributeBusinessLogic attributeBusinessLogic=createTestSubject();
+ private IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class);
@Before
- public void setup() throws Exception{
-
+ public void setup() throws Exception {
baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("graphLockOperation");
baseBusinessLogic.setAccessible(true);
baseBusinessLogic.set(attributeBusinessLogic, igraphLockOperation);
- baseBusinessLogic1 = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("userValidations");
+ final Field baseBusinessLogic1 = attributeBusinessLogic.getClass().getSuperclass()
+ .getDeclaredField("userValidations");
baseBusinessLogic1.setAccessible(true);
baseBusinessLogic1.set(attributeBusinessLogic, userValidations);
- baseBusinessLogic2 = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("componentsUtils");
+ final Field baseBusinessLogic2 = attributeBusinessLogic.getClass().getSuperclass()
+ .getDeclaredField("componentsUtils");
baseBusinessLogic2.setAccessible(true);
baseBusinessLogic2.set(attributeBusinessLogic, componentsUtils);
- baseBusinessLogic3 = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("janusGraphDao");
+ final Field baseBusinessLogic3 = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("janusGraphDao");
baseBusinessLogic3.setAccessible(true);
baseBusinessLogic3.set(attributeBusinessLogic, janusGraphDao);
@@ -103,85 +99,20 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
baseBusinessLogic.setAccessible(true);
baseBusinessLogic.set(attributeBusinessLogic, applicationDataTypeCache);
- baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("propertyOperation");
+ baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("attributeOperation");
baseBusinessLogic.setAccessible(true);
- baseBusinessLogic.set(attributeBusinessLogic, propertyOperation);
- }
-
- @Test
- public void testCreateAttribute() throws Exception {
- AttributeBusinessLogic testSubject;
- String resourceId = "";
- PropertyDefinition newAttributeDef = null;
- String userId = "";
- Either<AttributeDataDefinition, ResponseFormat> result;
-
- // default test
- testSubject = createTestSubject();
- }
-
- @Test
- public void testIsAttributeExist() throws Exception {
- AttributeBusinessLogic testSubject;List<AttributeDataDefinition> attributes = null;
- String resourceUid = "";
- String propertyName = "";
- boolean result;
-
- // test 1
- testSubject=createTestSubject();attributes = null;
- }
-
- @Test
- public void testGetAttribute() throws Exception {
- AttributeBusinessLogic testSubject;
- String resourceId = "";
- String attributeId = "";
- String userId = "";
- Either<PropertyDefinition, ResponseFormat> result;
-
- // default test
- testSubject = createTestSubject();
- }
-
- @Test
- public void testUpdateAttribute() throws Exception {
- AttributeBusinessLogic testSubject;
- String resourceId = "";
- String attributeId = "";
- PropertyDefinition newAttDef = null;
- String userId = "";
- Either<PropertyDefinition, ResponseFormat> result;
-
- // default test
- testSubject = createTestSubject();
+ baseBusinessLogic.set(attributeBusinessLogic, attributeOperation);
}
@Test
- public void testDeleteAttribute() throws Exception {
- AttributeBusinessLogic testSubject;
- String resourceId = "";
- String attributeId = "";
- String userId = "";
- Either<PropertyDefinition, ResponseFormat> result;
-
- // default test
- testSubject = createTestSubject();
- }
-
- @Test
- public void createAttribute_lockfail() throws Exception {
+ public void createAttribute_lockfail() {
Either<AttributeDataDefinition, ResponseFormat> response;
- AttributeDataDefinition prop= new AttributeDataDefinition();
-
- response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
-
- Assert.assertEquals(true,response.isRight());
-
+ response = attributeBusinessLogic.createAttribute("RES01", new AttributeDataDefinition(), "USR01");
+ assertTrue(response.isRight());
}
@Test
- public void createAttribute_Success() throws Exception {
-
+ public void createAttribute_Success() {
Component resource = new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setIsDeleted(false);
@@ -192,32 +123,29 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- //Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY);
Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
AttributeDataDefinition attributeDataDefinition = new AttributeDataDefinition();
Either<AttributeDataDefinition, StorageOperationStatus> either = Either.left(attributeDataDefinition);
- when(toscaOperationFacade.addAttributeOfResource(anyObject(), anyObject())).thenReturn(either);
+ when(toscaOperationFacade.addAttributeOfResource(any(), any())).thenReturn(either);
- when(propertyOperation.isPropertyTypeValid(anyObject())).thenReturn(true);
+ when(attributeOperation.isAttributeTypeValid(any())).thenReturn(true);
Map<String, DataTypeDefinition> data = new HashMap<>();
data.put("ONE", new DataTypeDefinition());
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
- when(propertyOperation.isPropertyDefaultValueValid(anyObject(), anyObject())).thenReturn(true);
+ when(attributeOperation.isAttributeDefaultValueValid(any(), any())).thenReturn(true);
Either<AttributeDataDefinition, ResponseFormat> response;
response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
- Assert.assertEquals(true, response.isLeft());
-
+ assertTrue(response.isLeft());
}
@Test
- public void createAttribute_failtogettoscaelement() throws Exception {
-
+ public void createAttribute_failtogettoscaelement() throws NoSuchFieldException, IllegalAccessException {
Component resource= new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setIsDeleted(false);
@@ -231,19 +159,16 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("toscaOperationFacade");
baseBusinessLogic.setAccessible(true);
baseBusinessLogic.set(attributeBusinessLogic, toscaOperationFacade);
- //Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY);
Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.GENERAL_ERROR);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
- Assert.assertEquals(true,response.isRight());
-
+ assertTrue(response.isRight());
}
@Test
- public void createAttribute_componentvalidationfails() throws Exception {
-
+ public void createAttribute_componentvalidationfails() {
Component resource= new Resource();
resource.setLifecycleState(LifecycleStateEnum.CERTIFIED);
resource.setIsDeleted(false);
@@ -254,47 +179,42 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
Either<AttributeDataDefinition, ResponseFormat> response;
AttributeDataDefinition prop= new AttributeDataDefinition();
- //Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY);
Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
- Assert.assertEquals(true,response.isRight());
-
+ assertTrue(response.isRight());
}
@Test
- public void createAttribute_componentalreadyexist_fails() throws Exception {
-
+ public void createAttribute_componentalreadyexist_fails() {
Either<AttributeDataDefinition, ResponseFormat> response;
AttributeDefinition attrib = new AttributeDefinition();
attrib.setName("RES01");
- attrib.setParentUniqueId("RES01");
+ attrib.setOwnerId("RES01");
List<AttributeDataDefinition> attributes = new ArrayList<>();
attributes.add(attrib);
- Component resource = new Resource();
+ final Resource resource = new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setIsDeleted(false);
resource.setLastUpdaterUserId("USR01");
- ((Resource) resource).setAttributes(attributes);
+ resource.setAttributes(attributes);
when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- //Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY);
Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
- Assert.assertEquals(true, response.isRight());
-
+ assertTrue(response.isRight());
}
@Test
- public void createAttribute_addresourcetostoragefails() throws Exception {
+ public void createAttribute_addresourcetostoragefails() {
Component resource = new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
@@ -304,33 +224,32 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class);
when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- //Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY);
Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
AttributeDataDefinition attributeDataDefinition = new AttributeDataDefinition();
Either<AttributeDataDefinition, StorageOperationStatus> either = Either
.right(StorageOperationStatus.CONNECTION_FAILURE);
- when(toscaOperationFacade.addAttributeOfResource(anyObject(), anyObject())).thenReturn(either);
+ when(toscaOperationFacade.addAttributeOfResource(any(),any())).thenReturn(either);
- when(propertyOperation.isPropertyTypeValid(anyObject())).thenReturn(true);
+ when(attributeOperation.isAttributeTypeValid(any())).thenReturn(true);
Map<String, DataTypeDefinition> data = new HashMap<>();
data.put("ONE", new DataTypeDefinition());
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
- when(propertyOperation.isPropertyDefaultValueValid(anyObject(), anyObject())).thenReturn(true);
+ when(attributeOperation.isAttributeDefaultValueValid(any(),any())).thenReturn(true);
Either<AttributeDataDefinition, ResponseFormat> response;
AttributeDataDefinition attrib = new AttributeDefinition();
response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
- Assert.assertEquals(true, response.isRight());
+ assertTrue( response.isRight());
}
@Test
- public void testgetAttribute_ATTRIBUTE_NOT_FOUND() throws Exception {
+ public void testgetAttribute_ATTRIBUTE_NOT_FOUND() {
Either<AttributeDataDefinition, ResponseFormat> result;
Component resource= new Resource();
@@ -341,88 +260,79 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
result=attributeBusinessLogic.getAttribute("RES01","ATTR01", "USR01");
- Assert.assertEquals(true,result.isRight());
+ assertTrue(result.isRight());
}
@Test
- public void testgetAttribute_success() throws Exception {
+ public void testgetAttribute_success() {
Either<AttributeDataDefinition, ResponseFormat> result;
- Component resource = new Resource();
+ final Resource resource = new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setIsDeleted(false);
resource.setLastUpdaterUserId("USR01");
AttributeDefinition attrib = new AttributeDefinition();
attrib.setUniqueId("ATTR01");
- attrib.setParentUniqueId("RES01");
+ attrib.setOwnerId("RES01");
List<AttributeDataDefinition> attr = new ArrayList<>();
attr.add(attrib);
- ((Resource) resource).setAttributes(attr);
+ resource.setAttributes(attr);
Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
result = attributeBusinessLogic.getAttribute("RES01", "ATTR01", "USR01");
- Assert.assertEquals(true, result.isLeft());
+ assertTrue( result.isLeft());
}
@Test
- public void testgetAttribute_RESOURCE_NOT_FOUND() throws Exception {
+ public void testgetAttribute_RESOURCE_NOT_FOUND() {
Either<AttributeDataDefinition, ResponseFormat> result;
Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.PARENT_RESOURCE_NOT_FOUND);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
result=attributeBusinessLogic.getAttribute("RES01","ATTR01", "USR01");
- Assert.assertEquals(true,result.isRight());
+ assertTrue(result.isRight());
}
@Test
- public void testdeleteAttribute_FAILED_TO_LOCK_COMPONENT() throws Exception {
+ public void testdeleteAttribute_FAILED_TO_LOCK_COMPONENT() {
Either<AttributeDataDefinition, ResponseFormat> result;
result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01");
- Assert.assertEquals(true,result.isRight());
+ assertTrue(result.isRight());
}
@Test
- public void testdeleteAttribute_get_RESOURCE_from_DB_failed() throws Exception {
+ public void testdeleteAttribute_get_RESOURCE_from_DB_failed() {
Either<AttributeDataDefinition, ResponseFormat> result;
Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.CONNECTION_FAILURE);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01");
- Assert.assertEquals(true,result.isRight());
+ assertTrue(result.isRight());
}
@Test
- public void testdeleteAttribute_get_RESOURCE_verification_failed() throws Exception {
+ public void testdeleteAttribute_get_RESOURCE_verification_failed() {
Either<AttributeDataDefinition, ResponseFormat> result;
-
-
Component resource= new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setIsDeleted(true);
resource.setLastUpdaterUserId("USR01");
-
-
when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
-
-
-
-
Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
-
result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01");
- Assert.assertEquals(true,result.isRight());
+ assertTrue(result.isRight());
}
@Test
- public void testdeleteAttribute_nonexistingresource() throws Exception {
+ public void testdeleteAttribute_nonexistingresource() {
Either<AttributeDataDefinition, ResponseFormat> result;
@@ -437,15 +347,13 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01");
- Assert.assertEquals(true,result.isRight());
+ assertTrue(result.isRight());
}
@Test
- public void testdeleteAttribute_success() throws Exception {
+ public void testdeleteAttribute_success() {
Either<AttributeDataDefinition, ResponseFormat> result;
-
-
- Component resource= new Resource();
+ final Resource resource = new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setIsDeleted(false);
resource.setLastUpdaterUserId("USR01");
@@ -458,13 +366,13 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
AttributeDefinition attrib = new AttributeDefinition();
attrib.setUniqueId("ATTR01");
- attrib.setParentUniqueId("RES01");
+ attrib.setOwnerId("RES01");
List<AttributeDataDefinition> attributes = new ArrayList<>();
attributes.add(attrib);
- ((Resource) resource).setAttributes(attributes);
+ resource.setAttributes(attributes);
result = attributeBusinessLogic.deleteAttribute("RES01", "ATTR01", "USR01");
- Assert.assertEquals(true, result.isLeft());
+ assertTrue( result.isLeft());
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
index 3783c5e1fd..87875d8f20 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
@@ -20,12 +20,27 @@
package org.openecomp.sdc.be.components.impl;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import com.google.common.collect.Lists;
import fj.data.Either;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import org.junit.Test;
import org.mockito.Mockito;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.model.AttributeDefinition;
@@ -33,28 +48,12 @@ import org.openecomp.sdc.be.model.HeatParameterDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.model.operations.impl.AnnotationTypeOperations;
import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint;
import org.openecomp.sdc.be.utils.TypeUtils;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.yaml.snakeyaml.Yaml;
-import java.io.IOException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
public class ImportUtilsTest {
@@ -304,17 +303,6 @@ public class ImportUtilsTest {
}
@Test
- public void testGetAttributesFromYml() throws IOException {
-
- Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaWithAttribute.yml");
- Either<Map<String, AttributeDataDefinition>, ResultStatusEnum> actualAttributes = ImportUtils.getAttributes(toscaJson);
- assertTrue(actualAttributes.isLeft());
- Map<String, Map<String, Object>> expectedAttributes = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.ATTRIBUTES);
- compareAttributes(expectedAttributes, actualAttributes.left().value());
-
- }
-
- @Test
public void testGetPropertiesFromYml() throws IOException {
Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaProperties.yml");
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java
index a353ae9033..20ad0ad01f 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.be.model;
import lombok.Getter;
-import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.onap.sdc.tosca.datatypes.model.EntrySchema;
@@ -31,7 +30,7 @@ import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
@ToString
public class AttributeDefinition extends AttributeDataDefinition implements IOperationParameter, IComplexDefaultValue {
- // All names are according to TOSCA spec from
+ // All names are according to TOSCA spec from
// https://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.3/os/TOSCA-Simple-Profile-YAML-v1.3-os.html#DEFN_ELEMENT_ATTRIBUTE_DEFN
private String type;
private String description;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java
index 91a7b9c14f..6583bf46c4 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java
@@ -24,7 +24,6 @@ import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
@Getter
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
index a3d871a511..6f120dc4ca 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
@@ -28,15 +28,12 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.utils.MapUtil;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
@Getter
@Setter
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java
index 004451c667..43b74870e9 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java
@@ -21,6 +21,17 @@
package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
@@ -28,7 +39,13 @@ import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
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.datatypes.elements.*;
+import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
@@ -46,10 +63,6 @@ import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
-import java.util.*;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
@org.springframework.stereotype.Component("node-type-operation")
public class NodeTypeOperation extends ToscaElementOperation {
public static final Pattern uuidNewVersion = Pattern.compile("^\\d+.1");
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java
index 6798af42db..bc77d20ed5 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java
@@ -22,9 +22,20 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
import static org.openecomp.sdc.be.utils.TypeUtils.setField;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import fj.data.Either;
import java.lang.reflect.Type;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
@@ -33,6 +44,7 @@ import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.janusgraph.core.JanusGraphVertex;
+import org.onap.sdc.tosca.datatypes.model.EntrySchema;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -52,7 +64,6 @@ import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -75,11 +86,6 @@ import org.openecomp.sdc.common.util.ValidationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StopWatch;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-
-import fj.data.Either;
-
public abstract class ToscaElementOperation extends BaseOperation {
private static final String FAILED_TO_FETCH_FOR_TOSCA_ELEMENT_WITH_ID_ERROR = "failed to fetch {} for tosca element with id {}, error {}";
@@ -1003,15 +1009,21 @@ public abstract class ToscaElementOperation extends BaseOperation {
if (attributes instanceof Map) {
final Map<String, Object> map = (Map<String, Object>) attributes;
attributeDataDefinitionMap.putAll(map.values().stream().map(attributeMap -> {
- final AttributeDefinition attributeDef = new AttributeDefinition();
+ final AttributeDataDefinition attributeDef = new AttributeDataDefinition();
final String name = (String) ((Map<String, Object>) attributeMap).get("name");
attributeDef.setName(name);
final String type = (String) ((Map<String, Object>) attributeMap).get("type");
attributeDef.setType(type);
final String description = (String) ((Map<String, Object>) attributeMap).get("description");
attributeDef.setDescription(description);
+ final Object _default = ((Map<String, Object>) attributeMap).get("_default");
+ attributeDef.set_default(_default);
+ final String status = (String) ((Map<String, Object>) attributeMap).get("status");
+ attributeDef.setStatus(status);
+ final EntrySchema entry_schema = (EntrySchema) ((Map<String, Object>) attributeMap).get("entry_schema");
+ attributeDef.setEntry_schema(entry_schema);
return attributeDef;
- }).collect(Collectors.toMap(AttributeDefinition::getName, a -> a)));
+ }).collect(Collectors.toMap(AttributeDataDefinition::getName, a -> a)));
}
}
return attributeDataDefinitionMap;
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 50b2ae45b4..957c5f9d66 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
@@ -20,7 +20,27 @@
package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
+import static java.util.Objects.requireNonNull;
+import static org.apache.commons.collections.CollectionUtils.isEmpty;
+import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.BiPredicate;
+import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
@@ -29,21 +49,61 @@ import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.model.jsonjanusgraph.config.ContainerInstanceTypesData;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.HealingJanusGraphDao;
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.datatypes.elements.*;
-import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.*;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+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.ListCapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
+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.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.PromoteVersionEnum;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CatalogUpdateTimestamp;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceInterface;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+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.GroupInstance;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.PolicyDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RelationshipInfo;
+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.User;
import org.openecomp.sdc.be.model.catalog.CatalogComponent;
+import org.openecomp.sdc.be.model.jsonjanusgraph.config.ContainerInstanceTypesData;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
@@ -59,15 +119,6 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.function.BiPredicate;
-import java.util.stream.Collectors;
-
-import static java.util.Objects.requireNonNull;
-import static org.apache.commons.collections.CollectionUtils.isEmpty;
-import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
-
@org.springframework.stereotype.Component("tosca-operation-facade")
public class ToscaOperationFacade {
@@ -1592,7 +1643,8 @@ public class ToscaOperationFacade {
for (Entry<String, List<AttributeDataDefinition>> entry : instArttributes.entrySet()) {
final List<AttributeDataDefinition> value = entry.getValue();
attributesMap = new MapAttributesDataDefinition();
- attributesMap.setMapToscaDataDefinition(value.stream().map(AttributeDataDefinition::new).collect(Collectors.toMap(AttributeDataDefinition::getName, e -> e)));
+ attributesMap.setMapToscaDataDefinition(value.stream().map(AttributeDataDefinition::new)
+ .collect(Collectors.toMap(AttributeDataDefinition::getName, e -> e)));
instAttr.put(entry.getKey(), attributesMap);
}
}
@@ -2492,6 +2544,7 @@ public class ToscaOperationFacade {
if (newAttributeDef.getUniqueId() == null || newAttributeDef.getUniqueId().isEmpty()) {
String attUniqueId = UniqueIdBuilder.buildAttributeUid(component.getUniqueId(), newAttributeDef.getName());
newAttributeDef.setUniqueId(attUniqueId);
+ newAttributeDef.setOwnerId(component.getUniqueId());
}
StorageOperationStatus status = getToscaElementOperation(component).addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef, JsonPresentationFields.NAME);
@@ -2509,7 +2562,8 @@ public class ToscaOperationFacade {
}
}
if (result == null) {
- Optional<AttributeDataDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
+ Optional<AttributeDataDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value())
+ .getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
if (newAttribute.isPresent()) {
result = Either.left(newAttribute.get());
} else {
@@ -2539,7 +2593,8 @@ public class ToscaOperationFacade {
}
}
if (result == null) {
- Optional<AttributeDataDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
+ Optional<AttributeDataDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value())
+ .getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
if (newProperty.isPresent()) {
result = Either.left(newProperty.get());
} else {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java
index 427ad4314a..a51eb33c03 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java
@@ -7,9 +7,9 @@
* 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.
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
new file mode 100644
index 0000000000..0bbaa0ecb2
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java
@@ -0,0 +1,392 @@
+/*
+ * ============LICENSE_START=======================================================
+ * SDC
+ * Copyright (C) 2020 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 com.google.gson.JsonElement;
+import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
+import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
+import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
+import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
+import org.openecomp.sdc.be.resources.data.DataTypeData;
+import org.openecomp.sdc.be.resources.data.PropertyData;
+import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
+import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+@Component("attribute-operation")
+public class AttributeOperation extends AbstractOperation {
+
+ private static Logger log = Logger.getLogger(AttributeOperation.class.getName());
+
+ private static final String FAILED_TO_FETCH_ATTRIBUTES_OF_DATA_TYPE = "Failed to fetch attributes of data type {}";
+ private static final String DATA_TYPE_CANNOT_BE_FOUND_IN_GRAPH_STATUS_IS = "Data type {} cannot be found in graph. status is {}";
+ private static final String THE_VALUE_OF_ATTRIBUTE_FROM_TYPE_IS_INVALID = "The value {} of attribute from type {} is invalid";
+
+
+ @Autowired
+ public AttributeOperation(HealingJanusGraphGenericDao janusGraphGenericDao) {
+ this.janusGraphGenericDao = janusGraphGenericDao;
+ }
+
+ public boolean isAttributeTypeValid(final AttributeDataDefinition attributeDefinition) {
+
+ if (attributeDefinition == null) {
+ return false;
+ }
+
+ if (ToscaPropertyType.isValidType(attributeDefinition.getType()) == null) {
+ final Either<Boolean, JanusGraphOperationStatus> definedInDataTypes = isDefinedInDataTypes(
+ attributeDefinition.getType());
+
+ if (definedInDataTypes.isRight()) {
+ return false;
+ } else {
+ Boolean isExist = definedInDataTypes.left().value();
+ return isExist.booleanValue();
+ }
+
+ }
+ return true;
+ }
+
+ public Either<Boolean, JanusGraphOperationStatus> isDefinedInDataTypes(final String propertyType) {
+
+ final String dataTypeUid = UniqueIdBuilder.buildDataTypeUid(propertyType);
+ final Either<DataTypeDefinition, JanusGraphOperationStatus> dataTypeByUid = getDataTypeByUid(dataTypeUid);
+ if (dataTypeByUid.isRight()) {
+ final JanusGraphOperationStatus status = dataTypeByUid.right().value();
+ if (status == JanusGraphOperationStatus.NOT_FOUND) {
+ return Either.left(false);
+ }
+ return Either.right(status);
+ }
+
+ return Either.left(true);
+
+ }
+
+ /**
+ * Build Data type object from graph by unique id
+ */
+ public Either<DataTypeDefinition, JanusGraphOperationStatus> getDataTypeByUid(final String uniqueId) {
+
+ final Either<DataTypeData, JanusGraphOperationStatus> dataTypesRes = janusGraphGenericDao
+ .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.DataType), uniqueId, DataTypeData.class);
+
+ if (dataTypesRes.isRight()) {
+ JanusGraphOperationStatus status = dataTypesRes.right().value();
+ log.debug(DATA_TYPE_CANNOT_BE_FOUND_IN_GRAPH_STATUS_IS, uniqueId, status);
+ return Either.right(status);
+ }
+
+ final DataTypeData ctData = dataTypesRes.left().value();
+ final DataTypeDefinition dataTypeDefinition = new DataTypeDefinition(ctData.getDataTypeDataDefinition());
+
+ final JanusGraphOperationStatus propertiesStatus = fillProperties(uniqueId, dataTypeDefinition);
+ if (propertiesStatus != JanusGraphOperationStatus.OK) {
+ log.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, FAILED_TO_FETCH_ATTRIBUTES_OF_DATA_TYPE, uniqueId);
+ 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);
+ 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);
+ return Either.right(janusGraphOperationStatus);
+ }
+ } else {
+ // derived from node was found
+ final ImmutablePair<DataTypeData, GraphEdge> immutablePair = parentNode.left().value();
+ final DataTypeData parentCT = immutablePair.getKey();
+
+ final String parentUniqueId = parentCT.getUniqueId();
+ final Either<DataTypeDefinition, JanusGraphOperationStatus> dataTypeByUid = getDataTypeByUid(
+ parentUniqueId);
+
+ if (dataTypeByUid.isRight()) {
+ return Either.right(dataTypeByUid.right().value());
+ }
+
+ final DataTypeDefinition parentDataTypeDefinition = dataTypeByUid.left().value();
+
+ dataTypeDefinition.setDerivedFrom(parentDataTypeDefinition);
+ }
+
+ return Either.left(dataTypeDefinition);
+ }
+
+ private JanusGraphOperationStatus fillProperties(final String uniqueId,
+ final DataTypeDefinition dataTypeDefinition) {
+
+ final Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> findPropertiesOfNode = this
+ .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);
+ if (JanusGraphOperationStatus.NOT_FOUND.equals(janusGraphOperationStatus)) {
+ return JanusGraphOperationStatus.OK;
+ } else {
+ return janusGraphOperationStatus;
+ }
+ } else {
+ final Map<String, PropertyDefinition> properties = findPropertiesOfNode.left().value();
+ if (properties != null && !properties.isEmpty()) {
+ List<PropertyDefinition> listOfProps = new ArrayList<>();
+
+ for (final Entry<String, PropertyDefinition> entry : properties.entrySet()) {
+ final String propName = entry.getKey();
+ final PropertyDefinition propertyDefinition = entry.getValue();
+ final PropertyDefinition newPropertyDefinition = new PropertyDefinition(propertyDefinition);
+ newPropertyDefinition.setName(propName);
+ listOfProps.add(newPropertyDefinition);
+ }
+ dataTypeDefinition.setProperties(listOfProps);
+ }
+ return JanusGraphOperationStatus.OK;
+ }
+ }
+
+ public Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> findPropertiesOfNode(
+ final NodeTypeEnum nodeType, 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);
+
+ if (childrenNodes.isRight()) {
+ final JanusGraphOperationStatus operationStatus = childrenNodes.right().value();
+ return Either.right(operationStatus);
+ }
+
+ final List<ImmutablePair<PropertyData, GraphEdge>> values = childrenNodes.left().value();
+ if (values != null) {
+ for (final ImmutablePair<PropertyData, GraphEdge> immutablePair : values) {
+ final GraphEdge edge = immutablePair.getValue();
+ final String propertyName = (String) edge.getProperties().get(GraphPropertiesDictionary.NAME.getProperty());
+ log.debug("Attribute {} is associated to node {}", propertyName, uniqueId);
+ final PropertyData propertyData = immutablePair.getKey();
+ final PropertyDefinition propertyDefinition = this
+ .convertPropertyDataToPropertyDefinition(propertyData, propertyName);
+ resourceProps.put(propertyName, propertyDefinition);
+ }
+
+ }
+
+ log.debug("The properties associated to node {} are {}", uniqueId, resourceProps);
+ return Either.left(resourceProps);
+ }
+
+ public PropertyDefinition convertPropertyDataToPropertyDefinition(final PropertyData propertyDataResult,
+ final String propertyName) {
+ log.debug("The object returned after create property is {}", propertyDataResult);
+
+ final PropertyDefinition propertyDefResult = new PropertyDefinition(propertyDataResult.getPropertyDataDefinition());
+ propertyDefResult.setConstraints(convertConstraints(propertyDataResult.getConstraints()));
+ propertyDefResult.setName(propertyName);
+
+ return propertyDefResult;
+ }
+
+
+ public ImmutablePair<String, Boolean> isAttributeInnerTypeValid(final AttributeDataDefinition attributeDefinition,
+ final Map<String, DataTypeDefinition> dataTypes) {
+
+ if (attributeDefinition == null) {
+ return new ImmutablePair<>(null, false);
+ }
+
+ SchemaDefinition schema;
+ PropertyDataDefinition innerProp;
+ String innerType = null;
+ if ((schema = attributeDefinition.getSchema()) != null && ((innerProp = schema.getProperty()) != null)) {
+ innerType = innerProp.getType();
+ }
+
+ final ToscaPropertyType innerToscaType = ToscaPropertyType.isValidType(innerType);
+
+ if (innerToscaType == null) {
+ final DataTypeDefinition dataTypeDefinition = dataTypes.get(innerType);
+ if (dataTypeDefinition == null) {
+ log.debug("The inner type {} is not a data type.", innerType);
+ return new ImmutablePair<>(innerType, false);
+ } else {
+ log.debug("The inner type {} is a data type. Data type definition is {}", innerType,
+ dataTypeDefinition);
+ }
+ }
+ return new ImmutablePair<>(innerType, true);
+ }
+
+
+ public boolean isAttributeDefaultValueValid(final AttributeDataDefinition attributeDefinition,
+ final Map<String, DataTypeDefinition> dataTypes) {
+ if (attributeDefinition == null) {
+ return false;
+ }
+ boolean isValid;
+ String innerType = null;
+ final String propertyType = attributeDefinition.getType();
+ final ToscaPropertyType type = getType(propertyType);
+ if (type == ToscaPropertyType.LIST || type == ToscaPropertyType.MAP) {
+ final SchemaDefinition def = attributeDefinition.getSchema();
+ if (def == null) {
+ return false;
+ }
+ final PropertyDataDefinition propDef = def.getProperty();
+ if (propDef == null) {
+ return false;
+ }
+ innerType = propDef.getType();
+ }
+ final String value = (String) attributeDefinition.get_default();
+ if (type != null) {
+ isValid = isValidValue(type, value, innerType, dataTypes);
+ } else {
+ log.trace("The given type {} is not a pre defined one.", propertyType);
+
+ final DataTypeDefinition foundDt = dataTypes.get(propertyType);
+ if (foundDt != null) {
+ isValid = isValidComplexValue(foundDt, value, dataTypes);
+ } else {
+ isValid = false;
+ }
+ }
+ return isValid;
+ }
+
+ private boolean isValidComplexValue(final DataTypeDefinition foundDt, final String value,
+ final Map<String, DataTypeDefinition> dataTypes) {
+ final ImmutablePair<JsonElement, Boolean> validateAndUpdate = dataTypeValidatorConverter
+ .validateAndUpdate(value, foundDt, dataTypes);
+
+ log.trace("The result after validating complex value of type {} is {}", foundDt.getName(), validateAndUpdate);
+
+ return validateAndUpdate.right.booleanValue();
+
+ }
+
+
+ public StorageOperationStatus validateAndUpdateAttribute(final AttributeDataDefinition attributeDefinition,
+ final Map<String, DataTypeDefinition> dataTypes) {
+
+ log.trace("Going to validate attribute type and value. {}", attributeDefinition);
+
+ final String attributeDefinitionType = attributeDefinition.getType();
+ final String value = (String) attributeDefinition.get_default();
+
+ final ToscaPropertyType type = getType(attributeDefinitionType);
+
+ if (type == null) {
+
+ final DataTypeDefinition dataTypeDefinition = dataTypes.get(attributeDefinitionType);
+ if (dataTypeDefinition == null) {
+ log.debug("The type {} of attribute cannot be found.", attributeDefinitionType);
+ return StorageOperationStatus.INVALID_TYPE;
+ }
+
+ return validateAndUpdateAttributeComplexValue(attributeDefinition, attributeDefinitionType, value,
+ dataTypeDefinition, dataTypes);
+
+ }
+ String innerType;
+
+ final Either<String, JanusGraphOperationStatus> checkInnerType = getInnerType(type, attributeDefinition::getSchema);
+ if (checkInnerType.isRight()) {
+ return StorageOperationStatus.INVALID_TYPE;
+ }
+ innerType = checkInnerType.left().value();
+
+ log.trace("After validating property type {}", attributeDefinitionType);
+
+ if (!isValidValue(type, value, innerType, dataTypes)) {
+ log.info(THE_VALUE_OF_ATTRIBUTE_FROM_TYPE_IS_INVALID, value, type);
+ return StorageOperationStatus.INVALID_VALUE;
+ }
+
+ final PropertyValueConverter converter = type.getConverter();
+
+ if (isEmptyValue(value)) {
+ log.debug("Default value was not sent for attribute {}. Set default value to {}",
+ attributeDefinition.getName(), EMPTY_VALUE);
+ attributeDefinition.set_default(EMPTY_VALUE);
+ } else if (!isEmptyValue(value)) {
+ attributeDefinition.set_default(converter.convert(value, innerType, dataTypes));
+ }
+ return StorageOperationStatus.OK;
+ }
+
+ private StorageOperationStatus validateAndUpdateAttributeComplexValue(
+ final AttributeDataDefinition attributeDefinition,
+ final String attributeType,
+ final String value,
+ final DataTypeDefinition dataTypeDefinition,
+ final Map<String, DataTypeDefinition> dataTypes) {
+
+ final ImmutablePair<JsonElement, Boolean> validateResult = dataTypeValidatorConverter
+ .validateAndUpdate(value, dataTypeDefinition, dataTypes);
+ if (!validateResult.right.booleanValue()) {
+ log.debug(THE_VALUE_OF_ATTRIBUTE_FROM_TYPE_IS_INVALID, attributeType, attributeType);
+ return StorageOperationStatus.INVALID_VALUE;
+ }
+ final JsonElement jsonElement = validateResult.left;
+ if (log.isTraceEnabled()) {
+ log.trace("Going to update value in attribute definition {} {}", attributeDefinition.getName(),
+ (jsonElement != null ? jsonElement.toString() : null));
+ }
+ updateAttributeValue(attributeDefinition, jsonElement);
+ return StorageOperationStatus.OK;
+ }
+
+ private void updateAttributeValue(final AttributeDataDefinition attributeDefinition,
+ final JsonElement jsonElement) {
+ attributeDefinition.set_default(jsonElement);
+ }
+}
diff --git a/catalog-ui/src/app/models/attributes.ts b/catalog-ui/src/app/models/attributes.ts
index 80af540ef3..a51358cdc4 100644
--- a/catalog-ui/src/app/models/attributes.ts
+++ b/catalog-ui/src/app/models/attributes.ts
@@ -41,13 +41,12 @@ export interface IAttributeModel {
//server data
uniqueId:string;
name:string;
- defaultValue:string;
+ _default:string;
description:string;
type:string;
schema:SchemaAttributeGroupModel;
status:string;
value:string;
- hidden:boolean;
parentUniqueId:string;
//custom data
resourceInstanceUniqueId:string;
@@ -60,13 +59,12 @@ export class AttributeModel implements IAttributeModel {
//server data
uniqueId:string;
name:string;
- defaultValue:string;
+ _default:string;
description:string;
type:string;
schema:SchemaAttributeGroupModel;
status:string;
value:string;
- hidden:boolean;
parentUniqueId:string;
//custom data
resourceInstanceUniqueId:string;
@@ -77,20 +75,18 @@ export class AttributeModel implements IAttributeModel {
if (attribute) {
this.uniqueId = attribute.uniqueId;
this.name = attribute.name;
- this.defaultValue = attribute.defaultValue;
+ this._default = attribute._default;
this.description = attribute.description;
this.type = attribute.type;
this.status = attribute.status;
this.schema = attribute.schema;
this.value = attribute.value;
- this.hidden = attribute.hidden;
this.parentUniqueId = attribute.parentUniqueId;
this.resourceInstanceUniqueId = attribute.resourceInstanceUniqueId;
this.readonly = attribute.readonly;
this.valueUniqueUid = attribute.valueUniqueUid;
} else {
- this.defaultValue = '';
- this.hidden = false;
+ this._default = '';
}
if (!this.schema || !this.schema.property) {
@@ -104,13 +100,13 @@ export class AttributeModel implements IAttributeModel {
}
public convertToServerObject():string {
- if (this.defaultValue && this.type === 'map') {
- this.defaultValue = '{' + this.defaultValue + '}';
+ if (this._default && this.type === 'map') {
+ this._default = '{' + this._default + '}';
}
- if (this.defaultValue && this.type === 'list') {
- this.defaultValue = '[' + this.defaultValue + ']';
+ if (this._default && this.type === 'list') {
+ this._default = '[' + this._default + ']';
}
- this.defaultValue = this.defaultValue != "" && this.defaultValue != "[]" && this.defaultValue != "{}" ? this.defaultValue : null;
+ this._default = this._default != "" && this._default != "[]" && this._default != "{}" ? this._default : null;
return JSON.stringify(this);
};
@@ -118,10 +114,10 @@ export class AttributeModel implements IAttributeModel {
public convertValueToView() {
//unwrapping value {} or [] if type is complex
- if (this.defaultValue && (this.type === 'map' || this.type === 'list') &&
- ['[', '{'].indexOf(this.defaultValue.charAt(0)) > -1 &&
- [']', '}'].indexOf(this.defaultValue.slice(-1)) > -1) {
- this.defaultValue = this.defaultValue.slice(1, -1);
+ if (this._default && (this.type === 'map' || this.type === 'list') &&
+ ['[', '{'].indexOf(this._default.charAt(0)) > -1 &&
+ [']', '}'].indexOf(this._default.slice(-1)) > -1) {
+ this._default = this._default.slice(1, -1);
}
//also for value - for the modal in canvas
diff --git a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html
index bd30a469e0..094045e8b4 100644
--- a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html
+++ b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.html
@@ -48,19 +48,19 @@
<!-- ATTRIBUTE DEFAULT VALUE TEXT - OPTIONAL -->
<div *ngIf="attributeToEdit.type != 'boolean'">
<sdc-input
- #defaultValue
+ #_default
[required]="false"
label="Default Value"
- [(value)]="attributeToEdit.defaultValue"
+ [(value)]="attributeToEdit._default"
[disabled]="false"
- name="defaultValue"
+ name="_default"
testId="defaultValue"
[maxLength]="255"
(valueChange)="defaultValueChanged()">
</sdc-input>
- <sdc-validation [validateElement]="defaultValue" (validityChanged)="onValidityChange($event, 'defaultValue')">
- <sdc-regex-validator *ngIf="this.attributeToEdit.defaultValue && this.attributeToEdit.defaultValue.length > 0" message="{{ this.defaultValueErrorMessage }}"
+ <sdc-validation [validateElement]="_default" (validityChanged)="onValidityChange($event, 'default')">
+ <sdc-regex-validator *ngIf="this.attributeToEdit._default && this.attributeToEdit._default.length > 0" message="{{ this.defaultValueErrorMessage }}"
[pattern]="defaultValuePattern"></sdc-regex-validator>
<sdc-custom-validator *ngIf="this.attributeToEdit.type == 'map' && this.attributeToEdit.schema.property.type" message="{{ 'PROPERTY_EDIT_MAP_UNIQUE_KEYS' | translate }}"
[callback]="isMapUnique" [disabled]="false"></sdc-custom-validator>
@@ -71,7 +71,7 @@
<div *ngIf="attributeToEdit.type == 'boolean'">
<sdc-dropdown [disabled]="false" label="Default Value"
[required]="false"
- [selectedOption]="toDropDownOption(this.attributeToEdit.defaultValue)" placeHolder="Choose Default Value"
+ [selectedOption]="toDropDownOption(this.attributeToEdit._default)" placeHolder="Choose Default Value"
[options]="booleanValues" (changed)="onBooleanDefaultValueSelected($event)">
</sdc-dropdown>
@@ -88,17 +88,7 @@
</sdc-validation>
</sdc-dropdown>
</div>
-
- <!-- ATTRIBUTE HIDDEN - OPTIONAL -->
- <sdc-checkbox
- label="Hidden"
- [checked]="attributeToEdit.hidden"
- [disabled]="false"
- testId="hidden"
- (checkedChange)="this.onHiddenCheckboxClicked($event)"
- >
- </sdc-checkbox>
</div>
</div>
-</form> \ No newline at end of file
+</form>
diff --git a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts
index c703869ad2..b0a7651809 100644
--- a/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts
+++ b/catalog-ui/src/app/ng2/pages/workspace/attributes/attribute-modal.component.ts
@@ -15,7 +15,7 @@ import { AttributeOptions } from './attributes-options';
})
export class AttributeModalComponent implements OnInit {
- @ViewChild('defaultValue') validatedInput: InputComponent;
+ @ViewChild('_default') validatedInput: InputComponent;
public readonly types = AttributeOptions.types; // integer, string, boolean etc.
@@ -44,13 +44,9 @@ export class AttributeModalComponent implements OnInit {
this.revalidateDefaultValue();
}
- onHiddenCheckboxClicked(event: boolean) {
- this.attributeToEdit.hidden = event;
- }
-
onTypeSelected(selectedElement: IDropDownOption) {
if (this.attributeToEdit.type !== selectedElement.value && selectedElement.value === 'boolean') {
- this.attributeToEdit.defaultValue = ''; // Clean old value in case we choose change type to boolean
+ this.attributeToEdit._default = ''; // Clean old value in case we choose change type to boolean
}
this.attributeToEdit.type = selectedElement.value;
this.revalidateDefaultValue();
@@ -58,7 +54,7 @@ export class AttributeModalComponent implements OnInit {
onBooleanDefaultValueSelected(selectedElement: IDropDownOption) {
if (this.attributeToEdit.type === 'boolean') {
- this.attributeToEdit.defaultValue = selectedElement.value;
+ this.attributeToEdit._default = selectedElement.value;
}
}
@@ -92,8 +88,8 @@ export class AttributeModalComponent implements OnInit {
}
public isMapUnique = () => {
- if (this.attributeToEdit && this.attributeToEdit.type === 'map' && this.attributeToEdit.defaultValue) {
- return ValidationUtils.validateUniqueKeys(this.attributeToEdit.defaultValue);
+ if (this.attributeToEdit && this.attributeToEdit.type === 'map' && this.attributeToEdit._default) {
+ return ValidationUtils.validateUniqueKeys(this.attributeToEdit._default);
}
return true;
}
@@ -102,7 +98,7 @@ export class AttributeModalComponent implements OnInit {
this.setDefaultValuePattern(this.attributeToEdit.type);
setTimeout(() => {
if (this.validatedInput) {
- this.validatedInput.onKeyPress(this.attributeToEdit.defaultValue);
+ this.validatedInput.onKeyPress(this.attributeToEdit._default);
} }, 250);
}
diff --git a/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes-modal.component.spec.ts b/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes-modal.component.spec.ts
index 99aa140dd1..2eed2311bb 100644
--- a/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes-modal.component.spec.ts
+++ b/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes-modal.component.spec.ts
@@ -56,28 +56,18 @@ describe('attributes modal component', () => {
})
);
- it('test that when hidden is clicked, hidden attribute is set', async () => {
- fixture.componentInstance.attributeToEdit = new AttributeModel();
- const hidden = fixture.componentInstance.attributeToEdit.hidden;
- fixture.componentInstance.ngOnInit();
-
- expect(hidden).toBe(false);
- fixture.componentInstance.onHiddenCheckboxClicked(true);
- expect(fixture.componentInstance.attributeToEdit.hidden).toBe(true);
- });
-
it('test that when type is set to boolean default value is cleared', async () => {
const component = fixture.componentInstance;
component.attributeToEdit = new AttributeModel();
component.ngOnInit();
component.onTypeSelected({ value : 'string', label : 'string'});
- component.attributeToEdit.defaultValue = 'some_value';
+ component.attributeToEdit._default = 'some_value';
component.onTypeSelected({ value : 'boolean', label : 'boolean'});
- expect(component.attributeToEdit.defaultValue).toBe('');
+ expect(component.attributeToEdit._default).toBe('');
component.onBooleanDefaultValueSelected({ value : 'true', label : 'true'});
- expect(component.attributeToEdit.defaultValue).toBe('true');
+ expect(component.attributeToEdit._default).toBe('true');
});
it('test that when certain type is selected, the correct regex pattern is chosen', async () => {
@@ -120,9 +110,9 @@ describe('attributes modal component', () => {
expect(component.isMapUnique()).toBe(true); // map is not selected so return true by default
component.onTypeSelected({ value : 'map', label : 'map'});
component.onEntrySchemaTypeSelected({ value : 'boolean', label : 'boolean' });
- component.attributeToEdit.defaultValue = '"1":true,"2":false';
+ component.attributeToEdit._default = '"1":true,"2":false';
expect(component.isMapUnique()).toBe(true);
- component.attributeToEdit.defaultValue = '"1":true,"1":false';
+ component.attributeToEdit._default = '"1":true,"1":false';
expect(component.isMapUnique()).toBe(false);
});
});
diff --git a/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes.component.html b/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes.component.html
index 00a7a5cec0..6d50bbe11b 100644
--- a/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes.component.html
+++ b/catalog-ui/src/app/ng2/pages/workspace/attributes/attributes.component.html
@@ -66,7 +66,7 @@
<ngx-datatable-column [resizeable]="false" name="Default Value" [flexGrow]="3">
<ng-template ngx-datatable-cell-template let-row="row">
- {{row.defaultValue}}
+ {{row._default}}
</ng-template>
</ngx-datatable-column>
@@ -90,4 +90,4 @@
</ngx-datatable-column>
</ngx-datatable>
-</div> \ No newline at end of file
+</div>
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java
index b619c66ee0..27bd6635fb 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java
@@ -19,34 +19,98 @@
*/
package org.openecomp.sdc.be.datatypes.elements;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
+import java.io.Serializable;
+import org.onap.sdc.tosca.datatypes.model.EntrySchema;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-@Getter
-@Setter
-@NoArgsConstructor
-public class AttributeDataDefinition extends ToscaDataDefinition{
+public class AttributeDataDefinition extends ToscaDataDefinition implements Serializable {
- private String uniqueId;
- private String name;
- private SchemaDefinition schema;
- private String value;
+ public AttributeDataDefinition() {
+ }
public AttributeDataDefinition(final AttributeDataDefinition attributeDataDefinition) {
super();
this.setUniqueId(attributeDataDefinition.getUniqueId());
+ this.setOwnerId(attributeDataDefinition.getOwnerId());
this.setName(attributeDataDefinition.getName());
+ this.setType(attributeDataDefinition.getType());
+ this.setDescription(attributeDataDefinition.getDescription());
+ this.set_default(attributeDataDefinition.get_default());
+ this.setStatus(attributeDataDefinition.getStatus());
+ this.setEntry_schema(attributeDataDefinition.getEntry_schema());
this.setSchema(attributeDataDefinition.getSchema());
- this.setValue(attributeDataDefinition.getValue());
}
- public String getParentUniqueId() {
- return getOwnerId();
+ public String getUniqueId() {
+ return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
+ }
+
+ public void setUniqueId(String uniqueId) {
+ setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
+ }
+
+ @Override
+ public String getOwnerId() {
+ return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_ID);
+ }
+
+ @Override
+ public void setOwnerId(String ownerId) {
+ setToscaPresentationValue(JsonPresentationFields.OWNER_ID, ownerId);
+ }
+
+ public String getName() {
+ return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
+ }
+
+ public void setName(String name) {
+ setToscaPresentationValue(JsonPresentationFields.NAME, name);
+ }
+
+ @Override
+ public String getType() {
+ return (String) getToscaPresentationValue(JsonPresentationFields.TYPE);
+ }
+
+ public void setType(String type) {
+ setToscaPresentationValue(JsonPresentationFields.TYPE, type);
+ }
+
+ public String getDescription() {
+ return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
+ }
+
+ public void setDescription(String description) {
+ setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
+ }
+
+ public Object get_default() {
+ return getToscaPresentationValue(JsonPresentationFields.DEFAULT);
+ }
+
+ public void set_default(Object _default) {
+ setToscaPresentationValue(JsonPresentationFields.DEFAULT, _default);
+ }
+
+ public String getStatus() {
+ return (String) getToscaPresentationValue(JsonPresentationFields.STATUS);
+ }
+
+ public void setStatus(String status) {
+ setToscaPresentationValue(JsonPresentationFields.STATUS, status);
+ }
+
+ public EntrySchema getEntry_schema() {
+ return (EntrySchema) getToscaPresentationValue(JsonPresentationFields.SCHEMA);
+ }
+
+ public void setEntry_schema(EntrySchema entrySchema) {
+ setToscaPresentationValue(JsonPresentationFields.SCHEMA, entrySchema);
}
- public void setParentUniqueId(final String parentUniqueId) {
- setOwnerId(parentUniqueId);
+ public SchemaDefinition getSchema() {
+ return (SchemaDefinition) getToscaPresentationValue(JsonPresentationFields.SCHEMA);
}
+
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/EntrySchemaDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/EntrySchemaDataDefinition.java
new file mode 100644
index 0000000000..36e3452e53
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/EntrySchemaDataDefinition.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.be.datatypes.elements;
+
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.onap.sdc.tosca.datatypes.model.Constraint;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class EntrySchemaDataDefinition extends ToscaDataDefinition {
+
+ private String description;
+ private String type;
+ private List<Constraint> constraints;
+
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
index 41c04e77b2..76697a7223 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
@@ -108,6 +108,7 @@ public enum JsonPresentationFields {
//property
DEFINITION("definition", null),
DEFAULT_VALUE("defaultValue", null),
+ DEFAULT("default", null),
REQUIRED("required", null),
PASSWORD("password", null),
CONSTRAINTS("constraints", null),
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 66c64bd05f..a1b14b70ca 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
@@ -45,7 +45,9 @@ public class TypeUtils {
public enum ToscaTagNamesEnum {
DERIVED_FROM("derived_from"), IS_PASSWORD("is_password"),
// Properties
- PROPERTIES("properties"), TYPE("type"), STATUS("status"), ENTRY_SCHEMA("entry_schema"), REQUIRED("required"), DESCRIPTION("description"), DEFAULT_VALUE("default"), VALUE("value"), CONSTRAINTS("constraints"),
+ PROPERTIES("properties"), TYPE("type"), STATUS("status"),
+ ENTRY_SCHEMA("entry_schema"), REQUIRED("required"), DESCRIPTION("description"),
+ DEFAULT_VALUE("default"), VALUE("value"), CONSTRAINTS("constraints"),
// Group Types
MEMBERS("members"), METADATA("metadata"),
// Policy Types
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java
index 1b72cbc030..9dfbc39880 100644
--- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java
+++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,34 +20,48 @@
package org.onap.sdc.tosca.datatypes.model;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
+import org.apache.commons.lang3.StringUtils;
@Getter
@Setter
public class AttributeDefinition implements Cloneable {
- private String type;
- private String description;
- private Object _default;
- private String status;
- private EntrySchema entry_schema;
+ private String type;
+ private String description;
+ @JsonProperty("default")
+ private Object _default;
+ private String status;
+ private EntrySchema entry_schema;
- public AttributeDefinition() {
- status = Status.SUPPORTED.getName();
- }
+ public AttributeDefinition() {
+ status = Status.SUPPORTED.getName();
+ }
+ public AttributeDefinition(final String type,
+ final String description,
+ final Object _default,
+ final String status,
+ final EntrySchema entry_schema) {
+ this.setType(type);
+ this.setDescription(description);
+ this.set_default(_default);
+ this.setStatus(StringUtils.isEmpty(status) ? Status.SUPPORTED.getName() : status);
+ this.setEntry_schema(entry_schema);
+ }
- @Override
- public AttributeDefinition clone() {
- AttributeDefinition attributeDefinition = new AttributeDefinition();
- attributeDefinition.setType(this.getType());
- attributeDefinition.setDescription(this.getDescription());
- attributeDefinition.set_default(this.get_default());
- attributeDefinition.setStatus(this.getStatus());
- attributeDefinition.setEntry_schema(
- Objects.isNull(this.getEntry_schema()) ? null : this.getEntry_schema().clone());
- return attributeDefinition;
- }
+ @Override
+ public AttributeDefinition clone() {
+ AttributeDefinition attributeDefinition = new AttributeDefinition();
+ attributeDefinition.setType(this.getType());
+ attributeDefinition.setDescription(this.getDescription());
+ attributeDefinition.set_default(this.get_default());
+ attributeDefinition.setStatus(this.getStatus());
+ attributeDefinition.setEntry_schema(
+ Objects.isNull(this.getEntry_schema()) ? null : this.getEntry_schema().clone());
+ return attributeDefinition;
+ }
}
diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
index 00abcea757..1cea0c49e1 100644
--- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
+++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
@@ -71,7 +71,7 @@ public class ComponentInstanceAttributeTest extends ComponentBaseTest {
() -> (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER));
ComponentInstanceAttribute attributeOfRI = attributeGetter.apply(vfWithInsatncePreUpdate);
final String newAttValue = "NewValue";
- attributeOfRI.setValue(newAttValue);
+ attributeOfRI.set_default(newAttValue);
String body = gson.toJson(attributeOfRI);
String url = String.format(Urls.UPDATE_ATTRIBUTE_ON_RESOURCE_INSTANCE, config.getCatalogBeHost(),
config.getCatalogBePort(), ComponentTypeEnum.findParamByType(ComponentTypeEnum.RESOURCE),
@@ -82,7 +82,7 @@ public class ComponentInstanceAttributeTest extends ComponentBaseTest {
final Resource vfWithInsatncePostUpdate = swallowException(
() -> (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER));
ComponentInstanceAttribute updatedAttribute = attributeGetter.apply(vfWithInsatncePostUpdate);
- assertEquals(updatedAttribute.getValue(), newAttValue);
+ assertEquals(updatedAttribute.get_default(), newAttValue);
}
}