summaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java29
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java88
3 files changed, 39 insertions, 83 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index b8fabc307f..90716f9f86 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -2366,12 +2366,11 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
// Specific Update Logic
String newValue = attribute.getValue();
- final Either<Object, Boolean> isValid = attributeOperation
- .validateAndUpdateAttributeValue(attributeType, attribute.getValue(), true, innerType, allDataTypesEither.left().value());
+ final var isValid = attributeOperation.validateAndUpdateAttributeValue(attribute, innerType, allDataTypesEither.left().value());
if (isValid.isRight()) {
final Boolean res = isValid.right().value();
if (!Boolean.TRUE.equals(res)) {
- log.debug("validate and update attribute value has failed with value: {}", attribute.getValue());
+ log.debug("validate and update attribute value has failed with value: {}", newValue);
throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(
DaoStatusConverter.convertJanusGraphStatusToStorageStatus(JanusGraphOperationStatus.ILLEGAL_ARGUMENT)));
}
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 45180008ab..b374e62a54 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
@@ -712,13 +712,7 @@ public class ToscaExportHandler {
interfacesOperationsConverter.addInterfaceDefinitionElement(component, toscaNodeType, dataTypes, isAssociatedComponent);
addInputsToProperties(dataTypes, inputDef, mergedProperties);
final Map<String, ToscaAttribute> toscaAttributeMap;
- try {
- toscaAttributeMap = convertToToscaAttributes(component.getAttributes(), dataTypes);
- } catch (final ToscaConversionException e) {
- log.error(EcompLoggerErrorCode.SCHEMA_ERROR, ToscaExportHandler.class.getName(),
- COULD_NOT_PARSE_COMPONENT_ATTRIBUTES_COMPONENT_UNIQUE_ID, component.getName(), component.getUniqueId(), e);
- return Either.right(ToscaError.GENERAL_ERROR);
- }
+ toscaAttributeMap = convertToToscaAttributes(component.getAttributes(), dataTypes);
if (!toscaAttributeMap.isEmpty()) {
toscaNodeType.setAttributes(toscaAttributeMap);
}
@@ -763,7 +757,7 @@ public class ToscaExportHandler {
}
private Map<String, ToscaAttribute> convertToToscaAttributes(final List<AttributeDefinition> attributeList,
- final Map<String, DataTypeDefinition> dataTypes) throws ToscaConversionException {
+ final Map<String, DataTypeDefinition> dataTypes) {
if (CollectionUtils.isEmpty(attributeList)) {
return Collections.emptyMap();
}
@@ -981,9 +975,7 @@ public class ToscaExportHandler {
List<ComponentInstanceInput> instanceInputsList = componentInstancesInputs.get(instanceUniqueId);
if (instanceInputsList != null) {
instanceInputsList.forEach(input -> {
-
- Supplier<String> supplier = () -> input.getValue() != null && !Objects.isNull(input.getValue())
- ? input.getValue() : input.getDefaultValue();
+ Supplier<String> supplier = () -> input.getValue() != null && !Objects.isNull(input.getValue()) ? input.getValue() : input.getDefaultValue();
propertyConvertor.convertAndAddValue(dataTypes, props, input, supplier);
});
}
@@ -1010,9 +1002,7 @@ public class ToscaExportHandler {
// Filters out Attributes with empty default values
.filter(attributeDefinition -> StringUtils.isNotEmpty(attributeDefinition.getDefaultValue()))
// Converts and adds each value to attribute map
- .forEach(attributeDefinition -> {
- attributeConverter.convertAndAddValue(attribs, attributeDefinition);
- });
+ .forEach(attributeDefinition -> attributeConverter.convertAndAddValue(attribs, attributeDefinition));
}
}
@@ -1037,9 +1027,7 @@ public class ToscaExportHandler {
// Filters out Attributes with empty default values
.filter(attrib -> StringUtils.isNotEmpty(attrib.getDefaultValue()))
// Converts and adds each value to attribute map
- .forEach(attributeDefinition -> {
- attributeConverter.convertAndAddValue(attribs, attributeDefinition);
- });
+ .forEach(attributeDefinition -> attributeConverter.convertAndAddValue(attribs, attributeDefinition));
}
}
@@ -1237,13 +1225,11 @@ public class ToscaExportHandler {
Component originComponent,
Map<String, Component> componentCache) {
- final List<Map<String, ToscaTemplateRequirement>> toscaRequirements;
final List<RequirementCapabilityRelDef> requirementDefinitionList = filterRequirements(componentInstance,
relations);
if (isNotEmpty(requirementDefinitionList)) {
try {
- toscaRequirements = buildRequirements(component, componentInstance,
- requirementDefinitionList, originComponent, componentCache);
+ final List<Map<String, ToscaTemplateRequirement>> toscaRequirements = buildRequirements(component, componentInstance, requirementDefinitionList, originComponent, componentCache);
if (!toscaRequirements.isEmpty()) {
nodeTypeTemplate.setRequirements(toscaRequirements);
}
@@ -1267,8 +1253,7 @@ public class ToscaExportHandler {
final List<Map<String, ToscaTemplateRequirement>> toscaRequirements = new ArrayList<>();
for (RequirementCapabilityRelDef relationshipDefinition : filteredRelations) {
final Map<String, ToscaTemplateRequirement> toscaTemplateRequirementMap =
- buildRequirement(componentInstance, originComponent, component.getComponentInstances(),
- relationshipDefinition, componentCache);
+ buildRequirement(componentInstance, originComponent, component.getComponentInstances(), relationshipDefinition, componentCache);
toscaRequirements.add(toscaTemplateRequirementMap);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
index 55c2e8972f..202cf014fd 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
@@ -76,6 +76,7 @@ import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.exception.ToscaExportException;
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.CapabilityRequirementRelationship;
import org.openecomp.sdc.be.model.Component;
@@ -715,6 +716,15 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
componentInstancesAttributes.put("uuid", componentInstanceAttributes);
component.setComponentInstancesAttributes(componentInstancesAttributes);
+ ComponentInstanceProperty cip = new ComponentInstanceProperty();
+ cip.setInstanceUniqueId("id");
+
+ List<ComponentInstanceProperty> list = new ArrayList<>();
+ list.add(cip);
+
+ componentInstancesProperties.put("id", list);
+ component.setComponentInstancesProperties(componentInstancesProperties);
+
when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.left(component));
when(capabilityRequirementConverter
.convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
@@ -769,7 +779,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
final ComponentInstance instance = new ComponentInstance();
instance.setUniqueId("id");
instance.setComponentUid("uid");
- instance.setOriginType(OriginTypeEnum.ServiceProxy);
+ instance.setOriginType(OriginTypeEnum.VFC);
final List<GroupInstance> groupInstances = new ArrayList<>();
final GroupInstance groupInst = new GroupInstance();
final List<String> artifacts = new ArrayList<>();
@@ -782,6 +792,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
final List<PropertyDefinition> properties = new ArrayList<>();
properties.add(new PropertyDefinition());
instance.setProperties(properties);
+ component.setProperties(properties);
instance.setUniqueId("uuid");
instance.setDescription("desc");
@@ -826,6 +837,18 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
component.setArtifacts(artifactList);
component.setToscaArtifacts(artifactList);
+ final List<AttributeDefinition> attributes = new ArrayList<>();
+ final var attribute = new AttributeDefinition();
+ attribute.setName("mock");
+ attributes.add(attribute);
+ component.setAttributes(attributes);
+
+ List<ComponentInstanceInput> componentInstanceInputs = new ArrayList<>();
+ componentInstanceInputs.add(new ComponentInstanceInput());
+
+ componentInstancesInputs.put("id", componentInstanceInputs);
+ component.setComponentInstancesInputs(componentInstancesInputs);
+
when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.left(component));
when(capabilityRequirementConverter
.convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
@@ -935,6 +958,12 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
component.setUUID("uuid");
component.setDescription("desc");
+ final List<AttributeDefinition> attributes = new ArrayList<>();
+ final var attribute = new AttributeDefinition();
+ attribute.setName("mock");
+ attributes.add(attribute);
+ component.setAttributes(attributes);
+
componentCache.put("uid", component);
when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.right(false));
@@ -1006,63 +1035,6 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
}
@Test
- public void testAddComponentInstanceInputs() throws Exception {
-
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- Map<String, List<ComponentInstanceInput>> componentInstancesInputs = new HashMap<>();
- ComponentInstance componentInstance = new ComponentInstance();
- String instanceUniqueId = "id";
- Map<String, Object> props = new HashMap<>();
-
- List<ComponentInstanceInput> componentInstanceInputs = new ArrayList<>();
- componentInstanceInputs.add(new ComponentInstanceInput());
-
- componentInstancesInputs.put(instanceUniqueId, componentInstanceInputs);
-
- // default test
- Deencapsulation.invoke(testSubject, "addComponentInstanceInputs", dataTypes, componentInstancesInputs,
- instanceUniqueId, props);
- }
-
- @Test
- public void testAddPropertiesOfComponentInstance() throws Exception {
- Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = new HashMap<>();
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- ComponentInstance componentInstance = new ComponentInstance();
- String instanceUniqueId = "id";
- Map<String, Object> props = new HashMap<>();
-
- ComponentInstanceProperty cip = new ComponentInstanceProperty();
- cip.setInstanceUniqueId("id");
-
- List<ComponentInstanceProperty> list = new ArrayList<>();
- list.add(cip);
-
- componentInstancesProperties.put("id", list);
-
- // default test
- Deencapsulation.invoke(testSubject, "addPropertiesOfComponentInstance", componentInstancesProperties, dataTypes,
- instanceUniqueId, props);
- }
-
- @Test
- public void testAddPropertiesOfParentComponent() throws Exception {
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- ComponentInstance componentInstance = new ComponentInstance();
- Component componentOfInstance = new Resource();
- Map<String, Object> props = new HashMap<>();
-
- List<PropertyDefinition> properties = new ArrayList<>();
- properties.add(new PropertyDefinition());
-
- ((Resource) componentOfInstance).setProperties(properties);
-
- // default test
- Deencapsulation.invoke(testSubject, "addPropertiesOfParentComponent", dataTypes,
- componentOfInstance, props);
- }
-
- @Test
public void testCreateNodeType() throws Exception {
Component component = new Resource();