aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2023-03-23 11:52:27 +0000
committerJEFF VAN DAM <jeff.van.dam@est.tech>2023-03-31 10:28:19 +0000
commit3dff1c221e58de6a81cf6bbdfb84fdf97665e484 (patch)
treed670bd19a3721a59547f057e19109aa424191b88
parent94176d70ee48b1703981cd8786c306f7c055e15d (diff)
Support to change substitution mapping node or version after service creation
Before changing check for service property usage in sub mapping node change Issue-ID: SDC-4439 Issue-ID: SDC-4430 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: Ia0f24c626ac836f0b4e7ffbe0004e7ab30089b25
-rw-r--r--asdctool/src/main/resources/config/error-configuration.yaml8
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java13
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java175
-rw-r--r--catalog-be/src/main/resources/config/error-configuration.yaml8
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java322
-rw-r--r--catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html4
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionType.java5
13 files changed, 444 insertions, 116 deletions
diff --git a/asdctool/src/main/resources/config/error-configuration.yaml b/asdctool/src/main/resources/config/error-configuration.yaml
index 4246e0def5..4742241744 100644
--- a/asdctool/src/main/resources/config/error-configuration.yaml
+++ b/asdctool/src/main/resources/config/error-configuration.yaml
@@ -2860,4 +2860,12 @@ errors:
code: 400,
message: "Cannot change this properties constraints as the resource is an instance.",
messageId: "SVC4015"
+ }
+
+ #---------SVC4017-----------------------------
+ # %1 - Map of component instance and properties
+ SUBSTITUTION_NODE_TYPE_PROPERTY_IN_USE: {
+ code: 409,
+ message: "Cannot change substitution node type as properties of the existing type are referenced by properties %1.",
+ messageId: "SVC4017"
} \ No newline at end of file
diff --git a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
index ba2e58d6b8..05926151ba 100644
--- a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
+++ b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
@@ -2877,4 +2877,12 @@ errors:
code: 400,
message: "Input name '%1' already exist.",
messageId: "SVC4016"
- } \ No newline at end of file
+ }
+
+ #---------SVC4017-----------------------------
+ # %1 - Map of component instance and properties
+ SUBSTITUTION_NODE_TYPE_PROPERTY_IN_USE: {
+ code: 409,
+ message: "Cannot change substitution node type as properties of the existing type are referenced by properties %1.",
+ messageId: "SVC4017"
+ }
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 1b28435dd8..28d105904b 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
@@ -720,16 +720,21 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
}
protected <T extends Component> Resource fetchAndSetDerivedFromGenericType(final T component, final String toscaType) {
+ final Resource genericTypeResource = fetchDerivedFromGenericType(component, toscaType);
+ component.setDerivedFromGenericInfo(genericTypeResource);
+ return genericTypeResource;
+ }
+
+ protected <T extends Component> Resource fetchDerivedFromGenericType(final T component, final String toscaType) {
final Either<Resource, ResponseFormat> genericTypeEither = this.genericTypeBusinessLogic.fetchDerivedFromGenericType(component, toscaType);
if (genericTypeEither.isRight()) {
- log.debug("Failed to fetch latest generic type for component {} of type", component.getName(), component.assetType());
+ log.debug("Failed to fetch latest generic type for component {} of type {}", component.getName(), component.assetType());
throw new ByActionStatusComponentException(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType());
}
- final Resource genericTypeResource = genericTypeEither.left().value();
- component.setDerivedFromGenericInfo(genericTypeResource);
- return genericTypeResource;
+ return genericTypeEither.left().value();
}
+
public Either<Map<String, List<IComponentInstanceConnectedElement>>, ResponseFormat> getFilteredComponentInstanceProperties(String componentId,
Map<FilterKeyEnum, List<String>> filters,
String userId) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index 9b095cc062..a9014b4b21 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -19,6 +19,7 @@
* Modifications copyright (c) 2019 Nokia
* ================================================================================
*/
+
package org.openecomp.sdc.be.components.impl;
import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
@@ -97,6 +98,10 @@ import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunction;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionType;
+import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
@@ -189,7 +194,6 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
private final ServiceInstantiationTypeValidator serviceInstantiationTypeValidator;
private final ServiceCategoryValidator serviceCategoryValidator;
private final ServiceValidator serviceValidator;
- private final PolicyBusinessLogic policyBusinessLogic;
private final GroupBusinessLogic groupBusinessLogic;
private ForwardingPathOperation forwardingPathOperation;
private AuditCassandraDao auditCassandraDao;
@@ -209,8 +213,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
ComponentDescriptionValidator componentDescriptionValidator, ModelOperation modelOperation,
final ServiceRoleValidator serviceRoleValidator,
final ServiceInstantiationTypeValidator serviceInstantiationTypeValidator,
- final ServiceCategoryValidator serviceCategoryValidator, final ServiceValidator serviceValidator,
- final PolicyBusinessLogic policyBusinessLogic) {
+ final ServiceCategoryValidator serviceCategoryValidator, final ServiceValidator serviceValidator) {
super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic, interfaceOperation,
interfaceLifecycleTypeOperation, artifactsBusinessLogic, artifactToscaOperation, componentContactIdValidator, componentNameValidator,
componentTagsValidator, componentValidator, componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator);
@@ -224,7 +227,6 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
this.serviceInstantiationTypeValidator = serviceInstantiationTypeValidator;
this.serviceCategoryValidator = serviceCategoryValidator;
this.serviceValidator = serviceValidator;
- this.policyBusinessLogic = policyBusinessLogic;
this.groupBusinessLogic = groupBusinessLogic;
}
@@ -849,21 +851,42 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
log.info("Restricted operation for user: {}, on service: {}", user.getUserId(), currentService.getCreatorUserId());
return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
}
- Either<Service, ResponseFormat> validationRsponse = validateAndUpdateServiceMetadata(user, currentService, serviceUpdate);
- if (validationRsponse.isRight()) {
+ List<String> subNodePropsToBeRemoved = getSubstitutionNodePropertiesToBeRemoved(currentService, serviceUpdate);
+ List<PropertyDefinition> subNodePropsToBeAdded = getSubstitutionNodePropertiesToBeAdded(currentService, serviceUpdate);
+ boolean subNodeChanged = isSubstitutionNodeChanged(currentService, serviceUpdate);
+ Either<Service, ResponseFormat> validationResponse =
+ validateAndUpdateServiceMetadata(user, currentService, serviceUpdate, subNodeChanged, ListUtils.emptyIfNull(subNodePropsToBeRemoved));
+ if (validationResponse.isRight()) {
log.info("service update metadata: validations field.");
- return validationRsponse;
+ return validationResponse;
}
- Service serviceToUpdate = validationRsponse.left().value();
+ Service serviceToUpdate = validationResponse.left().value();
// lock resource
lockComponent(serviceId, currentService, "Update Service Metadata");
try {
+ if (subNodeChanged) {
+ if (!subNodePropsToBeRemoved.isEmpty()) {
+ removePropertiesFromService(currentService, subNodePropsToBeRemoved);
+ removeInputsFromService(currentService, subNodePropsToBeRemoved);
+ }
+ if (!subNodePropsToBeAdded.isEmpty()) {
+ addPropertiesToService(currentService, subNodePropsToBeAdded);
+ if (Constants.DEFAULT_MODEL_NAME.equals(currentService.getModel()) || currentService.getModel() == null) {
+ addInputsToService(currentService, subNodePropsToBeAdded);
+ }
+ }
+ }
return toscaOperationFacade.updateToscaElement(serviceToUpdate).right().map(rf -> {
janusGraphDao.rollback();
BeEcompErrorManager.getInstance().logBeSystemError("Update Service Metadata");
log.debug("failed to update sevice {}", serviceToUpdate.getUniqueId());
return (componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
}).left().bind(this::updateCatalogAndCommit);
+ } catch (ComponentException e) {
+ janusGraphDao.rollback();
+ BeEcompErrorManager.getInstance().logBeSystemError("Update Service Metadata");
+ log.debug("failed to update sevice {}", serviceToUpdate.getUniqueId());
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
} finally {
graphLockOperation.unlockComponent(serviceId, NodeTypeEnum.Service);
}
@@ -1034,9 +1057,18 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
@VisibleForTesting
- Either<Service, ResponseFormat> validateAndUpdateServiceMetadata(User user, Service currentService, Service serviceUpdate) {
+ Either<Service, ResponseFormat> validateAndUpdateServiceMetadata(User user, Service currentService, Service serviceUpdate, boolean subNodeChanged,
+ List<String> subNodePropsToBeRemoved) {
try {
boolean hasBeenCertified = ValidationUtils.hasBeenCertified(currentService.getVersion());
+ if (subNodeChanged) {
+ if (!subNodePropsToBeRemoved.isEmpty()) {
+ areSubstitutionNodePropertiesInUse(currentService, subNodePropsToBeRemoved);
+ }
+ currentService.setDerivedFromGenericVersion(serviceUpdate.getDerivedFromGenericVersion());
+ currentService.setDerivedFromGenericType(serviceUpdate.getDerivedFromGenericType());
+ }
+
Either<Boolean, ResponseFormat> response = validateAndUpdateCategory(user, currentService, serviceUpdate, hasBeenCertified,
UPDATE_SERVICE_METADATA);
if (response.isRight()) {
@@ -1103,6 +1135,131 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
}
+ private void addPropertiesToService(Service currentService, List<PropertyDefinition> subNodePropsToBeAdded) {
+ ListUtils.emptyIfNull(subNodePropsToBeAdded).forEach(prop -> {
+ Either<PropertyDefinition, StorageOperationStatus> addPropertyEither =
+ toscaOperationFacade.addPropertyToComponent(prop, currentService);
+ if (addPropertyEither.isRight()) {
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
+ }
+ });
+ }
+
+ private void addInputsToService(Service currentService, List<PropertyDefinition> subNodePropsToBeAdded) {
+ ListUtils.emptyIfNull(subNodePropsToBeAdded).forEach(prop -> {
+ InputDefinition inputDef = new InputDefinition(prop);
+ Either<InputDefinition, StorageOperationStatus> status =
+ toscaOperationFacade.addInputToComponent(prop.getName(), inputDef, currentService);
+ if (status.isRight()) {
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
+ }
+ });
+ }
+
+ private void removePropertiesFromService(Service currentService, List<String> subNodePropsToBeRemoved) {
+ List<PropertyDefinition> props = currentService.getProperties();
+ List<String> propsUniqueIdsToBeRemoved =
+ props.stream().filter(prop -> subNodePropsToBeRemoved.contains(prop.getName())).map(PropertyDefinition::getUniqueId)
+ .collect(Collectors.toList());
+ ListUtils.emptyIfNull(props).stream().filter(prop -> propsUniqueIdsToBeRemoved.contains(prop.getUniqueId())).forEach(prop -> {
+ StorageOperationStatus status = toscaOperationFacade.deletePropertyOfComponent(currentService, prop.getName());
+ if (status != StorageOperationStatus.OK) {
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
+ }
+ });
+ }
+
+ private void removeInputsFromService(Service currentService, List<String> subNodePropsToBeRemoved) {
+ List<PropertyDefinition> props = currentService.getProperties();
+ List<InputDefinition> inputs = currentService.getInputs();
+ List<String> propsUniqueIdsToBeRemoved =
+ props.stream().filter(prop -> subNodePropsToBeRemoved.contains(prop.getName())).map(PropertyDefinition::getUniqueId)
+ .collect(Collectors.toList());
+ ListUtils.emptyIfNull(inputs).stream().filter(input -> input.isMappedToComponentProperty() &&
+ (propsUniqueIdsToBeRemoved.contains(input.getPropertyId()) || subNodePropsToBeRemoved.contains(input.getName()))).forEach(input -> {
+ StorageOperationStatus status = toscaOperationFacade.deleteInputOfResource(currentService, input.getName());
+ if (status != StorageOperationStatus.OK) {
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
+ }
+ });
+ }
+
+ private void areSubstitutionNodePropertiesInUse(Service service, List<String> subNodePropsToBeRemoved) {
+ Map<String, List<ComponentInstanceProperty>> componentInstancesProps = service.getComponentInstancesProperties();
+ List<String> propsUniqueIdsToBeRemoved =
+ ListUtils.emptyIfNull(service.getProperties()).stream().filter(prop -> subNodePropsToBeRemoved.contains(prop.getName()))
+ .map(PropertyDefinition::getUniqueId)
+ .collect(Collectors.toList());
+ List<String> inputsUniqueIdsToBeRemoved = ListUtils.emptyIfNull(service.getInputs()).stream()
+ .filter(input -> propsUniqueIdsToBeRemoved.contains(input.getPropertyId()) || subNodePropsToBeRemoved.contains(input.getName()))
+ .map(PropertyDefinition::getUniqueId)
+ .collect(Collectors.toList());
+ Map<String, List<String>> inUse = new HashMap<>();
+ if (componentInstancesProps != null && !componentInstancesProps.isEmpty()) {
+ componentInstancesProps.forEach((compInstanceId, listOfProps) -> {
+ List<String> propsInUse = new ArrayList<>();
+ listOfProps.stream()
+ .filter(PropertyDataDefinition::isToscaFunction)
+ .filter(compProp -> ToscaFunctionType.isGetFunction(compProp.getToscaFunction().getType()))
+ .forEach(compProp -> {
+ ToscaFunction toscaFunction = compProp.getToscaFunction();
+ ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) toscaFunction;
+ String propName = toscaGetFunction.getPropertyName();
+ String propUniqueId = toscaGetFunction.getPropertyUniqueId();
+ if (inputsUniqueIdsToBeRemoved.contains(propUniqueId) || propsUniqueIdsToBeRemoved.contains(propUniqueId) ||
+ subNodePropsToBeRemoved.contains(propName)) {
+ propsInUse.add(compProp.getName());
+ }
+ });
+ if (!propsInUse.isEmpty()) {
+ Optional<ComponentInstance> componentInstance = service.getComponentInstanceById(compInstanceId);
+ componentInstance.ifPresent(instance -> inUse.put(instance.getName(), propsInUse));
+ }
+
+ });
+ }
+ if (!inUse.isEmpty()) {
+ String propsInUse = inUse.entrySet().stream().map(entry -> {
+ String properties = entry.getValue().stream().map(Object::toString).collect(Collectors.joining(", "));
+ return properties + " on " + entry.getKey();
+ }).collect(Collectors.joining(", properties "));
+ throw new ByActionStatusComponentException(ActionStatus.SUBSTITUTION_NODE_TYPE_PROPERTY_IN_USE, propsInUse);
+ }
+ }
+
+
+ private boolean isSubstitutionNodeChanged(Service currentService, Service updatedService) {
+ String currentServiceType = currentService.getDerivedFromGenericType();
+ String updatedServiceType = updatedService.getDerivedFromGenericType();
+ String currentServiceVersion = currentService.getDerivedFromGenericVersion();
+ String updatedServiceVersion = updatedService.getDerivedFromGenericVersion();
+ return !(StringUtils.equals(currentServiceType, updatedServiceType) && StringUtils.equals(currentServiceVersion, updatedServiceVersion));
+ }
+
+ private List<String> getSubstitutionNodePropertiesToBeRemoved(Service currentService, Service serviceUpdate) {
+ List<PropertyDefinition> currentProps = ListUtils.emptyIfNull(fetchDerivedFromGenericType(currentService, null).getProperties());
+ List<PropertyDefinition> updatedProps = ListUtils.emptyIfNull(fetchDerivedFromGenericType(serviceUpdate, null).getProperties());
+ if (!StringUtils.equals(currentService.getDerivedFromGenericType(), serviceUpdate.getDerivedFromGenericType())) {
+ return currentProps.stream().map(PropertyDefinition::getName).collect(Collectors.toList());
+ }
+ List<String> updatedPropNames = updatedProps.stream().map(PropertyDefinition::getName).collect(Collectors.toList());
+ List<String> propNamesToBeRemoved = currentProps.stream().map(PropertyDefinition::getName).collect(Collectors.toList());
+ propNamesToBeRemoved.removeIf(updatedPropNames::contains);
+ return propNamesToBeRemoved;
+ }
+
+ private List<PropertyDefinition> getSubstitutionNodePropertiesToBeAdded(Service currentService, Service serviceUpdate) {
+ List<PropertyDefinition> currentProps = ListUtils.emptyIfNull(fetchDerivedFromGenericType(currentService, null).getProperties());
+ List<PropertyDefinition> updatedProps = ListUtils.emptyIfNull(fetchDerivedFromGenericType(serviceUpdate, null).getProperties());
+ if (!StringUtils.equals(currentService.getDerivedFromGenericType(), serviceUpdate.getDerivedFromGenericType())) {
+ return updatedProps;
+ }
+ Set<String> currentPropNames = currentProps.stream().map(PropertyDefinition::getName).collect(Collectors.toSet());
+ updatedProps.removeIf(prop -> currentPropNames.contains(prop.getName()));
+ return updatedProps;
+ }
+
+
private void verifyValuesAreIdentical(Object updatedValue, Object originalValue, String fieldName) {
if (updatedValue != null && !updatedValue.equals(originalValue)) {
log.info("update service: received request to update {} to {} the field is not updatable ignoring.", fieldName, updatedValue);
diff --git a/catalog-be/src/main/resources/config/error-configuration.yaml b/catalog-be/src/main/resources/config/error-configuration.yaml
index 56dd54c5e4..a4b56d530c 100644
--- a/catalog-be/src/main/resources/config/error-configuration.yaml
+++ b/catalog-be/src/main/resources/config/error-configuration.yaml
@@ -2869,4 +2869,12 @@ errors:
code: 400,
message: "Cannot change this properties constraints as the resource is an instance.",
messageId: "SVC4015"
+ }
+
+ #---------SVC4017-----------------------------
+ # %1 - Map of component instance and properties
+ SUBSTITUTION_NODE_TYPE_PROPERTY_IN_USE: {
+ code: 409,
+ message: "Cannot change substitution node type as properties of the existing type are referenced by properties %1.",
+ messageId: "SVC4017"
} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java
index 638eef6898..c3fc69895b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java
@@ -187,7 +187,7 @@ public abstract class BaseServiceBusinessLogicTest extends ComponentBusinessLogi
serviceDistributionValidation, forwardingPathValidator, uiComponentDataConverter,
artifactToscaOperation, componentContactIdValidator, componentNameValidator,
componentTagsValidator, componentValidator, componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator,
- modelOperation, null, null, null, null, null);
+ modelOperation, null, null, null, null);
bl.setUserAdmin(mockUserAdmin);
bl.setGraphLockOperation(graphLockOperation);
bl.setJanusGraphDao(mockJanusGraphDao);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java
index 602a3bb4ce..e2d4e0ee78 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java
@@ -77,7 +77,7 @@ class ServiceDistributionBLTest extends ComponentBusinessLogicMock {
artifactToscaOperation, componentContactIdValidator,
componentNameValidator, componentTagsValidator, componentValidator, componentIconValidator,
componentProjectCodeValidator, componentDescriptionValidator, modelOperation, null, null,
- null, null, null);
+ null, null);
private Service serviceToActivate;
private ActivationRequestInformation activationRequestInformation;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java
index 049f8a5541..cc6f676618 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java
@@ -204,7 +204,7 @@ class ServiceBusinessLogicBaseTestSetup extends BaseBusinessLogicMock {
interfaceLifecycleTypeOperation, artifactBl, distributionEngine, componentInstanceBusinessLogic, serviceDistributionValidation,
forwardingPathValidator, uiComponentDataConverter, artifactToscaOperation, componentContactIdValidator, componentNameValidator,
componentTagsValidator, componentValidator, componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator,
- modelOperation, serviceRoleValidator, serviceInstantiationTypeValidator, serviceCategoryValidator, serviceValidator, null);
+ modelOperation, serviceRoleValidator, serviceInstantiationTypeValidator, serviceCategoryValidator, serviceValidator);
bl.setComponentContactIdValidator(componentContactIdValidator);
bl.setComponentIconValidator(componentIconValidator);
bl.setComponentTagsValidator(componentTagsValidator);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
index a5f823b12f..416703637f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
@@ -26,12 +26,11 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.when;
@@ -42,13 +41,12 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.UUID;
import java.util.Set;
-import java.util.HashSet;
-
+import java.util.UUID;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.hamcrest.MatcherAssert;
import org.junit.Assert;
@@ -59,13 +57,17 @@ import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceInterface;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.GroupInstance;
+import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.Model;
import org.openecomp.sdc.be.model.Operation;
import org.openecomp.sdc.be.model.PropertyDefinition;
@@ -94,14 +96,16 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
@Test
void testGetComponentAuditRecordsCertifiedVersion() {
- Either<List<Map<String, Object>>, ResponseFormat> componentAuditRecords = bl.getComponentAuditRecords(CERTIFIED_VERSION, COMPONNET_ID, user.getUserId());
+ Either<List<Map<String, Object>>, ResponseFormat> componentAuditRecords =
+ bl.getComponentAuditRecords(CERTIFIED_VERSION, COMPONNET_ID, user.getUserId());
assertTrue(componentAuditRecords.isLeft());
assertEquals(3, componentAuditRecords.left().value().size());
}
@Test
void testGetComponentAuditRecordsUnCertifiedVersion() {
- Either<List<Map<String, Object>>, ResponseFormat> componentAuditRecords = bl.getComponentAuditRecords(UNCERTIFIED_VERSION, COMPONNET_ID, user.getUserId());
+ Either<List<Map<String, Object>>, ResponseFormat> componentAuditRecords =
+ bl.getComponentAuditRecords(UNCERTIFIED_VERSION, COMPONNET_ID, user.getUserId());
assertTrue(componentAuditRecords.isLeft());
assertEquals(4, componentAuditRecords.left().value().size());
}
@@ -224,6 +228,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
}
assertEqualsServiceObject(createServiceObject(true), createResponse.left().value());
}
+
private void assertEqualsServiceObject(final Service expectedService, final Service actualService) {
assertEquals(expectedService.getContactId(), actualService.getContactId());
assertEquals(expectedService.getCategories(), actualService.getCategories());
@@ -304,9 +309,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
private void testServiceNameEmpty() {
Service serviceExccedsNameLimit = createServiceObject(false);
serviceExccedsNameLimit.setName(null);
- try{
+ try {
bl.createService(serviceExccedsNameLimit, user);
- } catch(ComponentException e){
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -318,9 +323,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
// contains :
String nameWrongFormat = "ljg\\fd";
service.setName(nameWrongFormat);
- try{
+ try {
bl.createService(service, user);
- } catch(ComponentException e){
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -333,20 +338,21 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
private void testServiceDescriptionEmpty() {
Service serviceExist = createServiceObject(false);
serviceExist.setDescription("");
- try{
+ try {
bl.createService(serviceExist, user);
- } catch(ComponentException e){
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
return;
}
fail();
}
+
private void testServiceDescriptionMissing() {
Service serviceExist = createServiceObject(false);
serviceExist.setDescription(null);
- try{
+ try {
bl.createService(serviceExist, user);
- } catch(ComponentException e){
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -357,19 +363,23 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Service serviceExccedsDescLimit = createServiceObject(false);
// 1025 chars, the limit is 1024
String tooLongServiceDesc = "1GUODojQ0sGzKR4NP7e5j82ADQ3KHTVOaezL95qcbuaqDtjZhAQGQ3iFwKAy580K4WiiXs3u3zq7RzXcSASl5fm0RsWtCMOIDP"
- + "AOf9Tf2xtXxPCuCIMCR5wOGnNTaFxgnJEHAGxilBhZDgeMNHmCN1rMK5B5IRJOnZxcpcL1NeG3APTCIMP1lNAxngYulDm9heFSBc8TfXAADq7703AvkJT0QPpGq2z2P"
- + "tlikcAnIjmWgfC5Tm7UH462BAlTyHg4ExnPPL4AO8c92VrD7kZSgSqiy73cN3gLT8uigkKrUgXQFGVUFrXVyyQXYtVM6bLBeuCGQf4C2j8lkNg6M0J3PC0PzMRoinOxk"
- + "Ae2teeCtVcIj4A1KQo3210j8q2v7qQU69Mabsa6DT9FgE4rcrbiFWrg0Zto4SXWD3o1eJA9o29lTg6kxtklH3TuZTmpi5KVp1NFhS1RpnqF83tzv4mZLKsx7Zh1fEgYvRFwx1"
- + "ar3RolyDfNoZiGBGTMsZzz7RPFBf2hTnLmNqVGQnHKhhGj0Y5s8t2cbqbO2nmHiJb9uaUVrCGypgbAcJL3KPOBfAVW8PcpmNj4yVjI3L4x5zHjmGZbp9vKshEQODcrmcgsYAoKqe"
- + "uu5u7jk8XVxEfQ0m5qL8UOErXPlJovSmKUmP5B5T0w299zIWDYCzSoNasHpHjOMDLAiDDeHbozUOn9t3Qou00e9POq4RMM0VnIx1H38nJoJZz2XH8CI5YMQe7oTagaxgQTF2aa0qaq2"
- + "V6nJsfRGRklGjNhFFYP2cS4Xv2IJO9DSX6LTXOmENrGVJJvMOZcvnBaZPfoAHN0LU4i1SoepLzulIxnZBfkUWFJgZ5wQ0Bco2GC1HMqzW21rwy4XHRxXpXbmW8LVyoA1KbnmVmROycU4"
- + "scTZ62IxIcIWCVeMjBIcTviXULbPUyqlfEPXWr8IMJtpAaELWgyquPClAREMDs2b9ztKmUeXlMccFES1XWbFTrhBHhmmDyVReEgCwfokrUFR13LTUK1k8I6OEHOs";
+ + "AOf9Tf2xtXxPCuCIMCR5wOGnNTaFxgnJEHAGxilBhZDgeMNHmCN1rMK5B5IRJOnZxcpcL1NeG3APTCIMP1lNAxngYulDm9heFSBc8TfXAADq7703AvkJT0QPpGq2z2P"
+ + "tlikcAnIjmWgfC5Tm7UH462BAlTyHg4ExnPPL4AO8c92VrD7kZSgSqiy73cN3gLT8uigkKrUgXQFGVUFrXVyyQXYtVM6bLBeuCGQf4C2j8lkNg6M0J3PC0PzMRoinOxk"
+ + "Ae2teeCtVcIj4A1KQo3210j8q2v7qQU69Mabsa6DT9FgE4rcrbiFWrg0Zto4SXWD3o1eJA9o29lTg6kxtklH3TuZTmpi5KVp1NFhS1RpnqF83tzv4mZLKsx7Zh1fEgYvRFwx1"
+ +
+ "ar3RolyDfNoZiGBGTMsZzz7RPFBf2hTnLmNqVGQnHKhhGj0Y5s8t2cbqbO2nmHiJb9uaUVrCGypgbAcJL3KPOBfAVW8PcpmNj4yVjI3L4x5zHjmGZbp9vKshEQODcrmcgsYAoKqe"
+ +
+ "uu5u7jk8XVxEfQ0m5qL8UOErXPlJovSmKUmP5B5T0w299zIWDYCzSoNasHpHjOMDLAiDDeHbozUOn9t3Qou00e9POq4RMM0VnIx1H38nJoJZz2XH8CI5YMQe7oTagaxgQTF2aa0qaq2"
+ +
+ "V6nJsfRGRklGjNhFFYP2cS4Xv2IJO9DSX6LTXOmENrGVJJvMOZcvnBaZPfoAHN0LU4i1SoepLzulIxnZBfkUWFJgZ5wQ0Bco2GC1HMqzW21rwy4XHRxXpXbmW8LVyoA1KbnmVmROycU4"
+ + "scTZ62IxIcIWCVeMjBIcTviXULbPUyqlfEPXWr8IMJtpAaELWgyquPClAREMDs2b9ztKmUeXlMccFES1XWbFTrhBHhmmDyVReEgCwfokrUFR13LTUK1k8I6OEHOs";
serviceExccedsDescLimit.setDescription(tooLongServiceDesc);
- try{
+ try {
bl.createService(serviceExccedsDescLimit, user);
- } catch(ComponentException e){
- assertComponentException(e, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, ComponentTypeEnum.SERVICE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
+ } catch (ComponentException e) {
+ assertComponentException(e, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, ComponentTypeEnum.SERVICE.getValue(),
+ "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
return;
}
fail();
@@ -380,9 +390,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
// Not english
String tooLongServiceDesc = "\uC2B5";
notEnglish.setDescription(tooLongServiceDesc);
- try{
+ try {
bl.createService(notEnglish, user);
- } catch(ComponentException e){
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -395,14 +405,15 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
private void testServiceIconEmpty() {
Service serviceExist = createServiceObject(false);
serviceExist.setIcon("");
- Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist,user,AuditingActionEnum.CREATE_SERVICE);
+ Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist, user, AuditingActionEnum.CREATE_SERVICE);
assertThat(service.left().value().getIcon()).isEqualTo(DEFAULT_ICON);
}
+
private void testServiceIconMissing() {
Service serviceExist = createServiceObject(false);
serviceExist.setIcon(null);
- Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist,user,AuditingActionEnum.CREATE_SERVICE);
+ Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist, user, AuditingActionEnum.CREATE_SERVICE);
assertThat(service.left().value().getIcon()).isEqualTo(DEFAULT_ICON);
}
@@ -421,9 +432,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
List<String> tagsList = new ArrayList<>();
tagsList.add(tag1);
serviceExccedsNameLimit.setTags(tagsList);
- try{
+ try {
bl.createService(serviceExccedsNameLimit, user);
- } catch(ComponentException e) {
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME);
return;
}
@@ -436,9 +447,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
List<String> tagsList = new ArrayList<>();
tagsList.add(tag1);
serviceExccedsNameLimit.setTags(tagsList);
- try{
+ try {
bl.createService(serviceExccedsNameLimit, user);
- } catch(ComponentException e) {
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.INVALID_FIELD_FORMAT, "Service", "tag");
return;
}
@@ -469,22 +480,23 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
// 59 chars instead of 50
String contactIdTooLong = "thisNameIsVeryLongAndExeccedsTheNormalLengthForContactId";
serviceContactId.setContactId(contactIdTooLong);
- try{
+ try {
bl.createService(serviceContactId, user);
- } catch(ComponentException e) {
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.SERVICE.getValue());
return;
}
fail();
}
+
private void testContactIdWrongFormatCreate() {
Service serviceContactId = createServiceObject(false);
// 3 letters and 3 digits and special characters
String contactIdTooLong = "yrt134!!!";
serviceContactId.setContactId(contactIdTooLong);
- try{
+ try {
bl.createService(serviceContactId, user);
- } catch(ComponentException e) {
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -494,9 +506,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
private void testResourceContactIdMissing() {
Service resourceExist = createServiceObject(false);
resourceExist.setContactId(null);
- try{
+ try {
bl.createService(resourceExist, user);
- } catch(ComponentException e) {
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_CONTACT, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -509,14 +521,15 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
private void testServiceCategoryExist() {
Service serviceExist = createServiceObject(false);
serviceExist.setCategories(null);
- try{
+ try {
bl.createService(serviceExist, user);
- } catch(ComponentException e) {
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.SERVICE.getValue());
return;
}
fail();
}
+
@Test
void markDistributionAsDeployedTestAlreadyDeployed() {
String notifyAction = "DNotify";
@@ -537,7 +550,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
resultList.add(event);
Either<List<DistributionDeployEvent>, ActionStatus> eventList = Either.left(resultList);
- Mockito.when(auditingDao.getDistributionDeployByStatus(Mockito.anyString(), Mockito.eq(resultAction), Mockito.anyString())).thenReturn(eventList);
+ Mockito.when(auditingDao.getDistributionDeployByStatus(Mockito.anyString(), Mockito.eq(resultAction), Mockito.anyString()))
+ .thenReturn(eventList);
Either<Service, ResponseFormat> markDeployed = bl.markDistributionAsDeployed(did, did, user);
assertTrue(markDeployed.isLeft());
@@ -589,9 +603,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
List<CategoryDefinition> categories = new ArrayList<>();
categories.add(category);
serviceExist.setCategories(categories);
- try{
+ try {
bl.createService(serviceExist, user);
- } catch(ComponentException e) {
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -608,8 +622,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
try {
bl.createService(serviceExist, user);
- } catch(ComponentException exp) {
- assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
+ } catch (ComponentException exp) {
+ assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
return;
}
fail();
@@ -623,7 +637,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
try {
bl.createService(serviceExist, user);
- } catch(ComponentException exp) {
+ } catch (ComponentException exp) {
assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
return;
}
@@ -638,7 +652,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
try {
bl.createService(serviceExist, user);
- } catch(ComponentException exp) {
+ } catch (ComponentException exp) {
assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
return;
}
@@ -695,7 +709,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
void testDeleteArchivedService_DeleteServiceSpecificModel() throws ToscaOperationException {
String serviceId = "12345";
String model = "serviceSpecificModel";
- List<String> deletedServcies= new ArrayList<>();
+ List<String> deletedServcies = new ArrayList<>();
deletedServcies.add("54321");
Model normativeExtensionModel = new Model("normativeExtensionModel", ModelTypeEnum.NORMATIVE_EXTENSION);
Either<Component, StorageOperationStatus> eitherService = Either.left(createNewService());
@@ -708,7 +722,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Mockito.verify(modelOperation, Mockito.times(1)).deleteModel(normativeExtensionModel, false);
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings({"unchecked", "rawtypes"})
@Test
void testFindGroupInstanceOnRelatedComponentInstance() {
@@ -721,7 +735,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat> findGroupInstanceRes;
Object[] argObjects = {service, componentInstances.get(1).getUniqueId(), componentInstances.get(1).getGroupInstances().get(1).getUniqueId()};
- Class[] argClasses = {Component.class, String.class,String.class};
+ Class[] argClasses = {Component.class, String.class, String.class};
try {
Method method = targetClass.getDeclaredMethod(methodName, argClasses);
method.setAccessible(true);
@@ -729,27 +743,26 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjects);
assertNotNull(findGroupInstanceRes);
assertEquals(findGroupInstanceRes.left().value().getKey().getUniqueId(), componentInstances.get(1)
- .getUniqueId());
+ .getUniqueId());
assertEquals(findGroupInstanceRes.left().value().getValue().getUniqueId(), componentInstances.get(1)
- .getGroupInstances()
- .get(1)
- .getUniqueId());
+ .getGroupInstances()
+ .get(1)
+ .getUniqueId());
- Object[] argObjectsInvalidCiId = {service, invalidId , componentInstances.get(1).getGroupInstances().get(1).getUniqueId()};
+ Object[] argObjectsInvalidCiId = {service, invalidId, componentInstances.get(1).getGroupInstances().get(1).getUniqueId()};
- findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjectsInvalidCiId);
+ findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjectsInvalidCiId);
assertNotNull(findGroupInstanceRes);
assertTrue(findGroupInstanceRes.isRight());
assertEquals("SVC4593", findGroupInstanceRes.right().value().getMessageId());
- Object[] argObjectsInvalidGiId = {service, componentInstances.get(1).getUniqueId() , invalidId};
+ Object[] argObjectsInvalidGiId = {service, componentInstances.get(1).getUniqueId(), invalidId};
- findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjectsInvalidGiId);
+ findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjectsInvalidGiId);
assertNotNull(findGroupInstanceRes);
assertTrue(findGroupInstanceRes.isRight());
assertEquals("SVC4653", findGroupInstanceRes.right().value().getMessageId());
- }
- catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -762,15 +775,15 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
service.setUniqueId("serviceUniqueId");
List<ComponentInstance> componentInstances = new ArrayList<>();
ComponentInstance ci;
- for(int i= 0; i<listSize; ++i){
+ for (int i = 0; i < listSize; ++i) {
ci = new ComponentInstance();
ci.setName("ciName" + i);
ci.setUniqueId("ciId" + i);
- List<GroupInstance> groupInstances= new ArrayList<>();
+ List<GroupInstance> groupInstances = new ArrayList<>();
GroupInstance gi;
- for(int j = 0; j<listSize; ++j){
+ for (int j = 0; j < listSize; ++j) {
gi = new GroupInstance();
- gi.setName(ci.getName( )+ "giName" + j);
+ gi.setName(ci.getName() + "giName" + j);
gi.setUniqueId(ci.getName() + "giId" + j);
groupInstances.add(gi);
}
@@ -782,7 +795,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
}
protected Service createNewService() {
- return (Service)createNewComponent();
+ return (Service) createNewComponent();
}
@Test
@@ -817,7 +830,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
currentService.setEcompGeneratedNaming(false);
newService.setEcompGeneratedNaming(true);
newService.setNamingPolicy("policy");
- Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
+ Either<Service, ResponseFormat> resultOfUpdate =
+ bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
Service updatedService = resultOfUpdate.left().value();
assertThat(updatedService.isEcompGeneratedNaming()).isTrue();
@@ -830,7 +844,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Service newService = createServiceObject(false);
currentService.setProjectCode("12345");
newService.setProjectCode("");
- Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
+ Either<Service, ResponseFormat> resultOfUpdate =
+ bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
Service updatedService = resultOfUpdate.left().value();
assertThat(updatedService.getProjectCode()).isEmpty();
@@ -842,7 +857,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Service newService = createServiceObject(false);
currentService.setProjectCode("");
newService.setProjectCode("12345");
- Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
+ Either<Service, ResponseFormat> resultOfUpdate =
+ bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
Service updatedService = resultOfUpdate.left().value();
assertThat(updatedService.getProjectCode()).isEqualTo("12345");
@@ -854,7 +870,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Service newService = createServiceObject(false);
currentService.setProjectCode("33333");
newService.setProjectCode("12345");
- Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
+ Either<Service, ResponseFormat> resultOfUpdate =
+ bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
Service updatedService = resultOfUpdate.left().value();
assertThat(updatedService.getProjectCode()).isEqualTo("12345");
@@ -867,17 +884,18 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
currentService.setServiceType("alice");
//valid English word
newService.setServiceType("bob");
- Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
+ Either<Service, ResponseFormat> resultOfUpdate =
+ bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
Service updatedService = resultOfUpdate.left().value();
assertThat(updatedService.getServiceType()).isEqualToIgnoringCase("bob");
//empty string is invalid
newService.setServiceType("");
- resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
+ resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
//null is invalid
newService.setServiceType(null);
- resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
+ resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isRight()).isTrue();
}
@@ -902,27 +920,28 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
currentService.setServiceFunction("alice");
//valid English word
newService.setServiceFunction("bob");
- Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
+ Either<Service, ResponseFormat> resultOfUpdate =
+ bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
Service updatedService = resultOfUpdate.left().value();
assertThat(updatedService.getServiceFunction()).isEqualToIgnoringCase("bob");
//empty string is valid
newService.setServiceFunction("");
- resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
+ resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
//null is valid and assigner to ""
newService.setServiceFunction(null);
- resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
+ resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService, false, new ArrayList<>());
assertThat(resultOfUpdate.isLeft()).isTrue();
assertThat(updatedService.getServiceFunction()).isEqualTo("");
}
-
@Test
void testServiceFunctionExceedLength() {
String serviceName = "Service";
- String serviceFunction = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+ String serviceFunction =
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
Service serviceFunctionExceedLength = createServiceObject(false);
serviceFunctionExceedLength.setName(serviceName);
serviceFunctionExceedLength.setServiceFunction(serviceFunction);
@@ -937,7 +956,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
}
@Test
- void testServiceFunctionInvalidCharacter(){
+ void testServiceFunctionInvalidCharacter() {
String serviceName = "Service";
String serviceFunction = "a?";
Service serviceFunctionExceedLength = createServiceObject(false);
@@ -958,8 +977,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", "2", "3",
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", "2", "3",
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -970,8 +989,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", "2", "3",
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", "2", "3",
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -985,8 +1004,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
String weirdUniqueServiceInstanceId = UUID.randomUUID().toString();
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", weirdUniqueServiceInstanceId, "3",
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", weirdUniqueServiceInstanceId, "3",
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -999,8 +1018,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", aService.getUniqueId(), "3",
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", aService.getUniqueId(), "3",
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -1013,15 +1032,15 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
Map<String, List<ComponentInstanceInterface>> componentInstancesInterfacesMap =
- Maps.newHashMap();
+ Maps.newHashMap();
componentInstancesInterfacesMap.put(aService.getUniqueId(),
- Lists.newArrayList(new ComponentInstanceInterface("1", new InterfaceInstanceDataDefinition())));
+ Lists.newArrayList(new ComponentInstanceInterface("1", new InterfaceInstanceDataDefinition())));
aService.setComponentInstancesInterfaces(componentInstancesInterfacesMap);
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", aService.getUniqueId(), "3",
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", aService.getUniqueId(), "3",
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -1035,10 +1054,10 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
String operationId = "operationId";
ComponentInstanceInterface componentInstanceInterface =
- new ComponentInstanceInterface("interfaceId", new InterfaceInstanceDataDefinition());
+ new ComponentInstanceInterface("interfaceId", new InterfaceInstanceDataDefinition());
Map<String, Operation> operationsMap = Maps.newHashMap();
operationsMap.put(operationId, new Operation(new ArtifactDataDefinition(), "1",
- new ListDataDefinition<>(), new ListDataDefinition<>()));
+ new ListDataDefinition<>(), new ListDataDefinition<>()));
componentInstanceInterface.setOperationsMap(operationsMap);
Map<String, List<ComponentInstanceInterface>> componentInstancesInterfacesMap = Maps.newHashMap();
@@ -1046,8 +1065,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
aService.setComponentInstancesInterfaces(componentInstancesInterfacesMap);
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", aService.getUniqueId(), operationId,
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", aService.getUniqueId(), operationId,
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -1096,7 +1115,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
@Test
- void testCreateService_withMultitenancyInvalidTenant_Failure() {
+ void testCreateService_withMultitenancyInvalidTenant_Failure() {
Service service = createServiceObject(false);
service.setTenant("invalid_tenant");
when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service, null)).thenReturn(Either.left(genericService));
@@ -1106,7 +1125,116 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
assertEqualsServiceObject(createServiceObject(true), createResponse.left().value());
}
- private Set<String> getTestRoles(){
+ @Test
+ void testUpdateSubstitutionNodeTypeAndVersion() {
+ Service currentService = createServiceObject(true);
+ currentService.setDerivedFromGenericType("genericTypeOne");
+ currentService.setDerivedFromGenericVersion("1.0");
+ Service newService = createServiceObject(false);
+ newService.setDerivedFromGenericType("genericTypeTwo");
+ newService.setDerivedFromGenericVersion("2.0");
+ List<String> subNodePropsToBeRemoved = new ArrayList<>();
+ subNodePropsToBeRemoved.add("testProp");
+ Either<Service, ResponseFormat> resultOfUpdate =
+ bl.validateAndUpdateServiceMetadata(user, currentService, newService, true, subNodePropsToBeRemoved);
+ assertThat(resultOfUpdate.isLeft()).isTrue();
+ Service updatedService = resultOfUpdate.left().value();
+ assertEquals("genericTypeTwo", updatedService.getDerivedFromGenericType());
+ assertEquals("2.0", updatedService.getDerivedFromGenericVersion());
+ }
+
+ @Test
+ void testUpdateSubstitutionNodeTypePropsToRemoveThrowInUseGetProperty() {
+ Service currentService = createServiceObject(true);
+ setComponentInstanceOnServiceWithPropWithToscaFunction(currentService, ToscaGetFunctionType.GET_PROPERTY, "testProp");
+ Service newService = createServiceObject(false);
+ List<String> subNodePropsToBeRemoved = new ArrayList<>();
+ subNodePropsToBeRemoved.add("testProp");
+ Either<Service, ResponseFormat> resultOfUpdate =
+ bl.validateAndUpdateServiceMetadata(user, currentService, newService, true, subNodePropsToBeRemoved);
+ assertThat(resultOfUpdate.isRight()).isTrue();
+ ResponseFormat response = resultOfUpdate.right().value();
+ assertEquals(409, response.getStatus());
+ assertEquals("Cannot change substitution node type as properties of the existing type are referenced by properties %1.", response.getText());
+ }
+
+ @Test
+ void testUpdateSubstitutionNodeTypePropsToRemoveThrowInUseGetAttribute() {
+ Service currentService = createServiceObject(true);
+ setComponentInstanceOnServiceWithPropWithToscaFunction(currentService, ToscaGetFunctionType.GET_ATTRIBUTE, "testProp");
+ Service newService = createServiceObject(false);
+ List<String> subNodePropsToBeRemoved = new ArrayList<>();
+ subNodePropsToBeRemoved.add("testProp");
+ Either<Service, ResponseFormat> resultOfUpdate =
+ bl.validateAndUpdateServiceMetadata(user, currentService, newService, true, subNodePropsToBeRemoved);
+ assertThat(resultOfUpdate.isRight()).isTrue();
+ ResponseFormat response = resultOfUpdate.right().value();
+ assertEquals(409, response.getStatus());
+ assertEquals("Cannot change substitution node type as properties of the existing type are referenced by properties %1.", response.getText());
+ }
+
+ @Test
+ void testUpdateSubstitutionNodeTypePropsToRemoveThrowInUseGetInput() {
+ Service currentService = createServiceObject(true);
+ setComponentInstanceOnServiceWithPropWithToscaFunction(currentService, ToscaGetFunctionType.GET_INPUT, "testProp");
+ Service newService = createServiceObject(false);
+ List<String> subNodePropsToBeRemoved = new ArrayList<>();
+ subNodePropsToBeRemoved.add("testProp");
+ Either<Service, ResponseFormat> resultOfUpdate =
+ bl.validateAndUpdateServiceMetadata(user, currentService, newService, true, subNodePropsToBeRemoved);
+ assertThat(resultOfUpdate.isRight()).isTrue();
+ ResponseFormat response = resultOfUpdate.right().value();
+ assertEquals(409, response.getStatus());
+ assertEquals("Cannot change substitution node type as properties of the existing type are referenced by properties %1.", response.getText());
+ }
+
+ private void setComponentInstanceOnServiceWithPropWithToscaFunction(Service currentService, ToscaGetFunctionType toscaGetFunctionType,
+ String testPropName) {
+ ComponentInstance compInstance = new ComponentInstance();
+ compInstance.setUniqueId("resourceUid");
+
+ List<ComponentInstance> compInstances = new ArrayList<>();
+ compInstances.add(compInstance);
+ currentService.setComponentInstances(compInstances);
+
+ ToscaGetFunctionDataDefinition toscaFunc = new ToscaGetFunctionDataDefinition();
+ toscaFunc.setPropertyName(testPropName);
+ toscaFunc.setPropertyUniqueId(testPropName + "Uid");
+ toscaFunc.setFunctionType(toscaGetFunctionType);
+
+ if (ToscaGetFunctionType.GET_INPUT.equals(toscaGetFunctionType)) {
+ toscaFunc.setPropertyName(testPropName + "Input");
+ toscaFunc.setPropertyUniqueId(testPropName + "InputUid");
+ InputDefinition compInput = new InputDefinition();
+ compInput.setName(testPropName + "Input");
+ compInput.setUniqueId(testPropName + "InputUid");
+ compInput.setPropertyId(testPropName + "Uid");
+ List<InputDefinition> compInputs = new ArrayList<>();
+ compInputs.add(compInput);
+ currentService.setInputs(compInputs);
+ }
+
+ ComponentInstanceProperty compInstProp = new ComponentInstanceProperty();
+ compInstProp.setName("compInstProp");
+ compInstProp.setToscaFunction(toscaFunc);
+
+ List<ComponentInstanceProperty> compInstProps = new ArrayList<>();
+ compInstProps.add(compInstProp);
+
+ Map<String, List<ComponentInstanceProperty>> mapCompInstProps = new HashMap<>();
+ mapCompInstProps.put("resourceUid", compInstProps);
+
+ PropertyDefinition compProp = new PropertyDefinition();
+ compProp.setName(testPropName);
+ compProp.setUniqueId(testPropName + "Uid");
+ List<PropertyDefinition> compProps = new ArrayList<>();
+ compProps.add(compProp);
+ currentService.setProperties(compProps);
+
+ currentService.setComponentInstancesProperties(mapCompInstProps);
+ }
+
+ private Set<String> getTestRoles() {
Set<String> roles = new HashSet<>();
roles.add("test_admin");
roles.add("test_tenant");
diff --git a/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
index fc4e7d33b7..e8c5d9a5df 100644
--- a/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
+++ b/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
@@ -2855,4 +2855,12 @@ errors:
code: 400,
message: "Cannot change this properties constraints as the resource is an instance.",
messageId: "SVC4015"
+ }
+
+ #---------SVC4017-----------------------------
+ # %1 - Map of component instance and properties
+ SUBSTITUTION_NODE_TYPE_PROPERTY_IN_USE: {
+ code: 409,
+ message: "Cannot change substitution node type as properties of the existing type are referenced by properties %1.",
+ messageId: "SVC4017"
} \ No newline at end of file
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
index 2717c0ca0c..e9d7baed2f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
@@ -151,6 +151,7 @@ public enum ActionStatus {
INVALID_COMPONENT_TYPE,
DATA_TYPE_PROPERTY_ALREADY_EXISTS,
UNEXPECTED_ERROR,
+ SUBSTITUTION_NODE_TYPE_PROPERTY_IN_USE,
//Tenant
MISSING_TENANT, TENANT_NAME_EXCEEDS_LIMIT, INVALID_TENANT_NAME, UNAUTHORIZED_TENANT
}
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
index f36b1cfe8f..6bdaffee55 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
@@ -594,7 +594,7 @@
<select class="i-sdc-form-select"
name="baseType"
data-ng-class="{'view-mode': isViewMode()}"
- data-ng-disabled="component.isCsarComponent() || !isCreateMode()"
+ data-ng-disabled="component.isCsarComponent() || !(isEditMode() || isCreateMode())"
data-ng-model="component.derivedFromGenericType"
data-ng-change="onBaseTypeChange()"
data-tests-id="selectBaseType"
@@ -609,7 +609,7 @@
<select class="i-sdc-form-select"
name="baseTypeVersion"
data-ng-class="{'view-mode': isViewMode()}"
- data-ng-disabled="component.isCsarComponent() || !isCreateMode()"
+ data-ng-disabled="component.isCsarComponent() || !(isEditMode() || isCreateMode())"
data-ng-model="component.derivedFromGenericVersion"
data-tests-id="selectBaseTypeVersion">
<option ng-repeat="version in baseTypeVersions">{{version}}</option>
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionType.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionType.java
index 2636c4f6d7..450c7d0d94 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionType.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionType.java
@@ -46,4 +46,9 @@ public enum ToscaFunctionType {
}
return Arrays.stream(values()).filter(toscaFunctionType -> toscaFunctionType.getName().equalsIgnoreCase(functionType)).findFirst();
}
+
+ public static boolean isGetFunction(final ToscaFunctionType functionType) {
+ return GET_INPUT.equals(functionType) || GET_PROPERTY.equals(functionType) || GET_ATTRIBUTE.equals(functionType);
+ }
+
}