From 1ec3dde2067e0181faa8e5098219c93126638aef Mon Sep 17 00:00:00 2001 From: vasraz Date: Mon, 6 Jul 2020 17:08:08 +0100 Subject: Support for defining attributes on a node_type This commit aims to add support of attributes on node_type. It is first of several commits to cover all support. It includes: - new classes: AttributeDefinition ComponentInstanceAttribute IAttributeInputCommon IAttributeInputCommon AttributeDataDefinition MapAttributesDataDefinition - support of 'Import of VFC with attributes' - TCs fix for changed code Next commit(s) will cover: - support of "Onboarding packages with attributes" - support of "Download TOSCA Artifacts - Tosca Model" - support of "Import onboarded VSP" Change-Id: I0167abc58e8aeef3d631833cc323e466f8e71492 Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3200 --- .../sdc/be/model/AttributeDefinition.java | 68 ++++ .../sdc/be/model/CapabilityDefinition.java | 54 +-- .../sdc/be/model/CapabilityTypeDefinition.java | 32 +- .../java/org/openecomp/sdc/be/model/Component.java | 2 +- .../sdc/be/model/ComponentInstanceAttribute.java | 53 +++ .../sdc/be/model/ComponentInstanceInterface.java | 26 +- .../sdc/be/model/IAttributeInputCommon.java | 33 ++ .../java/org/openecomp/sdc/be/model/Resource.java | 3 +- .../model/jsonjanusgraph/datamodel/NodeType.java | 4 +- .../jsonjanusgraph/datamodel/TopologyTemplate.java | 263 +++----------- .../operations/NodeTemplateOperation.java | 29 +- .../operations/NodeTypeOperation.java | 9 +- .../operations/TopologyTemplateOperation.java | 7 +- .../operations/ToscaElementOperation.java | 32 +- .../operations/ToscaOperationFacade.java | 37 +- .../model/jsonjanusgraph/utils/ModelConverter.java | 56 +-- .../sdc/be/ui/model/UiComponentDataTransfer.java | 3 +- .../sdc/be/ui/model/UiResourceDataTransfer.java | 4 +- .../sdc/be/model/CapabilityDefinitionTest.java | 26 -- .../sdc/be/model/CapabilityTypeDefinitionTest.java | 21 -- .../model/ComponentInstanceInterfaceBeanTest.java | 15 +- .../org/openecomp/sdc/be/model/ResourceTest.java | 102 +----- .../jsonjanusgraph/datamodel/NodeTypeTest.java | 161 +-------- .../datamodel/TopologyTemplateTest.java | 378 --------------------- 24 files changed, 350 insertions(+), 1068 deletions(-) create mode 100644 catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java create mode 100644 catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java create mode 100644 catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java (limited to 'catalog-model') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java new file mode 100644 index 0000000000..a353ae9033 --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2020, Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdc.be.model; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.onap.sdc.tosca.datatypes.model.EntrySchema; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; + +@Getter +@Setter +@ToString +public class AttributeDefinition extends AttributeDataDefinition implements IOperationParameter, IComplexDefaultValue { + + // All names are according to TOSCA spec from + // https://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.3/os/TOSCA-Simple-Profile-YAML-v1.3-os.html#DEFN_ELEMENT_ATTRIBUTE_DEFN + private String type; + private String description; + private Object _default; + private String status; + private EntrySchema entry_schema; + + public AttributeDefinition() { + toscaPresentation = null; + } + + public AttributeDefinition(final AttributeDefinition attributeDefinition) { + this.type = attributeDefinition.getType(); + this.description = attributeDefinition.getDescription(); + this._default = attributeDefinition.get_default(); + this.status = attributeDefinition.getStatus(); + this.entry_schema = attributeDefinition.getEntry_schema(); + } + + @Override + public String getDefaultValue() { + return String.valueOf(_default); + } + + @Override + public void setDefaultValue(final String value) { + this._default = value; + } + + @Override + public boolean isDefinition() { + return false; + } +} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java index a74243eb7e..061262eec0 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java @@ -21,6 +21,11 @@ package org.openecomp.sdc.be.model; import com.google.common.collect.Lists; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.SetUtils; @@ -31,9 +36,15 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; + /** * Specifies the capabilities that the Node Type exposes. */ +@Getter +@Setter +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@ToString public class CapabilityDefinition extends CapabilityDataDefinition { /** @@ -42,11 +53,6 @@ public class CapabilityDefinition extends CapabilityDataDefinition { */ private List properties; - - public CapabilityDefinition() { - super(); - } - public CapabilityDefinition(CapabilityDataDefinition cap) { super(cap); } @@ -70,44 +76,6 @@ public class CapabilityDefinition extends CapabilityDataDefinition { } } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((properties == null) ? 0 : properties.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - CapabilityDefinition other = (CapabilityDefinition) obj; - if (properties == null) { - if (other.properties != null) - return false; - } else if (!SetUtils.isEqualSet(properties, other.getProperties())) - return false; - return true; - } - - @Override - public String toString() { - return "CapabilityDefinition [properties=" + properties + "]"; - } - - public List getProperties() { - return properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - public void updateCapabilityProperties(CapabilityDefinition capabilityDefinition) { if(CollectionUtils.isNotEmpty(getProperties()) && capabilityDefinition!= null && CollectionUtils.isNotEmpty(capabilityDefinition.getProperties())){ Map propertiesInfo = capabilityDefinition.getProperties() diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java index 016c117e84..f7627e76df 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java @@ -20,6 +20,10 @@ package org.openecomp.sdc.be.model; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; import org.openecomp.sdc.be.datatypes.elements.CapabilityTypeDataDefinition; import org.openecomp.sdc.be.resources.data.CapabilityTypeData; @@ -30,32 +34,16 @@ import java.util.stream.Collectors; * Specifies the capabilities that the Node Type exposes. */ @SuppressWarnings("serial") +@Getter +@Setter +@NoArgsConstructor +@ToString(callSuper = true) public class CapabilityTypeDefinition extends CapabilityTypeDataDefinition { private String derivedFrom; private Map properties; - public String getDerivedFrom() { - return derivedFrom; - } - - public void setDerivedFrom(String derivedFrom) { - this.derivedFrom = derivedFrom; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - - public CapabilityTypeDefinition() { - super(); - } - public CapabilityTypeDefinition(CapabilityTypeDataDefinition p) { super(p); } @@ -75,8 +63,4 @@ public class CapabilityTypeDefinition extends CapabilityTypeDataDefinition { this.setValidSourceTypes( ctd.getCapabilityTypeDataDefinition().getValidSourceTypes()); } - @Override - public String toString() { - return super.toString() + " [ derivedFrom=" + derivedFrom + ", properties=" + properties + " ]"; - } } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java index dc0fb51d7c..ba73e77e05 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java @@ -73,7 +73,7 @@ public abstract class Component implements PropertiesOwner { private List componentInstancesRelations; private Map> componentInstancesInputs; private Map> componentInstancesProperties; - private Map> componentInstancesAttributes; + private Map> componentInstancesAttributes; private Map> capabilities; private Map> requirements; private Map> componentInstancesInterfaces; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java new file mode 100644 index 0000000000..91a7b9c14f --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2020, Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.model; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PropertyRule; + +@Getter +@Setter +public class ComponentInstanceAttribute extends AttributeDefinition implements IComponentInstanceConnectedElement, IAttributeInputCommon { + + public ComponentInstanceAttribute(final AttributeDataDefinition value) { + } + public ComponentInstanceAttribute() { + super(); + } + + /** + * The unique id of the property value on graph + */ + private String valueUniqueUid; + + private List path; + + private List rules ; + + private String componentInstanceName; + + private String componentInstanceId; + +} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java index c5a008085b..487d642a5c 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java @@ -16,17 +16,19 @@ package org.openecomp.sdc.be.model; -import com.google.common.annotations.VisibleForTesting; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition; +@Getter +@Setter +@NoArgsConstructor public class ComponentInstanceInterface extends InterfaceDefinition { private String interfaceId; private InterfaceInstanceDataDefinition interfaceInstanceDataDefinition; - @VisibleForTesting - ComponentInstanceInterface() {} - public ComponentInstanceInterface(String interfaceId, InterfaceInstanceDataDefinition interfaceInstanceDataDefinition) { this.interfaceId = interfaceId; @@ -38,20 +40,4 @@ public class ComponentInstanceInterface extends InterfaceDefinition { this.interfaceId = interfaceId; } - public String getInterfaceId() { - return interfaceId; - } - - public void setInterfaceId(String interfaceId) { - this.interfaceId = interfaceId; - } - - public InterfaceInstanceDataDefinition getInterfaceInstanceDataDefinition() { - return interfaceInstanceDataDefinition; - } - - public void setInterfaceInstanceDataDefinition( - InterfaceInstanceDataDefinition interfaceInstanceDataDefinition) { - this.interfaceInstanceDataDefinition = interfaceInstanceDataDefinition; - } } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java new file mode 100644 index 0000000000..fa8c162485 --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2020, Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.model; + +import java.util.List; +import org.openecomp.sdc.be.datatypes.elements.PropertyRule; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + +public interface IAttributeInputCommon { + + String getType(); + ToscaDataDefinition getSchema(); + List getRules(); + String getName(); +} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java index 44d6eff4fb..a3d871a511 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java @@ -32,6 +32,7 @@ import lombok.ToString; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.utils.MapUtil; import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.category.CategoryDefinition; @@ -57,7 +58,7 @@ public class Resource extends Component { private Map derivedFromMapOfIdToName; - private List attributes; + private List attributes; private String toscaVersion; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java index 296e80b674..a1b07bc58d 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Map; import lombok.Getter; import lombok.Setter; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; @Getter @Setter @@ -38,6 +38,6 @@ public class NodeType extends ToscaElement { private List derivedFrom; private List derivedList; private Map derivedFromMapOfIdToName; - private Map attributes; + private Map attributes; private Map interfaceArtifacts; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java index db330e9b19..7b9fd6fa05 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.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,26 +20,48 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.datamodel; +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.collections.MapUtils; -import org.openecomp.sdc.be.datatypes.elements.*; +import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty; +import org.openecomp.sdc.be.datatypes.elements.MapComponentInstanceExternalRefs; +import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; import org.openecomp.sdc.be.model.MapInterfaceInstanceDataDefinition; import org.openecomp.sdc.be.model.jsonjanusgraph.enums.JsonConstantKeysEnum; -import java.util.HashMap; -import java.util.Map; - -public class TopologyTemplate extends ToscaElement{ +@Getter +@Setter +public class TopologyTemplate extends ToscaElement { public TopologyTemplate() { super(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE); } + private Map inputs; private Map instInputs; private Map heatParameters; - private Map instAttributes; + private Map instAttributes; private Map instProperties; private Map groups; private Map policies; @@ -58,238 +80,61 @@ public class TopologyTemplate extends ToscaElement{ private Map instInterfaces; private Map componentInstInterfaces; private Map dataTypes; - private Map nodeFilterComponents; private Map substitutionFilterDataDefinitionMap; + //Component Instances External References (instanceId -> ExternalRefsMap) //----------------------------------------------------------------------- private Map mapComponentInstancesExternalRefs; - - public Map getMapComponentInstancesExternalRefs() { - return this.mapComponentInstancesExternalRefs; - } - - public void setComponentInstancesExternalRefs(Map mapComponentInstancesExternalRefs) { - this.mapComponentInstancesExternalRefs = mapComponentInstancesExternalRefs; - } //----------------------------------------------------------------------- - public Map getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map interfaces) { - this.interfaces = interfaces; - } - - public Map getInstInterfaces() { - return instInterfaces; - } - - public void setInstInterfaces( - Map instInterfaces) { - this.instInterfaces = instInterfaces; - } - public void addInstInterface(String compId, MapInterfaceInstanceDataDefinition - mapInterfaceInstanceDataDefinition) { - if(MapUtils.isEmpty(this.instInterfaces)) { + mapInterfaceInstanceDataDefinition) { + if (MapUtils.isEmpty(this.instInterfaces)) { this.instInterfaces = new HashMap<>(); } this.instInterfaces.put(compId, mapInterfaceInstanceDataDefinition); } - public Map getComponentInstInterfaces() { - return componentInstInterfaces; - } - - public void setComponentInstInterfaces( - Map componentInstInterfaces) { - this.componentInstInterfaces = componentInstInterfaces; - } - public void addComponentInstanceInterfaceMap(String componentInstanceId, MapInterfaceDataDefinition - mapInterfaceDataDefinition) { - if(MapUtils.isEmpty(this.componentInstInterfaces)) { + mapInterfaceDataDefinition) { + if (MapUtils.isEmpty(this.componentInstInterfaces)) { this.componentInstInterfaces = new HashMap<>(); } this.componentInstInterfaces.put(componentInstanceId, mapInterfaceDataDefinition); } - - public Map getInputs() { - return inputs; - } - public void setInputs(Map inputs) { - this.inputs = inputs; - } - public Map getInstInputs() { - return instInputs; - } - public void setInstInputs(Map instInputs) { - this.instInputs = instInputs; - } - public Map getHeatParameters() { - return heatParameters; - } - public void setHeatParameters(Map heatParameters) { - this.heatParameters = heatParameters; - } - public Map getInstAttributes() { - return instAttributes; - } - public void setInstAttributes(Map instAttributes) { - this.instAttributes = instAttributes; - } - public Map getInstProperties() { - return instProperties; - } - public void setInstProperties(Map instProperties) { - this.instProperties = instProperties; - } - public Map getGroups() { - return groups; - } - public void setGroups(Map groups) { - this.groups = groups; - } - public Map getPolicies() { - return policies; - } - public void setPolicies(Map policies) { - this.policies = policies; - } - public Map getInstGroups() { - return instGroups; - } - public void setInstGroups(Map instGroups) { - this.instGroups = instGroups; - } - public Map getServiceApiArtifacts() { - return serviceApiArtifacts; - } - public void setServiceApiArtifacts(Map serviceApiArtifacts) { - this.serviceApiArtifacts = serviceApiArtifacts; - } - public Map getCompositions() { - return compositions; - } - public void setCompositions(Map compositions) { - this.compositions = compositions; - } - public Map getCalculatedCapabilities() { - return calculatedCapabilities; - } - public void setCalculatedCapabilities(Map calculatedCapabilities) { - this.calculatedCapabilities = calculatedCapabilities; - } - public Map getCalculatedRequirements() { - return calculatedRequirements; - } - public void setCalculatedRequirements(Map calculatedRequirements) { - this.calculatedRequirements = calculatedRequirements; - } - public Map getFullfilledCapabilities() { - return fullfilledCapabilities; - } - public void setFullfilledCapabilities(Map fullfilledCapabilities) { - this.fullfilledCapabilities = fullfilledCapabilities; - } - public Map getFullfilledRequirements() { - return fullfilledRequirements; - } - public void setFullfilledRequirements(Map fullfilledRequirements) { - this.fullfilledRequirements = fullfilledRequirements; - } - - public Map getInstDeploymentArtifacts() { - return instDeploymentArtifacts; - } - public void setInstDeploymentArtifacts(Map instDeploymentArtifacts) { - this.instDeploymentArtifacts = instDeploymentArtifacts; - } - - public Map getCalculatedCapabilitiesProperties() { - return calculatedCapabilitiesProperties; - } - public void setCalculatedCapabilitiesProperties(Map calculatedCapabilitiesProperties) { - this.calculatedCapabilitiesProperties = calculatedCapabilitiesProperties; - } - - public Map getInstanceArtifacts() { - return instanceArtifacts; - } - public void setInstanceArtifacts(Map instanceArtifacts) { - this.instanceArtifacts = instanceArtifacts; - } - - public Map getForwardingPaths() { - return forwardingPaths; - } - - public void setForwardingPaths(Map forwardingPaths) { - this.forwardingPaths = forwardingPaths; - } - - public Map getNodeFilterComponents() { - return nodeFilterComponents; - } - - public void setNodeFilterComponents(Map nodeFilters) { - this.nodeFilterComponents = nodeFilters; - } - - public Map getSubstitutionFilterDataDefinitionMap() { - return substitutionFilterDataDefinitionMap; - } - - public void setSubstitutionFilterDataDefinitionMap( - Map substitutionFilterDataDefinitionMap) { - this.substitutionFilterDataDefinitionMap = substitutionFilterDataDefinitionMap; - } - - /** - * Gets data types. - * @return Current data types. - */ - public Map getDataTypes() { - return dataTypes; - } - /** - * Sets data types. - * @param dataTypes New data types. - */ - public void setDataTypes(Map dataTypes) { - this.dataTypes = dataTypes; - } - - /** - * Adds component instance to composition of topology template - * Note that component instance will be overrided in case if the topology template already contains a component instance with the same name + * Adds component instance to composition of topology template Note that component instance will be overrided in + * case if the topology template already contains a component instance with the same name + * * @param componentInstance */ - public void addComponentInstance(ComponentInstanceDataDefinition componentInstance){ - if(getCompositions() == null){ + public void addComponentInstance(ComponentInstanceDataDefinition componentInstance) { + if (getCompositions() == null) { compositions = new HashMap<>(); } - if(MapUtils.isEmpty(getCompositions())){ + if (MapUtils.isEmpty(getCompositions())) { compositions.put(JsonConstantKeysEnum.COMPOSITION.getValue(), new CompositionDataDefinition()); } - if(MapUtils.isEmpty(getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances())){ + if (MapUtils + .isEmpty(getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances())) { getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).setComponentInstances(new HashMap<>()); } - getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances().put(componentInstance.getUniqueId(), componentInstance); + getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances() + .put(componentInstance.getUniqueId(), componentInstance); } + /** * Returns map of component instances from composition + * * @return */ public Map getComponentInstances() { Map instances = null; - if(getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null ){ + if (getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null) { instances = getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances(); } return instances; @@ -297,22 +142,24 @@ public class TopologyTemplate extends ToscaElement{ /** - * Sets map of component instances to composition of topology template - * Note that component instances will be overrided in case if the topology template already contains a component instances + * Sets map of component instances to composition of topology template Note that component instances will be + * overrided in case if the topology template already contains a component instances + * * @param instances */ public void setComponentInstances(Map instances) { - if(getCompositions() == null){ + if (getCompositions() == null) { compositions = new HashMap<>(); } - if(MapUtils.isEmpty(getCompositions())){ + if (MapUtils.isEmpty(getCompositions())) { compositions.put(JsonConstantKeysEnum.COMPOSITION.getValue(), new CompositionDataDefinition()); } getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).setComponentInstances(instances); } + public Map getRelations() { Map relations = null; - if( getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null ){ + if (getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null) { relations = getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getRelations(); } return relations; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java index 930ba791d5..9cadd4e107 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java @@ -63,6 +63,7 @@ import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty; import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition; @@ -78,23 +79,7 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.ComponentInstanceInput; -import org.openecomp.sdc.be.model.ComponentInstanceProperty; -import org.openecomp.sdc.be.model.ComponentParametersView; -import org.openecomp.sdc.be.model.GroupDefinition; -import org.openecomp.sdc.be.model.GroupInstance; -import org.openecomp.sdc.be.model.InputDefinition; -import org.openecomp.sdc.be.model.PropertyDefinition; -import org.openecomp.sdc.be.model.RelationshipImpl; -import org.openecomp.sdc.be.model.RelationshipInfo; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -import org.openecomp.sdc.be.model.RequirementDefinition; -import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.NodeType; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate; import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement; @@ -958,8 +943,8 @@ public class NodeTemplateOperation extends BaseOperation { } if(MapUtils.isNotEmpty(originNodeType.getAttributes())){ - MapPropertiesDataDefinition instAttributes = - new MapPropertiesDataDefinition(originNodeType.getAttributes()); + MapAttributesDataDefinition instAttributes = + new MapAttributesDataDefinition(originNodeType.getAttributes()); status = addToscaDataDeepElementsBlockToToscaElement(updatedContainerVertex, EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, instAttributes, componentInstance.getUniqueId()); if (status != StorageOperationStatus.OK) { @@ -2199,16 +2184,16 @@ public class NodeTemplateOperation extends BaseOperation { return updateToscaDataDeepElementsOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES, properties, pathKeys, JsonPresentationFields.NAME); } - public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){ + public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute property){ List pathKeys = new ArrayList<>(); pathKeys.add(componentInstanceId); return updateToscaDataDeepElementOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, property, pathKeys, JsonPresentationFields.NAME); } - public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){ + public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute attribute){ List pathKeys = new ArrayList<>(); pathKeys.add(componentInstanceId); - return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, property, pathKeys, JsonPresentationFields.NAME); + return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, attribute, pathKeys, JsonPresentationFields.NAME); } public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java index 9a70e9c837..004451c667 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java @@ -389,7 +389,7 @@ public class NodeTypeOperation extends ToscaElementOperation { } private JanusGraphOperationStatus setResourceAttributesFromGraph(GraphVertex componentV, NodeType toscaElement) { - Either, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.ATTRIBUTES); + Either, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.ATTRIBUTES); if (result.isLeft()) { toscaElement.setAttributes(result.left().value()); } else { @@ -531,13 +531,13 @@ public class NodeTypeOperation extends ToscaElementOperation { private StorageOperationStatus associateAttributesToResource(GraphVertex nodeTypeVertex, NodeType nodeType, List derivedResources) { // Note : currently only one derived supported!!!! - Either, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.ATTRIBUTES); + Either, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.ATTRIBUTES); if (dataFromDerived.isRight()) { return dataFromDerived.right().value(); } - Map attributesAll = dataFromDerived.left().value(); + Map attributesAll = dataFromDerived.left().value(); - Map attributes = nodeType.getAttributes(); + Map attributes = nodeType.getAttributes(); if (attributes != null) { attributes.values().stream().filter(p -> p.getUniqueId() == null).forEach(p -> { String uid = UniqueIdBuilder.buildAttributeUid(nodeTypeVertex.getUniqueId(), p.getName()); @@ -660,6 +660,7 @@ public class NodeTypeOperation extends ToscaElementOperation { nodeTypeVertex.setLabel(VertexTypeEnum.NODE_TYPE); fillCommonMetadata(nodeTypeVertex, nodeType); + nodeTypeVertex.setJsonMetadataField(JsonPresentationFields.ATTRIBUTES, nodeType.getAttributes()); return nodeTypeVertex; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java index cc6cd1d430..af6ddd82e5 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java @@ -39,6 +39,9 @@ import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; +import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty; +import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; @@ -537,7 +540,7 @@ public class TopologyTemplateOperation extends ToscaElementOperation { } private StorageOperationStatus associateInstAttributesToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) { - Map instAttr = topologyTemplate.getInstAttributes(); + Map instAttr = topologyTemplate.getInstAttributes(); return associateInstAttributeToComponent(nodeTypeVertex, instAttr); } @@ -551,7 +554,7 @@ public class TopologyTemplateOperation extends ToscaElementOperation { return StorageOperationStatus.OK; } - public StorageOperationStatus associateInstAttributeToComponent(GraphVertex nodeTypeVertex, Map instAttr) { + public StorageOperationStatus associateInstAttributeToComponent(GraphVertex nodeTypeVertex, Map instAttr) { if (instAttr != null && !instAttr.isEmpty()) { Either assosiateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.INST_ATTRIBUTES, EdgeLabelEnum.INST_ATTRIBUTES, instAttr); if (assosiateElementToData.isRight()) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java index ec1185a706..90111e80ac 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java @@ -25,6 +25,7 @@ import java.util.*; import java.util.Map.Entry; import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -41,12 +42,14 @@ import org.openecomp.sdc.be.dao.jsongraph.utils.JsonParserUtils; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.catalog.CatalogComponent; @@ -92,7 +95,6 @@ public abstract class ToscaElementOperation extends BaseOperation { return gson; } - protected Either getComponentByLabelAndId(String uniqueId, ToscaElementTypeEnum nodeType, JsonParseFlagEnum parseFlag) { Map propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class); @@ -912,6 +914,7 @@ public abstract class ToscaElementOperation extends BaseOperation { switch (label) { case NODE_TYPE: toscaElement = new NodeType(); + ((NodeType) toscaElement).setAttributes(getAttributesFromComponentV(componentV)); break; case TOPOLOGY_TEMPLATE: toscaElement = new TopologyTemplate(); @@ -923,8 +926,8 @@ public abstract class ToscaElementOperation extends BaseOperation { if (toscaElement != null) { final Map jsonMetada = componentV.getMetadataJson(); + if (MapUtils.isNotEmpty(jsonMetada)) { toscaElement.setMetadata(jsonMetada); - if (jsonMetada != null) { final Object toscaVersion = jsonMetada.get(ToscaTagNamesEnum.TOSCA_VERSION.getElementName()); if (toscaVersion != null) { toscaElement.setToscaVersion((String) toscaVersion); @@ -934,6 +937,28 @@ public abstract class ToscaElementOperation extends BaseOperation { return (T) toscaElement; } + private Map getAttributesFromComponentV(final GraphVertex componentV) { + final Map jsonMetada = componentV.getMetadataJson(); + final Map attributeDataDefinitionMap = new HashMap<>(); + if (MapUtils.isNotEmpty(jsonMetada)) { + final Object attributes = jsonMetada.get(ToscaTagNamesEnum.ATTRIBUTES.getElementName()); + if (attributes instanceof Map) { + final Map map = (Map) attributes; + attributeDataDefinitionMap.putAll(map.values().stream().map(attributeMap -> { + final AttributeDefinition attributeDef = new AttributeDefinition(); + final String name = (String) ((Map) attributeMap).get("name"); + attributeDef.setName(name); + final String type = (String) ((Map) attributeMap).get("type"); + attributeDef.setType(type); + final String description = (String) ((Map) attributeMap).get("description"); + attributeDef.setDescription(description); + return attributeDef; + }).collect(Collectors.toMap(AttributeDefinition::getName, a -> a))); + } + } + return attributeDataDefinitionMap; + } + protected JanusGraphOperationStatus setResourceCategoryFromGraphV(Vertex vertex, CatalogComponent catalogComponent) { List categories = new ArrayList<>(); SubCategoryDefinition subcategory; @@ -1320,8 +1345,9 @@ public abstract class ToscaElementOperation extends BaseOperation { ResourceTypeEnum resourceType = ResourceTypeEnum.getType((String) resourceTypeStr); if (!CollectionUtils.isEmpty(excludeTypes)) { Optional op = excludeTypes.stream().filter(rt -> rt == resourceType).findAny(); - if (op.isPresent()) + if (op.isPresent()) { isAddToCatalog = false; + } } } return isAddToCatalog; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java index 427939f2f8..5b4388226b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java @@ -1472,7 +1472,7 @@ public class ToscaOperationFacade { } - public StorageOperationStatus associateInstAttributeToComponentToInstances(Map> instArttributes, Component component) { + public StorageOperationStatus associateInstAttributeToComponentToInstances(Map> instArttributes, Component component) { Either getVertexEither = janusGraphDao.getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse); if (getVertexEither.isRight()) { @@ -1482,24 +1482,24 @@ public class ToscaOperationFacade { } GraphVertex vertex = getVertexEither.left().value(); - Map instAttr = new HashMap<>(); + Map instAttr = new HashMap<>(); if (instArttributes != null) { - MapPropertiesDataDefinition attributesMap; - for (Entry> entry : instArttributes.entrySet()) { - attributesMap = new MapPropertiesDataDefinition(); - attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, e -> e))); + MapAttributesDataDefinition attributesMap; + for (Entry> entry : instArttributes.entrySet()) { + final List value = entry.getValue(); + attributesMap = new MapAttributesDataDefinition(); + attributesMap.setMapToscaDataDefinition(value.stream().map(AttributeDataDefinition::new).collect(Collectors.toMap(AttributeDataDefinition::getName, e -> e))); instAttr.put(entry.getKey(), attributesMap); } } setComponentInstanceAttributesOnComponent(component, instAttr); return topologyTemplateOperation.associateInstAttributeToComponent(vertex, instAttr); - } // endregion - private void setComponentInstanceAttributesOnComponent(Component resource, Map instAttr) { - Map> componentInstancesAttributes = resource.getComponentInstancesAttributes(); + private void setComponentInstanceAttributesOnComponent(Component resource, Map instAttr) { + Map> componentInstancesAttributes = resource.getComponentInstancesAttributes(); if (componentInstancesAttributes == null) componentInstancesAttributes = new HashMap<>(); componentInstancesAttributes.putAll(ModelConverter.getComponentInstancesAttributes(instAttr)); @@ -2382,11 +2382,10 @@ public class ToscaOperationFacade { } - - public Either addAttributeOfResource(Component component, PropertyDefinition newAttributeDef) { + public Either addAttributeOfResource(Component component, AttributeDataDefinition newAttributeDef) { Either getUpdatedComponentRes = null; - Either result = null; + Either result = null; if (newAttributeDef.getUniqueId() == null || newAttributeDef.getUniqueId().isEmpty()) { String attUniqueId = UniqueIdBuilder.buildAttributeUid(component.getUniqueId(), newAttributeDef.getName()); newAttributeDef.setUniqueId(attUniqueId); @@ -2407,7 +2406,7 @@ public class ToscaOperationFacade { } } if (result == null) { - Optional newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); + Optional newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); if (newAttribute.isPresent()) { result = Either.left(newAttribute.get()); } else { @@ -2418,10 +2417,10 @@ public class ToscaOperationFacade { return result; } - public Either updateAttributeOfResource(Component component, PropertyDefinition newAttributeDef) { + public Either updateAttributeOfResource(Component component, AttributeDataDefinition newAttributeDef) { Either getUpdatedComponentRes = null; - Either result = null; + Either result = null; StorageOperationStatus status = getToscaElementOperation(component).updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef, JsonPresentationFields.NAME); if (status != StorageOperationStatus.OK) { CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newAttributeDef.getName(), component.getName(), status); @@ -2437,7 +2436,7 @@ public class ToscaOperationFacade { } } if (result == null) { - Optional newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); + Optional newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny(); if (newProperty.isPresent()) { result = Either.left(newProperty.get()); } else { @@ -2536,12 +2535,12 @@ public class ToscaOperationFacade { return nodeTemplateOperation.addComponentInstanceProperty(containerComponent, componentInstanceId, property); } - public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){ + public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute property){ return nodeTemplateOperation.updateComponentInstanceAttribute(containerComponent, componentInstanceId, property); } - public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){ - return nodeTemplateOperation.addComponentInstanceAttribute(containerComponent, componentInstanceId, property); + public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute attribute){ + return nodeTemplateOperation.addComponentInstanceAttribute(containerComponent, componentInstanceId, attribute); } public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java index c278632dad..5ceb7f194c 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java @@ -48,6 +48,7 @@ import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition; import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; @@ -60,6 +61,7 @@ import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty; import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition; import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition; @@ -79,10 +81,12 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFieldsExtractor; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.AdditionalInformationDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.CapabilityRequirementRelationship; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstanceAttribute; import org.openecomp.sdc.be.model.ComponentInstanceInput; import org.openecomp.sdc.be.model.ComponentInstanceInterface; import org.openecomp.sdc.be.model.ComponentInstanceProperty; @@ -177,8 +181,6 @@ public class ModelConverter { return vertexType; } - - private static Service convertToService(ToscaElement toscaElement) { Service service = new Service(); convertComponentFields(service, toscaElement); @@ -308,9 +310,10 @@ public class ModelConverter { } private static void convertAttributes(NodeType nodeType, Resource resource) { - Map attributes = nodeType.getAttributes(); + Map attributes = nodeType.getAttributes(); if (attributes != null) { - List attrs = attributes.values().stream().map(dataDef -> ModelConverter.fromDataDefinition(resource.getUniqueId(), dataDef)).collect(Collectors.toList()); + final List attrs = attributes.values().stream() + .collect(Collectors.toList()); resource.setAttributes(attrs); } } @@ -984,9 +987,10 @@ public class ModelConverter { } private static void convertAttributes(Resource component, NodeType nodeType) { - List attributes = component.getAttributes(); + List attributes = component.getAttributes(); if (attributes != null) { - Map attrsByName = attributes.stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, Function.identity())); + Map attrsByName = attributes.stream() + .collect(Collectors.toMap(AttributeDataDefinition::getName, Function.identity())); nodeType.setAttributes(attrsByName); } } @@ -1434,8 +1438,10 @@ public class ModelConverter { for (Entry entry : topologyTemplate.getInstProperties().entrySet()) { if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) { String key = entry.getKey(); - List componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new PropertyDefinition(e.getValue()))) - .collect(Collectors.toList()); + List componentInstanceAttributes = entry.getValue() + .getMapToscaDataDefinition().entrySet().stream() + .map(e -> new ComponentInstanceProperty(new PropertyDefinition(e.getValue()))) + .collect(Collectors.toList()); properties.put(key, componentInstanceAttributes); } } @@ -1443,13 +1449,16 @@ public class ModelConverter { } } - public static Map> getComponentInstancesAttributes(Map mapPropertiesDataDefinition) { - Map> attributes = new HashMap<>(); - for (Map.Entry entry : mapPropertiesDataDefinition.entrySet()) { + public static Map> getComponentInstancesAttributes( + Map mapAttributesDataDefinitionMap) { + Map> attributes = new HashMap<>(); + for (Map.Entry entry : mapAttributesDataDefinitionMap.entrySet()) { if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) { String key = entry.getKey(); - List componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue()))) - .collect(Collectors.toList()); + List componentInstanceAttributes = entry.getValue() + .getMapToscaDataDefinition().entrySet().stream() + .map(e -> new ComponentInstanceAttribute(new ComponentInstanceAttribute(e.getValue()))) + .collect(Collectors.toList()); attributes.put(key, componentInstanceAttributes); } } @@ -1490,12 +1499,15 @@ public class ModelConverter { private static void setComponentInstancesAttributesToComponent(TopologyTemplate topologyTemplate, Component component) { if (topologyTemplate.getInstAttributes() != null) { - Map> attributes = new HashMap<>(); - for (Map.Entry entry : topologyTemplate.getInstAttributes().entrySet()) { + Map> attributes = new HashMap<>(); + for (Map.Entry entry : topologyTemplate.getInstAttributes() + .entrySet()) { if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) { String key = entry.getKey(); - List componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue()))) - .collect(Collectors.toList()); + List componentInstanceAttributes = entry.getValue() + .getMapToscaDataDefinition().entrySet().stream() + .map(e -> new ComponentInstanceAttribute(new ComponentInstanceAttribute(e.getValue()))) + .collect(Collectors.toList()); attributes.put(key, componentInstanceAttributes); } } @@ -1857,11 +1869,13 @@ public class ModelConverter { if (component.getComponentInstancesAttributes() != null) { topologyTemplate.setInstAttributes(new HashMap<>()); - MapPropertiesDataDefinition attributesMap; - for (Entry> entry : component.getComponentInstancesAttributes().entrySet()) { - attributesMap = new MapPropertiesDataDefinition(); + MapAttributesDataDefinition attributesMap; + for (Entry> entry : component.getComponentInstancesAttributes() + .entrySet()) { + attributesMap = new MapAttributesDataDefinition(); - attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, Function.identity()))); + attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(AttributeDefinition::new) + .collect(Collectors.toMap(AttributeDataDefinition::getName, Function.identity()))); topologyTemplate.getInstAttributes().put(entry.getKey(), attributesMap); } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java index f03a5e724f..d499dfe799 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java @@ -32,6 +32,7 @@ import org.openecomp.sdc.be.model.AdditionalInformationDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.CapabilityDefinition; import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.ComponentInstanceAttribute; import org.openecomp.sdc.be.model.ComponentInstanceInput; import org.openecomp.sdc.be.model.ComponentInstanceInterface; import org.openecomp.sdc.be.model.ComponentInstanceProperty; @@ -63,7 +64,7 @@ public class UiComponentDataTransfer { private List componentInstancesRelations; private Map> componentInstancesInputs; private Map> componentInstancesProperties; - private Map> componentInstancesAttributes; + private Map> componentInstancesAttributes; private Map> capabilities; private List policies; private Map> requirements; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java index 380593b4b3..a51c368c71 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java @@ -25,6 +25,8 @@ import java.util.Map; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; +import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; @@ -41,7 +43,7 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer { private List properties; - private List attributes; + private List attributes; private Map interfaces; diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityDefinitionTest.java index 41de118272..569691869f 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityDefinitionTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityDefinitionTest.java @@ -21,12 +21,7 @@ */ package org.openecomp.sdc.be.model; -import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsFor; -import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeFor; -import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanToStringFor; -import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; import java.util.ArrayList; import java.util.HashMap; @@ -45,27 +40,6 @@ public class CapabilityDefinitionTest { private static final String PROPERTIES = "properties"; private static final String VALUE = "VALUE"; - @Test - public void hasValidGettersAndSettersTest() { - assertThat(CapabilityDefinition.class, - hasValidGettersAndSettersExcluding("empty", "ownerIdIfEmpty", "version")); - } - - @Test - public void shouldHaveValidToString() { - assertThat(CapabilityDefinition.class, hasValidBeanToStringFor(PROPERTIES)); - } - - @Test - public void shouldHaveEquals() { - assertThat(CapabilityDefinition.class, hasValidBeanEqualsFor(PROPERTIES)); - } - - @Test - public void shouldHaveHashCode() { - assertThat(CapabilityDefinition.class, hasValidBeanHashCodeFor(PROPERTIES)); - } - @Test public void testParamConstructor() { EqualConstraint equalConstraint = new EqualConstraint(EQ); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityTypeDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityTypeDefinitionTest.java index 2a90d937dc..cf3bbf53a2 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityTypeDefinitionTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityTypeDefinitionTest.java @@ -22,11 +22,8 @@ package org.openecomp.sdc.be.model; -import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import java.util.Collections; import org.junit.Test; import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition.OwnerType; import org.openecomp.sdc.be.datatypes.elements.CapabilityTypeDataDefinition; @@ -41,24 +38,6 @@ public class CapabilityTypeDefinitionTest { private static final String DESCRIPTION = "DESCRIPTION"; private static final String UNIQUE_ID = "UNIQUE_ID"; - @Test - public void hasValidGettersAndSettersTest() { - assertThat(CapabilityTypeDefinition.class, - hasValidGettersAndSettersExcluding("empty", "ownerIdIfEmpty")); - } - - @Test - public void shouldHaveValidToString() { - CapabilityDefinition capabilityDefinition = new CapabilityDefinition( - new CapabilityTypeDefinition(), OWNER_NAME, NAME, RESOURCE); - capabilityDefinition.setProperties(Collections.emptyList()); - capabilityDefinition.setType(TYPE); - capabilityDefinition.setDescription(DESCRIPTION); - CapabilityTypeDefinition capabilityTypeDefinitionTest = new CapabilityTypeDefinition(capabilityDefinition); - String toStringRepr = capabilityTypeDefinitionTest.toString(); - assertEquals(toStringRepr, "CapabilityTypeDataDefinition [uniqueId=null, description=DESCRIPTION, type=TYPE, validSourceTypes=[], version=null, creationTime=null, modificationTime=null] [ derivedFrom=null, properties={} ]"); - } - @Test public void shouldCreateCapabilityTypeDefinitionFromCapabilityTypeData() { CapabilityTypeData capabilityTypeData = new CapabilityTypeData(); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java index 044e9e0c57..d0c1a666f4 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java @@ -19,9 +19,7 @@ */ package org.openecomp.sdc.be.model; -import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; import org.junit.Test; import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; @@ -34,17 +32,6 @@ public class ComponentInstanceInterfaceBeanTest { private static final InterfaceInstanceDataDefinition INTERFACE_INSTANCE_DATA_DEFINITION = new InterfaceInstanceDataDefinition(); private static final String ID = "ID"; - @Test - public void shouldHaveValidGettersAndSetters() { - assertThat(ComponentInstanceInterface.class, - hasValidGettersAndSettersExcluding( - "definition", - "ownerIdIfEmpty", - "empty", - "operationsMap", - "version")); - } - @Test public void verifyConstructors() { INTERFACE_DATA_DEFINITION.setUniqueId(ID); @@ -58,4 +45,4 @@ public class ComponentInstanceInterfaceBeanTest { assertEquals(componentInstanceInterface1.getUniqueId(), ID); assertEquals(componentInstanceInterface2.getInterfaceInstanceDataDefinition(), INTERFACE_INSTANCE_DATA_DEFINITION); } -} \ No newline at end of file +} diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java index cb50c9601c..447b053fea 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java @@ -29,6 +29,7 @@ import java.util.Map; import org.junit.Assert; import org.junit.Test; import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.unittests.utils.ModelConfDependentTest; @@ -44,66 +45,6 @@ public class ResourceTest extends ModelConfDependentTest { new Resource(componentMetadataDefinition); } - @Test - public void testGetProperties() throws Exception { - Resource testSubject; - List result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProperties(); - } - - @Test - public void testSetProperties() throws Exception { - Resource testSubject; - List properties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProperties(properties); - } - - @Test - public void testGetAttributes() throws Exception { - Resource testSubject; - List result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAttributes(); - } - - @Test - public void testSetAttributes() throws Exception { - Resource testSubject; - List attributes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setAttributes(attributes); - } - - @Test - public void testGetInterfaces() throws Exception { - Resource testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInterfaces(); - } - - @Test - public void testSetInterfaces() throws Exception { - Resource testSubject; - Map interfaces = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInterfaces(interfaces); - } - @Test public void testIsAbstract() throws Exception { Resource testSubject; @@ -164,47 +105,6 @@ public class ResourceTest extends ModelConfDependentTest { testSubject.setLicenseType(licenseType); } - @Test - public void testHashCode() throws Exception { - Resource testSubject; - int result; - - // default test - testSubject = createTestSubject(); - result = testSubject.hashCode(); - } - - @Test - public void testEquals() throws Exception { - Resource testSubject; - Object obj = null; - boolean result; - - // test 1 - testSubject = createTestSubject(); - result = testSubject.equals(obj); - Assert.assertEquals(false, result); - obj = new Object(); - result = testSubject.equals(obj); - Assert.assertEquals(false, result); - result = testSubject.equals(testSubject); - Assert.assertEquals(true, result); - - Resource testSubject2 = createTestSubject(); - result = testSubject.equals(testSubject2); - Assert.assertEquals(true, result); - } - - @Test - public void testToString() throws Exception { - Resource testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } - @Test public void testGetToscaResourceName() throws Exception { Resource testSubject; diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeTypeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeTypeTest.java index 011214a7c9..9473b1cd45 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeTypeTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeTypeTest.java @@ -20,16 +20,8 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.datamodel; -import java.util.List; -import java.util.Map; - -import org.junit.Test; -import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class NodeTypeTest { @@ -37,157 +29,14 @@ public class NodeTypeTest { return new NodeType(); } - - @Test - public void testGetDerivedList() throws Exception { - NodeType testSubject; - List result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDerivedList(); - } - - - @Test - public void testSetDerivedList() throws Exception { - NodeType testSubject; - List derivedList = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDerivedList(derivedList); - } - - - @Test - public void testGetDerivedFrom() throws Exception { - NodeType testSubject; - List result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDerivedFrom(); - } - - - @Test - public void testSetDerivedFrom() throws Exception { - NodeType testSubject; - List derivedFrom = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDerivedFrom(derivedFrom); - } - - - @Test - public void testGetAttributes() throws Exception { - NodeType testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAttributes(); - } - - - @Test - public void testSetAttributes() throws Exception { - NodeType testSubject; - Map attributes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setAttributes(attributes); - } - - - @Test - public void testGetCapabilties() throws Exception { - NodeType testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilities(); - } - - - @Test - public void testSetCapabilties() throws Exception { - NodeType testSubject; - Map capabilties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCapabilities(capabilties); - } - - - @Test - public void testGetRequirements() throws Exception { - NodeType testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRequirements(); - } - - - @Test - public void testSetRequirements() throws Exception { - NodeType testSubject; - Map requirements = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRequirements(requirements); - } - - - @Test - public void testGetCapabiltiesProperties() throws Exception { - NodeType testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilitiesProperties(); - } - - @Test - public void testSetCapabiltiesProperties() throws Exception { + public void testCTOR() throws Exception { NodeType testSubject; - Map capabiltiesProperties = null; // default test testSubject = createTestSubject(); - testSubject.setCapabilitiesProperties(capabiltiesProperties); + Assertions.assertNotNull(testSubject); + Assertions.assertEquals(ToscaElementTypeEnum.NODE_TYPE, testSubject.getToscaType()); } - - @Test - public void testGetInterfaceArtifacts() throws Exception { - NodeType testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInterfaceArtifacts(); - } - - - @Test - public void testSetInterfaceArtifacts() throws Exception { - NodeType testSubject; - Map interfaceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInterfaceArtifacts(interfaceArtifacts); - } } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplateTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplateTest.java index 4ea05e5925..d9beb9d644 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplateTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplateTest.java @@ -26,388 +26,12 @@ import org.junit.Test; import org.openecomp.sdc.be.datatypes.elements.*; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class TopologyTemplateTest { private TopologyTemplate createTestSubject() { return new TopologyTemplate(); } - - @Test - public void testGetInputs() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInputs(); - } - - - @Test - public void testSetInputs() throws Exception { - TopologyTemplate testSubject; - Map inputs = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInputs(inputs); - } - - - @Test - public void testGetInstInputs() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstInputs(); - } - - - @Test - public void testSetInstInputs() throws Exception { - TopologyTemplate testSubject; - Map instInputs = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstInputs(instInputs); - } - - - @Test - public void testGetHeatParameters() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHeatParameters(); - } - - - @Test - public void testSetHeatParameters() throws Exception { - TopologyTemplate testSubject; - Map heatParameters = null; - - // default test - testSubject = createTestSubject(); - testSubject.setHeatParameters(heatParameters); - } - - - @Test - public void testGetInstAttributes() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstAttributes(); - } - - - @Test - public void testSetInstAttributes() throws Exception { - TopologyTemplate testSubject; - Map instAttributes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstAttributes(instAttributes); - } - - - @Test - public void testGetInstProperties() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstProperties(); - } - - - @Test - public void testSetInstProperties() throws Exception { - TopologyTemplate testSubject; - Map instProperties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstProperties(instProperties); - } - - - @Test - public void testGetGroups() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getGroups(); - } - - - @Test - public void testSetGroups() throws Exception { - TopologyTemplate testSubject; - Map groups = null; - - // default test - testSubject = createTestSubject(); - testSubject.setGroups(groups); - } - - - @Test - public void testGetInstGroups() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstGroups(); - } - - - @Test - public void testSetInstGroups() throws Exception { - TopologyTemplate testSubject; - Map instGroups = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstGroups(instGroups); - } - - - @Test - public void testGetServiceApiArtifacts() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceApiArtifacts(); - } - - - @Test - public void testSetServiceApiArtifacts() throws Exception { - TopologyTemplate testSubject; - Map serviceApiArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceApiArtifacts(serviceApiArtifacts); - } - - - @Test - public void testGetCompositions() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCompositions(); - } - - - @Test - public void testSetCompositions() throws Exception { - TopologyTemplate testSubject; - Map compositions = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCompositions(compositions); - } - - - @Test - public void testGetCalculatedCapabilities() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCalculatedCapabilities(); - } - - - @Test - public void testSetCalculatedCapabilities() throws Exception { - TopologyTemplate testSubject; - Map calculatedCapabilities = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCalculatedCapabilities(calculatedCapabilities); - } - - - @Test - public void testGetCalculatedRequirements() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCalculatedRequirements(); - } - - - @Test - public void testSetCalculatedRequirements() throws Exception { - TopologyTemplate testSubject; - Map calculatedRequirements = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCalculatedRequirements(calculatedRequirements); - } - - - @Test - public void testGetFullfilledCapabilities() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getFullfilledCapabilities(); - } - - - @Test - public void testSetFullfilledCapabilities() throws Exception { - TopologyTemplate testSubject; - Map fullfilledCapabilities = null; - - // default test - testSubject = createTestSubject(); - testSubject.setFullfilledCapabilities(fullfilledCapabilities); - } - - - @Test - public void testGetFullfilledRequirements() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getFullfilledRequirements(); - } - - - @Test - public void testSetFullfilledRequirements() throws Exception { - TopologyTemplate testSubject; - Map fullfilledRequirements = null; - - // default test - testSubject = createTestSubject(); - testSubject.setFullfilledRequirements(fullfilledRequirements); - } - - - @Test - public void testGetInstDeploymentArtifacts() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstDeploymentArtifacts(); - } - - - @Test - public void testSetInstDeploymentArtifacts() throws Exception { - TopologyTemplate testSubject; - Map instDeploymentArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstDeploymentArtifacts(instDeploymentArtifacts); - } - - - @Test - public void testGetCalculatedCapabilitiesProperties() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCalculatedCapabilitiesProperties(); - } - - - @Test - public void testSetCalculatedCapabilitiesProperties() throws Exception { - TopologyTemplate testSubject; - Map calculatedCapabilitiesProperties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCalculatedCapabilitiesProperties(calculatedCapabilitiesProperties); - } - - - @Test - public void testGetInstanceArtifacts() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInstanceArtifacts(); - } - - - @Test - public void testSetInstanceArtifacts() throws Exception { - TopologyTemplate testSubject; - Map instanceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInstanceArtifacts(instanceArtifacts); - } - - - @Test - public void testGetDataTypes() throws Exception { - TopologyTemplate testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDataTypes(); - } - - - @Test - public void testSetDataTypes() throws Exception { - TopologyTemplate testSubject; - Map dataTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDataTypes(dataTypes); - } - - @Test public void testGetComponentInstances() throws Exception { TopologyTemplate testSubject; @@ -418,7 +42,6 @@ public class TopologyTemplateTest { result = testSubject.getComponentInstances(); } - @Test public void testSetComponentInstances() throws Exception { TopologyTemplate testSubject; @@ -429,7 +52,6 @@ public class TopologyTemplateTest { testSubject.setComponentInstances(instances); } - @Test public void testGetRelations() throws Exception { TopologyTemplate testSubject; -- cgit 1.2.3-korg