summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2022-07-14 21:06:58 +0100
committerMichael Morris <michael.morris@est.tech>2022-07-15 13:16:16 +0000
commitee8876059c520d97bf068734b25a02365d7fe1ea (patch)
tree46176fc6a016818c6d17dd0ac20054ec884e7802 /catalog-be/src
parente4055451d3fbfe1fba35dcf546907ad432f6b4fc (diff)
Support Outputs during Import Service
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I4d58576b70ef738d6fa7545cd268ec030b43f95c Issue-ID: SDC-4051
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java17
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java70
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java43
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java102
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java18
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java38
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java14
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java14
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java178
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java121
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java49
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java63
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java79
-rw-r--r--catalog-be/src/test/resources/normativeTypes/importToscaInputsOutputs.yml (renamed from catalog-be/src/test/resources/normativeTypes/importToscaInputs.yml)404
15 files changed, 740 insertions, 479 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java
index 79bfcc6df7..394d6b314b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java
@@ -25,7 +25,6 @@ import com.google.gson.Gson;
import fj.data.Either;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -182,7 +181,7 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
outputDefinition.setOutputPath(attributesName);
outputDefinition.setInstanceUniqueId(propertiesOwner.getUniqueId());
outputDefinition.setAttributeId(attributeOutput.getUniqueId());
- outputDefinition.setAttributes(Arrays.asList(attributeOutput));
+ outputDefinition.setAttribute(attributeOutput);
if (attribute instanceof IComponentInstanceConnectedElement) {
((IComponentInstanceConnectedElement) attribute).setComponentInstanceId(propertiesOwner.getUniqueId());
((IComponentInstanceConnectedElement) attribute).setComponentInstanceName(propertiesOwner.getName());
@@ -201,7 +200,7 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
attributeDataDefinition.setValue(jsonObject.toJSONString());
} else {
jsonObject
- .put(GET_ATTRIBUTE, Arrays.asList(output.getAttributes().get(0).getComponentInstanceName(), attributeDataDefinition.getName()));
+ .put(GET_ATTRIBUTE, Arrays.asList(output.getAttribute().getComponentInstanceName(), attributeDataDefinition.getName()));
output.setValue(jsonObject.toJSONString());
}
} else {
@@ -209,7 +208,7 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
if (objValue instanceof Map || objValue instanceof List) {
if (!complexProperty) {
jsonObject.put(GET_ATTRIBUTE,
- Arrays.asList(output.getAttributes().get(0).getComponentInstanceName(), attributeDataDefinition.getName()));
+ Arrays.asList(output.getAttribute().getComponentInstanceName(), attributeDataDefinition.getName()));
output.setValue(jsonObject.toJSONString());
} else {
final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) objValue;
@@ -218,7 +217,7 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
}
} else {
jsonObject
- .put(GET_ATTRIBUTE, Arrays.asList(output.getAttributes().get(0).getComponentInstanceName(), attributeDataDefinition.getName()));
+ .put(GET_ATTRIBUTE, Arrays.asList(output.getAttribute().getComponentInstanceName(), attributeDataDefinition.getName()));
output.setValue(jsonObject.toJSONString());
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
index 31281db0c7..ed753fdd18 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
@@ -42,6 +42,7 @@ import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.MEMBERS;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.NODE;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.NODE_TEMPLATES;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.NODE_TYPE;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.OUTPUTS;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.POLICIES;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.PROPERTIES;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.REQUIREMENTS;
@@ -93,6 +94,7 @@ import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupTypeDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.NodeTypeInfo;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PolicyTypeDefinition;
@@ -135,13 +137,16 @@ public class YamlTemplateParsingHandler {
Map<String, NodeTypeInfo> nodeTypesInfo, String nodeName,
Component component, String interfaceTemplateYaml) {
log.debug("#parseResourceInfoFromYAML - Going to parse yaml {} ", fileName);
- Map<String, Object> mappedToscaTemplate = getMappedToscaTemplate(fileName, resourceYml, nodeTypesInfo, nodeName);
- ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo();
- Map<String, Object> mappedTopologyTemplate = (Map<String, Object>) findToscaElement(mappedToscaTemplate, TOPOLOGY_TEMPLATE,
+ final Map<String, Object> mappedToscaTemplate = getMappedToscaTemplate(fileName, resourceYml, nodeTypesInfo, nodeName);
+ final ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo();
+ final Map<String, Object> mappedTopologyTemplate = (Map<String, Object>) findToscaElement(mappedToscaTemplate, TOPOLOGY_TEMPLATE,
ToscaElementTypeEnum.ALL).left().on(err -> failIfNotTopologyTemplate(fileName));
- Map<String, Object> mappedTopologyTemplateInputs = mappedTopologyTemplate.entrySet().stream()
+ final Map<String, Object> mappedTopologyTemplateInputs = mappedTopologyTemplate.entrySet().stream()
.filter(entry -> entry.getKey().equals(INPUTS.getElementName())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ final Map<String, Object> mappedTopologyTemplateOutputs = mappedTopologyTemplate.entrySet().stream()
+ .filter(entry -> entry.getKey().equals(OUTPUTS.getElementName())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
parsedToscaYamlInfo.setInputs(getInputs(mappedTopologyTemplateInputs));
+ parsedToscaYamlInfo.setOutputs(getOutputs(mappedTopologyTemplateOutputs));
parsedToscaYamlInfo.setInstances(getInstances(mappedToscaTemplate, createdNodesToscaResourceNames));
parsedToscaYamlInfo.setGroups(getGroups(mappedToscaTemplate, component.getModel()));
parsedToscaYamlInfo.setPolicies(getPolicies(mappedToscaTemplate, component.getModel()));
@@ -190,6 +195,10 @@ public class YamlTemplateParsingHandler {
return inputs;
}
+ private Map<String, OutputDefinition> getOutputs(Map<String, Object> toscaJson) {
+ return ImportUtils.getOutputs(toscaJson).left().on(err -> new HashMap<>());
+ }
+
private Map<String, PropertyDefinition> getProperties(Map<String, Object> toscaJson) {
return ImportUtils.getProperties(toscaJson).left().on(err -> new HashMap<>());
}
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 7719187cda..b4f6ee3950 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
@@ -41,7 +41,7 @@ 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.lang3.StringEscapeUtils;
+import org.apache.commons.text.StringEscapeUtils;
import org.onap.sdc.tosca.datatypes.model.EntrySchema;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
@@ -56,6 +56,7 @@ import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.HeatParameterDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.heat.HeatParameterType;
@@ -92,8 +93,8 @@ public final class ImportUtils {
}
@Autowired
- public static void setComponentsUtils(ComponentsUtils componentsUtils) {
- componentsUtils = componentsUtils;
+ public static void setComponentsUtils(ComponentsUtils cu) {
+ componentsUtils = cu;
}
private static void buildMap(Map<String, Object> output, Map<String, Object> map) {
@@ -257,8 +258,8 @@ public final class ImportUtils {
* @param toscaTagName
* @return
*/
- public static Either<String, ResultStatusEnum> findFirstToscaBooleanElement(Map<String, Object> toscaJson,
- TypeUtils.ToscaTagNamesEnum toscaTagName) {
+ private static Either<String, ResultStatusEnum> findFirstToscaBooleanElement(Map<String, Object> toscaJson,
+ TypeUtils.ToscaTagNamesEnum toscaTagName) {
Either<String, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
Either<Object, ResultStatusEnum> findFirstToscaElements = findToscaElement(toscaJson, toscaTagName, ToscaElementTypeEnum.BOOLEAN);
if (findFirstToscaElements.isLeft()) {
@@ -310,7 +311,7 @@ public final class ImportUtils {
} catch (ClassCastException | JsonParseException e) {
throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS_FORMAT, constraintJson.toString());
}
- if (propertyConstraint != null && propertyConstraint instanceof ValidValuesConstraint) {
+ if (propertyConstraint instanceof ValidValuesConstraint) {
try {
((ValidValuesConstraint) propertyConstraint).validateType(propertyType);
} catch (ConstraintValueDoNotMatchPropertyTypeException e) {
@@ -323,7 +324,7 @@ public final class ImportUtils {
return propertyConstraint;
}
- public static PropertyDefinition createModuleProperty(Map<String, Object> propertyValue) {
+ static PropertyDefinition createModuleProperty(Map<String, Object> propertyValue) {
PropertyDefinition propertyDef = new PropertyDefinition();
setField(propertyValue, TypeUtils.ToscaTagNamesEnum.TYPE, propertyDef::setType);
setFieldBoolean(propertyValue, ToscaTagNamesEnum.REQUIRED, req -> propertyDef.setRequired(Boolean.parseBoolean(req)));
@@ -340,12 +341,11 @@ public final class ImportUtils {
private static void setJsonStringField(Map<String, Object> propertyValue, ToscaTagNamesEnum elementName, String type, Consumer<String> setter) {
Either<Object, ResultStatusEnum> eitherValue = findToscaElement(propertyValue, elementName, ToscaElementTypeEnum.ALL);
if (eitherValue.isLeft()) {
- String propertyJsonStringValue = getPropertyJsonStringValue(eitherValue.left().value(), type);
- setter.accept(propertyJsonStringValue);
+ setter.accept(getPropertyJsonStringValue(eitherValue.left().value(), type));
}
}
- public static Annotation createModuleAnnotation(Map<String, Object> annotationMap, AnnotationTypeOperations annotationTypeOperations) {
+ private static Annotation createModuleAnnotation(Map<String, Object> annotationMap, AnnotationTypeOperations annotationTypeOperations) {
String parsedAnnotationType = findFirstToscaStringElement(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE).left().value();
AnnotationTypeDefinition annotationTypeObject = annotationTypeOperations.getLatestType(parsedAnnotationType);
if (annotationTypeObject != null) {
@@ -387,11 +387,11 @@ public final class ImportUtils {
return result;
}
- public static InputDefinition createModuleInput(final Map<String, Object> inputValue, final AnnotationTypeOperations annotationTypeOperations) {
+ private static InputDefinition createModuleInput(final Map<String, Object> inputValue, final AnnotationTypeOperations annotationTypeOperations) {
return parseAnnotationsAndAddItToInput(createModuleInput(inputValue), inputValue, annotationTypeOperations);
}
- public static InputDefinition createModuleInput(final Map<String, Object> inputValue) {
+ private static InputDefinition createModuleInput(final Map<String, Object> inputValue) {
final InputDefinition inputDef = new InputDefinition();
setField(inputValue, TypeUtils.ToscaTagNamesEnum.TYPE, inputDef::setType);
setFieldBoolean(inputValue, ToscaTagNamesEnum.REQUIRED, req -> inputDef.setRequired(Boolean.parseBoolean(req)));
@@ -408,8 +408,17 @@ public final class ImportUtils {
return inputDef;
}
- public static InputDefinition parseAnnotationsAndAddItToInput(InputDefinition inputDef, Map<String, Object> inputValue,
- AnnotationTypeOperations annotationTypeOperations) {
+ private static OutputDefinition createModuleOutput(final Map<String, Object> outputValue) {
+ final OutputDefinition outputDef = new OutputDefinition();
+ setField(outputValue, TypeUtils.ToscaTagNamesEnum.TYPE, outputDef::setType);
+ setField(outputValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, outputDef::setDescription);
+ setJsonStringField(outputValue, TypeUtils.ToscaTagNamesEnum.VALUE, outputDef.getType(), outputDef::setValue);
+ setField(outputValue, TypeUtils.ToscaTagNamesEnum.STATUS, outputDef::setStatus);
+ return outputDef;
+ }
+
+ private static InputDefinition parseAnnotationsAndAddItToInput(InputDefinition inputDef, Map<String, Object> inputValue,
+ AnnotationTypeOperations annotationTypeOperations) {
Function<String, Annotation> elementGenByName = ImportUtils::createAnnotation;
Function<Map<String, Object>, Annotation> func = annotation -> createModuleAnnotation(annotation, annotationTypeOperations);
return getElements(inputValue, TypeUtils.ToscaTagNamesEnum.ANNOTATIONS, elementGenByName, func).left()
@@ -425,7 +434,7 @@ public final class ImportUtils {
return inputDef;
}
- public static AttributeDefinition createModuleAttribute(Map<String, Object> attributeMap) {
+ static AttributeDefinition createModuleAttribute(Map<String, Object> attributeMap) {
AttributeDefinition attributeDef = new AttributeDefinition();
setField(attributeMap, TypeUtils.ToscaTagNamesEnum.TYPE, attributeDef::setType);
setField(attributeMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, attributeDef::setDescription);
@@ -486,7 +495,7 @@ public final class ImportUtils {
}
}
- public static void setFieldBoolean(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum tagName, Consumer<String> setter) {
+ private static void setFieldBoolean(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum tagName, Consumer<String> setter) {
Either<String, ResultStatusEnum> fieldStringValue = findFirstToscaBooleanElement(toscaJson, tagName);
if (fieldStringValue.isLeft()) {
setter.accept(fieldStringValue.left().value());
@@ -520,13 +529,19 @@ public final class ImportUtils {
return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS, elementGenByName, func);
}
+ public static Either<Map<String, OutputDefinition>, ResultStatusEnum> getOutputs(Map<String, Object> toscaJson) {
+ final Function<String, OutputDefinition> elementGenByName = ImportUtils::createOutputs;
+ final Function<Map<String, Object>, OutputDefinition> func = ImportUtils::createModuleOutput;
+ return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.OUTPUTS, elementGenByName, func);
+ }
+
public static Either<Map<String, InputDefinition>, ResultStatusEnum> getInputs(final Map<String, Object> toscaJson) {
return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS, ImportUtils::createInputs, ImportUtils::createModuleInput);
}
- public static <T> Either<Map<String, T>, ResultStatusEnum> getElements(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementTagName,
- Function<String, T> elementGenByName,
- Function<Map<String, Object>, T> func) {
+ private static <T> Either<Map<String, T>, ResultStatusEnum> getElements(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementTagName,
+ Function<String, T> elementGenByName,
+ Function<Map<String, Object>, T> func) {
Either<Map<String, T>, ResultStatusEnum> eitherResult = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
Either<Map<String, Object>, ResultStatusEnum> toscaAttributes = findFirstToscaMapElement(toscaJson, elementTagName);
if (toscaAttributes.isLeft()) {
@@ -571,13 +586,19 @@ public final class ImportUtils {
return input;
}
+ private static OutputDefinition createOutputs(final String name) {
+ final OutputDefinition output = new OutputDefinition();
+ output.setName(name);
+ return output;
+ }
+
private static Annotation createAnnotation(String name) {
Annotation annotation = new Annotation();
annotation.setName(name);
return annotation;
}
- public static Either<List<HeatParameterDefinition>, ResultStatusEnum> getHeatParameters(Map<String, Object> heatData, String artifactType) {
+ static Either<List<HeatParameterDefinition>, ResultStatusEnum> getHeatParameters(Map<String, Object> heatData, String artifactType) {
Either<List<HeatParameterDefinition>, ResultStatusEnum> eitherResult = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
Either<Map<String, Object>, ResultStatusEnum> toscaProperties = findFirstToscaMapElement(heatData, TypeUtils.ToscaTagNamesEnum.PARAMETERS);
if (toscaProperties.isLeft()) {
@@ -657,13 +678,16 @@ public final class ImportUtils {
}
public static String getPropertyJsonStringValue(Object value, String type) {
- Gson gson = new Gson();
if (type == null) {
return null;
}
ToscaPropertyType validType = ToscaPropertyType.isValidType(type);
- if (validType == null || validType == ToscaPropertyType.JSON || validType == ToscaPropertyType.MAP || validType == ToscaPropertyType.LIST) {
- return gson.toJson(value);
+ if (validType == null
+ || validType == ToscaPropertyType.JSON
+ || validType == ToscaPropertyType.MAP
+ || validType == ToscaPropertyType.LIST
+ || value instanceof Map) {
+ return (new Gson()).toJson(value);
}
return value.toString();
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index 18993e8f65..bca901ee8b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -127,14 +127,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
ComponentParametersView filters = new ComponentParametersView();
filters.disableAll();
filters.setIgnoreInputs(false);
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
+ Either<Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
.getToscaElement(componentId, filters);
if (getComponentEither.isRight()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus);
return Either.right(componentsUtils.getResponseFormat(actionStatus));
}
- org.openecomp.sdc.be.model.Component component = getComponentEither.left().value();
+ Component component = getComponentEither.left().value();
List<InputDefinition> inputs = component.getInputs();
return Either.left(inputs);
}
@@ -147,14 +147,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
filters.setIgnoreInputs(false);
filters.setIgnoreComponentInstances(false);
filters.setIgnoreComponentInstancesInputs(false);
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
+ Either<Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
.getToscaElement(componentId, filters);
if (getComponentEither.isRight()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus);
return Either.right(componentsUtils.getResponseFormat(actionStatus));
}
- org.openecomp.sdc.be.model.Component component = getComponentEither.left().value();
+ Component component = getComponentEither.left().value();
if (!ComponentValidations.validateComponentInstanceExist(component, componentInstanceId)) {
ActionStatus actionStatus = ActionStatus.COMPONENT_INSTANCE_NOT_FOUND;
log.debug("Failed to found component instance inputs {}, error: {}", componentInstanceId, actionStatus);
@@ -182,12 +182,12 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
String instanceId, String inputId) {
validateUserExists(userId);
String parentId = componentId;
- org.openecomp.sdc.be.model.Component component;
+ Component component;
ComponentParametersView filters = new ComponentParametersView();
filters.disableAll();
filters.setIgnoreComponentInstances(false);
if (!instanceId.equals(inputId)) {
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
+ Either<Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
.getToscaElement(parentId, filters);
if (getComponentEither.isRight()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
@@ -204,7 +204,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
filters.setIgnoreComponentInstancesProperties(false);
filters.setIgnoreComponentInstancesInputs(false);
filters.setIgnoreProperties(false);
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
+ Either<Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
.getToscaElement(parentId, filters);
if (getComponentEither.isRight()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
@@ -266,7 +266,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
List<InputDefinition> inputs, String userId, boolean shouldLockComp) {
List<InputDefinition> returnInputs = new ArrayList<>();
Either<List<InputDefinition>, ResponseFormat> result = null;
- org.openecomp.sdc.be.model.Component component = null;
+ Component component = null;
try {
validateUserExists(userId);
ComponentParametersView componentParametersView = new ComponentParametersView();
@@ -353,14 +353,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
public Either<List<ComponentInstanceInput>, ResponseFormat> getInputsForComponentInput(String userId, String componentId, String inputId) {
validateUserExists(userId);
- org.openecomp.sdc.be.model.Component component = null;
+ Component component = null;
ComponentParametersView filters = new ComponentParametersView();
filters.disableAll();
filters.setIgnoreComponentInstances(false);
filters.setIgnoreInputs(false);
filters.setIgnoreComponentInstancesInputs(false);
filters.setIgnoreProperties(false);
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
+ Either<Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
.getToscaElement(componentId, filters);
if (getComponentEither.isRight()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
@@ -388,7 +388,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
boolean shouldLockComp,
boolean inTransaction) {
Either<List<InputDefinition>, ResponseFormat> result = null;
- org.openecomp.sdc.be.model.Component component = null;
+ Component component = null;
try {
validateUserExists(userId);
component = getAndValidateComponentForCreate(userId, componentId, componentType, shouldLockComp);
@@ -431,7 +431,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
ComponentInstListInput componentListInput, boolean shouldLockComp,
boolean inTransaction) {
Either<List<InputDefinition>, ResponseFormat> result = null;
- org.openecomp.sdc.be.model.Component component = null;
+ Component component = null;
log.trace("#createListInput: enter");
try {
/* check if user exists */
@@ -513,11 +513,11 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
return componentParametersView;
}
- private org.openecomp.sdc.be.model.Component getAndValidateComponentForCreate(
+ private Component getAndValidateComponentForCreate(
String userId, String componentId, ComponentTypeEnum componentType, boolean shouldLockComp
) {
ComponentParametersView componentParametersView = getBaseComponentParametersView();
- org.openecomp.sdc.be.model.Component component = validateComponentExists(componentId, componentType, componentParametersView);
+ Component component = validateComponentExists(componentId, componentType, componentParametersView);
if (shouldLockComp) {
// lock the component
lockComponent(component, CREATE_INPUT);
@@ -566,7 +566,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
public Either<List<InputDefinition>, ResponseFormat> createInputsInGraph(Map<String, InputDefinition> inputs,
- org.openecomp.sdc.be.model.Component component) {
+ Component component) {
List<InputDefinition> resourceProperties = component.getInputs();
@@ -604,7 +604,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
private Either<List<InputDefinition>, ResponseFormat> createListInputsInGraph(Map<String, InputDefinition> inputs,
Map<String, DataTypeDefinition> privateDataTypes,
- org.openecomp.sdc.be.model.Component component) {
+ Component component) {
log.trace("#createListInputsInGraph: enter");
@@ -652,12 +652,12 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
componentParametersView.setIgnoreInterfaces(false);
componentParametersView.setIgnoreDataType(false);
componentParametersView.setIgnoreProperties(false);
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> componentEither = toscaOperationFacade
+ Either<Component, StorageOperationStatus> componentEither = toscaOperationFacade
.getToscaElement(componentId, componentParametersView);
if (componentEither.isRight()) {
throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(componentEither.right().value()));
}
- org.openecomp.sdc.be.model.Component component = componentEither.left().value();
+ Component component = componentEither.left().value();
// Validate inputId is child of the component
Optional<InputDefinition> optionalInput = component.getInputs().stream().
// filter by ID
@@ -700,10 +700,9 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
private Either<InputDefinition, ResponseFormat> deleteListInput(String componentId, String inputId,
- org.openecomp.sdc.be.model.Component component, InputDefinition inputForDelete,
+ Component component, InputDefinition inputForDelete,
StorageOperationStatus status) {
// the input is created by 'Declare List'.
-
// need to 1. undeclare properties, 2. delete input, 3. delete private data type
StorageOperationStatus storageOperationStatus = propertyDeclarationOrchestrator.unDeclarePropertiesAsListInputs(component, inputForDelete);
if (storageOperationStatus != StorageOperationStatus.OK) {
@@ -762,14 +761,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
filters.setIgnoreComponentInstancesInputs(false);
filters.setIgnoreComponentInstancesProperties(false);
filters.setIgnoreProperties(false);
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
+ Either<Component, StorageOperationStatus> getComponentEither = toscaOperationFacade
.getToscaElement(componentId, filters);
if (getComponentEither.isRight()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus);
return Either.right(componentsUtils.getResponseFormat(actionStatus));
}
- org.openecomp.sdc.be.model.Component component = getComponentEither.left().value();
+ Component component = getComponentEither.left().value();
Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
if (!op.isPresent()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java
index 2d6a619cc7..a5f819d9b0 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java
@@ -20,10 +20,12 @@
package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.sdc.be.components.attribute.AttributeDeclarationOrchestrator;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
@@ -32,8 +34,12 @@ import org.openecomp.sdc.be.components.validation.ComponentValidations;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.utils.MapUtil;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstOutputsMap;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribOutput;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceOutput;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.OutputDefinition;
@@ -51,6 +57,7 @@ import org.openecomp.sdc.common.log.enums.StatusCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
@org.springframework.stereotype.Component("outputsBusinessLogic")
public class OutputsBusinessLogic extends BaseBusinessLogic {
@@ -58,8 +65,8 @@ public class OutputsBusinessLogic extends BaseBusinessLogic {
private static final String CREATE_OUTPUT = "CreateOutput";
private static final Logger log = Logger.getLogger(OutputsBusinessLogic.class);
private static final String FAILED_TO_FOUND_COMPONENT_ERROR = "Failed to found component {}, error: {}";
- private static final String GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_GROUP = "Going to execute rollback on create group.";
- private static final String GOING_TO_EXECUTE_COMMIT_ON_CREATE_GROUP = "Going to execute commit on create group.";
+ private static final String GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_OUTPUTS = "Going to execute rollback on create outputs.";
+ private static final String GOING_TO_EXECUTE_COMMIT_ON_CREATE_OUTPUTS = "Going to execute commit on create outputs.";
private static final LoggerSupportability loggerSupportability = LoggerSupportability.getLogger(OutputsBusinessLogic.class);
private static final String FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_COMPONENT_INSTANCE_ID = "Failed to found component instance outputs componentInstanceId: {}";
private static final String FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_ERROR = "Failed to found component instance outputs {}, error: {}";
@@ -94,7 +101,7 @@ public class OutputsBusinessLogic extends BaseBusinessLogic {
if (!ComponentValidations.validateComponentInstanceExist(component, componentInstanceId)) {
final ActionStatus actionStatus = ActionStatus.COMPONENT_INSTANCE_NOT_FOUND;
log.debug(FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_ERROR, componentInstanceId, actionStatus);
- loggerSupportability.log(LoggerSupportabilityActions.CREATE_INPUTS, component.getComponentMetadataForSupportLog(), StatusCode.ERROR,
+ loggerSupportability.log(LoggerSupportabilityActions.CREATE_OUTPUTS, component.getComponentMetadataForSupportLog(), StatusCode.ERROR,
FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_COMPONENT_INSTANCE_ID, componentInstanceId);
return Either.right(componentsUtils.getResponseFormat(actionStatus));
}
@@ -110,11 +117,11 @@ public class OutputsBusinessLogic extends BaseBusinessLogic {
return createMultipleOutputs(userId, componentId, componentTypeEnum, componentInstOutputsMap, true, false);
}
- public Either<List<OutputDefinition>, ResponseFormat> createMultipleOutputs(final String userId, final String componentId,
- final ComponentTypeEnum componentType,
- final ComponentInstOutputsMap componentInstOutputsMapUi,
- final boolean shouldLockComp, final boolean inTransaction) {
- Either<List<OutputDefinition>, ResponseFormat> result = null;
+ private Either<List<OutputDefinition>, ResponseFormat> createMultipleOutputs(final String userId, final String componentId,
+ final ComponentTypeEnum componentType,
+ final ComponentInstOutputsMap componentInstOutputsMapUi,
+ final boolean shouldLockComp, final boolean inTransaction) {
+ Either<List<OutputDefinition>, ResponseFormat> result = Either.right(new ResponseFormat(HttpStatus.BAD_REQUEST.value()));
org.openecomp.sdc.be.model.Component component = null;
try {
validateUserExists(userId);
@@ -129,11 +136,11 @@ public class OutputsBusinessLogic extends BaseBusinessLogic {
return result;
} finally {
if (!inTransaction) {
- if (result == null || result.isRight()) {
- log.debug(GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_GROUP);
+ if (result.isRight()) {
+ log.debug(GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_OUTPUTS);
janusGraphDao.rollback();
} else {
- log.debug(GOING_TO_EXECUTE_COMMIT_ON_CREATE_GROUP);
+ log.debug(GOING_TO_EXECUTE_COMMIT_ON_CREATE_OUTPUTS);
janusGraphDao.commit();
}
}
@@ -144,11 +151,11 @@ public class OutputsBusinessLogic extends BaseBusinessLogic {
}
}
- private org.openecomp.sdc.be.model.Component getAndValidateComponentForCreate(final String userId, final String componentId,
- final ComponentTypeEnum componentType,
- final boolean shouldLockComp) {
+ private Component getAndValidateComponentForCreate(final String userId, final String componentId,
+ final ComponentTypeEnum componentType,
+ final boolean shouldLockComp) {
final ComponentParametersView componentParametersView = getBaseComponentParametersView();
- final org.openecomp.sdc.be.model.Component component = validateComponentExists(componentId, componentType, componentParametersView);
+ final Component component = validateComponentExists(componentId, componentType, componentParametersView);
if (shouldLockComp) {
// lock the component
lockComponent(component, CREATE_OUTPUT);
@@ -161,7 +168,11 @@ public class OutputsBusinessLogic extends BaseBusinessLogic {
final List<OutputDefinition> outputsToCreate) {
final Map<String, OutputDefinition> outputsToPersist = MapUtil.toMap(outputsToCreate, OutputDefinition::getName);
assignOwnerIdToOutputs(userId, outputsToPersist);
- return toscaOperationFacade.addOutputsToComponent(outputsToPersist, cmptId).left().map(persistedOutputs -> outputsToCreate);
+ final var statusEither = toscaOperationFacade.addOutputsToComponent(outputsToPersist, cmptId);
+ if (statusEither.isRight()) {
+ return statusEither;
+ }
+ return statusEither.left().map(persistedOutputs -> outputsToCreate);
}
private void assignOwnerIdToOutputs(final String userId, final Map<String, OutputDefinition> outputsToCreate) {
@@ -189,7 +200,6 @@ public class OutputsBusinessLogic extends BaseBusinessLogic {
* @return
*/
public OutputDefinition deleteOutput(final String componentId, final String userId, final String outputId) {
- Either<OutputDefinition, ResponseFormat> deleteEither = null;
if (log.isDebugEnabled()) {
log.debug("Going to delete output id: {}", outputId);
}
@@ -236,4 +246,62 @@ public class OutputsBusinessLogic extends BaseBusinessLogic {
unlockComponent(failed, component);
}
}
+
+ public Either<List<OutputDefinition>, ResponseFormat> createOutputsInGraph(final Map<String, OutputDefinition> outputs,
+ final Component component,
+ final String userId) {
+
+ final List<OutputDefinition> result = new ArrayList<>();
+ for (final Map.Entry<String, OutputDefinition> outputDefinition : outputs.entrySet()) {
+ final var outputDefinitionValue = outputDefinition.getValue();
+ outputDefinitionValue.setName(outputDefinition.getKey());
+
+ final String value = outputDefinitionValue.getValue();
+ if (value != null) {
+ final List<String> getAttribute = (List<String>) ImportUtils.loadYamlAsStrictMap(value)
+ .get(ToscaGetFunctionType.GET_ATTRIBUTE.getFunctionName());
+ if (getAttribute.size() == 2) {
+ final var optionalComponentInstance = component.getComponentInstanceByName(getAttribute.get(0));
+ if (optionalComponentInstance.isPresent()) {
+ final var createdOutputs
+ = createOutputs(component.getUniqueId(), userId, getAttribute.get(1), optionalComponentInstance.get());
+ if (createdOutputs.isRight()) {
+ return Either.right((createdOutputs.right().value()));
+ }
+ result.addAll(createdOutputs.left().value());
+ } else {
+ // From SELF
+ outputDefinitionValue.setInstanceUniqueId(component.getUniqueId());
+ }
+ }
+ }
+ }
+ return Either.left(result);
+
+ }
+
+ private Either<List<OutputDefinition>, ResponseFormat> createOutputs(final String componentUniqueId, final String userId,
+ final String attributeName,
+ final ComponentInstance componentInstance) {
+ // From Instance
+ final List<OutputDefinition> result = new ArrayList<>();
+ final var componentInstanceAttributes = componentInstance.getAttributes();
+ if (CollectionUtils.isNotEmpty(componentInstanceAttributes)) {
+ final var componentInstanceAttributeOptional = componentInstanceAttributes.stream()
+ .filter(ad -> ad.getName().equals(attributeName)).map(ComponentInstanceAttribute::new).findFirst();
+ if (componentInstanceAttributeOptional.isPresent()) {
+ final var componentInstOutputsMap = new ComponentInstOutputsMap();
+ componentInstOutputsMap.setComponentInstanceAttributes(Collections.singletonMap(componentInstance.getUniqueId(),
+ Collections.singletonList(new ComponentInstanceAttribOutput(componentInstanceAttributeOptional.get()))));
+ final var createdOutputs = createMultipleOutputs(userId, componentUniqueId, ComponentTypeEnum.SERVICE,
+ componentInstOutputsMap, true, false);
+ if (createdOutputs.isRight()) {
+ return Either.right((createdOutputs.right().value()));
+ }
+ result.addAll(createdOutputs.left().value());
+ }
+ }
+ return Either.left(result);
+ }
+
}
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 34460f46d5..3c21ae16a7 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
@@ -97,6 +97,7 @@ import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.NodeTypeInfo;
import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
import org.openecomp.sdc.be.model.PolicyDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
@@ -252,7 +253,7 @@ public class ServiceImportBusinessLogic {
throw new ComponentException(findNodeTypesArtifactsToHandleRes.right().value());
}
return createServiceFromYaml(service, csarInfo.getMainTemplateContent(), csarInfo.getMainTemplateName(), nodeTypesInfo, csarInfo,
- findNodeTypesArtifactsToHandleRes.left().value(), true, false, null);
+ findNodeTypesArtifactsToHandleRes.left().value(), true, false, null, user.getUserId());
} catch (Exception e) {
log.debug("Exception occured when createServiceFromCsar,error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.GENERAL_ERROR);
@@ -262,7 +263,8 @@ public class ServiceImportBusinessLogic {
protected Service createServiceFromYaml(Service service, String topologyTemplateYaml, String yamlName, Map<String, NodeTypeInfo> nodeTypesInfo,
CsarInfo csarInfo,
Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
- boolean shouldLock, boolean inTransaction, String nodeName) throws BusinessLogicException {
+ boolean shouldLock, boolean inTransaction, String nodeName, final String userId)
+ throws BusinessLogicException {
List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
Service createdService;
CreateServiceFromYamlParameter csfyp = new CreateServiceFromYamlParameter();
@@ -277,7 +279,7 @@ public class ServiceImportBusinessLogic {
csfyp.setNodeTypesInfo(nodeTypesInfo);
csfyp.setCsarInfo(csarInfo);
csfyp.setNodeName(nodeName);
- createdService = createServiceAndRIsFromYaml(service, false, nodeTypesArtifactsToCreate, shouldLock, inTransaction, csfyp);
+ createdService = createServiceAndRIsFromYaml(service, false, nodeTypesArtifactsToCreate, shouldLock, inTransaction, csfyp, userId);
log.debug("#createResourceFromYaml - The resource {} has been created ", service.getName());
} catch (ComponentException | BusinessLogicException e) {
log.debug("Create Service from yaml failed", e);
@@ -291,7 +293,8 @@ public class ServiceImportBusinessLogic {
protected Service createServiceAndRIsFromYaml(Service service, boolean isNormative,
Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
- boolean shouldLock, boolean inTransaction, CreateServiceFromYamlParameter csfyp)
+ boolean shouldLock, boolean inTransaction, CreateServiceFromYamlParameter csfyp,
+ final String userId)
throws BusinessLogicException {
List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
String yamlName = csfyp.getYamlName();
@@ -325,7 +328,7 @@ public class ServiceImportBusinessLogic {
log.trace("************* Going to add inputs from yaml {}", yamlName);
Map<String, InputDefinition> inputs = parsedToscaYamlInfo.getInputs();
service = serviceImportParseLogic.createInputsOnService(service, inputs);
- log.trace("************* Finish to add inputs from yaml {}", yamlName);
+ log.trace("************* Finished to add inputs from yaml {}", yamlName);
ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> substitutionFilterProperties = parsedToscaYamlInfo.getSubstitutionFilterProperties();
service = serviceImportParseLogic.createSubstitutionFilterOnService(service, substitutionFilterProperties);
log.trace("************* Added Substitution filter from interface yaml {}", yamlName);
@@ -334,6 +337,11 @@ public class ServiceImportBusinessLogic {
service = createRIAndRelationsFromYaml(yamlName, service, uploadComponentInstanceInfoMap, topologyTemplateYaml,
nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, nodeName);
log.trace("************* Finished to create nodes, RI and Relation from yaml {}", yamlName);
+ log.trace("************* Going to add outputs from yaml {}", yamlName);
+ Map<String, OutputDefinition> outputs = parsedToscaYamlInfo.getOutputs();
+ service = serviceImportParseLogic.createOutputsOnService(service, outputs, userId);
+ log.trace("************* Finished to add outputs from yaml {}", yamlName);
+
Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes
= groupBusinessLogic.validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), service.getSystemName());
if (validateUpdateVfGroupNamesRes.isRight()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
index 7a5b90976f..507f4ad32c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
@@ -77,6 +77,7 @@ import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.NodeTypeInfo;
import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RelationshipImpl;
import org.openecomp.sdc.be.model.RelationshipInfo;
@@ -112,7 +113,6 @@ 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;
@@ -131,27 +131,18 @@ public class ServiceImportParseLogic {
private static final String CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES = "Create Resource - validateCapabilityTypesCreate";
private static final String CATEGORY_IS_EMPTY = "Resource category is empty";
private static final Logger log = Logger.getLogger(ServiceImportParseLogic.class);
- @Autowired
private final ServiceBusinessLogic serviceBusinessLogic;
- @Autowired
private final ComponentsUtils componentsUtils;
- @Autowired
private final ToscaOperationFacade toscaOperationFacade;
- @Autowired
private final LifecycleBusinessLogic lifecycleBusinessLogic;
- @Autowired
private final InputsBusinessLogic inputsBusinessLogic;
- @Autowired
private final ResourceImportManager resourceImportManager;
- @Autowired
private final ComponentSubstitutionFilterBusinessLogic substitutionFilterBusinessLogic;
- @Autowired
private final IInterfaceLifecycleOperation interfaceTypeOperation;
- @Autowired
private final ICapabilityTypeOperation capabilityTypeOperation;
- @Autowired
private final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic;
private final GroupBusinessLogic groupBusinessLogic;
+ private final OutputsBusinessLogic outputsBusinessLogic;
public ServiceImportParseLogic(final ServiceBusinessLogic serviceBusinessLogic, final ComponentsUtils componentsUtils,
final ToscaOperationFacade toscaOperationFacade, final LifecycleBusinessLogic lifecycleBusinessLogic,
@@ -159,7 +150,7 @@ public class ServiceImportParseLogic {
final ComponentSubstitutionFilterBusinessLogic substitutionFilterBusinessLogic,
final IInterfaceLifecycleOperation interfaceTypeOperation, final ICapabilityTypeOperation capabilityTypeOperation,
final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic,
- final GroupBusinessLogic groupBusinessLogic) {
+ final GroupBusinessLogic groupBusinessLogic, final OutputsBusinessLogic outputsBusinessLogic) {
this.serviceBusinessLogic = serviceBusinessLogic;
this.componentsUtils = componentsUtils;
this.toscaOperationFacade = toscaOperationFacade;
@@ -171,6 +162,7 @@ public class ServiceImportParseLogic {
this.capabilityTypeOperation = capabilityTypeOperation;
this.componentNodeFilterBusinessLogic = componentNodeFilterBusinessLogic;
this.groupBusinessLogic = groupBusinessLogic;
+ this.outputsBusinessLogic = outputsBusinessLogic;
}
public Either<Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandle(
@@ -1039,8 +1031,6 @@ public class ServiceImportParseLogic {
reqDef.setLeftOccurrences(String.valueOf(left));
validRegDef = reqDef;
break;
- } else {
- continue;
}
} else {
validRegDef = reqDef;
@@ -1066,8 +1056,6 @@ public class ServiceImportParseLogic {
reqDef.setLeftOccurrences(String.valueOf(left));
validRegDef = reqDef;
break;
- } else {
- continue;
}
} else {
validRegDef = reqDef;
@@ -1371,6 +1359,24 @@ public class ServiceImportParseLogic {
return updatedResource.left().value();
}
+ public Service createOutputsOnService(final Service service, final Map<String, OutputDefinition> outputs, final String userId) {
+ if (MapUtils.isNotEmpty(outputs) || isNotEmpty(service.getOutputs())) {
+ final Either<List<OutputDefinition>, ResponseFormat> createOutputs = outputsBusinessLogic.createOutputsInGraph(outputs, service, userId);
+ if (createOutputs.isRight()) {
+ throw new ComponentException(createOutputs.right().value());
+ }
+ } else {
+ return service;
+ }
+ final Either<Service, StorageOperationStatus> updatedResource = toscaOperationFacade.getToscaElement(service.getUniqueId());
+ if (updatedResource.isRight()) {
+ throw new ComponentException(
+ componentsUtils.getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service,
+ ComponentTypeEnum.SERVICE));
+ }
+ return updatedResource.left().value();
+ }
+
public Service createSubstitutionFilterOnService(Service service,
ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> substitutionFilterProperties)
throws BusinessLogicException {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
index 7c300b310d..1b1111a86e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
@@ -1061,16 +1061,16 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
}
}
- protected void handleImportService(Wrapper<Response> responseWrapper, User user, UploadServiceInfo serviceInfoObject, String yamlAsString,
- ServiceAuthorityTypeEnum authority, boolean createNewVersion, String serviceUniqueId) throws ZipException {
+ protected void handleImportService(Wrapper<Response> responseWrapper, User user, UploadServiceInfo serviceInfoObject, String serviceUniqueId)
+ throws ZipException {
Response response = null;
- Object representation = null;
ImmutablePair<Service, ActionStatus> importedServiceStatus = null;
if (CsarValidationUtils.isCsarPayloadName(serviceInfoObject.getPayloadName())) {
log.debug("import service from csar");
importedServiceStatus = importServiceFromUICsar(serviceInfoObject, user, serviceUniqueId);
}
if (importedServiceStatus != null) {
+ Object representation = null;
try {
representation = RepresentationUtils.toRepresentation(importedServiceStatus.left);
} catch (IOException e) {
@@ -1083,18 +1083,14 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
private ImmutablePair<Service, ActionStatus> importServiceFromUICsar(UploadServiceInfo serviceInfoObject, User user, String serviceUniqueId)
throws ZipException {
- Service newService;
- ImmutablePair<Service, ActionStatus> result = null;
- ActionStatus actionStatus;
Service service = new Service();
String payloadName = serviceInfoObject.getPayloadName();
fillServiceFromServiceInfoObject(service, serviceInfoObject);
Map<String, byte[]> csarUIPayloadRes = getCsarFromPayload(serviceInfoObject);
getAndValidateCsarYaml(csarUIPayloadRes, service, user, payloadName);
- newService = serviceImportManager.getServiceImportBusinessLogic()
+ final Service newService = serviceImportManager.getServiceImportBusinessLogic()
.createService(service, AuditingActionEnum.CREATE_SERVICE, user, csarUIPayloadRes, payloadName);
- actionStatus = ActionStatus.CREATED;
- return new ImmutablePair<>(newService, actionStatus);
+ return new ImmutablePair<>(newService, ActionStatus.CREATED);
}
private void fillServiceFromServiceInfoObject(Service service, UploadServiceInfo serviceInfoObject) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java
index c26f3ca522..f49bfdc637 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ServiceServlet.java
@@ -672,18 +672,17 @@ public class ServiceServlet extends AbstractValidationsServlet {
}
private Wrapper<Response> performUIImport(String data, final HttpServletRequest request, String userId,
- String ServiceUniqueId) throws FileNotFoundException, ZipException {
+ String serviceUniqueId) throws FileNotFoundException, ZipException {
Wrapper<Response> responseWrapper = new Wrapper<>();
Wrapper<User> userWrapper = new Wrapper<>();
Wrapper<UploadServiceInfo> uploadServiceInfoWrapper = new Wrapper<>();
Wrapper<String> yamlStringWrapper = new Wrapper<>();
- ServiceAuthorityTypeEnum ServiceAuthorityEnum = ServiceAuthorityTypeEnum.USER_TYPE_UI;
- commonServiceGeneralValidations(responseWrapper, userWrapper, uploadServiceInfoWrapper, ServiceAuthorityEnum, userId, data);
+ ServiceAuthorityTypeEnum serviceAuthorityTypeEnum = ServiceAuthorityTypeEnum.USER_TYPE_UI;
+ commonServiceGeneralValidations(responseWrapper, userWrapper, uploadServiceInfoWrapper, serviceAuthorityTypeEnum, userId, data);
specificServiceAuthorityValidations(responseWrapper, uploadServiceInfoWrapper, yamlStringWrapper, userWrapper.getInnerElement(), request,
- data, ServiceAuthorityEnum);
+ data, serviceAuthorityTypeEnum);
if (responseWrapper.isEmpty()) {
- handleImportService(responseWrapper, userWrapper.getInnerElement(), uploadServiceInfoWrapper.getInnerElement(),
- yamlStringWrapper.getInnerElement(), ServiceAuthorityEnum, true, ServiceUniqueId);
+ handleImportService(responseWrapper, userWrapper.getInnerElement(), uploadServiceInfoWrapper.getInnerElement(), serviceUniqueId);
}
return responseWrapper;
}
@@ -775,8 +774,7 @@ public class ServiceServlet extends AbstractValidationsServlet {
uploadServiceInfoWrapper.getInnerElement().setProjectCode(oldService.getProjectCode());
if (responseWrapper.isEmpty()) {
log.debug("importReplaceService:start handleImportService");
- handleImportService(responseWrapper, userWrapper.getInnerElement(), uploadServiceInfoWrapper.getInnerElement(),
- yamlStringWrapper.getInnerElement(), serviceAuthorityEnum, true, null);
+ handleImportService(responseWrapper, userWrapper.getInnerElement(), uploadServiceInfoWrapper.getInnerElement(), null);
}
return responseWrapper.getInnerElement();
} catch (IOException | ZipException e) {
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 9cd095b5b5..b7559e3836 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
@@ -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,10 +20,10 @@
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 static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.Lists;
import fj.data.Either;
@@ -36,7 +36,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum;
@@ -46,6 +46,7 @@ import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.HeatParameterDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.operations.impl.AnnotationTypeOperations;
@@ -56,10 +57,32 @@ import org.yaml.snakeyaml.Yaml;
public class ImportUtilsTest {
+ public static String loadFileNameToJsonString(String fileName) throws IOException {
+ String sourceDir = "src/test/resources/normativeTypes";
+ return loadFileNameToJsonString(sourceDir, fileName);
+ }
+
+ public static String loadCustomTypeFileNameToJsonString(String fileName) throws IOException {
+ String sourceDir = "src/test/resources/customTypes";
+ return loadFileNameToJsonString(sourceDir, fileName);
+ }
+
+ private static String loadFileNameToJsonString(String sourceDir, String fileName) throws IOException {
+ java.nio.file.Path filePath = FileSystems.getDefault().getPath(sourceDir, fileName);
+ byte[] fileContent = Files.readAllBytes(filePath);
+ return new String(fileContent);
+ }
+
+ private static Object loadJsonFromFile(String fileName) throws IOException {
+ String content = loadFileNameToJsonString(fileName);
+ return new Yaml().load(content);
+ }
@Test
- public void testStringTypeFindToscaElements() throws IOException {
- Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements((Map<String, Object>) loadJsonFromFile("normative-types-string-list-test.yml"), "stringTestTag", ToscaElementTypeEnum.STRING, new ArrayList<>());
+ void testStringTypeFindToscaElements() throws IOException {
+ Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(
+ (Map<String, Object>) loadJsonFromFile("normative-types-string-list-test.yml"), "stringTestTag", ToscaElementTypeEnum.STRING,
+ new ArrayList<>());
assertTrue(toscaElements.isLeft());
List<Object> list = toscaElements.left().value();
assertEquals(4, list.size());
@@ -73,8 +96,9 @@ public class ImportUtilsTest {
}
@Test
- public void testBooleanTypeFindToscaElements() throws IOException {
- Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements((Map<String, Object>) loadJsonFromFile("normative-types-all-map-test.yml"), "required", ToscaElementTypeEnum.BOOLEAN, new ArrayList<>());
+ void testBooleanTypeFindToscaElements() throws IOException {
+ Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(
+ (Map<String, Object>) loadJsonFromFile("normative-types-all-map-test.yml"), "required", ToscaElementTypeEnum.BOOLEAN, new ArrayList<>());
assertTrue(toscaElements.isLeft());
List<Object> list = toscaElements.left().value();
assertEquals(3, list.size());
@@ -93,8 +117,10 @@ public class ImportUtilsTest {
}
@Test
- public void testListTypeFindToscaElements() throws IOException {
- Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements((Map<String, Object>) loadJsonFromFile("normative-types-string-list-test.yml"), "listTestTag", ToscaElementTypeEnum.LIST, new ArrayList<>());
+ void testListTypeFindToscaElements() throws IOException {
+ Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(
+ (Map<String, Object>) loadJsonFromFile("normative-types-string-list-test.yml"), "listTestTag", ToscaElementTypeEnum.LIST,
+ new ArrayList<>());
assertTrue(toscaElements.isLeft());
List<Object> list = toscaElements.left().value();
assertEquals(3, list.size());
@@ -106,9 +132,7 @@ public class ImportUtilsTest {
verifyListElement1(element);
} else if (count == 2) {
verifyListElement2(element);
- }
-
- else if (count == 3) {
+ } else if (count == 3) {
verifyListElement3(element);
}
count++;
@@ -116,8 +140,9 @@ public class ImportUtilsTest {
}
@Test
- public void testAllTypeFindToscaElements() throws IOException {
- Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements((Map<String, Object>) loadJsonFromFile("normative-types-all-map-test.yml"), "allTestTag", ToscaElementTypeEnum.ALL, new ArrayList<>());
+ void testAllTypeFindToscaElements() throws IOException {
+ Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(
+ (Map<String, Object>) loadJsonFromFile("normative-types-all-map-test.yml"), "allTestTag", ToscaElementTypeEnum.ALL, new ArrayList<>());
assertTrue(toscaElements.isLeft());
List<Object> list = toscaElements.left().value();
assertEquals(5, list.size());
@@ -139,14 +164,10 @@ public class ImportUtilsTest {
assertEquals("required", elementEntry.getKey());
assertTrue(elementEntry.getValue() instanceof Boolean);
assertTrue((Boolean) elementEntry.getValue());
- }
-
- else if (count == 3) {
+ } else if (count == 3) {
assertTrue(element instanceof String);
assertEquals("1 MB", element);
- }
-
- else if (count == 4) {
+ } else if (count == 4) {
assertTrue(element instanceof List);
List<Object> listElement = (List<Object>) element;
assertEquals(2, listElement.size());
@@ -173,8 +194,9 @@ public class ImportUtilsTest {
}
@Test
- public void testMapTypeFindToscaElements() throws IOException {
- Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements((Map<String, Object>) loadJsonFromFile("normative-types-all-map-test.yml"), "mapTestTag", ToscaElementTypeEnum.MAP, new ArrayList<>());
+ void testMapTypeFindToscaElements() throws IOException {
+ Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(
+ (Map<String, Object>) loadJsonFromFile("normative-types-all-map-test.yml"), "mapTestTag", ToscaElementTypeEnum.MAP, new ArrayList<>());
assertTrue(toscaElements.isLeft());
List<Object> list = toscaElements.left().value();
assertEquals(2, list.size());
@@ -214,14 +236,14 @@ public class ImportUtilsTest {
}
@Test
- public void testCreateFullHeatParameterModuleWithString() {
+ void testCreateFullHeatParameterModuleWithString() {
testCreateFullHeatParameterModule("string", "default value");
}
@Test
- public void testCreateFullHeatParameterModuleWithNumber() {
+ void testCreateFullHeatParameterModuleWithNumber() {
testCreateFullHeatParameterModule("number", "777");
testCreateFullHeatParameterModule("number", "777.23");
@@ -229,7 +251,7 @@ public class ImportUtilsTest {
}
@Test
- public void testCreateFullHeatParameterModuleWithBoolean() {
+ void testCreateFullHeatParameterModuleWithBoolean() {
testCreateFullHeatParameterModule("boolean", "true");
testCreateFullHeatParameterModule("boolean", "on");
@@ -238,34 +260,14 @@ public class ImportUtilsTest {
}
@Test
- public void testCreateFullHeatParameterModuleWithList() {
+ void testCreateFullHeatParameterModuleWithList() {
testCreateFullHeatParameterModule("comma_delimited_list", "[one, two]");
}
- // @Test
- // public void testCreateFullHeatParameterModuleWithInvalidType(){
- //
- // String name = "fullParameter";
- // String description = "description_text";
- //
- // Map<String, Object> parametersMap = new HashMap<String, Object>();
- // Map<String, Object> firstParam = createParameterMap("aaa", "aaa",
- // name, description);
- // parametersMap.put(ToscaTagNamesEnum.PARAMETERS.getElementName(),
- // firstParam);
- //
- // Either<List<HeatParameterDefinition>,ResultStatusEnum> heatParameters =
- // ImportUtils.getHeatParameters(parametersMap);
- // assertTrue(heatParameters.isRight());
- // assertEquals(ResultStatusEnum.INVALID_PROPERTY_TYPE,
- // heatParameters.right().value());
- //
- // }
-
@Test
- public void testCreateFullHeatParameterModuleWithMissingType() {
+ void testCreateFullHeatParameterModuleWithMissingType() {
String name = "fullParameter";
String description = "description_text";
@@ -274,14 +276,15 @@ public class ImportUtilsTest {
Map<String, Object> firstParam = createParameterMap(null, "aaa", name, description);
parametersMap.put(TypeUtils.ToscaTagNamesEnum.PARAMETERS.getElementName(), firstParam);
- Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils.getHeatParameters(parametersMap, ArtifactTypeEnum.HEAT.getType());
+ Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils.getHeatParameters(parametersMap,
+ ArtifactTypeEnum.HEAT.getType());
assertTrue(heatParameters.isRight());
assertEquals(ResultStatusEnum.INVALID_PROPERTY_TYPE, heatParameters.right().value());
}
@Test
- public void testCreateFullHeatParameterModuleWithMissingFields() {
+ void testCreateFullHeatParameterModuleWithMissingFields() {
String name = "fullParameter";
@@ -292,7 +295,8 @@ public class ImportUtilsTest {
Map<String, Object> firstParam = createParameterMap(type, defValue, name, null);
parametersMap.put(TypeUtils.ToscaTagNamesEnum.PARAMETERS.getElementName(), firstParam);
- Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils.getHeatParameters(parametersMap, ArtifactTypeEnum.HEAT.getType());
+ Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils.getHeatParameters(parametersMap,
+ ArtifactTypeEnum.HEAT.getType());
assertTrue(heatParameters.isLeft());
List<HeatParameterDefinition> parameterDefList = heatParameters.left().value();
assertFalse(parameterDefList.isEmpty());
@@ -303,7 +307,7 @@ public class ImportUtilsTest {
}
@Test
- public void testGetPropertiesFromYml() throws IOException {
+ void testGetPropertiesFromYml() throws IOException {
Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaProperties.yml");
Either<Map<String, PropertyDefinition>, ResultStatusEnum> actualProperties = ImportUtils.getProperties(toscaJson);
@@ -314,7 +318,7 @@ public class ImportUtilsTest {
}
@Test
- public void testGetPropertiesWithConstraintsFromYml() throws IOException {
+ void testGetPropertiesWithConstraintsFromYml() throws IOException {
Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("propertyConstraintsTest.yml");
Either<Map<String, PropertyDefinition>, ResultStatusEnum> actualProperties = ImportUtils.getProperties(toscaJson);
@@ -322,7 +326,7 @@ public class ImportUtilsTest {
Map<String, PropertyDefinition> properties = actualProperties.left().value();
assertTrue(properties.containsKey("service_type"));
PropertyDefinition property = properties.get("service_type");
- assertTrue(property.getConstraints()!= null && property.getConstraints().size() == 1);
+ assertTrue(property.getConstraints() != null && property.getConstraints().size() == 1);
assertTrue(property.getConstraints().get(0) instanceof ValidValuesConstraint);
assertNotNull(((ValidValuesConstraint) property.getConstraints().get(0)).getValidValues());
List<String> validValues = ((ValidValuesConstraint) property.getConstraints().get(0)).getValidValues();
@@ -330,7 +334,7 @@ public class ImportUtilsTest {
assertTrue(properties.containsKey("service_interface_type_list"));
property = properties.get("service_interface_type_list");
- assertTrue(property.getSchema()!= null && property.getSchema().getProperty() != null);
+ assertTrue(property.getSchema() != null && property.getSchema().getProperty() != null);
PropertyDefinition innerProperty = new PropertyDefinition(property.getSchema().getProperty());
List<PropertyConstraint> innerConstraints = innerProperty.getConstraints();
assertTrue(innerConstraints.get(0) instanceof ValidValuesConstraint);
@@ -340,14 +344,14 @@ public class ImportUtilsTest {
}
@Test
- public void testGetInputsFromYml() throws IOException {
+ void testGetInputsFromYml() throws IOException {
- Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaInputs.yml");
+ Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaInputsOutputs.yml");
- AnnotationTypeOperations annotationTypeOperations= Mockito.mock(AnnotationTypeOperations.class);
+ AnnotationTypeOperations annotationTypeOperations = Mockito.mock(AnnotationTypeOperations.class);
Mockito.when(annotationTypeOperations.getLatestType(Mockito.anyString())).thenReturn(null);
- Either<Map<String, InputDefinition>, ResultStatusEnum> actualInputs = ImportUtils.getInputs(toscaJson,annotationTypeOperations);
+ Either<Map<String, InputDefinition>, ResultStatusEnum> actualInputs = ImportUtils.getInputs(toscaJson, annotationTypeOperations);
assertTrue(actualInputs.isLeft());
Map<String, Map<String, Object>> expectedProperties = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS);
compareProperties(expectedProperties, actualInputs.left().value());
@@ -358,7 +362,18 @@ public class ImportUtilsTest {
compareProperties(expectedProperties, actualInputs.left().value());
}
- private void compareAttributes(Map<String, Map<String, Object>> expected, Map<String, AttributeDataDefinition> actual) {
+ @Test
+ void testGetOutputsFromYml() throws IOException {
+
+ Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaInputsOutputs.yml");
+
+ Either<Map<String, OutputDefinition>, ResultStatusEnum> actualOutputs = ImportUtils.getOutputs(toscaJson);
+ assertTrue(actualOutputs.isLeft());
+ Map<String, Map<String, Object>> expectedProperties = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.OUTPUTS);
+ compareAttributes(expectedProperties, actualOutputs.left().value());
+ }
+
+ private void compareAttributes(Map<String, Map<String, Object>> expected, Map<String, OutputDefinition> actual) {
Map<String, Object> singleExpectedAttribute;
AttributeDataDefinition actualAttribute, expectedAttributeModel;
@@ -373,11 +388,11 @@ public class ImportUtilsTest {
expectedAttributeModel = ImportUtils.createModuleAttribute(singleExpectedAttribute);
expectedAttributeModel.setName(expectedAttribute.getKey().toString());
- assertEquals(((AttributeDefinition)expectedAttributeModel).getDefaultValue(), ((AttributeDefinition)actualAttribute).getDefaultValue());
- assertEquals(((AttributeDefinition)expectedAttributeModel).getDescription(), ((AttributeDefinition)actualAttribute).getDescription());
- assertEquals(((AttributeDefinition)expectedAttributeModel).getName(), ((AttributeDefinition)actualAttribute).getName());
- assertEquals(((AttributeDefinition)expectedAttributeModel).getStatus(), ((AttributeDefinition)actualAttribute).getStatus());
- assertEquals(((AttributeDefinition)expectedAttributeModel).getType(), ((AttributeDefinition)actualAttribute).getType());
+ assertEquals(((AttributeDefinition) expectedAttributeModel).getDefaultValue(), ((AttributeDefinition) actualAttribute).getDefaultValue());
+ assertEquals(((AttributeDefinition) expectedAttributeModel).getDescription(), ((AttributeDefinition) actualAttribute).getDescription());
+ assertEquals(((AttributeDefinition) expectedAttributeModel).getName(), ((AttributeDefinition) actualAttribute).getName());
+ assertEquals(((AttributeDefinition) expectedAttributeModel).getStatus(), ((AttributeDefinition) actualAttribute).getStatus());
+ assertEquals(((AttributeDefinition) expectedAttributeModel).getType(), ((AttributeDefinition) actualAttribute).getType());
compareSchemas(expectedAttributeModel.getSchema(), actualAttribute.getSchema());
@@ -385,7 +400,7 @@ public class ImportUtilsTest {
}
- private void compareProperties(Map<String, Map<String, Object>> expected, Map<String, ? extends PropertyDefinition > actual) {
+ private void compareProperties(Map<String, Map<String, Object>> expected, Map<String, ? extends PropertyDefinition> actual) {
Map<String, Object> singleExpectedProperty;
PropertyDefinition actualProperty, expectedPropertyModel;
@@ -444,7 +459,8 @@ public class ImportUtilsTest {
Map<String, Object> firstParam = createParameterMap(type, defaultVal, name, description);
parametersMap.put(TypeUtils.ToscaTagNamesEnum.PARAMETERS.getElementName(), firstParam);
- Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils.getHeatParameters(parametersMap, ArtifactTypeEnum.HEAT.getType());
+ Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils.getHeatParameters(parametersMap,
+ ArtifactTypeEnum.HEAT.getType());
assertTrue(heatParameters.isLeft());
List<HeatParameterDefinition> parameterDefList = heatParameters.left().value();
assertFalse(parameterDefList.isEmpty());
@@ -532,26 +548,4 @@ public class ImportUtilsTest {
assertEquals("stringVal2", innerEntry.getValue());
}
- public static String loadFileNameToJsonString(String fileName) throws IOException {
- String sourceDir = "src/test/resources/normativeTypes";
- return loadFileNameToJsonString(sourceDir, fileName);
- }
-
- public static String loadCustomTypeFileNameToJsonString(String fileName) throws IOException {
- String sourceDir = "src/test/resources/customTypes";
- return loadFileNameToJsonString(sourceDir, fileName);
- }
-
- private static String loadFileNameToJsonString(String sourceDir, String fileName) throws IOException {
- java.nio.file.Path filePath = FileSystems.getDefault().getPath(sourceDir, fileName);
- byte[] fileContent = Files.readAllBytes(filePath);
- return new String(fileContent);
- }
-
-
- private static Object loadJsonFromFile(String fileName) throws IOException {
- String content = loadFileNameToJsonString(fileName);
- return new Yaml().load(content);
- }
-
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java
index 9c7e3848c6..cfdd774f67 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogicTest.java
@@ -20,10 +20,13 @@
package org.openecomp.sdc.be.components.impl;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -31,11 +34,13 @@ import static org.mockito.Mockito.when;
import fj.data.Either;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import javax.ws.rs.core.Response.Status;
import org.apache.commons.collections.CollectionUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -48,18 +53,19 @@ import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.validation.UserValidations;
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.janusgraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.ComponentInstOutputsMap;
import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceOutput;
import org.openecomp.sdc.be.model.ComponentInstanceAttribOutput;
+import org.openecomp.sdc.be.model.ComponentInstanceOutput;
import org.openecomp.sdc.be.model.ComponentParametersView;
-import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
@@ -92,31 +98,24 @@ class OutputsBusinessLogicTest {
@Mock
private ComponentsUtils componentsUtilsMock;
-
@Mock
private UserBusinessLogic userAdminMock;
-
@Mock
private ToscaOperationFacade toscaOperationFacadeMock;
-
@Mock
private UserValidations userValidations;
-
@Mock
private IGraphLockOperation graphLockOperation;
-
@Mock
private AttributeDeclarationOrchestrator attributeDeclarationOrchestrator;
-
@Mock
private ApplicationDataTypeCache applicationDataTypeCache;
-
@Mock
private AttributeOperation attributeOperation;
-
@Mock
private JanusGraphDao janusGraphDao;
-
+ @Mock
+ private ResponseFormatManager responseFormatManager;
@InjectMocks
private OutputsBusinessLogic testInstance;
@@ -126,7 +125,7 @@ class OutputsBusinessLogicTest {
private List<ComponentInstanceOutput> outputsList;
@BeforeEach
- public void setUp() {
+ void setUp() {
MockitoAnnotations.openMocks(this);
service = new Service();
service.setUniqueId(COMPONENT_ID);
@@ -145,6 +144,10 @@ class OutputsBusinessLogicTest {
// add a ComponentInstance
final ComponentInstance componentInstance = new ComponentInstance();
componentInstance.setUniqueId(COMPONENT_INSTANCE_ID);
+ componentInstance.setName(COMPONENT_INSTANCE_ID);
+ final AttributeDefinition attributeDefinition = new AttributeDefinition();
+ attributeDefinition.setName("attribName");
+ componentInstance.setAttributes(Collections.singletonList(attributeDefinition));
service.setComponentInstances(Collections.singletonList(componentInstance));
instanceOutputMap = new HashMap<>();
@@ -235,10 +238,8 @@ class OutputsBusinessLogicTest {
}
private void initMockitoStubbings(List<OutputDefinition> declaredPropertiesToOutputs) {
- when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(
- Either.left(service));
- when(attributeDeclarationOrchestrator.declareAttributesToOutputs(any(), any())).thenReturn(Either.left(
- declaredPropertiesToOutputs));
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
+ when(attributeDeclarationOrchestrator.declareAttributesToOutputs(any(), any())).thenReturn(Either.left(declaredPropertiesToOutputs));
when(toscaOperationFacadeMock.addOutputsToComponent(any(), any())).thenReturn(Either.left(declaredPropertiesToOutputs));
when(janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
@@ -299,8 +300,7 @@ class OutputsBusinessLogicTest {
service.setOutputs(Collections.singletonList(listOutput));
final String NONEXIST_OUTPUT_NAME = "myOutput";
- when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
- .thenReturn(Either.left(service));
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
try {
testInstance.deleteOutput(COMPONENT_ID, USER_ID, NONEXIST_OUTPUT_NAME);
@@ -319,8 +319,7 @@ class OutputsBusinessLogicTest {
listOutput.setUniqueId(outputId);
service.setOutputs(Collections.singletonList(listOutput));
- when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
- .thenReturn(Either.left(service));
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.NOT_FOUND);
when(componentsUtilsMock.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND, ComponentTypeEnum.SERVICE))
.thenReturn(ActionStatus.SERVICE_NOT_FOUND);
@@ -343,8 +342,7 @@ class OutputsBusinessLogicTest {
listOutput.setUniqueId(outputId);
service.setOutputs(Collections.singletonList(listOutput));
- when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
- .thenReturn(Either.left(service));
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacadeMock.deleteOutputOfResource(service, listOutput.getName())).thenReturn(StorageOperationStatus.BAD_REQUEST);
when(componentsUtilsMock.convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST)).thenReturn(ActionStatus.INVALID_CONTENT);
@@ -368,8 +366,7 @@ class OutputsBusinessLogicTest {
listOutput.setUniqueId(outputId);
service.setOutputs(Collections.singletonList(listOutput));
- when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
- .thenReturn(Either.left(service));
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacadeMock.deleteOutputOfResource(service, listOutput.getName())).thenReturn(StorageOperationStatus.OK);
when(attributeDeclarationOrchestrator.unDeclareAttributesAsOutputs(service, listOutput)).thenReturn(StorageOperationStatus.BAD_REQUEST);
@@ -392,8 +389,7 @@ class OutputsBusinessLogicTest {
listOutput.setUniqueId(outputId);
service.setOutputs(Collections.singletonList(listOutput));
- when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
- .thenReturn(Either.left(service));
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacadeMock.deleteOutputOfResource(service, listOutput.getName())).thenReturn(StorageOperationStatus.OK);
when(attributeDeclarationOrchestrator.unDeclareAttributesAsOutputs(service, listOutput)).thenReturn(StorageOperationStatus.OK);
@@ -402,4 +398,69 @@ class OutputsBusinessLogicTest {
verify(attributeDeclarationOrchestrator, times(1)).unDeclareAttributesAsOutputs(service, listOutput);
}
+ @Test
+ void testCreateOutputsInGraph_OK() {
+ final Map<String, OutputDefinition> outputs = new HashMap<>();
+ final var out_1 = new OutputDefinition();
+ out_1.setName("out-1");
+ out_1.setValue("{ get_attribute: [ instanceId, attribName ] }");
+ final var out_2 = new OutputDefinition();
+ out_2.setName("out-2");
+ out_2.setValue("{ get_attribute: [ SELF, oneMoreAttribute ] }");
+ outputs.put(out_1.getName(), out_1);
+ outputs.put(out_2.getName(), out_2);
+
+ final List<OutputDefinition> serviceOutputs = new ArrayList<>();
+ final var out_3 = new OutputDefinition();
+ out_3.setName("out-3");
+ serviceOutputs.add(out_3);
+ service.setOutputs(serviceOutputs);
+
+ final List<OutputDefinition> list = Arrays.asList(out_1, out_2, out_3);
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
+ when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
+ when(attributeDeclarationOrchestrator.declareAttributesToOutputs(eq(service), any(ComponentInstOutputsMap.class)))
+ .thenReturn(Either.left(list));
+ when(toscaOperationFacadeMock.addOutputsToComponent(anyMap(), anyString())).thenReturn(Either.left(list));
+
+ final var result = testInstance.createOutputsInGraph(outputs, service, USER_ID);
+ assertTrue(result.isLeft());
+ assertEquals(3, result.left().value().size());
+ assertEquals(list, result.left().value());
+ }
+
+ @Test
+ void testCreateOutputsInGraph_NegativeCreateAndAssociateOutputsStatus() {
+ final Map<String, OutputDefinition> outputs = new HashMap<>();
+ final var out_1 = new OutputDefinition();
+ out_1.setName("out-1");
+ out_1.setValue("{ get_attribute: [ instanceId, attribName ] }");
+ final var out_2 = new OutputDefinition();
+ out_2.setName("out-2");
+ out_2.setValue("{ get_attribute: [ SELF, oneMoreAttribute ] }");
+ outputs.put(out_1.getName(), out_1);
+ outputs.put(out_2.getName(), out_2);
+
+ final List<OutputDefinition> serviceOutputs = new ArrayList<>();
+ final var out_3 = new OutputDefinition();
+ out_3.setName("out-3");
+ serviceOutputs.add(out_3);
+ service.setOutputs(serviceOutputs);
+
+ final var list = Arrays.asList(out_1, out_2, out_3);
+ when(toscaOperationFacadeMock.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class))).thenReturn(Either.left(service));
+ when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
+ when(attributeDeclarationOrchestrator.declareAttributesToOutputs(eq(service), any(ComponentInstOutputsMap.class)))
+ .thenReturn(Either.left(list));
+ when(toscaOperationFacadeMock.addOutputsToComponent(anyMap(), eq(COMPONENT_ID)))
+ .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
+ when(componentsUtilsMock.convertFromStorageResponse(StorageOperationStatus.GENERAL_ERROR)).thenReturn(ActionStatus.GENERAL_ERROR);
+ when(componentsUtilsMock.getResponseFormat(StorageOperationStatus.GENERAL_ERROR))
+ .thenReturn(new ResponseFormat(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
+
+ final var result = testInstance.createOutputsInGraph(outputs, service, USER_ID);
+ assertNotNull(result);
+ assertTrue(result.isRight());
+ assertEquals(500, result.right().value().getStatus());
+ }
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
index 1d6a3ff673..dcc0289822 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.anyMap;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.openecomp.sdc.be.components.impl.ServiceImportBusinessLogic.CREATE_RESOURCE;
@@ -50,7 +51,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.components.csar.CsarInfo;
import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
@@ -108,18 +108,15 @@ import org.openecomp.sdc.exception.ResponseFormat;
class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTestSetup {
- @InjectMocks
- private ServiceImportBusinessLogic sIBL;
-
- @Mock
- private ArtifactDefinition artifactDefinition;
- @Mock
- private ServletUtils servletUtils;
- @Mock
- private ResourceImportManager resourceImportManager;
+ private static final String DEFAULT_ICON = "defaulticon";
- private AbstractValidationsServlet servlet = new ArtifactExternalServlet(userBusinessLogic,
+ private final ArtifactDefinition artifactDefinition = mock(ArtifactDefinition.class);
+ private final ResourceImportManager resourceImportManager = mock(ResourceImportManager.class);
+ private final ServletUtils servletUtils = mock(ServletUtils.class);
+ private final AbstractValidationsServlet servlet = new ArtifactExternalServlet(userBusinessLogic,
componentInstanceBusinessLogic, componentsUtils, servletUtils, resourceImportManager, artifactsBusinessLogic);
+ @InjectMocks
+ private ServiceImportBusinessLogic sIBL;
public static String loadFileNameToJsonString(String fileName) throws IOException {
String sourceDir = "src/test/resources/normativeTypes";
@@ -185,6 +182,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
when(serviceImportParseLogic.getServiceWithGroups(anyString())).thenReturn(newService);
when(mockJanusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
when(graphLockOperation.unlockComponentByName(anyString(), anyString(), any(NodeTypeEnum.class))).thenReturn(StorageOperationStatus.OK);
+ when(serviceImportParseLogic.createOutputsOnService(any(Service.class), any(), anyString())).thenReturn(newService);
Service result = sIBL.createService(oldService, AuditingActionEnum.CREATE_RESOURCE, user, payload, payloadName);
assertNotNull(result);
@@ -259,7 +257,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceFromYaml(oldService,
topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo,
- nodeTypesArtifactsToCreate, false, true, nodeName));
+ nodeTypesArtifactsToCreate, false, true, nodeName, user.getUserId()));
}
@Test
@@ -278,7 +276,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo);
when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(resource));
Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceAndRIsFromYaml(oldService,
- false, nodeTypesArtifactsToCreate, false, true, csfyp));
+ false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId()));
}
@Test
@@ -297,7 +295,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo);
when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(resource));
Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceAndRIsFromYaml(oldService,
- false, nodeTypesArtifactsToCreate, false, true, csfyp));
+ false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId()));
}
@Test
@@ -749,21 +747,26 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
void testCreateGroupsOnResourceNull() {
Service service = createServiceObject(true);
Map<String, GroupDefinition> groups = new HashMap<>();
- Assertions.assertNotNull(sIBL.createGroupsOnResource(service, groups));
+ Assertions.assertNotNull(
+ sIBL.createGroupsOnResource(service, groups));
}
@Test
void testUpdateGroupsMembersUsingResource() {
Service service = createServiceObject(true);
Map<String, GroupDefinition> groups = getGroups();
- Assertions.assertNotNull(sIBL.updateGroupsMembersUsingResource(groups, service));
+
+ Assertions.assertNotNull(
+ sIBL.updateGroupsMembersUsingResource(groups, service));
}
@Test
void testUpdateGroupsMembersUsingResource_left() {
Service service = createServiceObject(true);
Map<String, GroupDefinition> groups = getGroups();
- Assertions.assertNotNull(sIBL.updateGroupsMembersUsingResource(groups, service));
+
+ Assertions.assertNotNull(
+ sIBL.updateGroupsMembersUsingResource(groups, service));
}
@Test
@@ -1881,7 +1884,9 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
groupDefinition.setUniqueId("groupDefinitionUniqueId");
groupDefinition.setName("groupDefinition");
groupDefinitionList.add(groupDefinition);
- Assertions.assertNotNull(sIBL.createGroupsOnResource(resource, groups));
+
+ Assertions.assertNotNull(
+ sIBL.createGroupsOnResource(resource, groups));
}
@Test
@@ -1897,14 +1902,18 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
void testUpdateGroupsMembersUsingResource2() {
Resource resource = createParseResourceObject(true);
Map<String, GroupDefinition> groups = getGroups();
- Assertions.assertNotNull(sIBL.updateGroupsMembersUsingResource(groups, resource));
+
+ Assertions.assertNotNull(
+ sIBL.updateGroupsMembersUsingResource(groups, resource));
}
@Test
void testUpdateGroupsMembersUsingResource_left2() {
Resource resource = createParseResourceObject(true);
Map<String, GroupDefinition> groups = getGroups();
- Assertions.assertNotNull(sIBL.updateGroupsMembersUsingResource(groups, resource));
+
+ Assertions.assertNotNull(
+ sIBL.updateGroupsMembersUsingResource(groups, resource));
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
index 8ff8163128..beaa695fe4 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
@@ -20,6 +20,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import fj.data.Either;
@@ -43,15 +44,8 @@ import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.components.csar.CsarArtifactsAndGroupsBusinessLogic;
import org.openecomp.sdc.be.components.csar.CsarBusinessLogic;
import org.openecomp.sdc.be.components.csar.CsarInfo;
-import org.openecomp.sdc.be.components.distribution.engine.DistributionEngine;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
-import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
import org.openecomp.sdc.be.components.impl.utils.CreateServiceFromYamlParameter;
-import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
-import org.openecomp.sdc.be.components.merge.resource.ResourceDataMergeBusinessLogic;
-import org.openecomp.sdc.be.components.path.ForwardingPathValidator;
-import org.openecomp.sdc.be.components.validation.NodeFilterValidator;
-import org.openecomp.sdc.be.components.validation.ServiceDistributionValidation;
import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.components.validation.component.ComponentContactIdValidator;
import org.openecomp.sdc.be.components.validation.component.ComponentDescriptionValidator;
@@ -71,9 +65,7 @@ import org.openecomp.sdc.be.components.validation.service.ServiceRoleValidator;
import org.openecomp.sdc.be.components.validation.service.ServiceTypeValidator;
import org.openecomp.sdc.be.components.validation.service.ServiceValidator;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
-import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -85,6 +77,7 @@ import org.openecomp.sdc.be.externalapi.servlet.representation.ReplaceVNFInfo;
import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceInstanceMetadata;
import org.openecomp.sdc.be.facade.operations.CatalogOperation;
import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.impl.ServletUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
@@ -105,7 +98,6 @@ import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.UploadServiceInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -133,36 +125,29 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM
private static final String RESOURCE_TOSCA_NAME = "My-Resource_Tosca_Name";
private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
private static final String RESOURCE_SUBCATEGORY = "Router";
- protected final ServletContext servletContext = Mockito.mock(ServletContext.class);
- protected final ComponentValidator componentValidator = Mockito.mock(ComponentValidator.class);
- final DistributionEngine distributionEngine = Mockito.mock(DistributionEngine.class);
- final ServiceDistributionValidation serviceDistributionValidation = Mockito.mock(ServiceDistributionValidation.class);
- final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
- final ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class);
- final UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
- final NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class);
- final NodeFilterValidator serviceFilterValidator = Mockito.mock(NodeFilterValidator.class);
- // final ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
- final CsarBusinessLogic csarBusinessLogic = Mockito.mock(CsarBusinessLogic.class);
- final LifecycleBusinessLogic lifecycleBusinessLogic = Mockito.mock(LifecycleBusinessLogic.class);
- final CompositionBusinessLogic compositionBusinessLogic = Mockito.mock(CompositionBusinessLogic.class);
- final ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic = Mockito.mock(ResourceDataMergeBusinessLogic.class);
- final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic = Mockito.mock(ComponentNodeFilterBusinessLogic.class);
- protected UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
- protected WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
- protected WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
+
+ private final ArtifactDefinition artifactDefinition = mock(ArtifactDefinition.class);
+ private final ResourceImportManager resourceImportManager = mock(ResourceImportManager.class);
+ private final ServletUtils servletUtils = mock(ServletUtils.class);
+
+ protected final ServletContext servletContext = mock(ServletContext.class);
+ protected final ComponentValidator componentValidator = mock(ComponentValidator.class);
+ final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = mock(ComponentInstanceBusinessLogic.class);
+ final CsarBusinessLogic csarBusinessLogic = mock(CsarBusinessLogic.class);
+ final CompositionBusinessLogic compositionBusinessLogic = mock(CompositionBusinessLogic.class);
+ protected UserBusinessLogic userBusinessLogic = mock(UserBusinessLogic.class);
+ protected WebAppContextWrapper webAppContextWrapper = mock(WebAppContextWrapper.class);
+ protected WebApplicationContext webAppContext = mock(WebApplicationContext.class);
protected ResponseFormatManager responseManager = null;
- protected ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
- protected AuditCassandraDao auditingDao = Mockito.mock(AuditCassandraDao.class);
- protected ArtifactsBusinessLogic artifactsBusinessLogic = Mockito.mock(ArtifactsBusinessLogic.class);
- protected GraphLockOperation graphLockOperation = Mockito.mock(GraphLockOperation.class);
- protected JanusGraphDao mockJanusGraphDao = Mockito.mock(JanusGraphDao.class);
- protected ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
- protected CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic = Mockito.mock(CsarArtifactsAndGroupsBusinessLogic.class);
- protected GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
- protected UserValidations userValidations = Mockito.mock(UserValidations.class);
- protected CatalogOperation catalogOperation = Mockito.mock(CatalogOperation.class);
- protected ServiceImportParseLogic serviceImportParseLogic = Mockito.mock(ServiceImportParseLogic.class);
+ protected ComponentsUtils componentsUtils = mock(ComponentsUtils.class);
+ protected ArtifactsBusinessLogic artifactsBusinessLogic = mock(ArtifactsBusinessLogic.class);
+ protected GraphLockOperation graphLockOperation = mock(GraphLockOperation.class);
+ protected JanusGraphDao mockJanusGraphDao = mock(JanusGraphDao.class);
+ protected ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
+ protected CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic = mock(CsarArtifactsAndGroupsBusinessLogic.class);
+ protected UserValidations userValidations = mock(UserValidations.class);
+ protected CatalogOperation catalogOperation = mock(CatalogOperation.class);
+ protected ServiceImportParseLogic serviceImportParseLogic = mock(ServiceImportParseLogic.class);
protected ServiceTypeValidator serviceTypeValidator = new ServiceTypeValidator(componentsUtils);
protected ServiceRoleValidator serviceRoleValidator = new ServiceRoleValidator(componentsUtils);
protected ServiceFunctionValidator serviceFunctionValidator = new ServiceFunctionValidator(componentsUtils);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
index 0306ce082e..c564f59398 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
@@ -17,8 +17,11 @@
package org.openecomp.sdc.be.components.impl;
import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -43,6 +46,7 @@ import java.util.Map.Entry;
import java.util.NoSuchElementException;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.glassfish.grizzly.http.util.HttpStatus;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -77,6 +81,7 @@ 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;
+import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
import org.openecomp.sdc.be.model.RequirementDefinition;
@@ -118,6 +123,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
private final IElementOperation elementDao = mock(IElementOperation.class);
private final IInterfaceLifecycleOperation interfaceTypeOperation = mock(IInterfaceLifecycleOperation.class);
private final InputsBusinessLogic inputsBusinessLogic = mock(InputsBusinessLogic.class);
+ private final OutputsBusinessLogic outputsBusinessLogic = mock(OutputsBusinessLogic.class);
private final LifecycleBusinessLogic lifecycleBusinessLogic = mock(LifecycleBusinessLogic.class);
private final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic = mock(ComponentNodeFilterBusinessLogic.class);
@@ -128,7 +134,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
private ServiceImportParseLogic createTestSubject() {
return new ServiceImportParseLogic(serviceBusinessLogic, componentsUtils, toscaOperationFacade, lifecycleBusinessLogic, inputsBusinessLogic,
null, null, interfaceTypeOperation, capabilityTypeOperation, componentNodeFilterBusinessLogic,
- groupBusinessLogic);
+ groupBusinessLogic, outputsBusinessLogic);
}
@BeforeEach
@@ -1130,6 +1136,77 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
}
@Test
+ void testCreateOutputsOnService_OK() {
+ Service service = createServiceObject(true);
+ List<OutputDefinition> resourceOutputs = new ArrayList<>();
+ OutputDefinition outputDefinition = new OutputDefinition();
+ resourceOutputs.add(outputDefinition);
+ outputDefinition.setName("outputDefinitionName");
+ service.setOutputs(resourceOutputs);
+ Map<String, OutputDefinition> outputs = new HashMap<>();
+ outputs.put("outputsMap", outputDefinition);
+
+ when(outputsBusinessLogic.createOutputsInGraph(outputs, service, user.getUserId())).thenReturn(Either.left(resourceOutputs));
+ when(toscaOperationFacade.getToscaElement(service.getUniqueId())).thenReturn(Either.left(service));
+ Service outputsOnService = testSubject.createOutputsOnService(service, outputs, user.getUserId());
+ assertNotNull(outputsOnService);
+ assertSame(service, outputsOnService);
+ }
+
+ @Test
+ void testCreateOutputsOnService_Fail_whenOutputsIsEmpty() {
+ Service service = createServiceObject(true);
+ Map<String, OutputDefinition> outputs = new HashMap<>();
+ Service outputsOnService = testSubject.createOutputsOnService(service, outputs, user.getUserId());
+ assertNotNull(outputsOnService);
+ assertSame(service, outputsOnService);
+ }
+
+ @Test
+ void testCreateOutputsOnService_Fail_createOutputsInGraph() {
+ Service service = createServiceObject(true);
+ List<OutputDefinition> resourceOutputs = new ArrayList<>();
+ OutputDefinition outputDefinition = new OutputDefinition();
+ resourceOutputs.add(outputDefinition);
+ outputDefinition.setName("outputDefinitionName");
+ service.setOutputs(resourceOutputs);
+ Map<String, OutputDefinition> outputs = new HashMap<>();
+ outputs.put("outputsMap", outputDefinition);
+
+ when(outputsBusinessLogic.createOutputsInGraph(outputs, service, user.getUserId()))
+ .thenReturn(Either.right(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode())));
+
+ final var componentException = assertThrows(ComponentException.class, () -> {
+ testSubject.createOutputsOnService(service, outputs, user.getUserId());
+ });
+ assertNotNull(componentException);
+ assertEquals(ActionStatus.OK, componentException.getActionStatus());
+ assertEquals(400, componentException.getResponseFormat().getStatus());
+ }
+
+ @Test
+ void testCreateOutputsOnService_Fail_getToscaElement() {
+ Service service = createServiceObject(true);
+ List<OutputDefinition> resourceOutputs = new ArrayList<>();
+ OutputDefinition outputDefinition = new OutputDefinition();
+ resourceOutputs.add(outputDefinition);
+ outputDefinition.setName("outputDefinitionName");
+ service.setOutputs(resourceOutputs);
+ Map<String, OutputDefinition> outputs = new HashMap<>();
+ outputs.put("outputsMap", outputDefinition);
+
+ when(outputsBusinessLogic.createOutputsInGraph(outputs, service, user.getUserId())).thenReturn(Either.left(resourceOutputs));
+ when(toscaOperationFacade.getToscaElement(service.getUniqueId())).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+
+ final var componentException = assertThrows(ComponentException.class, () -> {
+ testSubject.createOutputsOnService(service, outputs, user.getUserId());
+ });
+ assertNotNull(componentException);
+ assertEquals(ActionStatus.OK, componentException.getActionStatus());
+ assertEquals(400, componentException.getResponseFormat().getStatus());
+ }
+
+ @Test
void testAssociateCINodeFilterToComponent() {
String yamlName = "yamlName.yml";
Service service = createServiceObject(true);
diff --git a/catalog-be/src/test/resources/normativeTypes/importToscaInputs.yml b/catalog-be/src/test/resources/normativeTypes/importToscaInputsOutputs.yml
index 9fac2fb2c7..83deccb333 100644
--- a/catalog-be/src/test/resources/normativeTypes/importToscaInputs.yml
+++ b/catalog-be/src/test/resources/normativeTypes/importToscaInputsOutputs.yml
@@ -11,28 +11,28 @@ metadata:
resourceVendorRelease: 1.0.0.wd03
resourceVendorModelNumber: '666'
imports:
-- nodes:
- file: nodes.yml
-- datatypes:
- file: data.yml
-- capabilities:
- file: capabilities.yml
-- relationships:
- file: relationships.yml
-- groups:
- file: groups.yml
-- policies:
- file: policies.yml
-- annotations:
- file: annotations.yml
-- resource-ciResVFOnboarded-base_vfw-aa8dcbff-nodes.vpgCvfc-interface:
- file: resource-CiresvfonboardedBaseVfwAa8dcbffNodesVpgcvfc-template-interface.yml
-- resource-CiresvfonboardedBaseVfwAa8dcbff.compute.nodes.heat.vpg:
- file: resource-Ciresvfonboardedbasevfwaa8dcbffComputeNodesHeatVpg-template.yml
-- resource-NeutronPort:
- file: resource-Neutronport-template.yml
-- resource-extNeutronCP:
- file: resource-Extneutroncp-template.yml
+ - nodes:
+ file: nodes.yml
+ - datatypes:
+ file: data.yml
+ - capabilities:
+ file: capabilities.yml
+ - relationships:
+ file: relationships.yml
+ - groups:
+ file: groups.yml
+ - policies:
+ file: policies.yml
+ - annotations:
+ file: annotations.yml
+ - resource-ciResVFOnboarded-base_vfw-aa8dcbff-nodes.vpgCvfc-interface:
+ file: resource-CiresvfonboardedBaseVfwAa8dcbffNodesVpgcvfc-template-interface.yml
+ - resource-CiresvfonboardedBaseVfwAa8dcbff.compute.nodes.heat.vpg:
+ file: resource-Ciresvfonboardedbasevfwaa8dcbffComputeNodesHeatVpg-template.yml
+ - resource-NeutronPort:
+ file: resource-Neutronport-template.yml
+ - resource-extNeutronCP:
+ file: resource-Extneutroncp-template.yml
topology_template:
inputs:
port_vpg_private_1_port_network:
@@ -201,6 +201,25 @@ topology_template:
port_vpg_private_0_port_order:
type: integer
required: false
+ outputs:
+ vpg_state:
+ value:
+ get_attribute:
+ - vpg
+ - state
+ type: string
+ vpg_vpg_private_0_port_tosca_name:
+ value:
+ get_attribute:
+ - vpg_vpg_private_0_port_tosca
+ - tosca_name
+ type: string
+ vpg_vpg_private_1_port_tosca_id:
+ value:
+ get_attribute:
+ - vpg_vpg_private_1_port
+ - tosca_id
+ type: string
node_templates:
vpg_vpg_private_0_port:
type: org.openecomp.resource.cp.nodes.heat.network.neutron.Port
@@ -225,8 +244,8 @@ topology_template:
get_input: port_vpg_private_0_port_related_networks
network:
get_input:
- - port_vpg_private_0_port_network
- - index_value
+ - port_vpg_private_0_port_network
+ - index_value
replacement_policy: AUTO
ip_requirements:
get_input: port_vpg_private_0_port_ip_requirements
@@ -234,8 +253,8 @@ topology_template:
get_input: port_vpg_private_0_port_network_role
fixed_ips:
get_input:
- - port_vpg_private_0_port_fixed_ips
- - index_value
+ - port_vpg_private_0_port_fixed_ips
+ - index_value
subinterface_indicator: false
mac_requirements:
get_input: port_vpg_private_0_port_mac_requirements
@@ -249,9 +268,9 @@ topology_template:
order:
get_input: port_vpg_private_0_port_order
requirements:
- - binding:
- capability: binding
- node: vpg
+ - binding:
+ capability: binding
+ node: vpg
capabilities:
network.outgoing.bytes.rate_vpg_vpg_private_0_port:
properties:
@@ -301,6 +320,9 @@ topology_template:
description: Number of incoming packets
type: Cumulative
category: network
+ attributes:
+ tosca_name:
+ type: string
vpg_vpg_private_1_port:
type: org.openecomp.resource.cp.v2.extNeutronCP
metadata:
@@ -324,8 +346,8 @@ topology_template:
get_input: port_vpg_private_1_port_related_networks
network:
get_input:
- - port_vpg_private_1_port_network
- - index_value
+ - port_vpg_private_1_port_network
+ - index_value
replacement_policy: AUTO
ip_requirements:
get_input: port_vpg_private_1_port_ip_requirements
@@ -333,8 +355,8 @@ topology_template:
get_input: port_vpg_private_1_port_network_role
fixed_ips:
get_input:
- - port_vpg_private_1_port_fixed_ips
- - index_value
+ - port_vpg_private_1_port_fixed_ips
+ - index_value
subinterface_indicator: false
mac_requirements:
get_input: port_vpg_private_1_port_mac_requirements
@@ -348,9 +370,9 @@ topology_template:
order:
get_input: port_vpg_private_1_port_order
requirements:
- - binding:
- capability: binding
- node: vpg
+ - binding:
+ capability: binding
+ node: vpg
capabilities:
network.incoming.bytes.rate_vpg_vpg_private_1_port:
properties:
@@ -406,6 +428,9 @@ topology_template:
description: Number of incoming bytes
type: Cumulative
category: network
+ attributes:
+ tosca_id:
+ type: string
vpg:
type: org.openecomp.resource.vfc.CiresvfonboardedBaseVfwAa8dcbff.abstract.compute.nodes.heat.vpg
metadata:
@@ -426,26 +451,26 @@ topology_template:
get_input: vm_flavor_name
key_name:
get_input:
- - compute_vpg_key_name
- - index_value
+ - compute_vpg_key_name
+ - index_value
image:
get_input: vm_image_name
image_update_policy: REBUILD
metadata:
get_input:
- - compute_vpg_metadata
- - index_value
+ - compute_vpg_metadata
+ - index_value
software_config_transport: POLL_SERVER_CFN
contrail_service_instance_ind: false
user_data_format:
get_input:
- - compute_vpg_user_data_format
- - index_value
+ - compute_vpg_user_data_format
+ - index_value
user_data_update_policy: REPLACE
name:
get_input:
- - compute_vpg_name
- - index_value
+ - compute_vpg_name
+ - index_value
flavor_update_policy: RESIZE
capabilities:
disk.read.bytes_vpg:
@@ -665,223 +690,226 @@ topology_template:
description: Average disk latency
type: Gauge
category: disk
+ attributes:
+ state:
+ type: string
substitution_mappings:
node_type: org.openecomp.resource.vfc.CiresvfonboardedBaseVfwAa8dcbffcvfc.abstract.nodes.vpg
capabilities:
network.incoming.bytes.rate_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - network.incoming.bytes.rate
+ - vpg_vpg_private_1_port
+ - network.incoming.bytes.rate
disk.read.bytes_vpg:
- - vpg
- - disk.read.bytes
+ - vpg
+ - disk.read.bytes
binding_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - binding
+ - vpg_vpg_private_1_port
+ - binding
network.outgoing.bytes.rate_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - network.outgoing.bytes.rate
+ - vpg_vpg_private_0_port
+ - network.outgoing.bytes.rate
forwarder_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - forwarder
+ - vpg_vpg_private_0_port
+ - forwarder
disk.allocation_vpg:
- - vpg
- - disk.allocation
+ - vpg
+ - disk.allocation
network.incoming.bytes_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - network.incoming.bytes
+ - vpg_vpg_private_1_port
+ - network.incoming.bytes
attachment_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - attachment
+ - vpg_vpg_private_0_port
+ - attachment
endpoint_vpg:
- - vpg
- - endpoint
+ - vpg
+ - endpoint
cpu_vpg:
- - vpg
- - cpu
+ - vpg
+ - cpu
disk.device.read.bytes.rate_vpg:
- - vpg
- - disk.device.read.bytes.rate
+ - vpg
+ - disk.device.read.bytes.rate
network.outgoing.bytes.rate_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - network.outgoing.bytes.rate
+ - vpg_vpg_private_1_port
+ - network.outgoing.bytes.rate
feature_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - feature
+ - vpg_vpg_private_1_port
+ - feature
disk.device.write.bytes.rate_vpg:
- - vpg
- - disk.device.write.bytes.rate
+ - vpg
+ - disk.device.write.bytes.rate
attachment_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - attachment
+ - vpg_vpg_private_1_port
+ - attachment
disk.iops_vpg:
- - vpg
- - disk.iops
+ - vpg
+ - disk.iops
disk.usage_vpg:
- - vpg
- - disk.usage
+ - vpg
+ - disk.usage
disk.device.usage_vpg:
- - vpg
- - disk.device.usage
+ - vpg
+ - disk.device.usage
disk.device.read.bytes_vpg:
- - vpg
- - disk.device.read.bytes
+ - vpg
+ - disk.device.read.bytes
disk.device.write.bytes_vpg:
- - vpg
- - disk.device.write.bytes
+ - vpg
+ - disk.device.write.bytes
disk.write.requests_vpg:
- - vpg
- - disk.write.requests
+ - vpg
+ - disk.write.requests
feature_vpg:
- - vpg
- - feature
+ - vpg
+ - feature
disk.capacity_vpg:
- - vpg
- - disk.capacity
+ - vpg
+ - disk.capacity
disk.device.latency_vpg:
- - vpg
- - disk.device.latency
+ - vpg
+ - disk.device.latency
disk.device.write.requests.rate_vpg:
- - vpg
- - disk.device.write.requests.rate
+ - vpg
+ - disk.device.write.requests.rate
feature_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - feature
+ - vpg_vpg_private_0_port
+ - feature
forwarder_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - forwarder
+ - vpg_vpg_private_1_port
+ - forwarder
network.outgoing.packets.rate_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - network.outgoing.packets.rate
+ - vpg_vpg_private_1_port
+ - network.outgoing.packets.rate
network.incoming.packets.rate_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - network.incoming.packets.rate
+ - vpg_vpg_private_1_port
+ - network.incoming.packets.rate
binding_vpg:
- - vpg
- - binding
+ - vpg
+ - binding
disk.device.allocation_vpg:
- - vpg
- - disk.device.allocation
+ - vpg
+ - disk.device.allocation
network.incoming.bytes_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - network.incoming.bytes
+ - vpg_vpg_private_0_port
+ - network.incoming.bytes
disk.ephemeral.size_vpg:
- - vpg
- - disk.ephemeral.size
+ - vpg
+ - disk.ephemeral.size
network.outgoing.bytes_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - network.outgoing.bytes
+ - vpg_vpg_private_1_port
+ - network.outgoing.bytes
network.incoming.packets_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - network.incoming.packets
+ - vpg_vpg_private_1_port
+ - network.incoming.packets
disk.write.requests.rate_vpg:
- - vpg
- - disk.write.requests.rate
+ - vpg
+ - disk.write.requests.rate
disk.write.bytes.rate_vpg:
- - vpg
- - disk.write.bytes.rate
+ - vpg
+ - disk.write.bytes.rate
disk.device.iops_vpg:
- - vpg
- - disk.device.iops
+ - vpg
+ - disk.device.iops
host_vpg:
- - vpg
- - host
+ - vpg
+ - host
network.outpoing.packets_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - network.outpoing.packets
+ - vpg_vpg_private_0_port
+ - network.outpoing.packets
instance_vpg:
- - vpg
- - instance
+ - vpg
+ - instance
disk.device.capacity_vpg:
- - vpg
- - disk.device.capacity
+ - vpg
+ - disk.device.capacity
disk.device.read.requests_vpg:
- - vpg
- - disk.device.read.requests
+ - vpg
+ - disk.device.read.requests
cpu_util_vpg:
- - vpg
- - cpu_util
+ - vpg
+ - cpu_util
memory.usage_vpg:
- - vpg
- - memory.usage
+ - vpg
+ - memory.usage
disk.device.read.requests.rate_vpg:
- - vpg
- - disk.device.read.requests.rate
+ - vpg
+ - disk.device.read.requests.rate
disk.read.requests_vpg:
- - vpg
- - disk.read.requests
+ - vpg
+ - disk.read.requests
cpu.delta_vpg:
- - vpg
- - cpu.delta
+ - vpg
+ - cpu.delta
network.incoming.packets.rate_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - network.incoming.packets.rate
+ - vpg_vpg_private_0_port
+ - network.incoming.packets.rate
network.incoming.bytes.rate_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - network.incoming.bytes.rate
+ - vpg_vpg_private_0_port
+ - network.incoming.bytes.rate
disk.write.bytes_vpg:
- - vpg
- - disk.write.bytes
+ - vpg
+ - disk.write.bytes
network.outgoing.packets.rate_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - network.outgoing.packets.rate
+ - vpg_vpg_private_0_port
+ - network.outgoing.packets.rate
scalable_vpg:
- - vpg
- - scalable
+ - vpg
+ - scalable
vcpus_vpg:
- - vpg
- - vcpus
+ - vpg
+ - vcpus
port_mirroring_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - port_mirroring
+ - vpg_vpg_private_1_port
+ - port_mirroring
disk.root.size_vpg:
- - vpg
- - disk.root.size
+ - vpg
+ - disk.root.size
disk.device.write.requests_vpg:
- - vpg
- - disk.device.write.requests
+ - vpg
+ - disk.device.write.requests
network.outgoing.bytes_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - network.outgoing.bytes
+ - vpg_vpg_private_0_port
+ - network.outgoing.bytes
memory_vpg:
- - vpg
- - memory
+ - vpg
+ - memory
network.outpoing.packets_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - network.outpoing.packets
+ - vpg_vpg_private_1_port
+ - network.outpoing.packets
os_vpg:
- - vpg
- - os
+ - vpg
+ - os
binding_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - binding
+ - vpg_vpg_private_0_port
+ - binding
disk.read.bytes.rate_vpg:
- - vpg
- - disk.read.bytes.rate
+ - vpg
+ - disk.read.bytes.rate
memory.resident_vpg:
- - vpg
- - memory.resident
+ - vpg
+ - memory.resident
disk.latency_vpg:
- - vpg
- - disk.latency
+ - vpg
+ - disk.latency
network.incoming.packets_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - network.incoming.packets
+ - vpg_vpg_private_0_port
+ - network.incoming.packets
requirements:
link_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - link
+ - vpg_vpg_private_0_port
+ - link
dependency_vpg:
- - vpg
- - dependency
+ - vpg
+ - dependency
dependency_vpg_vpg_private_0_port:
- - vpg_vpg_private_0_port
- - dependency
+ - vpg_vpg_private_0_port
+ - dependency
local_storage_vpg:
- - vpg
- - local_storage
+ - vpg
+ - local_storage
dependency_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - dependency
+ - vpg_vpg_private_1_port
+ - dependency
link_vpg_vpg_private_1_port:
- - vpg_vpg_private_1_port
- - link
+ - vpg_vpg_private_1_port
+ - link